Merge branch 'stachelbeere1248/patched/minimalborders' into stachelbeere1248/fullpatched

This commit is contained in:
Stachelbeere1248 2025-02-17 21:07:35 +01:00
commit 27da3bbbf4
2 changed files with 71 additions and 6 deletions

View file

@ -7,6 +7,7 @@
static const int sloppyfocus = 1; /* focus follows mouse */ static const int sloppyfocus = 1; /* focus follows mouse */
static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */ static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */
static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int borderpx = 1; /* border pixel of windows */
static const int draw_minimal_borders = 1; /* merge adjacent borders */
static const float rootcolor[] = COLOR(0x222222ff); static const float rootcolor[] = COLOR(0x222222ff);
static const float bordercolor[] = COLOR(0x444444ff); static const float bordercolor[] = COLOR(0x444444ff);
static const float focuscolor[] = COLOR(0x005577ff); static const float focuscolor[] = COLOR(0x005577ff);

76
dwl.c
View file

@ -109,6 +109,7 @@ typedef struct Monitor Monitor;
typedef struct { typedef struct {
/* Must keep these three elements in this order */ /* Must keep these three elements in this order */
unsigned int type; /* XDGShell or X11* */ unsigned int type; /* XDGShell or X11* */
int interact;
struct wlr_box geom; /* layout-relative, includes border */ struct wlr_box geom; /* layout-relative, includes border */
Monitor *mon; Monitor *mon;
struct wlr_scene_tree *scene; struct wlr_scene_tree *scene;
@ -341,7 +342,8 @@ static void rendermon(struct wl_listener *listener, void *data);
static void requestdecorationmode(struct wl_listener *listener, void *data); static void requestdecorationmode(struct wl_listener *listener, void *data);
static void requeststartdrag(struct wl_listener *listener, void *data); static void requeststartdrag(struct wl_listener *listener, void *data);
static void requestmonstate(struct wl_listener *listener, void *data); static void requestmonstate(struct wl_listener *listener, void *data);
static void resize(Client *c, struct wlr_box geo, int interact); static void resizeapply(Client *c, struct wlr_box geo, int interact);
static void resizenoapply(Client *c, struct wlr_box geo, int interact);
static void run(char *startup_cmd); static void run(char *startup_cmd);
static void setcursor(struct wl_listener *listener, void *data); static void setcursor(struct wl_listener *listener, void *data);
static void setcursorshape(struct wl_listener *listener, void *data); static void setcursorshape(struct wl_listener *listener, void *data);
@ -437,6 +439,7 @@ static Monitor *selmon;
static struct zdwl_ipc_manager_v2_interface dwl_manager_implementation = {.release = dwl_ipc_manager_release, .get_output = dwl_ipc_manager_get_output}; static struct zdwl_ipc_manager_v2_interface dwl_manager_implementation = {.release = dwl_ipc_manager_release, .get_output = dwl_ipc_manager_get_output};
static struct zdwl_ipc_output_v2_interface dwl_output_implementation = {.release = dwl_ipc_output_release, .set_tags = dwl_ipc_output_set_tags, .set_layout = dwl_ipc_output_set_layout, .set_client_tags = dwl_ipc_output_set_client_tags}; static struct zdwl_ipc_output_v2_interface dwl_output_implementation = {.release = dwl_ipc_output_release, .set_tags = dwl_ipc_output_set_tags, .set_layout = dwl_ipc_output_set_layout, .set_client_tags = dwl_ipc_output_set_client_tags};
static void (*resize)(Client *c, struct wlr_box geo, int interact) = resizeapply;
#ifdef XWAYLAND #ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data); static void activatex11(struct wl_listener *listener, void *data);
@ -514,6 +517,35 @@ applyrules(Client *c)
setmon(c, mon, newtags); setmon(c, mon, newtags);
} }
void
applyminimalborders(Client *c, Monitor *m)
{
struct wlr_box geom = c->geom;
geom.x -= borderpx;
geom.width += borderpx;
geom.y -= borderpx;
geom.height += borderpx;
if (geom.x < m->w.x) {
geom.x += borderpx;
geom.width -= borderpx;
}
if (geom.x + geom.width > m->w.width - (int)borderpx) {
geom.width -= borderpx;
}
if (geom.y < m->w.y) {
geom.y += borderpx;
geom.height -= borderpx;
}
if (geom.y + geom.height > m->w.height - (int)borderpx) {
geom.height -= borderpx;
}
resize(c, geom, 0);
}
void void
arrange(Monitor *m) arrange(Monitor *m)
{ {
@ -548,8 +580,28 @@ arrange(Monitor *m)
: c->scene->node.parent); : c->scene->node.parent);
} }
if (m->lt[m->sellt]->arrange) if (m->lt[m->sellt]->arrange) {
m->lt[m->sellt]->arrange(m); if (draw_minimal_borders) {
int save_width = m->w.width;
int save_height = m->w.height;
m->w.width += borderpx;
m->w.height += borderpx;
resize = resizenoapply;
m->lt[m->sellt]->arrange(m);
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
continue;
if (draw_minimal_borders)
applyminimalborders(c, m);
resizeapply(c, c->geom, c->interact);
}
m->w.width = save_width;
m->w.height = save_height;
resize = resizeapply;
} else {
m->lt[m->sellt]->arrange(m);
}
}
motionnotify(0, NULL, 0, 0, 0, 0); motionnotify(0, NULL, 0, 0, 0, 0);
checkidleinhibitor(NULL); checkidleinhibitor(NULL);
} }
@ -2269,8 +2321,13 @@ pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy,
struct timespec now; struct timespec now;
if (surface != seat->pointer_state.focused_surface && if (surface != seat->pointer_state.focused_surface &&
sloppyfocus && time && c && !client_is_unmanaged(c)) sloppyfocus && time && c && !client_is_unmanaged(c)) {
focusclient(c, 0); if (c->isfloating || c->isfullscreen) {
focusclient(c, 0);
} else {
focusclient(c, 1);
}
}
/* If surface is NULL, clear pointer focus */ /* If surface is NULL, clear pointer focus */
if (!surface) { if (!surface) {
@ -2403,7 +2460,7 @@ requestmonstate(struct wl_listener *listener, void *data)
} }
void void
resize(Client *c, struct wlr_box geo, int interact) resizeapply(Client *c, struct wlr_box geo, int interact)
{ {
struct wlr_box *bbox; struct wlr_box *bbox;
struct wlr_box clip; struct wlr_box clip;
@ -2435,6 +2492,13 @@ resize(Client *c, struct wlr_box geo, int interact)
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip); wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
} }
void
resizenoapply(Client *c, struct wlr_box geo, int interact)
{
c->geom = geo;
c->interact = interact;
}
void void
run(char *startup_cmd) run(char *startup_cmd)
{ {