diff --git a/common/swindow.c b/common/swindow.c index f4a67cb3d..9df068665 100644 --- a/common/swindow.c +++ b/common/swindow.c @@ -121,4 +121,33 @@ simplewindow_resize(simple_window_t *sw, unsigned int w, unsigned int h) xcb_free_pixmap(sw->connection, d); } +/** Move and resize a window in one call. + * \param sw The simple window to move and resize. + * \param x The new x coordinate. + * \param y The new y coordinate. + * \param w The new width. + * \param h The new height. + */ +void +simplewindow_moveresize(simple_window_t *sw, int x, int y, + unsigned int w, unsigned int h) +{ + const uint32_t moveresize_win_vals[] = { x, y, w, h }; + xcb_pixmap_t d; + xcb_screen_t *s = xcb_aux_get_screen(sw->connection, sw->phys_screen); + + sw->geometry.x = x; + sw->geometry.y = y; + sw->geometry.width = w; + sw->geometry.height = h; + d = sw->pixmap; + sw->pixmap = xcb_generate_id(sw->connection); + xcb_create_pixmap(sw->connection, s->root_depth, sw->pixmap, s->root, w, h); + xcb_configure_window(sw->connection, sw->window, + XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y + | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, + moveresize_win_vals); + xcb_free_pixmap(sw->connection, d); +} + // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/common/swindow.h b/common/swindow.h index c7765d960..0e4befd72 100644 --- a/common/swindow.h +++ b/common/swindow.h @@ -62,21 +62,7 @@ simplewindow_delete(simple_window_t **sw) void simplewindow_move(simple_window_t *, int, int); void simplewindow_resize(simple_window_t *, unsigned int, unsigned int); - -/** Move and resize a window in one call. - * \param sw The simple window to move and resize. - * \param x The new x coordinate. - * \param y The new y coordinate. - * \param w The new width. - * \param h The new height. - */ -static inline void -simplewindow_move_resize(simple_window_t *sw, int x, int y, - unsigned int w, unsigned int h) -{ - simplewindow_move(sw, x, y); - simplewindow_resize(sw, w, h); -} +void simplewindow_moveresize(simple_window_t *, int, int, unsigned int, unsigned int); /** Refresh the window content by copying its pixmap data to its window. * \param sw The simple window to refresh. diff --git a/titlebar.c b/titlebar.c index de8f7b680..bfb7fdb15 100644 --- a/titlebar.c +++ b/titlebar.c @@ -168,11 +168,11 @@ titlebar_update_geometry_floating(client_t *c) x_offset = (c->geometry.width - width) / 2; break; } - simplewindow_move_resize(c->titlebar->sw, - c->geometry.x + x_offset, - c->geometry.y - c->titlebar->sw->geometry.height, - width, - c->titlebar->sw->geometry.height); + simplewindow_moveresize(c->titlebar->sw, + c->geometry.x + x_offset, + c->geometry.y - c->titlebar->sw->geometry.height, + width, + c->titlebar->sw->geometry.height); break; case Bottom: if(c->titlebar->width) @@ -190,11 +190,11 @@ titlebar_update_geometry_floating(client_t *c) x_offset = (c->geometry.width - width) / 2; break; } - simplewindow_move_resize(c->titlebar->sw, - c->geometry.x + x_offset, - c->geometry.y + c->geometry.height + 2 * c->border, - width, - c->titlebar->sw->geometry.height); + simplewindow_moveresize(c->titlebar->sw, + c->geometry.x + x_offset, + c->geometry.y + c->geometry.height + 2 * c->border, + width, + c->titlebar->sw->geometry.height); break; case Left: if(c->titlebar->width) @@ -212,11 +212,11 @@ titlebar_update_geometry_floating(client_t *c) y_offset = (c->geometry.height - width) / 2; break; } - simplewindow_move_resize(c->titlebar->sw, - c->geometry.x - c->titlebar->sw->geometry.width, - c->geometry.y + y_offset, - c->titlebar->sw->geometry.width, - width); + simplewindow_moveresize(c->titlebar->sw, + c->geometry.x - c->titlebar->sw->geometry.width, + c->geometry.y + y_offset, + c->titlebar->sw->geometry.width, + width); break; case Right: if(c->titlebar->width) @@ -234,11 +234,11 @@ titlebar_update_geometry_floating(client_t *c) y_offset = (c->geometry.height - width) / 2; break; } - simplewindow_move_resize(c->titlebar->sw, - c->geometry.x + c->geometry.width + 2 * c->border, - c->geometry.y + y_offset, - c->titlebar->sw->geometry.width, - width); + simplewindow_moveresize(c->titlebar->sw, + c->geometry.x + c->geometry.width + 2 * c->border, + c->geometry.y + y_offset, + c->titlebar->sw->geometry.width, + width); break; } titlebar_draw(c); @@ -277,11 +277,11 @@ titlebar_update_geometry(client_t *c, area_t geometry) x_offset = (geometry.width - width) / 2; break; } - simplewindow_move_resize(c->titlebar->sw, - geometry.x + x_offset, - geometry.y, - width, - c->titlebar->sw->geometry.height); + simplewindow_moveresize(c->titlebar->sw, + geometry.x + x_offset, + geometry.y, + width, + c->titlebar->sw->geometry.height); break; case Bottom: if(c->titlebar->width) @@ -299,12 +299,12 @@ titlebar_update_geometry(client_t *c, area_t geometry) x_offset = (geometry.width - width) / 2; break; } - simplewindow_move_resize(c->titlebar->sw, - geometry.x + x_offset, - geometry.y + geometry.height - - c->titlebar->sw->geometry.height + 2 * c->border, - width, - c->titlebar->sw->geometry.height); + simplewindow_moveresize(c->titlebar->sw, + geometry.x + x_offset, + geometry.y + geometry.height + - c->titlebar->sw->geometry.height + 2 * c->border, + width, + c->titlebar->sw->geometry.height); break; case Left: if(!c->titlebar->width) @@ -322,11 +322,11 @@ titlebar_update_geometry(client_t *c, area_t geometry) y_offset = (geometry.height - width) / 2; break; } - simplewindow_move_resize(c->titlebar->sw, - geometry.x, - geometry.y + y_offset, - c->titlebar->sw->geometry.width, - width); + simplewindow_moveresize(c->titlebar->sw, + geometry.x, + geometry.y + y_offset, + c->titlebar->sw->geometry.width, + width); break; case Right: if(c->titlebar->width) @@ -344,12 +344,12 @@ titlebar_update_geometry(client_t *c, area_t geometry) y_offset = (geometry.height - width) / 2; break; } - simplewindow_move_resize(c->titlebar->sw, - geometry.x + geometry.width - - c->titlebar->sw->geometry.width + 2 * c->border, - geometry.y + y_offset, - c->titlebar->sw->geometry.width, - width); + simplewindow_moveresize(c->titlebar->sw, + geometry.x + geometry.width + - c->titlebar->sw->geometry.width + 2 * c->border, + geometry.y + y_offset, + c->titlebar->sw->geometry.width, + width); break; }