diff options
author | Campbell Barton <campbell@blender.org> | 2022-06-30 15:53:20 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-06-30 16:46:57 +0300 |
commit | 6bd2c6789b244a03bccdb254502567691c42b944 (patch) | |
tree | 264949e98f2d99a91e9a393c0cd3478ef1701a77 /source/blender/windowmanager/intern/wm_playanim.c | |
parent | df40e9d0aad0c2a5b649d99c25e991a3664501c5 (diff) |
GHOST: get/set cursor position now uses client instead of screen coords
Use client (window) relative coordinates for cursor position access,
this only moves the conversion from window-manager into GHOST,
(no functional changes).
This is needed for fix a bug in GHOST/Wayland which doesn't support
accessing absolute cursor coordinates & the window is needed to properly
access the cursor coordinates.
As it happens every caller to GHOST_GetCursorPosition was already making
the values window-relative, so there is little benefit in attempting to
workaround the problem on the Wayland side.
If needed the screen-space versions of functions can be exposed again.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_playanim.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_playanim.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index baba64b2230..99f117f267a 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -1217,8 +1217,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) GHOST_TEventButtonData *bd = GHOST_GetEventData(evt); int cx, cy, sizex, sizey, inside_window; - GHOST_GetCursorPosition(g_WS.ghost_system, &cx, &cy); - GHOST_ScreenToClient(g_WS.ghost_window, cx, cy, &cx, &cy); + GHOST_GetCursorPosition(g_WS.ghost_system, g_WS.ghost_window, &cx, &cy); playanim_window_get_size(&sizex, &sizey); inside_window = (cx >= 0 && cx < sizex && cy >= 0 && cy <= sizey); @@ -1267,15 +1266,15 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) * however the API currently doesn't support this. */ { int x_test, y_test; - GHOST_GetCursorPosition(g_WS.ghost_system, &x_test, &y_test); - if (x_test != cd->x || y_test != cd->y) { + GHOST_GetCursorPosition(g_WS.ghost_system, g_WS.ghost_window, &cx, &cy); + GHOST_ScreenToClient(g_WS.ghost_window, cd->x, cd->y, &x_test, &y_test); + + if (cx != x_test || cy != y_test) { /* we're not the last event... skipping */ break; } } - GHOST_ScreenToClient(g_WS.ghost_window, cd->x, cd->y, &cx, &cy); - tag_change_frame(ps, cx); } break; |