1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344
|
#!/usr/bin/env python
#
# petliwm.py -- Example PLWM window manager "configuration"
#
# Copyright (C) 1999-2001 Peter Liljenberg <petli@ctrl-c.liu.se>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import sys
import os
###SETUP PATH
sys.path[1:1] = [os.path.join(sys.path[0], '..')]
###END SETUP PATH
import time
from Xlib import X
from plwm import wmanager, focus, keys, \
deltamove, outline, \
frame, color, font, views, \
modewindow, modestatus, \
mw_clock, mw_biff, \
inspect
from plwm.cycle import CycleKeys
from plwm.moveresize import MoveResizeKeys
from plwm.cfilter import *
delta = deltamove.DeltaMove()
class MyClient(wmanager.Client,
outline.XorOutlineClient,
modestatus.ModeFocusedTitleClient):
# Put a frame around all client windows
window_proxy_class = frame.FrameProxy
start_iconified_clients = name('WMManager')
default_pointer_pos = {'Emacs': (-1, 0),
'XTerm': (-1, 0)}
class MyScreen(wmanager.Screen,
color.Color,
modewindow.ModeWindowScreen,
modestatus.ModeStatus,
modestatus.ModeMoveResize,
views.XMW_ViewHandler,
modestatus.ModeFocusedTitleScreen):
view_always_visible_clients = Or(name('XClock'),
name('XBiff'),
name('XModeWindow'))
class WMConfig:
def __wm_init__(self):
# Install the basic key map
BasicKeys(self)
class PLWM(wmanager.WindowManager,
font.Font,
focus.SloppyFocus,
focus.MoveFocus,
mw_clock.ModeWindowClock,
mw_biff.ModeWindowBiff,
inspect.InspectServer,
WMConfig):
client_class = MyClient
screen_class = MyScreen
class BasicKeys(keys.KeyHandler):
def F1(self, event):
self.wm.current_screen.view_find_with_client(name('XTerm'))
def S_F1(self, event):
self.wm.system('xterm -geometry 80x50+200+100')
def C_S_F1(self, event):
self.wm.current_screen.view_new()
self.wm.system('xterm -geometry 80x50+200+100')
def F2(self, event):
self.wm.current_screen.view_find_with_client(name('Emacs'))
def S_F2(self, event):
self.wm.system('emacs')
def C_S_F2(self, event):
self.wm.current_screen.view_new()
self.wm.system('emacs')
def F3(self, event):
self.wm.current_screen.view_find_with_client(name('Netscape'))
def S_F3(self, event):
self.wm.system('netscape')
def C_S_F3(self, event):
self.wm.current_screen.view_new()
self.wm.system('netscape')
def F5(self, event):
self.wm.current_screen.view_find_tag('F5')
def S_F5(self, event):
self.wm.current_screen.view_tag('F5')
def F6(self, event):
self.wm.current_screen.view_find_tag('F6')
def S_F6(self, event):
self.wm.current_screen.view_tag('F6')
def F7(self, event):
self.wm.current_screen.view_find_tag('F7')
def S_F7(self, event):
self.wm.current_screen.view_tag('F7')
def F8(self, event):
self.wm.current_screen.view_find_tag('F8')
def S_F8(self, event):
self.wm.current_screen.view_tag('F8')
# Simulate mouse clicks
def Any_F9(self, evt):
self.wm.fake_button_click(1)
def Any_F10(self, evt):
self.wm.fake_button_click(2)
def Any_F11(self, evt):
self.wm.fake_button_click(3)
def F12(self, evt):
self.wm.inspect_toggle()
def S_F12(self, evt):
self.wm.inspect_toggle(force = 1)
# Drop all keygrabs until Scroll_Lock is pressed again, to allow
# clients to recieve keys used by plwm
def S_Pause(self, evt):
wmanager.debug('keys', 'dropping keygrabs temporarily')
# First release all our grabs. They will be reinstalled
# when BypassHandler exits
self._ungrab()
BypassHandler(self)
def KP_Begin(self, event):
MyMoveResizeKeys(self, event)
def C_Tab(self, event):
CycleUMKeys(self, event)
def KP_Insert(self, event):
wmanager.debug('keys', 'Iconifying')
if self.wm.current_client:
self.wm.current_client.iconify()
def KP_Subtract(self, event):
wmanager.debug('keys', 'Prev view')
self.wm.current_screen.view_prev()
def KP_Add(self, event):
wmanager.debug('keys', 'Next view')
self.wm.current_screen.view_next()
def C_KP_Add(self, event):
wmanager.debug('keys', 'New view')
self.wm.current_screen.view_new()
def KP_Left(self, event):
self.wm.display.warp_pointer(-delta.get(event.time), 0)
def KP_Right(self, event):
self.wm.display.warp_pointer(delta.get(event.time), 0)
def KP_Up(self, event):
self.wm.display.warp_pointer(0, -delta.get(event.time))
def KP_Down(self, event):
self.wm.display.warp_pointer(0, delta.get(event.time))
def KP_Home(self, event):
d = delta.get(event.time)
self.wm.display.warp_pointer(-d, -d)
def KP_End(self, event):
d = delta.get(event.time)
self.wm.display.warp_pointer(-d, d)
def KP_Prior(self, event):
d = delta.get(event.time)
self.wm.display.warp_pointer(d, -d)
def KP_Next(self, event):
d = delta.get(event.time)
self.wm.display.warp_pointer(d, d)
def KP_Enter(self, event):
if self.wm.current_client:
self.wm.current_client.raiselower()
# For laptop compitability
KP_Divide = KP_Enter
def C_KP_Subtract(self, event):
self.wm.system('xlock -mode blank')
def C_M_Escape(self, event):
self.wm.quit()
def C_KP_Delete(self, event):
if self.wm.current_client:
self.wm.current_client.delete(1)
def C_S_KP_Delete(self, event):
if self.wm.current_client:
self.wm.current_client.destroy()
def C_KP_Left(self, event):
self.wm.move_focus(focus.MOVE_LEFT)
def C_KP_Right(self, event):
self.wm.move_focus(focus.MOVE_RIGHT)
def C_KP_Up(self, event):
self.wm.move_focus(focus.MOVE_UP)
def C_KP_Down(self, event):
self.wm.move_focus(focus.MOVE_DOWN)
def C_less(self, event):
self.wm.move_focus(focus.MOVE_LEFT)
def C_S_less(self, event):
self.wm.move_focus(focus.MOVE_RIGHT)
class BypassHandler(keys.KeyHandler):
propagate_keys = 0
def __init__(self, keyhandler):
keys.KeyHandler.__init__(self, keyhandler.wm)
self._keyhandler = keyhandler
self._message = modewindow.Message(.1, modewindow.LEFT, 0, '[Bypassing]')
self._screen = keyhandler.wm.current_screen
self._screen.modewindow_add_message(self._message)
def Pause(self, evt):
wmanager.debug('keys', 'reinstalling keygrabs')
self._screen.modewindow_remove_message(self._message)
# Delete ourself, and reinstall the callee grabs
self._cleanup()
self._keyhandler._buildmap()
# Remove it, just to be sure there are no circular references
del self._keyhandler
del self._screen
#
# Use the keymap for moving and resizing windows.
# Without any modifiers moves, with Shift enlarges, with Ctrl shrinks
# End with KP_5. Abort with Escape or KP_Delete.
#
class MyMoveResizeKeys(MoveResizeKeys):
KP_Left = MoveResizeKeys._move_w
KP_Right = MoveResizeKeys._move_e
KP_Up = MoveResizeKeys._move_n
KP_Down = MoveResizeKeys._move_s
KP_Home = MoveResizeKeys._move_nw
KP_End = MoveResizeKeys._move_sw
KP_Prior = MoveResizeKeys._move_ne
KP_Next = MoveResizeKeys._move_se
S_KP_Left = MoveResizeKeys._enlarge_w
S_KP_Right = MoveResizeKeys._enlarge_e
S_KP_Up = MoveResizeKeys._enlarge_n
S_KP_Down = MoveResizeKeys._enlarge_s
S_KP_Home = MoveResizeKeys._enlarge_nw
S_KP_End = MoveResizeKeys._enlarge_sw
S_KP_Prior = MoveResizeKeys._enlarge_ne
S_KP_Next = MoveResizeKeys._enlarge_se
C_KP_Left = MoveResizeKeys._shrink_w
C_KP_Right = MoveResizeKeys._shrink_e
C_KP_Up = MoveResizeKeys._shrink_n
C_KP_Down = MoveResizeKeys._shrink_s
C_KP_Home = MoveResizeKeys._shrink_nw
C_KP_End = MoveResizeKeys._shrink_sw
C_KP_Prior = MoveResizeKeys._shrink_ne
C_KP_Next = MoveResizeKeys._shrink_se
KP_Begin = MoveResizeKeys._moveresize_end
S_KP_Begin = MoveResizeKeys._moveresize_end
C_KP_Begin = MoveResizeKeys._moveresize_end
Escape = MoveResizeKeys._moveresize_abort
KP_Delete = MoveResizeKeys._moveresize_abort
class CycleUMKeys(CycleKeys):
_cycle_filter = iconified
Tab = CycleKeys._cycle_next
C_Tab = CycleKeys._cycle_next
S_Tab = CycleKeys._cycle_previous
S_C_Tab = CycleKeys._cycle_previous
Escape = CycleKeys._cycle_abort
Return = CycleKeys._cycle_end
if __name__ == '__main__':
wmanager.main(PLWM)
|