Compare commits
6 Commits
d436530ed3
...
89d740ee89
| Author | SHA1 | Date |
|---|---|---|
|
|
89d740ee89 | |
|
|
4dd9d502cf | |
|
|
c86e057c2c | |
|
|
f69b91e548 | |
|
|
6503a474b0 | |
|
|
d90e548ebc |
2
Makefile
2
Makefile
|
|
@ -16,7 +16,7 @@ LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(LIBS)
|
|||
all: dwl
|
||||
dwl: dwl.o util.o dwl-ipc-unstable-v2-protocol.o
|
||||
$(CC) dwl.o util.o dwl-ipc-unstable-v2-protocol.o $(LDLIBS) $(LDFLAGS) $(DWLCFLAGS) -o $@
|
||||
dwl.o: dwl.c config.mk config.h client.h xdg-shell-protocol.h wlr-layer-shell-unstable-v1-protocol.h dwl-ipc-unstable-v2-protocol.h
|
||||
dwl.o: dwl.c env.c config.mk config.h client.h xdg-shell-protocol.h wlr-layer-shell-unstable-v1-protocol.h dwl-ipc-unstable-v2-protocol.h
|
||||
util.o: util.c util.h
|
||||
dwl-ipc-unstable-v2-protocol.o: dwl-ipc-unstable-v2-protocol.h
|
||||
|
||||
|
|
|
|||
13
config.def.h
13
config.def.h
|
|
@ -1,9 +1,11 @@
|
|||
/* appearance */
|
||||
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 unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static const float bordercolor[] = {0.5, 0.5, 0.5, 1.0};
|
||||
static const float focuscolor[] = {1.0, 0.0, 0.0, 1.0};
|
||||
static const int smartborders = 1;
|
||||
static unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static float rootcolor[] = {0.3, 0.3, 0.3, 1.0};
|
||||
static float bordercolor[] = {0.5, 0.5, 0.5, 1.0};
|
||||
static float focuscolor[] = {1.0, 0.0, 0.0, 1.0};
|
||||
/* To conform the xdg-protocol, set the alpha to zero to restore the old behavior */
|
||||
static const float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0};
|
||||
|
||||
|
|
@ -17,6 +19,8 @@ static const char *const autostart[] = {
|
|||
#define TAGCOUNT (9)
|
||||
static const int tagcount = TAGCOUNT;
|
||||
|
||||
static const int hide_type = 1;
|
||||
|
||||
static const Rule rules[] = {
|
||||
/* app_id title tags mask isfloating monitor */
|
||||
/* examples:
|
||||
|
|
@ -116,11 +120,10 @@ static const char *menucmd[] = { "bemenu-run", NULL };
|
|||
static const Key keys[] = {
|
||||
/* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */
|
||||
/* modifier key function argument */
|
||||
|
||||
|
||||
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
|
||||
{ MODKEY, XKB_KEY_b, togglebar, {0}},
|
||||
{ MODKEY, XKB_KEY_r, regions, SHCMD("grim -g \"$(slurp)\"") },
|
||||
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
|
||||
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
||||
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
|
||||
|
|
|
|||
176
dwl.c
176
dwl.c
|
|
@ -95,6 +95,7 @@ typedef struct {
|
|||
const Arg arg;
|
||||
} Button;
|
||||
|
||||
typedef struct Pertag Pertag;
|
||||
typedef struct Monitor Monitor;
|
||||
typedef struct {
|
||||
/* Must keep these three elements in this order */
|
||||
|
|
@ -193,6 +194,7 @@ struct Monitor {
|
|||
struct wlr_box w; /* window area, layout-relative */
|
||||
struct wl_list layers[4]; /* LayerSurface::link */
|
||||
const Layout *lt[2];
|
||||
Pertag *pertag;
|
||||
unsigned int seltags;
|
||||
unsigned int sellt;
|
||||
uint32_t tagset[2];
|
||||
|
|
@ -283,6 +285,7 @@ static Client *focustop(Monitor *m);
|
|||
static void fullscreennotify(struct wl_listener *listener, void *data);
|
||||
static void handlesig(int signo);
|
||||
static size_t getunusedtag(void);
|
||||
static void hidecursor(int hide);
|
||||
static void incnmaster(const Arg *arg);
|
||||
static void inputdevice(struct wl_listener *listener, void *data);
|
||||
static int keybinding(uint32_t mods, xkb_keysym_t sym);
|
||||
|
|
@ -309,7 +312,7 @@ static void quit(const Arg *arg);
|
|||
static void restartdwl(const Arg *arg);
|
||||
static void rendermon(struct wl_listener *listener, void *data);
|
||||
static void requeststartdrag(struct wl_listener *listener, void *data);
|
||||
static void resize(Client *c, struct wlr_box geo, int interact);
|
||||
static void resize(Client *c, struct wlr_box geo, int interact, int draw_borders);
|
||||
static void run(char *startup_cmd);
|
||||
static void setcursor(struct wl_listener *listener, void *data);
|
||||
static void setfloating(Client *c, int floating);
|
||||
|
|
@ -342,6 +345,7 @@ static Monitor *xytomon(double x, double y);
|
|||
static void xytonode(double x, double y, struct wlr_surface **psurface,
|
||||
Client **pc, LayerSurface **pl, double *nx, double *ny);
|
||||
static void zoom(const Arg *arg);
|
||||
static void regions(const Arg *arg);
|
||||
|
||||
/* variables */
|
||||
static const char broken[] = "broken";
|
||||
|
|
@ -375,6 +379,7 @@ static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr;
|
|||
|
||||
static struct wlr_cursor *cursor;
|
||||
static struct wlr_xcursor_manager *cursor_mgr;
|
||||
static int cursor_hidden;
|
||||
|
||||
static struct wlr_session_lock_manager_v1 *session_lock_mgr;
|
||||
static struct wlr_scene_rect *locked_bg;
|
||||
|
|
@ -439,9 +444,19 @@ static Atom netatom[NetLast];
|
|||
/* attempt to encapsulate suck into one file */
|
||||
#include "client.h"
|
||||
|
||||
#include "env.c"
|
||||
|
||||
static pid_t *autostart_pids;
|
||||
static size_t autostart_len;
|
||||
|
||||
struct Pertag {
|
||||
unsigned int curtag, prevtag; /* current and previous tag */
|
||||
int nmasters[TAGCOUNT + 1]; /* number of windows in master area */
|
||||
float mfacts[TAGCOUNT + 1]; /* mfacts per tag */
|
||||
unsigned int sellts[TAGCOUNT + 1]; /* selected layouts */
|
||||
const Layout *ltidxs[TAGCOUNT + 1][2]; /* matrix of tags and layouts indexes */
|
||||
};
|
||||
|
||||
/* function implementations */
|
||||
void
|
||||
applybounds(Client *c, struct wlr_box *bbox)
|
||||
|
|
@ -619,6 +634,8 @@ axisnotify(struct wl_listener *listener, void *data)
|
|||
* for example when you move the scroll wheel. */
|
||||
struct wlr_pointer_axis_event *event = data;
|
||||
IDLE_NOTIFY_ACTIVITY;
|
||||
if(cursor_hidden)
|
||||
hidecursor(0);
|
||||
/* TODO: allow usage of scroll whell for mousebindings, it can be implemented
|
||||
* checking the event's orientation and the delta of the event */
|
||||
/* Notify the client with pointer focus of the axis event. */
|
||||
|
|
@ -637,6 +654,8 @@ buttonpress(struct wl_listener *listener, void *data)
|
|||
const Button *b;
|
||||
|
||||
IDLE_NOTIFY_ACTIVITY;
|
||||
if(cursor_hidden)
|
||||
hidecursor(0);
|
||||
|
||||
switch (event->state) {
|
||||
case WLR_BUTTON_PRESSED:
|
||||
|
|
@ -648,7 +667,6 @@ buttonpress(struct wl_listener *listener, void *data)
|
|||
xytonode(cursor->x, cursor->y, NULL, &c, NULL, NULL, NULL);
|
||||
if (c && (!client_is_unmanaged(c) || client_wants_focus(c)))
|
||||
focusclient(c, 1);
|
||||
|
||||
keyboard = wlr_seat_get_keyboard(seat);
|
||||
mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0;
|
||||
for (b = buttons; b < END(buttons); b++) {
|
||||
|
|
@ -775,6 +793,7 @@ cleanupmon(struct wl_listener *listener, void *data)
|
|||
wlr_scene_output_destroy(m->scene_output);
|
||||
wlr_scene_node_destroy(&m->fullscreen_bg->node);
|
||||
|
||||
free(m->pertag);
|
||||
closemon(m);
|
||||
free(m);
|
||||
}
|
||||
|
|
@ -797,7 +816,7 @@ closemon(Monitor *m)
|
|||
wl_list_for_each(c, &clients, link) {
|
||||
if (c->isfloating && c->geom.x > m->m.width)
|
||||
resize(c, (struct wlr_box){.x = c->geom.x - m->w.width, .y = c->geom.y,
|
||||
.width = c->geom.width, .height = c->geom.height}, 0);
|
||||
.width = c->geom.width, .height = c->geom.height}, 0, 1);
|
||||
if (c->mon == m)
|
||||
setmon(c, selmon, c->tags);
|
||||
}
|
||||
|
|
@ -1017,6 +1036,18 @@ createmon(struct wl_listener *listener, void *data)
|
|||
wl_list_insert(&mons, &m->link);
|
||||
printstatus();
|
||||
|
||||
m->pertag = calloc(1, sizeof(Pertag));
|
||||
m->pertag->curtag = m->pertag->prevtag = 1;
|
||||
|
||||
for (i = 0; i <= TAGCOUNT; i++) {
|
||||
m->pertag->nmasters[i] = m->nmaster;
|
||||
m->pertag->mfacts[i] = m->mfact;
|
||||
|
||||
m->pertag->ltidxs[i][0] = m->lt[0];
|
||||
m->pertag->ltidxs[i][1] = m->lt[1];
|
||||
m->pertag->sellts[i] = m->sellt;
|
||||
}
|
||||
|
||||
/* The xdg-protocol specifies:
|
||||
*
|
||||
* If the fullscreened surface is not opaque, the compositor must make
|
||||
|
|
@ -1099,10 +1130,10 @@ createpointer(struct wlr_pointer *pointer)
|
|||
libinput_device_config_tap_set_drag_enabled(libinput_device, tap_and_drag);
|
||||
libinput_device_config_tap_set_drag_lock_enabled(libinput_device, drag_lock);
|
||||
libinput_device_config_tap_set_button_map(libinput_device, button_map);
|
||||
}
|
||||
|
||||
if (libinput_device_config_scroll_has_natural_scroll(libinput_device))
|
||||
libinput_device_config_scroll_set_natural_scroll_enabled(libinput_device, natural_scrolling);
|
||||
if (libinput_device_config_scroll_has_natural_scroll(libinput_device))
|
||||
libinput_device_config_scroll_set_natural_scroll_enabled(libinput_device, natural_scrolling);
|
||||
}
|
||||
|
||||
if (libinput_device_config_dwt_is_available(libinput_device))
|
||||
libinput_device_config_dwt_set_enabled(libinput_device, disable_while_typing);
|
||||
|
|
@ -1126,6 +1157,8 @@ createpointer(struct wlr_pointer *pointer)
|
|||
libinput_device_config_accel_set_profile(libinput_device, accel_profile);
|
||||
libinput_device_config_accel_set_speed(libinput_device, accel_speed);
|
||||
}
|
||||
|
||||
inputconfig(libinput_device);
|
||||
}
|
||||
|
||||
wlr_cursor_attach_input_device(cursor, &pointer->base);
|
||||
|
|
@ -1602,6 +1635,20 @@ getunusedtag(void)
|
|||
return i;
|
||||
}
|
||||
|
||||
void
|
||||
hidecursor(int hide)
|
||||
{
|
||||
if (hide) {
|
||||
wlr_cursor_set_image(cursor, NULL, 0, 0, 0, 0, 0, 0);
|
||||
wlr_seat_pointer_notify_clear_focus(seat);
|
||||
cursor_hidden = 1;
|
||||
return;
|
||||
}
|
||||
wlr_xcursor_manager_set_cursor_image(cursor_mgr, "left_ptr", cursor);
|
||||
cursor_hidden = false;
|
||||
motionnotify(0);
|
||||
}
|
||||
|
||||
void
|
||||
handlesig(int signo)
|
||||
{
|
||||
|
|
@ -1641,7 +1688,7 @@ incnmaster(const Arg *arg)
|
|||
{
|
||||
if (!arg || !selmon)
|
||||
return;
|
||||
selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
|
||||
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0);
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
|
|
@ -1740,6 +1787,8 @@ keypress(struct wl_listener *listener, void *data)
|
|||
wlr_seat_set_keyboard(seat, kb->wlr_keyboard);
|
||||
wlr_seat_keyboard_notify_key(seat, event->time_msec,
|
||||
event->keycode, event->state);
|
||||
if(hide_type)
|
||||
hidecursor(1);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -1910,7 +1959,7 @@ monocle(Monitor *m)
|
|||
wl_list_for_each(c, &clients, link) {
|
||||
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
|
||||
continue;
|
||||
resize(c, m->w, 0);
|
||||
resize(c, m->w, 0, !smartborders);
|
||||
n++;
|
||||
}
|
||||
if (n)
|
||||
|
|
@ -1945,6 +1994,8 @@ motionnotify(uint32_t time)
|
|||
/* time is 0 in internal calls meant to restore pointer focus. */
|
||||
if (time) {
|
||||
IDLE_NOTIFY_ACTIVITY;
|
||||
if(cursor_hidden)
|
||||
hidecursor(0);
|
||||
|
||||
/* Update selmon (even while dragging a window) */
|
||||
if (sloppyfocus)
|
||||
|
|
@ -1958,11 +2009,11 @@ motionnotify(uint32_t time)
|
|||
if (cursor_mode == CurMove) {
|
||||
/* Move the grabbed client to the new position. */
|
||||
resize(grabc, (struct wlr_box){.x = cursor->x - grabcx, .y = cursor->y - grabcy,
|
||||
.width = grabc->geom.width, .height = grabc->geom.height}, 1);
|
||||
.width = grabc->geom.width, .height = grabc->geom.height}, 1, 1);
|
||||
return;
|
||||
} else if (cursor_mode == CurResize) {
|
||||
resize(grabc, (struct wlr_box){.x = grabc->geom.x, .y = grabc->geom.y,
|
||||
.width = cursor->x - grabc->geom.x, .height = cursor->y - grabc->geom.y}, 1);
|
||||
.width = cursor->x - grabc->geom.x, .height = cursor->y - grabc->geom.y}, 1, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2220,11 +2271,12 @@ requeststartdrag(struct wl_listener *listener, void *data)
|
|||
}
|
||||
|
||||
void
|
||||
resize(Client *c, struct wlr_box geo, int interact)
|
||||
resize(Client *c, struct wlr_box geo, int interact, int draw_borders)
|
||||
{
|
||||
struct wlr_box *bbox = interact ? &sgeom : &c->mon->w;
|
||||
client_set_bounds(c, geo.width, geo.height);
|
||||
c->geom = geo;
|
||||
c->bw = draw_borders ? borderpx : 0;
|
||||
applybounds(c, bbox);
|
||||
|
||||
/* Update scene-graph, including borders */
|
||||
|
|
@ -2324,6 +2376,8 @@ setfloating(Client *c, int floating)
|
|||
if (!c->mon)
|
||||
return;
|
||||
wlr_scene_node_reparent(&c->scene->node, layers[c->isfloating ? LyrFloat : LyrTile]);
|
||||
if (c->isfloating && !c->bw)
|
||||
resize(c, c->mon->m, 0, 1);
|
||||
arrange(c->mon);
|
||||
printstatus();
|
||||
}
|
||||
|
|
@ -2341,11 +2395,11 @@ setfullscreen(Client *c, int fullscreen)
|
|||
|
||||
if (fullscreen) {
|
||||
c->prev = c->geom;
|
||||
resize(c, c->mon->m, 0);
|
||||
resize(c, c->mon->m, 0, 0);
|
||||
} else {
|
||||
/* restore previous size instead of arrange for floating windows since
|
||||
* client positions are set by the user and cannot be recalculated */
|
||||
resize(c, c->prev, 0);
|
||||
resize(c, c->prev, 0, 1);
|
||||
}
|
||||
arrange(c->mon);
|
||||
printstatus();
|
||||
|
|
@ -2357,10 +2411,16 @@ setlayout(const Arg *arg)
|
|||
if (!selmon)
|
||||
return;
|
||||
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
|
||||
selmon->sellt ^= 1;
|
||||
selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag] ^= 1;
|
||||
if (arg && arg->v)
|
||||
selmon->lt[selmon->sellt] = (Layout *)arg->v;
|
||||
selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v;
|
||||
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, LENGTH(selmon->ltsymbol));
|
||||
if (!selmon->lt[selmon->sellt]->arrange) {
|
||||
/* floating layout, draw borders around all clients */
|
||||
Client *c;
|
||||
wl_list_for_each(c, &clients, link)
|
||||
resize(c, c->mon->m, 0, 1);
|
||||
}
|
||||
arrange(selmon);
|
||||
printstatus();
|
||||
}
|
||||
|
|
@ -2376,7 +2436,7 @@ setmfact(const Arg *arg)
|
|||
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
|
||||
if (f < 0.1 || f > 0.9)
|
||||
return;
|
||||
selmon->mfact = f;
|
||||
selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f;
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
|
|
@ -2395,7 +2455,7 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
|
|||
arrange(oldmon);
|
||||
if (m) {
|
||||
/* Make sure window actually overlaps with the monitor */
|
||||
resize(c, c->geom, 0);
|
||||
resize(c, c->geom, 0, 1);
|
||||
c->tags = newtags ? newtags : m->tagset[m->seltags]; /* assign tags of target monitor */
|
||||
setfullscreen(c, c->isfullscreen); /* This will call arrange(c->mon) */
|
||||
setfloating(c, c->isfloating);
|
||||
|
|
@ -2664,7 +2724,7 @@ tagmon(const Arg *arg)
|
|||
void
|
||||
tile(Monitor *m)
|
||||
{
|
||||
unsigned int i, n = 0, mw, my, ty;
|
||||
unsigned int i, n = 0, mw, my, ty, draw_borders = 1;
|
||||
Client *c;
|
||||
|
||||
wl_list_for_each(c, &clients, link)
|
||||
|
|
@ -2673,6 +2733,9 @@ tile(Monitor *m)
|
|||
if (n == 0)
|
||||
return;
|
||||
|
||||
if (n == smartborders)
|
||||
draw_borders = 0;
|
||||
|
||||
if (n > m->nmaster)
|
||||
mw = m->nmaster ? m->w.width * m->mfact : 0;
|
||||
else
|
||||
|
|
@ -2683,11 +2746,11 @@ tile(Monitor *m)
|
|||
continue;
|
||||
if (i < m->nmaster) {
|
||||
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, draw_borders);
|
||||
my += c->geom.height;
|
||||
} else {
|
||||
resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y + ty,
|
||||
.width = m->w.width - mw, .height = (m->w.height - ty) / (n - i)}, 0);
|
||||
.width = m->w.width - mw, .height = (m->w.height - ty) / (n - i)}, 0, draw_borders);
|
||||
ty += c->geom.height;
|
||||
}
|
||||
i++;
|
||||
|
|
@ -2746,6 +2809,7 @@ toggleview(const Arg *arg)
|
|||
{
|
||||
Monitor *m;
|
||||
uint32_t newtagset = selmon ? selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK) : 0;
|
||||
size_t i;
|
||||
|
||||
if (!newtagset)
|
||||
return;
|
||||
|
|
@ -2754,6 +2818,25 @@ toggleview(const Arg *arg)
|
|||
if (m !=selmon && newtagset & m->tagset[m->seltags])
|
||||
return;
|
||||
|
||||
if (newtagset == ~0) {
|
||||
selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||
selmon->pertag->curtag = 0;
|
||||
}
|
||||
|
||||
/* test if the user did not select the same tag */
|
||||
if (!(newtagset & 1 << (selmon->pertag->curtag - 1))) {
|
||||
selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||
for (i = 0; !(newtagset & 1 << i); i++) ;
|
||||
selmon->pertag->curtag = i + 1;
|
||||
}
|
||||
|
||||
/* apply settings for this view */
|
||||
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
||||
selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
||||
selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
||||
selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
||||
selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
||||
|
||||
selmon->tagset[selmon->seltags] = newtagset;
|
||||
attachclients(selmon);
|
||||
focusclient(focustop(selmon), 1);
|
||||
|
|
@ -2926,6 +3009,7 @@ view(const Arg *arg)
|
|||
{
|
||||
Monitor *m, *origm = selmon;
|
||||
unsigned int newtags = selmon->tagset[selmon->seltags ^ 1];
|
||||
size_t i, tmptag;
|
||||
|
||||
if (!selmon || (arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
||||
return;
|
||||
|
|
@ -2949,8 +3033,28 @@ view(const Arg *arg)
|
|||
}
|
||||
|
||||
origm->seltags ^= 1; /* toggle sel tagset */
|
||||
if (arg->ui & TAGMASK)
|
||||
if (arg->ui & TAGMASK) {
|
||||
origm->tagset[origm->seltags] = arg->ui & TAGMASK;
|
||||
origm->pertag->prevtag = origm->pertag->curtag;
|
||||
|
||||
if (arg->ui == ~0)
|
||||
origm->pertag->curtag = 0;
|
||||
else {
|
||||
for (i = 0; !(arg->ui & 1 << i); i++) ;
|
||||
origm->pertag->curtag = i + 1;
|
||||
}
|
||||
} else {
|
||||
tmptag = origm->pertag->prevtag;
|
||||
origm->pertag->prevtag = origm->pertag->curtag;
|
||||
origm->pertag->curtag = tmptag;
|
||||
}
|
||||
|
||||
origm->nmaster = origm->pertag->nmasters[origm->pertag->curtag];
|
||||
origm->mfact = origm->pertag->mfacts[origm->pertag->curtag];
|
||||
origm->sellt = origm->pertag->sellts[origm->pertag->curtag];
|
||||
origm->lt[origm->sellt] = origm->pertag->ltidxs[origm->pertag->curtag][origm->sellt];
|
||||
origm->lt[origm->sellt^1] = origm->pertag->ltidxs[origm->pertag->curtag][origm->sellt^1];
|
||||
|
||||
attachclients(origm);
|
||||
focusclient(focustop(origm), 1);
|
||||
arrange(origm);
|
||||
|
|
@ -3034,6 +3138,33 @@ zoom(const Arg *arg)
|
|||
arrange(selmon);
|
||||
}
|
||||
|
||||
void
|
||||
regions(const Arg *arg)
|
||||
{
|
||||
int pipefd[2];
|
||||
Client *c;
|
||||
Monitor *m;
|
||||
|
||||
if (pipe(pipefd) == -1)
|
||||
return;
|
||||
if (fork() == 0) {
|
||||
close(pipefd[1]);
|
||||
dup2(pipefd[0], STDIN_FILENO);
|
||||
close(pipefd[0]);
|
||||
setsid();
|
||||
execvp(((char **)arg->v)[0], (char **)arg->v);
|
||||
die("dwl: execvp %s failed:", ((char **)arg->v)[0]);
|
||||
}
|
||||
|
||||
close(pipefd[0]);
|
||||
wl_list_for_each(m, &mons, link)
|
||||
wl_list_for_each(c, &clients, link)
|
||||
if (VISIBLEON(c, m))
|
||||
dprintf(pipefd[1], "%d,%d %dx%d\n",
|
||||
c->geom.x, c->geom.y, c->geom.width, c->geom.height);
|
||||
close(pipefd[1]);
|
||||
}
|
||||
|
||||
#ifdef XWAYLAND
|
||||
void
|
||||
activatex11(struct wl_listener *listener, void *data)
|
||||
|
|
@ -3054,7 +3185,7 @@ configurex11(struct wl_listener *listener, void *data)
|
|||
return;
|
||||
if (c->isfloating || c->type == X11Unmanaged)
|
||||
resize(c, (struct wlr_box){.x = event->x, .y = event->y,
|
||||
.width = event->width, .height = event->height}, 0);
|
||||
.width = event->width, .height = event->height}, 0, 1);
|
||||
else
|
||||
arrange(c->mon);
|
||||
}
|
||||
|
|
@ -3158,6 +3289,7 @@ main(int argc, char *argv[])
|
|||
/* Wayland requires XDG_RUNTIME_DIR for creating its communications socket */
|
||||
if (!getenv("XDG_RUNTIME_DIR"))
|
||||
die("XDG_RUNTIME_DIR must be set");
|
||||
loadtheme();
|
||||
setup();
|
||||
run(startup_cmd);
|
||||
cleanup();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,213 @@
|
|||
static int
|
||||
isenabled(const char *val, int def)
|
||||
{
|
||||
return ((def && (!val || !val[0] || (val[0] != '0'))) || (!def && (val && val[0] && (val[0] != '0'))));
|
||||
}
|
||||
|
||||
static void
|
||||
setclickmethod(struct libinput_device *libinput_device)
|
||||
{
|
||||
const char *val;
|
||||
long l;
|
||||
char *end = NULL;
|
||||
|
||||
val = getenv("LIBINPUT_DEFAULT_CLICK_METHOD");
|
||||
if (!val || !val[0])
|
||||
return;
|
||||
|
||||
errno = 0;
|
||||
l = strtol(val, &end, 10);
|
||||
if (errno || (end && *end))
|
||||
return;
|
||||
|
||||
libinput_device_config_click_set_method(libinput_device,
|
||||
(enum libinput_config_click_method)l);
|
||||
}
|
||||
|
||||
static void
|
||||
settap(struct libinput_device *libinput_device)
|
||||
{
|
||||
const char *val;
|
||||
|
||||
val = getenv("LIBINPUT_DEFAULT_TAP");
|
||||
if (val) {
|
||||
if (!val[0])
|
||||
return;
|
||||
|
||||
libinput_device_config_tap_set_enabled(libinput_device,
|
||||
isenabled(val, 1) ? LIBINPUT_CONFIG_TAP_ENABLED :
|
||||
LIBINPUT_CONFIG_TAP_DISABLED);
|
||||
} else if (tap_to_click && libinput_device_config_tap_get_finger_count(libinput_device))
|
||||
libinput_device_config_tap_set_enabled(libinput_device,
|
||||
LIBINPUT_CONFIG_TAP_ENABLED);
|
||||
}
|
||||
|
||||
static void
|
||||
settapanddrag(struct libinput_device *libinput_device)
|
||||
{
|
||||
const char *val;
|
||||
|
||||
val = getenv("LIBINPUT_DEFAULT_DRAG");
|
||||
if (val && val[0])
|
||||
libinput_device_config_tap_set_drag_enabled(libinput_device,
|
||||
isenabled(val, 1) ? LIBINPUT_CONFIG_DRAG_ENABLED :
|
||||
LIBINPUT_CONFIG_DRAG_DISABLED);
|
||||
}
|
||||
|
||||
static void
|
||||
setnaturalscroll(struct libinput_device *libinput_device)
|
||||
{
|
||||
const char *val;
|
||||
|
||||
val = getenv("LIBINPUT_DEFAULT_NATURAL_SCROLL");
|
||||
if (val && val[0])
|
||||
libinput_device_config_scroll_set_natural_scroll_enabled(
|
||||
libinput_device, isenabled(val, 0));
|
||||
else if (!val && libinput_device_config_scroll_has_natural_scroll(libinput_device))
|
||||
libinput_device_config_scroll_set_natural_scroll_enabled(
|
||||
libinput_device, natural_scrolling);
|
||||
}
|
||||
|
||||
static void
|
||||
setaccelprofile(struct libinput_device *libinput_device)
|
||||
{
|
||||
const char *val;
|
||||
double profile;
|
||||
char *end = NULL;
|
||||
|
||||
val = getenv("LIBINPUT_DEFAULT_ACCELERATION_PROFILE");
|
||||
if (!val || !val[0])
|
||||
return;
|
||||
|
||||
errno = 0;
|
||||
profile = strtod(val, &end);
|
||||
if (errno || (end && *end))
|
||||
return;
|
||||
|
||||
libinput_device_config_accel_set_profile(libinput_device,
|
||||
(enum libinput_config_accel_profile)profile);
|
||||
}
|
||||
|
||||
static void
|
||||
setaccelspeed(struct libinput_device *libinput_device)
|
||||
{
|
||||
const char *val;
|
||||
double accel = 0;
|
||||
char *end = NULL;
|
||||
|
||||
val = getenv("LIBINPUT_DEFAULT_ACCELERATION");
|
||||
if (!val || !val[0])
|
||||
return;
|
||||
|
||||
errno = 0;
|
||||
accel = strtod(val, &end);
|
||||
if (errno || (end && *end) || (accel < -1) || (accel > 1))
|
||||
return;
|
||||
|
||||
libinput_device_config_accel_set_speed(libinput_device, accel);
|
||||
}
|
||||
|
||||
static void
|
||||
setscrollmethod(struct libinput_device *libinput_device)
|
||||
{
|
||||
const char *val;
|
||||
long l;
|
||||
char *end = NULL;
|
||||
|
||||
val = getenv("LIBINPUT_DEFAULT_SCROLL_METHOD");
|
||||
if (!val || !val[0])
|
||||
return;
|
||||
|
||||
errno = 0;
|
||||
l = strtol(val, &end, 10);
|
||||
if (errno || (end && *end))
|
||||
return;
|
||||
|
||||
libinput_device_config_scroll_set_method(libinput_device,
|
||||
(enum libinput_config_scroll_method)l);
|
||||
}
|
||||
|
||||
static void
|
||||
setdwt(struct libinput_device *libinput_device)
|
||||
{
|
||||
const char *val;
|
||||
|
||||
val = getenv("LIBINPUT_DEFAULT_DISABLE_WHILE_TYPING");
|
||||
if (val && val[0])
|
||||
libinput_device_config_dwt_set_enabled(libinput_device,
|
||||
isenabled(val, false) ? LIBINPUT_CONFIG_DWT_ENABLED :
|
||||
LIBINPUT_CONFIG_DWT_DISABLED);
|
||||
}
|
||||
|
||||
static void
|
||||
setmiddleemul(struct libinput_device *libinput_device)
|
||||
{
|
||||
const char *val;
|
||||
|
||||
val = getenv("LIBINPUT_DEFAULT_MIDDLE_EMULATION");
|
||||
if (val && val[0])
|
||||
libinput_device_config_middle_emulation_set_enabled(libinput_device,
|
||||
isenabled(val, false) ? LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED :
|
||||
LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
|
||||
}
|
||||
|
||||
static void
|
||||
setlefthanded(struct libinput_device *libinput_device)
|
||||
{
|
||||
const char *val;
|
||||
|
||||
val = getenv("LIBINPUT_DEFAULT_LEFT_HANDED");
|
||||
if (val && val[0])
|
||||
libinput_device_config_left_handed_set(libinput_device,
|
||||
isenabled(val, 0));
|
||||
}
|
||||
|
||||
static void
|
||||
inputconfig(struct libinput_device *libinput_device)
|
||||
{
|
||||
setclickmethod(libinput_device);
|
||||
settap(libinput_device);
|
||||
settapanddrag(libinput_device);
|
||||
setnaturalscroll(libinput_device);
|
||||
setaccelprofile(libinput_device);
|
||||
setaccelspeed(libinput_device);
|
||||
setscrollmethod(libinput_device);
|
||||
setdwt(libinput_device);
|
||||
setmiddleemul(libinput_device);
|
||||
setlefthanded(libinput_device);
|
||||
}
|
||||
|
||||
static void
|
||||
parsecolor(const char *val, float color[4])
|
||||
{
|
||||
uint8_t r, g, b;
|
||||
if (sscanf(val, "#%02hhx%02hhx%02hhx", &r, &g, &b) == 3) {
|
||||
color[0] = (float)r / 0xFF;
|
||||
color[1] = (float)g / 0xFF;
|
||||
color[2] = (float)b / 0xFF;
|
||||
color[3] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
loadtheme(void)
|
||||
{
|
||||
const char *val;
|
||||
unsigned int tmp;
|
||||
|
||||
val = getenv("DWL_ROOT_COLOR");
|
||||
if (val)
|
||||
parsecolor(val, rootcolor);
|
||||
|
||||
val = getenv("DWL_BORDER_COLOR");
|
||||
if (val)
|
||||
parsecolor(val, bordercolor);
|
||||
|
||||
val = getenv("DWL_FOCUS_COLOR");
|
||||
if (val)
|
||||
parsecolor(val, focuscolor);
|
||||
|
||||
val = getenv("DWL_BORDER");
|
||||
if (val && sscanf(val, "%u", &tmp) == 1)
|
||||
borderpx = tmp;
|
||||
}
|
||||
Loading…
Reference in New Issue