]> git.sur5r.net Git - i3/i3/commitdiff
Fix: Calculation of unoccupied space has to depend on current row/col
authorMichael Stapelberg <michael+git@stapelberg.de>
Mon, 23 Feb 2009 01:09:24 +0000 (02:09 +0100)
committerMichael Stapelberg <michael+git@stapelberg.de>
Mon, 23 Feb 2009 01:09:24 +0000 (02:09 +0100)
src/handlers.c
src/layout.c

index 21c509255cc4cea2cc8d95d690f93a10a89cbf30..9332bfbf8ba52a770e9ec71c697044d4d4ab9885 100644 (file)
@@ -337,10 +337,10 @@ int handle_windowname_change(void *data, xcb_connection_t *conn, uint8_t state,
  *
  */
 int handle_expose_event(void *data, xcb_connection_t *conn, xcb_expose_event_t *e) {
-        printf("handle_expose_event()\n");
         Client *client = table_get(byParent, e->window);
         if(!client || e->count != 0)
                 return 1;
+        printf("handle_expose_event()\n");
         decorate_window(conn, client);
         return 1;
 }
index f35f4d4c6fab3a138b9c342bbc5453e7e9882bb2..3b6caffa205f6c9b9b72d9dfb705576cc2b06ad0 100644 (file)
 #include "util.h"
 #include "xinerama.h"
 
+int get_unoccupied_x(Workspace *workspace, int row) {
+        int unoccupied = workspace->rect.width;
+        float default_factor_w = ((float)workspace->rect.width / (float)workspace->cols) / (float)workspace->rect.width;
+
+        printf("get_unoccupied_x(), starting with %d\n", unoccupied);
+
+        for (int cols = 0; cols < workspace->cols; cols++) {
+                printf("oh hai. wf[%d][%d] = %f\n", cols, row, workspace->table[cols][row]->width_factor);
+                if (workspace->table[cols][row]->width_factor == 0)
+                        unoccupied -= workspace->rect.width * default_factor_w;
+        }
+
+        printf("gots %d\n", unoccupied);
+        return unoccupied;
+}
+
 /*
  * For resizing containers (= cells), we need to know the space which is unoccupied by "default"
  * windows. The resized containers will be rendered relatively to this space, meaning that newly
  * created columns/rows after a container was resized will start with their normal size.
  *
  */
-Rect get_unoccupied_space(Workspace *workspace) {
+Rect get_unoccupied_space(Workspace *workspace, int col, int row) {
         printf("getting unoccupied space\n");
         float default_factor_w = ((float)workspace->rect.width / (float)workspace->cols) / (float)workspace->rect.width;
         float default_factor_h = (workspace->rect.height / workspace->rows) / workspace->rect.height;
@@ -272,9 +288,6 @@ void render_layout(xcb_connection_t *connection) {
                 printf("each of them therefore is %d px width and %d px height\n",
                                 width / r_ws->cols, height / r_ws->rows);
 
-                Rect space = get_unoccupied_space(r_ws);
-                printf("got %d / %d unoc space\n", space.width, space.height);
-
                 int xoffset[r_ws->rows];
                 int yoffset[r_ws->cols];
                 /* Initialize offsets */
@@ -297,7 +310,7 @@ void render_layout(xcb_connection_t *connection) {
                                 container->y = yoffset[cols];
                                 if (container->width_factor == 0)
                                         container->width = (width / r_ws->cols) * container->colspan;
-                                else container->width = space.width * container->width_factor;
+                                else container->width = get_unoccupied_x(r_ws, rows) * container->width_factor;
                                 container->height = (height / r_ws->rows) * container->rowspan;
 
                                 /* Render it */