improve: better support foreign protocol
This commit is contained in:
61
xdg.c
61
xdg.c
@@ -56,10 +56,10 @@ static void begin_interactive(struct diyac_view *toplevel,
|
||||
|
||||
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)
|
||||
if (toplevel->mapped)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -67,13 +67,14 @@ static void xdg_toplevel_map(struct wl_listener *listener, void *data)
|
||||
wlr_xdg_toplevel_set_wm_capabilities(toplevel->xdg_toplevel,
|
||||
WLR_XDG_TOPLEVEL_WM_CAPABILITIES_MAXIMIZE |
|
||||
WLR_XDG_TOPLEVEL_WM_CAPABILITIES_MINIMIZE);
|
||||
//WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN
|
||||
//WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN
|
||||
*/
|
||||
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);
|
||||
diyac_view_update_app_id(toplevel);
|
||||
diyac_view_update_title(toplevel);
|
||||
toplevel->original.x = (toplevel->output->usable_area.width - toplevel->original.width) / 2;
|
||||
toplevel->original.y = (toplevel->output->usable_area.height - toplevel->original.height) / 2;
|
||||
if (toplevel->original.width > toplevel->output->usable_area.width)
|
||||
@@ -98,15 +99,15 @@ static void xdg_toplevel_unmap(struct wl_listener *listener, void *data)
|
||||
{
|
||||
diyac_reset_cursor_mode(toplevel->server);
|
||||
}
|
||||
if(toplevel->state.fullscreen)
|
||||
if (toplevel->state.fullscreen)
|
||||
{
|
||||
/**
|
||||
* When a client exit during fullscreen mode, the top layer shall
|
||||
* be restored as it is currently disabled
|
||||
*/
|
||||
*/
|
||||
wlr_scene_node_set_enabled(&toplevel->output->scenes.top->node, true);
|
||||
}
|
||||
if(toplevel->server->active_view == toplevel)
|
||||
if (toplevel->server->active_view == toplevel)
|
||||
{
|
||||
toplevel->server->active_view = NULL;
|
||||
}
|
||||
@@ -114,11 +115,11 @@ static void xdg_toplevel_unmap(struct wl_listener *listener, void *data)
|
||||
if (root && root->mapped)
|
||||
{
|
||||
diyac_focus_view(root, true);
|
||||
//wlr_log(WLR_INFO, "focus root");
|
||||
// wlr_log(WLR_INFO, "focus root");
|
||||
}
|
||||
else
|
||||
{
|
||||
//wlr_log(WLR_INFO, "focus topmost");
|
||||
// wlr_log(WLR_INFO, "focus topmost");
|
||||
diyac_focus_topmost_view(toplevel->server, true);
|
||||
}
|
||||
|
||||
@@ -169,7 +170,7 @@ static void xdg_toplevel_request_fullscreen(struct wl_listener *listener, void *
|
||||
{
|
||||
struct diyac_view *toplevel =
|
||||
wl_container_of(listener, toplevel, request_fullscreen);
|
||||
diyac_view_set_fullscreen(toplevel,toplevel->xdg_toplevel->requested.fullscreen);
|
||||
diyac_view_set_fullscreen(toplevel, toplevel->xdg_toplevel->requested.fullscreen);
|
||||
}
|
||||
|
||||
static void xdg_toplevel_request_minimize(struct wl_listener *listener, void *data)
|
||||
@@ -183,7 +184,10 @@ 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);
|
||||
|
||||
if (toplevel->toplevel.handle)
|
||||
{
|
||||
wlr_foreign_toplevel_handle_v1_destroy(toplevel->toplevel.handle);
|
||||
}
|
||||
wl_list_remove(&toplevel->map.link);
|
||||
wl_list_remove(&toplevel->unmap.link);
|
||||
wl_list_remove(&toplevel->destroy.link);
|
||||
@@ -191,6 +195,11 @@ static void xdg_toplevel_destroy(struct wl_listener *listener, void *data)
|
||||
wl_list_remove(&toplevel->request_resize.link);
|
||||
wl_list_remove(&toplevel->request_maximize.link);
|
||||
wl_list_remove(&toplevel->request_fullscreen.link);
|
||||
|
||||
wl_list_remove(&toplevel->set_app_id.link);
|
||||
wl_list_remove(&toplevel->new_popup.link);
|
||||
wl_list_remove(&toplevel->set_title.link);
|
||||
|
||||
free(toplevel);
|
||||
}
|
||||
|
||||
@@ -215,13 +224,12 @@ static void popup_unconstrain(struct diyac_popup *popup)
|
||||
struct wlr_output_layout *output_layout = server->output_layout;
|
||||
struct wlr_output *wlr_output = view->output->wlr_output;
|
||||
struct wlr_box usable = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = view->output->wlr_output->width,
|
||||
.height = view->output->wlr_output->height
|
||||
};
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = view->output->wlr_output->width,
|
||||
.height = view->output->wlr_output->height};
|
||||
struct diyac_view *root = diyac_get_root_view(view);
|
||||
if(!root || ! root->state.fullscreen)
|
||||
if (!root || !root->state.fullscreen)
|
||||
{
|
||||
usable = view->output->usable_area;
|
||||
}
|
||||
@@ -316,9 +324,14 @@ static void xdg_popup_create(struct diyac_view *view, struct wlr_xdg_popup *wlr_
|
||||
|
||||
static void xdg_set_appid_notify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct diyac_view *xdg_toplevel_view =
|
||||
wl_container_of(listener, xdg_toplevel_view, set_app_id);
|
||||
wlr_log(WLR_INFO, "set application id");
|
||||
struct diyac_view *view = wl_container_of(listener, view, set_app_id);
|
||||
diyac_view_update_app_id(view);
|
||||
}
|
||||
|
||||
static void xdg_set_title_notify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct diyac_view *view = wl_container_of(listener, view, set_title);
|
||||
diyac_view_update_title(view);
|
||||
}
|
||||
|
||||
static void xdg_new_popup_notify(struct wl_listener *listener, void *data)
|
||||
@@ -358,7 +371,7 @@ void diyac_new_xdg_surface(struct wl_listener *listener, void *data)
|
||||
wlr_log(WLR_INFO, "diyac_new_xdg_surface: Creating new application windows");
|
||||
wlr_xdg_surface_ping(xdg_surface);
|
||||
/* Allocate a diyac_view for this surface */
|
||||
struct diyac_view *toplevel = calloc(1, sizeof(*toplevel));
|
||||
struct diyac_view *toplevel = calloc(1, sizeof(*toplevel));
|
||||
memset(&toplevel->state, 0, sizeof(toplevel->state));
|
||||
memset(&toplevel->requested, 0, sizeof(toplevel->requested));
|
||||
toplevel->server = server;
|
||||
@@ -379,6 +392,8 @@ void diyac_new_xdg_surface(struct wl_listener *listener, void *data)
|
||||
wlr_scene_node_set_enabled(&toplevel->scene_tree->node, false);
|
||||
diyac_node_descriptor_create(&toplevel->scene_tree->node,
|
||||
DIYAC_NODE_VIEW, toplevel);
|
||||
diyac_init_foreign_toplevel(toplevel);
|
||||
|
||||
/* Listen to the various events it can emit */
|
||||
toplevel->map.notify = xdg_toplevel_map;
|
||||
wl_signal_add(&xdg_surface->surface->events.map, &toplevel->map);
|
||||
@@ -403,6 +418,10 @@ void diyac_new_xdg_surface(struct wl_listener *listener, void *data)
|
||||
&toplevel->request_fullscreen);
|
||||
toplevel->new_popup.notify = xdg_new_popup_notify;
|
||||
wl_signal_add(&xdg_surface->events.new_popup, &toplevel->new_popup);
|
||||
|
||||
toplevel->set_app_id.notify = xdg_set_appid_notify;
|
||||
wl_signal_add(&xdg_toplevel->events.set_app_id, &toplevel->set_app_id);
|
||||
|
||||
toplevel->set_title.notify = xdg_set_title_notify;
|
||||
wl_signal_add(&xdg_toplevel->events.set_title, &toplevel->set_title);
|
||||
}
|
Reference in New Issue
Block a user