merge r5782,r5785,r5786 from trunk
authorDana Jansens <danakj@orodu.net>
Sun, 22 Apr 2007 16:01:12 +0000 (16:01 +0000)
committerDana Jansens <danakj@orodu.net>
Sun, 22 Apr 2007 16:01:12 +0000 (16:01 +0000)
openbox/action.c
openbox/client.c
openbox/event.c
openbox/focus.c
openbox/grab.c
openbox/grab.h
openbox/keyboard.c
openbox/popup.c

index fc6f5a78292b2d9dffa8b1df44171079a271277d..5e42b68b224aa3d44a7acddb65f735f217c13228 100644 (file)
@@ -1042,7 +1042,7 @@ void action_run_list(GSList *acts, ObClient *c, ObFrameContext context,
            it won't work right unless we XUngrabKeyboard first,
            even though we grabbed the key/button Asychronously.
            e.g. "gnome-panel-control --main-menu" */
-        XUngrabKeyboard(ob_display, event_curtime);
+        grab_keyboard(FALSE);
     }
 
     for (it = acts; it; it = g_slist_next(it)) {
index e7af570150a7040868231c41851ef0f8fb889c54..86acafb11ae23cb31c4284f012b69347b53bcff7 100644 (file)
@@ -507,6 +507,8 @@ void client_unmanage(ObClient *self)
     g_assert(self != NULL);
 
     frame_hide(self->frame);
+    /* sync to send the hide to the server quickly, and to get back the enter
+       events */
     XSync(ob_display, FALSE);
 
     if (focus_client == self) {
index 871b158a491591210b716ff09eec73404725de67..ca60d6f3c592828d2351a4d624aa51c22a07c89a 100644 (file)
@@ -590,9 +590,9 @@ static void event_process(const XEvent *ec, gpointer data)
                                          NULL, g_direct_equal, NULL);
 
                 if (e->type == ButtonPress || e->type == ButtonRelease ||
-                    e->type == MotionNotify)
+                    e->type == MotionNotify) {
                     mouse_event(client, e);
-                else if (e->type == KeyPress) {
+                else if (e->type == KeyPress) {
                     keyboard_event((focus_cycle_target ? focus_cycle_target :
                                     (focus_hilite ? focus_hilite : client)),
                                    e);
@@ -762,6 +762,8 @@ static void event_handle_client(ObClient *client, XEvent *e)
             frame_adjust_state(client->frame);
             break;
         case OB_FRAME_CONTEXT_FRAME:
+            if (keyboard_interactively_grabbed())
+                break;
             if (config_focus_follow && config_focus_delay)
                 ob_main_loop_timeout_remove_data(ob_main_loop,
                                                  focus_delay_func,
@@ -803,6 +805,8 @@ static void event_handle_client(ObClient *client, XEvent *e)
             frame_adjust_state(client->frame);
             break;
         case OB_FRAME_CONTEXT_FRAME:
+            if (keyboard_interactively_grabbed())
+                break;
             if (e->xcrossing.mode == NotifyGrab ||
                 e->xcrossing.mode == NotifyUngrab)
             {
index 197948e98c286c619a01cbd24036d16d45aac0d3..ea3d4fab0d75eb37c7d0a6d451c772f4effa22ac 100644 (file)
@@ -328,10 +328,16 @@ static void popup_cycle(ObClient *c, gboolean show)
 void focus_cycle_draw_indicator()
 {
     if (!focus_cycle_target) {
+        XEvent e;
+
         XUnmapWindow(ob_display, focus_indicator.top.win);
         XUnmapWindow(ob_display, focus_indicator.left.win);
         XUnmapWindow(ob_display, focus_indicator.right.win);
         XUnmapWindow(ob_display, focus_indicator.bottom.win);
+
+        /* kill enter events cause by this unmapping */
+        XSync(ob_display, FALSE);
+        while (XCheckTypedEvent(ob_display, EnterNotify, &e));
     } else {
         /*
           if (focus_cycle_target)
index dfff9570e3c6dab1aa8a9e4e2590f7236fca58a9..b81254a3972626cb1e187cd5ae23e953a4b72613 100644 (file)
@@ -114,33 +114,6 @@ gboolean grab_pointer(gboolean grab, gboolean owner_events, ObCursor cur)
     return ret;
 }
 
-gboolean grab_pointer_window(gboolean grab, gboolean owner_events,
-                             ObCursor cur, Window win)
-{
-    gboolean ret = FALSE;
-
-    if (grab) {
-        if (pgrabs++ == 0) {
-            ret = XGrabPointer(ob_display, win, owner_events,
-                               GRAB_PTR_MASK,
-                               GrabModeAsync, GrabModeAsync, None,
-                               ob_cursor(cur),
-                               event_curtime) == Success;
-            if (!ret)
-                --pgrabs;
-            else
-                grab_time = event_curtime;
-        } else
-            ret = TRUE;
-    } else if (pgrabs > 0) {
-        if (--pgrabs == 0) {
-            XUngrabPointer(ob_display, ungrab_time());
-        }
-        ret = TRUE;
-    }
-    return ret;
-}
-
 gint grab_server(gboolean grab)
 {
     static guint sgrabs = 0;
@@ -181,7 +154,6 @@ void grab_shutdown(gboolean reconfig)
 
     while (grab_keyboard(FALSE));
     while (grab_pointer(FALSE, FALSE, OB_CURSOR_NONE));
-    while (grab_pointer_window(FALSE, FALSE, OB_CURSOR_NONE, None));
     while (grab_server(FALSE));
 }
 
index 9f2cf562f09353575000fc5eb8b08671666372e8..088d2d6c792f2691f9438ac6deb4472a5d128aca 100644 (file)
@@ -29,8 +29,6 @@ void grab_shutdown(gboolean reconfig);
 
 gboolean grab_keyboard(gboolean grab);
 gboolean grab_pointer(gboolean grab, gboolean owner_events, ObCursor cur);
-gboolean grab_pointer_window(gboolean grab, gboolean owner_events,
-                             ObCursor cur, Window win);
 gint grab_server(gboolean grab);
 
 gboolean grab_on_keyboard();
index 248fd1ce0dd4bdf682152a371476fe92b2e95b8e..ba4559551a3e00c127a2ec793e796e5e0bd42df4 100644 (file)
@@ -164,10 +164,8 @@ gboolean keyboard_interactive_grab(guint state, ObClient *client,
     g_assert(action->data.any.interactive);
 
     if (!interactive_states) {
-        if (!grab_keyboard(TRUE))
-            return FALSE;
-        if (!grab_pointer(TRUE, FALSE, OB_CURSOR_NONE)) {
-            grab_keyboard(FALSE);
+        if (!grab_keyboard(TRUE)) {
+            ob_debug("grab KEYBOARD failed\n");
             return FALSE;
         }
     }
@@ -195,7 +193,6 @@ void keyboard_interactive_end(ObInteractiveState *s,
 
     if (!interactive_states) {
         grab_keyboard(FALSE);
-        grab_pointer(FALSE, FALSE, OB_CURSOR_NONE);
         keyboard_reset_chains();
     }
 }
index e7fcbbe552acbf9c93a3e2f29dd3137f9fade101..ee44ed2352688d4a013598630ddb8f88a02e517b 100644 (file)
@@ -213,8 +213,14 @@ void popup_show(ObPopup *self, gchar *text)
 void popup_hide(ObPopup *self)
 {
     if (self->mapped) {
+        XEvent e;
+
         XUnmapWindow(ob_display, self->bg);
         self->mapped = FALSE;
+
+        /* kill enter events cause by this unmapping */
+        XSync(ob_display, FALSE);
+        while (XCheckTypedEvent(ob_display, EnterNotify, &e));
     }
 }