winex11.drv: reset focus if application does not want to be activated.

Lei Zhang thestig at google.com
Thu Jun 21 18:03:30 CDT 2007


Hi,

When an application does not want to be activated, we should go
through the same code path as though the application the application
window cannot be activated.

The test program [1] for bug 8706 can be used to test the window behavior.

[1] http://bugs.winehq.org/attachment.cgi?id=6753&action=view
-------------- next part --------------
From f299fcb8c98b57db580c1ec89dac21d7cf0ace7e Mon Sep 17 00:00:00 2001
From: Lei Zhang <thestig at google.com>
Date: Thu, 21 Jun 2007 15:38:00 -0700
Subject: [PATCH] winex11.drv: reset focus if application does not want to be activated.
---
 dlls/winex11.drv/event.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c
index f13e079..bc3f446 100644
--- a/dlls/winex11.drv/event.c
+++ b/dlls/winex11.drv/event.c
@@ -433,12 +433,13 @@ static void handle_wm_protocols( HWND hw
     {
         Time event_time = (Time)event->data.l[1];
         HWND last_focus = x11drv_thread_data()->last_focus;
+        BOOL can_activate = can_activate_window(hwnd);
 
         TRACE( "got take focus msg for %p, enabled=%d, visible=%d (style %08x), focus=%p, active=%p, fg=%p, last=%p\n",
                hwnd, IsWindowEnabled(hwnd), IsWindowVisible(hwnd), GetWindowLongW(hwnd, GWL_STYLE),
                GetFocus(), GetActiveWindow(), GetForegroundWindow(), last_focus );
 
-        if (can_activate_window(hwnd))
+        if (can_activate)
         {
             /* simulate a mouse click on the caption to find out
              * whether the window wants to be activated */
@@ -446,9 +447,14 @@ static void handle_wm_protocols( HWND hw
                                        (WPARAM)GetAncestor( hwnd, GA_ROOT ),
                                        MAKELONG(HTCAPTION,WM_LBUTTONDOWN) );
             if (ma != MA_NOACTIVATEANDEAT && ma != MA_NOACTIVATE) set_focus( hwnd, event_time );
-            else TRACE( "not setting focus to %p (%lx), ma=%ld\n", hwnd, event->window, ma );
+            else
+            {
+                can_activate = FALSE;
+                TRACE( "not setting focus to %p (%lx), ma=%ld\n", hwnd, event->window, ma );
+            }
         }
-        else
+
+        if (!can_activate)
         {
             hwnd = GetFocus();
             if (hwnd) hwnd = GetAncestor( hwnd, GA_ROOT );
-- 
1.4.1


More information about the wine-patches mailing list