Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Bug: Window menu doesn't work on OSX  (Read 2931 times)

0 Members and 1 Guest are viewing this topic.

deadc0der

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Bug: Window menu doesn't work on OSX
« 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).
« Last Edit: May 19, 2016, 08:31:54 pm by deadc0der »

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Bug: Window menu doesn't work on OSX
« Reply #1 on: May 20, 2016, 08:59:07 am »
This is indeed a bug that I can reproduce on my end. When introduced 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.
SFML / OS X developer

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Bug: Window menu doesn't work on OSX
« Reply #2 on: May 30, 2016, 10:53:11 am »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Bug: Window menu doesn't work on OSX
« Reply #3 on: February 21, 2017, 11:34:07 pm »
A new fix was published, if any OS X users could test it!
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything