diff --git a/output.c b/output.c index d90c102..311582c 100644 --- a/output.c +++ b/output.c @@ -133,7 +133,7 @@ handle_output_frame(struct wl_listener *listener, void *data) view_for_each_surface(view, render_surface, &rdata); /* If we have dialogs open and this view is not the top of the stack, draw an overlay. */ - if (have_dialogs_open(output->server) && + if (view_has_children(output->server, view) && view->link.prev != &output->server->views) { render_overlay(renderer, output->wlr_output, width, height); } diff --git a/seat.c b/seat.c index 4c7ccec..bbb65bf 100644 --- a/seat.c +++ b/seat.c @@ -30,15 +30,6 @@ static void drag_icon_update_position(struct cg_drag_icon *drag_icon); -bool -have_dialogs_open(struct cg_server *server) -{ - /* We only need to test if there is more than a single - element. We don't need to know the entire length of the - list. */ - return server->views.next != server->views.prev; -} - /* XDG toplevels may have nested surfaces, such as popup windows for context * menus or tooltips. This function tests if any of those are underneath the * coordinates lx and ly (in output Layout Coordinates). If so, it sets the @@ -90,14 +81,14 @@ press_cursor_button(struct cg_seat *seat, struct wlr_input_device *device, { struct cg_server *server = seat->server; - if (state == WLR_BUTTON_PRESSED && !have_dialogs_open(server)) { - /* Focus that client if the button was pressed and - there are no open dialogs. */ + if (state == WLR_BUTTON_PRESSED) { double sx, sy; struct wlr_surface *surface; struct cg_view *view = desktop_view_at(server, lx, ly, &surface, &sx, &sy); - if (view) { + /* Focus that client if the button was pressed and + it has no open dialogs. */ + if (view && !view_has_children(server, view)) { seat_set_focus(seat, view); } } @@ -726,7 +717,7 @@ seat_set_focus(struct cg_seat *seat, struct cg_view *view) view_activate(prev_view, false); } - /* Move the view to the front, but only if it isn't the + /* Move the view to the front, but only if it isn't a fullscreen view. */ if (!view_is_primary(view)) { wl_list_remove(&view->link); diff --git a/seat.h b/seat.h index ab84abf..3c5cc76 100644 --- a/seat.h +++ b/seat.h @@ -85,6 +85,5 @@ struct cg_seat *cg_seat_create(struct cg_server *server); void cg_seat_destroy(struct cg_seat *seat); struct cg_view *seat_get_focus(struct cg_seat *seat); void seat_set_focus(struct cg_seat *seat, struct cg_view *view); -bool have_dialogs_open(struct cg_server *server); #endif diff --git a/view.c b/view.c index 3361a34..5e7ee05 100644 --- a/view.c +++ b/view.c @@ -112,17 +112,17 @@ void view_destroy(struct cg_view *view) { struct cg_server *server = view->server; - bool terminate = view_is_primary(view); if (view->wlr_surface != NULL) { view_unmap(view); } free(view); - /* If this was our primary view, exit. Otherwise, focus the + /* If this was our last primary view, exit. Otherwise, focus the previous (i.e., next highest in the stack) view. Since we're still here, we know there is at least one view in the list. */ + bool terminate = wl_list_empty(&server->views); if (terminate) { wl_display_terminate(server->wl_display); } else {