summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common.h14
-rw-r--r--src/gl_versions.h2
-rw-r--r--src/poll_common.c10
-rw-r--r--src/poll_common.h3
-rw-r--r--src/window_glfw.c2
-rw-r--r--src/window_glfw.h4
-rw-r--r--src/window_wayland.c39
-rw-r--r--src/window_wayland.h3
8 files changed, 48 insertions, 29 deletions
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;