Skip to content

Commit

Permalink
Fully support multiple primary clients
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Hjdskes committed Jan 12, 2019
1 parent b0bd4e6 commit b6024e9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
2 changes: 1 addition & 1 deletion output.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
19 changes: 5 additions & 14 deletions seat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion seat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 2 additions & 2 deletions view.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b6024e9

Please sign in to comment.