From 4febf1174f9005ac7a86e3faf5c152c71844dae3 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Mon, 16 Dec 2002 09:44:35 +0000 Subject: [PATCH] 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/branches/WX_2_4_BRANCH@18250 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/window.cpp | 4 +--- src/gtk1/window.cpp | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index bf5f12cdb8..36b4fbc8e9 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -4591,10 +4591,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 bf5f12cdb8..36b4fbc8e9 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -4591,10 +4591,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;