]> git.sur5r.net Git - i3/i3/commitdiff
Set WM_STATE_WITHDRAWN when unmapping, unmap windows when destroying (Thanks xeen)
authorMichael Stapelberg <michael@stapelberg.de>
Tue, 11 Aug 2009 10:16:10 +0000 (12:16 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Tue, 11 Aug 2009 10:16:10 +0000 (12:16 +0200)
Seems like java apps need it. Also, you probably want to use XToolkit,
when you have to work with java apps:

export AWT_TOOLKIT=XToolkit

include/client.h
src/client.c
src/commands.c
src/floating.c
src/handlers.c
src/manage.c
src/workspace.c

index 5d87b2ee4d5d8015b6354bd7afc6423f98af8d50..81cb5c6e4991eee79663eaddea1ba2a82db9e0f2 100644 (file)
@@ -85,4 +85,16 @@ bool client_is_floating(Client *client);
  */
 void client_change_border(xcb_connection_t *conn, Client *client, char border_type);
 
+/**
+ * Unmap the client, correctly setting any state which is needed.
+ *
+ */
+void client_unmap(xcb_connection_t *conn, Client *client);
+
+/**
+ * Map the client, correctly restoring any state needed.
+ *
+ */
+void client_map(xcb_connection_t *conn, Client *client);
+
 #endif
index 5ed5cf978a9caf201062fa9d2bbff3cb6ad5c771..a42698055c63f1849b6965abf4fe942183dbd957 100644 (file)
@@ -289,3 +289,28 @@ void client_change_border(xcb_connection_t *conn, Client *client, char border_ty
 
         redecorate_window(conn, client);
 }
+
+/*
+ * Unmap the client, correctly setting any state which is needed.
+ *
+ */
+void client_unmap(xcb_connection_t *conn, Client *client) {
+        /* Set WM_STATE_WITHDRAWN, it seems like Java apps need it */
+        long data[] = { XCB_WM_STATE_WITHDRAWN, XCB_NONE };
+        xcb_change_property(conn, XCB_PROP_MODE_REPLACE, client->child, atoms[WM_STATE], atoms[WM_STATE], 32, 2, data);
+
+        xcb_unmap_window(conn, client->frame);
+}
+
+/*
+ * Map the client, correctly restoring any state needed.
+ *
+ */
+void client_map(xcb_connection_t *conn, Client *client) {
+        /* Set WM_STATE_NORMAL because GTK applications don’t want to drag & drop if we don’t.
+         * Also, xprop(1) needs that to work. */
+        long data[] = { XCB_WM_STATE_NORMAL, XCB_NONE };
+        xcb_change_property(conn, XCB_PROP_MODE_REPLACE, client->child, atoms[WM_STATE], atoms[WM_STATE], 32, 2, data);
+
+        xcb_map_window(conn, client->frame);
+}
index f53e4335a1183bad9aa9284104d3ede934878780..6472d8604101e4d6e898fd2a0ddf733645998ab0 100644 (file)
@@ -530,7 +530,7 @@ static void move_floating_window_to_workspace(xcb_connection_t *conn, Client *cl
         /* If we’re moving it to an invisible screen, we need to unmap it */
         if (!workspace_is_visible(t_ws)) {
                 LOG("This workspace is not visible, unmapping\n");
-                xcb_unmap_window(conn, client->frame);
+                client_unmap(conn, client);
         } else {
                 /* If this is not the case, we move the window to a workspace
                  * which is on another screen, so we also need to adjust its
@@ -613,7 +613,7 @@ static void move_current_window_to_workspace(xcb_connection_t *conn, int workspa
         /* If we’re moving it to an invisible screen, we need to unmap it */
         if (!workspace_is_visible(to_container->workspace)) {
                 LOG("This workspace is not visible, unmapping\n");
-                xcb_unmap_window(conn, current_client->frame);
+                client_unmap(conn, current_client);
         } else {
                 if (current_client->fullscreen) {
                         LOG("Calling client_enter_fullscreen again\n");
index 70112b57051e48fd56495b2f863fa7a6e0f5f7c1..04d99f6c5a08d3f258bdc703a6e8481c7549fa57 100644 (file)
@@ -415,8 +415,8 @@ void floating_toggle_hide(xcb_connection_t *conn, Workspace *workspace) {
         LOG("floating_hidden is now: %d\n", workspace->floating_hidden);
         TAILQ_FOREACH(client, &(workspace->floating_clients), floating_clients) {
                 if (workspace->floating_hidden)
-                        xcb_unmap_window(conn, client->frame);
-                else xcb_map_window(conn, client->frame);
+                        client_unmap(conn, client);
+                else client_map(conn, client);
         }
 
         /* If we just unmapped all floating windows we should ensure that the focus
index 280750ba88e3f99fcd294c999fea204b3540bd6a..3c13b8c497df3f5c34e3a0a3bd94dcb7bb854869 100644 (file)
@@ -696,6 +696,9 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_noti
 
         LOG("child of 0x%08x.\n", client->frame);
         xcb_reparent_window(conn, client->child, root, 0, 0);
+
+        client_unmap(conn, client);
+
         xcb_destroy_window(conn, client->frame);
         xcb_flush(conn);
         table_remove(&by_parent, client->frame);
index 14c058fd26c5fd5ecf854079d95687c89c605741..a5a46237cb26f6033d3d2c3383e1f76c0e7b0880 100644 (file)
@@ -205,11 +205,6 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
         /* Yo dawg, I heard you like windows, so I create a window around your window… */
         new->frame = create_window(conn, framerect, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_CURSOR_LEFT_PTR, false, mask, values);
 
-        /* Set WM_STATE_NORMAL because GTK applications don’t want to drag & drop if we don’t.
-         * Also, xprop(1) needs that to work. */
-        long data[] = { XCB_WM_STATE_NORMAL, XCB_NONE };
-        xcb_change_property(conn, XCB_PROP_MODE_REPLACE, new->child, atoms[WM_STATE], atoms[WM_STATE], 32, 2, data);
-
         /* Put the client inside the save set. Upon termination (whether killed or normal exit
            does not matter) of the window manager, these clients will be correctly reparented
            to their most closest living ancestor (= cleanup) */
@@ -442,7 +437,7 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
         xcb_map_window(conn, child);
         if (map_frame) {
                 LOG("Mapping client\n");
-                xcb_map_window(conn, new->frame);
+                client_map(conn, new);
         }
         if (CUR_CELL->workspace->fullscreen_client == NULL && !new->dock) {
                 /* Focus the new window if we’re not in fullscreen mode and if it is not a dock window */
index d9925743b21204f81812ddf0d7d3b4724404057e..e89591a26d670b6722465c53e1f0a368775b58c7 100644 (file)
@@ -275,12 +275,12 @@ void workspace_map_clients(xcb_connection_t *conn, Workspace *ws) {
         /* Map all clients on the new workspace */
         FOR_TABLE(ws)
                 CIRCLEQ_FOREACH(client, &(ws->table[cols][rows]->clients), clients)
-                        xcb_map_window(conn, client->frame);
+                        client_map(conn, client);
 
         /* Map all floating clients */
         if (!ws->floating_hidden)
                 TAILQ_FOREACH(client, &(ws->floating_clients), floating_clients)
-                        xcb_map_window(conn, client->frame);
+                        client_map(conn, client);
 
         /* Map all stack windows, if any */
         struct Stack_Window *stack_win;
@@ -312,7 +312,7 @@ void workspace_unmap_clients(xcb_connection_t *conn, Workspace *u_ws) {
         FOR_TABLE(u_ws)
                 CIRCLEQ_FOREACH(client, &(u_ws->table[cols][rows]->clients), clients) {
                         LOG("unmapping normal client %p / %p / %p\n", client, client->frame, client->child);
-                        xcb_unmap_window(conn, client->frame);
+                        client_unmap(conn, client);
                         unmapped_clients++;
                 }
 
@@ -323,7 +323,7 @@ void workspace_unmap_clients(xcb_connection_t *conn, Workspace *u_ws) {
 
                 LOG("unmapping floating client %p / %p / %p\n", client, client->frame, client->child);
 
-                xcb_unmap_window(conn, client->frame);
+                client_unmap(conn, client);
                 unmapped_clients++;
         }