Merge branch 'handleUnplug' into output-management

This commit is contained in:
Stivvo 2020-10-25 11:08:08 +01:00
commit 927352865c

15
dwl.c
View File

@ -205,6 +205,7 @@ static void chvt(const Arg *arg);
static void cleanup(void); static void cleanup(void);
static void cleanupkeyboard(struct wl_listener *listener, void *data); static void cleanupkeyboard(struct wl_listener *listener, void *data);
static void cleanupmon(struct wl_listener *listener, void *data); static void cleanupmon(struct wl_listener *listener, void *data);
static void closemon(Monitor *m);
static void commitlayersurfacenotify(struct wl_listener *listener, void *data); static void commitlayersurfacenotify(struct wl_listener *listener, void *data);
static void commitnotify(struct wl_listener *listener, void *data); static void commitnotify(struct wl_listener *listener, void *data);
static void createkeyboard(struct wlr_input_device *device); static void createkeyboard(struct wlr_input_device *device);
@ -694,8 +695,7 @@ void
cleanupmon(struct wl_listener *listener, void *data) cleanupmon(struct wl_listener *listener, void *data)
{ {
struct wlr_output *wlr_output = data; struct wlr_output *wlr_output = data;
Monitor *m = wlr_output->data, *newmon; Monitor *m = wlr_output->data;
Client *c;
wl_list_remove(&m->destroy.link); wl_list_remove(&m->destroy.link);
wl_list_remove(&m->frame.link); wl_list_remove(&m->frame.link);
@ -703,6 +703,16 @@ cleanupmon(struct wl_listener *listener, void *data)
wlr_output_layout_remove(output_layout, m->wlr_output); wlr_output_layout_remove(output_layout, m->wlr_output);
updatemons(); updatemons();
closemon(m);
free(m);
}
void
closemon(Monitor *m)
{
// move all the clients on a closed monitor to another one
Monitor *newmon;
Client *c;
wl_list_for_each(newmon, &mons, link) { wl_list_for_each(newmon, &mons, link) {
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
@ -715,7 +725,6 @@ cleanupmon(struct wl_listener *listener, void *data)
} }
break; break;
} }
free(m);
} }
void void