]>
Dogcows Code - chaz/openbox/blob - openbox/grab.c
8 static guint kgrabs
, pgrabs
, sgrabs
;
10 #define MASK_LIST_SIZE 8
12 /*! A list of all possible combinations of keyboard lock masks */
13 static unsigned int mask_list
[MASK_LIST_SIZE
];
15 void grab_keyboard(gboolean grab
)
19 g_message("GRABBING KEYBOARD %d", kgrabs
);
20 XGrabKeyboard(ob_display
, ob_root
, 0, GrabModeAsync
, GrabModeSync
,
23 g_message("NOT GRABBING KEYBOARD %d", kgrabs
);
24 } else if (kgrabs
> 0) {
26 g_message("UNGRABBING KEYBOARD %d", kgrabs
);
27 XUngrabKeyboard(ob_display
, event_lasttime
);
29 g_message("NOT UNGRABBING KEYBOARD %d", kgrabs
);
33 void grab_pointer(gboolean grab
, Cursor cur
)
37 XGrabPointer(ob_display
, ob_root
, False
, 0, GrabModeAsync
,
38 GrabModeAsync
, FALSE
, cur
, event_lasttime
);
39 } else if (pgrabs
> 0) {
41 XUngrabPointer(ob_display
, event_lasttime
);
45 void grab_server(gboolean grab
)
49 XGrabServer(ob_display
);
50 XSync(ob_display
, FALSE
);
52 } else if (sgrabs
> 0) {
54 XUngrabServer(ob_display
);
64 kgrabs
= pgrabs
= sgrabs
= 0;
67 mask_list
[i
++] = LockMask
;
68 mask_list
[i
++] = NumLockMask
;
69 mask_list
[i
++] = LockMask
| NumLockMask
;
70 mask_list
[i
++] = ScrollLockMask
;
71 mask_list
[i
++] = ScrollLockMask
| LockMask
;
72 mask_list
[i
++] = ScrollLockMask
| NumLockMask
;
73 mask_list
[i
++] = ScrollLockMask
| LockMask
| NumLockMask
;
74 g_assert(i
== MASK_LIST_SIZE
);
79 while (kgrabs
) grab_keyboard(FALSE
);
80 while (pgrabs
) grab_pointer(FALSE
, None
);
81 while (sgrabs
) grab_server(FALSE
);
84 void grab_button(guint button
, guint state
, Window win
, guint mask
,
89 for (i
= 0; i
< MASK_LIST_SIZE
; ++i
)
90 XGrabButton(ob_display
, button
, state
| mask_list
[i
], win
, FALSE
, mask
,
91 pointer_mode
, GrabModeAsync
, None
, None
);
94 void ungrab_button(guint button
, guint state
, Window win
)
98 for (i
= 0; i
< MASK_LIST_SIZE
; ++i
)
99 XUngrabButton(ob_display
, button
, state
| mask_list
[i
], win
);
102 void grab_key(guint keycode
, guint state
, int keyboard_mode
)
106 xerror_set_ignore(TRUE
); /* can get BadAccess' from these */
107 xerror_occured
= FALSE
;
108 for (i
= 0; i
< MASK_LIST_SIZE
; ++i
)
109 XGrabKey(ob_display
, keycode
, state
| mask_list
[i
], ob_root
, FALSE
,
110 GrabModeAsync
, keyboard_mode
);
111 xerror_set_ignore(FALSE
);
113 g_warning("failed to grab keycode %d modifiers %d", keycode
, state
);
116 void ungrab_all_keys()
118 XUngrabKey(ob_display
, AnyKey
, AnyModifier
, ob_root
);
This page took 0.042449 seconds and 4 git commands to generate.