Repository navigation
Conversation
|
Thanks for the patch. At first glance, I see some code duplication we can wrap up but it looks good overall. But, since the toggle option is broken, I'd like to fix that first. I will do a bit of testing on the toggle binding and report back hopefully soon. |
|
I tested toggle hide cursor and it works ok here. |
soreau
left a comment
There was a problem hiding this comment.
The basic idea sounds good, but it could be restructured a bit, see review comments.
| wf::get_core().connect(&workspace_changed); | ||
| } | ||
|
|
||
| void reevaluate() |
There was a problem hiding this comment.
I feel like this should have a bool argument for the last conditional in the function, to avoid code duplication (see next comment).
| [=] (wf::input_event_signal<wlr_pointer_motion_event> *ev) | ||
| { | ||
| setup_hide_timer(); | ||
| auto view = wf::get_core().get_cursor_focus_view(); |
There was a problem hiding this comment.
Lines 77-95 is code duplicated in the reevaluate function above. You should be able to call reevaluate here with the added bool argument instead of 77-95, to hide or unhide in the case the window doesn't match disabled_for. You will have to modify the reevaluate function to handle the bool argument accordingly.
| setup_hide_timer(); | ||
| }; | ||
|
|
||
| wf::signal::connection_t<wf::workspace_changed_signal> workspace_changed = |
There was a problem hiding this comment.
I feel this addition should be in a separate patch since it's new behavior. Ideally, you would have a patch that adds the option to xml and the bulk of the code here, and another that adds calling reevaluate on workspace_changed. This way, we can merge instead of squash it so it will be easier to bisect in case there is a bug.
|
I think we should try to find out why the toggle binding doesn't work for you, but it would be easier if you joined chat to avoid flooding github with too many messages. |
Yeah sorry I thought the option was to toggle the plugin itself. |
|
@soreau Ok, I removed the workspace switch event, that means the user always need to move the mouse to make the cursor reappear (which is fine.) If later we want to get it back we could just use I built and installed and tested, works nicely for now. |
|
Sorry for all the changes, I learn a little bit of C++ along the way. |
Sorry if I wasn't clear before, but I didn't mean that we should remove the workspace switch event. I meant that this PR ideally should have only two commits/patches: One that adds the option in xml and cpp, then another patch that introduces the workspace switch event handling. However, the latter could go into another PR since it's a new idea, but either is fine with me. |
No worries, it's always a learning process. However, you can always consolidate your changes into one or two commits/patches and force-push your branch. |
soreau
left a comment
There was a problem hiding this comment.
You really shaped it up, I think it looks much better now. Just one last thing in the comment below.
Let me know if you want to add workspace switch back, then we can run the CI and merge this.
| wf::signal::connection_t<wf::input_event_signal<wlr_pointer_motion_event>> pointer_motion = | ||
| [=] (wf::input_event_signal<wlr_pointer_motion_event> *ev) | ||
| { | ||
| setup_hide_timer(); |
There was a problem hiding this comment.
When mouse motion happens, we need to reset the timer, so the cursor hides after moving the mouse.
There was a problem hiding this comment.
it's at the bottom of the function yes. Because show_cursor disconnects the timer now, so it can't be placed before.
|
|
||
| void show_cursor() | ||
| { | ||
| hide_timer.disconnect(); |
There was a problem hiding this comment.
It almost seems like we shouldn't call hide_timer.disconnect() here because when we show the cursor, we want it to timeout and ultimately hide it again. I think you want to disconnect the timer instead in toggle_cursor for the hidden case where show_cursor is called.
There was a problem hiding this comment.
I think it's fine because "show cursor" should explicitly show the cursor and should prevent any previously set timer to hide it again. The timer is set again on further mouse move (or any other event we might add in the future). Also it works well when turning the plugin off or for the toggle logic.
I am not sure why but this wf::signal::connection_t<wf::workspace_changed_signal> workspace_changed =
[=] (wf::workspace_changed_signal *ev)
{
...
}didn't work well last time I tested (when using "viewport switcher" keybinds). Is there a specific protocol to enable? Also we should think of the best strategy here, do we use same logic as mouse motion, if (hidden)
{
show_cursor();
}
restart_hide_timer();or do we call The latter seems preferable but we have to make sure the transition is completed before calling anything or else this new condition If it's ok for now maybe you can merge this, so we can work clean on a new PR for workspace event |
|
Ok fixed. Just had to move the event listener in the plugin class where Edit: After 2 days of usage everything works smoothly, not a single issue. |
To be honest, I liked the code better when I approved the changes. The patch seems kinda sloppy to me now, but I will have to give it another review later I suppose. |
|
@soreau Why would adding workspace change event be a bad thing? |
I am not saying that it is a bad thing, in fact we want this to be functional. I am saying that in the code, the only thing that should have happened is the addition of workspace change handler with the hide_or_show_cursor call. It seems that there were a lot more changes though. |
|
Here's the changes since your last review:
So really, I just added workspace change event listener since last review, the rest is just small tweaks, refactoring, making things coherent. |

Changes in this PR:
Note: It's worth mentioning I don't have a good knowledge of C++ and I used ChatGPT as an assistant. Though the changes seems solid.