mirror of
https://github.com/labwc/labwc.git
synced 2025-11-30 06:59:52 -05:00
Currently, the dependencies between foreign-toplevel[-internal],
ext-foreign, and wlr-foreign are cyclical and a bit complex.
I suggest we reorganize it into a simpler hierarchy:
foreign-toplevel/
-> foreign.c/h
-> (depends on) ext-foreign.c/h
-> (depends on) wlr-foreign.c/h
The refactored code is smaller and (IMO) easier to follow.
In detail:
- Add include/foreign-toplevel folder mirroring src/foreign-toplevel
- Split foreign-toplevel-internal.h to ext-foreign.h and wlr-foreign.h
- Eliminate ext-/wlr-foreign.c -> foreign.c reverse dependencies
(including internal signals and foreign_request* functions)
- Make struct foreign_toplevel private to foreign.c
Lightly tested with qmpanel (which uses wlr-foreign-toplevel).
v2: reorder foreign-toplevel internal API funcs
45 lines
1.2 KiB
C
45 lines
1.2 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
#include "foreign-toplevel/foreign.h"
|
|
#include <assert.h>
|
|
#include "common/mem.h"
|
|
#include "foreign-toplevel/ext-foreign.h"
|
|
#include "foreign-toplevel/wlr-foreign.h"
|
|
#include "view.h"
|
|
|
|
struct foreign_toplevel {
|
|
/* *-toplevel implementations */
|
|
struct wlr_foreign_toplevel wlr_toplevel;
|
|
struct ext_foreign_toplevel ext_toplevel;
|
|
|
|
/* TODO: add struct xdg_x11_mapped_toplevel at some point */
|
|
};
|
|
|
|
struct foreign_toplevel *
|
|
foreign_toplevel_create(struct view *view)
|
|
{
|
|
assert(view);
|
|
assert(view->mapped);
|
|
|
|
struct foreign_toplevel *toplevel = znew(*toplevel);
|
|
wlr_foreign_toplevel_init(&toplevel->wlr_toplevel, view);
|
|
ext_foreign_toplevel_init(&toplevel->ext_toplevel, view);
|
|
|
|
return toplevel;
|
|
}
|
|
|
|
void
|
|
foreign_toplevel_set_parent(struct foreign_toplevel *toplevel, struct foreign_toplevel *parent)
|
|
{
|
|
assert(toplevel);
|
|
wlr_foreign_toplevel_set_parent(&toplevel->wlr_toplevel,
|
|
parent ? &parent->wlr_toplevel : NULL);
|
|
}
|
|
|
|
void
|
|
foreign_toplevel_destroy(struct foreign_toplevel *toplevel)
|
|
{
|
|
assert(toplevel);
|
|
wlr_foreign_toplevel_finish(&toplevel->wlr_toplevel);
|
|
ext_foreign_toplevel_finish(&toplevel->ext_toplevel);
|
|
free(toplevel);
|
|
}
|