mirror of
https://github.com/cage-kiosk/cage.git
synced 2026-02-05 04:06:24 -05:00
Fully support multiple primary clients
This is the path we settled on in #24. That is: any new toplevel window takes over the Cage display, hiding any previous toplevels until it is closed. Only when the last toplevel is closed, does Cage exit as well.
This commit is contained in:
parent
b0bd4e680d
commit
b6024e982f
4 changed files with 8 additions and 18 deletions
2
output.c
2
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);
|
||||
}
|
||||
|
|
|
|||
19
seat.c
19
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);
|
||||
|
|
|
|||
1
seat.h
1
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
|
||||
|
|
|
|||
4
view.c
4
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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue