From 679a34b116deba2282d23948ceb88e093b68493c Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sun, 27 Sep 2020 14:29:31 +0200 Subject: [PATCH] app/internal/window: default to X11 on unix systems Wayland doesn't guarantee the presence of server-side window decorations (border, close/maximize/minimize buttons), and Gio doesn't have client-side decorations either (issue #29). The issue is more than a year old, so it's time to default to X11 to have a good out-of-the-box experience on unix systems. Updates gio#29 Signed-off-by: Elias Naur --- app/internal/window/os_unix.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/internal/window/os_unix.go b/app/internal/window/os_unix.go index baaebb56..6332f6bd 100644 --- a/app/internal/window/os_unix.go +++ b/app/internal/window/os_unix.go @@ -12,20 +12,20 @@ func Main() { select {} } -// instead of creating files with build tags for each combination of wayland +/- x11 +type windowDriver func(Callbacks, *Options) error + +// Instead of creating files with build tags for each combination of wayland +/- x11 // let each driver initialize these variables with their own version of createWindow. -var wlDriver, x11Driver func(Callbacks, *Options) error +var wlDriver, x11Driver windowDriver func NewWindow(window Callbacks, opts *Options) error { - var errFirst, err error - if wlDriver != nil { - if err = wlDriver(window, opts); err == nil { - return nil + var errFirst error + for _, d := range []windowDriver{x11Driver, wlDriver} { + if d == nil { + continue } - errFirst = err - } - if x11Driver != nil { - if err = x11Driver(window, opts); err == nil { + err := d(window, opts) + if err == nil { return nil } if errFirst == nil {