Author: mlytwyn
Date: Tue Mar 10 02:00:57 2015
New Revision: 38390

URL: http://svn.gna.org/viewcvs/gnustep?rev=38390&view=rev
Log:
Patch for closing menus on window out/window move sequences

Modified:
    libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSMenuView.h
    libs/gui/branches/gnustep_testplant_branch/Source/NSMenu.m
    libs/gui/branches/gnustep_testplant_branch/Source/NSMenuView.m
    libs/gui/branches/gnustep_testplant_branch/Source/NSWindow.m

Modified: libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSMenuView.h
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSMenuView.h?rev=38390&r1=38389&r2=38390&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSMenuView.h      
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSMenuView.h      
Tue Mar 10 02:00:57 2015
@@ -95,6 +95,7 @@
   BOOL           _needsSizing;
   char          _pad2[3];
   NSSize         _cellSize;
+  BOOL           _finished;
 
 @private
   id             _items_link;

Modified: libs/gui/branches/gnustep_testplant_branch/Source/NSMenu.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Source/NSMenu.m?rev=38390&r1=38389&r2=38390&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Source/NSMenu.m  (original)
+++ libs/gui/branches/gnustep_testplant_branch/Source/NSMenu.m  Tue Mar 10 
02:00:57 2015
@@ -125,17 +125,20 @@
 
 @interface NSMenuView (GNUstepPrivate)
 - (NSArray *)_itemCells;
+- (void)_finish;
 @end
-
 
 static NSZone  *menuZone = NULL;
 static NSString        *NSMenuLocationsKey = @"NSMenuLocations";
 static NSString *NSEnqueuedMenuMoveName = @"EnqueuedMoveNotificationName";
 static NSNotificationCenter *nc;
 static BOOL menuBarVisible = YES;
+static NSMenu   *_CurrentMenu = nil;
 
 @interface     NSMenu (GNUstepPrivate)
 
++ (NSMenu*)_currentMenu;
++ (void)_setCurrentMenu:(NSMenu*)menu;
 - (NSString *) _name;
 - (void) _setName: (NSString *)name;
 - (NSMenuPanel *) _createWindow;
@@ -144,6 +147,7 @@
 - (void) _setGeometry;
 - (void) _updateUserDefaults: (id) notification;
 - (void) _organizeMenu;
+- (void) _finish;
 
 @end
 
@@ -175,9 +179,38 @@
     }
   [super orderFrontRegardless];
 }
+
+- (void)orderOut:(id)sender
+{
+  [super orderOut:sender];
+  [_the_menu _finish];
+}
+
+- (void)orderWindow:(NSWindowOrderingMode)place relativeTo:(NSInteger)otherWin
+{
+  [super orderWindow:place relativeTo:otherWin];
+  [_the_menu _finish];
+}
+
 @end
 
 @implementation        NSMenu (GNUstepPrivate)
+
++ (NSMenu*)_currentMenu
+{
+  return _CurrentMenu;
+}
+
++ (void)_setCurrentMenu:(NSMenu*)menu
+{
+  @synchronized(self)
+  {
+    if (_CurrentMenu != menu)
+    {
+      _CurrentMenu = menu;
+    }
+  }
+}
 
 - (NSString *) _name;
 {
@@ -462,6 +495,11 @@
 
   [[self menuRepresentation] update];
   [self sizeToFit];
+}
+
+- (void) _finish
+{
+  [(NSMenuView*)_view _finish];
 }
 
 - (void) _setGeometry

Modified: libs/gui/branches/gnustep_testplant_branch/Source/NSMenuView.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Source/NSMenuView.m?rev=38390&r1=38389&r2=38390&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Source/NSMenuView.m      
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Source/NSMenuView.m      Tue Mar 
10 02:00:57 2015
@@ -88,6 +88,10 @@
 
 @interface NSMenu (Private)
 - (void) _attachMenu: (NSMenu*)aMenu;
+@end
+
+@interface      NSMenu (GNUstepPrivate)
++ (void)_setCurrentMenu:(NSMenu*)menu;
 @end
 
 @implementation NSMenu (Private)
@@ -1459,6 +1463,8 @@
   NSEvent *original;
   NSEventType type;
 
+  _finished = NO;
+
   /*
    * The original event is unused except to determine whether the method
    * was invoked in response to a right or left mouse down.
@@ -1731,11 +1737,12 @@
              [[event window] sendEvent: event];
            }
        }
-      while (type == NSAppKitDefined);
-    }
-  while ((type != NSLeftMouseUp &&
-         type != NSRightMouseUp &&
-         type != NSOtherMouseUp) || shouldFinish == NO);
+      while (type == NSAppKitDefined && (_finished == NO));
+    }
+  while ((_finished == NO) &&
+         ((type != NSLeftMouseUp &&
+          type != NSRightMouseUp &&
+          type != NSOtherMouseUp) || shouldFinish == NO));
 
   /*
    * Ok, we released the mouse
@@ -1890,9 +1897,11 @@
       originalTopLeft.y += originalFrame.size.height;
     }
   
+  [NSMenu _setCurrentMenu:[self menu]];
   [NSEvent startPeriodicEventsAfterDelay: 0.1 withPeriod: 0.01];
   [self trackWithEvent: theEvent];
   [NSEvent stopPeriodicEvents];
+  [NSMenu _setCurrentMenu:nil];
 
   if (restorePosition)
     {
@@ -1979,5 +1988,10 @@
   return _itemCells;
 }
 
+- (void)_finish
+{
+  _finished = YES;
+}
+
 @end
 

Modified: libs/gui/branches/gnustep_testplant_branch/Source/NSWindow.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Source/NSWindow.m?rev=38390&r1=38389&r2=38390&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Source/NSWindow.m        
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Source/NSWindow.m        Tue Mar 
10 02:00:57 2015
@@ -116,6 +116,10 @@
             source: (id)sourceObject
          slideBack: (BOOL)slideFlag;
 - (void) postDragEvent: (NSEvent*)event;
+@end
+
+@interface NSMenu (GNUstepPrivate)
++ (NSMenu*)_currentMenu;
 @end
 
 @interface NSView (MoveToWindow)
@@ -4043,6 +4047,10 @@
                 {
                   [self saveFrameUsingName: _autosaveName];
                 }
+              if ([NSMenu _currentMenu])
+                {
+                  [[NSMenu _currentMenu] close];
+                }
               [nc postNotificationName: NSWindowDidMoveNotification
                   object: self];
               break;
@@ -4068,6 +4076,10 @@
                 if (_autosaveName != nil)
                   {
                     [self saveFrameUsingName: _autosaveName];
+                  }
+                if ([NSMenu _currentMenu])
+                  {
+                    [[NSMenu _currentMenu] close];
                   }
 
                 [self _processResizeEvent];


_______________________________________________
Gnustep-cvs mailing list
Gnustep-cvs@gna.org
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to