Allow custom window level when sending window to top #7296

Merged
merged 6 commits into from Sep 28, 2016

Projects

None yet

4 participants

@adammeyer
Contributor

This allows for a custom window level to be set when sending a window to the top.

win.setAlwaysOnTop(true, 102);

This can be used when the NSFloatingWindowLevel isn't high enough. I have used this to put a window above the top menu bar.

@adammeyer adammeyer Allow custom window level when sending window to top
fbb3a28
@kevinsawicki
Contributor

Might be useful to include the possible values as well of these https://developer.apple.com/reference/appkit/nswindow/1664726-window_levels#symbols in the docs

@kevinsawicki kevinsawicki self-assigned this Sep 21, 2016
@adammeyer adammeyer custom window level docs
b35bde6
@adammeyer
Contributor

@kevinsawicki Thanks! I added the details to the docs. Currently the parameter is an integer, not a mac window level constant. I like that idea, but I'm not sure how to take a constant in as a string and then convert it to the constant value in the native window controller.

@kevinsawicki
Contributor

I like that idea, but I'm not sure how to take a constant in as a string and then convert it to the constant value in the native window controller.

I can help you update it, what do you think about these string value names for the different integer values:

  • NSNormalWindowLevel -> 'normal'
  • NSFloatingWindowLevel -> 'floating'
  • NSTornOffMenuWindowLevel -> 'torn-off-menu'
  • NSModalPanelWindowLevel -> 'modal-panel'
  • NSMainMenuWindowLevel -> 'main-menu'
  • NSStatusWindowLevel -> 'status'
  • NSPopUpMenuWindowLevel -> 'pop-up-menu'
  • NSScreenSaverWindowLevel -> 'screen-saver'
  • NSDockWindowLevel -> 'dock'
@adammeyer adammeyer custom window level as string
783d47f
@adammeyer
Contributor

Looks great! I committed my best attempt. I'm getting some errors with the string declarations.

@kevinsawicki kevinsawicki Fix compiler errors
bce6262
@kevinsawicki
Contributor

@adammeyer I pushed a change that gets things compiling.

When testing this though it is kind of hard to tell the differences between these levels, they seem to all be very similar.

Can you expand on how you plan to use it a bit?

kevinsawicki added some commits Sep 22, 2016
@kevinsawicki kevinsawicki Ignore level when calling SetAlwaysOnTop on Widget
c336cf5
@kevinsawicki kevinsawicki Compare against NSNormalWindowLevel in IsAlwaysOnTop
df03c92
@adammeyer
Contributor

I would like to open a window that fills the screen and is above the menu bar, without the animations that come with making a window "fullscreen". Kind of like showing a PowerPoint presentation.

I could also see it being used if you wanted multiple windows to always be on top, but one to be the top most of those.

@kevinsawicki
Contributor

I would like to open a window that fills the screen and is above the menu bar

Which level allows this? Curious to test it locally.

@adammeyer
Contributor

I believe screen-saver.

@adammeyer
Contributor

Yes, just confirmed it is screen-saver

@adammeyer
Contributor

@kevinsawicki Anything left to add?

@zcbenz
Contributor
zcbenz commented Sep 28, 2016

👍

@zcbenz zcbenz merged commit de76bf5 into electron:master Sep 28, 2016

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
@matheuss
matheuss commented Nov 1, 2016 edited

@adammeyer I just wanted to tell you that you're my hero – this will be very useful on wulkano/kap 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment