all repos — openbox @ 9fcb2aa1d25ec9889b45d145939fb17160b1106a

openbox fork - make it a bit more like ryudo

add grab/ungrab macros so dont need to pass in 10 arguments to ungrab stuff.
add a confine option to grab_pointer to confine the pointer to the screen, and use that for moveresize
Dana Jansens danakj@orodu.net
commit

9fcb2aa1d25ec9889b45d145939fb17160b1106a

parent

627125a6c6e6728de98aa813e353ec75bab7b54c

M openbox/action.copenbox/action.c

@@ -42,7 +42,7 @@ inline void client_action_start(union ActionData *data)

{ 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)

@@ -50,7 +50,7 @@ {

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;
M openbox/grab.copenbox/grab.c

@@ -67,7 +67,7 @@ {

return pgrabs > 0; } -gboolean grab_keyboard(gboolean grab) +gboolean grab_keyboard_full(gboolean grab) { gboolean ret = FALSE;

@@ -92,7 +92,8 @@

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;

@@ -100,7 +101,9 @@ if (grab) {

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;

@@ -158,8 +161,8 @@ void grab_shutdown(gboolean reconfig)

{ 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)); }
M openbox/grab.hopenbox/grab.h

@@ -27,9 +27,16 @@

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();
M openbox/keyboard.copenbox/keyboard.c

@@ -197,7 +197,7 @@ g_assert(istate.active);

/* 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 */

@@ -226,7 +226,7 @@ {

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);
M openbox/menuframe.copenbox/menuframe.c

@@ -914,10 +914,10 @@ /* no menus shown yet */

/* 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; } }

@@ -1035,8 +1035,8 @@ menu_frame_visible = g_list_delete_link(menu_frame_visible, it);

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);
M openbox/moveresize.copenbox/moveresize.c

@@ -187,10 +187,11 @@ cur = OB_CURSOR_MOVE;

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; }

@@ -275,8 +276,8 @@ void moveresize_end(gboolean cancel)

{ gint x, y; - grab_keyboard(FALSE); - grab_pointer(FALSE, FALSE, OB_CURSOR_NONE); + ungrab_keyboard(); + ungrab_pointer(); popup_hide(popup);