Commit 5cfd45707dda9a4f7242691d8368c875f9ef879f Parent: 1928c8efb7e459871562ae917d6e0cc7c6fad659 Author: mcol <mcol@posteo.net> Date: 2020-06-07 10:33:55 +0100 Committer: mcol <mcol@posteo.net> Committed: 2020-06-07 10:33:55 +0100 focus: also focus between windows and empty screens
qtools/focus/focus.py Modified
@@ -1,8 +1,8 @@ """ -This plugin exposes four functions - up, down, left and right - that when called will +This plugin exports four functions - up, down, left and right - that when called will move window focus to the first window in that general direction. Focussing is based entirely on position and geometry, so is independent of screens, layouts and whether -windows are floating or tiled. +windows are floating or tiled. It can also move focus to and from empty screens. Example usage: @@ -17,6 +17,9 @@ """ +from libqtile.config import Screen + + def up(qtile): _focus_window(qtile, -1, 'y') @@ -38,27 +41,35 @@ win_wide = None dist = 10000 dist_wide = 10000 + cur = qtile.current_window + if not cur: + cur = qtile.current_screen if axis == 'x': dim = 'width' band_axis = 'y' band_dim = 'height' - cur_pos, band_min, _, band_max = qtile.current_window.edges + cur_pos = cur.x + band_min = cur.y + band_max = cur.y + cur.height else: dim = 'height' band_axis = 'x' band_dim = 'width' - band_min, cur_pos, band_max, _ = qtile.current_window.edges + band_min = cur.x + cur_pos = cur.y + band_max = cur.x + cur.width - cur_pos += getattr(qtile.current_window, dim) / 2 + cur_pos += getattr(cur, dim) / 2 windows = [w for g in qtile.groups if g.screen for w in g.windows] + windows.extend([s for s in qtile.screens if not s.group.windows]) - if qtile.current_window in windows: - windows.remove(qtile.current_window) + if cur in windows: + windows.remove(cur) for w in windows: - if not w.minimized: + if isinstance(w, Screen) or not w.minimized: pos = getattr(w, axis) + getattr(w, dim) / 2 gap = dir * (pos - cur_pos) if gap > 0: @@ -77,4 +88,5 @@ if win: qtile.focus_screen(win.group.screen.index) win.group.focus(win, True) - win.focus(False) + if not isinstance(win, Screen): + win.focus(False)