xwindow_translate_for_gravity: Change instead of set argument
Previously, this function overwrote the value of its argument with the result. After this change, the function merely changes the given variable by the calculated argument. Thus, the old behaviour is achieved by setting the variable to zero before the call, which all callers already did. However, for most callers this change means that a temporary variable can be removed and instead xwindow_translate_for_gravity() will directly change the target variable. No change in behaviour intended. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
bbc4fba3c0
commit
21b7b29630
8
event.c
8
event.c
|
@ -345,17 +345,13 @@ event_handle_configurerequest(xcb_configure_request_event_t *ev)
|
|||
|
||||
if(ev->value_mask & XCB_CONFIG_WINDOW_X)
|
||||
{
|
||||
int16_t diff = 0;
|
||||
geometry.x = ev->x;
|
||||
xwindow_translate_for_gravity(c->size_hints.win_gravity, deco_left, 0, deco_right, 0, &diff, NULL);
|
||||
geometry.x += diff;
|
||||
xwindow_translate_for_gravity(c->size_hints.win_gravity, deco_left, 0, deco_right, 0, &geometry.x, NULL);
|
||||
}
|
||||
if(ev->value_mask & XCB_CONFIG_WINDOW_Y)
|
||||
{
|
||||
int16_t diff = 0;
|
||||
geometry.y = ev->y;
|
||||
xwindow_translate_for_gravity(c->size_hints.win_gravity, 0, deco_top, 0, deco_bottom, NULL, &diff);
|
||||
geometry.y += diff;
|
||||
xwindow_translate_for_gravity(c->size_hints.win_gravity, 0, deco_top, 0, deco_bottom, NULL, &geometry.y);
|
||||
}
|
||||
if(ev->value_mask & XCB_CONFIG_WINDOW_WIDTH)
|
||||
{
|
||||
|
|
|
@ -1387,12 +1387,9 @@ border_width_callback(client_t *c, uint16_t old_width, uint16_t new_width)
|
|||
{
|
||||
area_t geometry = c->geometry;
|
||||
int16_t diff = new_width - old_width;
|
||||
int16_t diff_x = 0, diff_y = 0;
|
||||
xwindow_translate_for_gravity(c->size_hints.win_gravity,
|
||||
diff, diff, diff, diff,
|
||||
&diff_x, &diff_y);
|
||||
geometry.x += diff_x;
|
||||
geometry.y += diff_y;
|
||||
&geometry.x, &geometry.y);
|
||||
/* inform client about changes */
|
||||
client_resize_do(c, geometry);
|
||||
}
|
||||
|
@ -2870,13 +2867,10 @@ titlebar_resize(lua_State *L, int cidx, client_t *c, client_titlebar_t bar, int
|
|||
|
||||
if(c->size_hints.flags & XCB_ICCCM_SIZE_HINT_P_WIN_GRAVITY)
|
||||
{
|
||||
int16_t diff_x = 0, diff_y = 0;
|
||||
xwindow_translate_for_gravity(c->size_hints.win_gravity,
|
||||
diff_left, diff_top,
|
||||
diff_right, diff_bottom,
|
||||
&diff_x, &diff_y);
|
||||
geometry.x += diff_x;
|
||||
geometry.y += diff_y;
|
||||
&geometry.x, &geometry.y);
|
||||
}
|
||||
|
||||
c->titlebar[bar].size = size;
|
||||
|
|
|
@ -400,8 +400,8 @@ xwindow_set_shape(xcb_window_t win, int width, int height, enum xcb_shape_sk_t k
|
|||
* \param change_height_before The window height difference that will be applied.
|
||||
* \param change_width_after The window width difference that will be applied.
|
||||
* \param change_height_after The window height difference that will be applied.
|
||||
* \param dx On return, this will be set to the amount the pixel has to be moved.
|
||||
* \param dy On return, this will be set to the amount the pixel has to be moved.
|
||||
* \param dx On return, this will be changed by the amount the pixel has to be moved.
|
||||
* \param dy On return, this will be changed by the amount the pixel has to be moved.
|
||||
*/
|
||||
void xwindow_translate_for_gravity(xcb_gravity_t gravity, int16_t change_width_before, int16_t change_height_before,
|
||||
int16_t change_width_after, int16_t change_height_after, int16_t *dx, int16_t *dy)
|
||||
|
@ -449,9 +449,9 @@ void xwindow_translate_for_gravity(xcb_gravity_t gravity, int16_t change_width_b
|
|||
}
|
||||
|
||||
if (dx)
|
||||
*dx = x;
|
||||
*dx += x;
|
||||
if (dy)
|
||||
*dy = y;
|
||||
*dy += y;
|
||||
}
|
||||
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
Loading…
Reference in New Issue