From: Michael Stapelberg Date: Sun, 28 Feb 2010 19:35:30 +0000 (+0100) Subject: add xcb_set_window_rect which configures a window according to a Rect X-Git-Tag: 3.e~6^2~138 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6f72970ece75a12913d2009e6f02946073772ab1;p=i3%2Fi3 add xcb_set_window_rect which configures a window according to a Rect --- diff --git a/include/xcb.h b/include/xcb.h index d4ac33a3..78e1373a 100644 --- a/include/xcb.h +++ b/include/xcb.h @@ -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 diff --git a/src/client.c b/src/client.c index 3b747f54..1ca35dc7 100644 --- a/src/client.c +++ b/src/client.c @@ -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); } diff --git a/src/layout.c b/src/layout.c index 182870df..19babe2f 100644 --- a/src/layout.c +++ b/src/layout.c @@ -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, diff --git a/src/xcb.c b/src/xcb.c index f7835d3a..fd01391e 100644 --- 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)); +}