Add restore-monitor patch
This commit is contained in:
39
dwl.c
39
dwl.c
@@ -110,6 +110,9 @@ typedef struct {
|
||||
unsigned int type; /* XDGShell or X11* */
|
||||
struct wlr_box geom; /* layout-relative, includes border */
|
||||
Monitor *mon;
|
||||
#if RESTORE_MONITOR_PATCH
|
||||
char *output;
|
||||
#endif // RESTORE_MONITOR_PATCH
|
||||
struct wlr_scene_tree *scene;
|
||||
struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
|
||||
struct wlr_scene_tree *scene_surface;
|
||||
@@ -1033,6 +1036,9 @@ createmon(struct wl_listener *listener, void *data)
|
||||
size_t i;
|
||||
struct wlr_output_state state;
|
||||
Monitor *m;
|
||||
#if RESTORE_MONITOR_PATCH
|
||||
Client *c;
|
||||
#endif // RESTORE_MONITOR_PATCH
|
||||
|
||||
if (!wlr_output_init_render(wlr_output, alloc, drw))
|
||||
return;
|
||||
@@ -1102,6 +1108,15 @@ 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);
|
||||
|
||||
#if RESTORE_MONITOR_PATCH
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (strcmp(wlr_output->name, c->output) == 0) {
|
||||
c->mon = m;
|
||||
}
|
||||
}
|
||||
updatemons(NULL, NULL);
|
||||
#endif // RESTORE_MONITOR_PATCH
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1331,6 +1346,9 @@ destroynotify(struct wl_listener *listener, void *data)
|
||||
wl_list_remove(&c->map.link);
|
||||
wl_list_remove(&c->unmap.link);
|
||||
}
|
||||
#if RESTORE_MONITOR_PATCH
|
||||
free(c->output);
|
||||
#endif // RESTORE_MONITOR_PATCH
|
||||
free(c);
|
||||
}
|
||||
|
||||
@@ -1841,6 +1859,12 @@ mapnotify(struct wl_listener *listener, void *data)
|
||||
} else {
|
||||
applyrules(c);
|
||||
}
|
||||
#if RESTORE_MONITOR_PATCH
|
||||
c->output = strdup(c->mon->wlr_output->name);
|
||||
if (c->output == NULL) {
|
||||
die("oom");
|
||||
}
|
||||
#endif // RESTORE_MONITOR_PATCH
|
||||
printstatus();
|
||||
|
||||
unset_fullscreen:
|
||||
@@ -2790,8 +2814,19 @@ void
|
||||
tagmon(const Arg *arg)
|
||||
{
|
||||
Client *sel = focustop(selmon);
|
||||
if (sel)
|
||||
setmon(sel, dirtomon(arg->i), 0);
|
||||
#if RESTORE_MONITOR_PATCH
|
||||
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");
|
||||
}
|
||||
#else // RESTORE_MONITOR_PATCH
|
||||
if (sel)
|
||||
setmon(sel, dirtomon(arg->i), 0);
|
||||
#endif // RESTORE_MONITOR_PATCH
|
||||
}
|
||||
|
||||
void
|
||||
|
Reference in New Issue
Block a user