]> git.sur5r.net Git - i3/i3/commitdiff
add xcb_set_window_rect which configures a window according to a Rect
authorMichael Stapelberg <michael@stapelberg.de>
Sun, 28 Feb 2010 19:35:30 +0000 (20:35 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Sun, 28 Feb 2010 19:35:30 +0000 (20:35 +0100)
include/xcb.h
src/client.c
src/layout.c
src/xcb.c

index d4ac33a3adbfc0326a9cf31ca3d2dc6ea13a0ae2..78e1373a964cc86cf15645e0a29f55184ca63b7a 100644 (file)
@@ -164,4 +164,10 @@ void cached_pixmap_prepare(xcb_connection_t *conn, struct Cached_Pixmap *pixmap)
 int predict_text_width(xcb_connection_t *conn, const char *font_pattern, char *text,
                        int length);
 
+/**
+ * Configures the given window to have the size/position specified by given rect
+ *
+ */
+void xcb_set_window_rect(xcb_connection_t *conn, xcb_window_t window, Rect r);
+
 #endif
index 3b747f54dffd5a34e51b5918b4055109279dfa4f..1ca35dc7cd35b4e8bd2fb34ac9f5165d998b9b1b 100644 (file)
@@ -164,32 +164,23 @@ void client_enter_fullscreen(xcb_connection_t *conn, Client *client) {
         workspace->fullscreen_client = client;
         LOG("Entering fullscreen mode...\n");
         /* We just entered fullscreen mode, let’s configure the window */
-        uint32_t mask = XCB_CONFIG_WINDOW_X |
-                        XCB_CONFIG_WINDOW_Y |
-                        XCB_CONFIG_WINDOW_WIDTH |
-                        XCB_CONFIG_WINDOW_HEIGHT;
-        uint32_t values[4] = {workspace->rect.x,
-                              workspace->rect.y,
-                              workspace->rect.width,
-                              workspace->rect.height};
+        Rect r = workspace->rect;
 
         DLOG("child itself will be at %dx%d with size %dx%d\n",
-                        values[0], values[1], values[2], values[3]);
+                        r.x, r.y, r.width, r.height);
 
-        xcb_configure_window(conn, client->frame, mask, values);
+        xcb_set_window_rect(conn, client->frame, r);
 
         /* Child’s coordinates are relative to the parent (=frame) */
-        values[0] = 0;
-        values[1] = 0;
-        xcb_configure_window(conn, client->child, mask, values);
+        r.x = 0;
+        r.y = 0;
+        xcb_set_window_rect(conn, client->child, r);
 
         /* Raise the window */
-        values[0] = XCB_STACK_MODE_ABOVE;
+        uint32_t values[] = { XCB_STACK_MODE_ABOVE };
         xcb_configure_window(conn, client->frame, XCB_CONFIG_WINDOW_STACK_MODE, values);
 
-        Rect child_rect = workspace->rect;
-        child_rect.x = child_rect.y = 0;
-        fake_configure_notify(conn, child_rect, client->child);
+        fake_configure_notify(conn, r, client->child);
 
         xcb_flush(conn);
 }
index 182870df70b6a9f8c8d3f60e023ec7f6753437e6..19babe2fd5ca21f9a1d72fa2f0adab0904611113 100644 (file)
@@ -246,20 +246,11 @@ void resize_client(xcb_connection_t *conn, Client *client) {
 
         DLOG("frame 0x%08x needs to be pushed to %dx%d\n", client->frame, client->rect.x, client->rect.y);
         DLOG("resizing client 0x%08x to %d x %d\n", client->frame, client->rect.width, client->rect.height);
-        xcb_configure_window(conn, client->frame,
-                        XCB_CONFIG_WINDOW_X |
-                        XCB_CONFIG_WINDOW_Y |
-                        XCB_CONFIG_WINDOW_WIDTH |
-                        XCB_CONFIG_WINDOW_HEIGHT,
-                        &(client->rect.x));
+        xcb_set_window_rect(conn, client->frame, client->rect);
 
         /* Adjust the position of the child inside its frame.
          * The coordinates of the child are relative to its frame, we
          * add a border of 2 pixel to each value */
-        uint32_t mask = XCB_CONFIG_WINDOW_X |
-                        XCB_CONFIG_WINDOW_Y |
-                        XCB_CONFIG_WINDOW_WIDTH |
-                        XCB_CONFIG_WINDOW_HEIGHT;
         Rect *rect = &(client->child_rect);
         switch (container_mode(client->container, true)) {
                 case MODE_STACK:
@@ -330,7 +321,7 @@ void resize_client(xcb_connection_t *conn, Client *client) {
 
         DLOG("child will be at %dx%d with size %dx%d\n", rect->x, rect->y, rect->width, rect->height);
 
-        xcb_configure_window(conn, client->child, mask, &(rect->x));
+        xcb_set_window_rect(conn, client->child, *rect);
 
         /* After configuring a child window we need to fake a configure_notify_event (see ICCCM 4.2.3).
          * This is necessary to inform the client of its position relative to the root window,
index f7835d3abffd9fea00fa0d790c23d778d113a064..fd01391e4255830aae87890a6c45a367485ffb92 100644 (file)
--- a/src/xcb.c
+++ b/src/xcb.c
@@ -3,7 +3,7 @@
  *
  * i3 - an improved dynamic tiling window manager
  *
- * © 2009 Michael Stapelberg and contributors
+ * © 2009-2010 Michael Stapelberg and contributors
  *
  * See file LICENSE for license information.
  *
@@ -375,3 +375,16 @@ int predict_text_width(xcb_connection_t *conn, const char *font_pattern, char *t
 
         return width;
 }
+
+/*
+ * Configures the given window to have the size/position specified by given rect
+ *
+ */
+void xcb_set_window_rect(xcb_connection_t *conn, xcb_window_t window, Rect r) {
+        xcb_configure_window(conn, window,
+                             XCB_CONFIG_WINDOW_X |
+                             XCB_CONFIG_WINDOW_Y |
+                             XCB_CONFIG_WINDOW_WIDTH |
+                             XCB_CONFIG_WINDOW_HEIGHT,
+                             &(r.x));
+}