~eliasnaur/gio-patches

gio: app/internal: [X11] implement Window.Close v1 PROPOSED

~sbinet
~sbinet: 1
 app/internal: [X11] implement Window.Close

 2 files changed, 18 insertions(+), 3 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~eliasnaur/gio-patches/patches/11304/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH gio] app/internal: [X11] implement Window.Close Export this patch

~sbinet
From: Sebastien Binet <s@sbinet.org>

Signed-off-by: Sebastien Binet <s@sbinet.org>
---
 app/internal/window/os_x11.go | 19 +++++++++++++++++--
 app/window.go                 |  2 +-
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/app/internal/window/os_x11.go b/app/internal/window/os_x11.go
index a0ece14..42749b0 100644
--- a/app/internal/window/os_x11.go
+++ b/app/internal/window/os_x11.go
@@ -110,8 +110,23 @@ func (w *x11Window) WriteClipboard(s string) {

func (w *x11Window) ShowTextInput(show bool) {}

// Close the window. Not implemented for X11.
func (w *x11Window) Close() {}
// Close the window.
func (w *x11Window) Close() {
	w.mu.Lock()
	defer w.mu.Unlock()

	ev := C.XClientMessageEvent{
		_type:        C.ClientMessage,
		display:      w.x,
		window:       w.xw,
		message_type: w.atom("WM_PROTOCOLS", true),
		format:       32,
	}
	arr := (*[5]C.long)(unsafe.Pointer(&ev.data))
	arr[0] = C.long(w.atoms.evDelWindow)
	arr[1] = C.CurrentTime
	C.XSendEvent(w.x, w.xw, C.False, C.NoEventMask, (*C.XEvent)(unsafe.Pointer(&ev)))
}

var x11OneByte = make([]byte, 1)

diff --git a/app/window.go b/app/window.go
index 6b66511..2c9860c 100644
--- a/app/window.go
+++ b/app/window.go
@@ -211,7 +211,7 @@ func (w *Window) WriteClipboard(s string) {
// Close the window. The window's event loop should exit when it receives
// system.DestroyEvent.
//
// Currently, only macOS and Windows driver implements this functionality,
// Currently, only macOS, Windows and X11 drivers implement this functionality,
// all others are stubbed.
func (w *Window) Close() {
	w.driverDo(func() {
-- 
2.26.2
Thank you, merged.

-- elias