Waybar icon indicating copy to clipboard operation
Waybar copied to clipboard

[FEATURE REQUEST] wlr/taskbar let the cursor over the icon

Open adocampo opened this issue 1 year ago • 3 comments

I had to install the module wlr/taskbar because some times my wife sits on my computer and she can't even figure how to open anything. So I've used to use that module myself.

I find annoying to click in the icon and the cursor disappearing from there and placing itself in the middle of the clicked application. I know this is a normal behavior in hypraland (and perhaps others), but feels unnatural when clicking on a taskbar item.

I see in the waybar-wlr-taskbar man page there are just some click actions, like activate, close, maximize, etc... I would love to see an option let the cursor just there, where I just clicked above that icon.

I've been playing with hyprctl cursorpos to obtain the coordinates and screen of the cursor, and hyprctl dispatch movecursor to move the cursor where I want, so if in the wlr-taskbar would be an action "execute_command" and we would be able to run our custom command on-click, on-click-middle, and on-click-right, we would be able not just to do exactly that, but extend functionality of the events way a lot more.

What dou you think, devs?

adocampo avatar Dec 19 '24 17:12 adocampo

Some background info: right now, the action handling in wlr/taskbar is slightly broken, because the on-clicks are evaluated both by wlr-taskbar on the individual buttons and AModule on the whole module. PR #3420 would fix that. If it's merged, you could theoretically do something like

{
    "layer": "top", // Waybar at top layer
    "position": "top", // Waybar position (top|bottom|left|right)
    "height" : 50,
    "modules-center": ["wlr/taskbar"],
    "wlr/taskbar": {
      "format": "{icon}",
      "icon-size": 24,
      "all-outputs": false,
      "actions" : {
          "on-click": "activate",
          "on-click-middle": "maximize",
          "on-click-right": "close",
      },
     "on-click": "module-wide-action.sh",
      "on-click-middle": "module-wide-action.sh",
      "on-click-right": "module-wide-action.sh",
    },
}

and both the wlr window action and the script should be executed. In order to actually move the cursor back, this is no option, because you can't run a script before and after and generally it'd probably race anyway.

I suppose it would be nice to create a followup PR to allow custom commands to be run INSTEAD of the window action, and then the user can do whatever they want, e.g. run hyprctl to retrieve cursor position, activate or close a window and then move the cursor back to the original position. But I think this is still not going to work. wlr/taskbar is using wlr foreign toplevel handles, see https://wayland.app/protocols/wlr-foreign-toplevel-management-unstable-v1 . AFAIK, this handle does not translate into anything you can use with hyprctl (or swaymsg, for that matter).

BTW, on sway, the cursor does NOT jump to the window in question. And the protocol does not say anything about cursor handling for the individual actions. Best suggestion I can offer is to ask the Hyprland people why it does.

EDIT: replaced incorrect link to PR

RobertMueller2 avatar Dec 20 '24 08:12 RobertMueller2

Throwing another comment in here since I'm running into this now myself; has there been any progress on this? I see that referred issue is still open.

yourlocaltechboi avatar May 25 '25 07:05 yourlocaltechboi

Throwing another comment in here since I'm running into this now myself; has there been any progress on this? I see that referred issue is still open.

Yes, but it is actually unrelated. I wanted to link a PR, #3420, which is also still open 😅

RobertMueller2 avatar May 25 '25 07:05 RobertMueller2