Ken Thomases : winemac: Implement the Mac "Window" menu.

Alexandre Julliard julliard at winehq.org
Fri Jan 11 13:46:58 CST 2013


Module: wine
Branch: master
Commit: b3f71fdeb101945ce6d971016278e1d8248035c1
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b3f71fdeb101945ce6d971016278e1d8248035c1

Author: Ken Thomases <ken at codeweavers.com>
Date:   Fri Jan 11 06:21:06 2013 -0600

winemac: Implement the Mac "Window" menu.

---

 dlls/winemac.drv/cocoa_app.m    |   11 +++++++++++
 dlls/winemac.drv/cocoa_window.m |   26 ++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m
index 28d2ad2..d869a05 100644
--- a/dlls/winemac.drv/cocoa_app.m
+++ b/dlls/winemac.drv/cocoa_app.m
@@ -51,7 +51,18 @@
             [item setSubmenu:submenu];
             [mainMenu addItem:item];
 
+            submenu = [[[NSMenu alloc] initWithTitle:@"Window"] autorelease];
+            [submenu addItemWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@""];
+            [submenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""];
+            [submenu addItem:[NSMenuItem separatorItem]];
+            [submenu addItemWithTitle:@"Bring All to Front" action:@selector(arrangeInFront:) keyEquivalent:@""];
+            item = [[[NSMenuItem alloc] init] autorelease];
+            [item setTitle:@"Window"];
+            [item setSubmenu:submenu];
+            [mainMenu addItem:item];
+
             [self setMainMenu:mainMenu];
+            [self setWindowsMenu:submenu];
         }
     }
 
diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m
index 9d359ff..49dd31b 100644
--- a/dlls/winemac.drv/cocoa_window.m
+++ b/dlls/winemac.drv/cocoa_window.m
@@ -172,9 +172,17 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens)
         else
             behavior |= NSWindowCollectionBehaviorManaged;
         if (state->excluded_by_cycle)
+        {
             behavior |= NSWindowCollectionBehaviorIgnoresCycle;
+            if ([self isVisible])
+                [NSApp removeWindowsItem:self];
+        }
         else
+        {
             behavior |= NSWindowCollectionBehaviorParticipatesInCycle;
+            if ([self isVisible])
+                [NSApp addWindowsItem:self title:[self title] filename:NO];
+        }
         [self setCollectionBehavior:behavior];
     }
 
@@ -196,6 +204,9 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens)
                 [latentParentWindow addChildWindow:self ordered:NSWindowAbove];
                 self.latentParentWindow = nil;
             }
+
+            if (![self isExcludedFromWindowsMenu])
+                [NSApp addWindowsItem:self title:[self title] filename:NO];
         }
 
         return on_screen;
@@ -206,6 +217,7 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens)
         self.latentParentWindow = [self parentWindow];
         [latentParentWindow removeChildWindow:self];
         [self orderOut:nil];
+        [NSApp removeWindowsItem:self];
     }
 
     - (BOOL) setFrameIfOnScreen:(NSRect)contentRect
@@ -277,6 +289,18 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens)
         return [self canBecomeKeyWindow];
     }
 
+    - (BOOL) isExcludedFromWindowsMenu
+    {
+        return !([self collectionBehavior] & NSWindowCollectionBehaviorParticipatesInCycle);
+    }
+
+    - (BOOL) validateMenuItem:(NSMenuItem *)menuItem
+    {
+        if ([menuItem action] == @selector(makeKeyAndOrderFront:))
+            return [self isKeyWindow] || (!self.disabled && !self.noActivate);
+        return [super validateMenuItem:menuItem];
+    }
+
 
     /*
      * ---------- NSWindowDelegate methods ----------
@@ -372,6 +396,8 @@ void macdrv_set_cocoa_window_title(macdrv_window w, const unsigned short* title,
         titleString = @"";
     OnMainThreadAsync(^{
         [window setTitle:titleString];
+        if ([window isVisible] && ![window isExcludedFromWindowsMenu])
+            [NSApp changeWindowsItem:window title:titleString filename:NO];
     });
 
     [pool release];




More information about the wine-cvs mailing list