From b358280c23da301970c3cf2e721829e0684b1614 Mon Sep 17 00:00:00 2001 From: Adam Fedor Date: Sat, 27 Dec 2003 01:06:19 +0000 Subject: [PATCH] Focus fixes for w32 git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@18277 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 10 ++++++ Documentation/Back/DefaultsSummary.gsdoc | 11 +++++++ Headers/win32/WIN32Server.h | 4 +++ Source/win32/WIN32Server.m | 41 +++++++++++++++++++++++- Source/win32/WIN32ServerEvent.m | 19 +++++++++-- 5 files changed, 81 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index f359295..52574ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2003-12-26 Adam Fedor + + * Focus fixes. + * Headers/win32/WIN32Server.h: Add flags ivar + * Source/win32/WIN32Server.m (orderwindow:::): If useWMTaskBar + flag set, don't show app icon and don't order out menu window. + * Source/win32/WIN32ServerEvent.m (windowEventProc:::): + On activation message, activate app, on deactivation message, + deactivate app (if message comes from menu window). + 2003-12-25 Fred Kiefer * Source/win32/WIN32Server.m (-_initWin32Context) set a default diff --git a/Documentation/Back/DefaultsSummary.gsdoc b/Documentation/Back/DefaultsSummary.gsdoc index 06374c0..429999b 100644 --- a/Documentation/Back/DefaultsSummary.gsdoc +++ b/Documentation/Back/DefaultsSummary.gsdoc @@ -83,6 +83,17 @@ problem with the X-Server.

+ + GSUseWMTaskBar + +

[W32 backend only] + A string value which defaults to YES. If enabled, the + backend assumes that miniwindows are displayed in a task bar. In + this case, the app icon is not shown and the main menu behavior + is changed so it is not ordered out, but minimized, so clicking + on the minimized menu will activate the application. +

+
GSXEnableFontSet

A string value which defaults to NO. If set to diff --git a/Headers/win32/WIN32Server.h b/Headers/win32/WIN32Server.h index 11c72d8..2de71b4 100644 --- a/Headers/win32/WIN32Server.h +++ b/Headers/win32/WIN32Server.h @@ -36,6 +36,10 @@ HWND currentFocus; HWND desiredFocus; HWND currentActive; + + struct { + BOOL useWMTaskBar; + } flags; } @end diff --git a/Source/win32/WIN32Server.m b/Source/win32/WIN32Server.m index 0566a72..69b850f 100644 --- a/Source/win32/WIN32Server.m +++ b/Source/win32/WIN32Server.m @@ -29,9 +29,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -106,6 +108,8 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, */ - (id) initWithAttributes: (NSDictionary *)info { + NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; + [self _initWin32Context]; [super initWithAttributes: info]; @@ -113,6 +117,14 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, [self setupRunLoopInputSourcesForMode: NSConnectionReplyMode]; [self setupRunLoopInputSourcesForMode: NSModalPanelRunLoopMode]; [self setupRunLoopInputSourcesForMode: NSEventTrackingRunLoopMode]; + + flags.useWMTaskbar = YES; + if ([defs stringForKey: @"GSUseWMTaskbar"] != nil + && [defs boolForKey: @"GSUseWMTaskbar"] == NO) + { + flags.useWMTaskbar = NO; + } + return self; } @@ -390,9 +402,36 @@ DWORD windowStyleForGSStyle(unsigned int style) - (void) orderwindow: (int) op : (int) otherWin : (int) winNum { NSDebugLLog(@"WTrace", @"orderwindow: %d : %d : %d", op, otherWin, winNum); + + if (flags.useWMTaskBar) + { + /* When using this policy, we make these changes: + - don't show the application icon window + - Never order out the main menu, just minimize it, so that + when the user clicks on it in the taskbar it will activate the + application. + */ + int special; + special = [[NSApp iconWindow] windowNumber]; + if (winNum == special) + { + return; + } + special = [[[NSApp mainMenu] window] windowNumber]; + if (winNum == special && op == NSWindowOut) + { + ShowWindow((HWND)winNum, SW_MINIMIZE); + return; + } + } + if (op != NSWindowOut) { - ShowWindow((HWND)winNum, SW_SHOW); + int flag = SW_SHOW; + if (IsIconic((HWND)winNum)) + flag = SW_RESTORE; + ShowWindow((HWND)winNum, flag); + return; } switch (op) diff --git a/Source/win32/WIN32ServerEvent.m b/Source/win32/WIN32ServerEvent.m index 38eed36..a1ad178 100755 --- a/Source/win32/WIN32ServerEvent.m +++ b/Source/win32/WIN32ServerEvent.m @@ -370,9 +370,22 @@ static void invalidateWindow(HWND hwnd, RECT rect); if (LOWORD(wParam)) currentActive = hwnd; break; - case WM_ACTIVATEAPP: - NSDebugLLog(@"NSEvent", @"Got Message %s for %d: %s", "ACTIVATEAPP", - hwnd, (wParam) ? "activate" : "deactivate"); + case WM_ACTIVATEAPP: + { + int special; + BOOL active = [NSApp isActive]; + NSDebugLLog(@"NSEvent", @"Got Message %s for %d: %s (app is %s)", + "ACTIVATEAPP", hwnd, (wParam) ? "activate" : "deactivate", + (active) ? "active" : "deactivated"); + special = [[[NSApp mainMenu] window] windowNumber]; + if (active == NO && wParam) + { + + [NSApp activateIgnoringOtherApps: YES]; + } + else if (special == (int)hwnd && active == YES && wParam == 0) + [NSApp deactivate]; + } break; case WM_MOUSEACTIVATE: NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MOUSEACTIVATE", hwnd);