implement relative window levels, closes #8153

This commit is contained in:
leethomas 2017-01-23 20:36:09 -08:00
parent 91ed9aeeee
commit 7a0a87a6f3
6 changed files with 20 additions and 7 deletions

View file

@ -512,8 +512,10 @@ bool Window::IsClosable() {
void Window::SetAlwaysOnTop(bool top, mate::Arguments* args) {
std::string level = "floating";
int relativeLevel = 0;
args->GetNext(&level);
window_->SetAlwaysOnTop(top, level);
args->GetNext(&relativeLevel);
window_->SetAlwaysOnTop(top, level, relativeLevel);
}
bool Window::IsAlwaysOnTop() {

View file

@ -119,7 +119,8 @@ class NativeWindow : public base::SupportsUserData,
virtual void SetClosable(bool closable) = 0;
virtual bool IsClosable() = 0;
virtual void SetAlwaysOnTop(bool top,
const std::string& level = "floating") = 0;
const std::string& level = "floating",
int relativeLevel = 0) = 0;
virtual bool IsAlwaysOnTop() = 0;
virtual void Center() = 0;
virtual void SetTitle(const std::string& title) = 0;

View file

@ -67,7 +67,8 @@ class NativeWindowMac : public NativeWindow,
bool IsFullScreenable() override;
void SetClosable(bool closable) override;
bool IsClosable() override;
void SetAlwaysOnTop(bool top, const std::string& level) override;
void SetAlwaysOnTop(bool top, const std::string& level,
int relativeLevel) override;
bool IsAlwaysOnTop() override;
void Center() override;
void SetTitle(const std::string& title) override;

View file

@ -1056,8 +1056,9 @@ bool NativeWindowMac::IsClosable() {
return [window_ styleMask] & NSClosableWindowMask;
}
void NativeWindowMac::SetAlwaysOnTop(bool top, const std::string& level) {
void NativeWindowMac::SetAlwaysOnTop(bool top, const std::string& level, int relativeLevel) {
int windowLevel = NSNormalWindowLevel;
if (top) {
if (level == "floating") {
windowLevel = NSFloatingWindowLevel;
@ -1078,7 +1079,13 @@ void NativeWindowMac::SetAlwaysOnTop(bool top, const std::string& level) {
windowLevel = NSDockWindowLevel;
}
}
[window_ setLevel:windowLevel];
NSInteger newLevel = windowLevel + relativeLevel;
if (newLevel >= 0 && newLevel < CGWindowLevelForKey(kCGMaximumWindowLevelKey)) {
[window_ setLevel:newLevel];
} else {
[window_ setLevel:windowLevel];
}
}
bool NativeWindowMac::IsAlwaysOnTop() {

View file

@ -682,7 +682,8 @@ bool NativeWindowViews::IsClosable() {
#endif
}
void NativeWindowViews::SetAlwaysOnTop(bool top, const std::string& level) {
void NativeWindowViews::SetAlwaysOnTop(bool top, const std::string& level,
int relativeLevel) {
window_->SetAlwaysOnTop(top);
}

View file

@ -86,7 +86,8 @@ class NativeWindowViews : public NativeWindow,
bool IsFullScreenable() override;
void SetClosable(bool closable) override;
bool IsClosable() override;
void SetAlwaysOnTop(bool top, const std::string& level) override;
void SetAlwaysOnTop(bool top, const std::string& level,
int relativeLevel) override;
bool IsAlwaysOnTop() override;
void Center() override;
void SetTitle(const std::string& title) override;