]>
Dogcows Code - chaz/openbox/blob - openbox/grab.c
8 #define GRAB_PTR_MASK (ButtonPressMask | ButtonReleaseMask | ButtonMotionMask)
9 #define GRAB_KEY_MASK (KeyPressMask | KeyReleaseMask)
11 #define MASK_LIST_SIZE 8
13 /*! A list of all possible combinations of keyboard lock masks */
14 static unsigned int mask_list
[MASK_LIST_SIZE
];
16 int grab_keyboard(gboolean grab
)
18 static guint kgrabs
= 0;
21 XGrabKeyboard(ob_display
, ob_root
, FALSE
, GrabModeAsync
,
22 GrabModeAsync
, event_lasttime
);
23 } else if (kgrabs
> 0) {
25 XUngrabKeyboard(ob_display
, event_lasttime
);
30 int grab_pointer(gboolean grab
, Cursor cur
)
32 static guint pgrabs
= 0;
35 XGrabPointer(ob_display
, ob_root
, False
, GRAB_PTR_MASK
,
36 GrabModeAsync
, GrabModeAsync
, FALSE
, cur
,
38 } else if (pgrabs
> 0) {
40 XUngrabPointer(ob_display
, event_lasttime
);
45 int grab_pointer_window(gboolean grab
, Cursor cur
, Window win
)
47 static guint pgrabs
= 0;
50 XGrabPointer(ob_display
, win
, False
, GRAB_PTR_MASK
, GrabModeAsync
,
51 GrabModeAsync
, TRUE
, cur
, event_lasttime
);
52 } else if (pgrabs
> 0) {
54 XUngrabPointer(ob_display
, event_lasttime
);
59 int grab_server(gboolean grab
)
61 static guint sgrabs
= 0;
64 XGrabServer(ob_display
);
65 XSync(ob_display
, FALSE
);
67 } else if (sgrabs
> 0) {
69 XUngrabServer(ob_display
);
81 mask_list
[i
++] = LockMask
;
82 mask_list
[i
++] = NumLockMask
;
83 mask_list
[i
++] = LockMask
| NumLockMask
;
84 mask_list
[i
++] = ScrollLockMask
;
85 mask_list
[i
++] = ScrollLockMask
| LockMask
;
86 mask_list
[i
++] = ScrollLockMask
| NumLockMask
;
87 mask_list
[i
++] = ScrollLockMask
| LockMask
| NumLockMask
;
88 g_assert(i
== MASK_LIST_SIZE
);
93 while (grab_keyboard(FALSE
));
94 while (grab_pointer(FALSE
, None
));
95 while (grab_pointer_window(FALSE
, None
, None
));
96 while (grab_server(FALSE
));
99 void grab_button_full(guint button
, guint state
, Window win
, guint mask
,
100 int pointer_mode
, Cursor cursor
)
104 for (i
= 0; i
< MASK_LIST_SIZE
; ++i
)
105 XGrabButton(ob_display
, button
, state
| mask_list
[i
], win
, FALSE
, mask
,
106 pointer_mode
, GrabModeSync
, None
, cursor
);
109 void grab_button(guint button
, guint state
, Window win
, guint mask
)
111 grab_button_full(button
, state
, win
, mask
, GrabModeAsync
, None
);
114 void ungrab_button(guint button
, guint state
, Window win
)
118 for (i
= 0; i
< MASK_LIST_SIZE
; ++i
)
119 XUngrabButton(ob_display
, button
, state
| mask_list
[i
], win
);
122 void grab_key(guint keycode
, guint state
, int keyboard_mode
)
126 xerror_set_ignore(TRUE
); /* can get BadAccess' from these */
127 xerror_occured
= FALSE
;
128 for (i
= 0; i
< MASK_LIST_SIZE
; ++i
)
129 XGrabKey(ob_display
, keycode
, state
| mask_list
[i
], ob_root
, FALSE
,
130 GrabModeSync
, keyboard_mode
);
131 xerror_set_ignore(FALSE
);
133 g_warning("failed to grab keycode %d modifiers %d", keycode
, state
);
136 void ungrab_all_keys()
138 XUngrabKey(ob_display
, AnyKey
, AnyModifier
, ob_root
);
This page took 0.037831 seconds and 4 git commands to generate.