示例#1
0
    def switch_group(self, i):
        '''
        Switch the current group into group i
        '''
        for monitor in self.monitors:
            monitor.tilers[self.group].hide_windows()
            monitor.tilers[i].show_windows()
            monitor.tilers[i].tile_windows()
        self.group = i
        self.notifyicon.draw_icon(self.icon)
        Monitor.refresh_all_windows()

        # find new window to focus on (method 1)
        # new_curr_win = Window.window_under_cursor(self.windows)
        # if(new_curr_win != None):
        #     self.send_window_to_tiler(new_curr_win, i)
        #     new_curr_win.focus()
        # else:
        #     # other windows should lose focus
        #     # self.notifyicon.focus()
        #     self.taskbar.taskbar.focus()

        # find new window to focus on (method 2)
        curr_mon = Monitor.current_monitor_from_list(self.monitors)
        curr_win = curr_mon.tilers[i].get_current_window()
        if(curr_win != None):
            curr_win.focus()
        else:
            # other windows should lose focus
            # self.notifyicon.focus()
            self.taskbar.taskbar.focus()
示例#2
0
 def cmd_focus_previous_monitor(self):
     monitor = Monitor.current_monitor_from_list(self.monitors) 
     previousMonitor = Utility.previous_item(self.monitors, monitor)
     if(previousMonitor and previousMonitor.tilers[self.group].has_windows()):
         window = previousMonitor.tilers[self.group].get_current_window()
         if(window != None):
             window.focus()
示例#3
0
 def cmd_focus_next_monitor(self):
     monitor = Monitor.current_monitor_from_list(self.monitors)
     nextMonitor = Utility.next_item(self.monitors, monitor)
     if(nextMonitor and nextMonitor.tilers[self.group].has_windows()):
         window = nextMonitor.tilers[self.group].get_current_window()
         if(window != None):
             window.focus()
示例#4
0
    def __init__(self, name):
        '''
        Set up the notifyicon and the monitors
        '''
        self.group = 0
        self.ICONFOLDER = 'icons/'

        # the events that trigger the removal of a window
        self.REMOVE_EVENTS = (
            HSHELL_WINDOWDESTROYED,
            # placeholder
        )

        # the events that trigger an additional window
        self.ADD_EVENTS = (
            HSHELL_WINDOWCREATED,
            # placeholder
        )

        self.monitors = Monitor.display_monitors()
        if self.monitors is not None:
            self.stop = False
        else:
            self.stop = True

        self.notifyicon = NotifyIcon(name, self.icon)
        self.add_hotkeys_to_notifyicon()
        self.notifyicon.register_hotkeys()
        self.notifyicon.register_shellhook() 

        self.taskbar = Taskbar()
        self.taskbar.show()

        self.windows = dict()
示例#5
0
    def cmd_toggle_taskbar_visibility(self):
        
        self.taskbar.toggle_visibility()

        curmonitor = Monitor.current_monitor_from_list(self.monitors)
        curmonitor.recalc_tiler_dimensions()

        self.current_tiler.tile_windows()
    def cmd_toggle_taskbar_visibility(self):

        self.taskbar.toggle_visibility()

        curmonitor = Monitor.current_monitor_from_list(self.monitors)
        curmonitor.recalc_tiler_dimensions()

        self.current_tiler.tile_windows()
示例#7
0
 def cmd_move_to_next_monitor(self):
     window = Window.focused_window(self.windows)
     # if(window.validate()):
     monitor = Monitor.monitor_from_window_in_list(self.monitors, window)
     nextMonitor = Utility.next_item(self.monitors, monitor)
     if(monitor != nextMonitor):
         tiler = monitor.tilers[self.group]
         nextTiler = nextMonitor.tilers[self.group]
         tiler.remove_window(window)
         nextTiler.add_window(window)
         window.focus()
示例#8
0
 def cmd_move_to_previous_monitor(self):
     window = Window.focused_window(self.windows)
     # if(window.validate()):
     monitor = Monitor.monitor_from_window_in_list(self.monitors, window)
     previousMonitor = Utility.previous_item(self.monitors, monitor)
     if(monitor != previousMonitor):
         tiler = monitor.tilers[self.group]
         previousTiler = previousMonitor.tilers[self.group]
         tiler.remove_window(window)
         previousTiler.add_window(window)
         window.focus()
示例#9
0
    def cmd_focus_previous_monitor(self):

        monitor = Monitor.current_monitor_from_list(self.monitors) 

        previousMonitor = Utility.previous_item(self.monitors, monitor)

        if previousMonitor and previousMonitor.tilers[self.group].windows:

            window = previousMonitor.tilers[self.group].windows[0]

            if not window.focus():

                previousMonitor.tilers[self.group].remove_window(window)
示例#10
0
    def cmd_focus_next_monitor(self):

        monitor = Monitor.current_monitor_from_list(self.monitors) 

        nextMonitor = Utility.next_item(self.monitors, monitor)

        if nextMonitor and nextMonitor.tilers[self.group].windows:

            window = nextMonitor.tilers[self.group].windows[0]

            if not window.focus():

                nextMonitor.tilers[self.group].remove_window(window)
    def cmd_focus_next_monitor(self):

        monitor = Monitor.current_monitor_from_list(self.monitors)

        nextMonitor = Utility.next_item(self.monitors, monitor)

        if nextMonitor and nextMonitor.tilers[self.group].windows:

            window = nextMonitor.tilers[self.group].windows[0]

            if not window.focus():

                nextMonitor.tilers[self.group].remove_window(window)
    def cmd_focus_previous_monitor(self):

        monitor = Monitor.current_monitor_from_list(self.monitors)

        previousMonitor = Utility.previous_item(self.monitors, monitor)

        if previousMonitor and previousMonitor.tilers[self.group].windows:

            window = previousMonitor.tilers[self.group].windows[0]

            if not window.focus():

                previousMonitor.tilers[self.group].remove_window(window)
示例#13
0
    def start(self):
        'start the listeners with a safety try/finally to unregister keys and kill the icon'
        self.notifyicon.show_balloon('Go!', 'PWT')

        # Do an initial lookup of all the windows and tile accordingly
        for monitor in self.monitors:
            windows = Window.valid_windows_from_monitor(monitor)
            for window in windows:
                self.add_window(monitor.tilers[self.group], window)
            monitor.tilers[self.group].tile_windows()

        try:
            # message priming read
            message = self.notifyicon.windowmessage

            while message:
                if message[1][1] == WM_HOTKEY:
                    # if message is WM_HOTKEY
                    # execute the corresponding hotkeycmd using the id
                    self.notifyicon.hotkeys[message[1][2]-1].execute()
                elif message[1][2] in self.ADD_EVENTS:
                    # if lparam is an add event
                    window = Window(message[1][3])
                    self.add_window(self.current_tiler, window)
                elif message[1][2] in self.REMOVE_EVENTS:
                    #if lparam is a remove event
                    self.handle_remove_event(message[1][3], Monitor.monitor_from_point_in_list(
                        self.monitors, message[1][5]))
                if self.stop:
                    self.notifyicon.show_balloon('Stopping!', 'PWT')
                    break

                # Grab the next message from the message queue
                message = self.notifyicon.windowmessage
        except:
            logging.exception('Exception occurred')

        self.notifyicon.unregister_shellhook()  # Unregister shellhook
        self.notifyicon.unregister_hotkeys()    # Unregister hotkeys
        self.decorate_all_tiled_windows()   # Decorate windows
        self.taskbar.show()                 # make sure the taskbar is shown on exit
        self.notifyicon.destroy()           # Remove icon
示例#14
0
    def send_window_to_tiler(self, window, i):
        "sends window to tiler i"

        currentMonitor = Monitor.monitor_from_window_in_list(self.monitors, window)
        currentTiler = currentMonitor.tilers[self.group] 
        targetTiler = currentMonitor.tilers[i] 

        #hide the window
        if window.validate():

            window.hide()

            #Remove window if it's in the tiler
            if window in currentTiler.windows:

                currentTiler.windows.remove(window)
                currentTiler.tile_windows()

            #Add window if it's not already in the target tiler
            if window not in targetTiler.windows:

                targetTiler.windows.append(window)
示例#15
0
    def cmd_shift_to_previous_monitor(self):

        window = Window.focused_window()

        if window.validate():

            monitor = Monitor.monitor_from_window_in_list(self.monitors, window) 
            previousMonitor = Utility.previous_item(self.monitors, monitor)

            if previousMonitor:
                
                tiler = monitor.tilers[self.group]
                previousTiler = previousMonitor.tilers[self.group]

                if window in tiler.windows:

                    tiler.remove_window(window)

                if window not in previousTiler.windows:

                    previousTiler.add_window(window)

                window.focus()
    def send_window_to_tiler(self, window, i):
        "sends window to tiler i"

        currentMonitor = Monitor.monitor_from_window_in_list(
            self.monitors, window)
        currentTiler = currentMonitor.tilers[self.group]
        targetTiler = currentMonitor.tilers[i]

        #hide the window
        if window.validate():

            window.hide()

            #Remove window if it's in the tiler
            if window in currentTiler.windows:

                currentTiler.windows.remove(window)
                currentTiler.tile_windows()

            #Add window if it's not already in the target tiler
            if window not in targetTiler.windows:

                targetTiler.windows.append(window)
示例#17
0
    def send_window_to_tiler(self, window, i):
        '''
        sends window to tiler i
        '''
        currentMonitor = Monitor.monitor_from_window_in_list(self.monitors, window)
        currentTiler = window.container.container.container
        targetTiler = currentMonitor.tilers[i]
        if(targetTiler != currentTiler):
            currentTiler.remove_window(window)
            if(targetTiler.currentLayout.has_window(window)):
                logging.error('Window "%s" already in destination tiler', window.get_name())
            else:
                targetTiler.currentLayout.add_window(window)
            window.hide()   # hide the window from current tiler
            currentTiler.tile_windows()

            curr_window = currentTiler.get_current_window()
            if(curr_window != None):
                curr_window.focus()
            else:
                # other windows should lose focus
                # self.notifyicon.focus()
                self.taskbar.taskbar.focus()
示例#18
0
    def cmd_shift_to_next_monitor(self):

        window = Window.focused_window()

        if window.validate():

            monitor = Monitor.monitor_from_window_in_list(self.monitors, window) 
            nextMonitor = Utility.next_item(self.monitors, monitor)

            if nextMonitor:
                
                tiler = monitor.tilers[self.group]
                nextTiler = nextMonitor.tilers[self.group]

                if window in tiler.windows:

                    tiler.remove_window(window)

                if window not in nextTiler.windows:

                    nextTiler.add_window(window)

                window.focus()
    def __init__(self, name):
        """
        Set up the notifyicon and the monitors
        """

        self.group = 0

        self.ICONFOLDER = "icons/"

        #the events that trigger the removal of a window
        self.REMOVE_EVENTS = (
            HSHELL_WINDOWDESTROYED,  #placeholder
        )

        #the events that trigger an additional window
        self.ADD_EVENTS = (
            HSHELL_WINDOWCREATED,  #placeholder
        )

        self.notifyicon = NotifyIcon(name, self.icon)

        self.add_hotkeys_to_notifyicon()
        self.notifyicon.register_hotkeys()

        self.notifyicon.register_shellhook()

        self.taskbar = Taskbar()

        self.monitors = Monitor.display_monitors()

        if self.monitors is not None:

            self.stop = False

        else:

            self.stop = True
    def cmd_shift_to_previous_monitor(self):

        window = Window.focused_window()

        if window.validate():

            monitor = Monitor.monitor_from_window_in_list(
                self.monitors, window)
            previousMonitor = Utility.previous_item(self.monitors, monitor)

            if previousMonitor:

                tiler = monitor.tilers[self.group]
                previousTiler = previousMonitor.tilers[self.group]

                if window in tiler.windows:

                    tiler.remove_window(window)

                if window not in previousTiler.windows:

                    previousTiler.add_window(window)

                window.focus()
    def cmd_shift_to_next_monitor(self):

        window = Window.focused_window()

        if window.validate():

            monitor = Monitor.monitor_from_window_in_list(
                self.monitors, window)
            nextMonitor = Utility.next_item(self.monitors, monitor)

            if nextMonitor:

                tiler = monitor.tilers[self.group]
                nextTiler = nextMonitor.tilers[self.group]

                if window in tiler.windows:

                    tiler.remove_window(window)

                if window not in nextTiler.windows:

                    nextTiler.add_window(window)

                window.focus()
示例#22
0
    def start(self):
        "start the listeners with a safety try/finally to unregister keys and kill the icon"

        self.notifyicon.show_balloon("Go!", "PWT")

        #Do an initial lookup of all the windows and tile accordingly
        for monitor in self.monitors:

            monitor.tilers[self.group].windows = Window.valid_windows_from_monitor(monitor)
            monitor.tilers[self.group].tile_windows()

        try:

            #message priming read
            message = self.notifyicon.windowmessage

            while message:

                #if message is WM_HOTKEY
                if message[1][1] == WM_HOTKEY:

                    #execute the corresponding hotkeycmd using the id
                    self.notifyicon.hotkeys[message[1][2] - 1].execute()

                #if lparam is an add event
                elif message[1][2] in self.ADD_EVENTS:
                    
                    window = Window(message[1][3])

                    if window not in self.current_group_windows:
                        
                        self.current_tiler.add_window(window)
                    
                #if lparam is a remove event
                elif message[1][2] in self.REMOVE_EVENTS:

                    self.handle_remove_event(Window(message[1][3])
                            , Monitor.monitor_from_point_in_list(self.monitors, message[1][5]))

                if self.stop:

                    self.notifyicon.show_balloon("Stop!", "PWT")
                    break

                #Grab the next message from the message queue
                message = self.notifyicon.windowmessage

        finally:

            #Unregister hotkeys and shellhook
            self.notifyicon.unregister_shellhook()
            self.notifyicon.unregister_hotkeys()

            #Decorate windows
            self.decorate_all_tiledwindows()

            #make sure the taskbar is shown on exit
            self.taskbar.show()

            #Remove icon
            self.notifyicon.destroy()
    def current_tiler(self):
        "Returns the current tiler"

        return Monitor.current_monitor_from_list(
            self.monitors).tilers[self.group]
示例#24
0
 def current_tiler(self):
     "Returns the current tiler"
     
     return Monitor.current_monitor_from_list(self.monitors).tilers[self.group]
    def start(self):
        "start the listeners with a safety try/finally to unregister keys and kill the icon"

        self.notifyicon.show_balloon("Go!", "PWT")

        #Do an initial lookup of all the windows and tile accordingly
        for monitor in self.monitors:

            monitor.tilers[
                self.group].windows = Window.valid_windows_from_monitor(
                    monitor)
            monitor.tilers[self.group].tile_windows()

        try:

            #message priming read
            message = self.notifyicon.windowmessage

            while message:

                #if message is WM_HOTKEY
                if message[1][1] == WM_HOTKEY:

                    #execute the corresponding hotkeycmd using the id
                    self.notifyicon.hotkeys[message[1][2] - 1].execute()

                #if lparam is an add event
                elif message[1][2] in self.ADD_EVENTS:

                    window = Window(message[1][3])

                    if window not in self.current_group_windows:

                        self.current_tiler.add_window(window)

                #if lparam is a remove event
                elif message[1][2] in self.REMOVE_EVENTS:

                    self.handle_remove_event(
                        Window(message[1][3]),
                        Monitor.monitor_from_point_in_list(
                            self.monitors, message[1][5]))

                if self.stop:

                    self.notifyicon.show_balloon("Stop!", "PWT")
                    break

                #Grab the next message from the message queue
                message = self.notifyicon.windowmessage

        finally:

            #Unregister hotkeys and shellhook
            self.notifyicon.unregister_shellhook()
            self.notifyicon.unregister_hotkeys()

            #Decorate windows
            self.decorate_all_tiledwindows()

            #make sure the taskbar is shown on exit
            self.taskbar.show()

            #Remove icon
            self.notifyicon.destroy()