Skip to content
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

Merged

Conversation

leethomas
Copy link
Contributor

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.

[window_ setLevel:windowLevel];

NSInteger newLevel = windowLevel + relativeLevel;
if (newLevel >= 0 && newLevel < CGWindowLevelForKey(kCGMaximumWindowLevelKey)) {
Copy link
Contributor

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.

Copy link
Contributor

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);
Copy link
Contributor

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?

Copy link
Contributor Author

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) {
Copy link
Contributor

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?

@kevinsawicki kevinsawicki merged commit dc1c11a into electron:master Jan 30, 2017
@kevinsawicki
Copy link
Contributor

Thanks for this @leethomas 👍 🚢

@zeke
Copy link
Contributor

zeke commented Jan 31, 2017

cc @matheuss @codetheory

@matheuss
Copy link

Amazing, will help a lot on Kap! Thank you @leethomas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants