Remove packed attribute from Rect
Fixes #3785 -- the issue where the Travis build failed because of gcc's -Werror=address-of-packed-member. Adds an equality function to avoid relying on memcmp().
This commit is contained in:
parent
39a65166c4
commit
a73510026f
|
@ -159,7 +159,7 @@ struct Rect {
|
|||
uint32_t y;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
} __attribute__((packed));
|
||||
};
|
||||
|
||||
/**
|
||||
* Stores the reserved pixels on each screen edge read from a
|
||||
|
|
|
@ -64,6 +64,7 @@ int max(int a, int b);
|
|||
bool rect_contains(Rect rect, uint32_t x, uint32_t y);
|
||||
Rect rect_add(Rect a, Rect b);
|
||||
Rect rect_sub(Rect a, Rect b);
|
||||
bool rect_equals(Rect a, Rect b);
|
||||
|
||||
/**
|
||||
* Returns true if the name consists of only digits.
|
||||
|
|
|
@ -469,7 +469,7 @@ static void cmd_resize_floating(I3_CMD, const char *way, const char *direction_s
|
|||
|
||||
/* Did we actually resize anything or did the size constraints prevent us?
|
||||
* If we could not resize, exit now to not move the window. */
|
||||
if (memcmp(&old_rect, &(floating_con->rect), sizeof(Rect)) == 0) {
|
||||
if (rect_equals(old_rect, floating_con->rect)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -322,11 +322,10 @@ void floating_enable(Con *con, bool automatic) {
|
|||
|
||||
DLOG("Original rect: (%d, %d) with %d x %d\n", con->rect.x, con->rect.y, con->rect.width, con->rect.height);
|
||||
DLOG("Geometry = (%d, %d) with %d x %d\n", con->geometry.x, con->geometry.y, con->geometry.width, con->geometry.height);
|
||||
Rect zero = {0, 0, 0, 0};
|
||||
nc->rect = con->geometry;
|
||||
/* If the geometry was not set (split containers), we need to determine a
|
||||
* sensible one by combining the geometry of all children */
|
||||
if (memcmp(&(nc->rect), &zero, sizeof(Rect)) == 0) {
|
||||
if (rect_equals(nc->rect, (Rect){0, 0, 0, 0})) {
|
||||
DLOG("Geometry not set, combining children\n");
|
||||
Con *child;
|
||||
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
|
||||
|
|
|
@ -141,8 +141,7 @@ static int json_end_map(void *ctx) {
|
|||
// Also set a size if none was supplied, otherwise the placeholder
|
||||
// window cannot be created as X11 requests with width=0 or
|
||||
// height=0 are invalid.
|
||||
const Rect zero = {0, 0, 0, 0};
|
||||
if (memcmp(&(json_node->rect), &zero, sizeof(Rect)) == 0) {
|
||||
if (rect_equals(json_node->rect, (Rect){0, 0, 0, 0})) {
|
||||
DLOG("Geometry not set, combining children\n");
|
||||
Con *child;
|
||||
TAILQ_FOREACH(child, &(json_node->nodes_head), nodes) {
|
||||
|
|
|
@ -279,7 +279,7 @@ void scratchpad_fix_resolution(void) {
|
|||
|
||||
Rect new_rect = __i3_output->rect;
|
||||
|
||||
if (memcmp(&old_rect, &new_rect, sizeof(Rect)) == 0) {
|
||||
if (rect_equals(new_rect, old_rect)) {
|
||||
DLOG("Scratchpad size unchanged.\n");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,10 @@ Rect rect_sub(Rect a, Rect b) {
|
|||
a.height - b.height};
|
||||
}
|
||||
|
||||
bool rect_equals(Rect a, Rect b) {
|
||||
return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns true if the name consists of only digits.
|
||||
*
|
||||
|
|
7
src/x.c
7
src/x.c
|
@ -251,8 +251,7 @@ void x_move_win(Con *src, Con *dest) {
|
|||
state_dest->con = state_src->con;
|
||||
state_src->con = NULL;
|
||||
|
||||
Rect zero = {0, 0, 0, 0};
|
||||
if (memcmp(&(state_dest->window_rect), &(zero), sizeof(Rect)) == 0) {
|
||||
if (rect_equals(state_dest->window_rect, (Rect){0, 0, 0, 0})) {
|
||||
memcpy(&(state_dest->window_rect), &(state_src->window_rect), sizeof(Rect));
|
||||
DLOG("COPYING RECT\n");
|
||||
}
|
||||
|
@ -929,7 +928,7 @@ void x_push_node(Con *con) {
|
|||
bool fake_notify = false;
|
||||
/* Set new position if rect changed (and if height > 0) or if the pixmap
|
||||
* needs to be recreated */
|
||||
if ((is_pixmap_needed && con->frame_buffer.id == XCB_NONE) || (memcmp(&(state->rect), &rect, sizeof(Rect)) != 0 &&
|
||||
if ((is_pixmap_needed && con->frame_buffer.id == XCB_NONE) || (!rect_equals(state->rect, rect) &&
|
||||
rect.height > 0)) {
|
||||
/* We first create the new pixmap, then render to it, set it as the
|
||||
* background and only afterwards change the window size. This reduces
|
||||
|
@ -1008,7 +1007,7 @@ void x_push_node(Con *con) {
|
|||
|
||||
/* dito, but for child windows */
|
||||
if (con->window != NULL &&
|
||||
memcmp(&(state->window_rect), &(con->window_rect), sizeof(Rect)) != 0) {
|
||||
!rect_equals(state->window_rect, con->window_rect)) {
|
||||
DLOG("setting window rect (%d, %d, %d, %d)\n",
|
||||
con->window_rect.x, con->window_rect.y, con->window_rect.width, con->window_rect.height);
|
||||
xcb_set_window_rect(conn, con->window->id, con->window_rect);
|
||||
|
|
Loading…
Reference in New Issue