forked from RepoMirrors/dwl
Compare commits
2 Commits
d24d4ced54
...
de05b947f6
Author | SHA1 | Date | |
---|---|---|---|
|
de05b947f6 | ||
|
690d7e22f7 |
94
dwl.c
94
dwl.c
@ -113,6 +113,7 @@ typedef struct {
|
||||
unsigned int type; /* XDGShell or X11* */
|
||||
struct wlr_box geom; /* layout-relative, includes border */
|
||||
Monitor *mon;
|
||||
char *output;
|
||||
struct wlr_scene_tree *scene;
|
||||
struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
|
||||
struct wlr_scene_tree *scene_surface;
|
||||
@ -388,6 +389,12 @@ static void zoom(const Arg *arg);
|
||||
static void bstack(Monitor *m);
|
||||
static void bstackhoriz(Monitor *m);
|
||||
|
||||
/* push */
|
||||
static Client *nexttiled(Client *sel);
|
||||
static Client *prevtiled(Client *sel);
|
||||
static void pushdown(const Arg *arg);
|
||||
static void pushup(const Arg *arg);
|
||||
|
||||
/* variables */
|
||||
static const char broken[] = "broken";
|
||||
static pid_t child_pid = -1;
|
||||
@ -1105,6 +1112,7 @@ createmon(struct wl_listener *listener, void *data)
|
||||
size_t i;
|
||||
struct wlr_output_state state;
|
||||
Monitor *m;
|
||||
Client *c;
|
||||
|
||||
if (!wlr_output_init_render(wlr_output, alloc, drw))
|
||||
return;
|
||||
@ -1196,6 +1204,13 @@ createmon(struct wl_listener *listener, void *data)
|
||||
wlr_output_layout_add_auto(output_layout, wlr_output);
|
||||
else
|
||||
wlr_output_layout_add(output_layout, wlr_output, m->m.x, m->m.y);
|
||||
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (strcmp(wlr_output->name, c->output) == 0) {
|
||||
c->mon = m;
|
||||
}
|
||||
}
|
||||
updatemons(NULL, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1426,6 +1441,7 @@ destroynotify(struct wl_listener *listener, void *data)
|
||||
wl_list_remove(&c->map.link);
|
||||
wl_list_remove(&c->unmap.link);
|
||||
}
|
||||
free(c->output);
|
||||
free(c);
|
||||
}
|
||||
|
||||
@ -2136,6 +2152,10 @@ mapnotify(struct wl_listener *listener, void *data)
|
||||
} else {
|
||||
applyrules(c);
|
||||
}
|
||||
c->output = strdup(c->mon->wlr_output->name);
|
||||
if (c->output == NULL) {
|
||||
die("oom");
|
||||
}
|
||||
printstatus();
|
||||
|
||||
unset_fullscreen:
|
||||
@ -3080,8 +3100,14 @@ void
|
||||
tagmon(const Arg *arg)
|
||||
{
|
||||
Client *sel = focustop(selmon);
|
||||
if (sel)
|
||||
setmon(sel, dirtomon(arg->i), 0);
|
||||
if (!sel)
|
||||
return;
|
||||
setmon(sel, dirtomon(arg->i), 0);
|
||||
free(sel->output);
|
||||
sel->output = strdup(sel->mon->wlr_output->name);
|
||||
if (sel->output == NULL) {
|
||||
die("oom");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -3755,3 +3781,67 @@ bstackhoriz(Monitor *m) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
static Client *
|
||||
nexttiled(Client *sel) {
|
||||
Client *c;
|
||||
wl_list_for_each(c, &sel->link, link) {
|
||||
if (&c->link == &clients)
|
||||
break; /* don't wrap */
|
||||
if (!c->isfloating && VISIBLEON(c, selmon))
|
||||
return c;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Client *
|
||||
prevtiled(Client *sel) {
|
||||
Client *c;
|
||||
wl_list_for_each_reverse(c, &sel->link, link) {
|
||||
if (&c->link == &clients)
|
||||
break; /* don't wrap */
|
||||
if (!c->isfloating && VISIBLEON(c, selmon))
|
||||
return c;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
pushup(const Arg *arg) {
|
||||
Client *sel = focustop(selmon);
|
||||
Client *c;
|
||||
|
||||
if(!sel || sel->isfloating)
|
||||
return;
|
||||
if((c = prevtiled(sel))) {
|
||||
/* attach before c */
|
||||
wl_list_remove(&sel->link);
|
||||
wl_list_insert(c->link.prev, &sel->link);
|
||||
} else {
|
||||
/* move to the end */
|
||||
wl_list_remove(&sel->link);
|
||||
wl_list_insert(clients.prev, &sel->link);
|
||||
}
|
||||
focusclient(sel, 1);
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
static void
|
||||
pushdown(const Arg *arg) {
|
||||
Client *sel = focustop(selmon);
|
||||
Client *c;
|
||||
|
||||
if(!sel || sel->isfloating)
|
||||
return;
|
||||
if((c = nexttiled(sel))) {
|
||||
/* attach after c */
|
||||
wl_list_remove(&sel->link);
|
||||
wl_list_insert(&c->link, &sel->link);
|
||||
} else {
|
||||
/* move to the front */
|
||||
wl_list_remove(&sel->link);
|
||||
wl_list_insert(&clients, &sel->link);
|
||||
}
|
||||
focusclient(sel, 1);
|
||||
arrange(selmon);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user