diff options
| author | 2024-01-20 16:27:51 -0500 | |
|---|---|---|
| committer | 2024-01-20 16:27:51 -0500 | |
| commit | d8699c50f808f99b6cbec981a4d02fd6ed32cc6a (patch) | |
| tree | 8004a64ff166eb50f8639f08f029bffe18172850 | |
| parent | 4565c5a2fc23049a29d20226a6b0a4368d2f55ef (diff) | |
| download | stela-d8699c50f808f99b6cbec981a4d02fd6ed32cc6a.tar.gz stela-d8699c50f808f99b6cbec981a4d02fd6ed32cc6a.tar.bz2 stela-d8699c50f808f99b6cbec981a4d02fd6ed32cc6a.zip | |
Various fixes
Signed-off-by: Andrew Opalach <andrew@akon.city>
| -rw-r--r-- | include/skh/gl.h | 3 | ||||
| -rw-r--r-- | meson.build | 26 | ||||
| -rw-r--r-- | meson_options.txt | 4 | ||||
| -rw-r--r-- | src/common.h | 14 | ||||
| -rw-r--r-- | src/gl_versions.h | 2 | ||||
| -rw-r--r-- | src/poll_common.c | 10 | ||||
| -rw-r--r-- | src/poll_common.h | 3 | ||||
| -rw-r--r-- | src/window_glfw.c | 2 | ||||
| -rw-r--r-- | src/window_glfw.h | 4 | ||||
| -rw-r--r-- | src/window_wayland.c | 39 | ||||
| -rw-r--r-- | src/window_wayland.h | 3 | ||||
| -rw-r--r-- | subprojects/glfw3.wrap | 1 | ||||
| -rw-r--r-- | subprojects/packagefiles/vulkan/meson.build | 2 | ||||
| -rw-r--r-- | subprojects/vulkan.wrap | 2 |
14 files changed, 75 insertions, 40 deletions
diff --git a/include/skh/gl.h b/include/skh/gl.h new file mode 100644 index 0000000..5b9185a --- /dev/null +++ b/include/skh/gl.h @@ -0,0 +1,3 @@ +#pragma once + +#include "../../src/gl_common.h" diff --git a/meson.build b/meson.build index 27bc428..7999d21 100644 --- a/meson.build +++ b/meson.build @@ -13,11 +13,15 @@ is_macos = host_machine.system() == 'darwin' alabaster = subproject('libalabaster').get_variable('alabaster') akiyo = subproject('libakiyo', default_options: ['event-loop=disabled']).get_variable('akiyo') -sekihi_src = ['src/sekihi.c', 'src/poll_common.c', 'src/window.c'] +sekihi_src = ['src/sekihi.c', 'src/window.c'] sekihi_inc = [include_directories('include')] sekihi_deps = [alabaster, akiyo] sekihi_args = [] +if get_option('window') in ['x11', 'wayland'] + sekihi_src += ['src/poll_common.c'] +endif + if get_option('poll') == 'inline' sekihi_args += ['-DSEKIHI_POLL_INLINE'] elif get_option('poll') == 'fd' @@ -33,7 +37,7 @@ if get_option('pause') endif if get_option('api') == 'opengl' - use_glad = true + use_glad = false if use_glad sekihi_deps += [subproject('glad').get_variable('glad')] sekihi_args += ['-DSEKIHI_USE_GLAD'] @@ -52,7 +56,7 @@ if get_option('api') == 'opengl' endif elif get_option('api') == 'vulkan' vulkan = dependency('vulkan') - vulkan_headers = vulkan.partial_dependency(includes: true, compile_args: true) + vulkan_headers = vulkan.partial_dependency(includes: true, compile_args: true, link_args: true) sekihi_deps += [vulkan_headers] sekihi_args += ['-DSEKIHI_API_VULKAN'] endif @@ -71,7 +75,7 @@ if get_option('window') == 'glfw' glfw_opts.add_cmake_defines({ 'GLFW_BUILD_X11': is_linux }) glfw_opts.add_cmake_defines({ 'GLFW_BUILD_WIN32': is_windows }) glfw_opts.add_cmake_defines({ 'GLFW_BUILD_COCAO': is_macos }) - glfw3 = cmake.subproject('glfw3', options: glfw_opts).dependency('glfw3') + glfw3 = cmake.subproject('glfw3', options: glfw_opts).dependency('glfw') endif sekihi_src += ['src/window_glfw.c'] sekihi_deps += [glfw3] @@ -85,6 +89,7 @@ elif get_option('window') == 'x11' sekihi_args += ['-DSEKIHI_WINDOW_X11'] elif get_option('window') == 'wayland' wl_client = dependency('wayland-client') + wl_cursor = dependency('wayland-cursor') wl_egl = dependency('wayland-egl') wl_protocols = dependency('wayland-protocols', required: false) if not wl_protocols.found() @@ -109,6 +114,10 @@ elif get_option('window') == 'wayland' wl_protocols_datadir + '/stable/xdg-shell/xdg-shell.xml'), scanner_private_code.process( wl_protocols_datadir + '/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml'), + scanner_private_code.process( + wl_protocols_datadir + '/unstable/tablet/tablet-unstable-v2.xml'), + scanner_private_code.process( + wl_protocols_datadir + '/staging/cursor-shape/cursor-shape-v1.xml'), #scanner_private_code.process( # wl_protocols_datadir + '/unstable/xdg-output/xdg-output-unstable-v1.xml'), scanner_private_code.process( @@ -123,6 +132,10 @@ elif get_option('window') == 'wayland' wl_protocols_datadir + '/stable/xdg-shell/xdg-shell.xml'), scanner_client_header.process( wl_protocols_datadir + '/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml'), + scanner_client_header.process( + wl_protocols_datadir + '/unstable/tablet/tablet-unstable-v2.xml'), + scanner_client_header.process( + wl_protocols_datadir + '/staging/cursor-shape/cursor-shape-v1.xml'), #scanner_client_header.process( # wl_protocols_datadir + '/unstable/xdg-output/xdg-output-unstable-v1.xml'), scanner_client_header.process( @@ -133,7 +146,7 @@ elif get_option('window') == 'wayland' # wlr_protocols_datadir + '/unstable/wlr-foreign-toplevel-management-unstable-v1.xml') ] lib_protocols = static_library( - 'protocols', protocols_src + protocols_headers, dependencies: wl_client) + 'protocols', protocols_src + protocols_headers, dependencies: [wl_client, wl_cursor]) protocols = declare_dependency(link_with: lib_protocols, sources: protocols_headers) sekihi_src += ['src/window_wayland.c'] sekihi_deps += [wl_egl, protocols] @@ -145,6 +158,5 @@ sekihi = declare_dependency(include_directories: sekihi_inc, compile_args: sekihi_args) if not meson.is_subproject() - sekihi_lib = shared_library('sekihi', [], - gnu_symbol_visibility: 'hidden', dependencies: sekihi, install: false) + sekihi_lib = shared_library('sekihi', dependencies: sekihi, install: false) endif diff --git a/meson_options.txt b/meson_options.txt index 8eed019..d84eace 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,5 +1,5 @@ option('api', type: 'combo', choices: ['opengl', 'vulkan', 'dx11'], value: 'opengl') -option('window', type: 'combo', choices: ['glfw', 'wayland', 'x11'], value: 'glfw') +option('window', type: 'combo', choices: ['glfw', 'wayland', 'x11'], value: 'wayland') option('poll', type: 'combo', choices: ['inline', 'fd'], value: 'inline') option('event-buffer', type: 'boolean', value: false) -option('pause', type: 'boolean', value: false) +option('pause', type: 'boolean', value: true) diff --git a/src/common.h b/src/common.h new file mode 100644 index 0000000..2ccc502 --- /dev/null +++ b/src/common.h @@ -0,0 +1,14 @@ +#pragma once + +#include "window.h" + +#if defined SEKIHI_PAUSE +static bool skh_should_refresh_common(struct skh_window *window) +{ + if (window->pending_refresh) { + window->pending_refresh = false; + return true; + } + return false; +} +#endif diff --git a/src/gl_versions.h b/src/gl_versions.h index c90f319..e999682 100644 --- a/src/gl_versions.h +++ b/src/gl_versions.h @@ -1,7 +1,5 @@ #pragma once -#include "egl_common.h" - // https://github.com/haasn/libplacebo/blob/795600a44b03fcd52c055981a403ad60ee5d027a/demos/window_glfw.c#L194 #ifdef SEKIHI_USE_GLES #define PASTE_GL_VERSIONS() static struct { \ diff --git a/src/poll_common.c b/src/poll_common.c index 1d18f84..965bf1d 100644 --- a/src/poll_common.c +++ b/src/poll_common.c @@ -57,13 +57,3 @@ bool skh_process_events_common(struct aki_pollfd *fds) #endif } -#if defined SEKIHI_PAUSE -bool skh_should_refresh_common(struct skh_window *window) -{ - if (window->pending_refresh) { - window->pending_refresh = false; - return true; - } - return false; -} -#endif diff --git a/src/poll_common.h b/src/poll_common.h index 69dc536..c4ff4ea 100644 --- a/src/poll_common.h +++ b/src/poll_common.h @@ -11,6 +11,3 @@ void skh_wake_common(struct skh_window *window, struct aki_pollfd *fds); #endif #endif bool skh_process_events_common(struct aki_pollfd *fds); -#if defined SEKIHI_PAUSE -bool skh_should_refresh_common(struct skh_window *window); -#endif diff --git a/src/window_glfw.c b/src/window_glfw.c index 64b8d67..2d8b673 100644 --- a/src/window_glfw.c +++ b/src/window_glfw.c @@ -2,7 +2,7 @@ #include <al/log.h> #include "window_glfw.h" -#include "poll_common.h" +#include "common.h" #if defined SEKIHI_API_OPENGL #define SEKIHI_GL_API GLFW_OPENGL_API diff --git a/src/window_glfw.h b/src/window_glfw.h index cead8ff..c352a9b 100644 --- a/src/window_glfw.h +++ b/src/window_glfw.h @@ -2,8 +2,8 @@ #if defined SEKIHI_API_VULKAN #define GLFW_INCLUDE_VULKAN -#elif defined SEKIHI_API_OPENGL -#include "egl_common.h" +#else +#include "gl_common.h" #endif #include <GLFW/glfw3.h> #ifndef _WIN32 diff --git a/src/window_wayland.c b/src/window_wayland.c index 51d2a7c..0bf1c47 100644 --- a/src/window_wayland.c +++ b/src/window_wayland.c @@ -2,6 +2,7 @@ #include <al/lib.h> #include "window_wayland.h" +#include "common.h" #include "poll_common.h" static void xdg_wm_base_ping(void *data, struct xdg_wm_base *shell, u32 serial) @@ -19,12 +20,14 @@ static void pointer_enter(void *data, struct wl_pointer *pointer, { struct skh_window_wayland *wl = (struct skh_window_wayland *)data; (void)pointer; - (void)serial; (void)surface; wl->pointer_x = wl_fixed_to_double(surface_x); wl->pointer_y = wl_fixed_to_double(surface_y); wl->last_pointer_x = wl->pointer_x; wl->last_pointer_y = wl->pointer_y; + if (wl->cursor_shape_device) { + wp_cursor_shape_device_v1_set_shape(wl->cursor_shape_device, serial, WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DEFAULT); + } } static void pointer_leave(void *data, struct wl_pointer *pointer, @@ -213,6 +216,9 @@ static void seat_capabilities(void *data, struct wl_seat *seat, u32 capabilities if (capabilities & WL_SEAT_CAPABILITY_POINTER) { if (!wl->pointer) { wl->pointer = wl_seat_get_pointer(wl->seat); + if (wl->cursor_shape) { + wl->cursor_shape_device = wp_cursor_shape_manager_v1_get_pointer(wl->cursor_shape, wl->pointer); + } wl_pointer_add_listener(wl->pointer, &pointer_listener, wl); } } else { @@ -435,6 +441,8 @@ static void global_add(void *data, struct wl_registry *registry, u32 name, xdg_wm_base_add_listener(wl->xdg_wm_base, &xdg_wm_base_listener, wl); } else if (strcmp(interface, zxdg_decoration_manager_v1_interface.name) == 0) { wl->zxdg_decoration_manager = wl_registry_bind(registry, name, &zxdg_decoration_manager_v1_interface, AL_MIN(1u, version)); + } else if (strcmp(interface, wp_cursor_shape_manager_v1_interface.name) == 0) { + wl->cursor_shape = wl_registry_bind(registry, name, &wp_cursor_shape_manager_v1_interface, AL_MIN(1u, version)); } else if (strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) { wl->layer_shell = wl_registry_bind(registry, name, &zwlr_layer_shell_v1_interface, AL_MIN(4u, version)); } else if (strcmp(interface, wp_presentation_interface.name) == 0) { @@ -490,14 +498,14 @@ static const struct wl_surface_listener surface_listener = { .preferred_buffer_transform = preferred_buffer_transform }; -static bool check_new_dimensions(struct skh_window_wayland *wl, s32 width, s32 height) +static bool check_and_set_dimensions(struct skh_window_wayland *wl, s32 width, s32 height) { - if ((width && height) && (width != wl->w.width || height != wl->w.height)) { - wl->w.width = width; - wl->w.height = height; - return true; + if (!width || !height || (width == wl->w.width && height == wl->w.height)) { + return false; } - return false; + wl->w.width = width; + wl->w.height = height; + return true; } static void send_resize_internal(struct skh_window_wayland *wl) @@ -529,9 +537,7 @@ static void handle_xdg_toplevel_configure(void *data, struct xdg_toplevel *tople struct skh_window_wayland *wl = (struct skh_window_wayland *)data; (void)toplevel; (void)states; - if (check_new_dimensions(wl, width, height)) { - wl->pending = true; - } + wl->pending = check_and_set_dimensions(wl, width, height); } static void handle_xdg_toplevel_close(void *data, struct xdg_toplevel *toplevel) @@ -568,7 +574,7 @@ static void handle_layer_surface_configure(void *data, struct zwlr_layer_surface u32 serial, u32 width, u32 height) { struct skh_window_wayland *wl = (struct skh_window_wayland *)data; - if (check_new_dimensions(wl, width, height)) { + if (check_and_set_dimensions(wl, width, height)) { send_resize_internal(wl); } zwlr_layer_surface_v1_ack_configure(surface, serial); @@ -719,6 +725,17 @@ static bool window_wayland_create_window(struct skh_window *window, s32 width, s wl_surface_commit(wl->surface); wl_display_roundtrip(wl->display); + /* + struct wl_cursor_theme *cursor_theme = wl_cursor_theme_load(NULL, 24, shm); + struct wl_cursor *cursor = wl_cursor_theme_get_cursor(cursor_theme, "left_ptr"); + wl->cursor.image = cursor->images[0]; + struct wl_buffer *cursor_buffer = wl_cursor_image_get_buffer(wl->cursor.image); + + wl->cursor.surface = wl_compositor_create_surface(wl->compositor); + wl_surface_attach(wl->cursor.surface, cursor_buffer, 0, 0); + wl_surface_commit(wl->cursor.surface); + */ + skh_egl_make_current(&wl->egl); skh_egl_swap_interval(&wl->egl, (wl->flags & SEKIHI_WINDOW_VSYNC) ? 1 : 0); skh_egl_release_current(&wl->egl); diff --git a/src/window_wayland.h b/src/window_wayland.h index af5eac6..3f0acf2 100644 --- a/src/window_wayland.h +++ b/src/window_wayland.h @@ -9,6 +9,7 @@ #include <wayland-egl.h> #include <xdg-shell-client-protocol.h> #include <xdg-decoration-unstable-v1-client-protocol.h> +#include <cursor-shape-v1-client-protocol.h> //#include <xdg-output-unstable-v1-client-protocol.h> //#include <wlr-foreign-toplevel-management-unstable-v1-client-protocol.h> #include <wlr-layer-shell-unstable-v1-client-protocol.h> @@ -40,6 +41,8 @@ struct skh_window_wayland { struct xdg_surface *xdg_surface; struct xdg_toplevel *xdg_toplevel; struct zxdg_decoration_manager_v1 *zxdg_decoration_manager; + struct wp_cursor_shape_manager_v1 *cursor_shape; + struct wp_cursor_shape_device_v1 *cursor_shape_device; struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration; struct zwlr_layer_shell_v1 *layer_shell; struct skh_monitor_wayland *monitor; diff --git a/subprojects/glfw3.wrap b/subprojects/glfw3.wrap index f0cffe1..1612e20 100644 --- a/subprojects/glfw3.wrap +++ b/subprojects/glfw3.wrap @@ -2,3 +2,4 @@ url = https://github.com/glfw/glfw.git revision = 46cebb5081820418f2a20f3e90b07f9b1bd44b42 depth = 1 +method = cmake diff --git a/subprojects/packagefiles/vulkan/meson.build b/subprojects/packagefiles/vulkan/meson.build index 722ea11..f83e5e8 100644 --- a/subprojects/packagefiles/vulkan/meson.build +++ b/subprojects/packagefiles/vulkan/meson.build @@ -1,3 +1,3 @@ -project('vulkan', 'c', version: '1.3.261') +project('vulkan', 'c', version: '1.3.243') vulkan = declare_dependency(include_directories: include_directories('include')) meson.override_dependency('vulkan', vulkan) diff --git a/subprojects/vulkan.wrap b/subprojects/vulkan.wrap index e330da4..937d68c 100644 --- a/subprojects/vulkan.wrap +++ b/subprojects/vulkan.wrap @@ -1,6 +1,6 @@ [wrap-git] url = https://github.com/KhronosGroup/Vulkan-Headers.git -revision = v1.3.261 +revision = v1.3.243 depth = 1 patch_directory = vulkan |