зеркало из https://github.com/electron/electron.git
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:
Родитель
9d570dc645
Коммит
200388ff96
|
@ -748,6 +748,12 @@ std::vector<int> BrowserWindow::GetPosition() {
|
|||
return result;
|
||||
}
|
||||
|
||||
#if defined(OS_WIN) || defined(OS_MACOSX)
|
||||
void BrowserWindow::MoveTop() {
|
||||
window_->MoveTop();
|
||||
}
|
||||
#endif
|
||||
|
||||
void BrowserWindow::SetTitle(const std::string& title) {
|
||||
window_->SetTitle(title);
|
||||
}
|
||||
|
@ -1281,6 +1287,9 @@ void BrowserWindow::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetMethod("center", &BrowserWindow::Center)
|
||||
.SetMethod("setPosition", &BrowserWindow::SetPosition)
|
||||
.SetMethod("getPosition", &BrowserWindow::GetPosition)
|
||||
#if defined(OS_WIN) || defined(OS_MACOSX)
|
||||
.SetMethod("moveTop" , &BrowserWindow::MoveTop)
|
||||
#endif
|
||||
.SetMethod("setTitle", &BrowserWindow::SetTitle)
|
||||
.SetMethod("getTitle", &BrowserWindow::GetTitle)
|
||||
.SetMethod("flashFrame", &BrowserWindow::FlashFrame)
|
||||
|
|
|
@ -159,6 +159,9 @@ class BrowserWindow : public mate::TrackableObject<BrowserWindow>,
|
|||
void SetResizable(bool resizable);
|
||||
bool IsResizable();
|
||||
void SetMovable(bool movable);
|
||||
#if defined(OS_WIN) || defined(OS_MACOSX)
|
||||
void MoveTop();
|
||||
#endif
|
||||
bool IsMovable();
|
||||
void SetMinimizable(bool minimizable);
|
||||
bool IsMinimizable();
|
||||
|
|
|
@ -103,6 +103,9 @@ class NativeWindow : public base::SupportsUserData {
|
|||
virtual double GetSheetOffsetX();
|
||||
virtual double GetSheetOffsetY();
|
||||
virtual void SetResizable(bool resizable) = 0;
|
||||
#if defined(OS_WIN) || defined(OS_MACOSX)
|
||||
virtual void MoveTop() = 0;
|
||||
#endif
|
||||
virtual bool IsResizable() = 0;
|
||||
virtual void SetMovable(bool movable) = 0;
|
||||
virtual bool IsMovable() = 0;
|
||||
|
|
|
@ -50,6 +50,7 @@ class NativeWindowMac : public NativeWindow {
|
|||
void SetContentSizeConstraints(
|
||||
const extensions::SizeConstraints& size_constraints) override;
|
||||
void SetResizable(bool resizable) override;
|
||||
void MoveTop() override;
|
||||
bool IsResizable() override;
|
||||
void SetMovable(bool movable) override;
|
||||
void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size)
|
||||
|
|
|
@ -1192,6 +1192,9 @@ void NativeWindowMac::SetContentSizeConstraints(
|
|||
NativeWindow::SetContentSizeConstraints(size_constraints);
|
||||
}
|
||||
|
||||
void NativeWindowMac::MoveTop(){
|
||||
[window_ orderWindow:NSWindowAbove relativeTo:0];
|
||||
}
|
||||
void NativeWindowMac::SetResizable(bool resizable) {
|
||||
SetStyleMask(resizable, NSResizableWindowMask);
|
||||
}
|
||||
|
|
|
@ -88,7 +88,6 @@ void FlipWindowStyle(HWND handle, bool on, DWORD flag) {
|
|||
bool IsAltKey(const content::NativeWebKeyboardEvent& event) {
|
||||
return event.windows_key_code == ui::VKEY_MENU;
|
||||
}
|
||||
|
||||
bool IsAltModifier(const content::NativeWebKeyboardEvent& event) {
|
||||
typedef content::NativeWebKeyboardEvent::Modifiers Modifiers;
|
||||
int modifiers = event.GetModifiers();
|
||||
|
@ -625,6 +624,16 @@ void NativeWindowViews::SetResizable(bool 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() {
|
||||
#if defined(OS_WIN)
|
||||
if (has_frame())
|
||||
|
|
|
@ -77,6 +77,9 @@ class NativeWindowViews : public NativeWindow,
|
|||
void SetContentSizeConstraints(
|
||||
const extensions::SizeConstraints& size_constraints) override;
|
||||
void SetResizable(bool resizable) override;
|
||||
#if defined(OS_WIN)
|
||||
void MoveTop() override;
|
||||
#endif
|
||||
bool IsResizable() override;
|
||||
void SetMovable(bool movable) 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.
|
||||
|
||||
#### `win.moveTop()` _macOS_ _Windows_
|
||||
|
||||
Moves window to top(z-order) regardless of focus
|
||||
|
||||
#### `win.center()`
|
||||
|
||||
Moves window to the center of the screen.
|
||||
|
|
Загрузка…
Ссылка в новой задаче