Skip to content

Commit

Permalink
Allow popups to be placed at mouse pointer
Browse files Browse the repository at this point in the history
Adds `relative_to=0` to ``popup.show()`.
  • Loading branch information
elParaguayo committed Apr 25, 2024
1 parent a02828e commit 5e4e868
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion qtile_extras/popup/toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ def show(
positive x value will shift the popup to the right and a positive y value will shift
the popup down.
Setting ``relative_to=0`` is a special case which positions the top left corner of the
popup at the mouse's current location.
Setting ``relative_to_bar=True`` will automatically adjust the offset by the width of
the bar or gap (including any margin) nearest the point on the above grid
i.e. if ``relative_to=1`` then the y coordinate would be adjusted for any bar on the
Expand Down Expand Up @@ -282,7 +285,10 @@ def show(
if isinstance(y, float):
y = int(scr.height * y)

if relative_to == 1:
if relative_to == 0:
x, y = self.qtile.core.get_mouse_position()

elif relative_to == 1:
x += scr.x
y += scr.y

Expand Down

0 comments on commit 5e4e868

Please sign in to comment.