mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 18:05:35 +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:
@@ -46,6 +46,11 @@ type Config struct {
|
||||
CustomRenderer bool
|
||||
}
|
||||
|
||||
// ConfigEvent is sent whenever the configuration of a Window changes.
|
||||
type ConfigEvent struct {
|
||||
Config Config
|
||||
}
|
||||
|
||||
func (c *Config) apply(m unit.Metric, options []Option) {
|
||||
for _, o := range options {
|
||||
o(m, c)
|
||||
@@ -135,9 +140,6 @@ type driver interface {
|
||||
// Configure the window.
|
||||
Configure([]Option)
|
||||
|
||||
// Config returns the current configuration.
|
||||
Config() Config
|
||||
|
||||
// SetCursor updates the current cursor to name.
|
||||
SetCursor(name pointer.CursorName)
|
||||
|
||||
@@ -187,4 +189,5 @@ func newWindowRendezvous() *windowRendezvous {
|
||||
return wr
|
||||
}
|
||||
|
||||
func (_ wakeupEvent) ImplementsEvent() {}
|
||||
func (wakeupEvent) ImplementsEvent() {}
|
||||
func (ConfigEvent) ImplementsEvent() {}
|
||||
|
||||
Reference in New Issue
Block a user