add a confine option to grab_pointer to confine the pointer to the screen, and use that for moveresize
{
if (config_focus_follow)
if (data->any.context != OB_FRAME_CONTEXT_CLIENT && !data->any.button)
- grab_pointer(TRUE, FALSE, OB_CURSOR_NONE);
+ grab_pointer(FALSE, FALSE, OB_CURSOR_NONE);
}
inline void client_action_end(union ActionData *data)
if (config_focus_follow)
if (data->any.context != OB_FRAME_CONTEXT_CLIENT) {
if (!data->any.button) {
- grab_pointer(FALSE, FALSE, OB_CURSOR_NONE);
+ ungrab_pointer();
} else {
ObClient *c;
return pgrabs > 0;
}
-gboolean grab_keyboard(gboolean grab)
+gboolean grab_keyboard_full(gboolean grab)
{
gboolean ret = FALSE;
return ret;
}
-gboolean grab_pointer(gboolean grab, gboolean owner_events, ObCursor cur)
+gboolean grab_pointer_full(gboolean grab, gboolean owner_events,
+ gboolean confine, ObCursor cur)
{
gboolean ret = FALSE;
if (pgrabs++ == 0) {
ret = XGrabPointer(ob_display, screen_support_win, owner_events,
GRAB_PTR_MASK,
- GrabModeAsync, GrabModeAsync, None,
+ GrabModeAsync, GrabModeAsync,
+ (confine ? RootWindow(ob_display, ob_screen) :
+ None),
ob_cursor(cur), event_curtime) == Success;
if (!ret)
--pgrabs;
{
if (reconfig) return;
- while (grab_keyboard(FALSE));
- while (grab_pointer(FALSE, FALSE, OB_CURSOR_NONE));
+ while (ungrab_keyboard());
+ while (ungrab_pointer());
while (grab_server(FALSE));
}
void grab_startup(gboolean reconfig);
void grab_shutdown(gboolean reconfig);
-gboolean grab_keyboard(gboolean grab);
-gboolean grab_pointer(gboolean grab, gboolean owner_events, ObCursor cur);
+gboolean grab_keyboard_full(gboolean grab);
+/*! @param confine If true the pointer is confined to the screen */
+gboolean grab_pointer_full(gboolean grab, gboolean owner_events,
+ gboolean confine, ObCursor cur);
gint grab_server(gboolean grab);
+#define grab_keyboard() grab_keyboard_full(TRUE)
+#define ungrab_keyboard() grab_keyboard_full(FALSE)
+#define grab_pointer(o,c,u) grab_pointer_full(TRUE, (o), (c), (u))
+#define ungrab_pointer() grab_pointer_full(FALSE, FALSE, FALSE, OB_CURSOR_NONE)
+
gboolean grab_on_keyboard();
gboolean grab_on_pointer();
/* ungrab first so they won't be NotifyWhileGrabbed */
if (ungrab)
- grab_keyboard(FALSE);
+ ungrab_keyboard();
/* set this before running the actions so they know the keyboard is not
grabbed */
g_assert(action->data.any.interactive);
if (!istate.active) {
- if (!grab_keyboard(TRUE))
+ if (!grab_keyboard())
return FALSE;
} else if (action->func != istate.action->func) {
keyboard_interactive_end(state, TRUE, action->data.any.time, FALSE);
/* grab the pointer in such a way as to pass through "owner events"
so that we can get enter/leave notifies in the menu. */
- if (!grab_pointer(TRUE, TRUE, OB_CURSOR_POINTER))
+ if (!grab_pointer(TRUE, FALSE, OB_CURSOR_POINTER))
return FALSE;
- if (!grab_keyboard(TRUE)) {
- grab_pointer(FALSE, TRUE, OB_CURSOR_POINTER);
+ if (!grab_keyboard()) {
+ ungrab_pointer();
return FALSE;
}
}
if (menu_frame_visible == NULL) {
/* last menu shown */
- grab_pointer(FALSE, TRUE, OB_CURSOR_NONE);
- grab_keyboard(FALSE);
+ ungrab_pointer();
+ ungrab_keyboard();
}
XUnmapWindow(ob_display, self->window);
else
g_assert_not_reached();
- if (!grab_pointer(TRUE, FALSE, cur))
+ /* keep the pointer bounded to the screen for move/resize */
+ if (!grab_pointer(FALSE, TRUE, cur))
return;
- if (!grab_keyboard(TRUE)) {
- grab_pointer(FALSE, FALSE, OB_CURSOR_NONE);
+ if (!grab_keyboard()) {
+ ungrab_pointer();
return;
}
{
gint x, y;
- grab_keyboard(FALSE);
- grab_pointer(FALSE, FALSE, OB_CURSOR_NONE);
+ ungrab_keyboard();
+ ungrab_pointer();
popup_hide(popup);