Electron Add new Feature moveTop
Electron Browser Window moveTop function
- this feature is merged in electron master branch few month ago
- Problem
- move Top(z-order) function not implemented in electron
const electron = require('electron'); const curWindow = electron.remote.getCurrentWindow(); curWindow.moveTop();
- Solution
- on Window os, we can use SetWindowPos
-
on Mac os, we can use
- Windows OS
void NativeWindowViews::MoveTop() { #if defined(OS_WIN) 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); #elif defined(USE_X11) atom::MoveWindowToForeground(GetAcceleratedWidget()); #endif }
- MacOS
void NativeWindowMac::MoveTop() { [window_ orderWindow:NSWindowAbove relativeTo:0]; }