added movestack patch
This commit is contained in:
parent
eeae37586f
commit
fa874b6f97
4 changed files with 164 additions and 33 deletions
159
dwl.c
159
dwl.c
|
@ -84,14 +84,15 @@
|
|||
#define MAX(A, B) ((A) > (B) ? (A) : (B))
|
||||
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
||||
#define CLEANMASK(mask) (mask & ~WLR_MODIFIER_CAPS)
|
||||
#define VISIBLEON(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]) && !(C)->swallowedby || C->issticky)
|
||||
#define VISIBLEON(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]) && !(C)->swallowedby)
|
||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||
#define END(A) ((A) + LENGTH(A))
|
||||
#define TAGMASK ((1u << LENGTH(tags)) - 1)
|
||||
#define LISTEN(E, L, H) wl_signal_add((E), ((L)->notify = (H), (L)))
|
||||
#define LISTEN_STATIC(E, H) do { static struct wl_listener _l = {.notify = (H)}; wl_signal_add((E), &_l); } while (0)
|
||||
#define BORDERPX(C) (borderpx + ((C)->swallowing ? (C)->swallowing->bw : 0))
|
||||
#define BORDERPX(C) (borderpx + ((C)->swallowing ? (int)ceilf(swallowborder * (C)->swallowing->bw) : 0))
|
||||
#define TEXTW(mon, text) (drwl_font_getwidth(mon->drw, text) + mon->lrpad)
|
||||
#define PREFIX(str, prefix) !strncmp(str, prefix, strlen(prefix))
|
||||
|
||||
/* enums */
|
||||
enum { SchemeNorm, SchemeSel, SchemeUrg }; /* color schemes */
|
||||
|
@ -159,11 +160,11 @@ struct Client {
|
|||
unsigned int bw;
|
||||
uint32_t tags;
|
||||
int isfloating, isurgent, isfullscreen, issticky;
|
||||
int isterm, noswallow;
|
||||
int isterm, noswallow;
|
||||
uint32_t resize; /* configure serial of a pending resize */
|
||||
pid_t pid;
|
||||
Client *swallowing; /* client being hidden */
|
||||
Client *swallowedby;
|
||||
pid_t pid;
|
||||
Client *swallowing; /* client being hidden */
|
||||
Client *swallowedby;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
@ -359,6 +360,7 @@ static void destroykeyboardgroup(struct wl_listener *listener, void *data);
|
|||
static Monitor *dirtomon(enum wlr_direction dir);
|
||||
static void drawbar(Monitor *m);
|
||||
static void drawbars(void);
|
||||
static int drawstatus(Monitor *m);
|
||||
static void focusclient(Client *c, int lift);
|
||||
static void focusmon(const Arg *arg);
|
||||
static void focusstack(const Arg *arg);
|
||||
|
@ -384,6 +386,7 @@ static void locksession(struct wl_listener *listener, void *data);
|
|||
static void mapnotify(struct wl_listener *listener, void *data);
|
||||
static void maximizenotify(struct wl_listener *listener, void *data);
|
||||
static void monocle(Monitor *m);
|
||||
static void movestack(const Arg *arg);
|
||||
static void motionabsolute(struct wl_listener *listener, void *data);
|
||||
static void motionnotify(uint32_t time, struct wlr_input_device *device, double sx,
|
||||
double sy, double sx_unaccel, double sy_unaccel);
|
||||
|
@ -418,9 +421,9 @@ static void setmon(Client *c, Monitor *m, uint32_t newtags);
|
|||
static void setpsel(struct wl_listener *listener, void *data);
|
||||
static void setsel(struct wl_listener *listener, void *data);
|
||||
static void setup(void);
|
||||
static void swallow(Client *c, Client *toswallow);
|
||||
static void spawn(const Arg *arg);
|
||||
static void startdrag(struct wl_listener *listener, void *data);
|
||||
static void swallow(Client *c, Client *toswallow);
|
||||
static int statusin(int fd, unsigned int mask, void *data);
|
||||
static void switchxkbrule(const Arg *arg);
|
||||
static void tag(const Arg *arg);
|
||||
|
@ -511,7 +514,7 @@ static struct wlr_box sgeom;
|
|||
static struct wl_list mons;
|
||||
static Monitor *selmon;
|
||||
|
||||
static char stext[256];
|
||||
static char stext[512];
|
||||
static struct wl_event_source *status_event_source;
|
||||
|
||||
static const struct wlr_buffer_impl buffer_impl = {
|
||||
|
@ -1872,11 +1875,8 @@ drawbar(Monitor *m)
|
|||
return;
|
||||
|
||||
/* draw status first so it can be overdrawn by tags later */
|
||||
if (m == selmon) { /* status is only drawn on selected monitor */
|
||||
drwl_setscheme(m->drw, colors[SchemeNorm]);
|
||||
tw = TEXTW(m, stext) - m->lrpad + 2; /* 2px right padding */
|
||||
drwl_text(m->drw, m->b.width - tw, 0, tw, m->b.height, 0, stext, 0);
|
||||
}
|
||||
if (m == selmon) /* status is only drawn on selected monitor */
|
||||
tw = drawstatus(m);
|
||||
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (c->mon != m)
|
||||
|
@ -1928,6 +1928,88 @@ drawbars(void)
|
|||
drawbar(m);
|
||||
}
|
||||
|
||||
int
|
||||
drawstatus(Monitor *m)
|
||||
{
|
||||
int x, tw, iw;
|
||||
char rstext[512] = "";
|
||||
char *p, *argstart, *argend, *itext;
|
||||
uint32_t scheme[3], *color;
|
||||
|
||||
/* calculate real width of stext */
|
||||
for (p = stext; *p; p++) {
|
||||
if (PREFIX(p, "^^")) {
|
||||
strncat(rstext, p, 2);
|
||||
p++;
|
||||
} else if (PREFIX(p, "^fg(") || PREFIX(p, "^bg(")) {
|
||||
argend = strchr(p, ')');
|
||||
if (!argend) { /* ignore this command */
|
||||
argstart = strchr(p, '(') + 1;
|
||||
strncat(rstext, p, argstart - p);
|
||||
p = argstart - 1;
|
||||
} else {
|
||||
p = argend;
|
||||
}
|
||||
} else {
|
||||
strncat(rstext, p, 1);
|
||||
}
|
||||
}
|
||||
tw = TEXTW(m, rstext) - m->lrpad;
|
||||
|
||||
x = m->b.width - tw;
|
||||
itext = stext;
|
||||
scheme[0] = colors[SchemeNorm][0];
|
||||
scheme[1] = colors[SchemeNorm][1];
|
||||
drwl_setscheme(m->drw, scheme);
|
||||
for (p = stext; *p; p++) {
|
||||
if (PREFIX(p, "^^")) {
|
||||
p++;
|
||||
} else if (PREFIX(p, "^fg(") || PREFIX(p, "^bg(")) {
|
||||
argstart = strchr(p, '(') + 1;
|
||||
argend = strchr(argstart, ')');
|
||||
if (!argend) { /* ignore this command */
|
||||
p = argstart - 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
*p = '\0';
|
||||
iw = TEXTW(m, itext) - m->lrpad;
|
||||
if (*itext) /* only draw text if there is something to draw */
|
||||
x = drwl_text(m->drw, x, 0, iw, m->b.height, 0, itext, 0);
|
||||
*p = '^';
|
||||
|
||||
if (PREFIX(p, "^fg("))
|
||||
color = &scheme[0];
|
||||
else
|
||||
color = &scheme[1];
|
||||
|
||||
if (argend != argstart) {
|
||||
*argend = '\0';
|
||||
*color = strtoul(argstart, NULL, 16);
|
||||
*color = *color << 8 | 0xff; /* add alpha channel */
|
||||
*argend = ')';
|
||||
} else {
|
||||
*color = 0; /* reset */
|
||||
}
|
||||
|
||||
/* reset color back to normal if none was provided */
|
||||
if (!scheme[0])
|
||||
scheme[0] = colors[SchemeNorm][0];
|
||||
if (!scheme[1])
|
||||
scheme[1] = colors[SchemeNorm][1];
|
||||
|
||||
itext = argend + 1;
|
||||
drwl_setscheme(m->drw, scheme);
|
||||
p = argend;
|
||||
}
|
||||
}
|
||||
iw = TEXTW(m, itext) - m->lrpad;
|
||||
if (*itext)
|
||||
drwl_text(m->drw, x, 0, iw, m->b.height, 0, itext, 0);
|
||||
|
||||
return tw;
|
||||
}
|
||||
|
||||
void
|
||||
focusclient(Client *c, int lift)
|
||||
{
|
||||
|
@ -2497,6 +2579,48 @@ monocle(Monitor *m)
|
|||
wlr_scene_node_raise_to_top(&c->scene->node);
|
||||
}
|
||||
|
||||
void
|
||||
movestack(const Arg *arg)
|
||||
{
|
||||
Client *c, *sel = focustop(selmon);
|
||||
|
||||
if (!sel) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (wl_list_length(&clients) <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg->i > 0) {
|
||||
wl_list_for_each(c, &sel->link, link) {
|
||||
if (&c->link == &clients) {
|
||||
c = wl_container_of(&clients, c, link);
|
||||
break; /* wrap past the sentinel node */
|
||||
}
|
||||
if (VISIBLEON(c, selmon) || &c->link == &clients) {
|
||||
break; /* found it */
|
||||
}
|
||||
}
|
||||
} else {
|
||||
wl_list_for_each_reverse(c, &sel->link, link) {
|
||||
if (&c->link == &clients) {
|
||||
c = wl_container_of(&clients, c, link);
|
||||
break; /* wrap past the sentinel node */
|
||||
}
|
||||
if (VISIBLEON(c, selmon) || &c->link == &clients) {
|
||||
break; /* found it */
|
||||
}
|
||||
}
|
||||
/* backup one client */
|
||||
c = wl_container_of(c->link.prev, c, link);
|
||||
}
|
||||
|
||||
wl_list_remove(&sel->link);
|
||||
wl_list_insert(&c->link, &sel->link);
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
void
|
||||
motionabsolute(struct wl_listener *listener, void *data)
|
||||
{
|
||||
|
@ -2731,7 +2855,6 @@ outputmgrtest(struct wl_listener *listener, void *data)
|
|||
pid_t
|
||||
parentpid(pid_t pid)
|
||||
{
|
||||
#ifdef __linux__
|
||||
unsigned int v = 0;
|
||||
FILE *f;
|
||||
char buf[256];
|
||||
|
@ -2741,14 +2864,6 @@ parentpid(pid_t pid)
|
|||
fscanf(f, "%*u %*s %*c %u", &v);
|
||||
fclose(f);
|
||||
return (pid_t)v;
|
||||
#elif defined(__FreeBSD__)
|
||||
struct kinfo_proc kip;
|
||||
size_t len = sizeof(struct kinfo_proc);
|
||||
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, p };
|
||||
if (sysctl(mib, 4, &kip, &len, NULL, 0) < 0 || len == 0)
|
||||
return 0;
|
||||
return kip.ki_ppid;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue