mirror of
https://github.com/virtcode/hypr-dynamic-cursors
synced 2025-09-19 16:13:21 +02:00
fix: correct hotspot on transformed monitors
This commit is contained in:
parent
bdb84fafa7
commit
6a1d3e68c9
2 changed files with 20 additions and 8 deletions
18
README.md
18
README.md
|
@ -1,9 +1,7 @@
|
||||||
# hypr-dynamic-cursors
|
# hypr-dynamic-cursors
|
||||||
This plugin makes your more realistic by simulating how it would behave if it was an actual object being dragged across your screen. This means that it will change orientation based on in which direction you are moving.
|
This plugin makes your cursor more realistic by simulating how it would behave if it was an actual object being dragged across your screen. This means that it will change orientation based on in which direction you are moving.
|
||||||
|
|
||||||
This plugin changes the cursor rendering, so it will work with all of your cursor themes.
|
Why did I implement this again?
|
||||||
|
|
||||||
Why should you use this? Right, why did I implement this again?
|
|
||||||
|
|
||||||
## showcase
|
## showcase
|
||||||
Currently, the cursor is being simulated as a stick being dragged across a surface. In action, this looks like this.
|
Currently, the cursor is being simulated as a stick being dragged across a surface. In action, this looks like this.
|
||||||
|
@ -22,7 +20,7 @@ This plugin is still very early in its development. **Currently, only the `-git`
|
||||||
|
|
||||||
If anything here sounds interesting to you, don't hesitate to contribute.
|
If anything here sounds interesting to you, don't hesitate to contribute.
|
||||||
|
|
||||||
Also note that this plugin was created more or less as a joke. I do not guarantee any updates or bugfixes, but will still try to somewhat maintain it.
|
Please note that this plugin was created more or less as a joke. I mainly wanted to see how using a rotating cursor was like. So I will not guarantee any future updates and bugfixes.
|
||||||
|
|
||||||
## installation
|
## installation
|
||||||
Installation is supported via `hyprpm`. Supported hyprland versions are `v0.42.0` (yet unreleased) and upwards. The main branch generally tries to target `-git`.
|
Installation is supported via `hyprpm`. Supported hyprland versions are `v0.42.0` (yet unreleased) and upwards. The main branch generally tries to target `-git`.
|
||||||
|
@ -57,8 +55,16 @@ Depending on your hyprland configuration, this plugin can have a different perfo
|
||||||
Rotating the cursor can be done in the same draw call that is used to draw the cursor anyways, so there is no additional performance impact. Note however that software cursors in of themselves are not really efficient.
|
Rotating the cursor can be done in the same draw call that is used to draw the cursor anyways, so there is no additional performance impact. Note however that software cursors in of themselves are not really efficient.
|
||||||
|
|
||||||
**Hardware Cursors**: Medium performance impact. <br>
|
**Hardware Cursors**: Medium performance impact. <br>
|
||||||
To rotate the cursor smoothly, the cursor shape needs to be changed quite often. This is not exactly compatible with how hardware cursors are intended to work. With this plugin, the overhead of changing the cursor shape can be noticed more often, making it less efficient. It is still more efficient than using software cursor though.
|
To rotate the cursor smoothly, the cursor shape needs to be changed quite often. This is not exactly compatible with how hardware cursors are intended to work. With this plugin, the overhead of changing the cursor shape can be noticed more often, making it use more resources. Compared to normal hardware cursors, there is a big performance hit, but it is still more efficient than using software cursor though.
|
||||||
|
|
||||||
|
## development
|
||||||
|
To work on this plugin, you can clone this repository and use the Makefile to build it. I suggest opening a nested Hyprland session, and loading the plugin there:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
make load
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want to debug hardware cursors, this plugin also has an additional configuration option, `hw_debug` which when true will show where the whole cursor buffer is, and also shows when it is updated.
|
||||||
|
|
||||||
## license
|
## license
|
||||||
This plugin is licensed under the MIT License. Have a look at the `LICENSE.md` file for more information.
|
This plugin is licensed under the MIT License. Have a look at the `LICENSE.md` file for more information.
|
||||||
|
|
|
@ -173,11 +173,17 @@ bool CDynamicCursors::setHardware(CPointerManager* pointers, SP<CPointerManager:
|
||||||
if (!state->monitor->output->impl->set_cursor)
|
if (!state->monitor->output->impl->set_cursor)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const auto HOTSPOT = pointers->transformedHotspot(state->monitor.lock());
|
auto P_MONITOR = state->monitor.lock();
|
||||||
|
if (!P_MONITOR->output->cursor_swapchain) return false;
|
||||||
|
|
||||||
|
// we need to transform the hotspot manually as we need to indent it by the size
|
||||||
|
const auto HOTSPOT = CBox{(pointers->currentCursorImage.hotspot + pointers->currentCursorImage.size) * P_MONITOR->scale, {0, 0}}
|
||||||
|
.transform(wlTransformToHyprutils(wlr_output_transform_invert(P_MONITOR->transform)), P_MONITOR->output->cursor_swapchain->width, P_MONITOR->output->cursor_swapchain->height)
|
||||||
|
.pos();
|
||||||
|
|
||||||
Debug::log(TRACE, "[pointer] hw transformed hotspot for {}: {}", state->monitor->szName, HOTSPOT);
|
Debug::log(TRACE, "[pointer] hw transformed hotspot for {}: {}", state->monitor->szName, HOTSPOT);
|
||||||
|
|
||||||
if (!state->monitor->output->impl->set_cursor(state->monitor->output, buf, HOTSPOT.x + pointers->currentCursorImage.size.x, HOTSPOT.y + pointers->currentCursorImage.size.y))
|
if (!state->monitor->output->impl->set_cursor(state->monitor->output, buf, HOTSPOT.x, HOTSPOT.y))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
wlr_buffer_unlock(state->cursorFrontBuffer);
|
wlr_buffer_unlock(state->cursorFrontBuffer);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue