Add coordinates relative to the current output in i3bar click events

Currently i3bar click events provide x and y coordinates relative to all monitors.
I've added coordinates relative to the current output.

+-----------+-----------+
|           |   i3bar   |
|           +-----------+
|   HDMI-0  |    DP-0   |
| 1920x1080 | 2560x1080 |
+-----------+-----------+

When you click in the top right corner of the DP-0,
i3bar will provide something like this:

{
  "x": 4480,
  "y": 10,
  "output_x": 2560,
  "output_y": 10,
}

This is useful for creating a rofi menu or something else.
rofi -show run -location 1 -xoffset ${I3_OUTPUT_X} -yoffset ${I3_OUTPUT_Y}
This commit is contained in:
Andrey Burov
2020-10-06 21:38:09 +03:00
parent e6f419b882
commit 60384d446b
5 changed files with 27 additions and 10 deletions

View File

@ -260,6 +260,8 @@ button::
relative_x, relative_y::
Coordinates where the click occurred, with respect to the top left corner
of the block
output_x, output_y::
Coordinates relative to the current output where the click occurred
width, height::
Width and height (in px) of the block
modifiers::
@ -273,10 +275,12 @@ modifiers::
"instance": "eth0",
"button": 1,
"modifiers": ["Shift", "Mod1"],
"x": 1320,
"x": 1925,
"y": 1400,
"relative_x": 12,
"relative_y": 8,
"output_x": 5,
"output_y": 1400,
"width": 50,
"height": 22
}