app: replace driver.Close with Perform(ActionClose)

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-06-23 14:31:44 +02:00
parent 43116400d0
commit 371de3462b
9 changed files with 26 additions and 45 deletions
-2
View File
@@ -162,8 +162,6 @@ type driver interface {
Configure([]Option)
// SetCursor updates the current cursor to name.
SetCursor(cursor pointer.Cursor)
// Close the window.
Close()
// Wakeup wakes up the event loop and sends a WakeupEvent.
Wakeup()
// Perform actions on the window.
-3
View File
@@ -1414,9 +1414,6 @@ func setNavigationColor(env *C.JNIEnv, view C.jobject, color color.NRGBA) {
)
}
// Close the window. Not implemented for Android.
func (w *window) Close() {}
// runOnMain runs a function on the Java main thread.
func runOnMain(f func(env *C.JNIEnv)) {
go func() {
-3
View File
@@ -346,9 +346,6 @@ func (w *window) ShowTextInput(show bool) {
func (w *window) SetInputHint(_ key.InputHint) {}
// Close the window. Not implemented for iOS.
func (w *window) Close() {}
func newWindow(win *callbacks, options []Option) error {
mainWindow.in <- windowAndConfig{win, options}
return <-mainWindow.errs
-3
View File
@@ -597,9 +597,6 @@ func (w *window) SetInputHint(mode key.InputHint) {
w.keyboard(mode)
}
// Close the window. Not implemented for js.
func (w *window) Close() {}
func (w *window) resize() {
w.scale = float32(w.window.Get("devicePixelRatio").Float())
+3 -4
View File
@@ -375,6 +375,9 @@ func (w *window) Perform(acts system.Action) {
C.raiseWindow(w.window)
}
})
if acts&system.ActionClose != 0 {
C.closeWindow(w.window)
}
}
func (w *window) SetCursor(cursor pointer.Cursor) {
@@ -413,10 +416,6 @@ func (w *window) runOnMain(f func()) {
})
}
func (w *window) Close() {
C.closeWindow(w.window)
}
func (w *window) setStage(stage system.Stage) {
if stage == w.stage {
return
+2 -5
View File
@@ -1034,6 +1034,8 @@ func (w *window) Perform(actions system.Action) {
switch action {
case system.ActionMove:
w.move()
case system.ActionClose:
w.dead = true
default:
w.resize(action)
}
@@ -1627,11 +1629,6 @@ func (w *window) SetInputHint(_ key.InputHint) {}
func (w *window) EditorStateChanged(old, new editorState) {}
// Close the window.
func (w *window) Close() {
w.dead = true
}
func (w *window) NewContext() (context, error) {
var firstErr error
if f := newWaylandVulkanContext; f != nil {
+2 -4
View File
@@ -753,10 +753,6 @@ func (w *window) HWND() (syscall.Handle, int, int) {
return w.hwnd, w.config.Size.X, w.config.Size.Y
}
func (w *window) Close() {
windows.PostMessage(w.hwnd, windows.WM_CLOSE, 0, 0)
}
func (w *window) Perform(acts system.Action) {
walkActions(acts, func(a system.Action) {
switch a {
@@ -774,6 +770,8 @@ func (w *window) Perform(acts system.Action) {
windows.SetWindowPos(w.hwnd, 0, x, y, dx, dy, windows.SWP_NOOWNERZORDER|windows.SWP_FRAMECHANGED)
case system.ActionRaise:
w.raise()
case system.ActionClose:
windows.PostMessage(w.hwnd, windows.WM_CLOSE, 0, 0)
}
})
}
+5 -2
View File
@@ -266,6 +266,9 @@ func (w *x11Window) Perform(acts system.Action) {
w.raise()
}
})
if acts&system.ActionClose != 0 {
w.close()
}
}
func (w *x11Window) center() {
@@ -331,8 +334,8 @@ func (w *x11Window) SetInputHint(_ key.InputHint) {}
func (w *x11Window) EditorStateChanged(old, new editorState) {}
// Close the window.
func (w *x11Window) Close() {
// close the window.
func (w *x11Window) close() {
var xev C.XEvent
ev := (*C.XClientMessageEvent)(unsafe.Pointer(&xev))
*ev = C.XClientMessageEvent{
+14 -19
View File
@@ -456,25 +456,10 @@ func (c *callbacks) Event(e event.Event) bool {
c.waitEvents = c.waitEvents[:len(c.waitEvents)-1]
handled = c.w.processEvent(c.d, e)
}
closing := false
if _, iswakeup := e.(wakeupEvent); iswakeup {
select {
case opts := <-c.w.options:
c.d.Configure(opts)
default:
}
select {
case acts := <-c.w.actions:
// Pospone closing to last.
closing = (acts & system.ActionClose) != 0
acts &^= system.ActionClose
c.d.Perform(acts)
default:
}
}
c.w.updateState(c.d)
if closing {
c.d.Close()
select {
case <-c.w.dead:
default:
c.w.updateState(c.d)
}
return handled
}
@@ -867,6 +852,16 @@ func (w *Window) processEvent(d driver, e event.Event) bool {
w.out <- e2
w.waitAck(d)
case wakeupEvent:
select {
case opts := <-w.options:
d.Configure(opts)
default:
}
select {
case acts := <-w.actions:
d.Perform(acts)
default:
}
case ConfigEvent:
w.decorations.Config = e2.Config
if !w.fallbackDecorate() {