Applied changes in menuInWindow.patch

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@31895 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
espectador 2011-01-16 00:32:54 +00:00
parent a99e46fa36
commit b3d789fcec
6 changed files with 50 additions and 32 deletions

View file

@ -1,3 +1,14 @@
2011-01-15 German Arias <german@xelalug.org>
* Source/NSWindow.m:
* Source/NSSavePanel.m: Reverted latest changes.
* Source/NSMenuView.m: Added the appropriate code to close
the menu after select an option, but before do the
instructions of the selected option.
* Headers/AppKit/NSApplication.h:
* Source/NSApplication.m: Save the main window when the
app is hidden or when is deactivated.
2011-01-15 Wolfgang Lux <wolfgang.lux@gmail.com> 2011-01-15 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSColorWell.m (-activate:): Deactivate an activate color * Source/NSColorWell.m (-activate:): Deactivate an activate color

View file

@ -145,6 +145,7 @@ APPKIT_EXPORT NSString *NSEventTrackingRunLoopMode;
NSMutableArray *_hidden; NSMutableArray *_hidden;
NSMutableArray *_inactive; NSMutableArray *_inactive;
NSWindow *_hidden_key; NSWindow *_hidden_key;
NSWindow *_hidden_main;
GSInfoPanel *_infoPanel; GSInfoPanel *_infoPanel;
/* This autorelease pool should only be created and used by -run, with /* This autorelease pool should only be created and used by -run, with

View file

@ -1315,18 +1315,17 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
[_hidden_key makeKeyWindow]; [_hidden_key makeKeyWindow];
_hidden_key = nil; _hidden_key = nil;
} }
if ([self mainWindow] == nil && _hidden_main != nil
&& [[self windows] indexOfObjectIdenticalTo: _hidden_main] != NSNotFound)
{
[_hidden_main makeMainWindow];
_hidden_main = nil;
}
if ([self keyWindow] != nil) if ([self keyWindow] != nil)
{ {
[[self keyWindow] orderFront: self]; [[self keyWindow] orderFront: self];
/* If menu is in window, we need a main window, in other way
the menu can't respond */
if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", self) ==
NSWindows95InterfaceStyle && [[self keyWindow] canBecomeMainWindow])
{
[[self keyWindow] becomeMainWindow];
}
} }
else if ([self mainWindow] != nil) else if ([self mainWindow] != nil)
{ {
@ -1376,10 +1375,13 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
_hidden_key = [self keyWindow]; _hidden_key = [self keyWindow];
[_hidden_key resignKeyWindow]; [_hidden_key resignKeyWindow];
} }
// FIXME: main window is not saved for when the app is activated again. // The main window is saved for when the app is activated again.
// This is not a problem if it is also key, and I'm not sure if it // This is necessary for menu in window.
// is a problem at all. May be annoying in the case of workspace switch. if ([self mainWindow] != nil)
[[self mainWindow] resignMainWindow]; {
_hidden_main = [self mainWindow];
[_hidden_main resignMainWindow];
}
windows_list = GSOrderedWindows(); windows_list = GSOrderedWindows();
iter = [windows_list reverseObjectEnumerator]; iter = [windows_list reverseObjectEnumerator];
@ -2418,6 +2420,14 @@ image.</p><p>See Also: -applicationIconImage</p>
[_hidden_key resignKeyWindow]; [_hidden_key resignKeyWindow];
} }
// The main window is saved for when the app is activated again.
// This is necessary for menu in window.
if ([self mainWindow] != nil)
{
_hidden_main = [self mainWindow];
[_hidden_main resignMainWindow];
}
windows_list = GSOrderedWindows(); windows_list = GSOrderedWindows();
iter = [windows_list reverseObjectEnumerator]; iter = [windows_list reverseObjectEnumerator];

View file

@ -1389,14 +1389,21 @@ static NSMapTable *viewInfo = 0;
- (BOOL) _executeItemAtIndex: (int)indexOfActionToExecute - (BOOL) _executeItemAtIndex: (int)indexOfActionToExecute
removeSubmenu: (BOOL)subMenusNeedRemoving removeSubmenu: (BOOL)subMenusNeedRemoving
{ {
NSInterfaceStyle style =
NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", self);
/*If we have menu in window, close the menu after select
an option*/
if (style == NSWindows95InterfaceStyle)
{
[[[[NSApp mainWindow] menu] attachedMenu] close];
}
if (indexOfActionToExecute >= 0 if (indexOfActionToExecute >= 0
&& [_attachedMenu attachedMenu] != nil && [_attachedMenu attachedMenu] == && [_attachedMenu attachedMenu] != nil && [_attachedMenu attachedMenu] ==
[[_items_link objectAtIndex: indexOfActionToExecute] submenu]) [[_items_link objectAtIndex: indexOfActionToExecute] submenu])
{ {
NSInterfaceStyle style = if (style == NSMacintoshInterfaceStyle)
NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", self);
if (style == NSMacintoshInterfaceStyle ||
style == NSWindows95InterfaceStyle)
{ {
// On Macintosh, clicking on or releasing the mouse over a // On Macintosh, clicking on or releasing the mouse over a
// submenu item always closes the menu (if it is open) and // submenu item always closes the menu (if it is open) and
@ -1405,6 +1412,11 @@ static NSMapTable *viewInfo = 0;
return YES; return YES;
} }
if (style == NSWindows95InterfaceStyle)
{
return YES;
}
if (subMenusNeedRemoving) if (subMenusNeedRemoving)
{ {
[self detachSubmenu]; [self detachSubmenu];

View file

@ -50,7 +50,6 @@
#import "AppKit/NSImage.h" #import "AppKit/NSImage.h"
#import "AppKit/NSImageView.h" #import "AppKit/NSImageView.h"
#import "AppKit/NSMatrix.h" #import "AppKit/NSMatrix.h"
#import "AppKit/NSMenu.h"
#import "AppKit/NSPasteboard.h" #import "AppKit/NSPasteboard.h"
#import "AppKit/NSDragging.h" #import "AppKit/NSDragging.h"
#import "AppKit/NSSavePanel.h" #import "AppKit/NSSavePanel.h"
@ -183,7 +182,6 @@ setPath(NSBrowser *browser, NSString *path)
NSImage *image; NSImage *image;
NSRect r; NSRect r;
id lastKeyView; id lastKeyView;
NSInterfaceStyle style = NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil);
// Track window resizing so we can change number of browser columns. // Track window resizing so we can change number of browser columns.
[[NSNotificationCenter defaultCenter] addObserver: self [[NSNotificationCenter defaultCenter] addObserver: self
@ -375,12 +373,6 @@ setPath(NSBrowser *browser, NSString *path)
[self registerForDraggedTypes: [NSArray arrayWithObjects: [self registerForDraggedTypes: [NSArray arrayWithObjects:
NSFilenamesPboardType, nil]]; NSFilenamesPboardType, nil]];
if (style == NSWindows95InterfaceStyle)
{
[[[[NSApp mainWindow] menu] attachedMenu] close];
}
return self; return self;
} }

View file

@ -1818,14 +1818,6 @@ many times.
if (_f.is_main == YES) if (_f.is_main == YES)
{ {
_f.is_main = NO; _f.is_main = NO;
//We close the menu if the app will be hide
if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", self) ==
NSWindows95InterfaceStyle)
{
[[[self menu] attachedMenu] close];
}
if (_f.is_key == YES) if (_f.is_key == YES)
{ {
[_wv setInputState: GSTitleBarKey]; [_wv setInputState: GSTitleBarKey];