]> git.sur5r.net Git - i3/i3/commitdiff
Bugfix: Correctly use base_width/base_height and size increment hints, correctly...
authorMichael Stapelberg <michael@stapelberg.de>
Sun, 23 Aug 2009 19:49:38 +0000 (21:49 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Sat, 29 Aug 2009 09:08:58 +0000 (11:08 +0200)
include/data.h
src/handlers.c
src/layout.c
src/xcb.c

index 440c9a8f70c4ebdb590d2745895dad676d672220..ec95613fb830697f699bf8b611e255f14a02cb28 100644 (file)
@@ -346,6 +346,9 @@ struct Client {
         int proportional_height;
         int proportional_width;
 
+        int base_height;
+        int base_width;
+
         /** contains the minimum increment size as specified for the window
          * (in pixels). */
         int width_increment;
index 2f98f019a673f8bc834e0385c6cbae5a1faf4f36..d5fb06c66fafa1fd11e0086ba9715c20aed5f761 100644 (file)
@@ -1017,13 +1017,9 @@ int handle_normal_hints(void *data, xcb_connection_t *conn, uint8_t state, xcb_w
                         client->width_increment = size_hints.width_inc;
                 if (size_hints.height_inc > 0)
                         client->height_increment = size_hints.height_inc;
-        }
 
-        /* If no aspect ratio was set or if it was invalid, we ignore the hints */
-        if (!(size_hints.flags & XCB_SIZE_HINT_P_ASPECT) ||
-            (size_hints.min_aspect_num <= 0) ||
-            (size_hints.min_aspect_den <= 0)) {
-                return 1;
+                resize_client(conn, client);
+                xcb_flush(conn);
         }
 
         int base_width = 0, base_height = 0;
@@ -1039,6 +1035,16 @@ int handle_normal_hints(void *data, xcb_connection_t *conn, uint8_t state, xcb_w
                 base_height = size_hints.min_height;
         }
 
+        client->base_width = base_width;
+        client->base_height = base_height;
+
+        /* If no aspect ratio was set or if it was invalid, we ignore the hints */
+        if (!(size_hints.flags & XCB_SIZE_HINT_P_ASPECT) ||
+            (size_hints.min_aspect_num <= 0) ||
+            (size_hints.min_aspect_den <= 0)) {
+                return 1;
+        }
+
         double width = client->rect.width - base_width;
         double height = client->rect.height - base_height;
         /* Convert numerator/denominator to a double */
index 1d58097d9d4133ae6807a30a50b175de20cff242..409b9651008d3ab4e76137c5424692c40854c634 100644 (file)
@@ -26,6 +26,7 @@
 #include "layout.h"
 #include "client.h"
 #include "floating.h"
+#include "handlers.h"
 
 /*
  * Updates *destination with new_value and returns true if it was changed or false
@@ -288,14 +289,14 @@ void resize_client(xcb_connection_t *conn, Client *client) {
 
         if (client->height_increment > 1) {
                 int old_height = rect->height;
-                rect->height = ((int)(rect->height / client->height_increment) * client->height_increment) + 1;
+                rect->height -= (rect->height - client->base_height) % client->height_increment;
                 LOG("Lost %d pixel due to client's height_increment (%d px)\n",
                     old_height - rect->height, client->height_increment);
         }
 
         if (client->width_increment > 1) {
                 int old_width = rect->width;
-                rect->width = ((int)(rect->width / client->width_increment) * client->width_increment) + 1;
+                rect->width -= (rect->width - client->base_width) % client->width_increment;
                 LOG("Lost %d pixel due to client's width_increment (%d px)\n",
                     old_width - rect->width, client->width_increment);
         }
@@ -308,6 +309,13 @@ void resize_client(xcb_connection_t *conn, Client *client) {
          * This is necessary to inform the client of its position relative to the root window,
          * not relative to its frame (as done in the configure_notify_event by the x server). */
         fake_absolute_configure_notify(conn, client);
+
+        /* Force redrawing after resizing the window because any now lost
+         * pixels could contain old garbage. */
+        xcb_expose_event_t generated;
+        generated.window = client->frame;
+        generated.count = 0;
+        handle_expose_event(NULL, conn, &generated);
 }
 
 /*
index 4ed2f1aaf52e0b07adda377f449480bbe8dc6881..7ec4aa2cbe55aef313d6d3416c77a19546ca8565 100644 (file)
--- a/src/xcb.c
+++ b/src/xcb.c
@@ -193,8 +193,8 @@ void fake_absolute_configure_notify(xcb_connection_t *conn, Client *client) {
 
         absolute.x = client->rect.x + client->child_rect.x;
         absolute.y = client->rect.y + client->child_rect.y;
-        absolute.width = client->rect.width - (2 * client->child_rect.x);
-        absolute.height = client->rect.height - client->child_rect.y - 1;
+        absolute.width = client->child_rect.width;
+        absolute.height = client->child_rect.height;
 
         fake_configure_notify(conn, absolute, client->child);
 }