Vincent Povirk : winex11.drv: Allow explorer to focus other process windows .

Alexandre Julliard julliard at winehq.org
Thu Nov 12 10:22:11 CST 2009


Module: wine
Branch: master
Commit: 6823f4aaf8b91b729062573e4eef94f9e29b7792
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6823f4aaf8b91b729062573e4eef94f9e29b7792

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Wed Nov 11 14:37:51 2009 -0600

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)




More information about the wine-cvs mailing list