From f018c2087b3e7a36b8c884d1155f2baddd359dc3 Mon Sep 17 00:00:00 2001 From: Sergii Stoian Date: Fri, 5 Apr 2019 14:07:33 +0300 Subject: [PATCH 1/4] Added support for WindowMaker's WMFHideApplication action. --- ChangeLog | 12 +++++ .../Additions/GNUstepGUI/GSDisplayServer.h | 1 + Headers/AppKit/NSEvent.h | 1 + Source/GSDisplayServer.m | 6 +++ Source/NSApplication.m | 53 +++++++++++-------- Source/NSWindow.m | 4 ++ 6 files changed, 54 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index b27b0eedd..62275df54 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2019-04-05 Sergii Stoian + + * Headers/AppKit/NSEvent.h: new event subtype `GSAppKitAppHide` was added. + * Source/NSWindow.m (sendEvent:): handle "GSAppKitAppHide" event subtype. + + * Headers/Additions/GNUstepGUI/GSDisplayServer.h, + * Source/GSDisplayServer.m (hidewindow:): new methods was added. + + * Source/NSApplication.m (hide:): Send -hidewindow: to to the main menu. + If window manager doesn't support _GNUSTEP_HIDE_APP atom - hide windows + by ourself. + 2019-04-03 Sergii Stoian * Source/NSApplication.m (activateIgnoringOtherApps:): diff --git a/Headers/Additions/GNUstepGUI/GSDisplayServer.h b/Headers/Additions/GNUstepGUI/GSDisplayServer.h index 70b781594..c808cf06f 100644 --- a/Headers/Additions/GNUstepGUI/GSDisplayServer.h +++ b/Headers/Additions/GNUstepGUI/GSDisplayServer.h @@ -136,6 +136,7 @@ APPKIT_EXPORT NSString *GSScreenNumber; - (void) windowbacking: (NSBackingStoreType)type : (int)win; - (void) titlewindow: (NSString *)window_title : (int)win; - (void) miniwindow: (int)win; +- (BOOL) hidewindow: (int)win; - (BOOL) appOwnsMiniwindow; - (void) setWindowdevice: (int)win forContext: (NSGraphicsContext *)ctxt; // Deprecated diff --git a/Headers/AppKit/NSEvent.h b/Headers/AppKit/NSEvent.h index 4de780049..386f4dd9b 100644 --- a/Headers/AppKit/NSEvent.h +++ b/Headers/AppKit/NSEvent.h @@ -532,6 +532,7 @@ typedef enum { GSAppKitDraggingFinished, GSAppKitRegionExposed, GSAppKitWindowDeminiaturize, + GSAppKitAppHide } GSAppKitSubtype; #endif diff --git a/Source/GSDisplayServer.m b/Source/GSDisplayServer.m index b1af205c1..b2d1ca8ff 100644 --- a/Source/GSDisplayServer.m +++ b/Source/GSDisplayServer.m @@ -601,6 +601,12 @@ GSCurrentServer(void) [self subclassResponsibility: _cmd]; } +/** Hides all application windows */ +- (void) hidewindow: (int) win +{ + [self subclassResponsibility: _cmd]; +} + /** Returns YES if the application should create the miniwindow counterpart to the full size window and own it. Some display systems handle the miniwindow themselves. In this case the backend subclass should diff --git a/Source/NSApplication.m b/Source/NSApplication.m index 8abed8f68..e957ee50a 100644 --- a/Source/NSApplication.m +++ b/Source/NSApplication.m @@ -2496,30 +2496,37 @@ image.

See Also: -applicationIconImage

[_hidden_main resignMainWindow]; } - windows_list = GSOrderedWindows(); - iter = [windows_list reverseObjectEnumerator]; + // Sends -hidewindow: to the main menu. If window manager supports + // _GNUSTEP_WM_HIDE_APP atom - call succeeds - our windows will be + // hidden by window manager, next application should be activated. + win = [[self mainMenu] window]; + if ([GSServerForWindow(win) hidewindow: [win windowNumber]] == NO) + { + windows_list = GSOrderedWindows(); + iter = [windows_list reverseObjectEnumerator]; - while ((win = [iter nextObject])) - { - if ([win isVisible] == NO && ![win isMiniaturized]) - { - continue; /* Already invisible */ - } - if ([win canHide] == NO) - { - continue; /* Not hideable */ - } - if (win == _app_icon_window) - { - continue; /* can't hide the app icon. */ - } - if (_app_is_active == YES && [win hidesOnDeactivate] == YES) - { - continue; /* Will be hidden by deactivation */ - } - [_hidden addObject: win]; - [win orderOut: self]; - } + while ((win = [iter nextObject])) + { + if ([win isVisible] == NO && ![win isMiniaturized]) + { + continue; /* Already invisible */ + } + if ([win canHide] == NO) + { + continue; /* Not hideable */ + } + if (win == _app_icon_window) + { + continue; /* can't hide the app icon. */ + } + if (_app_is_active == YES && [win hidesOnDeactivate] == YES) + { + continue; /* Will be hidden by deactivation */ + } + [_hidden addObject: win]; + [win orderOut: self]; + } + } _app_is_hidden = YES; if (YES == [[NSUserDefaults standardUserDefaults] diff --git a/Source/NSWindow.m b/Source/NSWindow.m index cd9f2236b..112eef462 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -4224,6 +4224,10 @@ checkCursorRectanglesExited(NSView *theView, NSEvent *theEvent, NSPoint lastPoi [self performMiniaturize: NSApp]; break; + case GSAppKitAppHide: + [NSApp hide: self]; + break; + case GSAppKitWindowFocusIn: if (_f.is_miniaturized) { From 07dcc41ad0e8554c5f9e877b8d989293bda4accd Mon Sep 17 00:00:00 2001 From: Sergii Stoian Date: Sat, 6 Apr 2019 00:25:09 +0300 Subject: [PATCH 2/4] (hidewindow:): fixes to return value and type. --- ChangeLog | 4 ++++ Source/GSDisplayServer.m | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 62275df54..054112519 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2019-04-06 Sergii Stoian + + * Source/GSDisplayServer.m (hidewindow:): fixes to return value and type. + 2019-04-05 Sergii Stoian * Headers/AppKit/NSEvent.h: new event subtype `GSAppKitAppHide` was added. diff --git a/Source/GSDisplayServer.m b/Source/GSDisplayServer.m index b2d1ca8ff..e2413c9cf 100644 --- a/Source/GSDisplayServer.m +++ b/Source/GSDisplayServer.m @@ -602,9 +602,9 @@ GSCurrentServer(void) } /** Hides all application windows */ -- (void) hidewindow: (int) win +- (BOOL) hidewindow: (int) win { - [self subclassResponsibility: _cmd]; + return NO; } /** Returns YES if the application should create the miniwindow counterpart From f5bcf3019b35bc82036e3f37f98b4cdd6e8759e0 Mon Sep 17 00:00:00 2001 From: Sergii Stoian Date: Sat, 6 Apr 2019 01:23:17 +0300 Subject: [PATCH 3/4] Change comments upon request of @fredkiefer. --- ChangeLog | 3 +++ Source/GSDisplayServer.m | 3 ++- Source/NSApplication.m | 5 ++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 054112519..f01d81828 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ 2019-04-06 Sergii Stoian + * Source/NSApplication.m (hide:): Change comment before call to `hidwindow`. + * Source/GSDisplayServer.m (hidewindow:): fixes to return value and type. + Change comment. 2019-04-05 Sergii Stoian diff --git a/Source/GSDisplayServer.m b/Source/GSDisplayServer.m index e2413c9cf..1df21c943 100644 --- a/Source/GSDisplayServer.m +++ b/Source/GSDisplayServer.m @@ -601,7 +601,8 @@ GSCurrentServer(void) [self subclassResponsibility: _cmd]; } -/** Hides all application windows */ +/** Ask the window manager to hide all the application windows for us. + Return whether they have been hidden. */ - (BOOL) hidewindow: (int) win { return NO; diff --git a/Source/NSApplication.m b/Source/NSApplication.m index e957ee50a..5ec3b4727 100644 --- a/Source/NSApplication.m +++ b/Source/NSApplication.m @@ -2496,9 +2496,8 @@ image.

See Also: -applicationIconImage

[_hidden_main resignMainWindow]; } - // Sends -hidewindow: to the main menu. If window manager supports - // _GNUSTEP_WM_HIDE_APP atom - call succeeds - our windows will be - // hidden by window manager, next application should be activated. + /** Ask the window manager to hide all the application windows for us. + Return whether they have been hidden. */ win = [[self mainMenu] window]; if ([GSServerForWindow(win) hidewindow: [win windowNumber]] == NO) { From b5e65175a390ddc3aa75f897a0a2a16e21c28f4c Mon Sep 17 00:00:00 2001 From: Sergii Stoian Date: Sat, 6 Apr 2019 22:36:56 +0300 Subject: [PATCH 4/4] `hidewindow` methods was renamed to `hideApplication`. --- ChangeLog | 8 +++++++- Headers/Additions/GNUstepGUI/GSDisplayServer.h | 2 +- Source/GSDisplayServer.m | 2 +- Source/NSApplication.m | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index f01d81828..9f23938bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,12 @@ 2019-04-06 Sergii Stoian - * Source/NSApplication.m (hide:): Change comment before call to `hidwindow`. + * Headers/Additions/GNUstepGUI/GSDisplayServer.h, + * Source/NSApplication.m, + * Source/GSDisplayServer.m: `hidewindow` method was renamed to + `hideApplication` + + * Source/NSApplication.m (hide:): Change comment before call to + `hidewindow`. * Source/GSDisplayServer.m (hidewindow:): fixes to return value and type. Change comment. diff --git a/Headers/Additions/GNUstepGUI/GSDisplayServer.h b/Headers/Additions/GNUstepGUI/GSDisplayServer.h index c808cf06f..2df8f16e4 100644 --- a/Headers/Additions/GNUstepGUI/GSDisplayServer.h +++ b/Headers/Additions/GNUstepGUI/GSDisplayServer.h @@ -136,7 +136,7 @@ APPKIT_EXPORT NSString *GSScreenNumber; - (void) windowbacking: (NSBackingStoreType)type : (int)win; - (void) titlewindow: (NSString *)window_title : (int)win; - (void) miniwindow: (int)win; -- (BOOL) hidewindow: (int)win; +- (BOOL) hideApplication: (int)win; - (BOOL) appOwnsMiniwindow; - (void) setWindowdevice: (int)win forContext: (NSGraphicsContext *)ctxt; // Deprecated diff --git a/Source/GSDisplayServer.m b/Source/GSDisplayServer.m index 1df21c943..f752c18ec 100644 --- a/Source/GSDisplayServer.m +++ b/Source/GSDisplayServer.m @@ -603,7 +603,7 @@ GSCurrentServer(void) /** Ask the window manager to hide all the application windows for us. Return whether they have been hidden. */ -- (BOOL) hidewindow: (int) win +- (BOOL) hideApplication: (int) win { return NO; } diff --git a/Source/NSApplication.m b/Source/NSApplication.m index 5ec3b4727..8fc7e554f 100644 --- a/Source/NSApplication.m +++ b/Source/NSApplication.m @@ -2499,7 +2499,7 @@ image.

See Also: -applicationIconImage

/** Ask the window manager to hide all the application windows for us. Return whether they have been hidden. */ win = [[self mainMenu] window]; - if ([GSServerForWindow(win) hidewindow: [win windowNumber]] == NO) + if ([GSServerForWindow(win) hideApplication: [win windowNumber]] == NO) { windows_list = GSOrderedWindows(); iter = [windows_list reverseObjectEnumerator];