Skip to content

Commit

Permalink
Use qtile.get_mouse_position rather than passing it as arguments
Browse files Browse the repository at this point in the history
See #1371 for rationale.
  • Loading branch information
ramnes committed Jul 6, 2019
1 parent fdb3a32 commit f502dad
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion libqtile/core/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ def handle_MotionNotify(self, e): # noqa: N802
status, val = self.server.call((
i.selectors,
i.name,
i.args + (rx + dx, ry + dy, e.event_x, e.event_y),
i.args + (rx + dx, ry + dy),
i.kwargs
))
if status in (command_interface.ERROR, command_interface.EXCEPTION):
Expand Down
11 changes: 6 additions & 5 deletions libqtile/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -1324,19 +1324,19 @@ def cmd_toscreen(self, index=None):
"""
self.toscreen(index)

def cmd_move_floating(self, dx, dy, curx, cury):
def cmd_move_floating(self, dx, dy):
"""Move window by dx and dy"""
self.tweak_float(dx=dx, dy=dy)

def cmd_resize_floating(self, dw, dh, curx, cury):
def cmd_resize_floating(self, dw, dh):
"""Add dw and dh to size of window"""
self.tweak_float(dw=dw, dh=dh)

def cmd_set_position_floating(self, x, y, curx, cury):
def cmd_set_position_floating(self, x, y):
"""Move window to x and y"""
self.tweak_float(x=x, y=y)

def cmd_set_size_floating(self, w, h, curx, cury):
def cmd_set_size_floating(self, w, h):
"""Set window dimensions to w and h"""
self.tweak_float(w=w, h=h)

Expand Down Expand Up @@ -1416,13 +1416,14 @@ def _is_in_window(self, x, y, window):
return (window.edges[0] <= x <= window.edges[2] and
window.edges[1] <= y <= window.edges[3])

def cmd_set_position(self, dx, dy, curx, cury):
def cmd_set_position(self, dx, dy):
if self.floating:
self.tweak_float(dx, dy)
return
for window in self.group.windows:
if window == self or window.floating:
continue
curx, cury = self.qtile.get_mouse_position()
if self._is_in_window(curx, cury, window):
clients = self.group.layout.clients
index1 = clients.index(self)
Expand Down
10 changes: 5 additions & 5 deletions test/test_fakescreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,38 +342,38 @@ def test_float_outside_edges(qtile):
'clients': [], 'current': 0, 'group': 'a', 'name': 'max'}

# move left, but some still on screen 0
qtile.c.window.move_floating(-30, 20, 42, 42)
qtile.c.window.move_floating(-30, 20)
assert qtile.c.window.info()['width'] == 164
assert qtile.c.window.info()['height'] == 164
assert qtile.c.window.info()['x'] == -14
assert qtile.c.window.info()['y'] == 20
assert qtile.c.window.info()['group'] == 'a'

# move up, but some still on screen 0
qtile.c.window.set_position_floating(-10, -20, 42, 42)
qtile.c.window.set_position_floating(-10, -20)
assert qtile.c.window.info()['width'] == 164
assert qtile.c.window.info()['height'] == 164
assert qtile.c.window.info()['x'] == -10
assert qtile.c.window.info()['y'] == -20
assert qtile.c.window.info()['group'] == 'a'

# move above a
qtile.c.window.set_position_floating(50, -20, 42, 42)
qtile.c.window.set_position_floating(50, -20)
assert qtile.c.window.info()['width'] == 164
assert qtile.c.window.info()['height'] == 164
assert qtile.c.window.info()['x'] == 50
assert qtile.c.window.info()['y'] == -20
assert qtile.c.window.info()['group'] == 'a'

# move down so still left, but next to screen c
qtile.c.window.set_position_floating(-10, 520, 42, 42)
qtile.c.window.set_position_floating(-10, 520)
assert qtile.c.window.info()['height'] == 164
assert qtile.c.window.info()['x'] == -10
assert qtile.c.window.info()['y'] == 520
assert qtile.c.window.info()['group'] == 'c'

# move above b
qtile.c.window.set_position_floating(700, -10, 42, 42)
qtile.c.window.set_position_floating(700, -10)
assert qtile.c.window.info()['width'] == 164
assert qtile.c.window.info()['height'] == 164
assert qtile.c.window.info()['x'] == 700
Expand Down
16 changes: 8 additions & 8 deletions test/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,14 +429,14 @@ def test_default_float(qtile):
assert self.c.window.info()['y'] == 208
assert self.c.window.info()['floating'] is True

self.c.window.move_floating(10, 20, 42, 42)
self.c.window.move_floating(10, 20)
assert self.c.window.info()['width'] == 164
assert self.c.window.info()['height'] == 164
assert self.c.window.info()['x'] == 328
assert self.c.window.info()['y'] == 228
assert self.c.window.info()['floating'] is True

self.c.window.set_position_floating(10, 20, 42, 42)
self.c.window.set_position_floating(10, 20)
assert self.c.window.info()['width'] == 164
assert self.c.window.info()['height'] == 164
assert self.c.window.info()['x'] == 10
Expand All @@ -461,7 +461,7 @@ def test_last_float_size(qtile):
assert self.c.window.info()['width'] == 150
assert self.c.window.info()['height'] == 100
# resize
self.c.window.set_size_floating(50, 90, 42, 42)
self.c.window.set_size_floating(50, 90)
assert self.c.window.info()['width'] == 50
assert self.c.window.info()['height'] == 90
# back to not floating
Expand Down Expand Up @@ -673,7 +673,7 @@ def test_floating_focus(qtile):
assert self.c.window.info()['width'] == 398
assert self.c.window.info()['height'] == 578
self.c.window.toggle_floating()
self.c.window.move_floating(10, 20, 42, 42)
self.c.window.move_floating(10, 20)
assert self.c.window.info()['name'] == 'xeyes'
assert self.c.group.info()['focus'] == 'xeyes'
# check what stack thinks is focus
Expand Down Expand Up @@ -725,25 +725,25 @@ def test_move_floating(qtile):
self.c.window.toggle_floating()
assert self.c.window.info()['floating'] is True

self.c.window.move_floating(10, 20, 42, 42)
self.c.window.move_floating(10, 20)
assert self.c.window.info()['width'] == 150
assert self.c.window.info()['height'] == 100
assert self.c.window.info()['x'] == 10
assert self.c.window.info()['y'] == 20

self.c.window.set_size_floating(50, 90, 42, 42)
self.c.window.set_size_floating(50, 90)
assert self.c.window.info()['width'] == 50
assert self.c.window.info()['height'] == 90
assert self.c.window.info()['x'] == 10
assert self.c.window.info()['y'] == 20

self.c.window.resize_floating(10, 20, 42, 42)
self.c.window.resize_floating(10, 20)
assert self.c.window.info()['width'] == 60
assert self.c.window.info()['height'] == 110
assert self.c.window.info()['x'] == 10
assert self.c.window.info()['y'] == 20

self.c.window.set_size_floating(10, 20, 42, 42)
self.c.window.set_size_floating(10, 20)
assert self.c.window.info()['width'] == 10
assert self.c.window.info()['height'] == 20
assert self.c.window.info()['x'] == 10
Expand Down

0 comments on commit f502dad

Please sign in to comment.