xwl.c: only add surfaces to view-list on first map

X11 apps produce surfaces which are never mapped. Excluding these from
the view-list simplifices the code.
This commit is contained in:
Johan Malm 2020-08-31 08:33:23 +01:00
parent 7afc189c06
commit a042aad9f6
4 changed files with 7 additions and 21 deletions

View file

@ -44,11 +44,7 @@ static void show_one_xdg_view(struct view *view)
static void show_one_xwl_view(struct view *view) static void show_one_xwl_view(struct view *view)
{ {
fprintf(stderr, "XWL "); fprintf(stderr, "XWL ");
if (!view->been_mapped) { fprintf(stderr, "%d ", xwl_nr_parents(view));
fprintf(stderr, "- ");
} else {
fprintf(stderr, "%d ", xwl_nr_parents(view));
}
fprintf(stderr, " %d ", fprintf(stderr, " %d ",
wl_list_length(&view->xwayland_surface->children)); wl_list_length(&view->xwayland_surface->children));
if (view->mapped) { if (view->mapped) {
@ -64,7 +60,6 @@ static void show_one_xwl_view(struct view *view)
* Other variables to consider printing: * Other variables to consider printing:
* *
* view->mapped, * view->mapped,
* view->been_mapped,
* view->xwayland_surface->override_redirect, * view->xwayland_surface->override_redirect,
* wlr_xwayland_or_surface_wants_focus(view->xwayland_surface)); * wlr_xwayland_or_surface_wants_focus(view->xwayland_surface));
* view->xwayland_surface->saved_width, * view->xwayland_surface->saved_width,

View file

@ -29,11 +29,6 @@ struct wlr_box deco_box(struct view *view, enum deco_part deco_part)
struct wlr_box box = { .x = 0, .y = 0, .width = 0, .height = 0 }; struct wlr_box box = { .x = 0, .y = 0, .width = 0, .height = 0 };
BUG_ON(!view); BUG_ON(!view);
BUG_ON(!view->surface);
if (!view || !view->surface)
return box;
BUG_ON(!view->been_mapped);
BUG_ON(!view->show_server_side_deco);
if ((view->w < 1) || (view->h < 1)) { if ((view->w < 1) || (view->h < 1)) {
warn("view (%p) has no width/height", view); warn("view (%p) has no width/height", view);
return box; return box;

View file

@ -3,7 +3,7 @@
static bool is_toplevel(struct view *view) static bool is_toplevel(struct view *view)
{ {
if (!view || !view->been_mapped) if (!view)
return false; return false;
switch (view->type) { switch (view->type) {
case LAB_XDG_SHELL_VIEW: case LAB_XDG_SHELL_VIEW:
@ -128,9 +128,7 @@ static struct wlr_xwayland_surface *top_parent(struct view *view)
static void move_xwayland_decendants_to_front(struct view *parent) static void move_xwayland_decendants_to_front(struct view *parent)
{ {
if (parent->type != LAB_XWAYLAND_VIEW) if (!parent || parent->type != LAB_XWAYLAND_VIEW)
return;
if (!parent || !parent->been_mapped)
return; return;
struct view *view, *next; struct view *view, *next;
wl_list_for_each_reverse_safe(view, next, &parent->server->views, link) wl_list_for_each_reverse_safe(view, next, &parent->server->views, link)
@ -140,7 +138,7 @@ static void move_xwayland_decendants_to_front(struct view *parent)
break; break;
if (view->type != LAB_XWAYLAND_VIEW) if (view->type != LAB_XWAYLAND_VIEW)
continue; continue;
if (!view->been_mapped || !view->mapped) if (!view->mapped)
continue; continue;
if (top_parent(view) != parent->xwayland_surface) if (top_parent(view) != parent->xwayland_surface)
continue; continue;
@ -254,8 +252,6 @@ struct view *view_at(struct server *server, double lx, double ly,
*/ */
struct view *view; struct view *view;
wl_list_for_each (view, &server->views, link) { wl_list_for_each (view, &server->views, link) {
if (!view->been_mapped)
continue;
if (_view_at(view, lx, ly, surface, sx, sy)) if (_view_at(view, lx, ly, surface, sx, sy))
return view; return view;
if (!view->show_server_side_deco) if (!view->show_server_side_deco)

View file

@ -32,6 +32,7 @@ void xwl_surface_map(struct wl_listener *listener, void *data)
if (!view->been_mapped) { if (!view->been_mapped) {
view->show_server_side_deco = has_ssd(view); view->show_server_side_deco = has_ssd(view);
view_init_position(view); view_init_position(view);
wl_list_insert(&view->server->views, &view->link);
} }
view->been_mapped = true; view->been_mapped = true;
@ -62,7 +63,8 @@ void xwl_surface_unmap(struct wl_listener *listener, void *data)
void xwl_surface_destroy(struct wl_listener *listener, void *data) void xwl_surface_destroy(struct wl_listener *listener, void *data)
{ {
struct view *view = wl_container_of(listener, view, destroy); struct view *view = wl_container_of(listener, view, destroy);
wl_list_remove(&view->link); if (view->been_mapped)
wl_list_remove(&view->link);
wl_list_remove(&view->map.link); wl_list_remove(&view->map.link);
wl_list_remove(&view->unmap.link); wl_list_remove(&view->unmap.link);
wl_list_remove(&view->destroy.link); wl_list_remove(&view->destroy.link);
@ -99,6 +101,4 @@ void xwl_surface_new(struct wl_listener *listener, void *data)
view->request_configure.notify = xwl_surface_configure; view->request_configure.notify = xwl_surface_configure;
wl_signal_add(&xwayland_surface->events.request_configure, wl_signal_add(&xwayland_surface->events.request_configure,
&view->request_configure); &view->request_configure);
wl_list_insert(&server->views, &view->link);
} }