winex11.drv: send WM_MOUSEACTIVATE before closing a window (try 3)
Lei Zhang
thestig at google.com
Mon Jun 18 16:08:32 CDT 2007
Hi,
On Windows, clicking the close button of a nonactive window generates
a WM_MOUSEACTIVATE notification. Applications with custom window
procedures can then choose to ignore the close button if they wished
to by returning MA_ACTIVATEANDEAT / MA_NOACTIVATEANDEAT.
This patch sends WM_MOUSEACTIVATE and honors the MA_*ANDEAT return
values. It differs from the last attempt in that:
- it just sets the active window rather than changing the focus
- it sends the correct lparam value in WM_MOUSEACTIVATE
- it replaced two return value checking if statements with a switch block.
-------------- next part --------------
From fdaec030a303d50f3196b6b509be87de31903273 Mon Sep 17 00:00:00 2001
From: Lei Zhang <thestig at google.com>
Date: Mon, 18 Jun 2007 14:00:04 -0700
Subject: [PATCH] winex11.drv: send WM_MOUSEACTIVATE before closing a window
---
dlls/winex11.drv/event.c | 28 +++++++++++++++++++++++++++-
1 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c
index e3047fd..03a7ab9 100644
--- a/dlls/winex11.drv/event.c
+++ b/dlls/winex11.drv/event.c
@@ -396,6 +396,7 @@ static void handle_wm_protocols( HWND hw
if (IsWindowEnabled(hwnd))
{
HMENU hSysMenu;
+ BOOL close = TRUE;
if (GetClassLongW(hwnd, GCL_STYLE) & CS_NOCLOSE) return;
hSysMenu = GetSystemMenu(hwnd, FALSE);
@@ -405,7 +406,32 @@ static void handle_wm_protocols( HWND hw
if (state == 0xFFFFFFFF || (state & (MF_DISABLED | MF_GRAYED)))
return;
}
- PostMessageW( hwnd, WM_X11DRV_DELETE_WINDOW, 0, 0 );
+ if (GetActiveWindow() != hwnd)
+ {
+ LRESULT ma = SendMessageW( hwnd, WM_MOUSEACTIVATE,
+ (WPARAM)GetAncestor( hwnd, GA_ROOT ),
+ MAKELONG(HTCLOSE,WM_LBUTTONDOWN) );
+ switch(ma)
+ {
+ case MA_NOACTIVATEANDEAT:
+ close = FALSE;
+ /* fall through */
+ case MA_NOACTIVATE:
+ break;
+ case MA_ACTIVATEANDEAT:
+ close = FALSE;
+ /* fall through */
+ case MA_ACTIVATE:
+ case 0:
+ SetActiveWindow(hwnd);
+ break;
+ default:
+ WARN( "unknown WM_MOUSEACTIVATE code %d\n", (int) ma );
+ break;
+ }
+ }
+ if (close)
+ PostMessageW( hwnd, WM_X11DRV_DELETE_WINDOW, 0, 0 );
}
}
else if (protocol == x11drv_atom(WM_TAKE_FOCUS))
--
1.4.1
More information about the wine-patches
mailing list