Changeset 138
- Timestamp:
- 02/13/08 16:57:28 (1 year ago)
- Files:
-
- trunk/conf/config-example.py (modified) (2 diffs)
- trunk/pycawm/__init__.py (modified) (1 diff)
- trunk/pycawm/client.py (modified) (4 diffs)
- trunk/pycawm/clientunderpointer.py (modified) (1 diff)
- trunk/pycawm/focuses.py (modified) (4 diffs)
- trunk/pycawm/screenshotunderpointer.py (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/conf/config-example.py
r137 r138 28 28 from pycawm import ClientUnderPointer 29 29 from pycawm import MoveUnderPointer 30 from pycawm import ScreenshotUnderPointer 30 31 from pycawm import PycaWM 31 32 from pycawm.button import (CloseButton, MiniIconButton, ShadeButton, … … 143 144 ('Move Window', Menu.python, 144 145 lambda: MoveUnderPointer(self)), 146 ('Take Window Screenshot', Menu.python, 147 lambda: ScreenshotUnderPointer(self)), 145 148 ('Close Window', Menu.python, 146 149 lambda: ClientUnderPointer(self, Client.close)), trunk/pycawm/__init__.py
r134 r138 23 23 from clientunderpointer import ClientUnderPointer 24 24 from moveunderpointer import MoveUnderPointer 25 from screenshotunderpointer import ScreenshotUnderPointer 25 26 from pycawm import PycaWM trunk/pycawm/client.py
r137 r138 26 26 27 27 from Xlib import X, Xutil, protocol, error 28 from Xlib.error import BadDrawable, BadWindow, BadMatch 28 from Xlib.error import BadDrawable, BadWindow, BadMatch, XError 29 29 from Xlib.X import ZPixmap 30 30 from Xlib.ext import shape … … 35 35 from patterns import Null, DictWrapper 36 36 37 38 AllPlanes = 4294967295L # from /usr/X11R6/include/Xlib.h 37 39 38 40 class PseudoParent(object): … … 993 995 height = value[1] 994 996 data = value[2:width*height+2].tostring() 995 data_rgb = ''996 for i in xrange(0, len(data), 4):997 data_rgb += data[i + 2] + data[i + 1] + data[i]998 997 image = Image.fromstring('RGB', (width, height), 999 data _rgb).resize(size, Image.ANTIALIAS)1000 return image 998 data, 'raw', 'BGRX') 999 return image.resize(size, Image.ANTIALIAS) 1001 1000 elif (self.wm_hints is not None and 1002 1001 self.wm_hints.flags & Xutil.IconPixmapHint): … … 1007 1006 data = self.wm_hints.icon_pixmap.get_image(0, 0, 1008 1007 geo.width, geo.height, 1009 ZPixmap, 4294967295).data1008 ZPixmap, AllPlanes).data 1010 1009 if len(data) != geo.width * geo.height * 4: 1011 1010 return None 1012 data_rgb = ''1013 for i in xrange(0, len(data), 4):1014 data_rgb += data[i + 2] + data[i + 1] + data[i]1015 1011 image = Image.fromstring('RGB', (geo.width, geo.height), 1016 data _rgb).resize(size, Image.ANTIALIAS)1017 return image 1012 data, 'raw', 'BGRX') 1013 return image.resize(size, Image.ANTIALIAS) 1018 1014 return None 1015 1016 def take_screenshot(self): 1017 geo = self.window.get_geometry() 1018 try: 1019 data = self.window.get_image(0, 0, geo.width, geo.height, 1020 ZPixmap, AllPlanes).data 1021 except XError: 1022 return None 1023 if len(data) != geo.width * geo.height * 4: 1024 return None 1025 screenshot = Image.fromstring('RGB', (geo.width, geo.height), 1026 data, 'raw', 'BGRX') 1027 return screenshot trunk/pycawm/clientunderpointer.py
r134 r138 22 22 if sys.version_info < (2, 5): 23 23 raise ImportError('clientunderpointer module needs at least Python 2.5!') 24 25 import time26 24 27 25 from Xlib import X trunk/pycawm/focuses.py
r134 r138 44 44 class ClickToFocus(Focus): 45 45 def init_focus(self, wm): 46 add_post_hook(Client.take_focus, Client.upper)46 add_post_hook(Client.take_focus, self.client_upper) 47 47 add_pre_hook(wm.button_press_reply, self.pre_button_press_reply) 48 48 self.init_focus_aux(wm) … … 57 57 for client in wm.clients: 58 58 client.grab_button() 59 60 @staticmethod 61 def client_upper(client, *args, **kwargs): 62 client.upper() 59 63 60 64 @staticmethod … … 81 85 def destroy_focus_aux(self, wm): 82 86 # this method will be reused in ClickToSloppyFocus 83 remove_pre_hook(wm.button_press_reply, self.pre_button_press_reply)84 87 remove_post_hook(Client.__init__, self.client_grab_button) 85 88 # a bit harsh, but it works... … … 88 91 89 92 def destroy_focus(self, wm): 90 remove_post_hook(Client.take_focus, Client.upper) 93 remove_post_hook(Client.take_focus, self.client_upper) 94 remove_pre_hook(wm.button_press_reply, self.pre_button_press_reply) 91 95 self.destroy_focus_aux(wm) 92 96
