diff options
| author | Dana Jansens <danakj@orodu.net> | 2003-01-27 13:42:41 +0000 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2003-01-27 13:42:41 +0000 |
| commit | 5face4c6f35172761367f63ac0b6eaf62d84e532 (patch) | |
| tree | 061851b68cc6e2d645b5966f76fa4ad0d300af92 /scripts | |
| parent | 5168a8add5ed46f74b615ecc60738c1113606734 (diff) | |
use otk objects in the ob scripts by importing otk
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/callbacks.py | 64 | ||||
| -rw-r--r-- | scripts/config.py | 10 | ||||
| -rw-r--r-- | scripts/windowplacement.py | 3 |
3 files changed, 40 insertions, 37 deletions
diff --git a/scripts/callbacks.py b/scripts/callbacks.py index caea7586..1289a7bb 100644 --- a/scripts/callbacks.py +++ b/scripts/callbacks.py @@ -1,35 +1,45 @@ -########################################################################### -### Functions that can be used as callbacks for mouse/keyboard bindings ### -########################################################################### +############################################################################ +### Functions that can be used as callbacks for mouse/keyboard bindings ### +############################################################################ + +############################################################################# +### Options that can be modified to change the default hooks' behaviors. ### +### ### +# resize_nearest - 1 to resize from the corner nearest where the mouse ### +### is, 0 to resize always from the bottom right corner. ### +resize_nearest = 1 ### +### ### +############################################################################# import ob +import otk def state_above(data, add=2): """Toggles, adds or removes the 'above' state on a window.""" if not data.client: return - ob.send_client_msg(ob.display.screenInfo(data.screen).rootWindow(), - ob.Property_atoms().net_wm_state, data.client.window(), - add, ob.Property_atoms().net_wm_state_above) + ob.send_client_msg(otk.display.screenInfo(data.screen).rootWindow(), + otk.Property_atoms().net_wm_state, data.client.window(), + add, otk.Property_atoms().net_wm_state_above) def state_below(data, add=2): """Toggles, adds or removes the 'below' state on a window.""" if not data.client: return - ob.send_client_msg(ob.display.screenInfo(data.screen).rootWindow(), - ob.Property_atoms().net_wm_state, data.client.window(), - add, ob.Property_atoms().net_wm_state_below) + ob.send_client_msg(otk.display.screenInfo(data.screen).rootWindow(), + otk.Property_atoms().net_wm_state, data.client.window(), + add, otk.Property_atoms().net_wm_state_below) def state_shaded(data, add=2): """Toggles, adds or removes the 'shaded' state on a window.""" if not data.client: return - ob.send_client_msg(ob.display.screenInfo(data.screen).rootWindow(), - ob.Property_atoms().net_wm_state, data.client.window(), - add, ob.Property_atoms().net_wm_state_shaded) + ob.send_client_msg(otk.display.screenInfo(data.screen).rootWindow(), + otk.Property_atoms().net_wm_state, data.client.window(), + add, otk.Property_atoms().net_wm_state_shaded) def iconify(data): """Iconifies the window on which the event occured""" if not data.client: return - ob.send_client_msg(ob.display.screenInfo(data.screen).rootWindow(), - ob.Property_atoms().wm_change_state, + ob.send_client_msg(otk.display.screenInfo(data.screen).rootWindow(), + otk.Property_atoms().wm_change_state, data.client.window(), 3) # IconicState def restore(data): @@ -37,15 +47,15 @@ def restore(data): if. If you want to focus the window too, it is recommended that you use the activate() function.""" if not data.client: return - ob.send_client_msg(ob.display.screenInfo(data.screen).rootWindow(), - ob.Property_atoms().wm_change_state, + ob.send_client_msg(otk.display.screenInfo(data.screen).rootWindow(), + otk.Property_atoms().wm_change_state, data.client.window(), 1) # NormalState def close(data): """Closes the window on which the event occured""" if not data.client: return - ob.send_client_msg(ob.display.screenInfo(data.screen).rootWindow(), - ob.Property_atoms().net_close_window, + ob.send_client_msg(otk.display.screenInfo(data.screen).rootWindow(), + otk.Property_atoms().net_close_window, data.client.window(), 0) def focus(data): @@ -83,23 +93,23 @@ def resize(data): # pick a corner to anchor if not (resize_nearest or data.context == MC_Grip): - corner = Client.TopLeft + corner = ob.Client.TopLeft else: x = px - data.press_clientx y = py - data.press_clienty if y < data.press_clientheight / 2: if x < data.press_clientwidth / 2: - corner = Client.BottomRight + corner = ob.Client.BottomRight dx *= -1 else: - corner = Client.BottomLeft + corner = ob.Client.BottomLeft dy *= -1 else: if x < data.press_clientwidth / 2: - corner = Client.TopRight + corner = ob.Client.TopRight dx *= -1 else: - corner = Client.TopLeft + corner = ob.Client.TopLeft data.client.resize(corner, data.press_clientwidth + dx, @@ -133,8 +143,8 @@ def unshade(data): def change_desktop(data, num): """Switches to a specified desktop""" - root = ob.display.screenInfo(data.screen).rootWindow() - ob.send_client_msg(root, ob.Property_atoms().net_current_desktop, + root = otk.display.screenInfo(data.screen).rootWindow() + ob.send_client_msg(root, otk.Property_atoms().net_current_desktop, root, num) def next_desktop(data, no_wrap=0): @@ -164,8 +174,8 @@ def prev_desktop(data, no_wrap=0): def send_to_desktop(data, num): """Sends a client to a specified desktop""" if not data.client: return - ob.send_client_msg(ob.display.screenInfo(data.screen).rootWindow(), - ob.Property_atoms().net_wm_desktop, + ob.send_client_msg(otk.display.screenInfo(data.screen).rootWindow(), + otk.Property_atoms().net_wm_desktop, data.client.window(),num) def toggle_all_desktops(data): diff --git a/scripts/config.py b/scripts/config.py index e59360be..823d9d3f 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -30,15 +30,5 @@ desktop_names = ["one", "two", "three", "four", "five", "six", "seven", \ # between. number_of_desktops = 4 -############################################################################# -### Options that can be modified by the user to change the default hooks' ### -### behaviors. ### -############################################################################# - -# resize_nearest - 1 to resize from the corner nearest where the mouse is, 0 -# to resize always from the bottom right corner. -resize_nearest = 1 - - print "Loaded config.py" diff --git a/scripts/windowplacement.py b/scripts/windowplacement.py index 127cd2ad..81d260e8 100644 --- a/scripts/windowplacement.py +++ b/scripts/windowplacement.py @@ -3,6 +3,7 @@ ### ob.EventAction.PlaceWindow event. ### ############################################################################ +import otk import ob import random @@ -13,6 +14,8 @@ def random(data): client_area = data.client.area() frame_size = data.client.frame.size() screen_area = ob.openbox.screen(data.screen).area() + print str(screen_area.x()) + " " + str(screen_area.y()) + " " + \ + str(screen_area.width()) + " " + str(screen_area.height()) width = screen_area.width() - (client_area.width() + frame_size.left + frame_size.right) height = screen_area.height() - (client_area.height() + |
