diff --git a/app/os.go b/app/os.go index c6968954..a6133e1c 100644 --- a/app/os.go +++ b/app/os.go @@ -164,8 +164,6 @@ type driver interface { Configure([]Option) // SetCursor updates the current cursor to name. SetCursor(cursor pointer.Cursor) - // Raise the window at the top. - Raise() // Close the window. Close() // Wakeup wakes up the event loop and sends a WakeupEvent. diff --git a/app/os_android.go b/app/os_android.go index 877d7af0..502c5555 100644 --- a/app/os_android.go +++ b/app/os_android.go @@ -1321,8 +1321,6 @@ func (w *window) Configure(options []Option) { func (w *window) Perform(system.Action) {} -func (w *window) Raise() {} - func (w *window) SetCursor(cursor pointer.Cursor) { runInJVM(javaVM(), func(env *C.JNIEnv) { setCursor(env, w.view, cursor) diff --git a/app/os_ios.go b/app/os_ios.go index 1336d537..ad7124d0 100644 --- a/app/os_ios.go +++ b/app/os_ios.go @@ -288,8 +288,6 @@ func (w *window) EditorStateChanged(old, new editorState) {} func (w *window) Perform(system.Action) {} -func (w *window) Raise() {} - func (w *window) SetAnimating(anim bool) { v := w.view if v == 0 { diff --git a/app/os_js.go b/app/os_js.go index 00a17ed1..5d65c3ae 100644 --- a/app/os_js.go +++ b/app/os_js.go @@ -540,8 +540,6 @@ func (w *window) Configure(options []Option) { func (w *window) Perform(system.Action) {} -func (w *window) Raise() {} - var webCursor = [...]string{ pointer.CursorDefault: "default", pointer.CursorNone: "none", diff --git a/app/os_macos.go b/app/os_macos.go index 5854b6ad..e957c789 100644 --- a/app/os_macos.go +++ b/app/os_macos.go @@ -369,7 +369,14 @@ func (w *window) setTitle(prev, cnf Config) { } } -func (w *window) Perform(system.Action) {} +func (w *window) Perform(acts system.Action) { + walkActions(acts, func(a system.Action) { + switch a { + case system.ActionRaise: + C.raiseWindow(w.window) + } + }) +} func (w *window) SetCursor(cursor pointer.Cursor) { w.cursor = windowSetCursor(w.cursor, cursor) @@ -397,10 +404,6 @@ func (w *window) SetAnimating(anim bool) { } } -func (w *window) Raise() { - C.raiseWindow(w.window) -} - func (w *window) runOnMain(f func()) { runOnMain(func() { // Make sure the view is still valid. The window might've been closed diff --git a/app/os_wayland.go b/app/os_wayland.go index 3dcf4609..696d7107 100644 --- a/app/os_wayland.go +++ b/app/os_wayland.go @@ -1033,6 +1033,8 @@ func (w *window) setTitle(prev, cnf Config) { } func (w *window) Perform(actions system.Action) { + // NB. there is no way for a minimized window to be unminimized. + // https://wayland.app/protocols/xdg-shell#xdg_toplevel:request:set_minimized walkActions(actions, func(action system.Action) { switch action { case system.ActionMove: @@ -1081,11 +1083,6 @@ func (w *window) resize(a system.Action) { C.xdg_toplevel_resize(w.topLvl, s.seat, s.serial, C.uint32_t(edge)) } -func (w *window) Raise() { - // NB. there is no way for a minimized window to be unminimized. - // https://wayland.app/protocols/xdg-shell#xdg_toplevel:request:set_minimized -} - func (w *window) SetCursor(cursor pointer.Cursor) { ptr := w.disp.seat.pointer if ptr == nil { diff --git a/app/os_windows.go b/app/os_windows.go index 9dd9b1c2..de22b201 100644 --- a/app/os_windows.go +++ b/app/os_windows.go @@ -765,9 +765,16 @@ func (w *window) Close() { windows.PostMessage(w.hwnd, windows.WM_CLOSE, 0, 0) } -func (w *window) Perform(system.Action) {} +func (w *window) Perform(acts system.Action) { + walkActions(acts, func(a system.Action) { + switch a { + case system.ActionRaise: + w.raise() + } + }) +} -func (w *window) Raise() { +func (w *window) raise() { windows.SetForegroundWindow(w.hwnd) windows.SetWindowPos(w.hwnd, windows.HWND_TOPMOST, 0, 0, 0, 0, windows.SWP_NOMOVE|windows.SWP_NOSIZE|windows.SWP_SHOWWINDOW) diff --git a/app/os_x11.go b/app/os_x11.go index 8d84343b..5405b03b 100644 --- a/app/os_x11.go +++ b/app/os_x11.go @@ -172,7 +172,7 @@ func (w *x11Window) Configure(options []Option) { switch prev.Mode { case Fullscreen: case Minimized: - w.Raise() + w.raise() fallthrough default: w.config.Mode = Fullscreen @@ -190,7 +190,7 @@ func (w *x11Window) Configure(options []Option) { switch prev.Mode { case Fullscreen: case Minimized: - w.Raise() + w.raise() fallthrough default: w.config.Mode = Maximized @@ -205,7 +205,7 @@ func (w *x11Window) Configure(options []Option) { C.XResizeWindow(w.x, w.xw, C.uint(cnf.Size.X), C.uint(cnf.Size.Y)) case Minimized: w.config.Mode = Windowed - w.Raise() + w.raise() case Maximized: w.config.Mode = Windowed w.sendWMStateEvent(_NET_WM_STATE_REMOVE, w.atoms.wmStateMaximizedHorz, w.atoms.wmStateMaximizedVert) @@ -273,9 +273,16 @@ func (w *x11Window) setTitle(prev, cnf Config) { } } -func (w *x11Window) Perform(system.Action) {} +func (w *x11Window) Perform(acts system.Action) { + walkActions(acts, func(a system.Action) { + switch a { + case system.ActionRaise: + w.raise() + } + }) +} -func (w *x11Window) Raise() { +func (w *x11Window) raise() { var xev C.XEvent ev := (*C.XClientMessageEvent)(unsafe.Pointer(&xev)) *ev = C.XClientMessageEvent{ diff --git a/app/window.go b/app/window.go index 30447cd0..641f3a7a 100644 --- a/app/window.go +++ b/app/window.go @@ -980,31 +980,29 @@ func (w *Window) decorate(d driver, e system.FrameEvent, o *op.Ops) image.Point // Perform the actions on the window. func (w *Window) Perform(actions system.Action) { + var options []Option + walkActions(actions, func(action system.Action) { + switch action { + case system.ActionMinimize: + options = append(options, Minimized.Option()) + case system.ActionMaximize: + options = append(options, Maximized.Option()) + case system.ActionUnmaximize: + options = append(options, Windowed.Option()) + case system.ActionCenter: + options = append(options, + func(m unit.Metric, cnf *Config) { + // Set the flag so the driver can later do the actual centering. + cnf.center = true + }) + case system.ActionClose: + w.closing = true + default: + return + } + actions &^= action + }) w.driverDefer(func(d driver) { - var options []Option - walkActions(actions, func(action system.Action) { - switch action { - case system.ActionMinimize: - options = append(options, Minimized.Option()) - case system.ActionMaximize: - options = append(options, Maximized.Option()) - case system.ActionUnmaximize: - options = append(options, Windowed.Option()) - case system.ActionRaise: - d.Raise() - case system.ActionCenter: - options = append(options, - func(m unit.Metric, cnf *Config) { - // Set the flag so the driver can later do the actual centering. - cnf.center = true - }) - case system.ActionClose: - w.closing = true - default: - return - } - actions &^= action - }) if len(options) > 0 { d.Configure(options) }