mirror of
https://github.com/debauchee/barrier.git
synced 2026-05-15 14:16:02 -06:00
[PR #1883] Hotkey on active screen only #1834
Labels
No labels
HiDPI
bounty
bsd/freebsd
bsd/openbsd
bug
bug
build-infra
cantfix
critical
doc
duplicate
enhancement
fix-available
from git
from release
good first issue
help wanted
installer/package
invalid
linux
macOS
meta
needs testing
pull-request
query
question
regression
regression
v2.4.0
windows
wontfix
work-in-progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/barrier#1834
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/debauchee/barrier/pull/1883
Author: @Rajveer86
Created: 1/25/2023
Status: 🔄 Open
Base:
master← Head:hotkey_on_active_screen_only📝 Commits (4)
f38ab7d[FEATURE] Add ability to perform keystrokes on only the active screen, if thatactive screen exists inscreens903b34c[FEATURE] ImplementdisableGlobalHotkeyRegisteroption for keystroke conditions to allow apps on the primary client to respond to the keystroke without the OS blocking thembd1408dAdded feature document for active screen hotkeys37299c2[BUGFIX] Fix macOS not properly skipping hotkey registration/unregistration📊 Changes
22 files changed (+175 additions, -85 deletions)
View changed files
➕
doc/newsfragments/keystrokes-on-active-screen-only.feature(+12 -0)📝
src/lib/barrier/IKeyState.cpp(+4 -1)📝
src/lib/barrier/IKeyState.h(+2 -1)📝
src/lib/barrier/IPlatformScreen.h(+2 -2)📝
src/lib/barrier/IPrimaryScreen.h(+2 -2)📝
src/lib/barrier/PlatformScreen.h(+2 -2)📝
src/lib/barrier/Screen.cpp(+4 -4)📝
src/lib/barrier/Screen.h(+2 -2)📝
src/lib/platform/MSWindowsScreen.cpp(+6 -9)📝
src/lib/platform/MSWindowsScreen.h(+2 -2)📝
src/lib/platform/OSXScreen.h(+2 -2)📝
src/lib/platform/OSXScreen.mm(+14 -10)📝
src/lib/platform/XWindowsScreen.cpp(+13 -7)📝
src/lib/platform/XWindowsScreen.h(+2 -2)📝
src/lib/server/Config.cpp(+51 -7)📝
src/lib/server/Config.h(+6 -0)📝
src/lib/server/InputFilter.cpp(+9 -7)📝
src/lib/server/InputFilter.h(+3 -2)📝
src/lib/server/PrimaryClient.cpp(+6 -14)📝
src/lib/server/PrimaryClient.h(+2 -2)...and 2 more files
📄 Description
What this PR does
This PR allows keystroke actions to be performed on only the active screen of specified screens.
Current behaviour
Currently keystroke actions behave as such:
keystroke(Control) = keystroke(Super)- performs on the active screen only, but with no way to have custom keystrokes for different screenskeystroke(Control) = keystroke(Super,Mac-Mini)- always performs on the specified screens, regardless of whether they are active, and no way to target a specific oneNew behaviour (
activeScreenOnlyoption)This PR adds a new optional setting
activeScreenOnlyto keystroke actions, used as such:keystroke(Control) = keystroke(Super,Mac-Mini,activeScreenOnly)- performs onMac-Mini, and only when it is activeAs normal, keystroke actions can be chained, meaning that we can have different shortcuts for different screens, and only when those screens are active:
keystroke(Control) = keystroke(Super,Mac-Mini:Mac-Pro,activeScreenOnly),keystroke(Alt,Laptop,activeScreenOnly)- changesControl->SuperonMac-MiniandMac-Pro, andControl->AltonLaptop, and only on the one that is activeWindows and macOS server specifics (
disableGlobalHotkeyRegisteroption)On Windows and macOS this works for both server and clients, with the exception being for keystroke actions intended for the server where the keystroke matches the condition (for instance, adding a custom action on a client, but preserving the original keystroke on the server) e.g.
keystroke(Control) = keystroke(Super,Mac-Mini,activeScreenOnly), keystroke(Alt,Server,activeScreenOnly)- this works on Serverkeystroke(Control) = keystroke(Super,Mac-Mini,activeScreenOnly), keystroke(Control,Server,activeScreenOnly)- this does not work on ServerSince Barrier registers a hotkey for the keystroke condition on the server, this prevents the ability to specify the original keystroke as an action for the server. For this, a new option
disableGlobalHotkeyRegisterfor the condition allows disabling hotkey registration with the OS. This allows the original keystroke to be performed on the server when it is in focus i.e.keystroke(Control,disableGlobalHotkeyRegister) = keystroke(Super,Rajveer-Mac-Mini,activeScreenOnly)- this allows the original keystroke to perform on the server, akin to if we also hadkeystroke(Control,Server,activeScreenOnly)Linux server specifics
On Linux, keystroke actions currently don't seem to work on the server at all. However, using
disableGlobalHotkeyRegisterat least allows us to achieve the same as in the above example (i.e. the server can perform the default keybind whilst clients have custom keybinds)keystroke(Left) = keystroke(Right)- this works on Windows and macOS when focusing the server, but not Linuxkeystroke(Left) = keystroke(Left)- this doesn't work on any server (but works on all when usingdisableGlobalHotkeyRegister)keystroke(Left,disableGlobalHotkeyRegister) = keystroke(Right,Mac-Mini,activeScreenOnly)- but at least this allows a custom hotkey onMac-Miniwhilst still allowing the default keystroke to perform on a server on any platformA real-world example
I want to control my Mac computers from my Windows machine, and want them to work with Windows keybinds (e.g. Ctrl+C to copy). On macOS I use Karabiner-Elements for this, but this doesn't work with Barrier. I now use the below configuration to achieve the same effect when running a Windows server:
Contributor Checklist:
doc/newsfragmentsdirectory IF it is auser-visible change (and make sure to read the
README.mdin that directory)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.