From: Julian Smart Date: Mon, 16 Dec 2002 09:44:35 +0000 (+0000) Subject: Applied [ 654253 ] wxGTK: fix to wxGetMousePosition() X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/37d81cc2e2e27c640f22de52dcd4f2d936333372?ds=sidebyside Applied [ 654253 ] wxGTK: fix to wxGetMousePosition() wxGetMousePosition() returns -999, -999 when the mouse pointer is not over a GTK window. This is apparently because it uses the current window as a handle to get to the X display. This is not necessary, however; GDK_DISPLAY() can be used. With this patch wxGetMousePosition() works regardless of where on the screen the mouse is. Jay Berkenbilt (jay_berkenbilt) modified by JACS git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18250 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 2cee058d32..5208da0f59 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -4605,10 +4605,8 @@ wxPoint wxGetMousePosition() int x, y; GdkWindow* windowAtPtr = gdk_window_at_pointer(& x, & y); - if (!windowAtPtr) - return wxPoint(-999, -999); - Display *display = GDK_WINDOW_XDISPLAY(windowAtPtr); + Display *display = windowAtPtr ? GDK_WINDOW_XDISPLAY(windowAtPtr) : GDK_DISPLAY(); Window rootWindow = RootWindowOfScreen (DefaultScreenOfDisplay(display)); Window rootReturn, childReturn; int rootX, rootY, winX, winY; diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 2cee058d32..5208da0f59 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -4605,10 +4605,8 @@ wxPoint wxGetMousePosition() int x, y; GdkWindow* windowAtPtr = gdk_window_at_pointer(& x, & y); - if (!windowAtPtr) - return wxPoint(-999, -999); - Display *display = GDK_WINDOW_XDISPLAY(windowAtPtr); + Display *display = windowAtPtr ? GDK_WINDOW_XDISPLAY(windowAtPtr) : GDK_DISPLAY(); Window rootWindow = RootWindowOfScreen (DefaultScreenOfDisplay(display)); Window rootReturn, childReturn; int rootX, rootY, winX, winY;