diff options
author | Orestis Floros <orestisflo@gmail.com> | 2020-02-19 11:41:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-19 11:41:58 +0100 |
commit | 854885ea9d3649746480c84d8d5cc8140da7e89e (patch) | |
tree | 22dcf74fd7c0b133e24c8e9f721b57d4210c066e | |
parent | 1f0c628cde40cf87371481041b7197344e0417c6 (diff) | |
parent | 670c23600f30a5f0e417c0d3d256356c73e149b4 (diff) | |
download | i3-854885ea9d3649746480c84d8d5cc8140da7e89e.tar.gz i3-854885ea9d3649746480c84d8d5cc8140da7e89e.zip |
Merge pull request #3949 from xzfc/overlap
Sanitize window dimensions and handle decoration overlap
-rw-r--r-- | include/util.h | 1 | ||||
-rw-r--r-- | src/click.c | 2 | ||||
-rw-r--r-- | src/handlers.c | 4 | ||||
-rw-r--r-- | src/render.c | 4 | ||||
-rw-r--r-- | src/util.c | 6 |
5 files changed, 14 insertions, 3 deletions
diff --git a/include/util.h b/include/util.h index 68b3c68f..8459db10 100644 --- a/include/util.h +++ b/include/util.h @@ -65,6 +65,7 @@ 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); +Rect rect_sanitize_dimensions(Rect rect); /** * Returns true if the name consists of only digits. diff --git a/src/click.c b/src/click.c index e5dcfa92..19076252 100644 --- a/src/click.c +++ b/src/click.c @@ -361,7 +361,7 @@ int handle_button_press(xcb_button_press_event_t *event) { /* Check if the click was on the decoration of a child */ Con *child; - TAILQ_FOREACH (child, &(con->nodes_head), nodes) { + TAILQ_FOREACH_REVERSE (child, &(con->nodes_head), nodes_head, nodes) { if (!rect_contains(child->deco_rect, event->event_x, event->event_y)) continue; diff --git a/src/handlers.c b/src/handlers.c index 79e5329b..7926fec5 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -160,7 +160,7 @@ static void handle_enter_notify(xcb_enter_notify_event_t *event) { layout_t layout = (enter_child ? con->parent->layout : con->layout); if (layout == L_DEFAULT) { Con *child; - TAILQ_FOREACH (child, &(con->nodes_head), nodes) { + TAILQ_FOREACH_REVERSE (child, &(con->nodes_head), nodes_head, nodes) { if (rect_contains(child->deco_rect, event->event_x, event->event_y)) { LOG("using child %p / %s instead!\n", child, child->name); con = child; @@ -217,7 +217,7 @@ static void handle_motion_notify(xcb_motion_notify_event_t *event) { /* see over which rect the user is */ Con *current; - TAILQ_FOREACH (current, &(con->nodes_head), nodes) { + TAILQ_FOREACH_REVERSE (current, &(con->nodes_head), nodes_head, nodes) { if (!rect_contains(current->deco_rect, event->event_x, event->event_y)) continue; diff --git a/src/render.c b/src/render.c index 112268cc..40704f52 100644 --- a/src/render.c +++ b/src/render.c @@ -64,6 +64,8 @@ void render_con(Con *con) { inset->width -= (2 * con->border_width); inset->height -= (2 * con->border_width); + *inset = rect_sanitize_dimensions(*inset); + /* NB: We used to respect resize increment size hints for tiling * windows up until commit 0db93d9 here. However, since all terminal * emulators cope with ignoring the size hints in a better way than we @@ -121,6 +123,8 @@ void render_con(Con *con) { render_con_dockarea(con, child, ¶ms); } + child->rect = rect_sanitize_dimensions(child->rect); + DLOG("child at (%d, %d) with (%d x %d)\n", child->rect.x, child->rect.y, child->rect.width, child->rect.height); x_raise_con(child); @@ -53,6 +53,12 @@ Rect rect_sub(Rect a, Rect b) { a.height - b.height}; } +Rect rect_sanitize_dimensions(Rect rect) { + rect.width = (int32_t)rect.width <= 0 ? 1 : rect.width; + rect.height = (int32_t)rect.height <= 0 ? 1 : rect.height; + return rect; +} + bool rect_equals(Rect a, Rect b) { return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height; } |