X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=scripts%2Fcycle.py;h=f77f3d8ad40bb44a397b5db1a122c880fc246597;hb=216a04bdd057c03a719a0908cd003503b4f73fdb;hp=3a2ff57bfba52a0c169157ef1f7e0919cc7caec1;hpb=5fc7db1c16783530a95382e61cfcb46d2480142c;p=chaz%2Fopenbox diff --git a/scripts/cycle.py b/scripts/cycle.py index 3a2ff57b..f77f3d8a 100644 --- a/scripts/cycle.py +++ b/scripts/cycle.py @@ -1,4 +1,4 @@ -import ob, otk +import ob, otk, config class _Cycle: """ This is a basic cycling class for anything, from xOr's stackedcycle.py, @@ -127,7 +127,7 @@ class _Cycle: # 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)) @@ -145,7 +145,6 @@ class _Cycle: 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. @@ -242,9 +241,9 @@ class _CycleWindows(_Cycle): """ 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 @@ -299,7 +298,8 @@ class _CycleWindows(_Cycle): 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: @@ -328,7 +328,7 @@ class _CycleWindows(_Cycle): 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 @@ -346,17 +346,13 @@ class _CycleWindows(_Cycle): # 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 @@ -395,7 +391,8 @@ class _CycleWindowsLinear(_CycleWindows): 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 @@ -425,7 +422,7 @@ class _CycleWindowsLinear(_CycleWindows): 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 @@ -452,9 +449,10 @@ class _CycleDesktops(_Cycle): _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 @@ -468,9 +466,7 @@ class _CycleDesktops(_Cycle): 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()