def gaze_scroll(): # print("gaze_scroll") if (eye_zoom_mouse.zoom_mouse.state == eye_zoom_mouse.STATE_IDLE ): # or eye_zoom_mouse.zoom_mouse.state == eye_zoom_mouse.STATE_SLEEP: x, y = ctrl.mouse_pos() # the rect for the window containing the mouse rect = None # on windows, check the active_window first since ui.windows() is not z-ordered if app.platform == "windows" and ui.active_window().rect.contains( x, y): rect = ui.active_window().rect else: windows = ui.windows() for w in windows: if w.rect.contains(x, y): rect = w.rect break if rect is None: # print("no window found!") return midpoint = rect.y + rect.height / 2 amount = int(((y - midpoint) / (rect.height / 10))**3) actions.mouse_scroll(by_lines=False, y=amount)
def gazeScroll(): windows = ui.windows() window = None x, y = ctrl.mouse_pos() for w in windows: if w.rect.contains(x, y): window = w.rect break if window is None: return midpoint = window.y + window.height / 2 amount = ((y - midpoint) / (window.height / 10))**3 ctrl.mouse_scroll(by_lines=False, y=amount)
def gaze_scroll(): #print("gaze_scroll") if eye_zoom_mouse.zoom_mouse.state == eye_zoom_mouse.STATE_IDLE: windows = ui.windows() window = None x, y = ctrl.mouse_pos() for w in windows: if w.rect.contains(x, y): window = w.rect break if window is None: #print("no window found!") return midpoint = window.y + window.height / 2 amount = int(((y - midpoint) / (window.height / 10))**3) actions.mouse_scroll(by_lines=False, y=amount)
def show_window_switcher(): """Display a window switcher""" global shown_windows global window_spelling global groups global this_desktop_windows global window_to_words shown_windows = ui.windows() print("current desk is...") current_desk = list( filter( lambda l: l.split(" ")[1][0] == "*", run(["wmctrl", "-d"], capture_output=True, encoding="utf8").stdout.splitlines()))[0].split(" ") print(" ", current_desk) # wmctrl -l gives us window IDs (in hex) and desktop numbers (-1 is pinned) desk_map = run(["wmctrl", "-l"], capture_output=True, encoding="utf8").stdout.splitlines() # for every window, store its ID : its desk desk_map = { int(a[0][2:], 16): int(a[1]) for a in map(lambda l: l.split()[0:2], desk_map) } # build letter combos combs = make_combinations(len(shown_windows)) # grab the desktops that have windows groups = sorted(set(desk_map.values())) print("desk map:") print(" ", desk_map) # put a list of all window objects that are on one desktop for each desk groups = { k: list(filter(lambda e: desk_map.get(e.id, None) == k, shown_windows)) for k in groups } shown_windows = [] this_desktop_windows = [] window_to_words = {} # make a flat list for k in groups: shown_windows.extend(groups[k]) if k == -1 or k == int(current_desk[0]): this_desktop_windows.extend(groups[k]) # turn letter combos into word combos (ab -> air bat) window_spelling = list( map( lambda entry: " ".join( map(lambda digit: default_alphabet[digit], entry)), combs)) ctx.lists['self.window_selection_words'] = window_spelling i = 0 for k in groups: print(repr(k), " ", repr(int(current_desk[0]))) if k == -1 or k == int(current_desk[0]): print(" this is the one!") for w in groups[k]: print(" saving spelling for ", w.id, " as ", window_spelling[i], " which is ", i) window_to_words[w.id] = window_spelling[i] i += 1 else: i += len(groups[k]) gui.show()