Example #1
0
    def __init__(self, screen=None, ignore_workarea=False):
        # type: (gtk.gdk.Screen, bool) -> None
        """
        Initializes C{WindowManager}.

        @param screen: The X11 screen to operate on. If C{None}, the default
            screen as retrieved by C{gtk.gdk.screen_get_default} will be used.
        @type screen: C{gtk.gdk.Screen}

        @todo: Confirm that the root window only changes on X11 server
               restart. (Something which will crash QuickTile anyway since
               PyGTK makes X server disconnects uncatchable.)

               It could possibly change while toggling "allow desktop icons"
               in KDE 3.x. (Not sure what would be equivalent elsewhere)
        """
        self.gdk_screen = screen or gtk.gdk.screen_get_default()
        if self.gdk_screen is None:
            raise XInitError("GTK+ could not open a connection to the X server"
                             " (bad DISPLAY value?)")

        # pylint: disable=no-member
        self.screen = wnck.screen_get(self.gdk_screen.get_number())
        self.workarea = WorkArea(self.gdk_screen,
                                 ignore_struts=ignore_workarea)
Example #2
0
    def __init__(self, screen=None, ignore_workarea=False):
        # type: (gtk.gdk.Screen, bool) -> None
        """
        Initializes C{WindowManager}.

        @param screen: The X11 screen to operate on. If C{None}, the default
            screen as retrieved by C{gtk.gdk.screen_get_default} will be used.
        @type screen: C{gtk.gdk.Screen}

        @todo: Confirm that the root window only changes on X11 server
               restart. (Something which will crash QuickTile anyway since
               PyGTK makes X server disconnects uncatchable.)

               It could possibly change while toggling "allow desktop icons"
               in KDE 3.x. (Not sure what would be equivalent elsewhere)
        """
        self.gdk_screen = screen or gtk.gdk.screen_get_default()
        if self.gdk_screen is None:
            raise XInitError("GTK+ could not open a connection to the X server"
                             " (bad DISPLAY value?)")

        # pylint: disable=no-member
        self.screen = wnck.screen_get(self.gdk_screen.get_number())
        self.workarea = WorkArea(self.gdk_screen,
                                 ignore_struts=ignore_workarea)
Example #3
0
    def do_open(self):
        screen = wnck.screen_get(0)
        opened_one = False

        app_wins = self.app_group.get_windows()
        active_ws = screen.get_active_workspace()

        # Sorted by stacking order
        visible_wins = [
            win for win in screen.get_windows_stacked()
            if win in app_wins and win.is_on_workspace(active_ws)
        ]
        if not visible_wins and self.item:
            self.item.open()
            return

        if screen.get_active_window() in visible_wins:
            # Already active
            if len(visible_wins) > 1:
                # This group has the active win, so cycle the topmost active window down
                print " *** Raising window: ", visible_wins[0].get_name()
                visible_wins[0].activate(gtk.get_current_event_time())
            return
        else:
            # Not currently active, so raise them all
            for win in visible_wins:
                win.activate(gtk.get_current_event_time())
            return

        raise Exception(
            "No application windows on this desktop, and no Item to launch")
Example #4
0
def find_active_win_dbg(screen_no):
    wl = wnck.screen_get(screen_no).get_windows_stacked()
    for w in range(len(wl)-1,0,-1):
        if (wl[w].is_active()):
            print "%s - Active"%(wl[w].get_name())
        else:
            print wl[w].get_name()
Example #5
0
    def __init__(self, name):
        ItemSource.__init__(self, name=name)

        self.screen = wnck.screen_get(0)
        self.timeout_id = None

        self.screen.connect("window-opened",
                            lambda x, y: self.queue_reload_maybe(y))
        self.screen.connect("window-closed",
                            lambda x, y: self.queue_reload_maybe(y))
        self.screen.connect("application-opened", self.queue_reload)
        self.screen.connect("application-closed", self.queue_reload)
        self.screen.connect("active-workspace-changed", self.queue_reload)

        bookmarks.connect("reload", lambda x: self.emit("reload"))
Example #6
0
def runScript(delay, SCRIPT_PATH, SCRIPT_NAME):
    screen = wnck.screen_get(0)
    #screen = wnck.screen_get_default()

    while gtk.events_pending():
        gtk.main_iteration()

    windowTitle = re.compile('.*Board.*')

    for window in screen.get_windows():
        if windowTitle.match(window.get_name()):
            window.activate(int(time.time()))
            window.maximize()

    #MOUSE CLICK TO ACTUALLY FOCUS EAGLE BOARD
    m = PyMouse()
    x, y = m.screen_size()
    #m.click(x/4, y/4, 1)

    #KEYBOARD INPUT
    k = PyKeyboard()

    caps_flag = 0
    if int(commands.getoutput('xset q | grep LED')[65]) % 2:
        k.tap_key(k.caps_lock_key)
        caps_flag = 1

    #BRING UP ALT-FILE MENU
    k.press_key(k.alt_key)
    k.type_string('f')
    k.release_key(k.alt_key)

    #PRESS T TO RUN SCRIPT FROM ALT-FILE MENUs
    k.type_string('t')

    time.sleep(delay)

    #TYPE IN SCRIPT NAME TO DIALOG BOX
    k.type_string(SCRIPT_PATH + SCRIPT_NAME)

    time.sleep(delay)
    time.sleep(delay)

    k.tap_key(k.enter_key)

    if caps_flag:
        k.tap_key(k.caps_lock_key)
Example #7
0
    def __init__(self, screen=None, ignore_workarea=False):
        """
        Initializes C{WindowManager}.

        @param screen: The X11 screen to operate on. If C{None}, the default
            screen as retrieved by C{gtk.gdk.screen_get_default} will be used.
        @type screen: C{gtk.gdk.Screen}

        @todo: Confirm that the root window only changes on X11 server
               restart. (Something which will crash QuickTile anyway since
               PyGTK makes X server disconnects uncatchable.)

               It could possibly change while toggling "allow desktop icons"
               in KDE 3.x. (Not sure what would be equivalent elsewhere)
        """
        self.gdk_screen = screen or gtk.gdk.screen_get_default()
        self.screen = wnck.screen_get(self.gdk_screen.get_number())
        self.ignore_workarea = ignore_workarea
Example #8
0
    def __init__(self, screen=None, ignore_workarea=False):
        """
        Initializes C{WindowManager}.

        @param screen: The X11 screen to operate on. If C{None}, the default
            screen as retrieved by C{gtk.gdk.screen_get_default} will be used.
        @type screen: C{gtk.gdk.Screen}

        @todo: Confirm that the root window only changes on X11 server
               restart. (Something which will crash QuickTile anyway since
               PyGTK makes X server disconnects uncatchable.)

               It could possibly change while toggling "allow desktop icons"
               in KDE 3.x. (Not sure what would be equivalent elsewhere)
        """
        self.gdk_screen = screen or gtk.gdk.screen_get_default()
        self.screen = wnck.screen_get(self.gdk_screen.get_number())
        self.ignore_workarea = ignore_workarea
Example #9
0
def get_wnck_screen(index):
    '''
    get the index screen
    @param index: the index of screen
    '''
    global WNCK_SCREEN
    screen = wnck.screen_get(index)
    if screen:
        WNCK_SCREEN = screen
        WNCK_SCREEN.force_update()

        global WNCK_WORKSPACE
        global SCREEN_WIDTH
        global SCREEN_HEIGHT
        WNCK_WORKSPACE = WNCK_SCREEN.get_active_workspace()
        SCREEN_WIDTH = WNCK_SCREEN.get_width()
        SCREEN_HEIGHT = WNCK_SCREEN.get_height()
    if index >= SCREEN_NUM:
        return
    global GDK_SCREEN
    GDK_SCREEN = DISPLAY.get_screen(index)
Example #10
0
def get_wnck_screen(index):
    '''
    get the index screen
    @param index: the index of screen
    '''
    global WNCK_SCREEN
    screen = wnck.screen_get(index)
    if screen:
        WNCK_SCREEN = screen
        WNCK_SCREEN.force_update()
        
        global WNCK_WORKSPACE
        global SCREEN_WIDTH
        global SCREEN_HEIGHT
        WNCK_WORKSPACE = WNCK_SCREEN.get_active_workspace()
        SCREEN_WIDTH = WNCK_SCREEN.get_width()
        SCREEN_HEIGHT = WNCK_SCREEN.get_height()
    if index >= SCREEN_NUM:
        return
    global GDK_SCREEN
    GDK_SCREEN = DISPLAY.get_screen(index)
Example #11
0
def find_global_active():
    """
    return: current screen
    catch: each screen might have one active window. so if there's 2, use default screen.
    """
    count = 0
    s = None
    for i in range(0,MAX_SCREEN_NUM,1):
        screen = wnck.screen_get(i)
        if screen == None:
            continue
        screen.force_update()

        active_win = screen.get_active_window()
        if active_win is not None:
            s = screen
            count += 1
    if count == 1:
        return s
    elif count > 1:
        return wnck.screen_get_default()
    return None
Example #12
0
def focus_away(direction):
    cur_screen = pengliu_wm_utils.find_global_active()
    while gtk.events_pending():
        gtk.main_iteration(False)
        
    active_win = pengliu_wm_utils.find_active_win(cur_screen)
    xp,yp,wp,hp = active_win.get_geometry()
    display = xp / SCREENSIZE
    
    cur_num = cur_screen.get_number()    
    destdisplay = display
    destscreen = cur_num
    destdisplay += direction
    if destdisplay >= DISPLAYONSCREEN[cur_num]:
        destscreen += 1
        if destscreen >= NUMSCREEN:
            return
        else:
            destdisplay = 0
    elif destdisplay < 0:
        destscreen -= 1
        if destscreen < 0:
            return
        else:
            destdisplay = DISPLAYONSCREEN[destscreen] - 1
            
    if destdisplay == display and destscreen == cur_screen:
        return

    minx = SCREENSIZE * destdisplay
    maxx = minx + SCREENSIZE
    
    dest = wnck.screen_get(destscreen);
    while gtk.events_pending():
        gtk.main_iteration(False)

    top = pengliu_wm_utils.find_top_win_on_screen_within(dest, minx, maxx)
    if top is not None:
        top.activate(0)
def runScript(delay, SCRIPT_NAME):
    #screen = wnck.screen_get_default()
    screen = wnck.screen_get(0)

    while gtk.events_pending():
        gtk.main_iteration()

    windowTitle = re.compile('.*Board.*')
    
    for window in screen.get_windows():
        if windowTitle.match(window.get_name()):
            window.activate(int(time.time()))
            window.maximize()
    
    #MOUSE CLICK TO ACTUALLY FOCUS EAGLE BOARD
    m = PyMouse()
    x, y = m.screen_size()
    #m.click(x/4, y/4, 1)
    
    #KEYBOARD INPUT
    k = PyKeyboard()
    
    #BRING UP ALT-FILE MENU
    k.press_key(k.alt_key)
    k.type_string('f')
    k.release_key(k.alt_key)
    
    #PRESS T TO RUN SCRIPT FROM ALT-FILE MENU
    k.type_string('t')
    
    time.sleep(delay)
    
    #TYPE IN SCRIPT NAME TO DIALOG BOX
    k.type_string('/home/anton/Documents/st/st-py/' + SCRIPT_NAME)
    
    time.sleep(delay)
    time.sleep(delay)
    
    k.tap_key(k.enter_key)
Example #14
0
    def __init__(self):

        self.screen = wnck.screen_get(0)

        self.screen.connect('window-opened', self.window_opened)
        self.screen.connect('window-closed', self.window_closed)
Example #15
0
 def do_clicked(self):
     screen = wnck.screen_get(0)
     screen.toggle_showing_desktop(not screen.get_showing_desktop())