def _inner(qtile: Qtile) -> None: if len(qtile.screens) == 1: qtile.groups_map[name].cmd_toscreen() return if name in '12345': qtile.focus_screen(LEFT_SCREEN_IDX) qtile.groups_map[name].cmd_toscreen() else: qtile.focus_screen(RIGHT_SCREEN_IDX) qtile.groups_map[name].cmd_toscreen()
def focus_smart(qtile: Qtile, key): if key is None or qtile.current_screen is None: return win = qtile.current_window if win is None: x, y = qtile.current_screen.x, qtile.current_screen.y else: x, y = win.info()["x"], win.info()["y"] screens = qtile.screens candidates = [] candidates_screens = get_candidates_screens(qtile, x, y, key) screens_helper = [] for screen in screens: group = screen.group if group is None or screen.x is None or screen.y is None: continue layout = group.layout clients = list(layout.clients) if group.floating_layout is not None: for client in group.floating_layout.clients: if client.info()["name"] == "Kodi": continue if client.fullscreen and int( client.info()["group"][-1]) == screen.index: clients = [client] break else: clients.extend([ c for c in list(group.floating_layout.clients) if int(c.info()["group"][-1]) == screen.index ]) for c in clients: if c.info()["name"] == "Kodi": continue if key == "h": if c.info()["x"] < x: candidates.append(c) screens_helper.append(screen) elif key == "j": if c.info()["y"] > y: candidates.append(c) screens_helper.append(screen) elif key == "k": if c.info()["y"] < y: candidates.append(c) screens_helper.append(screen) elif key == "l": if c.info()["x"] > x: candidates.append(c) screens_helper.append(screen) selected_idx, selected = get_closest(x, y, candidates) if selected is None or selected_idx is None: screen = closest_screen(x, y, candidates_screens) if screen is not None: qtile.focus_screen(screen.index, warp=False) return selected_screen = screens_helper[selected_idx] qtile.focus_screen(selected_screen.index) selected_screen.group.focus(selected)