add moveTop API to move window z-oder to top for win32, mac (#12485)
* add moveTop API to move window z-oder to top for win32, mac * BrowserWindow::MoveTop SetMethod bug fix
This commit is contained in:
parent
9d570dc645
commit
200388ff96
8 changed files with 36 additions and 1 deletions
|
@ -748,6 +748,12 @@ std::vector<int> BrowserWindow::GetPosition() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(OS_WIN) || defined(OS_MACOSX)
|
||||||
|
void BrowserWindow::MoveTop() {
|
||||||
|
window_->MoveTop();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void BrowserWindow::SetTitle(const std::string& title) {
|
void BrowserWindow::SetTitle(const std::string& title) {
|
||||||
window_->SetTitle(title);
|
window_->SetTitle(title);
|
||||||
}
|
}
|
||||||
|
@ -1281,6 +1287,9 @@ void BrowserWindow::BuildPrototype(v8::Isolate* isolate,
|
||||||
.SetMethod("center", &BrowserWindow::Center)
|
.SetMethod("center", &BrowserWindow::Center)
|
||||||
.SetMethod("setPosition", &BrowserWindow::SetPosition)
|
.SetMethod("setPosition", &BrowserWindow::SetPosition)
|
||||||
.SetMethod("getPosition", &BrowserWindow::GetPosition)
|
.SetMethod("getPosition", &BrowserWindow::GetPosition)
|
||||||
|
#if defined(OS_WIN) || defined(OS_MACOSX)
|
||||||
|
.SetMethod("moveTop" , &BrowserWindow::MoveTop)
|
||||||
|
#endif
|
||||||
.SetMethod("setTitle", &BrowserWindow::SetTitle)
|
.SetMethod("setTitle", &BrowserWindow::SetTitle)
|
||||||
.SetMethod("getTitle", &BrowserWindow::GetTitle)
|
.SetMethod("getTitle", &BrowserWindow::GetTitle)
|
||||||
.SetMethod("flashFrame", &BrowserWindow::FlashFrame)
|
.SetMethod("flashFrame", &BrowserWindow::FlashFrame)
|
||||||
|
|
|
@ -159,6 +159,9 @@ class BrowserWindow : public mate::TrackableObject<BrowserWindow>,
|
||||||
void SetResizable(bool resizable);
|
void SetResizable(bool resizable);
|
||||||
bool IsResizable();
|
bool IsResizable();
|
||||||
void SetMovable(bool movable);
|
void SetMovable(bool movable);
|
||||||
|
#if defined(OS_WIN) || defined(OS_MACOSX)
|
||||||
|
void MoveTop();
|
||||||
|
#endif
|
||||||
bool IsMovable();
|
bool IsMovable();
|
||||||
void SetMinimizable(bool minimizable);
|
void SetMinimizable(bool minimizable);
|
||||||
bool IsMinimizable();
|
bool IsMinimizable();
|
||||||
|
|
|
@ -103,6 +103,9 @@ class NativeWindow : public base::SupportsUserData {
|
||||||
virtual double GetSheetOffsetX();
|
virtual double GetSheetOffsetX();
|
||||||
virtual double GetSheetOffsetY();
|
virtual double GetSheetOffsetY();
|
||||||
virtual void SetResizable(bool resizable) = 0;
|
virtual void SetResizable(bool resizable) = 0;
|
||||||
|
#if defined(OS_WIN) || defined(OS_MACOSX)
|
||||||
|
virtual void MoveTop() = 0;
|
||||||
|
#endif
|
||||||
virtual bool IsResizable() = 0;
|
virtual bool IsResizable() = 0;
|
||||||
virtual void SetMovable(bool movable) = 0;
|
virtual void SetMovable(bool movable) = 0;
|
||||||
virtual bool IsMovable() = 0;
|
virtual bool IsMovable() = 0;
|
||||||
|
|
|
@ -50,6 +50,7 @@ class NativeWindowMac : public NativeWindow {
|
||||||
void SetContentSizeConstraints(
|
void SetContentSizeConstraints(
|
||||||
const extensions::SizeConstraints& size_constraints) override;
|
const extensions::SizeConstraints& size_constraints) override;
|
||||||
void SetResizable(bool resizable) override;
|
void SetResizable(bool resizable) override;
|
||||||
|
void MoveTop() override;
|
||||||
bool IsResizable() override;
|
bool IsResizable() override;
|
||||||
void SetMovable(bool movable) override;
|
void SetMovable(bool movable) override;
|
||||||
void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size)
|
void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size)
|
||||||
|
|
|
@ -1192,6 +1192,9 @@ void NativeWindowMac::SetContentSizeConstraints(
|
||||||
NativeWindow::SetContentSizeConstraints(size_constraints);
|
NativeWindow::SetContentSizeConstraints(size_constraints);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindowMac::MoveTop(){
|
||||||
|
[window_ orderWindow:NSWindowAbove relativeTo:0];
|
||||||
|
}
|
||||||
void NativeWindowMac::SetResizable(bool resizable) {
|
void NativeWindowMac::SetResizable(bool resizable) {
|
||||||
SetStyleMask(resizable, NSResizableWindowMask);
|
SetStyleMask(resizable, NSResizableWindowMask);
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,6 @@ void FlipWindowStyle(HWND handle, bool on, DWORD flag) {
|
||||||
bool IsAltKey(const content::NativeWebKeyboardEvent& event) {
|
bool IsAltKey(const content::NativeWebKeyboardEvent& event) {
|
||||||
return event.windows_key_code == ui::VKEY_MENU;
|
return event.windows_key_code == ui::VKEY_MENU;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsAltModifier(const content::NativeWebKeyboardEvent& event) {
|
bool IsAltModifier(const content::NativeWebKeyboardEvent& event) {
|
||||||
typedef content::NativeWebKeyboardEvent::Modifiers Modifiers;
|
typedef content::NativeWebKeyboardEvent::Modifiers Modifiers;
|
||||||
int modifiers = event.GetModifiers();
|
int modifiers = event.GetModifiers();
|
||||||
|
@ -625,6 +624,16 @@ void NativeWindowViews::SetResizable(bool resizable) {
|
||||||
resizable_ = resizable;
|
resizable_ = resizable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
void NativeWindowViews::MoveTop() {
|
||||||
|
gfx::Point pos = GetPosition();
|
||||||
|
gfx::Size size = GetSize();
|
||||||
|
::SetWindowPos(GetAcceleratedWidget(), HWND_TOP,
|
||||||
|
pos.x(), pos.y(), size.width(), size.height(),
|
||||||
|
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool NativeWindowViews::IsResizable() {
|
bool NativeWindowViews::IsResizable() {
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
if (has_frame())
|
if (has_frame())
|
||||||
|
|
|
@ -77,6 +77,9 @@ class NativeWindowViews : public NativeWindow,
|
||||||
void SetContentSizeConstraints(
|
void SetContentSizeConstraints(
|
||||||
const extensions::SizeConstraints& size_constraints) override;
|
const extensions::SizeConstraints& size_constraints) override;
|
||||||
void SetResizable(bool resizable) override;
|
void SetResizable(bool resizable) override;
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
void MoveTop() override;
|
||||||
|
#endif
|
||||||
bool IsResizable() override;
|
bool IsResizable() override;
|
||||||
void SetMovable(bool movable) override;
|
void SetMovable(bool movable) override;
|
||||||
bool IsMovable() override;
|
bool IsMovable() override;
|
||||||
|
|
|
@ -1007,6 +1007,10 @@ can not be focused on.
|
||||||
|
|
||||||
Returns `Boolean` - Whether the window is always on top of other windows.
|
Returns `Boolean` - Whether the window is always on top of other windows.
|
||||||
|
|
||||||
|
#### `win.moveTop()` _macOS_ _Windows_
|
||||||
|
|
||||||
|
Moves window to top(z-order) regardless of focus
|
||||||
|
|
||||||
#### `win.center()`
|
#### `win.center()`
|
||||||
|
|
||||||
Moves window to the center of the screen.
|
Moves window to the center of the screen.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue