summaryrefslogtreecommitdiff
path: root/src/window_x11.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/window_x11.c')
-rw-r--r--src/window_x11.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/window_x11.c b/src/window_x11.c
index 17de7ae..6d9ef78 100644
--- a/src/window_x11.c
+++ b/src/window_x11.c
@@ -39,7 +39,7 @@ bool stl_global_init(bool skip_graphics)
if (!skip_graphics) {
#if defined STELA_API_VULKAN
- global.vk_extensions = (const char **)al_calloc(2, sizeof(const char *const *));
+ global.vk_extensions = (const char **)al_calloc(2, sizeof(const char *));
global.vk_extensions[0] = "VK_KHR_surface";
global.vk_extensions[1] = "VK_KHR_xlib_surface";
#elif defined STELA_API_OPENGL
@@ -60,14 +60,19 @@ bool stl_global_init(bool skip_graphics)
}
global.cursors[STELA_CURSOR_NORMAL] = None;
+ // Only cursors also defined by XC_* seem to work on Xwayland.
+ // https://tronche.com/gui/x/xlib/appendix/b/
+ global.cursors[STELA_CURSOR_CROSSHAIR] = XcursorLibraryLoadCursor(global.x11_d, "crosshair");
+ global.cursors[STELA_CURSOR_MOVE] = XcursorLibraryLoadCursor(global.x11_d, "hand2");
char *cursor_theme = XcursorGetTheme(global.x11_d);
s32 cursor_size = XcursorGetDefaultSize(global.x11_d);
- XcursorImage *image;
- if ((image = XcursorLibraryLoadImage("crosshair", cursor_theme, cursor_size))) {
+ XcursorImage *image = XcursorLibraryLoadImage("crosshair", cursor_theme, cursor_size);
+ if (image) {
global.cursors[STELA_CURSOR_CROSSHAIR] = XcursorImageLoadCursor(global.x11_d, image);
XcursorImageDestroy(image);
}
- if ((image = XcursorLibraryLoadImage("pointer", cursor_theme, cursor_size))) {
+ image = XcursorLibraryLoadImage("move", cursor_theme, cursor_size);
+ if (image) {
global.cursors[STELA_CURSOR_MOVE] = XcursorImageLoadCursor(global.x11_d, image);
XcursorImageDestroy(image);
}
@@ -535,7 +540,7 @@ static void handle_next_xevent(struct stl_window_x11 *xw)
case KeyRelease: {
KeySym sym = XkbKeycodeToKeysym(global.x11_d, xev.xkey.keycode, 0, 0);//(xev.xkey.state & ShiftMask) ? 1 : 0);
if (sym != NoSymbol) {
- u8 mapped_state = xev.type == KeyPress ? STELA_BUTTON_PRESSED : STELA_BUTTON_RELEASED;
+ u8 mapped_state = (xev.type == KeyPress) ? STELA_BUTTON_PRESSED : STELA_BUTTON_RELEASED;
u16 mapped_key = keysym_to_key(sym);
stl_window_send_key_immediate_event(&xw->w, mapped_state, mapped_key);
stl_window_send_key_event(&xw->w, mapped_state, mapped_key);
@@ -585,7 +590,7 @@ static void handle_next_xevent(struct stl_window_x11 *xw)
}
break;
case MotionNotify:
- stl_window_send_pointer_pos_event(&xw->w, (f64)xev.xmotion.x, (f64)xev.xmotion.y);
+ stl_window_send_pointer_event(&xw->w, STELA_POINTER_POS, (f64)xev.xmotion.x, (f64)xev.xmotion.y);
break;
case MapNotify:
break;
@@ -651,10 +656,10 @@ static VkResult window_x11_vk_destroy_surface(VkInstance inst, VkSurfaceKHR surf
return stl_vk_destroy_surface(inst, surface);
}
-static const char *const *window_x11_vk_get_extensions(u32 *num)
+static const char * const *window_x11_vk_get_extensions(u32 *num)
{
*num = 2;
- return global.vk_extensions;
+ return (const char * const *)global.vk_extensions;
}
#elif defined STELA_API_OPENGL
static bool window_x11_gl_loader_load(void *window)