XQuartz: Change handling of Windows menu to workaround a bug triggered by mixing Sparkle and X11 windows
<rdar://problem/7088335> NSApplication releases the separator in the Windows menu even though it's an IBOutlet (cherry picked from commit 27ac5135267be9cb221329ae68461117dd43a4bf)
This commit is contained in:
		
							parent
							
								
									171409cecb
								
							
						
					
					
						commit
						0d73893a57
					
				|  | @ -67,8 +67,13 @@ | ||||||
|     IBOutlet NSTextField *sync_text2; |     IBOutlet NSTextField *sync_text2; | ||||||
|     IBOutlet NSPopUpButton *depth; |     IBOutlet NSPopUpButton *depth; | ||||||
| 
 | 
 | ||||||
|     IBOutlet NSMenuItem *x11_about_item; |  | ||||||
|     IBOutlet NSMenuItem *window_separator; |     IBOutlet NSMenuItem *window_separator; | ||||||
|  |     // window_separator is DEPRECATED due to this radar:
 | ||||||
|  |     // <rdar://problem/7088335> NSApplication releases the separator in the Windows menu even though it's an IBOutlet
 | ||||||
|  |     // It is kept around for localization compatability and is subject to removal "eventually"
 | ||||||
|  |     // If it is !NULL (meaning it is in the nib), it is removed from the menu and released
 | ||||||
|  | 
 | ||||||
|  |     IBOutlet NSMenuItem *x11_about_item; | ||||||
|     IBOutlet NSMenuItem *dock_window_separator; |     IBOutlet NSMenuItem *dock_window_separator; | ||||||
|     IBOutlet NSMenuItem *apps_separator; |     IBOutlet NSMenuItem *apps_separator; | ||||||
|     IBOutlet NSMenuItem *toggle_fullscreen_item; |     IBOutlet NSMenuItem *toggle_fullscreen_item; | ||||||
|  | @ -84,6 +89,9 @@ | ||||||
| 
 | 
 | ||||||
|     IBOutlet NSMenu *dock_menu; |     IBOutlet NSMenu *dock_menu; | ||||||
|      |      | ||||||
|  |     // This is where in the Windows menu we'll start (this will be the index of the separator)
 | ||||||
|  |     NSInteger windows_menu_start; | ||||||
|  | 
 | ||||||
|     int checked_window_item; |     int checked_window_item; | ||||||
|     x_list *pending_apps; |     x_list *pending_apps; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -104,6 +104,13 @@ BOOL xquartz_resetenv_display = NO; | ||||||
|      name: NSWindowWillCloseNotification |      name: NSWindowWillCloseNotification | ||||||
|      object: [apps_table window]]; |      object: [apps_table window]]; | ||||||
| 
 | 
 | ||||||
|  |     // Setup data about our Windows menu | ||||||
|  |     if(window_separator) { | ||||||
|  |         [[window_separator menu] removeItem:window_separator]; | ||||||
|  |         window_separator = nil; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     windows_menu_start = [[X11App windowsMenu] numberOfItems]; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| - (void) item_selected:sender | - (void) item_selected:sender | ||||||
|  | @ -117,17 +124,15 @@ BOOL xquartz_resetenv_display = NO; | ||||||
| - (void) remove_window_menu | - (void) remove_window_menu | ||||||
| { | { | ||||||
|   NSMenu *menu; |   NSMenu *menu; | ||||||
|   int first, count, i; |   int count, i; | ||||||
| 
 | 
 | ||||||
|   /* Work backwards so we don't mess up the indices */ |   /* Work backwards so we don't mess up the indices */ | ||||||
|   menu = [window_separator menu]; |   menu = [X11App windowsMenu]; | ||||||
|   first = [menu indexOfItem:window_separator] + 1; |  | ||||||
|   count = [menu numberOfItems]; |   count = [menu numberOfItems]; | ||||||
|   for (i = count - 1; i >= first; i--) |   for (i = count - 1; i >= windows_menu_start; i--) | ||||||
|     [menu removeItemAtIndex:i]; |     [menu removeItemAtIndex:i]; | ||||||
| 	 | 	 | ||||||
|   menu = [dock_window_separator menu]; |   count = [dock_menu indexOfItem:dock_window_separator]; | ||||||
|   count = [menu indexOfItem:dock_window_separator]; |  | ||||||
|   for (i = 0; i < count; i++) |   for (i = 0; i < count; i++) | ||||||
|     [dock_menu removeItemAtIndex:0]; |     [dock_menu removeItemAtIndex:0]; | ||||||
| } | } | ||||||
|  | @ -138,9 +143,15 @@ BOOL xquartz_resetenv_display = NO; | ||||||
|   NSMenuItem *item; |   NSMenuItem *item; | ||||||
|   int first, count, i; |   int first, count, i; | ||||||
| 
 | 
 | ||||||
|   menu = [window_separator menu]; |   menu = [X11App windowsMenu]; | ||||||
|   first = [menu indexOfItem:window_separator] + 1; |   first = windows_menu_start + 1; | ||||||
|   count = [list count]; |   count = [list count]; | ||||||
|  |    | ||||||
|  |   // Push a Separator | ||||||
|  |   if(count) { | ||||||
|  |       [menu addItem:[NSMenuItem separatorItem]]; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   for (i = 0; i < count; i++) |   for (i = 0; i < count; i++) | ||||||
|     { |     { | ||||||
|       NSString *name, *shortcut; |       NSString *name, *shortcut; | ||||||
|  | @ -285,8 +296,8 @@ BOOL xquartz_resetenv_display = NO; | ||||||
|   int first, count; |   int first, count; | ||||||
|   int n = [nn intValue]; |   int n = [nn intValue]; | ||||||
| 
 | 
 | ||||||
|   menu = [window_separator menu]; |   menu = [X11App windowsMenu]; | ||||||
|   first = [menu indexOfItem:window_separator] + 1; |   first = windows_menu_start + 1; | ||||||
|   count = [menu numberOfItems] - first; |   count = [menu numberOfItems] - first; | ||||||
| 	 | 	 | ||||||
|   if (checked_window_item >= 0 && checked_window_item < count) |   if (checked_window_item >= 0 && checked_window_item < count) | ||||||
|  | @ -729,9 +740,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row | ||||||
|      |      | ||||||
|   if (item == toggle_fullscreen_item) |   if (item == toggle_fullscreen_item) | ||||||
|     return !quartzEnableRootless; |     return !quartzEnableRootless; | ||||||
|   else   if (item == copy_menu_item) // For some reason, this isn't working... |   else if (menu == [X11App windowsMenu] || menu == dock_menu | ||||||
|       return NO; |  | ||||||
|   else if (menu == [window_separator menu] || menu == dock_menu |  | ||||||
| 	   || (menu == [x11_about_item menu] && [item tag] == 42)) | 	   || (menu == [x11_about_item menu] && [item tag] == 42)) | ||||||
|     return (AppleWMSelectedEvents () & AppleWMControllerNotifyMask) != 0; |     return (AppleWMSelectedEvents () & AppleWMControllerNotifyMask) != 0; | ||||||
|   else |   else | ||||||
|  |  | ||||||
|  | @ -2,9 +2,9 @@ | ||||||
| <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03"> | <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03"> | ||||||
| 	<data> | 	<data> | ||||||
| 		<int key="IBDocument.SystemTarget">1050</int> | 		<int key="IBDocument.SystemTarget">1050</int> | ||||||
| 		<string key="IBDocument.SystemVersion">9J61</string> | 		<string key="IBDocument.SystemVersion">9L29</string> | ||||||
| 		<string key="IBDocument.InterfaceBuilderVersion">677</string> | 		<string key="IBDocument.InterfaceBuilderVersion">677</string> | ||||||
| 		<string key="IBDocument.AppKitVersion">949.46</string> | 		<string key="IBDocument.AppKitVersion">949.54</string> | ||||||
| 		<string key="IBDocument.HIToolboxVersion">353.00</string> | 		<string key="IBDocument.HIToolboxVersion">353.00</string> | ||||||
| 		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> | 		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> | ||||||
| 			<bool key="EncodedWithXMLCoder">YES</bool> | 			<bool key="EncodedWithXMLCoder">YES</bool> | ||||||
|  | @ -341,17 +341,6 @@ | ||||||
| 									<reference key="NSOnImage" ref="531645050"/> | 									<reference key="NSOnImage" ref="531645050"/> | ||||||
| 									<reference key="NSMixedImage" ref="351811234"/> | 									<reference key="NSMixedImage" ref="351811234"/> | ||||||
| 								</object> | 								</object> | ||||||
| 								<object class="NSMenuItem" id="444952046"> |  | ||||||
| 									<reference key="NSMenu" ref="96874957"/> |  | ||||||
| 									<bool key="NSIsDisabled">YES</bool> |  | ||||||
| 									<bool key="NSIsSeparator">YES</bool> |  | ||||||
| 									<string key="NSTitle"/> |  | ||||||
| 									<string key="NSKeyEquiv"/> |  | ||||||
| 									<int key="NSKeyEquivModMask">1048576</int> |  | ||||||
| 									<int key="NSMnemonicLoc">2147483647</int> |  | ||||||
| 									<reference key="NSOnImage" ref="531645050"/> |  | ||||||
| 									<reference key="NSMixedImage" ref="351811234"/> |  | ||||||
| 								</object> |  | ||||||
| 							</object> | 							</object> | ||||||
| 							<string key="NSName">_NSWindowsMenu</string> | 							<string key="NSName">_NSWindowsMenu</string> | ||||||
| 						</object> | 						</object> | ||||||
|  | @ -1953,14 +1942,6 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string> | ||||||
| 					</object> | 					</object> | ||||||
| 					<int key="connectionID">549</int> | 					<int key="connectionID">549</int> | ||||||
| 				</object> | 				</object> | ||||||
| 				<object class="IBConnectionRecord"> |  | ||||||
| 					<object class="IBOutletConnection" key="connection"> |  | ||||||
| 						<string key="label">window_separator</string> |  | ||||||
| 						<reference key="source" ref="485884620"/> |  | ||||||
| 						<reference key="destination" ref="444952046"/> |  | ||||||
| 					</object> |  | ||||||
| 					<int key="connectionID">300331</int> |  | ||||||
| 				</object> |  | ||||||
| 				<object class="IBConnectionRecord"> | 				<object class="IBConnectionRecord"> | ||||||
| 					<object class="IBOutletConnection" key="connection"> | 					<object class="IBOutletConnection" key="connection"> | ||||||
| 						<string key="label">menu</string> | 						<string key="label">menu</string> | ||||||
|  | @ -2209,7 +2190,6 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string> | ||||||
| 							<reference ref="1036389925"/> | 							<reference ref="1036389925"/> | ||||||
| 							<reference ref="369641893"/> | 							<reference ref="369641893"/> | ||||||
| 							<reference ref="155085383"/> | 							<reference ref="155085383"/> | ||||||
| 							<reference ref="444952046"/> |  | ||||||
| 							<reference ref="984461797"/> | 							<reference ref="984461797"/> | ||||||
| 							<reference ref="280172320"/> | 							<reference ref="280172320"/> | ||||||
| 						</object> | 						</object> | ||||||
|  | @ -3013,11 +2993,6 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string> | ||||||
| 						<reference key="object" ref="8201128"/> | 						<reference key="object" ref="8201128"/> | ||||||
| 						<reference key="parent" ref="492358940"/> | 						<reference key="parent" ref="492358940"/> | ||||||
| 					</object> | 					</object> | ||||||
| 					<object class="IBObjectRecord"> |  | ||||||
| 						<int key="objectID">300330</int> |  | ||||||
| 						<reference key="object" ref="444952046"/> |  | ||||||
| 						<reference key="parent" ref="96874957"/> |  | ||||||
| 					</object> |  | ||||||
| 					<object class="IBObjectRecord"> | 					<object class="IBObjectRecord"> | ||||||
| 						<int key="objectID">300337</int> | 						<int key="objectID">300337</int> | ||||||
| 						<reference key="object" ref="10973343"/> | 						<reference key="object" ref="10973343"/> | ||||||
|  | @ -3401,8 +3376,6 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string> | ||||||
| 					<string>298.ImportedFromIB2</string> | 					<string>298.ImportedFromIB2</string> | ||||||
| 					<string>300295.IBPluginDependency</string> | 					<string>300295.IBPluginDependency</string> | ||||||
| 					<string>300295.IBShouldRemoveOnLegacySave</string> | 					<string>300295.IBShouldRemoveOnLegacySave</string> | ||||||
| 					<string>300330.IBPluginDependency</string> |  | ||||||
| 					<string>300330.ImportedFromIB2</string> |  | ||||||
| 					<string>300337.IBPluginDependency</string> | 					<string>300337.IBPluginDependency</string> | ||||||
| 					<string>300337.ImportedFromIB2</string> | 					<string>300337.ImportedFromIB2</string> | ||||||
| 					<string>300338.IBPluginDependency</string> | 					<string>300338.IBPluginDependency</string> | ||||||
|  | @ -3638,7 +3611,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string> | ||||||
| 					<reference ref="9"/> | 					<reference ref="9"/> | ||||||
| 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string> | 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string> | ||||||
| 					<reference ref="9"/> | 					<reference ref="9"/> | ||||||
| 					<string>{{349, 858}, {315, 153}}</string> | 					<string>{{349, 868}, {315, 143}}</string> | ||||||
| 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string> | 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string> | ||||||
| 					<reference ref="9"/> | 					<reference ref="9"/> | ||||||
| 					<string>{{271, 666}, {301, 153}}</string> | 					<string>{{271, 666}, {301, 153}}</string> | ||||||
|  | @ -3699,8 +3672,6 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string> | ||||||
| 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string> | 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string> | ||||||
| 					<reference ref="9"/> | 					<reference ref="9"/> | ||||||
| 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string> | 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string> | ||||||
| 					<reference ref="9"/> |  | ||||||
| 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string> |  | ||||||
| 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string> | 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string> | ||||||
| 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string> | 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string> | ||||||
| 					<reference ref="9"/> | 					<reference ref="9"/> | ||||||
|  |  | ||||||
										
											Binary file not shown.
										
									
								
							
		Loading…
	
		Reference in New Issue