]> git.sur5r.net Git - i3/i3/blobdiff - src/util.c
Bugfix: Use more precise floating point arithmetic (Thanks helgiks)
[i3/i3] / src / util.c
index 94a5e336b4dc31489efbc5080e499bd383c89fe1..149af2dae32d43f0ac25f7f0ffe05387c1a0c846 100644 (file)
@@ -352,10 +352,13 @@ void switch_layout_mode(xcb_connection_t *conn, Container *container, int mode)
                 if (container->mode == MODE_STACK || container->mode == MODE_TABBED)
                         goto after_stackwin;
 
-                /* When entering stacking mode, we need to open a window on which we can draw the
-                   title bars of the clients, it has height 1 because we don’t bother here with
-                   calculating the correct height - it will be adjusted when rendering anyways. */
-                Rect rect = {container->x, container->y, container->width, 1};
+                /* When entering stacking mode, we need to open a window on
+                 * which we can draw the title bars of the clients, it has
+                 * height 1 because we don’t bother here with calculating the
+                 * correct height - it will be adjusted when rendering anyways.
+                 * Also, we need to use max(width, 1) because windows cannot
+                 * be created with either width == 0 or height == 0. */
+                Rect rect = {container->x, container->y, max(container->width, 1), 1};
 
                 uint32_t mask = 0;
                 uint32_t values[2];
@@ -455,12 +458,13 @@ Client *get_matching_client(xcb_connection_t *conn, const char *window_classtitl
         }
 
         LOG("Getting clients for class \"%s\" / title \"%s\"\n", to_class, to_title);
-        for (int workspace = 0; workspace < num_workspaces; workspace++) {
-                if (workspaces[workspace].screen == NULL)
+        Workspace *ws;
+        TAILQ_FOREACH(ws, workspaces, workspaces) {
+                if (ws->screen == NULL)
                         continue;
 
                 Client *client;
-                SLIST_FOREACH(client, &(workspaces[workspace].focus_stack), focus_clients) {
+                SLIST_FOREACH(client, &(ws->focus_stack), focus_clients) {
                         LOG("Checking client with class=%s, name=%s\n", client->window_class, client->name);
                         if (!client_matches_class_name(client, to_class, to_title, to_title_ucs, to_title_ucs_len))
                                 continue;