forked from joejulian/gio
app: replace driver.Raise with Perform(ActionRaise)
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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",
|
||||
|
||||
+8
-5
@@ -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
|
||||
|
||||
+2
-5
@@ -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 {
|
||||
|
||||
+9
-2
@@ -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)
|
||||
|
||||
+12
-5
@@ -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{
|
||||
|
||||
+22
-24
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user