Merge pull request #3787 from orestisfl/rect

Remove packed attribute from Rect
This commit is contained in:
Ingo Bürk 2019-09-03 09:59:34 +02:00 committed by GitHub
commit 0e73396d28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 13 additions and 11 deletions

View File

@ -159,7 +159,7 @@ struct Rect {
uint32_t y; uint32_t y;
uint32_t width; uint32_t width;
uint32_t height; uint32_t height;
} __attribute__((packed)); };
/** /**
* Stores the reserved pixels on each screen edge read from a * Stores the reserved pixels on each screen edge read from a

View File

@ -64,6 +64,7 @@ int max(int a, int b);
bool rect_contains(Rect rect, uint32_t x, uint32_t y); bool rect_contains(Rect rect, uint32_t x, uint32_t y);
Rect rect_add(Rect a, Rect b); Rect rect_add(Rect a, Rect b);
Rect rect_sub(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. * Returns true if the name consists of only digits.

View File

@ -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? /* 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 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; return;
} }

View File

@ -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("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); 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; nc->rect = con->geometry;
/* If the geometry was not set (split containers), we need to determine a /* If the geometry was not set (split containers), we need to determine a
* sensible one by combining the geometry of all children */ * 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"); DLOG("Geometry not set, combining children\n");
Con *child; Con *child;
TAILQ_FOREACH(child, &(con->nodes_head), nodes) { TAILQ_FOREACH(child, &(con->nodes_head), nodes) {

View File

@ -141,8 +141,7 @@ static int json_end_map(void *ctx) {
// Also set a size if none was supplied, otherwise the placeholder // Also set a size if none was supplied, otherwise the placeholder
// window cannot be created as X11 requests with width=0 or // window cannot be created as X11 requests with width=0 or
// height=0 are invalid. // height=0 are invalid.
const Rect zero = {0, 0, 0, 0}; if (rect_equals(json_node->rect, (Rect){0, 0, 0, 0})) {
if (memcmp(&(json_node->rect), &zero, sizeof(Rect)) == 0) {
DLOG("Geometry not set, combining children\n"); DLOG("Geometry not set, combining children\n");
Con *child; Con *child;
TAILQ_FOREACH(child, &(json_node->nodes_head), nodes) { TAILQ_FOREACH(child, &(json_node->nodes_head), nodes) {

View File

@ -279,7 +279,7 @@ void scratchpad_fix_resolution(void) {
Rect new_rect = __i3_output->rect; 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"); DLOG("Scratchpad size unchanged.\n");
return; return;
} }

View File

@ -53,6 +53,10 @@ Rect rect_sub(Rect a, Rect b) {
a.height - b.height}; 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. * Returns true if the name consists of only digits.
* *

View File

@ -251,8 +251,7 @@ void x_move_win(Con *src, Con *dest) {
state_dest->con = state_src->con; state_dest->con = state_src->con;
state_src->con = NULL; state_src->con = NULL;
Rect zero = {0, 0, 0, 0}; if (rect_equals(state_dest->window_rect, (Rect){0, 0, 0, 0})) {
if (memcmp(&(state_dest->window_rect), &(zero), sizeof(Rect)) == 0) {
memcpy(&(state_dest->window_rect), &(state_src->window_rect), sizeof(Rect)); memcpy(&(state_dest->window_rect), &(state_src->window_rect), sizeof(Rect));
DLOG("COPYING RECT\n"); DLOG("COPYING RECT\n");
} }
@ -929,7 +928,7 @@ void x_push_node(Con *con) {
bool fake_notify = false; bool fake_notify = false;
/* Set new position if rect changed (and if height > 0) or if the pixmap /* Set new position if rect changed (and if height > 0) or if the pixmap
* needs to be recreated */ * 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)) { rect.height > 0)) {
/* We first create the new pixmap, then render to it, set it as the /* We first create the new pixmap, then render to it, set it as the
* background and only afterwards change the window size. This reduces * 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 */ /* dito, but for child windows */
if (con->window != NULL && 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", 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); 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); xcb_set_window_rect(conn, con->window->id, con->window_rect);