add tag and view functions
parent
fda58764ab
commit
387dff81b3
18
config.def.h
18
config.def.h
|
@ -1,6 +1,9 @@
|
|||
/* appearance */
|
||||
static const float rootcolor[] = {0.3, 0.3, 0.3, 1.0};
|
||||
|
||||
/* tagging */
|
||||
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||
|
||||
/* layout(s) */
|
||||
static const Layout layouts[] = {
|
||||
/* symbol arrange function */
|
||||
|
@ -27,6 +30,9 @@ static const struct xkb_rule_names xkb_rules = {
|
|||
};
|
||||
|
||||
#define MODKEY WLR_MODIFIER_ALT
|
||||
#define TAGKEYS(KEY,SKEY,TAG) \
|
||||
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, SKEY, tag, {.ui = 1 << TAG} }
|
||||
|
||||
/* commands */
|
||||
static const char *termcmd[] = { "kitty", "-o", "linux_display_server=wayland", NULL };
|
||||
|
@ -36,9 +42,21 @@ static const Key keys[] = {
|
|||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd } },
|
||||
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
|
||||
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
||||
{ MODKEY, XKB_KEY_Tab, view, {0} },
|
||||
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
|
||||
TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0),
|
||||
TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1),
|
||||
TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2),
|
||||
TAGKEYS( XKB_KEY_4, XKB_KEY_dollar, 3),
|
||||
TAGKEYS( XKB_KEY_5, XKB_KEY_percent, 4),
|
||||
TAGKEYS( XKB_KEY_6, XKB_KEY_caret, 5),
|
||||
TAGKEYS( XKB_KEY_7, XKB_KEY_ampersand, 6),
|
||||
TAGKEYS( XKB_KEY_8, XKB_KEY_asterisk, 7),
|
||||
TAGKEYS( XKB_KEY_9, XKB_KEY_parenleft, 8),
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Q, quit, {0} },
|
||||
};
|
||||
|
||||
|
|
40
dwl.c
40
dwl.c
|
@ -32,8 +32,9 @@
|
|||
/* macros */
|
||||
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
||||
#define CLEANMASK(mask) (mask & ~WLR_MODIFIER_CAPS)
|
||||
#define VISIBLEON(C, M) ((C)->mon == (M))
|
||||
#define VISIBLEON(C, M) ((C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]))
|
||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
||||
|
||||
/* enums */
|
||||
enum { CurNormal, CurMove, CurResize }; /* cursor */
|
||||
|
@ -64,6 +65,7 @@ typedef struct {
|
|||
struct wl_listener request_resize;
|
||||
Monitor *mon;
|
||||
int x, y; /* layout-relative */
|
||||
unsigned int tags;
|
||||
int isfloating;
|
||||
} Client;
|
||||
|
||||
|
@ -94,7 +96,9 @@ struct Monitor {
|
|||
struct wlr_box *geom; /* layout-relative */
|
||||
int wx, wy, ww, wh; /* layout-relative */
|
||||
const Layout *lt[2];
|
||||
unsigned int seltags;
|
||||
unsigned int sellt;
|
||||
unsigned int tagset[2];
|
||||
double mfact;
|
||||
int nmaster;
|
||||
};
|
||||
|
@ -147,9 +151,11 @@ static void setcursor(struct wl_listener *listener, void *data);
|
|||
static void setlayout(const Arg *arg);
|
||||
static void setup(void);
|
||||
static void spawn(const Arg *arg);
|
||||
static void tag(const Arg *arg);
|
||||
static void tile(Monitor *m);
|
||||
static void togglefloating(const Arg *arg);
|
||||
static void unmapnotify(struct wl_listener *listener, void *data);
|
||||
static void view(const Arg *arg);
|
||||
static Client *xytoclient(double x, double y,
|
||||
struct wlr_surface **surface, double *sx, double *sy);
|
||||
static Monitor *xytomon(double x, double y);
|
||||
|
@ -290,6 +296,7 @@ createmon(struct wl_listener *listener, void *data)
|
|||
/* Allocates and configures monitor state using configured rules */
|
||||
Monitor *m = calloc(1, sizeof(*m));
|
||||
m->wlr_output = wlr_output;
|
||||
m->tagset[0] = m->tagset[1] = 1;
|
||||
int i;
|
||||
for (i = 0; i < LENGTH(monrules); i++) {
|
||||
if (!monrules[i].name ||
|
||||
|
@ -564,6 +571,7 @@ maprequest(struct wl_listener *listener, void *data)
|
|||
|
||||
/* Insert this client into the list and focus it. */
|
||||
c->mon = selmon;
|
||||
c->tags = c->mon->tagset[c->mon->seltags];
|
||||
wl_list_insert(&clients, &c->link);
|
||||
wl_list_insert(&fstack, &c->flink);
|
||||
focus(c, NULL);
|
||||
|
@ -776,6 +784,12 @@ rendermon(struct wl_listener *listener, void *data)
|
|||
* our client list is ordered front-to-back, we iterate over it backwards. */
|
||||
Client *c;
|
||||
wl_list_for_each_reverse(c, &clients, link) {
|
||||
/* Only render clients which are on this monitor. */
|
||||
/* XXX consider checking wlr_output_layout_intersects, in case a
|
||||
* window can be seen on multiple outputs */
|
||||
if (!VISIBLEON(c, m))
|
||||
continue;
|
||||
|
||||
struct render_data rdata = {
|
||||
.output = m->wlr_output,
|
||||
.when = &now,
|
||||
|
@ -784,8 +798,7 @@ rendermon(struct wl_listener *listener, void *data)
|
|||
};
|
||||
/* This calls our render function for each surface among the
|
||||
* xdg_surface's toplevel and popups. */
|
||||
wlr_xdg_surface_for_each_surface(c->xdg_surface,
|
||||
render, &rdata);
|
||||
wlr_xdg_surface_for_each_surface(c->xdg_surface, render, &rdata);
|
||||
}
|
||||
|
||||
/* Hardware cursors are rendered by the GPU on a separate plane, and can be
|
||||
|
@ -1047,6 +1060,16 @@ spawn(const Arg *arg)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
tag(const Arg *arg)
|
||||
{
|
||||
Client *sel = selclient();
|
||||
if (sel && arg->ui & TAGMASK) {
|
||||
sel->tags = arg->ui & TAGMASK;
|
||||
focus(NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
tile(Monitor *m)
|
||||
{
|
||||
|
@ -1106,6 +1129,17 @@ unmapnotify(struct wl_listener *listener, void *data)
|
|||
focus(NULL, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
view(const Arg *arg)
|
||||
{
|
||||
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
||||
return;
|
||||
selmon->seltags ^= 1; /* toggle sel tagset */
|
||||
if (arg->ui & TAGMASK)
|
||||
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
||||
focus(NULL, NULL);
|
||||
}
|
||||
|
||||
Client *
|
||||
xytoclient(double x, double y,
|
||||
struct wlr_surface **surface, double *sx, double *sy)
|
||||
|
|
Loading…
Reference in New Issue