From: Thomas Debesse Date: Wed, 10 Mar 2021 07:08:09 +0000 (+0100) Subject: radiant/cursor: get the display from the widget, attempt to support multiple displays... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5be978bbdfa45b8c20c479f3c58d5c5566f7bcfe;p=xonotic%2Fnetradiant.git radiant/cursor: get the display from the widget, attempt to support multiple displays and screens --- diff --git a/libs/gtkutil/cursor.cpp b/libs/gtkutil/cursor.cpp index 9ada67e6..42b1123c 100644 --- a/libs/gtkutil/cursor.cpp +++ b/libs/gtkutil/cursor.cpp @@ -46,13 +46,15 @@ void default_cursor( ui::Widget widget ){ } void Sys_GetCursorPos( ui::Widget widget, int *x, int *y ){ - gdk_display_get_pointer( gdk_display_get_default(), 0, x, y, 0 ); + GdkDisplay *display = gtk_widget_get_display( GTK_WIDGET( widget ) ); + // No need to store the screen, it will be recovered from widget again. + gdk_display_get_pointer( display, NULL, x, y, NULL ); } void Sys_SetCursorPos( ui::Widget widget, int x, int y ){ - GdkScreen *screen; - gdk_display_get_pointer( gdk_display_get_default(), &screen, 0, 0, 0 ); - gdk_display_warp_pointer( gdk_display_get_default(), screen, x, y ); + GdkDisplay *display = gtk_widget_get_display( GTK_WIDGET( widget ) ); + GdkScreen *screen = gtk_widget_get_screen( GTK_WIDGET( widget ) ); + gdk_display_warp_pointer( display, screen, x, y ); } gboolean DeferredMotion::gtk_motion(ui::Widget widget, GdkEventMotion *event, DeferredMotion *self)