-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Fix #3857: Enter Full Screen exists under 2 different menu items #3891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #3857: Enter Full Screen exists under 2 different menu items #3891
Conversation
iina/AppDelegate.swift
Outdated
@@ -201,6 +201,9 @@ class AppDelegate: NSObject, NSApplicationDelegate { | |||
} | |||
} | |||
|
|||
// Hide Window > "Enter Full Screen" menu item, becuase this is already present in the Video menu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because
iina/AppDelegate.swift
Outdated
@@ -201,6 +201,9 @@ class AppDelegate: NSObject, NSApplicationDelegate { | |||
} | |||
} | |||
|
|||
// Hide Window > "Enter Full Screen" menu item, becuase this is already present in the Video menu | |||
UserDefaults.standard.set(false, forKey: "NSFullScreenMenuItemEverywhere") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the wrong place to set this. That is what is causing this:
Although it's set when IINA starts, it will not take effect until the app is closed & reopened.
The only Apple documentation on this seems to be AppKit Release Notes (macOS 10.12 and Earlier) which says:
AppKit automatically creates an "Enter Full Screen" menu item after the application finishes launching if an equivalent menu item isn't found. If this menu item should not be created for your app, before NSApplicationDidFinishLaunchingNotification is sent you may set the NSFullScreenMenuItemEverywhere default to NO.
This statement has been added to the method applicationDidFinishLaunching
which is after the NSApplicationDidFinishLaunchingNotification
notification. I tested moving this statement into the applicationWillFinishLaunching
method right after the "App will launch" log is emitted. I used defaults
to make sure that key was not set. The menu item was hidden on the first run. I did not have to restart IINA for it to take effect.
I think the correct solution here should be to get AppKit to recognize our fullscreen menu item as the legitimate one, rather than using the user default to suppress the addition of the second one in the Window menu. |
a31df3c
to
fd261eb
Compare
I've force-re-submitted an improved commit based on the above feedback, though honestly @low-batt should get full credit, since he did do more than 50% of the work for this one-liner.
@saagarjha I did a deep-dive into this... Of the affected open source projects I found, the majority seem to have settled on the above preference setting (Electron being the biggest name I found) but I did discover that the Chromium was able to trigger Apple's matching logic by changing the name of the menu item action to I was able to do the same in this branch, but there are still some problems. I was only able to trigger the override by hard-coding the action selector in the XIB file. But I still can't figure out how to create a selector for MainWindowController inside the XIB -- IINA is currently doing that in code after the app has started. Best I could do was to make the XIB call an action in MenuController, which in turn calls the action in MainWindowController. And everything works this way - except the "Enter Full Screen" menu item is never grayed out because it's using a MenuController selector instead of a MainWindowController selector, and I'm not ready to commit a lot more time to figure out how to make that work. IMHO it seems like using a special selector name is not the most robust solution, especially because I haven't found any documentation from Apple to support it. At least the preference key is documented. |
@svobs Full credit goes to you for providing the implementation. With Apple specifying a clear requirement on how the menus must be structured, but apparently no documentation on how to implement it, I thought this needed a detailed review. Due to the feedback from @saagarjha I looked again for guidence from Apple on how to implement the HIG requirement of suppressing the menu item in the One reason why developers fail to document things is because "it is obvious". So I tried a quick experiment. I first made sure to delete the preference:
The documentation for NSWindow.toggleFullScreen says:
IINA's main menu does not contain a "Enter Full Screen" menu item. In a quick test I added that menu item to the Given the only documentation for I followed this post in order to properly attach the action: If the menu item action is not attached to |
My understanding is that using the toggleFullScreen: action is the correct way to do this, yes. Is it not being propagated correctly through the responder chain? |
The responder chain is not being used. The full screen menu item under the The task at hand is to eliminate the full screen menu item under the |
Description:
Since the "Enter Fullscreen" option already exists under the Video menu, this patch hides the instance under the Window menu, to conform with Apple HIG. Note:
fn-F
shortcut, which still works.