From 4a61a0f8a749831b74aca04302a30ebbbb6f5586 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Tue, 13 Oct 2026 16:23:07 +0300 Subject: Track pointer capture by its result in the game example The game assumed yasl_surface_set_pointer_mode() always succeeded, so on backends without relative mode it believed the pointer was captured. Co-Authored-By: Claude Opus 5.5 --- examples/game.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/game.c b/examples/game.c index 065ff99..4517519 100644 --- a/examples/game.c +++ b/examples/game.c @@ -186,10 +186,11 @@ static enum yasl_app_result on_event(void *ud, const struct yasl_event *ev) case YASL_KEY_E: game->key_e = down; break; case YASL_KEY_SPACE: if (ev->key.action == YASL_KEY_PRESS) { - /* Toggle relative pointer mode */ - game->relative_mouse = !game->relative_mouse; - yasl_surface_set_pointer_mode(game->surface, - game->relative_mouse ? YASL_POINTER_RELATIVE : YASL_POINTER_NORMAL); + /* Toggle relative pointer mode; unsupported backends stay normal. */ + game->relative_mouse = !game->relative_mouse && + yasl_surface_set_pointer_mode(game->surface, YASL_POINTER_RELATIVE); + if (!game->relative_mouse) + yasl_surface_set_pointer_mode(game->surface, YASL_POINTER_NORMAL); } break; case YASL_KEY_ESCAPE: @@ -221,8 +222,8 @@ static enum yasl_app_result on_event(void *ud, const struct yasl_event *ev) case YASL_EVENT_POINTER_DOWN: if (!game->relative_mouse) { /* Click window to capture cursor */ - game->relative_mouse = true; - yasl_surface_set_pointer_mode(game->surface, YASL_POINTER_RELATIVE); + game->relative_mouse = + yasl_surface_set_pointer_mode(game->surface, YASL_POINTER_RELATIVE); } break; -- cgit v1.2.3