#include "history.h"
#include "monitor.h"
#include "query.h"
+#include "geometry.h"
#include "subscribe.h"
#include "settings.h"
#include "stack.h"
return;
}
- layout_t set_layout = d->layout;
+ layout_t last_layout = d->layout;
if (single_monocle && tiled_count(d->root) == 1) {
d->layout = LAYOUT_MONOCLE;
}
xcb_rectangle_t rect = m->rectangle;
- int wg = (gapless_monocle && d->layout == LAYOUT_MONOCLE ? 0 : d->window_gap);
- rect.x += m->left_padding + d->left_padding + wg;
- rect.y += m->top_padding + d->top_padding + wg;
- rect.width -= m->left_padding + d->left_padding + d->right_padding + m->right_padding + wg;
- rect.height -= m->top_padding + d->top_padding + d->bottom_padding + m->bottom_padding + wg;
+
+ if (!paddingless_monocle || d->layout != LAYOUT_MONOCLE) {
+ rect.x += m->left_padding + d->left_padding;
+ rect.y += m->top_padding + d->top_padding;
+ rect.width -= m->left_padding + d->left_padding + d->right_padding + m->right_padding;
+ rect.height -= m->top_padding + d->top_padding + d->bottom_padding + m->bottom_padding;
+ }
+
+ if (!gapless_monocle || d->layout != LAYOUT_MONOCLE) {
+ rect.x += d->window_gap;
+ rect.y += d->window_gap;
+ rect.width -= d->window_gap;
+ rect.height -= d->window_gap;
+ }
apply_layout(m, d, d->root, rect, rect);
- d->layout = set_layout;
+ d->layout = last_layout;
}
void apply_layout(monitor_t *m, desktop_t *d, node_t *n, xcb_rectangle_t rect, xcb_rectangle_t root_rect)
}
xcb_rectangle_t r;
+ xcb_rectangle_t cr = get_rectangle(d, n);
client_state_t s = n->client->state;
if (s == STATE_TILED || s == STATE_PSEUDO_TILED) {
int wg = (gapless_monocle && d->layout == LAYOUT_MONOCLE ? 0 : d->window_gap);
r = m->rectangle;
}
- window_move_resize(n->id, r.x, r.y, r.width, r.height);
+ if (!rect_eq(r, cr)) {
+ window_move_resize(n->id, r.x, r.y, r.width, r.height);
+ if (frozen_pointer->action == ACTION_NONE) {
+ put_status(SBSC_MASK_NODE_GEOMETRY, "node_geometry %s %s 0x%X %ux%u+%i+%i\n", m->name, d->name, n->id, r.width, r.height, r.x, r.y);
+ }
+ }
+
window_border_width(n->id, bw);
- if (frozen_pointer->action == ACTION_NONE) {
- put_status(SBSC_MASK_NODE_GEOMETRY, "node_geometry %s %s 0x%X %ux%u+%i+%i\n", m->name, d->name, n->id, r.width, r.height, r.x, r.y);
- }
} else {
xcb_rectangle_t first_rect;
xcb_rectangle_t second_rect;
if (n->vacant) {
continue;
}
- unsigned int n_area = node_area(NULL, d, n);
+ unsigned int n_area = node_area(d, n);
if (n_area > b_manual_area && (n->presel != NULL || !n->private)) {
b_manual = n;
b_manual_area = n_area;
p = f->parent;
}
if (f->presel == NULL && (f->private || private_count(f->parent) > 0)) {
- xcb_rectangle_t rect = get_rectangle(m, d, f);
+ xcb_rectangle_t rect = get_rectangle(d, f);
presel_dir(m, d, f, (rect.width >= rect.height ? DIR_EAST : DIR_SOUTH));
}
}
}
if (pointer_follows_focus) {
- center_pointer(get_rectangle(m, d, n));
+ center_pointer(get_rectangle(d, n));
}
}
}
node_t *nearest = NULL;
- direction_t dir2;
+ direction_t dir2 = DIR_NORTH;
xcb_point_t pt;
xcb_point_t pt2;
- get_side_handle(m, d, n, dir, &pt);
+ get_side_handle(d, n, dir, &pt);
get_opposite(dir, &dir2);
double ds = DBL_MAX;
coordinates_t ref = {m, d, n};
continue;
}
- get_side_handle(m, d, a, dir2, &pt2);
+ get_side_handle(d, a, dir2, &pt2);
double ds2 = distance(pt, pt2);
if (ds2 < ds) {
ds = ds2;
}
}
-unsigned int node_area(monitor_t *m, desktop_t *d, node_t *n)
+unsigned int node_area(desktop_t *d, node_t *n)
{
if (n == NULL) {
return 0;
}
- xcb_rectangle_t rect = get_rectangle(m, d, n);
- return rect.width * rect.height;
+ return area(get_rectangle(d, n));
}
int tiled_count(node_t *n)
if (f->vacant || !node_matches(&loc, &ref, sel)) {
continue;
}
- unsigned int f_area = node_area(m, d, f);
+ unsigned int f_area = node_area(d, f);
if (f_area > b_area) {
b = f;
b_area = f_area;
free(n);
ewmh_update_client_list(false);
+ ewmh_update_client_list(true);
if (d->focus != last_focus) {
if (d == mon->desk) {
a.y <= b.y && (a.y + a.height) >= (b.y + b.height));
}
-xcb_rectangle_t get_rectangle(monitor_t *m, desktop_t *d, node_t *n)
+xcb_rectangle_t get_rectangle(desktop_t *d, node_t *n)
{
client_t *c = n->client;
if (c != NULL) {
- switch (c->state) {
- case STATE_TILED:
- case STATE_PSEUDO_TILED:
- return c->tiled_rectangle;
- break;
- case STATE_FLOATING:
- return c->floating_rectangle;
- break;
- case STATE_FULLSCREEN:
- default:
- return m != NULL ? m->rectangle : (xcb_rectangle_t) {0, 0, screen_width, screen_height};
- break;
- }
+ xcb_get_geometry_reply_t *g = xcb_get_geometry_reply(dpy, xcb_get_geometry(dpy, n->id), NULL);
+ if (g != NULL) {
+ xcb_rectangle_t rect = (xcb_rectangle_t) {g->x, g->y, g->width, g->height};
+ free(g);
+ return rect;
+ } else {
+ return (xcb_rectangle_t) {0, 0, screen_width, screen_height};
+ }
} else {
int wg = (d == NULL ? 0 : (gapless_monocle && d->layout == LAYOUT_MONOCLE ? 0 : d->window_gap));
xcb_rectangle_t rect = n->rectangle;
}
}
-void get_side_handle(monitor_t *m, desktop_t *d, node_t *n, direction_t dir, xcb_point_t *pt)
+void get_side_handle(desktop_t *d, node_t *n, direction_t dir, xcb_point_t *pt)
{
- xcb_rectangle_t rect = get_rectangle(m, d, n);
+ xcb_rectangle_t rect = get_rectangle(d, n);
switch (dir) {
case DIR_EAST: