Changeset 196
- Timestamp:
- 02/25/2008 11:19:36 AM (11 months ago)
- Location:
- trunk
- Files:
-
- 2 modified
-
examples/plpwm.py (modified) (9 diffs)
-
plwm/panes.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/plpwm.py
r195 r196 1 1 #!/usr/bin/env python 2 # $Id: plpwm.py,v 1.4 4 2007-07-14 09:19:34mwm Exp $2 # $Id: plpwm.py,v 1.45 2008-02-25 17:19:36 mwm Exp $ 3 3 # 4 4 # plpwm.py -- Example PLWM window manager configuration with panes. … … 31 31 32 32 from time import sleep 33 from string import digits 33 34 34 35 from Xlib import X, XK … … 60 61 C_a = input.InputKeyHandler._begin 61 62 C_e = input.InputKeyHandler._end 62 C_y = input.InputKeyHandler._paste 63 C_y = input.InputKeyHandler._paste_selection 63 64 c_p = input.InputKeyHandler._history_up 64 65 c_n = input.InputKeyHandler._history_down … … 84 85 menu_bordercolor = "Red" 85 86 message_bordercolor = "Blue" 87 86 88 87 88 89 class WMConfig: 89 90 def __wm_init__(my): 90 "install the panes key map" 91 PaneKeys(my) 92 91 "install the panes key map, menus, and try to restore my config." 92 93 auto_restore(my, PaneKeys(my).menus.find('paneconfigmenus')) 94 93 95 94 96 class PLPWM(wmanager.WindowManager, … … 96 98 panes.panesManager, 97 99 inspect.InspectServer, 98 WMConfig):100 WMConfig): 99 101 "Set up my window manager." 100 102 … … 219 221 220 222 def M1_m(my, event): 221 def itunes(node): os.system('itunes %s' % node.get('command'))223 def itunes(node): os.system('itunes "%s" &' % node.get('command')) 222 224 view_menu(my.wm.panes_list[my.wm.panes_current], 223 225 XML_controller(my.menus.find('itunesmenu'), … … 240 242 def reload_menus(): 241 243 my.menus = load_menus(my.menu_file) 244 auto_restore(my.wm, my.menus.find('paneconfigmenus')) 242 245 243 246 def restore_menu(wm): … … 301 304 302 305 306 def auto_restore(wm, panes): 307 "Look for and restore an automatic config." 308 309 geom = '%dx%d' % (wm.screens[0].root_full_width, 310 wm.screens[0].root_full_height) 311 for config in panes: 312 startup = config.get('startup') 313 if (startup == 'match' and config.get('label').endswith(geom)) or \ 314 startup == 'use': 315 restore(wm, config) 316 break 317 303 318 def restore(wm, config): 304 319 "Build my standard work environment." 305 320 306 pane = wm.panes_list[0] 307 pane.maximize() 321 wm.panes_list[0].maximize() 308 322 309 323 # Disconnect all windows from panes to avoid displaying everything … … 313 327 314 328 # Disconnect any remaining panes from their windows as well. 315 pane.window = None 316 329 wm.panes_list[0].window = None 330 331 places = dict() 317 332 for node in config: 318 333 if node.tag == 'vertical': 319 pane.vertical_split(float(node.get('fraction')))334 wm.panes_list[wm.panes_current].vertical_split(float(node.get('fraction'))) 320 335 elif node.tag == 'horizontal': 321 pane.horizontal_split(float(node.get('fraction')))336 wm.panes_list[wm.panes_current].horizontal_split(float(node.get('fraction'))) 322 337 elif node.tag == 'newpane': 323 338 pane = wm.panes_list[int(node.get('pane'))] 324 339 elif node.tag == 'goto': 325 wm.panes_goto(int(node.get(' number')))340 wm.panes_goto(int(node.get('pane'))) 326 341 elif node.tag == 'number': 327 wm.panes_number(int(node.get('number'))) 342 wm.panes_number(int(node.get('new'))) 343 elif node.tag == 'placewindow': 344 places[node.get('name')] = int(node.get('pane')) 328 345 else: 329 346 raise ValueError, 'Unrecognized pane config element %s' % node 330 347 348 # Now fix any windows wired by title 349 panecount = len(wm.panes_list) 350 for s in wm.screens: 351 for c in s.query_clients(cfilter.true, 1): 352 title = c.get_title() 353 if title[-2] == '@' and title[-1] in digits: 354 pane = digits.index(title[-1]) 355 if pane < panecount: 356 wm.panes_list[pane].add_window(c) 357 continue 358 else: 359 for name in places: 360 if name in title: 361 if places[name] < panecount: 362 wm.panes_list[places[name]].add_window(c) 363 break 331 364 332 365 # And now make the world sane -
trunk/plwm/panes.py
r191 r196 1 # $Id: panes.py,v 1.2 1 2006-09-18 21:43:28mwm Exp $1 # $Id: panes.py,v 1.22 2008-02-25 17:19:36 mwm Exp $ 2 2 # 3 3 # panes.py -- Handle panes (sometimes known as "frames") … … 174 174 175 175 w = my.get_window(event.window) 176 if w :176 if w and w.panes_pane: 177 177 if event.value_mask & (X.CWX | X.CWY | X.CWWidth | X.CWHeight): 178 178 w.panes_pane.place_window(w) … … 236 236 if my.window: my.deactivate() 237 237 my.window = window 238 if my.wm.panes_list[my.wm.panes_current] == my: 239 my.activate() 238 my.activate() 240 239 241 240 def iconify_window(my):
