-
Notifications
You must be signed in to change notification settings - Fork 15.8k
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
Feature/macOS relative window levels #8487
Feature/macOS relative window levels #8487
Conversation
[window_ setLevel:windowLevel]; | ||
|
||
NSInteger newLevel = windowLevel + relativeLevel; | ||
if (newLevel >= 0 && newLevel < CGWindowLevelForKey(kCGMaximumWindowLevelKey)) { |
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.
Not a big fan of silent fallbacks. Ideally it should throw when I'm giving it invalid values, like above CGWindowLevelForKey(kCGMaximumWindowLevelKey)
, so I would know I'm doing something wrong.
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.
Yeah, I agree, the new level being out of range should throw an error.
window_->SetAlwaysOnTop(top, level, relativeLevel, &error); | ||
|
||
if (!error.empty()) { | ||
args->ThrowError(error); |
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.
Can you add a spec that asserts this error is thrown for invalid relative levels?
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.
good idea. done
|
||
NSInteger newLevel = windowLevel + relativeLevel; | ||
|
||
if (newLevel >= 0 && newLevel <= maxWindowLevel) { |
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.
Looks like there is a kCGMinimumWindowLevelKey
, maybe that would be better to use than 0
here?
Thanks for this @leethomas 👍 🚢 |
Amazing, will help a lot on Kap! Thank you @leethomas |
Small change to implement #8153. I don't have a test for it because then I'd have to expose the getter for
level
to verify that the levels were taken into account which would feel like a strange thing to do for just a test, unless you guys think it should be in the API.