From 7ac3c89f97e1145ae0912af3376f7b6ab678f34e Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Wed, 11 Nov 2009 14:37:51 -0600 Subject: [PATCH 2/3] winex11.drv: Allow explorer to focus other process windows. When explorer gets a take focus message, it tries to focus the foreground window, but this doesn't work because set_focus can only focus windows in the current process. We have to look for the focus window in the foreground thread, not the current one, or we won't find the other process's windows. Since the other process may crash at any time, causing its windows to be destroyed, we also have to ignore the BadWindow error that will occur if that happens at a critical time. --- dlls/winex11.drv/event.c | 4 +++- dlls/winex11.drv/x11drv_main.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 345b675..8c23203 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -476,11 +476,13 @@ static void set_focus( Display *display, HWND hwnd, Time time ) { HWND focus; Window win; + GUITHREADINFO threadinfo; TRACE( "setting foreground window to %p\n", hwnd ); SetForegroundWindow( hwnd ); - focus = GetFocus(); + GetGUIThreadInfo(0, &threadinfo); + focus = threadinfo.hwndFocus; if (focus) focus = GetAncestor( focus, GA_ROOT ); win = X11DRV_get_whole_window(focus); diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c index 8299457..b97426e 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -188,7 +188,8 @@ static const char * const atom_names[NB_XATOMS - FIRST_XATOM] = */ static inline BOOL ignore_error( Display *display, XErrorEvent *event ) { - if (event->request_code == X_SetInputFocus && event->error_code == BadMatch) return TRUE; + if (event->request_code == X_SetInputFocus && + (event->error_code == BadMatch || event->error_code == BadWindow)) return TRUE; /* ignore a number of errors on gdi display caused by creating/destroying windows */ if (display == gdi_display) -- 1.6.3.3