use LayerSurface.mon when possible

This commit is contained in:
Leonardo Hernández Hernández 2022-06-21 16:03:20 -05:00
parent 9b84940e37
commit c1578bc14d
No known key found for this signature in database
GPG Key ID: E538897EE11B9624

16
dwl.c
View File

@ -759,14 +759,13 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
LayerSurface *layersurface = wl_container_of(listener, layersurface, surface_commit); LayerSurface *layersurface = wl_container_of(listener, layersurface, surface_commit);
struct wlr_layer_surface_v1 *wlr_layer_surface = layersurface->layer_surface; struct wlr_layer_surface_v1 *wlr_layer_surface = layersurface->layer_surface;
struct wlr_output *wlr_output = wlr_layer_surface->output; struct wlr_output *wlr_output = wlr_layer_surface->output;
Monitor *m;
if (!wlr_output || !(layersurface->mon = wlr_output->data))
return;
wlr_scene_node_reparent(layersurface->scene, wlr_scene_node_reparent(layersurface->scene,
layers[wlr_layer_surface->current.layer]); layers[wlr_layer_surface->current.layer]);
if (!wlr_output || !(m = wlr_output->data))
return;
if (wlr_layer_surface->current.committed == 0 if (wlr_layer_surface->current.committed == 0
&& layersurface->mapped == wlr_layer_surface->mapped) && layersurface->mapped == wlr_layer_surface->mapped)
return; return;
@ -775,10 +774,10 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
if (layers[wlr_layer_surface->current.layer] != layersurface->scene) { if (layers[wlr_layer_surface->current.layer] != layersurface->scene) {
wl_list_remove(&layersurface->link); wl_list_remove(&layersurface->link);
wl_list_insert(&m->layers[wlr_layer_surface->current.layer], wl_list_insert(&layersurface->mon->layers[wlr_layer_surface->current.layer],
&layersurface->link); &layersurface->link);
} }
arrangelayers(m); arrangelayers(layersurface->mon);
} }
void void
@ -1055,7 +1054,7 @@ destroylayersurfacenotify(struct wl_listener *listener, void *data)
wl_list_remove(&layersurface->surface_commit.link); wl_list_remove(&layersurface->surface_commit.link);
wlr_scene_node_destroy(layersurface->scene); wlr_scene_node_destroy(layersurface->scene);
if (layersurface->layer_surface->output) { if (layersurface->layer_surface->output) {
if (layersurface->mon) if ((layersurface->mon = layersurface->layer_surface->output->data))
arrangelayers(layersurface->mon); arrangelayers(layersurface->mon);
layersurface->layer_surface->output = NULL; layersurface->layer_surface->output = NULL;
} }
@ -1361,8 +1360,9 @@ void
maplayersurfacenotify(struct wl_listener *listener, void *data) maplayersurfacenotify(struct wl_listener *listener, void *data)
{ {
LayerSurface *layersurface = wl_container_of(listener, layersurface, map); LayerSurface *layersurface = wl_container_of(listener, layersurface, map);
layersurface->mon = layersurface->layer_surface->output->data;
wlr_surface_send_enter(layersurface->layer_surface->surface, wlr_surface_send_enter(layersurface->layer_surface->surface,
layersurface->layer_surface->output); layersurface->mon->wlr_output);
motionnotify(0); motionnotify(0);
} }