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