mirror of
https://codeberg.org/dwl/dwl.git
synced 2025-10-27 02:04:14 +00:00
Allow centering the terminal
Adds a keybinding that toggles centering Alacritty horizontally when it's the only window, while still tiling multiple windows. This limits the width of long text making it easier to read, and avoids covering the wallpaper more than necessary. Replace the Alacritty app id if you use a different terminal.
This commit is contained in:
parent
960c32a7d8
commit
064f8f20dc
@ -127,6 +127,7 @@ static const Key keys[] = {
|
|||||||
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||||
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
||||||
|
{ MODKEY, XKB_KEY_z, togglecenter, {0} },
|
||||||
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
|
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
|
||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
|
||||||
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
||||||
|
|||||||
18
dwl.c
18
dwl.c
@ -125,6 +125,7 @@ typedef struct {
|
|||||||
unsigned int bw;
|
unsigned int bw;
|
||||||
uint32_t tags;
|
uint32_t tags;
|
||||||
int isfloating, isurgent, isfullscreen;
|
int isfloating, isurgent, isfullscreen;
|
||||||
|
bool centered;
|
||||||
uint32_t resize; /* configure serial of a pending resize */
|
uint32_t resize; /* configure serial of a pending resize */
|
||||||
} Client;
|
} Client;
|
||||||
|
|
||||||
@ -302,6 +303,7 @@ static void startdrag(struct wl_listener *listener, void *data);
|
|||||||
static void tag(const Arg *arg);
|
static void tag(const Arg *arg);
|
||||||
static void tagmon(const Arg *arg);
|
static void tagmon(const Arg *arg);
|
||||||
static void tile(Monitor *m);
|
static void tile(Monitor *m);
|
||||||
|
static void togglecenter(const Arg *arg);
|
||||||
static void togglefloating(const Arg *arg);
|
static void togglefloating(const Arg *arg);
|
||||||
static void togglefullscreen(const Arg *arg);
|
static void togglefullscreen(const Arg *arg);
|
||||||
static void toggletag(const Arg *arg);
|
static void toggletag(const Arg *arg);
|
||||||
@ -367,6 +369,8 @@ static struct wlr_box sgeom;
|
|||||||
static struct wl_list mons;
|
static struct wl_list mons;
|
||||||
static Monitor *selmon;
|
static Monitor *selmon;
|
||||||
|
|
||||||
|
static bool center;
|
||||||
|
|
||||||
/* global event handlers */
|
/* global event handlers */
|
||||||
static struct wl_listener cursor_axis = {.notify = axisnotify};
|
static struct wl_listener cursor_axis = {.notify = axisnotify};
|
||||||
static struct wl_listener cursor_button = {.notify = buttonpress};
|
static struct wl_listener cursor_button = {.notify = buttonpress};
|
||||||
@ -468,6 +472,8 @@ applyrules(Client *c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
wlr_scene_node_reparent(&c->scene->node, layers[c->isfloating ? LyrFloat : LyrTile]);
|
wlr_scene_node_reparent(&c->scene->node, layers[c->isfloating ? LyrFloat : LyrTile]);
|
||||||
|
if (!strcmp(appid, "Alacritty"))
|
||||||
|
c->centered = true;
|
||||||
setmon(c, mon, newtags);
|
setmon(c, mon, newtags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2376,6 +2382,11 @@ tile(Monitor *m)
|
|||||||
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
|
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
|
||||||
continue;
|
continue;
|
||||||
if (i < m->nmaster) {
|
if (i < m->nmaster) {
|
||||||
|
if (n == 1 && center && c->centered) {
|
||||||
|
resize(c, (struct wlr_box){.x = m->w.width / 4, .y = m->w.y,
|
||||||
|
.width = m->w.width / 2, .height = m->w.height - 2 * c->bw}, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw,
|
resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw,
|
||||||
.height = (m->w.height - my) / (MIN(n, m->nmaster) - i)}, 0);
|
.height = (m->w.height - my) / (MIN(n, m->nmaster) - i)}, 0);
|
||||||
my += c->geom.height;
|
my += c->geom.height;
|
||||||
@ -2388,6 +2399,13 @@ tile(Monitor *m)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
togglecenter(const Arg *arg)
|
||||||
|
{
|
||||||
|
center = !center;
|
||||||
|
tile(selmon);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
togglefloating(const Arg *arg)
|
togglefloating(const Arg *arg)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user