-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcursor_unix.go
58 lines (48 loc) · 1.13 KB
/
cursor_unix.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package saver
import (
"github.com/BurntSushi/xgb"
"github.com/BurntSushi/xgb/xfixes"
"github.com/BurntSushi/xgb/xproto"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/driver"
)
var conn *xgb.Conn
func initCursor() {
var err error
conn, err = xgb.NewConn()
if err != nil {
fyne.LogError("Failed to connect to X11 to hide cursor", err)
return
}
err = xfixes.Init(conn)
if err != nil {
fyne.LogError("Failed to init fixes extension to X11 to hide cursor", err)
return
}
r, err := xfixes.QueryVersion(conn, 4, 0).Reply()
if err != nil || r.MajorVersion < 4 {
return
}
}
func doHideCursor(ctx any) {
switch win := ctx.(type) {
case driver.X11WindowContext:
if conn == nil {
return
}
_ = xfixes.HideCursorChecked(conn, xproto.Window(win.WindowHandle)).Check()
case driver.WaylandWindowContext:
// TODO request cursor hide for Wayland
}
}
func doShowCursor(ctx any) {
switch win := ctx.(type) {
case driver.X11WindowContext:
if conn == nil {
return
}
_ = xfixes.ShowCursorChecked(conn, xproto.Window(win.WindowHandle)).Check()
case driver.WaylandWindowContext:
// TODO request cursor hide for Wayland
}
}