mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
app: guarantee a ConfigEvent for every Window.Configure call
Not only is the client guaranteed a ConfigEvent, but app.Window can assume that an unsupported decoration change will be corrected (by a ConfigEvent with Decorated forced to the supported value). Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+1
-3
@@ -1329,9 +1329,7 @@ func (w *window) Configure(options []Option) {
|
||||
if cnf.Decorated != prev.Decorated {
|
||||
w.config.Decorated = cnf.Decorated
|
||||
}
|
||||
if w.config != prev {
|
||||
w.callbacks.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
w.callbacks.Event(ConfigEvent{Config: w.config})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
+1
-3
@@ -281,9 +281,7 @@ func (w *window) Configure([]Option) {
|
||||
prev := w.config
|
||||
// Decorations are never disabled.
|
||||
w.config.Decorated = true
|
||||
if w.config != prev {
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
|
||||
func (w *window) EditorStateChanged(old, new editorState) {}
|
||||
|
||||
+1
-3
@@ -533,9 +533,7 @@ func (w *window) Configure(options []Option) {
|
||||
if cnf.Decorated != prev.Decorated {
|
||||
w.config.Decorated = cnf.Decorated
|
||||
}
|
||||
if w.config != prev {
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
|
||||
func (w *window) Perform(system.Action) {}
|
||||
|
||||
+1
-3
@@ -390,9 +390,7 @@ func (w *window) Configure(options []Option) {
|
||||
C.setWindowStandardButtonHidden(w.window, C.NSWindowMiniaturizeButton, barTrans)
|
||||
C.setWindowStandardButtonHidden(w.window, C.NSWindowZoomButton, barTrans)
|
||||
}
|
||||
if w.config != prev {
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
|
||||
func (w *window) setTitle(prev, cnf Config) {
|
||||
|
||||
+1
-3
@@ -1010,9 +1010,7 @@ func (w *window) Configure(options []Option) {
|
||||
C.xdg_toplevel_set_max_size(w.topLvl, C.int32_t(scaled.X), C.int32_t(scaled.Y))
|
||||
}
|
||||
}
|
||||
if w.config != prev || w.config.Decorated != cnf.Decorated {
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
|
||||
func (w *window) setTitle(prev, cnf Config) {
|
||||
|
||||
+3
-12
@@ -188,7 +188,6 @@ func createNativeWindow() (*window, error) {
|
||||
// It reads the window style and size/position and updates w.config.
|
||||
// If anything has changed it emits a ConfigEvent to notify the application.
|
||||
func (w *window) update() {
|
||||
var triggerEvent bool
|
||||
r := windows.GetWindowRect(w.hwnd)
|
||||
size := image.Point{
|
||||
X: int(r.Right - r.Left - w.deltas.width),
|
||||
@@ -210,17 +209,9 @@ func (w *window) update() {
|
||||
} else {
|
||||
mode = Windowed
|
||||
}
|
||||
if size != w.config.Size {
|
||||
w.config.Size = size
|
||||
triggerEvent = true
|
||||
}
|
||||
if mode != w.config.Mode {
|
||||
w.config.Mode = mode
|
||||
triggerEvent = true
|
||||
}
|
||||
if triggerEvent {
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
w.config.Size = size
|
||||
w.config.Mode = mode
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
|
||||
func windowProc(hwnd syscall.Handle, msg uint32, wParam, lParam uintptr) uintptr {
|
||||
|
||||
+1
-3
@@ -234,9 +234,7 @@ func (w *x11Window) Configure(options []Option) {
|
||||
if cnf.Decorated != prev.Decorated {
|
||||
w.config.Decorated = cnf.Decorated
|
||||
}
|
||||
if w.config != prev {
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
|
||||
func (w *x11Window) setTitle(prev, cnf Config) {
|
||||
|
||||
+1
-6
@@ -861,16 +861,11 @@ func (w *Window) processEvent(d driver, e event.Event) bool {
|
||||
case wakeupEvent:
|
||||
select {
|
||||
case opts := <-w.options:
|
||||
// Send a decoration mode update, in case the driver does not
|
||||
// support switching.
|
||||
cnf := Config{Decorated: w.decorations.enabled}
|
||||
for _, opt := range opts {
|
||||
opt(w.metric, &cnf)
|
||||
}
|
||||
if w.decorations.enabled != cnf.Decorated {
|
||||
w.decorations.enabled = cnf.Decorated
|
||||
w.out <- ConfigEvent{Config: w.effectiveConfig()}
|
||||
}
|
||||
w.decorations.enabled = cnf.Decorated
|
||||
d.Configure(opts)
|
||||
default:
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user