]> git.sur5r.net Git - i3/i3/commitdiff
Only send WM_TAKE_FOCUS when the client supports it in the protocols atom
authorMichael Stapelberg <michael@stapelberg.de>
Fri, 18 Mar 2011 16:26:19 +0000 (17:26 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Fri, 18 Mar 2011 16:26:19 +0000 (17:26 +0100)
Fixes launching xterm, for example

include/client.h
include/data.h
src/client.c
src/manage.c
src/util.c

index 45b8f4a7ef2d6525ca1cc6a0618955c2b470aef4..2381b8175cb5098a09e819afc30eff70a29e6f57 100644 (file)
@@ -31,6 +31,12 @@ void client_remove_from_container(xcb_connection_t *conn, Client *client,
  */
 void client_warp_pointer_into(xcb_connection_t *conn, Client *client);
 
+/**
+ * Returns true if the client supports the given protocol atom (like WM_DELETE_WINDOW)
+ *
+ */
+bool client_supports_protocol(xcb_connection_t *conn, Client *client, xcb_atom_t atom);
+
 /**
  * Kills the given window using WM_DELETE_WINDOW or xcb_kill_window
  *
index a8b31d3b3e81a66b54f17c2aea6f70ed2fd6962d..f4f6f971d22acdecd96746f50988b9250090646a 100644 (file)
@@ -444,6 +444,9 @@ struct Client {
          * one. Therefore, this flag is set when reparenting. */
         bool awaiting_useless_unmap;
 
+        /* Whether the client needs WM_TAKE_FOCUS */
+        bool needs_take_focus;
+
         /* XCB contexts */
         xcb_window_t frame;             /**< Our window: The frame around the
                                          * client */
index fc0d46ac084b4e1c12d0b0649e7dd2dbfe06ad02..af7ba4bbec651e927813c76f675d65defc1e410c 100644 (file)
@@ -74,7 +74,7 @@ void client_warp_pointer_into(xcb_connection_t *conn, Client *client) {
  * Returns true if the client supports the given protocol atom (like WM_DELETE_WINDOW)
  *
  */
-static bool client_supports_protocol(xcb_connection_t *conn, Client *client, xcb_atom_t atom) {
+bool client_supports_protocol(xcb_connection_t *conn, Client *client, xcb_atom_t atom) {
         xcb_get_property_cookie_t cookie;
         xcb_icccm_get_wm_protocols_reply_t protocols;
         bool result = false;
index 0b33034e5eafce7e0b34ad62c9b21691959ee29f..fe5338c01c3d6bec772ca06f85e0b21772471675 100644 (file)
@@ -477,6 +477,7 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
                 redecorate_window(conn, new);
         }
 
+        new->needs_take_focus = client_supports_protocol(conn, new, A_WM_TAKE_FOCUS);
         new->initialized = true;
 
         /* Check if the window already got the fullscreen hint set */
@@ -512,7 +513,8 @@ map:
                         }
                         if (new->container == CUR_CELL || client_is_floating(new)) {
                                 xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, new->child, XCB_CURRENT_TIME);
-                                take_focus(conn, new);
+                                if (new->needs_take_focus)
+                                        take_focus(conn, new);
                                 ewmh_update_active_window(new->child);
                         }
                 }
index ae5c86a004e8cf0bb8ddcbb4f4ebe765031483a3..e34140e3dbbde6e898235d61889e83c36258eb4b 100644 (file)
@@ -280,7 +280,8 @@ void set_focus(xcb_connection_t *conn, Client *client, bool set_anyways) {
         CLIENT_LOG(client);
         /* Set focus to the entered window, and flush xcb buffer immediately */
         xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, client->child, XCB_CURRENT_TIME);
-        take_focus(conn, client);
+        if (client->needs_take_focus)
+                take_focus(conn, client);
         ewmh_update_active_window(client->child);
         //xcb_warp_pointer(conn, XCB_NONE, client->child, 0, 0, 0, 0, 10, 10);