Example #1
0
    def __init__(self, wid):
        self.wid = wid
        self.gdk = gtk.gdk.window_foreign_new_for_display(state.gtk_display, 
                                                          self.wid)
        self.name = ewmh.get_wm_name(self.wid).reply()
        self.geom = self.get_geometry()
        self.desk = ewmh.get_wm_desktop(self.wid).reply()
        self.invis = gtk.Invisible()

        self.gdk.set_events(gtk.gdk.PROPERTY_CHANGE_MASK
                            | gtk.gdk.STRUCTURE_MASK)
        self.gdk.set_user_data(self.invis)
        self.invis.connect('property_notify_event', self.cb_prop_change)

        # This is interesting; look for configure events on the decor window
        if state.wmname.lower() == 'openbox':
            pid = window.get_parent_window(self.wid)
            pgdk = gtk.gdk.window_foreign_new_for_display(state.gtk_display,
                                                          pid)
            pinvis = gtk.Invisible()
            pgdk.set_events(gtk.gdk.STRUCTURE_MASK)
            pgdk.set_user_data(pinvis)
            pinvis.connect('configure_event', self.cb_configure)
        else:
            self.invis.connect('configure_event', self.cb_configure)

        self.update_state()
Example #2
0
    def __init__(self, wid):
        self.wid = wid
        self.gdk = gtk.gdk.window_foreign_new_for_display(
            state.gtk_display, self.wid)
        self.name = ewmh.get_wm_name(self.wid).reply()
        self.geom = self.get_geometry()
        self.desk = ewmh.get_wm_desktop(self.wid).reply()
        self.invis = gtk.Invisible()

        self.gdk.set_events(gtk.gdk.PROPERTY_CHANGE_MASK
                            | gtk.gdk.STRUCTURE_MASK)
        self.gdk.set_user_data(self.invis)
        self.invis.connect('property_notify_event', self.cb_prop_change)

        # This is interesting; look for configure events on the decor window
        if state.wmname.lower() == 'openbox':
            pid = window.get_parent_window(self.wid)
            pgdk = gtk.gdk.window_foreign_new_for_display(
                state.gtk_display, pid)
            pinvis = gtk.Invisible()
            pgdk.set_events(gtk.gdk.STRUCTURE_MASK)
            pgdk.set_user_data(pinvis)
            pinvis.connect('configure_event', self.cb_configure)
        else:
            self.invis.connect('configure_event', self.cb_configure)

        self.update_state()
Example #3
0
def windows(result_fun, prefix_complete=False, homogenous=False, 
            current_desk=False):
    global currentPrompt

    desks = range(0, ewmh.get_number_of_desktops().reply())
    names = ewmh.get_desktop_names().reply()

    content = {}
    for d in desks:
        if current_desk and state.desktop != d:
            continue

        name = d
        if d < len(names):
            name = names[d]

        content[name] = []

    clients = ewmh.get_client_list_stacking().reply()
    for c in reversed(clients):
        nm = ewmh.get_wm_desktop(c).reply()
        if nm < len(names):
            nm = names[nm]
        if nm in content:
            wm_name = ewmh.get_wm_name(c).reply()
            if not wm_name:
                wm_name = icccm.get_wm_name(c).reply()
            if not wm_name or not isinstance(wm_name, basestring):
                wm_name = 'N/A'
            content[nm].append((wm_name, c))

    currentPrompt = Prompt(content, result_fun, prefix_complete, homogenous)
Example #4
0
    def __init__(self, wid):
        self.wid = wid

        self.name = ewmh.get_wm_name(self.wid).reply() or 'N/A'
        debug('Connecting to %s' % self)

        window.listen(self.wid, 'PropertyChange', 'FocusChange')
        event.connect('PropertyNotify', self.wid, self.cb_property_notify)
        event.connect('FocusIn', self.wid, self.cb_focus_in)
        event.connect('FocusOut', self.wid, self.cb_focus_out)

        # This connects to the parent window (decorations)
        # We get all resize AND move events... might be too much
        self.parentid = window.get_parent_window(self.wid)
        window.listen(self.parentid, 'StructureNotify')
        event.connect('ConfigureNotify', self.parentid, 
                      self.cb_configure_notify)

        # A window should only be floating if that is default
        self.floating = config.floats_default

        # Not currently in a "moving" state
        self.moving = False

        # Load some data
        self.desk = ewmh.get_wm_desktop(self.wid).reply()

        # Add it to this desktop's tilers
        tile.update_client_add(self)

        # First cut at saving client geometry
        self.save()
Example #5
0
    def __init__(self, wid):
        self.wid = wid

        self.name = ewmh.get_wm_name(self.wid).reply() or "N/A"
        debug("Connecting to %s" % self)

        window.listen(self.wid, "PropertyChange", "FocusChange")
        event.connect("PropertyNotify", self.wid, self.cb_property_notify)
        event.connect("FocusIn", self.wid, self.cb_focus_in)
        event.connect("FocusOut", self.wid, self.cb_focus_out)

        # This connects to the parent window (decorations)
        # We get all resize AND move events... might be too much
        self.parentid = window.get_parent_window(self.wid)
        window.listen(self.parentid, "StructureNotify")
        event.connect("ConfigureNotify", self.parentid, self.cb_configure_notify)
        debug("Parent: %s" % str(self.parentid))
        # A window should only be floating if that is default
        self.floating = getattr(config, "floats_default", False)

        # Not currently in a "moving" state
        self.moving = False

        # Load some data
        self.desk = ewmh.get_wm_desktop(self.wid).reply()
        debug("Desk: %s" % str(self.desk))

        # Add it to this desktop's tilers
        ret = tile.update_client_add(self)
        # does this work?
        debug("Ret: %s" % str(ret))

        # First cut at saving client geometry
        self.save()
        debug("Init finished and save() called %s" % self)
Example #6
0
    def __init__(self, wid):
        GeometryWindow.__init__(self, wid)

        self._properties = core.ListProperties(self.id)
        self._protocols = icccm.get_wm_protocols(conn, self.id)
        self._hints = icccm.get_wm_hints(conn, self.id)
        self._normal_hints = icccm.get_wm_normal_hints(conn, self.id)
        self._class = icccm.get_wm_class(conn, self.id)
        self._motif = motif.get_hints(conn, self.id)
        self._wmname = ewmh.get_wm_name(conn, self.id)
        self._wmclass = icccm.get_wm_class(conn, self.id)
def goto_window(win_name_or_id):
    wid = win_name_or_id
    if isinstance(wid, basestring):
        clients = ewmh.get_client_list().reply()
        for c in clients:
            if wid == ewmh.get_wm_name(c).reply():
                wid = c
                break

    if isinstance(wid, int):
        wdesk = ewmh.get_wm_desktop(wid).reply()
        if wdesk not in ewmh.get_visible_desktops().reply():
            ewmh.request_current_desktop_checked(wdesk).check()
        ewmh.request_active_window_checked(wid, source=2).check()
def goto_window(win_name_or_id):
    wid = win_name_or_id
    if isinstance(wid, basestring):
        clients = ewmh.get_client_list().reply()
        for c in clients:
            if wid == ewmh.get_wm_name(c).reply():
                wid = c
                break

    if isinstance(wid, int):
        wdesk = ewmh.get_wm_desktop(wid).reply()
        if wdesk not in ewmh.get_visible_desktops().reply():
            ewmh.request_current_desktop_checked(wdesk).check()
        ewmh.request_active_window_checked(wid, source=2).check()
Example #9
0
	def get_window_manager(self):
		utilwm = window.WindowManagers.Unknown
		w = ewmh.get_supporting_wm_check(xpybutil.root).reply()
		if w:
			childw = ewmh.get_supporting_wm_check(w).reply()
			if childw == w:
				wm = ewmh.get_wm_name(childw).reply()
				if wm.lower() == 'openbox':
						utilwm = window.WindowManagers.Openbox
				elif wm.lower() == 'kwin':
						utilwm = window.WindowManagers.KWin

				logging.info( '%s window manager is running...' % wm )
		
		return utilwm
Example #10
0
def cli():
    ARGS = sys.argv[1:]
    bus = SessionBus()
    rofi_bus = bus.get('pro.wizardsoftheweb.pyrofibus')

    if ARGS and ARGS[0]:
        rofi_bus.ActivateWindow(int(ARGS[0].split(' ')[-1]))
        exit(0)

    window_ids = rofi_bus.GetWindowList()
    desktops = get_desktop_names().reply()
    items = []
    max_desktop = 0
    max_class = 0
    max_name = 0
    for window_id in window_ids:
        new_item = [
            desktops[get_wm_desktop(window_id).reply()],
            get_property(
                window_id,
                'WM_CLASS').reply().value.to_string().split('\x00')[1],
            get_wm_name(window_id).reply().encode('utf-8'),
            window_id,
        ]
        max_desktop = len(
            new_item[0]) if len(new_item[0]) > max_desktop else max_desktop
        max_class = len(
            new_item[1]) if len(new_item[1]) > max_class else max_class
        max_name = len(
            new_item[2]) if len(new_item[2]) > max_name else max_name
        items.append(new_item)
    items.append(items.pop(0))

    for item in items:
        print("{:{max_desktop}} {:{max_class}} {:{max_name}} {}".format(
            *item,
            max_desktop=max_desktop + 2,
            max_class=max_class + 2,
            max_name=max_name))
Example #11
0
    def update_title(self, atom):
        """
        Updates the 'wmname' attribute of a window object. Prefers EWMH and
        falls back to ICCCM if necessary. If no name can be found, use an empty
        string.
        """
        assert atom in ('_NET_WM_NAME', 'WM_NAME')

        # If the window has a _NET_WM_NAME property, ignore WM_NAME
        if atom == 'WM_NAME' and aid('_NET_WM_NAME') in self.win.properties:
            return

        new_name = ''
        if atom == '_NET_WM_NAME':
            new_name = ewmh.get_wm_name(state.conn, self.win.id).reply()
        elif atom == 'WM_NAME':
            new_name = icccm.get_wm_name(state.conn, self.win.id).reply()

        # Don't update if it's the same...
        if new_name == self.win.wmname:
            return

        self.win.wmname = new_name
Example #12
0
def should_ignore(client):
    # Don't waste time on clients we'll never possibly tile
    if client in ignore:
        return True

    nm = ewmh.get_wm_name(client).reply()

    wm_class = icccm.get_wm_class(client).reply()
    if wm_class is not None:
        try:
            inst, cls = wm_class
            matchNames = set([inst.lower(), cls.lower()])

            if matchNames.intersection(config.ignore):
                debug('Ignoring %s because it is in the ignore list' % nm)
                return True

            if hasattr(config, 'tile_only') and config.tile_only:
              if not matchNames.intersection(config.tile_only):
                debug('Ignoring %s because it is not in the tile_only '
                      'list' % nm)
                return True
        except ValueError:
            pass

    if icccm.get_wm_transient_for(client).reply() is not None:
        debug('Ignoring %s because it is transient' % nm)
        ignore.append(client)
        return True

    wtype = ewmh.get_wm_window_type(client).reply()
    if wtype:
        for atom in wtype:
            aname = util.get_atom_name(atom)

            if aname in ('_NET_WM_WINDOW_TYPE_DESKTOP',
                         '_NET_WM_WINDOW_TYPE_DOCK',
                         '_NET_WM_WINDOW_TYPE_TOOLBAR',
                         '_NET_WM_WINDOW_TYPE_MENU',
                         '_NET_WM_WINDOW_TYPE_UTILITY',
                         '_NET_WM_WINDOW_TYPE_SPLASH',
                         '_NET_WM_WINDOW_TYPE_DIALOG',
                         '_NET_WM_WINDOW_TYPE_DROPDOWN_MENU',
                         '_NET_WM_WINDOW_TYPE_POPUP_MENU',
                         '_NET_WM_WINDOW_TYPE_TOOLTIP',
                         '_NET_WM_WINDOW_TYPE_NOTIFICATION',
                         '_NET_WM_WINDOW_TYPE_COMBO', 
                         '_NET_WM_WINDOW_TYPE_DND'):
                debug('Ignoring %s because it has type %s' % (nm, aname))
                ignore.append(client)
                return True

    wstate = ewmh.get_wm_state(client).reply()
    if wstate is None:
        debug('Ignoring %s because it does not have a state' % nm)
        return True

    for atom in wstate:
        aname = util.get_atom_name(atom)

        # For now, while I decide how to handle these guys
        if aname == '_NET_WM_STATE_STICKY':
            debug('Ignoring %s because it is sticky and they are weird' % nm)
            return True
        if aname in ('_NET_WM_STATE_SHADED', '_NET_WM_STATE_HIDDEN',
                     '_NET_WM_STATE_FULLSCREEN', '_NET_WM_STATE_MODAL'):
            debug('Ignoring %s because it has state %s' % (nm, aname))
            return True

    d = ewmh.get_wm_desktop(client).reply()
    if d == 0xffffffff:
        debug('Ignoring %s because it\'s on all desktops' \
              '(not implemented)' % nm)
        return True

    return False
Example #13
0
import config

PYTYLE_STATE = 'startup'
GRAB = None

_wmrunning = False

wm = 'N/A'
utilwm = window.WindowManagers.Unknown
while not _wmrunning:
    w = ewmh.get_supporting_wm_check(xpybutil.root).reply()
    if w:
        childw = ewmh.get_supporting_wm_check(w).reply()
        if childw == w:
            _wmrunning = True
            wm = ewmh.get_wm_name(childw).reply()
            if wm.lower() == 'openbox':
                utilwm = window.WindowManagers.Openbox
            elif wm.lower() == 'kwin':
                utilwm = window.WindowManagers.KWin

            print '%s window manager is running...' % wm
            sys.stdout.flush()

    if not _wmrunning:
        time.sleep(1)

root_geom = ewmh.get_desktop_geometry().reply()
monitors = xinerama.get_monitors()
phys_monitors = xinerama.get_physical_mapping(monitors)
desk_num = ewmh.get_number_of_desktops().reply()
Example #14
0
def name_change_handler() :
    active_name = ewmh.get_wm_name(active_window).reply()
    print active_window, active_name, ii.idle_msec()
 def get_rofi_window_title(window_id):
     return get_wm_name(window_id).reply().encode('utf-8')
Example #16
0
def should_ignore(client):
    debug("Entering should_ignore %s" % str(client))
    # debug_object(clients)
    # debug("This client: %s" % str(client))
    # Don't waste time on clients we'll never possibly tile
    if client in ignore:
        # debug("Ignoring client %s" % client)
        # debug("Ignore is:")
        # debug(ignore)
        return True

    nm = ewmh.get_wm_name(client).reply()

    wm_class = icccm.get_wm_class(client).reply()
    if wm_class is not None:
        try:
            inst, cls = wm_class
            matchNames = set([inst.lower(), cls.lower()])

            if matchNames.intersection(config.ignore):
                debug("Ignoring %s because it is in the ignore list" % nm)
                return True

            if hasattr(config, "tile_only") and config.tile_only:
                if not matchNames.intersection(config.tile_only):
                    debug("Ignoring %s because it is not in the tile_only " "list" % nm)
                debug("Ignoring client %s" % client)
                return True
        except ValueError:
            pass

    if icccm.get_wm_transient_for(client).reply() is not None:
        debug("Ignoring %s because it is transient" % nm)
        ignore.append(client)
        return True

    wtype = ewmh.get_wm_window_type(client).reply()
    if wtype:
        for atom in wtype:
            aname = util.get_atom_name(atom)

            if aname in (
                "_NET_WM_WINDOW_TYPE_DESKTOP",
                "_NET_WM_WINDOW_TYPE_DOCK",
                "_NET_WM_WINDOW_TYPE_TOOLBAR",
                "_NET_WM_WINDOW_TYPE_MENU",
                "_NET_WM_WINDOW_TYPE_UTILITY",
                "_NET_WM_WINDOW_TYPE_SPLASH",
                "_NET_WM_WINDOW_TYPE_DIALOG",
                "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU",
                "_NET_WM_WINDOW_TYPE_POPUP_MENU",
                "_NET_WM_WINDOW_TYPE_TOOLTIP",
                "_NET_WM_WINDOW_TYPE_NOTIFICATION",
                "_NET_WM_WINDOW_TYPE_COMBO",
                "_NET_WM_WINDOW_TYPE_DND",
            ):
                debug("Ignoring %s because it has type %s" % (nm, aname))
                ignore.append(client)
                return True

    wstate = ewmh.get_wm_state(client).reply()
    if wstate is None:
        debug("Ignoring %s because it does not have a state" % nm)
        return True

    for atom in wstate:
        aname = util.get_atom_name(atom)

        # For now, while I decide how to handle these guys
        if aname == "_NET_WM_STATE_STICKY":
            debug("Ignoring %s because it is sticky and they are weird" % nm)
            return True
        if aname in (
            "_NET_WM_STATE_SHADED",
            "_NET_WM_STATE_HIDDEN",
            "_NET_WM_STATE_FULLSCREEN",
            "_NET_WM_STATE_MODAL",
        ):
            debug("Ignoring %s because it has state %s" % (nm, aname))
            return True

    d = ewmh.get_wm_desktop(client).reply()
    if d == 0xFFFFFFFF:
        debug("Ignoring %s because it's on all desktops" "(not implemented)" % nm)
        return True

    debug("Not ignoring client %s" % client)
    return False