From 88b8c80c2bc64579aa1c36c1825fb8c7377f7742 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 3 Jan 2025 02:27:20 +0100 Subject: A little bit of glitch fixing, warp cursor after hiding ui when XI grabbing --- src/Overlay.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/Overlay.cpp') diff --git a/src/Overlay.cpp b/src/Overlay.cpp index 896f611..e736627 100644 --- a/src/Overlay.cpp +++ b/src/Overlay.cpp @@ -1115,8 +1115,6 @@ namespace gsr { XFlush(display); if(xi_display) { - XFixesShowCursor(xi_display, DefaultRootWindow(xi_display)); - XFlush(xi_display); cursor_texture.clear(); cursor_sprite.set_texture(nullptr); } @@ -1142,6 +1140,18 @@ namespace gsr { if(xi_display) { XCloseDisplay(xi_display); xi_display = nullptr; + + if(window) { + mgl_context *context = mgl_get_context(); + Display *display = (Display*)context->connection; + + const mgl::vec2i new_cursor_position = mgl::vec2i(window->internal_window()->pos.x, window->internal_window()->pos.y) + window->get_mouse_position(); + XWarpPointer(display, DefaultRootWindow(display), DefaultRootWindow(display), 0, 0, 0, 0, new_cursor_position.x, new_cursor_position.y); + XFlush(display); + + XFixesShowCursor(display, DefaultRootWindow(display)); + XFlush(display); + } } if(window) { -- cgit v1.2.3