]> Dogcows Code - chaz/openbox/blobdiff - openbox/event.c
yet MORE focus events reworkings. mozilla behaves now too. woot
[chaz/openbox] / openbox / event.c
index f140bfcf17056c386fab33a08d6b7bb6144ef4f7..b048e7e64e7e95babf6c08f0536386d9bb99df5a 100644 (file)
@@ -224,14 +224,15 @@ void event_process(XEvent *e)
         g_message("FocusIn on %lx mode %d detail %d", window,
                   e->xfocus.mode, e->xfocus.detail);
        if (e->xfocus.detail == NotifyInferior ||
-            e->xfocus.detail == NotifyAncestor ||
+            /*e->xfocus.detail == NotifyAncestor ||*/
             e->xfocus.detail > NotifyNonlinearVirtual) return;
-            g_message("FocusIn on %lx", window);*/
+            g_message("FocusIn on %lx", window);
         break;
     case FocusOut:
         g_message("FocusOut on %lx mode %d detail %d", window,
                   e->xfocus.mode, e->xfocus.detail);
-       if (e->xfocus.detail == NotifyInferior ||
+       if (e->xfocus.mode == NotifyGrab ||
+            e->xfocus.detail == NotifyInferior ||
             e->xfocus.detail == NotifyAncestor ||
             e->xfocus.detail > NotifyNonlinearVirtual) return;
 
@@ -243,10 +244,23 @@ void event_process(XEvent *e)
             if (XCheckTypedEvent(ob_display, FocusIn, &fi)) {
                event_process(&fi);
 
+                /* secret magic way of event_process telling us that no client
+                   was found for the FocusIn event.
+                   
+                   it should be noted!! that focus events of invalud types
+                   (the ones that cause a return in the FocusIn case above)
+                   will not cause this focus_fallback to be called. it will
+                   be assumed that focus is going someplace sane still, or
+                   there are more focus events coming to fix up the situation.
+                   this may not be perfect.. but its working! and focus events
+                   are too much headache to take that for granted. ktnx. ^_^
+                */
+                if (fi.xfocus.window == None)
+                    focus_fallback(FALSE);
                 if (fi.xfocus.window == e->xfocus.window)
                     return;
             } else
-                focus_set_client(NULL);
+                focus_fallback(FALSE);
         }
        break;
     case EnterNotify:
@@ -270,6 +284,8 @@ void event_process(XEvent *e)
        event_handle_root(e);
     else if (e->type == MapRequest)
        client_manage(window);
+    else if (e->type == FocusIn)
+       e->xfocus.window = None; /* says a client was found for the event! */
     else if (e->type == ConfigureRequest) {
        /* unhandled configure requests must be used to configure the
           window directly */
@@ -343,17 +359,21 @@ static void event_handle_client(Client *client, XEvent *e)
         engine_frame_adjust_focus(client->frame);
        break;
     case EnterNotify:
-        if (ob_state == State_Starting) {
-            /* move it to the top of the focus order */
-            guint desktop = client->desktop;
-            if (desktop == DESKTOP_ALL) desktop = screen_desktop;
-            focus_order[desktop] = g_list_remove(focus_order[desktop], client);
-            focus_order[desktop] = g_list_prepend(focus_order[desktop],client);
-        } else {
-            if (!config_get("focusFollowsMouse", Config_Bool, &focus_follow))
-                g_assert_not_reached();
-            if (focus_follow.bool)
-                client_focus(client);
+        if (client_normal(client)) {
+            if (ob_state == State_Starting) {
+                /* move it to the top of the focus order */
+                guint desktop = client->desktop;
+                if (desktop == DESKTOP_ALL) desktop = screen_desktop;
+                focus_order[desktop] = g_list_remove(focus_order[desktop],
+                                                     client);
+                focus_order[desktop] = g_list_prepend(focus_order[desktop],
+                                                      client);
+            } else {
+                if (!config_get("focusFollowsMouse",Config_Bool,&focus_follow))
+                    g_assert_not_reached();
+                if (focus_follow.bool)
+                    client_focus(client);
+            }
         }
         break;
     case ConfigureRequest:
@@ -513,7 +533,8 @@ static void event_handle_client(Client *client, XEvent *e)
            }
             if ((unsigned)e->xclient.data.l[0] < screen_num_desktops ||
                 (unsigned)e->xclient.data.l[0] == DESKTOP_ALL)
-                client_set_desktop(client, (unsigned)e->xclient.data.l[0]);
+                client_set_desktop(client, (unsigned)e->xclient.data.l[0],
+                                   FALSE);
        } else if (msgtype == prop_atoms.net_wm_state) {
            /* can't compress these */
            g_message("net_wm_state %s %ld %ld for 0x%lx",
This page took 0.029072 seconds and 4 git commands to generate.