-import ob, otk
+import ob, otk, config
class _Cycle:
"""
This is a basic cycling class for anything, from xOr's stackedcycle.py,
# show or hide the list and its child widgets
if len(self.items) > 1:
- size = self.screeninfo.size()
+ size = self.screen.size()
self.widget.moveresize(otk.Rect((size.width() - width) / 2,
(size.height() - height) / 2,
width, height))
preferably caching it. Data is what's given to callback functions.
"""
self.screen = ob.openbox.screen(data.screen)
- self.screeninfo = otk.display.screenInfo(data.screen)
def chooseStartPos(self):
"""Set self.menupos to a number between 0 and len(self.items) - 1.
def next(self, data):
"""Focus the next window."""
- if not data.state:
- raise RuntimeError("next must be bound to a key" +
- "combination with at least one modifier")
self.cycle(data, 1)
def previous(self, data):
"""Focus the previous window."""
- if not data.state:
- raise RuntimeError("previous must be bound to a key" +
- "combination with at least one modifier")
self.cycle(data, 0)
#---------------------- Window Cycling --------------------
"""
This is a basic cycling class for Windows.
- An example of inheriting from and modifying this class is _ClassCycleWindows,
- which allows users to cycle around windows of a certain application
- name/class only.
+ An example of inheriting from and modifying this class is
+ _ClassCycleWindows, which allows users to cycle around windows of a certain
+ application name/class only.
This class has an underscored name because I use the singleton pattern
(so CycleWindows is an actual instance of this class). This doesn't have
if not client.normal(): return 0
if not (client.canFocus() or client.focusNotify()): return 0
- if focus.AVOID_SKIP_TASKBAR and client.skipTaskbar(): return 0
+ if config.get('focus', 'avoid_skip_taskbar') and client.skipTaskbar():
+ return 0
if client.iconic():
if self.INCLUDE_ICONS:
if self.INCLUDE_ALL_DESKTOPS:
d = client.desktop()
if d == 0xffffffff: d = self.screen.desktop()
- t = self.screen.desktopName(d) + " - " + t
+ t = self.screen.desktopNames()[d] + " - " + t
return t
# move the to client's desktop if required
if not (client.iconic() or client.desktop() == 0xffffffff or \
client.desktop() == self.screen.desktop()):
- root = self.screeninfo.rootWindow()
- ob.send_client_msg(root, otk.atoms.net_current_desktop,
- root, client.desktop())
+ self.screen.changeDesktop(client.desktop())
# send a net_active_window message for the target
if final or not client.iconic():
if final: r = self.RAISE_WINDOW
else: r = 0
- ob.send_client_msg(self.screeninfo.rootWindow(),
- otk.atoms.openbox_active_window,
- client.window(), final, r)
+ client.focus(final, r)
if not final:
focus._skip += 1
if not client.normal(): return 0
if not (client.canFocus() or client.focusNotify()): return 0
- if focus.AVOID_SKIP_TASKBAR and client.skipTaskbar(): return 0
+ if config.get('focus', 'avoid_skip_taskbar') and client.skipTaskbar():
+ return 0
if client.iconic(): return 0
if self.INCLUDE_OMNIPRESENT and desk == 0xffffffff: return 1
def populateItems(self):
# get the list of clients, keeping iconic windows at the bottom
iconic_clients = []
- for i in range(self.screen.clientCount()):
- c = self.screen.client(i)
+ for c in self.screen.clients:
if self.shouldAdd(c):
self.items.append(c)
if self.INCLUDE_ALL_DESKTOPS:
d = client.desktop()
if d == 0xffffffff: d = self.screen.desktop()
- t = self.screen.desktopName(d) + " - " + t
+ t = self.screen.desktopNames()[d] + " - " + t
return t
def __eq__(self, other):
return other.index == self.index
- START_WITH_NEXT = 0
-
def __init__(self):
_Cycle.__init__(self)
def populateItems(self):
- for i in range(self.screen.numDesktops()):
- self.items.append(
- _CycleDesktops.Desktop(self.screen.desktopName(i), i))
+ names = self.screen.desktopNames()
+ num = self.screen.numDesktops()
+ for n, i in zip(names[:num], range(num)):
+ self.items.append(_CycleDesktops.Desktop(n, i))
def menuLabel(self, desktop):
return desktop.name
desktop = self.items[self.menupos]
except IndexError: return
- root = self.screeninfo.rootWindow()
- ob.send_client_msg(root, otk.atoms.net_current_desktop,
- root, desktop.index)
+ self.screen.changeDesktop(desktop.index)
CycleDesktops = _CycleDesktops()