2024-08-12 20:31:52 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2025-08-07 20:30:59 -04:00
|
|
|
#include "foreign-toplevel/foreign.h"
|
2024-08-12 20:31:52 +02:00
|
|
|
#include <assert.h>
|
|
|
|
|
#include "common/mem.h"
|
2025-08-07 20:30:59 -04:00
|
|
|
#include "foreign-toplevel/ext-foreign.h"
|
|
|
|
|
#include "foreign-toplevel/wlr-foreign.h"
|
2024-08-12 20:31:52 +02:00
|
|
|
#include "view.h"
|
|
|
|
|
|
2025-08-07 20:30:59 -04:00
|
|
|
struct foreign_toplevel {
|
|
|
|
|
/* *-toplevel implementations */
|
|
|
|
|
struct wlr_foreign_toplevel wlr_toplevel;
|
|
|
|
|
struct ext_foreign_toplevel ext_toplevel;
|
2024-08-12 20:31:52 +02:00
|
|
|
|
2025-08-07 20:30:59 -04:00
|
|
|
/* TODO: add struct xdg_x11_mapped_toplevel at some point */
|
|
|
|
|
};
|
2024-08-12 20:31:52 +02:00
|
|
|
|
|
|
|
|
struct foreign_toplevel *
|
|
|
|
|
foreign_toplevel_create(struct view *view)
|
|
|
|
|
{
|
|
|
|
|
assert(view);
|
|
|
|
|
assert(view->mapped);
|
|
|
|
|
|
|
|
|
|
struct foreign_toplevel *toplevel = znew(*toplevel);
|
2025-08-07 20:30:59 -04:00
|
|
|
wlr_foreign_toplevel_init(&toplevel->wlr_toplevel, view);
|
|
|
|
|
ext_foreign_toplevel_init(&toplevel->ext_toplevel, view);
|
2024-08-12 20:31:52 +02:00
|
|
|
|
|
|
|
|
return toplevel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
foreign_toplevel_set_parent(struct foreign_toplevel *toplevel, struct foreign_toplevel *parent)
|
|
|
|
|
{
|
|
|
|
|
assert(toplevel);
|
2025-08-07 20:30:59 -04:00
|
|
|
wlr_foreign_toplevel_set_parent(&toplevel->wlr_toplevel,
|
|
|
|
|
parent ? &parent->wlr_toplevel : NULL);
|
2024-08-12 20:31:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
foreign_toplevel_destroy(struct foreign_toplevel *toplevel)
|
|
|
|
|
{
|
|
|
|
|
assert(toplevel);
|
2025-08-07 20:30:59 -04:00
|
|
|
wlr_foreign_toplevel_finish(&toplevel->wlr_toplevel);
|
|
|
|
|
ext_foreign_toplevel_finish(&toplevel->ext_toplevel);
|
2024-08-12 20:31:52 +02:00
|
|
|
free(toplevel);
|
|
|
|
|
}
|