Mad Fish DT World

MadfishDT world github blog page

Electron Add new Feature moveTop

Electron Browser Window moveTop function

  1. 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];
        }