mirror of
https://github.com/DeeJanuz/frametop.git
synced 2026-10-06 05:00:08 +02:00
Merge PR #22 (ehippy: lazy susan, Meta+Alt+Tab spins the panels around you) into experimental
Conflicts with experimental's pause_toggle, steam_menu and command: actions and its AnnounceOverlay: both kept. The spin bindings join the Meta tap in the defaults, spinning doesn't need pointer mode, and like other actions it does nothing while Frametop is paused. AnnounceOverlay now sends through the PR's SendPointer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
17269134ce
9 files changed
+213
-13
No files matched your search
@@ -57,6 +57,7 @@ If you work in the desktop for long stretches, or leave the headset on a stand,
|
|||||||
| While carrying a screen, sweep its laser across your other controller's ring, then let go | Pins it to that wrist, at its size and distance, as you hold it when you let go; it shows while you see its front. Grab its bar to adjust it (it stays pinned); sweep across the ring again to take it off |
|
| While carrying a screen, sweep its laser across your other controller's ring, then let go | Pins it to that wrist, at its size and distance, as you hold it when you let go; it shows while you see its front. Grab its bar to adjust it (it stays pinned); sweep across the ring again to take it off |
|
||||||
| Set a screen to On your head (Frametop Display Settings, Visibility & pins) | Pins it to your head where it is, like a HUD. Grab its bar to move it; it stays on your head |
|
| Set a screen to On your head (Frametop Display Settings, Visibility & pins) | Pins it to your head where it is, like a HUD. Grab its bar to move it; it stays on your head |
|
||||||
| Meta+Shift+R in the desktop | Puts the screens back in their layout (also in the menu as Reset Screen Layout, and mappable to a mouse button) |
|
| Meta+Shift+R in the desktop | Puts the screens back in their layout (also in the menu as Reset Screen Layout, and mappable to a mouse button) |
|
||||||
|
| Meta+Alt+Tab, or Meta+Alt+Shift+Tab | Spins every screen and floating window around you together, like a lazy susan, so the next one on your right (or left) glides to straight ahead, with the pointer and typing going to it. Their arrangement stays the same: the room turns instead of you. Tap again to keep going; Meta+Shift+R puts the screens back. Pinned screens stay where they are |
|
||||||
| Meta+Shift+H in the desktop | Hides or shows all screens (also in the menu as Hide/Show Screens, and mappable). The Visibility & pins tab of Frametop Display Settings can instead show them only with the dashboard open, or while you look at your wrist |
|
| Meta+Shift+H in the desktop | Hides or shows all screens (also in the menu as Hide/Show Screens, and mappable). The Visibility & pins tab of Frametop Display Settings can instead show them only with the dashboard open, or while you look at your wrist |
|
||||||
| Tap Meta, on any keyboard | Opens the Steam menu in the SteamVR dashboard, or closes the dashboard, wherever you are. The desktop's launcher is still on the taskbar and Alt+F1. Change it in Frametop Input Settings (Keyboard page), where any key combination or modifier tap can do a Frametop or Steam action, open a profile, or run a command of your own |
|
| Tap Meta, on any keyboard | Opens the Steam menu in the SteamVR dashboard, or closes the dashboard, wherever you are. The desktop's launcher is still on the taskbar and Alt+F1. Change it in Frametop Input Settings (Keyboard page), where any key combination or modifier tap can do a Frametop or Steam action, open a profile, or run a command of your own |
|
||||||
| Switch a screen to Hidden (Frametop Display Settings, Visibility & pins → Screens shown) | Hides just that screen until you switch it back, whatever the other visibility settings say; new windows that would open on it float instead |
|
| Switch a screen to Hidden (Frametop Display Settings, Visibility & pins → Screens shown) | Hides just that screen until you switch it back, whatever the other visibility settings say; new windows that would open on it float instead |
|
||||||
|
|||||||
+1
-1
@@ -134,7 +134,7 @@ A Kirigami app with a Python backend, in the Plasma menu under Settings. It runs
|
|||||||
- Buttons maps a pointer device's buttons. Choose Capture a button, press the button or key, then pick an action: a click, back, scroll, toggle dashboard, recenter, pointer on or off, head follow on or off, gaze pointer on or off, gaze precision, gaze drag, gaze quick check, faster or slower, reset the screen layout, hide or show the screens, open or close the keyboard, float a window in VR or put it back, put all floating windows back, pause or resume Frametop ([Pausing for VR games](#pausing-for-vr-games)), Open profile NAME (one per profile, [profiles.md](profiles.md)), pass the key through, or nothing. Devices with saved mappings are listed even while they're asleep.
|
- Buttons maps a pointer device's buttons. Choose Capture a button, press the button or key, then pick an action: a click, back, scroll, toggle dashboard, recenter, pointer on or off, head follow on or off, gaze pointer on or off, gaze precision, gaze drag, gaze quick check, faster or slower, reset the screen layout, hide or show the screens, open or close the keyboard, float a window in VR or put it back, put all floating windows back, pause or resume Frametop ([Pausing for VR games](#pausing-for-vr-games)), Open profile NAME (one per profile, [profiles.md](profiles.md)), pass the key through, or nothing. Devices with saved mappings are listed even while they're asleep.
|
||||||
- Controllers maps the Frame controllers' buttons (every button but the system button) to the same actions, except passing a key through and the gaze actions: gaze mode is a mouse and keyboard feature ([gaze-controllers.md](gaze-controllers.md)). Capture a button and press it on a controller, or pick it from the list. The controllers aren't input devices on the host; only SteamVR sees them. So the pointer helper reads them with SteamVR input (`pointer/helper/vrbuttons.h`, `pointer/helper/actions/`) and sends presses to the relay (`vrbtn right/a 1`), which does the mapped action. The helper only takes the buttons that are mapped (the relay tells it with `vrbind`), at an overlay-global priority, and only while no game (scene application) runs, so games keep every button; with In games on (`controller_in_games`), a mapped button is taken from games too. That needs SteamVR's "Enable global input from overlays (Experimental)" setting (`steamvr/globalActionSetPriority`), which the page's Global input switch turns on and off. Mappings are saved as `controller_buttons` in `~/.config/frametop-input.json`.
|
- Controllers maps the Frame controllers' buttons (every button but the system button) to the same actions, except passing a key through and the gaze actions: gaze mode is a mouse and keyboard feature ([gaze-controllers.md](gaze-controllers.md)). Capture a button and press it on a controller, or pick it from the list. The controllers aren't input devices on the host; only SteamVR sees them. So the pointer helper reads them with SteamVR input (`pointer/helper/vrbuttons.h`, `pointer/helper/actions/`) and sends presses to the relay (`vrbtn right/a 1`), which does the mapped action. The helper only takes the buttons that are mapped (the relay tells it with `vrbind`), at an overlay-global priority, and only while no game (scene application) runs, so games keep every button; with In games on (`controller_in_games`), a mapped button is taken from games too. That needs SteamVR's "Enable global input from overlays (Experimental)" setting (`steamvr/globalActionSetPriority`), which the page's Global input switch turns on and off. Mappings are saved as `controller_buttons` in `~/.config/frametop-input.json`.
|
||||||
- Game optimization has the pause for VR games: its state with Pause now or Resume, whether VR games pause Frametop by themselves, the controller gesture (one or two buttons, pressed once or twice; one button always takes two presses), what happens to the desktop, and the sound. They're saved as `pause_auto`, `pause_gesture`, `pause_desktop`, and `pause_sound` in `~/.config/frametop-input.json`. See [Pausing for VR games](#pausing-for-vr-games).
|
- Game optimization has the pause for VR games: its state with Pause now or Resume, whether VR games pause Frametop by themselves, the controller gesture (one or two buttons, pressed once or twice; one button always takes two presses), what happens to the desktop, and the sound. They're saved as `pause_auto`, `pause_gesture`, `pause_desktop`, and `pause_sound` in `~/.config/frametop-input.json`. See [Pausing for VR games](#pausing-for-vr-games).
|
||||||
- Keyboard sets when Frametop's keyboard opens: whenever a text field is selected; only while no pass-through keyboard is connected (the default; keyboards other programs make through uinput, like frame-voice's, don't count); only with a mouse or controller button mapped to Open/close keyboard; or never, which turns the button off too. Keep it open (on by default, `vr_keyboard_persist`) leaves it open after the text field loses focus. The mode is saved as `vr_keyboard` in `~/.config/frametop-input.json`, and the page lists the keyboards that count as connected. Its Key combinations section maps modifiers plus a key, or one modifier tapped on its own, on any keyboard, to any action but passing a key through or nothing, or to Run a command…: a command line the input relay runs with `sh -c` when you press the keys (`command:CMD`). The command runs as the relay's user service, outside the desktop's session, with `layout/`, `float/` and `steam/` on its `PATH` (so `ft-layout use Work` or `ft-float launch org.kde.dolphin` work as they are), and its output goes to the relay's journal. The gaze clicks (Gaze left click and Gaze right click) only go on key combinations. The defaults are a Meta tap (open the Steam menu, or close the dashboard), Meta+J (gaze left click), Meta+K (gaze right click), and Meta+Shift+F (float window in VR or put it back); remove them or add others there. A tap is a press and release with no other key, mouse button, or scroll in between; a bound one sends the desktop F24 before the release, so Plasma's launcher doesn't open on it. The combination's last key isn't typed, and the modifiers still reach the app; while typing goes to Steam rather than the desktop, keyboards aren't grabbed, so Steam or the game sees the keys too. They're saved as `key_bindings` in the same file; a file with its own list, even an empty one, gets no defaults.
|
- Keyboard sets when Frametop's keyboard opens: whenever a text field is selected; only while no pass-through keyboard is connected (the default; keyboards other programs make through uinput, like frame-voice's, don't count); only with a mouse or controller button mapped to Open/close keyboard; or never, which turns the button off too. Keep it open (on by default, `vr_keyboard_persist`) leaves it open after the text field loses focus. The mode is saved as `vr_keyboard` in `~/.config/frametop-input.json`, and the page lists the keyboards that count as connected. Its Key combinations section maps modifiers plus a key, or one modifier tapped on its own, on any keyboard, to any action but passing a key through or nothing, or to Run a command…: a command line the input relay runs with `sh -c` when you press the keys (`command:CMD`). The command runs as the relay's user service, outside the desktop's session, with `layout/`, `float/` and `steam/` on its `PATH` (so `ft-layout use Work` or `ft-float launch org.kde.dolphin` work as they are), and its output goes to the relay's journal. The gaze clicks (Gaze left click and Gaze right click) only go on key combinations. The defaults are a Meta tap (open the Steam menu, or close the dashboard), Meta+J (gaze left click), Meta+K (gaze right click), Meta+Shift+F (float window in VR or put it back), and Meta+Alt+Tab and Meta+Alt+Shift+Tab (spin the panels: every screen and floating window turns about your head, so the next one on the right or left comes to the front; ft-screens' `spin next|prev|<degrees>`); remove them or add others there. A tap is a press and release with no other key, mouse button, or scroll in between; a bound one sends the desktop F24 before the release, so Plasma's launcher doesn't open on it. The combination's last key isn't typed, and the modifiers still reach the app; while typing goes to Steam rather than the desktop, keyboards aren't grabbed, so Steam or the game sees the keys too. They're saved as `key_bindings` in the same file; a file with its own list, even an empty one, gets no defaults.
|
||||||
- Pointer has a Head follow switch and sliders for the pointer settings, which apply immediately, and a Recenter button.
|
- Pointer has a Head follow switch and sliders for the pointer settings, which apply immediately, and a Recenter button.
|
||||||
- Ignored panels lists the SteamVR overlays that are showing, grouped by app (the first two parts of the overlay key, such as `sasaken.frame-perf-overlay`), from the pointer helper (`overlays`). Tick a panel, or Ignore the whole app, and the pointer passes through it to what's behind. It's for panels you only look at, like a performance overlay that follows your view. The list is saved as `POINTER_IGNORE` in `~/.config/frametop.conf`: comma-separated overlay keys, where a shell pattern like `vendor.app*` covers a whole app, including panels it opens later. The helper reloads at once. Frametop's own screens aren't listed, and entries for apps that aren't open are listed below, to remove.
|
- Ignored panels lists the SteamVR overlays that are showing, grouped by app (the first two parts of the overlay key, such as `sasaken.frame-perf-overlay`), from the pointer helper (`overlays`). Tick a panel, or Ignore the whole app, and the pointer passes through it to what's behind. It's for panels you only look at, like a performance overlay that follows your view. The list is saved as `POINTER_IGNORE` in `~/.config/frametop.conf`: comma-separated overlay keys, where a shell pattern like `vendor.app*` covers a whole app, including panels it opens later. The helper reloads at once. Frametop's own screens aren't listed, and entries for apps that aren't open are listed below, to remove.
|
||||||
- Gaze has the gaze pointer switch (on now and from now on; a mapped button toggles it until the helper restarts), what the mouse's left button and movement do, the gaze dot, the eye tracker and eye bias, the gaze mode sliders, the gaze service's state (headset, samples per second, how often the tracker is losing each eye, the calibration, the nudges learned), and Quick check, Calibrate, and Check headset fit (each in a panel in the headset), Reload calibration, and Forget nudges. The gaze probe, a development tool, is in the page's overflow menu.
|
- Gaze has the gaze pointer switch (on now and from now on; a mapped button toggles it until the helper restarts), what the mouse's left button and movement do, the gaze dot, the eye tracker and eye bias, the gaze mode sliders, the gaze service's state (headset, samples per second, how often the tracker is losing each eye, the calibration, the nudges learned), and Quick check, Calibrate, and Check headset fit (each in a panel in the headset), Reload calibration, and Forget nudges. The gaze probe, a development tool, is in the page's overflow menu.
|
||||||
|
|||||||
@@ -378,6 +378,17 @@ function run(c) {
|
|||||||
case "activate":
|
case "activate":
|
||||||
if (w) workspace.activeWindow = w;
|
if (w) workspace.activeWindow = w;
|
||||||
break;
|
break;
|
||||||
|
case "activate-output": { // the top window on that output (a spin brought it to the front)
|
||||||
|
const order = workspace.stackingOrder;
|
||||||
|
for (let i = order.length - 1; i >= 0; --i) {
|
||||||
|
const o = order[i];
|
||||||
|
if (o.deleted || o.minimized || o.hidden || !o.managed || !o.output) continue;
|
||||||
|
if (o.output.name !== c.output || !o.normalWindow || o.popupWindow) continue;
|
||||||
|
workspace.activeWindow = o;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case "minimize":
|
case "minimize":
|
||||||
if (w) w.minimized = c.on;
|
if (w) w.minimized = c.on;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ command-line side). Replies go to the sender:
|
|||||||
("float pointer" is the float key: the window under the pointer, else the active one,
|
("float pointer" is the float key: the window under the pointer, else the active one,
|
||||||
floated or docked; the input relay sends it for float_toggle, and "dock all" for dock_all)
|
floated or docked; the input relay sends it for float_toggle, and "dock all" for dock_all)
|
||||||
dock N | close N | resize N W H | scale N STEPS (ft-screens, N = its screen)
|
dock N | close N | resize N W H | scale N STEPS (ft-screens, N = its screen)
|
||||||
|
front N (ft-screens: a spin brought panel N to the front: make its window, or the top one
|
||||||
|
on a screen, KWin's active window)
|
||||||
|
|
||||||
Spare outputs are WL-<screens> .. WL-<screens + slots - 1>. A floating window's output is its
|
Spare outputs are WL-<screens> .. WL-<screens + slots - 1>. A floating window's output is its
|
||||||
frame plus a margin on each side (FLOAT_MARGIN pixels), so menus have room; the panel shows
|
frame plus a margin on each side (FLOAT_MARGIN pixels), so menus have room; the panel shows
|
||||||
@@ -1063,6 +1065,13 @@ class Daemon:
|
|||||||
for f in list(self.floats.values()):
|
for f in list(self.floats.values()):
|
||||||
self.dock(f)
|
self.dock(f)
|
||||||
return "ok"
|
return "ok"
|
||||||
|
if cmd == "front" and len(rest) == 1 and rest[0].isdigit():
|
||||||
|
f = self.by_panel(int(rest[0]))
|
||||||
|
if f:
|
||||||
|
self.command(cmd="activate", id=f.id)
|
||||||
|
else: # a screen: its output is WL-<N - 1>
|
||||||
|
self.command(cmd="activate-output", output=f"WL-{int(rest[0]) - 1}")
|
||||||
|
return "ok"
|
||||||
if cmd in ("dock", "close", "resize", "scale") and rest and rest[0].isdigit():
|
if cmd in ("dock", "close", "resize", "scale") and rest and rest[0].isdigit():
|
||||||
f = self.by_panel(int(rest[0]))
|
f = self.by_panel(int(rest[0]))
|
||||||
if not f:
|
if not f:
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ ACTION_LABELS = {
|
|||||||
"screens_toggle": "Hide/show desktop screens", "keyboard_toggle": "Open/close keyboard",
|
"screens_toggle": "Hide/show desktop screens", "keyboard_toggle": "Open/close keyboard",
|
||||||
"float_toggle": "Float window in VR / put it back", "dock_all": "Put all floating windows back",
|
"float_toggle": "Float window in VR / put it back", "dock_all": "Put all floating windows back",
|
||||||
"pause_toggle": "Pause/resume Frametop (for VR games)",
|
"pause_toggle": "Pause/resume Frametop (for VR games)",
|
||||||
|
"spin_next": "Spin the panels: next one on the right to the front",
|
||||||
|
"spin_prev": "Spin the panels: next one on the left to the front",
|
||||||
"key": "Pass through as key",
|
"key": "Pass through as key",
|
||||||
"none": "Do nothing",
|
"none": "Do nothing",
|
||||||
}
|
}
|
||||||
@@ -163,9 +165,10 @@ GAZE_MOUSE = {"precision": "Gaze precision: hold to steer with the mouse, releas
|
|||||||
MODIFIER_CODES = {29: 29, 97: 29, 42: 42, 54: 42, 56: 56, 100: 56, 125: 125, 126: 125}
|
MODIFIER_CODES = {29: 29, 97: 29, 42: 42, 54: 42, 56: 56, 100: 56, 125: 125, 126: 125}
|
||||||
MODIFIER_NAMES = {29: "Ctrl", 42: "Shift", 56: "Alt", 125: "Meta"}
|
MODIFIER_NAMES = {29: "Ctrl", 42: "Shift", 56: "Alt", 125: "Meta"}
|
||||||
# What a rules file without "key_bindings" gets (the relay's DEFAULT_KEY_BINDINGS): a Meta tap
|
# What a rules file without "key_bindings" gets (the relay's DEFAULT_KEY_BINDINGS): a Meta tap
|
||||||
# opens Steam's menu, Meta+J and Meta+K click at the gaze, Meta+Shift+F floats a window.
|
# opens Steam's menu, Meta+J and Meta+K click at the gaze, Meta+Shift+F floats a window,
|
||||||
|
# Meta+Alt+Tab and Meta+Alt+Shift+Tab spin the panels.
|
||||||
DEFAULT_KEY_BINDINGS = {"125": "steam_menu", "125+36": "gaze_left", "125+37": "gaze_right",
|
DEFAULT_KEY_BINDINGS = {"125": "steam_menu", "125+36": "gaze_left", "125+37": "gaze_right",
|
||||||
"42+125+33": "float_toggle"}
|
"42+125+33": "float_toggle", "56+125+15": "spin_next", "42+56+125+15": "spin_prev"}
|
||||||
|
|
||||||
|
|
||||||
def key_bindings(rules):
|
def key_bindings(rules):
|
||||||
|
|||||||
+19
-5
@@ -30,7 +30,9 @@ gaze_quickcal = the gaze service's one-dot check ("quickcal" to @ft_gazed), sens
|
|||||||
layout_reset = put the desktop screens back in their saved layout, screens_toggle = hide or show the desktop screens,
|
layout_reset = put the desktop screens back in their saved layout, screens_toggle = hide or show the desktop screens,
|
||||||
keyboard_toggle = open or close Frametop's keyboard, float_toggle = float the desktop window under the
|
keyboard_toggle = open or close Frametop's keyboard, float_toggle = float the desktop window under the
|
||||||
pointer (else the active one) in VR, or put it back if it floats, dock_all = put every floating
|
pointer (else the active one) in VR, or put it back if it floats, dock_all = put every floating
|
||||||
window back (both to ft-floatd, @frametop_float), profile:NAME = switch to that profile (ft-layout
|
window back (both to ft-floatd, @frametop_float), spin_next and spin_prev = turn every panel in the
|
||||||
|
room about your head so the next one to the right or left comes to the front (ft-screens' "spin",
|
||||||
|
Meta+Alt+Tab and Meta+Alt+Shift+Tab by default), profile:NAME = switch to that profile (ft-layout
|
||||||
use NAME: its screens and apps; docs/profiles.md), steam_menu = open the SteamVR dashboard on
|
use NAME: its screens and apps; docs/profiles.md), steam_menu = open the SteamVR dashboard on
|
||||||
Steam's menu, or close the dashboard (steam/ft-steam menu, through Steam's UI), pause_toggle =
|
Steam's menu, or close the dashboard (steam/ft-steam menu, through Steam's UI), pause_toggle =
|
||||||
pause Frametop for a VR game, or resume it (game_pause.py), command:CMD = run
|
pause Frametop for a VR game, or resume it (game_pause.py), command:CMD = run
|
||||||
@@ -209,14 +211,16 @@ RULES_PATH = os.path.expanduser("~/.config/frametop-input.json")
|
|||||||
ACTIONS = ("left", "right", "middle", "back", "scroll_up", "scroll_down", "dashboard", "recenter",
|
ACTIONS = ("left", "right", "middle", "back", "scroll_up", "scroll_down", "dashboard", "recenter",
|
||||||
"pointer_toggle", "follow_toggle", "gaze_toggle", "gaze_precision", "gaze_drag", "gaze_left", "gaze_right",
|
"pointer_toggle", "follow_toggle", "gaze_toggle", "gaze_precision", "gaze_drag", "gaze_left", "gaze_right",
|
||||||
"gaze_quickcal", "sens_up", "sens_down", "layout_reset", "screens_toggle", "keyboard_toggle", "float_toggle",
|
"gaze_quickcal", "sens_up", "sens_down", "layout_reset", "screens_toggle", "keyboard_toggle", "float_toggle",
|
||||||
"dock_all", "steam_menu", "pause_toggle", "key", "none")
|
"dock_all", "spin_next", "spin_prev", "steam_menu", "pause_toggle", "key", "none")
|
||||||
# Gaze mode is a mouse feature: these never come from a controller button (docs/gaze-controllers.md).
|
# Gaze mode is a mouse feature: these never come from a controller button (docs/gaze-controllers.md).
|
||||||
GAZE_ACTIONS = ("gaze_toggle", "gaze_precision", "gaze_drag", "gaze_left", "gaze_right", "gaze_quickcal")
|
GAZE_ACTIONS = ("gaze_toggle", "gaze_precision", "gaze_drag", "gaze_left", "gaze_right", "gaze_quickcal")
|
||||||
# Key combinations a rules file without "key_bindings" gets: a Meta tap opens Steam's menu, Meta+J
|
# Key combinations a rules file without "key_bindings" gets: a Meta tap opens Steam's menu, Meta+J
|
||||||
# and Meta+K click at the gaze (free on the Frametop desktop, and apps don't use Meta),
|
# and Meta+K click at the gaze (free on the Frametop desktop, and apps don't use Meta),
|
||||||
# Meta+Shift+F floats a window.
|
# Meta+Shift+F floats a window, and Meta+Alt+Tab and Meta+Alt+Shift+Tab spin the panels around
|
||||||
|
# you (ft-screens' lazy susan); not Meta+Tab, which is Cmd+Tab on a Mac reached through a remote
|
||||||
|
# desktop like RustDesk.
|
||||||
DEFAULT_KEY_BINDINGS = {"125": "steam_menu", "125+36": "gaze_left", "125+37": "gaze_right",
|
DEFAULT_KEY_BINDINGS = {"125": "steam_menu", "125+36": "gaze_left", "125+37": "gaze_right",
|
||||||
"42+125+33": "float_toggle"}
|
"42+125+33": "float_toggle", "56+125+15": "spin_next", "42+56+125+15": "spin_prev"}
|
||||||
KEY_F24 = 194 # sent to the desktop with a Meta combination (see the top)
|
KEY_F24 = 194 # sent to the desktop with a Meta combination (see the top)
|
||||||
# Key combinations ("key_bindings"): modifiers, each side's code folded into the left one's.
|
# Key combinations ("key_bindings"): modifiers, each side's code folded into the left one's.
|
||||||
MODIFIERS = {29: 29, 97: 29, 42: 42, 54: 42, 56: 56, 100: 56, 125: 125, 126: 125}
|
MODIFIERS = {29: 29, 97: 29, 42: 42, 54: 42, 56: 56, 100: 56, 125: 125, 126: 125}
|
||||||
@@ -232,6 +236,9 @@ GAZED = "\0ft_gazed"
|
|||||||
FLOAT = "\0frametop_float" # ft-floatd, floating windows in the Frametop desktop
|
FLOAT = "\0frametop_float" # ft-floatd, floating windows in the Frametop desktop
|
||||||
# Actions for ft-floatd ("float_toggle", "dock_all"): they don't need pointer mode.
|
# Actions for ft-floatd ("float_toggle", "dock_all"): they don't need pointer mode.
|
||||||
FLOAT_ACTIONS = {"float_toggle": b"float pointer", "dock_all": b"dock all"}
|
FLOAT_ACTIONS = {"float_toggle": b"float pointer", "dock_all": b"dock all"}
|
||||||
|
# Actions for ft-screens: spin_next and spin_prev turn every panel in the room about your head,
|
||||||
|
# so the next one to the right or left comes to the front. They don't need pointer mode either.
|
||||||
|
SCREENS_ACTIONS = {"spin_next": b"spin next", "spin_prev": b"spin prev"}
|
||||||
PROFILE = "profile:" # "profile:NAME": switch to that profile (doesn't need pointer mode either)
|
PROFILE = "profile:" # "profile:NAME": switch to that profile (doesn't need pointer mode either)
|
||||||
COMMAND = "command:" # "command:CMD": run CMD (nor does this)
|
COMMAND = "command:" # "command:CMD": run CMD (nor does this)
|
||||||
|
|
||||||
@@ -242,7 +249,7 @@ def known_action(a):
|
|||||||
|
|
||||||
|
|
||||||
def needs_pointer(a):
|
def needs_pointer(a):
|
||||||
return a not in FLOAT_ACTIONS and a not in ("steam_menu", "pause_toggle") and not a.startswith((PROFILE, COMMAND))
|
return a not in FLOAT_ACTIONS and a not in SCREENS_ACTIONS and a not in ("steam_menu", "pause_toggle") and not a.startswith((PROFILE, COMMAND))
|
||||||
|
|
||||||
|
|
||||||
def works_paused(a):
|
def works_paused(a):
|
||||||
@@ -925,6 +932,13 @@ def main():
|
|||||||
except OSError:
|
except OSError:
|
||||||
pass # the Frametop desktop isn't running
|
pass # the Frametop desktop isn't running
|
||||||
log(action)
|
log(action)
|
||||||
|
elif action in SCREENS_ACTIONS:
|
||||||
|
if value == 1:
|
||||||
|
try:
|
||||||
|
screens_sock.sendto(SCREENS_ACTIONS[action], SCREENS)
|
||||||
|
except OSError:
|
||||||
|
pass # the Frametop desktop isn't running
|
||||||
|
log(action)
|
||||||
elif state["pointer"]:
|
elif state["pointer"]:
|
||||||
state["pointer"].action(action, value, now, source)
|
state["pointer"].action(action, value, now, source)
|
||||||
|
|
||||||
|
|||||||
@@ -346,6 +346,20 @@ static void handle_vr_event(const struct ft_event *e, void *data) {
|
|||||||
if (e->screen < 0 || e->screen >= MAX_SCREENS || !s->screens[e->screen]) return;
|
if (e->screen < 0 || e->screen >= MAX_SCREENS || !s->screens[e->screen]) return;
|
||||||
struct screen *sc = s->screens[e->screen];
|
struct screen *sc = s->screens[e->screen];
|
||||||
struct wlr_surface *surface = sc->toplevel->base->surface;
|
struct wlr_surface *surface = sc->toplevel->base->surface;
|
||||||
|
if (e->type == FT_FRONT) {
|
||||||
|
// A spin brought this panel to the front: typing goes to it, as after a click there,
|
||||||
|
// and ft-floatd makes its window (or the top one on a screen) KWin's active window.
|
||||||
|
wlr_seat_keyboard_notify_enter(s->seat, surface, NULL, 0, NULL);
|
||||||
|
s->keys_clicked = true;
|
||||||
|
char msg[32];
|
||||||
|
snprintf(msg, sizeof msg, "front %d", e->screen + 1);
|
||||||
|
struct sockaddr_un addr = {.sun_family = AF_UNIX};
|
||||||
|
const char name[] = "frametop_float";
|
||||||
|
memcpy(addr.sun_path + 1, name, sizeof name - 1);
|
||||||
|
sendto(s->relay_fd, msg, strlen(msg), MSG_DONTWAIT, (struct sockaddr *)&addr,
|
||||||
|
offsetof(struct sockaddr_un, sun_path) + 1 + sizeof name - 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const uint32_t t = now_ms();
|
const uint32_t t = now_ms();
|
||||||
const double x = e->x / s->scale[e->screen], y = e->y / s->scale[e->screen]; // KWin's units
|
const double x = e->x / s->scale[e->screen], y = e->y / s->scale[e->screen]; // KWin's units
|
||||||
switch (e->type) {
|
switch (e->type) {
|
||||||
|
|||||||
+151
-4
@@ -1008,19 +1008,21 @@ void SendFloat(const std::string &msg) {
|
|||||||
std::printf("to ft-floatd: %s\n", msg.c_str());
|
std::printf("to ft-floatd: %s\n", msg.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// A new panel: the pointer helper reads SteamVR's list of panels only every 20 s, so it's told
|
// To the pointer helper (@ft_pointer_helper), from an unbound socket.
|
||||||
// at once ("overlay <key>"), or the mouse couldn't click a menu until then.
|
void SendPointer(const std::string &msg) {
|
||||||
void AnnounceOverlay(const char *key) {
|
|
||||||
static const int fd = socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
|
static const int fd = socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
|
||||||
sockaddr_un addr{};
|
sockaddr_un addr{};
|
||||||
addr.sun_family = AF_UNIX;
|
addr.sun_family = AF_UNIX;
|
||||||
const char name[] = "ft_pointer_helper";
|
const char name[] = "ft_pointer_helper";
|
||||||
std::memcpy(addr.sun_path + 1, name, sizeof name - 1);
|
std::memcpy(addr.sun_path + 1, name, sizeof name - 1);
|
||||||
const std::string msg = std::string("overlay ") + key;
|
|
||||||
sendto(fd, msg.data(), msg.size(), MSG_DONTWAIT, reinterpret_cast<sockaddr *>(&addr),
|
sendto(fd, msg.data(), msg.size(), MSG_DONTWAIT, reinterpret_cast<sockaddr *>(&addr),
|
||||||
socklen_t(offsetof(sockaddr_un, sun_path) + 1 + sizeof name - 1));
|
socklen_t(offsetof(sockaddr_un, sun_path) + 1 + sizeof name - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A new panel: the pointer helper reads SteamVR's list of panels only every 20 s, so it's told
|
||||||
|
// at once ("overlay <key>"), or the mouse couldn't click a menu until then.
|
||||||
|
void AnnounceOverlay(const char *key) { SendPointer(std::string("overlay ") + key); }
|
||||||
|
|
||||||
// Where a device's ray meets the screen's plane, in the screen's x (right) and y (up),
|
// Where a device's ray meets the screen's plane, in the screen's x (right) and y (up),
|
||||||
// metres from its centre.
|
// metres from its centre.
|
||||||
bool RayOnPlane(const Mat &p, const Mat &d, double *x, double *y) {
|
bool RayOnPlane(const Mat &p, const Mat &d, double *x, double *y) {
|
||||||
@@ -1488,6 +1490,137 @@ Screen *Find(int one_based) {
|
|||||||
return it == g_screens.end() ? nullptr : &it->second;
|
return it == g_screens.end() ? nullptr : &it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- the lazy susan
|
||||||
|
// "spin next|prev|<degrees>": the panels in the room (screens and floating windows, not
|
||||||
|
// pinned ones) turn together about a vertical axis through your head, so the next panel to
|
||||||
|
// your right (next) or left (prev) glides to straight ahead, or the ring turns by that many
|
||||||
|
// degrees (positive turns it left, like next). Their arrangement stays as it is: the room
|
||||||
|
// turns instead of you. A spin that arrives during one adds to it, from where the panels are
|
||||||
|
// headed, so quick taps carry on smoothly. Grabbing a panel, or a command that places it,
|
||||||
|
// takes it out of the spin where it is. The 3D mouse's pointer goes to straight ahead.
|
||||||
|
constexpr double kSpinSeconds = 0.3; // how long a spin takes
|
||||||
|
constexpr double kSpinAhead = 8; // degrees: a panel this near straight ahead is the current one
|
||||||
|
constexpr double kSpinFocus = 30; // degrees: when a spin settles, the panel this near ahead gets typing
|
||||||
|
|
||||||
|
struct Spin {
|
||||||
|
bool on = false;
|
||||||
|
double cx = 0, cz = 0; // the axis
|
||||||
|
double from = 0, to = 0; // radians, turned from the poses in base (positive: to the left)
|
||||||
|
Clock::time_point start;
|
||||||
|
std::map<int, Mat> base; // index -> its pose before the spin
|
||||||
|
int front = -1; // settled: this panel came to the front (ft_vr_poll reports it)
|
||||||
|
} g_spin;
|
||||||
|
|
||||||
|
// p turned a radians about the vertical axis through (cx, cz); positive turns it to the left.
|
||||||
|
Mat Turned(const Mat &p, double a, double cx, double cz) {
|
||||||
|
const double c = std::cos(a), s = std::sin(a);
|
||||||
|
Mat r = Identity();
|
||||||
|
r.m[0][0] = float(c), r.m[0][2] = float(s);
|
||||||
|
r.m[2][0] = float(-s), r.m[2][2] = float(c);
|
||||||
|
r.m[0][3] = float(cx - c * cx - s * cz);
|
||||||
|
r.m[2][3] = float(cz + s * cx - c * cz);
|
||||||
|
return Mul(r, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Spinnable(const Screen &s) { return s.pinned == kNone && (!s.floating || s.floatOn) && s.drag == Drag::None; }
|
||||||
|
|
||||||
|
double SpinNow() {
|
||||||
|
if (!g_spin.on) return g_spin.to;
|
||||||
|
const double t = std::min(1.0, std::chrono::duration<double>(Clock::now() - g_spin.start).count() / kSpinSeconds);
|
||||||
|
return g_spin.from + (g_spin.to - g_spin.from) * t * t * (3 - 2 * t);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateSpin() {
|
||||||
|
if (!g_spin.on) return;
|
||||||
|
const double a = SpinNow();
|
||||||
|
const bool done = Clock::now() - g_spin.start >= std::chrono::duration<double>(kSpinSeconds);
|
||||||
|
for (auto it = g_spin.base.begin(); it != g_spin.base.end();) {
|
||||||
|
auto s = g_screens.find(it->first);
|
||||||
|
if (s == g_screens.end() || !Spinnable(s->second)) {
|
||||||
|
it = g_spin.base.erase(it); // grabbed, pinned, or gone: it stays where it is now
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
SetAbsolute(s->second, Turned(it->second, a, g_spin.cx, g_spin.cz));
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
if (done) {
|
||||||
|
// The panel now nearest straight ahead (of where you face) gets typing and the active window.
|
||||||
|
Mat head;
|
||||||
|
double nearest = kSpinFocus;
|
||||||
|
if (DevicePose(vr::k_unTrackedDeviceIndex_Hmd, &head)) {
|
||||||
|
for (const auto &[i, p] : g_spin.base) {
|
||||||
|
const auto it = g_screens.find(i);
|
||||||
|
Mat q;
|
||||||
|
if (it == g_screens.end() || !it->second.visible || !ScreenPose(it->second, &q)) continue;
|
||||||
|
double f[3] = {-head.m[0][2], 0, -head.m[2][2]};
|
||||||
|
double d[3] = {q.m[0][3] - head.m[0][3], 0, q.m[2][3] - head.m[2][3]};
|
||||||
|
const double fl = std::sqrt(Dot3(f, f)), dl = std::sqrt(Dot3(d, d));
|
||||||
|
if (fl < 1e-6 || dl < 1e-6) continue;
|
||||||
|
const double a = std::acos(std::clamp(Dot3(f, d) / (fl * dl), -1.0, 1.0)) * 180 / M_PI;
|
||||||
|
if (a < nearest) nearest = a, g_spin.front = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_spin.on = false;
|
||||||
|
g_spin.base.clear();
|
||||||
|
ArrangeDesktopSoon(); // KWin's outputs follow where the screens are now
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpinCommand(const char *arg, char *reply, int size) {
|
||||||
|
Mat head;
|
||||||
|
if (!DevicePose(vr::k_unTrackedDeviceIndex_Hmd, &head))
|
||||||
|
return (void)std::snprintf(reply, size, "error no head pose (headset off?)");
|
||||||
|
if (g_spin.on) {
|
||||||
|
g_spin.from = SpinNow(); // carry on from where the panels are now
|
||||||
|
} else {
|
||||||
|
g_spin.base.clear();
|
||||||
|
for (auto &[i, s] : g_screens) {
|
||||||
|
Mat p;
|
||||||
|
if (Spinnable(s) && ScreenPose(s, &p)) g_spin.base[i] = p;
|
||||||
|
}
|
||||||
|
g_spin.cx = head.m[0][3], g_spin.cz = head.m[2][3];
|
||||||
|
g_spin.from = g_spin.to = 0;
|
||||||
|
}
|
||||||
|
if (g_spin.base.empty()) return (void)std::snprintf(reply, size, "error nothing to spin");
|
||||||
|
double turn; // degrees, positive to the left
|
||||||
|
const bool next = !std::strcmp(arg, "next");
|
||||||
|
if (next || !std::strcmp(arg, "prev")) {
|
||||||
|
// Each visible panel's bearing from where you face, to the right positive, as it will
|
||||||
|
// be when the spin so far ends; the nearest one past straight ahead comes to the front.
|
||||||
|
double fx = -head.m[0][2], fz = -head.m[2][2];
|
||||||
|
const double n = std::sqrt(fx * fx + fz * fz) + 1e-9;
|
||||||
|
fx /= n, fz /= n;
|
||||||
|
const double rx = -fz, rz = fx;
|
||||||
|
double best = 0;
|
||||||
|
bool found = false;
|
||||||
|
for (const auto &[i, p] : g_spin.base) {
|
||||||
|
const auto s = g_screens.find(i);
|
||||||
|
if (s == g_screens.end() || !s->second.visible) continue;
|
||||||
|
const Mat q = Turned(p, g_spin.to, g_spin.cx, g_spin.cz);
|
||||||
|
const double dx = q.m[0][3] - head.m[0][3], dz = q.m[2][3] - head.m[2][3];
|
||||||
|
double a = std::atan2(dx * rx + dz * rz, dx * fx + dz * fz) * 180 / M_PI;
|
||||||
|
if (!next) a = -a;
|
||||||
|
if (a <= kSpinAhead) a += 360;
|
||||||
|
if (!found || a < best) best = a, found = true;
|
||||||
|
}
|
||||||
|
if (!found || best >= 360 - kSpinAhead) {
|
||||||
|
if (!g_spin.on) g_spin.base.clear();
|
||||||
|
return (void)std::snprintf(reply, size, "ok 0 (no other panel)");
|
||||||
|
}
|
||||||
|
if (best > 180) best -= 360; // the short way round
|
||||||
|
turn = next ? best : -best;
|
||||||
|
} else {
|
||||||
|
char *end;
|
||||||
|
turn = std::strtod(arg, &end);
|
||||||
|
if (end == arg || *end) return (void)std::snprintf(reply, size, "error spin next|prev|<degrees>");
|
||||||
|
}
|
||||||
|
g_spin.to += turn * M_PI / 180;
|
||||||
|
g_spin.start = Clock::now();
|
||||||
|
g_spin.on = true;
|
||||||
|
SendPointer("recenter"); // the 3D mouse's pointer stays in front of you, on what comes there
|
||||||
|
std::snprintf(reply, size, "ok %.1f", turn);
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t LinuxButton(uint32_t vrButton) {
|
uint32_t LinuxButton(uint32_t vrButton) {
|
||||||
switch (vrButton) {
|
switch (vrButton) {
|
||||||
case vr::VRMouseButton_Right: return BTN_RIGHT;
|
case vr::VRMouseButton_Right: return BTN_RIGHT;
|
||||||
@@ -2134,6 +2267,14 @@ void ft_vr_poll(void (*handle)(const struct ft_event *, void *), void *data) {
|
|||||||
handle(&e, data);
|
handle(&e, data);
|
||||||
}
|
}
|
||||||
++g_tick;
|
++g_tick;
|
||||||
|
UpdateSpin();
|
||||||
|
if (g_spin.front >= 0) {
|
||||||
|
ft_event e{};
|
||||||
|
e.type = FT_FRONT;
|
||||||
|
e.screen = g_spin.front;
|
||||||
|
g_spin.front = -1;
|
||||||
|
handle(&e, data);
|
||||||
|
}
|
||||||
UpdateGame();
|
UpdateGame();
|
||||||
UpdateArrange();
|
UpdateArrange();
|
||||||
UpdateVisibility();
|
UpdateVisibility();
|
||||||
@@ -2210,6 +2351,8 @@ void ft_vr_keyboard_hide(void) {
|
|||||||
// ~100 ms (it landed on something else), KWin gets it anyway
|
// ~100 ms (it landed on something else), KWin gets it anyway
|
||||||
// state -> "ok <mode> <manual 0|1> <wrist deg> <gesture hand> <gesture deg>
|
// state -> "ok <mode> <manual 0|1> <wrist deg> <gesture hand> <gesture deg>
|
||||||
// <controllers> <game running 0|1> <ingames>"
|
// <controllers> <game running 0|1> <ingames>"
|
||||||
|
// spin next|prev|<degrees> turn every panel in the room about your head (see the lazy
|
||||||
|
// susan) -> "ok <degrees turned>"
|
||||||
// cutouts on|off|state hand cutouts (see handcut.h) -> "ok <on|off> <ready|idle|unavailable>
|
// cutouts on|off|state hand cutouts (see handcut.h) -> "ok <on|off> <ready|idle|unavailable>
|
||||||
// <last composite ms> ms, predict <on|off> lead <ms> ms"
|
// <last composite ms> ms, predict <on|off> lead <ms> ms"
|
||||||
// cutouts predict on|off move the hands ahead along their velocity (on by default)
|
// cutouts predict on|off move the hands ahead along their velocity (on by default)
|
||||||
@@ -2247,6 +2390,7 @@ void ft_vr_command(const char *cmd, char *reply, int size) {
|
|||||||
Screen *s = Find(n);
|
Screen *s = Find(n);
|
||||||
if (!s) return (void)std::snprintf(reply, size, "error no screen %d", n);
|
if (!s) return (void)std::snprintf(reply, size, "error no screen %d", n);
|
||||||
EndDrag(*s);
|
EndDrag(*s);
|
||||||
|
g_spin.base.erase(n - 1);
|
||||||
SetAbsolute(*s, PanelPose(x, y, z, yaw, pitch, roll));
|
SetAbsolute(*s, PanelPose(x, y, z, yaw, pitch, roll));
|
||||||
std::snprintf(reply, size, "ok");
|
std::snprintf(reply, size, "ok");
|
||||||
} else if (std::sscanf(cmd, "width %d %lf", &n, &w) == 2) {
|
} else if (std::sscanf(cmd, "width %d %lf", &n, &w) == 2) {
|
||||||
@@ -2413,6 +2557,7 @@ void ft_vr_command(const char *cmd, char *reply, int size) {
|
|||||||
Mat m{};
|
Mat m{};
|
||||||
for (int k = 0; k < 12; ++k) m.m[k / 4][k % 4] = r[k];
|
for (int k = 0; k < 12; ++k) m.m[k / 4][k % 4] = r[k];
|
||||||
EndDrag(*s);
|
EndDrag(*s);
|
||||||
|
g_spin.base.erase(n - 1);
|
||||||
SetAbsolute(*s, m);
|
SetAbsolute(*s, m);
|
||||||
std::snprintf(reply, size, "ok");
|
std::snprintf(reply, size, "ok");
|
||||||
} else if (int k0; std::sscanf(cmd, "sub %d %d %d %d %d %d", &n, &k0, &x0, &y0, &w0, &h0) == 6 ||
|
} else if (int k0; std::sscanf(cmd, "sub %d %d %d %d %d %d", &n, &k0, &x0, &y0, &w0, &h0) == 6 ||
|
||||||
@@ -2440,6 +2585,8 @@ void ft_vr_command(const char *cmd, char *reply, int size) {
|
|||||||
if ((g_press.buttons & ButtonBit(BTN_LEFT)) && g_press.device != kNone && !IsHandController(g_press.device))
|
if ((g_press.buttons & ButtonBit(BTN_LEFT)) && g_press.device != kNone && !IsHandController(g_press.device))
|
||||||
g_press.upAt = g_tick + 9;
|
g_press.upAt = g_tick + 9;
|
||||||
std::snprintf(reply, size, "ok");
|
std::snprintf(reply, size, "ok");
|
||||||
|
} else if (std::sscanf(cmd, "spin %15s", word) == 1) {
|
||||||
|
SpinCommand(word, reply, size);
|
||||||
} else if (std::strncmp(cmd, "state", 5) == 0) {
|
} else if (std::strncmp(cmd, "state", 5) == 0) {
|
||||||
std::snprintf(reply, size, "ok %s %d %.0f %s %.0f %s %d %s", ModeName(), g_manual ? 1 : 0, g_wristAngle,
|
std::snprintf(reply, size, "ok %s %d %.0f %s %.0f %s %d %s", ModeName(), g_manual ? 1 : 0, g_wristAngle,
|
||||||
g_gestureHand.c_str(), g_gestureAngle, LasersName(), g_gameRunning ? 1 : 0,
|
g_gestureHand.c_str(), g_gestureAngle, LasersName(), g_gameRunning ? 1 : 0,
|
||||||
|
|||||||
+2
-1
@@ -17,7 +17,8 @@ struct ft_dmabuf {
|
|||||||
int fd[4];
|
int fd[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ft_event_type { FT_MOTION, FT_BUTTON, FT_SCROLL, FT_LEAVE, FT_QUIT, FT_KEY, FT_KEYBOARD_CLOSED };
|
// FT_FRONT: a spin (the lazy susan) brought panel `screen` to straight ahead: typing goes there.
|
||||||
|
enum ft_event_type { FT_MOTION, FT_BUTTON, FT_SCROLL, FT_LEAVE, FT_QUIT, FT_KEY, FT_KEYBOARD_CLOSED, FT_FRONT };
|
||||||
|
|
||||||
struct ft_event {
|
struct ft_event {
|
||||||
enum ft_event_type type;
|
enum ft_event_type type;
|
||||||
|
|||||||
Reference in new issue
Block a user