mirror of
https://github.com/labwc/labwc.git
synced 2025-11-30 06:59:52 -05:00
view: factor out view_impl_init_foreign_toplevel()
This commit is contained in:
parent
51c2003ed8
commit
5543affe35
5 changed files with 40 additions and 37 deletions
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
struct view;
|
struct view;
|
||||||
|
|
||||||
|
void view_impl_init_foreign_toplevel(struct view *view);
|
||||||
|
|
||||||
void view_impl_map(struct view *view);
|
void view_impl_map(struct view *view);
|
||||||
void view_impl_unmap(struct view *view);
|
void view_impl_unmap(struct view *view);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,7 @@ struct view_impl {
|
||||||
void (*unmap)(struct view *view, bool client_request);
|
void (*unmap)(struct view *view, bool client_request);
|
||||||
void (*maximize)(struct view *view, enum view_axis maximized);
|
void (*maximize)(struct view *view, enum view_axis maximized);
|
||||||
void (*minimize)(struct view *view, bool minimize);
|
void (*minimize)(struct view *view, bool minimize);
|
||||||
|
struct view *(*get_parent)(struct view *self);
|
||||||
struct view *(*get_root)(struct view *self);
|
struct view *(*get_root)(struct view *self);
|
||||||
void (*append_children)(struct view *self, struct wl_array *children);
|
void (*append_children)(struct view *self, struct wl_array *children);
|
||||||
bool (*is_modal_dialog)(struct view *self);
|
bool (*is_modal_dialog)(struct view *self);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,24 @@
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
#include "window-rules.h"
|
#include "window-rules.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
view_impl_init_foreign_toplevel(struct view *view)
|
||||||
|
{
|
||||||
|
if (view->foreign_toplevel) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
view->foreign_toplevel = foreign_toplevel_create(view);
|
||||||
|
|
||||||
|
if (view->impl->get_parent) {
|
||||||
|
struct view *parent = view->impl->get_parent(view);
|
||||||
|
if (parent && parent->foreign_toplevel) {
|
||||||
|
foreign_toplevel_set_parent(view->foreign_toplevel,
|
||||||
|
parent->foreign_toplevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
view_impl_map(struct view *view)
|
view_impl_map(struct view *view)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
29
src/xdg.c
29
src/xdg.c
|
|
@ -575,6 +575,14 @@ xdg_toplevel_view_minimize(struct view *view, bool minimized)
|
||||||
/* noop */
|
/* noop */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct view *
|
||||||
|
xdg_toplevel_view_get_parent(struct view *view)
|
||||||
|
{
|
||||||
|
struct wlr_xdg_toplevel *toplevel = xdg_toplevel_from_view(view);
|
||||||
|
return toplevel->parent ?
|
||||||
|
(struct view *)toplevel->parent->base->data : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static struct wlr_xdg_toplevel *
|
static struct wlr_xdg_toplevel *
|
||||||
top_parent_of(struct view *view)
|
top_parent_of(struct view *view)
|
||||||
{
|
{
|
||||||
|
|
@ -755,24 +763,6 @@ set_initial_position(struct view *view)
|
||||||
view_place_by_policy(view, /* allow_cursor */ true, rc.placement_policy);
|
view_place_by_policy(view, /* allow_cursor */ true, rc.placement_policy);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
init_foreign_toplevel(struct view *view)
|
|
||||||
{
|
|
||||||
assert(!view->foreign_toplevel);
|
|
||||||
view->foreign_toplevel = foreign_toplevel_create(view);
|
|
||||||
|
|
||||||
struct wlr_xdg_toplevel *toplevel = xdg_toplevel_from_view(view);
|
|
||||||
if (!toplevel->parent) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
struct wlr_xdg_surface *surface = toplevel->parent->base;
|
|
||||||
struct view *parent = surface->data;
|
|
||||||
if (!parent->foreign_toplevel) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
foreign_toplevel_set_parent(view->foreign_toplevel, parent->foreign_toplevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xdg_toplevel_view_map(struct view *view)
|
xdg_toplevel_view_map(struct view *view)
|
||||||
{
|
{
|
||||||
|
|
@ -799,7 +789,7 @@ xdg_toplevel_view_map(struct view *view)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!view->foreign_toplevel) {
|
if (!view->foreign_toplevel) {
|
||||||
init_foreign_toplevel(view);
|
view_impl_init_foreign_toplevel(view);
|
||||||
/*
|
/*
|
||||||
* Initial outputs will be synced via
|
* Initial outputs will be synced via
|
||||||
* view->events.new_outputs on view_moved()
|
* view->events.new_outputs on view_moved()
|
||||||
|
|
@ -889,6 +879,7 @@ static const struct view_impl xdg_toplevel_view_impl = {
|
||||||
.unmap = xdg_toplevel_view_unmap,
|
.unmap = xdg_toplevel_view_unmap,
|
||||||
.maximize = xdg_toplevel_view_maximize,
|
.maximize = xdg_toplevel_view_maximize,
|
||||||
.minimize = xdg_toplevel_view_minimize,
|
.minimize = xdg_toplevel_view_minimize,
|
||||||
|
.get_parent = xdg_toplevel_view_get_parent,
|
||||||
.get_root = xdg_toplevel_view_get_root,
|
.get_root = xdg_toplevel_view_get_root,
|
||||||
.append_children = xdg_toplevel_view_append_children,
|
.append_children = xdg_toplevel_view_append_children,
|
||||||
.is_modal_dialog = xdg_toplevel_view_is_modal_dialog,
|
.is_modal_dialog = xdg_toplevel_view_is_modal_dialog,
|
||||||
|
|
|
||||||
|
|
@ -192,6 +192,13 @@ xwayland_view_offer_focus(struct view *view)
|
||||||
wlr_xwayland_surface_offer_focus(xwayland_surface_from_view(view));
|
wlr_xwayland_surface_offer_focus(xwayland_surface_from_view(view));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct view *
|
||||||
|
xwayland_view_get_parent(struct view *view)
|
||||||
|
{
|
||||||
|
struct wlr_xwayland_surface *xsurface = xwayland_surface_from_view(view);
|
||||||
|
return xsurface->parent ? (struct view *)xsurface->parent->data : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static struct wlr_xwayland_surface *
|
static struct wlr_xwayland_surface *
|
||||||
top_parent_of(struct view *view)
|
top_parent_of(struct view *view)
|
||||||
{
|
{
|
||||||
|
|
@ -767,23 +774,6 @@ set_initial_position(struct view *view,
|
||||||
view_adjust_for_layout_change(view);
|
view_adjust_for_layout_change(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
init_foreign_toplevel(struct view *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->foreign_toplevel) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
foreign_toplevel_set_parent(view->foreign_toplevel, parent->foreign_toplevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_surface(struct view *view, struct wlr_surface *surface)
|
set_surface(struct view *view, struct wlr_surface *surface)
|
||||||
{
|
{
|
||||||
|
|
@ -862,7 +852,7 @@ xwayland_view_map(struct view *view)
|
||||||
* shown in taskbars/docks/etc.
|
* shown in taskbars/docks/etc.
|
||||||
*/
|
*/
|
||||||
if (!view->foreign_toplevel && view_is_focusable(view)) {
|
if (!view->foreign_toplevel && view_is_focusable(view)) {
|
||||||
init_foreign_toplevel(view);
|
view_impl_init_foreign_toplevel(view);
|
||||||
/*
|
/*
|
||||||
* Initial outputs will be synced via
|
* Initial outputs will be synced via
|
||||||
* view->events.new_outputs on view_moved()
|
* view->events.new_outputs on view_moved()
|
||||||
|
|
@ -1037,6 +1027,7 @@ static const struct view_impl xwayland_view_impl = {
|
||||||
.unmap = xwayland_view_unmap,
|
.unmap = xwayland_view_unmap,
|
||||||
.maximize = xwayland_view_maximize,
|
.maximize = xwayland_view_maximize,
|
||||||
.minimize = xwayland_view_minimize,
|
.minimize = xwayland_view_minimize,
|
||||||
|
.get_parent = xwayland_view_get_parent,
|
||||||
.get_root = xwayland_view_get_root,
|
.get_root = xwayland_view_get_root,
|
||||||
.append_children = xwayland_view_append_children,
|
.append_children = xwayland_view_append_children,
|
||||||
.is_modal_dialog = xwayland_view_is_modal_dialog,
|
.is_modal_dialog = xwayland_view_is_modal_dialog,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue