- Timestamp:
- 07/25/2008 12:06:47 PM (5 months ago)
- Files:
-
- 1 modified
-
trunk/examples/examplewm.py (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/examplewm.py
r218 r220 19 19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 20 21 """ Example PLWM window manager21 """Example PLWM window manager 22 22 23 23 This example demonstrates basic window manager construction and some of the … … 26 26 27 27 """ 28 29 28 import sys 30 29 import os … … 54 53 outline.XorOutlineClient, 55 54 modestatus.ModeFocusedTitleClient): 56 """ Example client class55 """Example client class 57 56 58 57 This class adds an XOR outline for moving/resizing windows and a hook to … … 63 62 64 63 """ 65 66 64 # Put a frame around all client windows 67 65 window_proxy_class = frame.FrameProxy … … 79 77 views.XMW_ViewHandler, 80 78 modestatus.ModeFocusedTitleScreen): 81 """ Example screen class79 """Example screen class 82 80 83 81 This class adds support for colors(FIXME), views, and a mode window, and … … 87 85 88 86 """ 89 90 87 view_always_visible_clients = Or(name('XClock'), 91 88 name('XBiff'), … … 93 90 94 91 class WMConfig: 95 """ Example window manager configuration class92 """Example window manager configuration class 96 93 97 94 Installs the BasicKeys key map into the window manager. … … 100 97 101 98 """ 102 103 99 def __wm_init__(self): 104 100 # Install the basic key map … … 114 110 inspect.InspectServer, 115 111 WMConfig): 116 """ Example window manager class112 """Example window manager class 117 113 118 114 This class sets up the configuration for the window manager, including font … … 122 118 123 119 """ 124 125 120 client_class = MyClient 126 121 screen_class = MyScreen … … 128 123 129 124 class BasicKeys(keys.KeyHandler): 130 """ Basic key bindings125 """Basic key bindings 131 126 132 127 This class defines all key-bindings for the example window manager. 133 128 134 129 """ 135 136 130 def F1(self, event): 137 """ Find a view containing an XTerm. 138 """ 139 131 """Find a view containing an XTerm.""" 140 132 self.wm.current_screen.view_find_with_client(name('XTerm')) 141 133 142 134 def S_F1(self, event): 143 """ Start an XTerm. 144 """ 145 135 """Start an XTerm.""" 146 136 self.wm.system('xterm -geometry 80x50+200+100') 147 137 148 138 def C_S_F1(self, event): 149 """ Start an XTerm in a new view. 150 """ 151 139 """Start an XTerm in a new view.""" 152 140 self.wm.current_screen.view_new() 153 141 self.wm.system('xterm -geometry 80x50+200+100') 154 142 155 143 def F2(self, event): 156 """ Find a view containing an Emacs window. 157 """ 158 144 """Find a view containing an Emacs window.""" 159 145 self.wm.current_screen.view_find_with_client(name('Emacs')) 160 146 161 147 def S_F2(self, event): 162 """ Start Emacs. 163 """ 164 148 """Start Emacs.""" 165 149 self.wm.system('emacs') 166 150 167 151 def C_S_F2(self, event): 168 """ Start Emacs in a new view. 169 """ 170 152 """Start Emacs in a new view.""" 171 153 self.wm.current_screen.view_new() 172 154 self.wm.system('emacs') 173 155 174 156 def F3(self, event): 175 """ Find a view containing a Netscape window. 176 """ 177 157 """Find a view containing a Netscape window.""" 178 158 self.wm.current_screen.view_find_with_client(name('Netscape')) 179 159 180 160 def S_F3(self, event): 181 """ Start Netscape. 182 """ 183 161 """Start Netscape.""" 184 162 self.wm.system('netscape') 185 163 186 164 def C_S_F3(self, event): 187 """ Start Netscape in a new view. 188 """ 189 165 """Start Netscape in a new view.""" 190 166 self.wm.current_screen.view_new() 191 167 self.wm.system('netscape') 192 168 193 169 def F5(self, event): 194 """ Switch to the next view with the tag 'F5'. 195 """ 196 170 """Switch to the next view with the tag 'F5'.""" 197 171 self.wm.current_screen.view_find_tag('F5') 198 172 199 173 def S_F5(self, event): 200 """ Set the current view's tag to 'F5'. 201 """ 202 174 """Set the current view's tag to 'F5'.""" 203 175 self.wm.current_screen.view_tag('F5') 204 176 205 177 def F6(self, event): 206 """ Switch to the next view with the tag 'F6'. 207 """ 208 178 """Switch to the next view with the tag 'F6'.""" 209 179 self.wm.current_screen.view_find_tag('F6') 210 180 211 181 def S_F6(self, event): 212 """ Set the current view's tag to 'F6'. 213 """ 214 182 """Set the current view's tag to 'F6'.""" 215 183 self.wm.current_screen.view_tag('F6') 216 184 217 185 def F7(self, event): 218 """ Switch to the next view with the tag 'F7'. 219 """ 220 186 """Switch to the next view with the tag 'F7'.""" 221 187 self.wm.current_screen.view_find_tag('F7') 222 188 223 189 def S_F7(self, event): 224 """ Set the current view's tag to 'F7'. 225 """ 226 190 """Set the current view's tag to 'F7'.""" 227 191 self.wm.current_screen.view_tag('F7') 228 192 229 193 def F8(self, event): 230 """ Switch to the next view with the tag 'F8'. 231 """ 232 194 """Switch to the next view with the tag 'F8'.""" 233 195 self.wm.current_screen.view_find_tag('F8') 234 196 235 197 def S_F8(self, event): 236 """ Set the current view's tag to 'F8'. 237 """ 238 198 """Set the current view's tag to 'F8'.""" 239 199 self.wm.current_screen.view_tag('F8') 240 200 241 201 # Simulate mouse clicks 242 202 def Any_F9(self, evt): 243 """ Simulate a primary (usually, left) mouse button click. 203 """Simulate a primary (usually, left) mouse button click.""" 204 self.wm.fake_button_click(1) 205 206 def Any_F10(self, evt): 207 """Simulate a secondary (usually, right) mouse button click.""" 208 self.wm.fake_button_click(2) 209 210 def Any_F11(self, evt): 211 """Simulate a tertiary (usually, middle) mouse button click.""" 212 self.wm.fake_button_click(3) 213 214 215 def F12(self, evt): 216 """Toggle inspect mode.""" 217 self.wm.inspect_toggle() 218 219 def S_F12(self, evt): 220 """Toggle inspect mode, forcing if needed.""" 221 self.wm.inspect_toggle(force = 1) 222 223 def S_Pause(self, evt): 224 """Drop all keygrabs until Scroll_Lock is pressed again. 225 226 Allows clients to recieve keys used by plwm. 227 244 228 """ 245 246 self.wm.fake_button_click(1)247 248 def Any_F10(self, evt):249 """ Simulate a secondary (usually, right) mouse button click.250 """251 252 self.wm.fake_button_click(2)253 254 def Any_F11(self, evt):255 """ Simulate a tertiary (usually, middle) mouse button click.256 """257 258 self.wm.fake_button_click(3)259 260 261 def F12(self, evt):262 """ Toggle inspect mode.263 """264 265 self.wm.inspect_toggle()266 267 def S_F12(self, evt):268 """ Toggle inspect mode, forcing if needed.269 """270 271 self.wm.inspect_toggle(force = 1)272 273 def S_Pause(self, evt):274 """ Drop all keygrabs until Scroll_Lock is pressed again.275 276 Allows clients to recieve keys used by plwm.277 """278 279 229 wmanager.debug('keys', 'dropping keygrabs temporarily') 280 230 … … 287 237 288 238 def KP_Begin(self, event): 289 """ Start moving / resizing the current window. 290 """ 291 239 """Start moving / resizing the current window.""" 292 240 MyMoveResizeKeys(self, event) 293 241 294 242 295 243 def C_Tab(self, event): 296 """ Cycle through minimized windows. 297 """ 298 244 """Cycle through minimized windows.""" 299 245 CycleUMKeys(self, event) 300 246 301 247 def KP_Insert(self, event): 302 """ Iconify the current window. 303 """ 304 248 """Iconify the current window.""" 305 249 wmanager.debug('keys', 'Iconifying') 306 250 if self.wm.current_client: … … 308 252 309 253 def KP_Subtract(self, event): 310 """ Switch to the previous view. 311 """ 312 254 """Switch to the previous view.""" 313 255 wmanager.debug('keys', 'Prev view') 314 256 self.wm.current_screen.view_prev() 315 257 316 258 def KP_Add(self, event): 317 """ Switch to the next view. 318 """ 319 259 """Switch to the next view.""" 320 260 wmanager.debug('keys', 'Next view') 321 261 self.wm.current_screen.view_next() 322 262 323 263 def C_KP_Add(self, event): 324 """ Create a new view. 325 """ 326 264 """Create a new view.""" 327 265 wmanager.debug('keys', 'New view') 328 266 self.wm.current_screen.view_new() 329 267 330 268 def KP_Left(self, event): 331 """ Move the pointer to the left. 332 """ 333 269 """Move the pointer to the left.""" 334 270 self.wm.display.warp_pointer(-delta.get(event.time), 0) 335 271 336 272 def KP_Right(self, event): 337 """ Move the pointer to the right. 338 """ 339 273 """Move the pointer to the right.""" 340 274 self.wm.display.warp_pointer(delta.get(event.time), 0) 341 275 342 276 def KP_Up(self, event): 343 """ Move the pointer up. 344 """ 345 277 """Move the pointer up.""" 346 278 self.wm.display.warp_pointer(0, -delta.get(event.time)) 347 279 348 280 def KP_Down(self, event): 349 """ Move the pointer down. 350 """ 351 281 """Move the pointer down.""" 352 282 self.wm.display.warp_pointer(0, delta.get(event.time)) 353 283 354 284 def KP_Home(self, event): 355 """ Move the pointer up and to the left. 356 """ 357 285 """Move the pointer up and to the left.""" 358 286 d = delta.get(event.time) 359 287 self.wm.display.warp_pointer(-d, -d) 360 288 361 289 def KP_End(self, event): 362 """ Move the pointer down and to the left. 363 """ 364 290 """Move the pointer down and to the left.""" 365 291 d = delta.get(event.time) 366 292 self.wm.display.warp_pointer(-d, d) 367 293 368 294 def KP_Prior(self, event): 369 """ Move the pointer up and to the right. 370 """ 371 295 """Move the pointer up and to the right.""" 372 296 d = delta.get(event.time) 373 297 self.wm.display.warp_pointer(d, -d) 374 298 375 299 def KP_Next(self, event): 376 """ Move the pointer down and to the right. 377 """ 378 300 """Move the pointer down and to the right.""" 379 301 d = delta.get(event.time) 380 302 self.wm.display.warp_pointer(d, d) 381 303 382 304 def KP_Enter(self, event): 383 """ Raise or lower the current window. 384 """ 385 305 """Raise or lower the current window.""" 386 306 if self.wm.current_client: 387 307 self.wm.current_client.raiselower() … … 391 311 392 312 def C_KP_Subtract(self, event): 393 """ Lock the screen with xlock. 394 """ 395 313 """Lock the screen with xlock.""" 396 314 self.wm.system('xlock -mode blank') 397 315 398 316 def C_M_Escape(self, event): 399 """ Quit the window manager. 400 """ 401 317 """Quit the window manager.""" 402 318 self.wm.quit() 403 319 404 320 def C_KP_Delete(self, event): 405 """ Close the current window. 406 """ 407 321 """Close the current window.""" 408 322 if self.wm.current_client: 409 323 self.wm.current_client.delete(1) 410 324 411 325 def C_S_KP_Delete(self, event): 412 """ Kill the current client. 413 """ 414 326 """Kill the current client.""" 415 327 if self.wm.current_client: 416 328 self.wm.current_client.destroy() 417 329 418 330 def C_KP_Left(self, event): 419 """ Focus the next window to the left of the current one. 420 """ 421 331 """Focus the next window to the left of the current one.""" 422 332 self.wm.move_focus(focus.MOVE_LEFT) 423 333 424 334 def C_KP_Right(self, event): 425 """ Focus the next window to the right of the current one. 426 """ 427 335 """Focus the next window to the right of the current one.""" 428 336 self.wm.move_focus(focus.MOVE_RIGHT) 429 337 430 338 def C_KP_Up(self, event): 431 """ Focus the next window above the current one. 432 """ 433 339 """Focus the next window above the current one.""" 434 340 self.wm.move_focus(focus.MOVE_UP) 435 341 436 342 def C_KP_Down(self, event): 437 """ Focus the next window below the current one. 438 """ 439 343 """Focus the next window below the current one.""" 440 344 self.wm.move_focus(focus.MOVE_DOWN) 441 345 442 346 def C_less(self, event): 443 """ Focus the next window to the left of the current one. 444 """ 445 347 """Focus the next window to the left of the current one.""" 446 348 self.wm.move_focus(focus.MOVE_LEFT) 447 349 448 350 def C_S_less(self, event): 449 """ Focus the next window to the right of the current one. 450 """ 451 351 """Focus the next window to the right of the current one.""" 452 352 self.wm.move_focus(focus.MOVE_RIGHT) 453 353 454 354 455 355 class BypassHandler(keys.KeyHandler): 456 """ Surrogate key handler to bypass the window manager's key bindings.356 """Surrogate key handler to bypass the window manager's key bindings. 457 357 458 358 Allows clients to receive key presses normally handled by the WM. 459 359 460 360 """ 461 462 361 propagate_keys = 0 463 362 … … 470 369 471 370 def Pause(self, evt): 472 """ Restore normal key bindings. 473 """ 474 371 """Restore normal key bindings.""" 475 372 wmanager.debug('keys', 'reinstalling keygrabs') 476 373 … … 492 389 493 390 class MyMoveResizeKeys(MoveResizeKeys): 494 """ Keys for moving and resizing the current window. 495 """ 496 391 """Keys for moving and resizing the current window.""" 497 392 KP_Left = MoveResizeKeys._move_w 498 393 KP_Right = MoveResizeKeys._move_e … … 531 426 532 427 class CycleUMKeys(CycleKeys): 533 """ Keys to cycle through all iconified windows. 534 """ 535 428 """Keys to cycle through all iconified windows.""" 536 429 _cycle_filter = iconified 537 430
