foreign-toplevel: create generic abstraction

This commit is contained in:
Consolatis 2024-08-12 20:31:52 +02:00 committed by Johan Malm
parent 5e1f91c9d1
commit 2a825008c6
15 changed files with 463 additions and 196 deletions

View file

@ -8,6 +8,7 @@
#include "common/mem.h"
#include "config/rcxml.h"
#include "config/session.h"
#include "foreign-toplevel.h"
#include "labwc.h"
#include "node.h"
#include "ssd.h"
@ -669,17 +670,18 @@ set_initial_position(struct view *view,
static void
init_foreign_toplevel(struct view *view)
{
foreign_toplevel_handle_create(view);
assert(!view->foreign_toplevel);
view->foreign_toplevel = foreign_toplevel_create(view);
struct wlr_xwayland_surface *surface = xwayland_surface_from_view(view);
if (!surface->parent) {
return;
}
struct view *parent = (struct view *)surface->parent->data;
if (!parent || !parent->toplevel.handle) {
if (!parent || !parent->foreign_toplevel) {
return;
}
wlr_foreign_toplevel_handle_v1_set_parent(view->toplevel.handle, parent->toplevel.handle);
foreign_toplevel_set_parent(view->foreign_toplevel, parent->foreign_toplevel);
}
static void
@ -736,6 +738,19 @@ xwayland_view_map(struct view *view)
view->scene_node = &tree->node;
}
/*
* Exclude unfocusable views from wlr-foreign-toplevel. These
* views (notifications, floating toolbars, etc.) should not be
* shown in taskbars/docks/etc.
*/
if (!view->foreign_toplevel && view_is_focusable(view)) {
init_foreign_toplevel(view);
/*
* Initial outputs will be synced via
* view->events.new_outputs on view_moved()
*/
}
if (!view->been_mapped) {
check_natural_geometry(view);
set_initial_position(view, xwayland_surface);
@ -749,16 +764,6 @@ xwayland_view_map(struct view *view)
view_moved(view);
}
/*
* Exclude unfocusable views from wlr-foreign-toplevel. These
* views (notifications, floating toolbars, etc.) should not be
* shown in taskbars/docks/etc.
*/
if (!view->toplevel.handle && view_is_focusable(view)) {
init_foreign_toplevel(view);
foreign_toplevel_update_outputs(view);
}
/* Add commit here, as xwayland map/unmap can change the wlr_surface */
wl_signal_add(&xwayland_surface->surface->events.commit, &view->commit);
view->commit.notify = handle_commit;
@ -794,8 +799,9 @@ xwayland_view_unmap(struct view *view, bool client_request)
* the unmapped view doesn't show up in panels and the like.
*/
out:
if (client_request && view->toplevel.handle) {
wlr_foreign_toplevel_handle_v1_destroy(view->toplevel.handle);
if (client_request && view->foreign_toplevel) {
foreign_toplevel_destroy(view->foreign_toplevel);
view->foreign_toplevel = NULL;
}
}