mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 09:25:38 +00:00
app: replace Window.Config with ConfigEvent
Unlike Raise, Close and other fire-and-forget methods on Window, Config calls driverRun because it needs to wait for the result. However, driverRun isn't guaranteed to block in all contexts. This change avoids the synchronization dance altogether by removing the Config method and introducing a ConfigEvent event. The event also makes it clear when the configuration changes. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+11
-11
@@ -507,19 +507,20 @@ func (w *window) SetAnimating(anim bool) {
|
||||
}
|
||||
|
||||
func (w *window) draw(sync bool) {
|
||||
width, height := C.ANativeWindow_getWidth(w.win), C.ANativeWindow_getHeight(w.win)
|
||||
if width == 0 || height == 0 {
|
||||
size := image.Pt(int(C.ANativeWindow_getWidth(w.win)), int(C.ANativeWindow_getHeight(w.win)))
|
||||
if size != w.config.Size {
|
||||
w.config.Size = size
|
||||
w.callbacks.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
if size.X == 0 || size.Y == 0 {
|
||||
return
|
||||
}
|
||||
const inchPrDp = 1.0 / 160
|
||||
ppdp := float32(w.dpi) * inchPrDp
|
||||
w.callbacks.Event(frameEvent{
|
||||
FrameEvent: system.FrameEvent{
|
||||
Now: time.Now(),
|
||||
Size: image.Point{
|
||||
X: int(width),
|
||||
Y: int(height),
|
||||
},
|
||||
Now: time.Now(),
|
||||
Size: w.config.Size,
|
||||
Insets: w.insets,
|
||||
Metric: unit.Metric{
|
||||
PxPerDp: ppdp,
|
||||
@@ -815,13 +816,12 @@ func (w *window) Configure(options []Option) {
|
||||
w.config.Mode = Windowed
|
||||
}
|
||||
}
|
||||
if w.config != prev {
|
||||
w.callbacks.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (w *window) Config() Config {
|
||||
return w.config
|
||||
}
|
||||
|
||||
func (w *window) Raise() {}
|
||||
|
||||
func (w *window) SetCursor(name pointer.CursorName) {
|
||||
|
||||
Reference in New Issue
Block a user