feat: add wlr_foreign_toplevel support
This commit is contained in:
48
xdg.c
48
xdg.c
@@ -7,6 +7,7 @@
|
||||
#include "node.h"
|
||||
#include "view.h"
|
||||
#include "output.h"
|
||||
#include "foreign.h"
|
||||
|
||||
static void xdg_popup_create(struct diyac_view *view, struct wlr_xdg_popup *wlr_popup);
|
||||
|
||||
@@ -58,6 +59,10 @@ static void xdg_toplevel_map(struct wl_listener *listener, void *data)
|
||||
|
||||
/* Called when the surface is mapped, or ready to display on-screen. */
|
||||
struct diyac_view *toplevel = wl_container_of(listener, toplevel, map);
|
||||
if(toplevel->mapped)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/*
|
||||
wlr_xdg_toplevel_set_wm_capabilities(toplevel->xdg_toplevel,
|
||||
WLR_XDG_TOPLEVEL_WM_CAPABILITIES_MAXIMIZE |
|
||||
@@ -67,6 +72,7 @@ static void xdg_toplevel_map(struct wl_listener *listener, void *data)
|
||||
wlr_xdg_surface_get_geometry(toplevel->xdg_toplevel->base, &toplevel->original);
|
||||
wlr_scene_node_set_enabled(&toplevel->scene_tree->node, true);
|
||||
toplevel->mapped = true;
|
||||
diyac_init_foreign_toplevel(toplevel);
|
||||
wl_list_insert(&toplevel->server->views, &toplevel->link);
|
||||
toplevel->original.x = (toplevel->output->usable_area.width - toplevel->original.width) / 2;
|
||||
toplevel->original.y = (toplevel->output->usable_area.height - toplevel->original.height) / 2;
|
||||
@@ -100,6 +106,22 @@ static void xdg_toplevel_unmap(struct wl_listener *listener, void *data)
|
||||
*/
|
||||
wlr_scene_node_set_enabled(&toplevel->output->scenes.top->node, true);
|
||||
}
|
||||
if(toplevel->server->active_view == toplevel)
|
||||
{
|
||||
toplevel->server->active_view = NULL;
|
||||
}
|
||||
struct diyac_view *root = diyac_get_root_view(toplevel);
|
||||
if (root && root->mapped)
|
||||
{
|
||||
diyac_focus_view(root, true);
|
||||
//wlr_log(WLR_INFO, "focus root");
|
||||
}
|
||||
else
|
||||
{
|
||||
//wlr_log(WLR_INFO, "focus topmost");
|
||||
diyac_focus_topmost_view(toplevel->server, true);
|
||||
}
|
||||
|
||||
wl_list_remove(&toplevel->link);
|
||||
}
|
||||
|
||||
@@ -140,31 +162,21 @@ static void xdg_toplevel_request_maximize(
|
||||
|
||||
struct diyac_view *toplevel =
|
||||
wl_container_of(listener, toplevel, request_maximize);
|
||||
toplevel->requested.maximized = toplevel->xdg_toplevel->requested.maximized;
|
||||
diyac_reset_cursor_mode(toplevel->server);
|
||||
diyac_view_update_geometry(toplevel, false);
|
||||
diyac_view_set_maximize(toplevel, toplevel->xdg_toplevel->requested.maximized);
|
||||
}
|
||||
|
||||
static void xdg_toplevel_request_fullscreen(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct diyac_view *toplevel =
|
||||
wl_container_of(listener, toplevel, request_fullscreen);
|
||||
toplevel->requested.fullscreen = toplevel->xdg_toplevel->requested.fullscreen;
|
||||
/**
|
||||
* TODO: use client specific output for fullscreen
|
||||
* toplevel->xdg_toplevel->requested.fullscreen_output
|
||||
*/
|
||||
diyac_reset_cursor_mode(toplevel->server);
|
||||
diyac_view_update_geometry(toplevel, false);
|
||||
diyac_view_set_fullscreen(toplevel,toplevel->xdg_toplevel->requested.fullscreen);
|
||||
}
|
||||
|
||||
static void xdg_toplevel_request_minimize(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct diyac_view *toplevel =
|
||||
wl_container_of(listener, toplevel, request_minimize);
|
||||
toplevel->requested.minimized = toplevel->xdg_toplevel->requested.minimized;
|
||||
//TODO implement minimize
|
||||
wlr_xdg_surface_schedule_configure(toplevel->xdg_toplevel->base);
|
||||
diyac_view_set_mimimize(toplevel, toplevel->xdg_toplevel->requested.minimized);
|
||||
}
|
||||
|
||||
static void xdg_toplevel_destroy(struct wl_listener *listener, void *data)
|
||||
@@ -172,16 +184,6 @@ static void xdg_toplevel_destroy(struct wl_listener *listener, void *data)
|
||||
/* Called when the xdg_toplevel is destroyed. */
|
||||
struct diyac_view *toplevel = wl_container_of(listener, toplevel, destroy);
|
||||
|
||||
struct diyac_view *root = diyac_get_root_view(toplevel);
|
||||
if (root && root->mapped)
|
||||
{
|
||||
diyac_focus_view(root, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
diyac_focus_topmost_view(toplevel->server, true);
|
||||
}
|
||||
|
||||
wl_list_remove(&toplevel->map.link);
|
||||
wl_list_remove(&toplevel->unmap.link);
|
||||
wl_list_remove(&toplevel->destroy.link);
|
||||
|
Reference in New Issue
Block a user