summaryrefslogtreecommitdiff
path: root/openbox
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2007-05-13 23:30:52 +0000
committerDana Jansens <danakj@orodu.net>2007-05-13 23:30:52 +0000
commit9fcb2aa1d25ec9889b45d145939fb17160b1106a (patch)
treeb8ca781c16f637cf12cce61cd4aa7b38b9e1b9e9 /openbox
parent627125a6c6e6728de98aa813e353ec75bab7b54c (diff)
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
Diffstat (limited to 'openbox')
-rw-r--r--openbox/action.c4
-rw-r--r--openbox/grab.c13
-rw-r--r--openbox/grab.h11
-rw-r--r--openbox/keyboard.c4
-rw-r--r--openbox/menuframe.c10
-rw-r--r--openbox/moveresize.c11
6 files changed, 32 insertions, 21 deletions
diff --git a/openbox/action.c b/openbox/action.c
index 8c8064f8..cb703a66 100644
--- a/openbox/action.c
+++ b/openbox/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 @@ 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;
diff --git a/openbox/grab.c b/openbox/grab.c
index b6a7a939..ac91a6bc 100644
--- a/openbox/grab.c
+++ b/openbox/grab.c
@@ -67,7 +67,7 @@ gboolean grab_on_pointer()
return pgrabs > 0;
}
-gboolean grab_keyboard(gboolean grab)
+gboolean grab_keyboard_full(gboolean grab)
{
gboolean ret = FALSE;
@@ -92,7 +92,8 @@ gboolean grab_keyboard(gboolean grab)
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 @@ gboolean grab_pointer(gboolean grab, gboolean owner_events, ObCursor cur)
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));
}
diff --git a/openbox/grab.h b/openbox/grab.h
index 67dff212..8a654c8b 100644
--- a/openbox/grab.h
+++ b/openbox/grab.h
@@ -27,10 +27,17 @@
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();
diff --git a/openbox/keyboard.c b/openbox/keyboard.c
index 5cfd4571..b834046b 100644
--- a/openbox/keyboard.c
+++ b/openbox/keyboard.c
@@ -197,7 +197,7 @@ static void keyboard_interactive_end(guint state, gboolean cancel, Time time,
/* 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 @@ gboolean keyboard_interactive_grab(guint state, ObClient *client,
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);
diff --git a/openbox/menuframe.c b/openbox/menuframe.c
index c6dd02fa..68ea4949 100644
--- a/openbox/menuframe.c
+++ b/openbox/menuframe.c
@@ -914,10 +914,10 @@ static gboolean menu_frame_show(ObMenuFrame *self)
/* 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 @@ void menu_frame_hide(ObMenuFrame *self)
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);
diff --git a/openbox/moveresize.c b/openbox/moveresize.c
index 37c190d5..b5fe6cb0 100644
--- a/openbox/moveresize.c
+++ b/openbox/moveresize.c
@@ -187,10 +187,11 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr)
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);