]>
Dogcows Code - chaz/openbox/blob - openbox/grab.c
7 static guint kgrabs
, pgrabs
, sgrabs
;
9 #define MASK_LIST_SIZE 8
11 /*! A list of all possible combinations of keyboard lock masks */
12 static unsigned int mask_list
[MASK_LIST_SIZE
];
14 void grab_keyboard(gboolean grab
)
18 g_message("GRABBING KEYBOARD %d", kgrabs
);
19 XGrabKeyboard(ob_display
, ob_root
, 0, GrabModeAsync
, GrabModeSync
,
22 g_message("NOT GRABBING KEYBOARD %d", kgrabs
);
23 } else if (kgrabs
> 0) {
25 g_message("UNGRABBING KEYBOARD %d", kgrabs
);
26 XUngrabKeyboard(ob_display
, event_lasttime
);
28 g_message("NOT UNGRABBING KEYBOARD %d", kgrabs
);
32 void grab_pointer(gboolean grab
, Cursor cur
)
36 XGrabPointer(ob_display
, ob_root
, False
, 0, GrabModeAsync
,
37 GrabModeAsync
, FALSE
, cur
, event_lasttime
);
38 } else if (pgrabs
> 0) {
40 XUngrabPointer(ob_display
, event_lasttime
);
44 void grab_server(gboolean grab
)
48 XGrabServer(ob_display
);
49 XSync(ob_display
, FALSE
);
51 } else if (sgrabs
> 0) {
53 XUngrabServer(ob_display
);
63 kgrabs
= pgrabs
= sgrabs
= 0;
66 mask_list
[i
++] = LockMask
;
67 mask_list
[i
++] = NumLockMask
;
68 mask_list
[i
++] = LockMask
| NumLockMask
;
69 mask_list
[i
++] = ScrollLockMask
;
70 mask_list
[i
++] = ScrollLockMask
| LockMask
;
71 mask_list
[i
++] = ScrollLockMask
| NumLockMask
;
72 mask_list
[i
++] = ScrollLockMask
| LockMask
| NumLockMask
;
73 g_assert(i
== MASK_LIST_SIZE
);
78 while (kgrabs
) grab_keyboard(FALSE
);
79 while (pgrabs
) grab_pointer(FALSE
, None
);
80 while (sgrabs
) grab_server(FALSE
);
83 void grab_button(guint button
, guint state
, Window win
, guint mask
,
88 for (i
= 0; i
< MASK_LIST_SIZE
; ++i
)
89 XGrabButton(ob_display
, button
, state
| mask_list
[i
], win
, FALSE
, mask
,
90 pointer_mode
, GrabModeAsync
, None
, None
);
93 void ungrab_button(guint button
, guint state
, Window win
)
97 for (i
= 0; i
< MASK_LIST_SIZE
; ++i
)
98 XUngrabButton(ob_display
, button
, state
| mask_list
[i
], win
);
101 void grab_key(guint keycode
, guint state
, int keyboard_mode
)
105 for (i
= 0; i
< MASK_LIST_SIZE
; ++i
)
106 XGrabKey(ob_display
, keycode
, state
| mask_list
[i
], ob_root
, FALSE
,
107 GrabModeAsync
, keyboard_mode
);
110 void ungrab_all_keys()
112 XUngrabKey(ob_display
, AnyKey
, AnyModifier
, ob_root
);
This page took 0.042066 seconds and 4 git commands to generate.