~eliasnaur/gio-patches

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH] app/internal/window: cleanup X11 initialization

Details
Message ID
<20191111124154.12118-1-db047h@gmail.com>
DKIM signature
missing
Download raw message
Patch: +15 -23
Removed redundant XSelectInput and XChangeWindowAttributes as well as
obsolete screen parameter in x11DetectUIScale.

Signed-off-by: Denis Bernard <db047h@gmail.com>
---
 app/internal/window/os_x11.go | 38 ++++++++++++++---------------------
 1 file changed, 15 insertions(+), 23 deletions(-)

diff --git a/app/internal/window/os_x11.go b/app/internal/window/os_x11.go
index f82f17d..d820360 100644
--- a/app/internal/window/os_x11.go
+++ b/app/internal/window/os_x11.go
@@ -478,30 +478,26 @@ func newX11Window(gioWin Callbacks, opts *Options) error {
		return errors.New("x11: cannot connect to the X server")
	}

	root := C.XDefaultRootWindow(dpy)
	screen := C.XDefaultScreen(dpy)
	ppsp := x11DetectUIScale(dpy, screen)
	ppsp := x11DetectUIScale(dpy)
	cfg := config{pxPerDp: ppsp, pxPerSp: ppsp}
	swa := C.XSetWindowAttributes{
		event_mask: C.ExposureMask | C.FocusChangeMask | // update
			C.KeyPressMask | C.KeyReleaseMask | // keyboard
			C.ButtonPressMask | C.ButtonReleaseMask | // mouse clicks
			C.PointerMotionMask | // mouse movement
			C.StructureNotifyMask, // resize
		background_pixmap: C.None,
		override_redirect: C.False,
	}
	win := C.XCreateWindow(dpy, C.XDefaultRootWindow(dpy),
		0, 0, C.uint(cfg.Px(opts.Width)), C.uint(cfg.Px(opts.Height)),
		0, C.CopyFromParent, C.InputOutput, nil,
		C.CWEventMask|C.CWBackPixmap|C.CWOverrideRedirect, &swa)
	var (
		swa C.XSetWindowAttributes
		xim C.XIM
		xic C.XIC
	)
	swa.event_mask = C.ExposureMask | C.PointerMotionMask | C.KeyPressMask
	swa.background_pixmap = C.None
	win := C.XCreateWindow(dpy, root,
		0, 0, C.uint(cfg.Px(opts.Width)), C.uint(cfg.Px(opts.Height)), 0,
		C.CopyFromParent, C.InputOutput,
		nil, C.CWEventMask|C.CWBackPixmap,
		&swa)
	C.gio_x11_init_ime(dpy, win, &xim, &xic)
	C.XSelectInput(dpy, win, 0|
		C.ExposureMask|C.FocusChangeMask| // update
		C.KeyPressMask|C.KeyReleaseMask| // keyboard
		C.ButtonPressMask|C.ButtonReleaseMask| // mouse clicks
		C.PointerMotionMask| // mouse movement
		C.StructureNotifyMask, // resize
	)

	w := &x11Window{
		w: gioWin, x: dpy, xw: win,
@@ -514,10 +510,6 @@ func newX11Window(gioWin Callbacks, opts *Options) error {
	w.notify.read = pipe[0]
	w.notify.write = pipe[1]

	var xattr C.XSetWindowAttributes
	xattr.override_redirect = C.False
	C.XChangeWindowAttributes(dpy, win, C.CWOverrideRedirect, &xattr)

	var hints C.XWMHints
	hints.input = C.True
	hints.flags = C.InputHint
@@ -548,7 +540,7 @@ func newX11Window(gioWin Callbacks, opts *Options) error {
}

// detectUIScale reports the system UI scale, or 1.0 if it fails.
func x11DetectUIScale(dpy *C.Display, screen C.int) float32 {
func x11DetectUIScale(dpy *C.Display) float32 {
	// default fixed DPI value used in most desktop UI toolkits
	const defaultDesktopDPI = 96
	var scale float32 = 1.0
-- 
2.17.1
Details
Message ID
<BYD2YVFS7PDO.192V5LA7RMCQC@toolbox>
In-Reply-To
<20191111124154.12118-1-db047h@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Thank you, merged.
Review patch Export thread (mbox)