]> git.sur5r.net Git - i3/i3/commitdiff
Bugfix: Don’t mess up x/y coordinates in configurerequests for floating windows
authorMichael Stapelberg <michael@stapelberg.de>
Thu, 11 Mar 2010 22:34:29 +0000 (23:34 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Thu, 11 Mar 2010 22:34:29 +0000 (23:34 +0100)
This was the cause for ticket #93, which actually has a false
conclusion for the reason of this bug.

This code needs to be refactored.

src/handlers.c
testcases/t/12-floating-resize.t

index 37ae0e54b10dd6dea74e5cb5b891f7da13f3cbdc..b43cc4f3f29a7cdffbfb368dde12c515ffafdf0d 100644 (file)
@@ -365,11 +365,31 @@ int handle_configure_request(void *prophs, xcb_connection_t *conn, xcb_configure
         if (client_is_floating(client)) {
                 i3Font *font = load_font(conn, config.font);
                 int mode = (client->container != NULL ? client->container->mode : MODE_DEFAULT);
+                /* TODO: refactor this code. we need a function to translate
+                 * coordinates of child_rect/rect. */
 
-                if (event->value_mask & XCB_CONFIG_WINDOW_X)
-                        client->rect.x = event->x;
-                if (event->value_mask & XCB_CONFIG_WINDOW_Y)
-                        client->rect.y = event->y;
+                if (event->value_mask & XCB_CONFIG_WINDOW_X) {
+                        if (mode == MODE_STACK || mode == MODE_TABBED) {
+                                client->rect.x = event->x - 2;
+                        } else {
+                                if (client->titlebar_position == TITLEBAR_OFF && client->borderless)
+                                        client->rect.x = event->x;
+                                else if (client->titlebar_position == TITLEBAR_OFF && !client->borderless)
+                                        client->rect.x = event->x - 1;
+                                else client->rect.x = event->x - 2;
+                        }
+                }
+                if (event->value_mask & XCB_CONFIG_WINDOW_Y) {
+                        if (mode == MODE_STACK || mode == MODE_TABBED) {
+                                client->rect.y = event->y - 2;
+                        } else {
+                                if (client->titlebar_position == TITLEBAR_OFF && client->borderless)
+                                        client->rect.y = event->y;
+                                else if (client->titlebar_position == TITLEBAR_OFF && !client->borderless)
+                                        client->rect.y = event->y - 1;
+                                else client->rect.y = event->y - font->height - 2 - 2;
+                        }
+                }
                 if (event->value_mask & XCB_CONFIG_WINDOW_WIDTH) {
                         if (mode == MODE_STACK || mode == MODE_TABBED) {
                                 client->rect.width = event->width + 2 + 2;
index 034205ecf22b57a2c77b3c3d996dd69e391c3c46..d908d345b0066b3f261553be8aa4cf8749ab517d 100644 (file)
@@ -4,7 +4,7 @@
 # the workspace to be empty).
 # TODO: skip it by default?
 
-use Test::More tests => 16;
+use Test::More tests => 17;
 use Test::Deep;
 use X11::XCB qw(:all);
 use Data::Dumper;
@@ -47,6 +47,13 @@ isa_ok($window, 'X11::XCB::Window');
 $window->map;
 sleep 0.25;
 
+# See if configurerequests cause window movements (they should not)
+my ($a, $t) = $window->rect;
+$window->rect(X11::XCB::Rect->new(x => $a->x, y => $a->y, width => $a->width, height => $a->height));
+
+sleep 0.25;
+my ($na, $nt) = $window->rect;
+is_deeply($na, $a, 'Rects are equal after configurerequest');
 
 sub test_resize {
     $window->rect(X11::XCB::Rect->new(x => 0, y => 0, width => 100, height => 100));