add xcb_set_window_rect which configures a window according to a Rect
This commit is contained in:
parent
7caf98dd18
commit
6f72970ece
@ -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 predict_text_width(xcb_connection_t *conn, const char *font_pattern, char *text,
|
||||||
int length);
|
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
|
#endif
|
||||||
|
25
src/client.c
25
src/client.c
@ -164,32 +164,23 @@ void client_enter_fullscreen(xcb_connection_t *conn, Client *client) {
|
|||||||
workspace->fullscreen_client = client;
|
workspace->fullscreen_client = client;
|
||||||
LOG("Entering fullscreen mode...\n");
|
LOG("Entering fullscreen mode...\n");
|
||||||
/* We just entered fullscreen mode, let’s configure the window */
|
/* We just entered fullscreen mode, let’s configure the window */
|
||||||
uint32_t mask = XCB_CONFIG_WINDOW_X |
|
Rect r = workspace->rect;
|
||||||
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};
|
|
||||||
|
|
||||||
DLOG("child itself will be at %dx%d with size %dx%d\n",
|
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) */
|
/* Child’s coordinates are relative to the parent (=frame) */
|
||||||
values[0] = 0;
|
r.x = 0;
|
||||||
values[1] = 0;
|
r.y = 0;
|
||||||
xcb_configure_window(conn, client->child, mask, values);
|
xcb_set_window_rect(conn, client->child, r);
|
||||||
|
|
||||||
/* Raise the window */
|
/* 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);
|
xcb_configure_window(conn, client->frame, XCB_CONFIG_WINDOW_STACK_MODE, values);
|
||||||
|
|
||||||
Rect child_rect = workspace->rect;
|
fake_configure_notify(conn, r, client->child);
|
||||||
child_rect.x = child_rect.y = 0;
|
|
||||||
fake_configure_notify(conn, child_rect, client->child);
|
|
||||||
|
|
||||||
xcb_flush(conn);
|
xcb_flush(conn);
|
||||||
}
|
}
|
||||||
|
13
src/layout.c
13
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("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);
|
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_set_window_rect(conn, client->frame, client->rect);
|
||||||
XCB_CONFIG_WINDOW_X |
|
|
||||||
XCB_CONFIG_WINDOW_Y |
|
|
||||||
XCB_CONFIG_WINDOW_WIDTH |
|
|
||||||
XCB_CONFIG_WINDOW_HEIGHT,
|
|
||||||
&(client->rect.x));
|
|
||||||
|
|
||||||
/* Adjust the position of the child inside its frame.
|
/* Adjust the position of the child inside its frame.
|
||||||
* The coordinates of the child are relative to its frame, we
|
* The coordinates of the child are relative to its frame, we
|
||||||
* add a border of 2 pixel to each value */
|
* 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);
|
Rect *rect = &(client->child_rect);
|
||||||
switch (container_mode(client->container, true)) {
|
switch (container_mode(client->container, true)) {
|
||||||
case MODE_STACK:
|
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);
|
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).
|
/* 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,
|
* This is necessary to inform the client of its position relative to the root window,
|
||||||
|
15
src/xcb.c
15
src/xcb.c
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* i3 - an improved dynamic tiling window manager
|
* i3 - an improved dynamic tiling window manager
|
||||||
*
|
*
|
||||||
* © 2009 Michael Stapelberg and contributors
|
* © 2009-2010 Michael Stapelberg and contributors
|
||||||
*
|
*
|
||||||
* See file LICENSE for license information.
|
* 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;
|
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));
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user