-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Region + follow mouse = magnifier #35
Comments
There is no way to get the mouse position in wayland if the mouse is not currently over your own window, so this would require extra compositor support. some compositors (e.g. sway, hyprland) might have ways to get the current mouse position via IPC, wo you could script that outside wl-mirror in a similar way to what wl-present does. |
if this is easily scriptable on a compositor, I would very gladly accept a PR for an example script that implements a magnifier, since it's a really cool demo. |
It seems like there is no feature to get the current mouse coordinates on sway, but there is an IPC command for it on hyprland ( Here's a very hacky proof-of-concept script for hyprland that demonstrates the possibility: #!/bin/bash
# usage: ./magnify.sh eDP-1
# usage: ./magnify.sh eDP-1 200
DEFAULT_SIZE=100
magnify-region() {
SIZE=${1:-$DEFAULT_SIZE}
POS=$(hyprctl cursorpos)
IFS=',' read -r X Y <<< "$POS"
echo "$((X-SIZE/2)),$((Y-SIZE/2)) $((SIZE))x$((SIZE))"
}
magnify() {
SIZE=${1:-$DEFAULT_SIZE}
while sleep .1; do
wl-present set-region "$(magnify-region "$SIZE")"
done
}
wl-present mirror "${1:-eDP-1}" &
magnify "${2:-$DEFAULT_SIZE}"
trap 'killall wl-mirror' EXIT This doesn't provide a great experience, but shows that if at some point compositors provide better ways to get the cursor position, this could be implementable. |
Of note: IIRC it's possible for compositors to provide the cursor image as a separate layer in the XDG Portals / Pipewire screen capture protocol (see #16). Technically wl-mirror could also extract mouse coordinates from there once that protocol is implemented, and that would be a much more consistent source of the cursor position for magnification. This would still be a hack though, since it's not guaranteed that a compositor provides the cursor as a separate layer or displays it at all. |
Since there isn't a good way to get the cursor position in Wayland right now I might either close this issue or mark this as an "upstream bug" since there isn't much we can do as a regular Wayland client that would solve this in a satisfactory fashion. |
Well, till something comes up in the protocols... |
If it is possible to make a region follow mouse, wl-mirror could act as screen magnifier.
The text was updated successfully, but these errors were encountered: