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:
Elias Naur
2021-09-19 09:57:41 +02:00
parent 64bcb1ccd5
commit 18c2ba8e20
9 changed files with 102 additions and 108 deletions
+7 -4
View File
@@ -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() {}