SFML community forums

Help => Window => Topic started by: deadc0der on May 19, 2016, 07:55:53 pm

Title: Bug: Window menu doesn't work on OSX
Post by: deadc0der on May 19, 2016, 07:55:53 pm
Hi, I think I found a bug in the OSX version of SFML.

The "Window" menu in the menu bar normally contains the options "Minimize", "Zoom" and "Enter Full Screen", as well as a list of windows. In an SFML program, though these menu items exist, they are greyed out, which also has the unfortunate side-effect that the familiar keyboard shortcuts for these actions don't work either.

I was able to reproduce the problem on a simple program that only creates a window and runs an event loop, and even on all of the examples (except, of course, the command-line ones), which leads me to believe the problem was effectively in SFML.

So, does the problem always happen or is it just on my machine?

EDIT: I tried to associate the "Minimize" menu item with the selector miniaturize: instead of performMiniaturize:. That didn't change anything.

EDIT 2: I was able to get "Minimize" and "Zoom" to work (the items are enabled, and perform the requested function) by associating these menu items with the following custom selectors:
- (void) doMiniaturize: (id) sender {
        [[self keyWindow] performMiniaturize: sender];
}

- (void) doZoom: (id) sender {
        [[self keyWindow] performZoom: sender];
}
 

However, this can't be applied to "Enter Full Screen" and the window list, since these are added by the system (presumably during the call to [NSApp setWindowsMenu]).

I believe the problem is that the menu items target the SFApplication instance, when they should target the current key window (NSWindow does have performMiniaturize and performZoom). However, I don't know how to make the binding such that the target changes when a different window becomes key (apart from overriding the delegate to find out when a different window becomes key, but that seems particularly clumsy).
Title: Re: Bug: Window menu doesn't work on OSX
Post by: Hiura on May 20, 2016, 08:59:07 am
This is indeed a bug that I can reproduce on my end. When introduced (https://github.com/SFML/SFML/commit/a6dba586ee944b5f5ff125c2154cc47ca19ce46e) this worked fine.

In a first phase, you could open an issue on Github for that. But since I won't have time to look into this soon, it would be very appreciated if you could use `git bisect` to find which commit did introduce the regression. Note that to do this, you'll need to update cmake/Config.cmake this the attached patch on some git versions if you're using OS X 10.10 or above.

Pin-pointing the actual commit that broke the menu would be very helpful to understand what went wrong.  :)

Regarding the "Enter Full Screen" action, this cannot be implemented ATM because we cannot programmatically change the "style" of a window in SFML. It would be inconsistent with this limitation to have such menu.
Title: Re: Bug: Window menu doesn't work on OSX
Post by: eXpl0it3r on May 30, 2016, 10:53:11 am
Ticket has been created. (https://github.com/SFML/SFML/issues/1091)
Title: Re: Bug: Window menu doesn't work on OSX
Post by: eXpl0it3r on February 21, 2017, 11:34:07 pm
A new fix (https://github.com/SFML/SFML/pull/1193) was published, if any OS X users could test it!