swindow: do not resize if nothing to do

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-06-18 13:50:50 +02:00
parent 95c8e05c4d
commit 1a31d49b3d
2 changed files with 45 additions and 28 deletions

View File

@ -105,21 +105,24 @@ simplewindow_move(simple_window_t *sw, int x, int y)
* \param h New height. * \param h New height.
*/ */
void void
simplewindow_resize(simple_window_t *sw, unsigned int w, unsigned int h) simplewindow_resize(simple_window_t *sw, int w, int h)
{ {
xcb_screen_t *s = xutil_screen_get(sw->connection, sw->phys_screen); xcb_screen_t *s = xutil_screen_get(sw->connection, sw->phys_screen);
const uint32_t resize_win_vals[] = { w, h }; uint32_t resize_win_vals[2];
xcb_pixmap_t d; xcb_pixmap_t d;
sw->geometry.width = w; if(w > 0 && h > 0 && (sw->geometry.width != w || sw->geometry.height != h))
sw->geometry.height = h; {
d = sw->pixmap; sw->geometry.width = resize_win_vals[0] = w;
sw->pixmap = xcb_generate_id(sw->connection); sw->geometry.height = resize_win_vals[1] = h;
xcb_create_pixmap(sw->connection, s->root_depth, sw->pixmap, s->root, w, h); d = sw->pixmap;
xcb_configure_window(sw->connection, sw->window, sw->pixmap = xcb_generate_id(sw->connection);
XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, xcb_create_pixmap(sw->connection, s->root_depth, sw->pixmap, s->root, w, h);
resize_win_vals); xcb_configure_window(sw->connection, sw->window,
xcb_free_pixmap(sw->connection, d); XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
resize_win_vals);
xcb_free_pixmap(sw->connection, d);
}
} }
/** Move and resize a window in one call. /** Move and resize a window in one call.
@ -130,25 +133,39 @@ simplewindow_resize(simple_window_t *sw, unsigned int w, unsigned int h)
* \param h The new height. * \param h The new height.
*/ */
void void
simplewindow_moveresize(simple_window_t *sw, int x, int y, simplewindow_moveresize(simple_window_t *sw, int x, int y, int w, int h)
unsigned int w, unsigned int h)
{ {
const uint32_t moveresize_win_vals[] = { x, y, w, h }; uint32_t moveresize_win_vals[4], mask_vals = 0;
xcb_pixmap_t d; xcb_pixmap_t d;
xcb_screen_t *s = xutil_screen_get(sw->connection, sw->phys_screen); xcb_screen_t *s = xutil_screen_get(sw->connection, sw->phys_screen);
sw->geometry.x = x; if(sw->geometry.x != x || sw->geometry.y != y)
sw->geometry.y = y; {
sw->geometry.width = w; sw->geometry.x = moveresize_win_vals[0] = x;
sw->geometry.height = h; sw->geometry.y = moveresize_win_vals[1] = y;
d = sw->pixmap; mask_vals |= XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y;
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, if(sw->geometry.width != w || sw->geometry.height != h)
XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y {
| XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, if(mask_vals)
moveresize_win_vals); {
xcb_free_pixmap(sw->connection, d); sw->geometry.width = moveresize_win_vals[2] = w;
sw->geometry.height = moveresize_win_vals[3] = h;
}
else
{
sw->geometry.width = moveresize_win_vals[0] = w;
sw->geometry.height = moveresize_win_vals[1] = h;
}
mask_vals |= XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
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_free_pixmap(sw->connection, d);
}
xcb_configure_window(sw->connection, sw->window, mask_vals, moveresize_win_vals);
} }
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View File

@ -61,8 +61,8 @@ simplewindow_delete(simple_window_t **sw)
} }
void simplewindow_move(simple_window_t *, int, int); void simplewindow_move(simple_window_t *, int, int);
void simplewindow_resize(simple_window_t *, unsigned int, unsigned int); void simplewindow_resize(simple_window_t *, int, int);
void simplewindow_moveresize(simple_window_t *, int, int, unsigned int, unsigned int); void simplewindow_moveresize(simple_window_t *, int, int, int, int);
/** Refresh the window content by copying its pixmap data to its window. /** Refresh the window content by copying its pixmap data to its window.
* \param sw The simple window to refresh. * \param sw The simple window to refresh.