winex11.drv: Ignore FocusOut event if new focus window does not exist.

Dmitry Timoshkov dmitry at codeweavers.com
Tue Mar 29 01:45:59 CDT 2011


This is a fix for the problem reported in the bug 26017 that the game
3D Pinball can't enter fullscreen mode correctly.

After pressing F4 Pinball game switches display mode to 640x480, and
resizes it main window to 640x480. There is no any other activity in
the application. But right after that the window receives FocusOut
event out of the air, which leads to WM_CANCELMODE and SetFocus(0), and
on WM_ACTIVATEAPP(0) the application restores screen resolution to default
leaving fullscreen mode.

In Wine logs there no any trace why that FocusOut event gets received, but
in the Metacity logs I see:

WINDOW_STATE: Received pending unmap, 0 now pending
FOCUS: Focus unmap event received on 0x4000004 (3D Pinball) 0x260022c (unknown window) mode n/a detail n/a
FOCUS: 0x4000004 (3D Pinball) is now the previous focus window due to being focused out or unmapped
FOCUS: * Focus --> NULL (was 0x4000004 (3D Pinball))
...
FOCUS: Focus got set to None, probably due to brain-damage in the X protocol (see bug 125492).  Setting the default focus window.

There is no any trace of the window 0x260022c in Metacity logs, and Metacity
itself can't recognize it and calls that window 'unknown'.
---
 dlls/winex11.drv/event.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c
index 6e4225c..1982c7a 100644
--- a/dlls/winex11.drv/event.c
+++ b/dlls/winex11.drv/event.c
@@ -706,6 +706,11 @@ static void X11DRV_FocusOut( HWND hwnd, XEvent *xev )
     if (event->detail == NotifyPointer) return;
     if (ximInComposeMode) return;
 
+    wine_tsx11_lock();
+    XGetInputFocus( event->display, &focus_win, &revert );
+    wine_tsx11_unlock();
+    if (!focus_win) return;
+
     x11drv_thread_data()->last_focus = hwnd;
     if ((xic = X11DRV_get_ic( hwnd )))
     {
-- 
1.7.4.1




More information about the wine-patches mailing list