This commit is contained in:
jahruz67
2026-05-08 18:29:35 -07:00
parent 36babc27f1
commit 87594f0c21
3 changed files with 37 additions and 27 deletions
-1
View File
@@ -80,7 +80,6 @@ int waitHotkey(uintptr_t hkhandle, unsigned int mod, int key) {
Window root = DefaultRootWindow(d);
grab_all(d, keycode, mod, root);
XSelectInput(d, root, KeyPressMask | KeyReleaseMask);
XEvent ev;
while(1) {
+27 -16
View File
@@ -236,14 +236,19 @@ func (hk *Hotkey) registerPortal() error {
return errors.New("CreateSession: invalid session_handle")
}
shortcutTuple := []interface{}{
wisfreeGlobalShortcutID,
map[string]dbus.Variant{
"description": dbus.MakeVariant("Hold to dictate; release to transcribe (WIS Free)"),
"preferred_trigger": dbus.MakeVariant(trigger),
type portalShortcut struct {
ID string
Details map[string]dbus.Variant
}
shortcutsArg := []portalShortcut{
{
ID: wisfreeGlobalShortcutID,
Details: map[string]dbus.Variant{
"description": dbus.MakeVariant("Hold to dictate; release to transcribe (WIS Free)"),
"preferred_trigger": dbus.MakeVariant(trigger),
},
},
}
shortcutsArg := []interface{}{shortcutTuple}
bindOpts := map[string]dbus.Variant{
"handle_token": dbus.MakeVariant(randomPortalToken()),
@@ -268,8 +273,20 @@ func (hk *Hotkey) registerPortal() error {
return fmt.Errorf("BindShortcuts rejected (code %d); install a desktop with GlobalShortcuts portal support (e.g. recent KDE Plasma) or set %s=1 to force X11 hotkeys under XWayland", code, envForceX11)
}
if sc, ok := results["shortcuts"]; ok {
if ar, ok := sc.Value().([][]interface{}); ok && len(ar) == 0 {
log.Printf("wis-free-v3 hotkey: BindShortcuts returned empty shortcut list (desktop may have declined the binding)")
val := sc.Value()
isEmpty := false
switch v := val.(type) {
case []interface{}:
isEmpty = len(v) == 0
case [][]interface{}:
isEmpty = len(v) == 0
case []map[string]interface{}:
isEmpty = len(v) == 0
}
if isEmpty {
_ = conn.Object(portalBusName, sessPath).Call(ifaceSession+".Close", 0).Store()
_ = conn.Close()
return fmt.Errorf("BindShortcuts returned empty shortcut list (desktop declined the binding)")
}
}
@@ -347,15 +364,9 @@ func (hk *Hotkey) portalSignalLoop() {
name := sig.Name
switch {
case name == "Activated" || strings.HasSuffix(name, ".Activated"):
select {
case hk.keydownIn <- Event{}:
default:
}
go func() { hk.keydownIn <- Event{} }()
case name == "Deactivated" || strings.HasSuffix(name, ".Deactivated"):
select {
case hk.keyupIn <- Event{}:
default:
}
go func() { hk.keyupIn <- Event{} }()
}
}
}
+10 -10
View File
@@ -22,16 +22,16 @@ type Key uint16
// See /usr/include/X11/keysymdef.h
const (
KeySpace Key = 0x0020
Key1 Key = 0x0030
Key2 Key = 0x0031
Key3 Key = 0x0032
Key4 Key = 0x0033
Key5 Key = 0x0034
Key6 Key = 0x0035
Key7 Key = 0x0036
Key8 Key = 0x0037
Key9 Key = 0x0038
Key0 Key = 0x0039
Key0 Key = 0x0030
Key1 Key = 0x0031
Key2 Key = 0x0032
Key3 Key = 0x0033
Key4 Key = 0x0034
Key5 Key = 0x0035
Key6 Key = 0x0036
Key7 Key = 0x0037
Key8 Key = 0x0038
Key9 Key = 0x0039
KeyA Key = 0x0061
KeyB Key = 0x0062
KeyC Key = 0x0063