]>
Dogcows Code - chaz/openbox/blob - scripts/focus.py
172c165829ea963bae7545e116a25b99bc64e493
1 ###########################################################################
2 ### Functions for helping out with your window focus. ###
3 ###########################################################################
5 ###########################################################################
6 ### Options that affect the behavior of the focus module. ###
7 ###########################################################################
9 """Don't focus windows which have requested to not be displayed in taskbars.
10 You will still be able to focus the windows, but not through cycling, and
11 they won't be focused as a fallback if 'fallback' is enabled."""
13 """When cycling focus, raise the window chosen as well as focusing it. This
14 does not affect fallback focusing behavior."""
16 """Send focus somewhere when nothing is left with the focus, if possible."""
17 ###########################################################################
19 def next(data
, num
=1):
20 """Focus the next window."""
23 def previous(data
, num
=1):
24 """Focus the previous window."""
27 ###########################################################################
28 ###########################################################################
30 ###########################################################################
31 ### Internal stuff, should not be accessed outside the module. ###
32 ###########################################################################
37 # maintain a list of clients, stacked in focus order
41 def _focusable(client
, desktop
):
42 if not client
.normal(): return 0
43 if not (client
.canFocus() or client
.focusNotify()): return 0
44 if avoid_skip_taskbar
and client
.skipTaskbar(): return 0
46 desk
= client
.desktop()
47 if not (desk
== 0xffffffff or desk
== desktop
): return 0
57 win
= data
.client
.window()
60 _clients
.insert(0, win
)
63 desktop
= ob
.openbox
.screen(data
.screen
).desktop()
65 client
= ob
.openbox
.findClient(w
)
66 if client
and _focusable(client
, desktop
) and client
.focus():
70 _clients
.append(data
.client
.window())
72 def _closewindow(data
):
74 focus
._clients
.remove(data
.client
.window())
75 except ValueError: pass
77 ob
.ebind(ob
.EventAction
.NewWindow
, _newwindow
)
78 ob
.ebind(ob
.EventAction
.CloseWindow
, _closewindow
)
79 ob
.ebind(ob
.EventAction
.Focus
, _focused
)
81 def _cycle(data
, num
, forward
):
82 global avoid_skip_taskbar
84 screen
= ob
.openbox
.screen(data
.screen
)
85 count
= screen
.clientCount()
87 if not count
: return # no clients
91 client_win
= data
.client
.window()
101 elif screen
.client(i
).window() == client_win
:
103 if found
== 1: # wraparound
104 if forward
: target
= 0
105 else: target
= count
- 1
108 desktop
= screen
.desktop()
110 client
= screen
.client(t
)
111 if client
and _focusable(client
, desktop
) and client
.focus():
113 screen
.raiseWindow(client
)
117 if t
>= count
: t
-= count
121 if t
== target
: return # nothing to focus
123 print "Loaded focus.py"
This page took 0.037581 seconds and 4 git commands to generate.