view: close popups on focus-change

...and the following:

- mouse-event on server-side-decoration
- window switching
This commit is contained in:
Johan Malm 2023-03-11 19:45:47 +00:00
parent 44c6cf6c1f
commit 216a83c1f9
6 changed files with 39 additions and 0 deletions

View file

@ -24,6 +24,7 @@ struct view;
struct view_impl { struct view_impl {
void (*configure)(struct view *view, struct wlr_box geo); void (*configure)(struct view *view, struct wlr_box geo);
void (*close)(struct view *view); void (*close)(struct view *view);
void (*close_popups)(struct view *view);
const char *(*get_string_prop)(struct view *view, const char *prop); const char *(*get_string_prop)(struct view *view, const char *prop);
void (*map)(struct view *view); void (*map)(struct view *view);
void (*set_activated)(struct view *view, bool activated); void (*set_activated)(struct view *view, bool activated);
@ -134,6 +135,7 @@ struct xdg_toplevel_view {
void view_set_activated(struct view *view); void view_set_activated(struct view *view);
void view_set_output(struct view *view, struct output *output); void view_set_output(struct view *view, struct output *output);
void view_close(struct view *view); void view_close(struct view *view);
void view_close_popups(struct view *view);
/** /**
* view_move_resize - resize and move view * view_move_resize - resize and move view

View file

@ -818,6 +818,9 @@ handle_press_mousebinding(struct server *server, struct cursor_context *ctx,
continue; continue;
} }
consumed_by_frame_context |= mousebind->context == LAB_SSD_FRAME; consumed_by_frame_context |= mousebind->context == LAB_SSD_FRAME;
if (ctx->view) {
view_close_popups(ctx->view);
}
actions_run(ctx->view, server, &mousebind->actions, resize_edges); actions_run(ctx->view, server, &mousebind->actions, resize_edges);
} }
} }

View file

@ -55,10 +55,20 @@ desktop_arrange_all_views(struct server *server)
} }
} }
static void
close_all_popups(struct server *server)
{
struct view *view;
wl_list_for_each(view, &server->views, link) {
view_close_popups(view);
}
}
void void
desktop_focus_and_activate_view(struct seat *seat, struct view *view) desktop_focus_and_activate_view(struct seat *seat, struct view *view)
{ {
if (!view) { if (!view) {
close_all_popups(seat->server);
seat_focus_surface(seat, NULL); seat_focus_surface(seat, NULL);
return; return;
} }
@ -97,6 +107,7 @@ desktop_focus_and_activate_view(struct seat *seat, struct view *view)
return; return;
} }
view_close_popups(view);
view_set_activated(view); view_set_activated(view);
seat_focus_surface(seat, view->surface); seat_focus_surface(seat, view->surface);
} }
@ -188,6 +199,9 @@ desktop_cycle_view(struct server *server, struct view *start_view,
return start_view; /* may be NULL */ return start_view; /* may be NULL */
} }
} }
view_close_popups(start_view);
struct view *view = start_view; struct view *view = start_view;
struct wlr_scene_node *node = &view->scene_tree->node; struct wlr_scene_node *node = &view->scene_tree->node;

View file

@ -96,6 +96,7 @@ interactive_begin(struct view *view, enum input_mode mode, uint32_t edges)
server->grab_y = seat->cursor->y; server->grab_y = seat->cursor->y;
server->grab_box = geometry; server->grab_box = geometry;
server->resize_edges = edges; server->resize_edges = edges;
view_close_popups(view);
} }
/* Returns true if view was snapped to any edge */ /* Returns true if view was snapped to any edge */

View file

@ -161,6 +161,14 @@ view_close(struct view *view)
} }
} }
void
view_close_popups(struct view *view)
{
if (view->impl->close_popups) {
view->impl->close_popups(view);
}
}
void void
view_move(struct view *view, int x, int y) view_move(struct view *view, int x, int y)
{ {

View file

@ -295,6 +295,16 @@ xdg_toplevel_view_close(struct view *view)
wlr_xdg_toplevel_send_close(xdg_toplevel_from_view(view)); wlr_xdg_toplevel_send_close(xdg_toplevel_from_view(view));
} }
static void
xdg_toplevel_view_close_popups(struct view *view)
{
struct wlr_xdg_toplevel *toplevel = xdg_toplevel_from_view(view);
struct wlr_xdg_popup *popup, *next;
wl_list_for_each_safe(popup, next, &toplevel->base->popups, link) {
wlr_xdg_popup_destroy(popup);
}
}
static void static void
xdg_toplevel_view_maximize(struct view *view, bool maximized) xdg_toplevel_view_maximize(struct view *view, bool maximized)
{ {
@ -446,6 +456,7 @@ xdg_toplevel_view_unmap(struct view *view)
static const struct view_impl xdg_toplevel_view_impl = { static const struct view_impl xdg_toplevel_view_impl = {
.configure = xdg_toplevel_view_configure, .configure = xdg_toplevel_view_configure,
.close = xdg_toplevel_view_close, .close = xdg_toplevel_view_close,
.close_popups = xdg_toplevel_view_close_popups,
.get_string_prop = xdg_toplevel_view_get_string_prop, .get_string_prop = xdg_toplevel_view_get_string_prop,
.map = xdg_toplevel_view_map, .map = xdg_toplevel_view_map,
.set_activated = xdg_toplevel_view_set_activated, .set_activated = xdg_toplevel_view_set_activated,