~eliasnaur/gio-patches

gio: io/pointer: added the grab cursor v1 PROPOSED

~pierrec
~pierrec: 1
 io/pointer: added the grab cursor

 7 files changed, 22 insertions(+), 7 deletions(-)
#419109 apple.yml success
#419110 freebsd.yml success
#419111 linux.yml success
#419112 openbsd.yml success
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/20127/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH gio] io/pointer: added the grab cursor Export this patch

~pierrec
From: pierre <pierre.curto@gmail.com>

Signed-off-by: pierre <pierre.curto@gmail.com>
---
 app/internal/window/os_darwin.go  |  2 ++
 app/internal/window/os_macos.m    |  3 +++
 app/internal/window/os_wayland.go |  2 ++
 app/internal/window/os_windows.go |  2 ++
 app/internal/window/os_x11.go     |  5 ++++-
 app/internal/windows/windows.go   | 13 +++++++------
 io/pointer/pointer.go             |  2 ++
 7 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/app/internal/window/os_darwin.go b/app/internal/window/os_darwin.go
index 0c6b355..a8472bb 100644
--- a/app/internal/window/os_darwin.go
+++ b/app/internal/window/os_darwin.go
@@ -198,6 +198,8 @@ func windowSetCursor(from, to pointer.CursorName) pointer.CursorName {
		curID = 5
	case pointer.CursorRowResize:
		curID = 6
	case pointer.CursorGrab:
		curID = 7
	case pointer.CursorNone:
		runOnMain(func() {
			C.gio_hideCursor()
diff --git a/app/internal/window/os_macos.m b/app/internal/window/os_macos.m
index 2fefb14..fa5a98e 100644
--- a/app/internal/window/os_macos.m
+++ b/app/internal/window/os_macos.m
@@ -119,6 +119,9 @@ void gio_setCursor(NSUInteger curID) {
			case 6:
				[NSCursor.resizeUpDownCursor set];
				break;
			case 7:
                [NSCursor.openHandCursor set];
                break;
			default:
				[NSCursor.arrowCursor set];
				break;
diff --git a/app/internal/window/os_wayland.go b/app/internal/window/os_wayland.go
index 535cf0c..cee2128 100644
--- a/app/internal/window/os_wayland.go
+++ b/app/internal/window/os_wayland.go
@@ -930,6 +930,8 @@ func (w *window) SetCursor(name pointer.CursorName) {
		name = "top_side"
	case pointer.CursorColResize:
		name = "left_side"
	case pointer.CursorGrab:
		name = "hand1"
	}
	cname := C.CString(string(name))
	defer C.free(unsafe.Pointer(cname))
diff --git a/app/internal/window/os_windows.go b/app/internal/window/os_windows.go
index 2d0a9da..559134a 100644
--- a/app/internal/window/os_windows.go
+++ b/app/internal/window/os_windows.go
@@ -606,6 +606,8 @@ func loadCursor(name pointer.CursorName) (syscall.Handle, error) {
		curID = windows.IDC_SIZEWE
	case pointer.CursorRowResize:
		curID = windows.IDC_SIZENS
	case pointer.CursorGrab:
		curID = windows.IDC_SIZEALL
	case pointer.CursorNone:
		return 0, nil
	}
diff --git a/app/internal/window/os_x11.go b/app/internal/window/os_x11.go
index ab44ca8..367edd9 100644
--- a/app/internal/window/os_x11.go
+++ b/app/internal/window/os_x11.go
@@ -118,10 +118,13 @@ func (w *x11Window) WriteClipboard(s string) {
}

func (w *x11Window) SetCursor(name pointer.CursorName) {
	if name == pointer.CursorNone {
	switch name {
	case pointer.CursorNone:
		w.cursor = name
		C.XFixesHideCursor(w.x, w.xw)
		return
	case pointer.CursorGrab:
		name = "hand1"
	}
	if w.cursor == pointer.CursorNone {
		C.XFixesShowCursor(w.x, w.xw)
diff --git a/app/internal/windows/windows.go b/app/internal/windows/windows.go
index c8846e5..17ce6bb 100644
--- a/app/internal/windows/windows.go
+++ b/app/internal/windows/windows.go
@@ -65,12 +65,13 @@ const (

	HTCLIENT = 1

	IDC_ARROW  = 32512
	IDC_IBEAM  = 32513
	IDC_HAND   = 32649
	IDC_CROSS  = 32515
	IDC_SIZENS = 32645
	IDC_SIZEWE = 32644
	IDC_ARROW   = 32512
	IDC_IBEAM   = 32513
	IDC_HAND    = 32649
	IDC_CROSS   = 32515
	IDC_SIZENS  = 32645
	IDC_SIZEWE  = 32644
	IDC_SIZEALL = 32646

	INFINITE = 0xFFFFFFFF

diff --git a/io/pointer/pointer.go b/io/pointer/pointer.go
index b112bfd..3b4326f 100644
--- a/io/pointer/pointer.go
+++ b/io/pointer/pointer.go
@@ -103,6 +103,8 @@ const (
	CursorColResize CursorName = "col-resize"
	// CursorRowResize is the cursor for horizontal resize.
	CursorRowResize CursorName = "row-resize"
	// CursorGrab is the cursor for moving object in any direction.
	CursorGrab CursorName = "grab"
	// CursorNone hides the cursor. To show it again, use any other cursor.
	CursorNone CursorName = "none"
)
-- 
2.26.2
builds.sr.ht
gio/patches: SUCCESS in 20m14s

[io/pointer: added the grab cursor][0] from [~pierrec][1]

[0]: https://lists.sr.ht/~eliasnaur/gio-patches/patches/20127
[1]: mailto:pierre.curto@gmail.com

✓ #419109 SUCCESS gio/patches/apple.yml   https://builds.sr.ht/~eliasnaur/job/419109
✓ #419111 SUCCESS gio/patches/linux.yml   https://builds.sr.ht/~eliasnaur/job/419111
✓ #419112 SUCCESS gio/patches/openbsd.yml https://builds.sr.ht/~eliasnaur/job/419112
✓ #419110 SUCCESS gio/patches/freebsd.yml https://builds.sr.ht/~eliasnaur/job/419110
Thanks, applied.

Elias