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); Window root = DefaultRootWindow(d);
grab_all(d, keycode, mod, root); grab_all(d, keycode, mod, root);
XSelectInput(d, root, KeyPressMask | KeyReleaseMask);
XEvent ev; XEvent ev;
while(1) { while(1) {
+27 -16
View File
@@ -236,14 +236,19 @@ func (hk *Hotkey) registerPortal() error {
return errors.New("CreateSession: invalid session_handle") return errors.New("CreateSession: invalid session_handle")
} }
shortcutTuple := []interface{}{ type portalShortcut struct {
wisfreeGlobalShortcutID, ID string
map[string]dbus.Variant{ Details map[string]dbus.Variant
"description": dbus.MakeVariant("Hold to dictate; release to transcribe (WIS Free)"), }
"preferred_trigger": dbus.MakeVariant(trigger), 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{ bindOpts := map[string]dbus.Variant{
"handle_token": dbus.MakeVariant(randomPortalToken()), "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) 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 sc, ok := results["shortcuts"]; ok {
if ar, ok := sc.Value().([][]interface{}); ok && len(ar) == 0 { val := sc.Value()
log.Printf("wis-free-v3 hotkey: BindShortcuts returned empty shortcut list (desktop may have declined the binding)") 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 name := sig.Name
switch { switch {
case name == "Activated" || strings.HasSuffix(name, ".Activated"): case name == "Activated" || strings.HasSuffix(name, ".Activated"):
select { go func() { hk.keydownIn <- Event{} }()
case hk.keydownIn <- Event{}:
default:
}
case name == "Deactivated" || strings.HasSuffix(name, ".Deactivated"): case name == "Deactivated" || strings.HasSuffix(name, ".Deactivated"):
select { go func() { hk.keyupIn <- Event{} }()
case hk.keyupIn <- Event{}:
default:
}
} }
} }
} }
+10 -10
View File
@@ -22,16 +22,16 @@ type Key uint16
// See /usr/include/X11/keysymdef.h // See /usr/include/X11/keysymdef.h
const ( const (
KeySpace Key = 0x0020 KeySpace Key = 0x0020
Key1 Key = 0x0030 Key0 Key = 0x0030
Key2 Key = 0x0031 Key1 Key = 0x0031
Key3 Key = 0x0032 Key2 Key = 0x0032
Key4 Key = 0x0033 Key3 Key = 0x0033
Key5 Key = 0x0034 Key4 Key = 0x0034
Key6 Key = 0x0035 Key5 Key = 0x0035
Key7 Key = 0x0036 Key6 Key = 0x0036
Key8 Key = 0x0037 Key7 Key = 0x0037
Key9 Key = 0x0038 Key8 Key = 0x0038
Key0 Key = 0x0039 Key9 Key = 0x0039
KeyA Key = 0x0061 KeyA Key = 0x0061
KeyB Key = 0x0062 KeyB Key = 0x0062
KeyC Key = 0x0063 KeyC Key = 0x0063