improvement on xdg request handles
This commit is contained in:
68
xdg.c
68
xdg.c
@@ -63,11 +63,11 @@ static void xdg_toplevel_map(struct wl_listener *listener, void *data)
|
||||
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;
|
||||
if(toplevel->original.width > toplevel->output->usable_area.width)
|
||||
if (toplevel->original.width > toplevel->output->usable_area.width)
|
||||
{
|
||||
toplevel->original.width = toplevel->output->usable_area.width;
|
||||
}
|
||||
if(toplevel->original.height > toplevel->output->usable_area.height)
|
||||
if (toplevel->original.height > toplevel->output->usable_area.height)
|
||||
{
|
||||
toplevel->original.height = toplevel->output->usable_area.height;
|
||||
}
|
||||
@@ -88,21 +88,7 @@ static void xdg_toplevel_unmap(struct wl_listener *listener, void *data)
|
||||
{
|
||||
diyac_reset_cursor_mode(toplevel->server);
|
||||
}
|
||||
|
||||
if(toplevel->server->grabbed_view == toplevel)
|
||||
{
|
||||
toplevel->server->grabbed_view = NULL;
|
||||
}
|
||||
struct diyac_view * root = diyac_get_root_view(toplevel);
|
||||
wl_list_remove(&toplevel->link);
|
||||
if(root && root->mapped)
|
||||
{
|
||||
diyac_focus_view(root, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
diyac_cursor_focus(toplevel->server);
|
||||
}
|
||||
}
|
||||
|
||||
static void xdg_toplevel_request_move(
|
||||
@@ -113,6 +99,7 @@ static void xdg_toplevel_request_move(
|
||||
* decorations. Note that a more sophisticated compositor should check the
|
||||
* provided serial against a list of button press serials sent to this
|
||||
* client, to prevent the client from requesting this whenever they want. */
|
||||
wlr_log(WLR_INFO, "Request move");
|
||||
struct diyac_view *toplevel = wl_container_of(listener, toplevel, request_move);
|
||||
begin_interactive(toplevel, DIYAC_CURSOR_MOVE, 0);
|
||||
}
|
||||
@@ -125,6 +112,7 @@ static void xdg_toplevel_request_resize(
|
||||
* decorations. Note that a more sophisticated compositor should check the
|
||||
* provided serial against a list of button press serials sent to this
|
||||
* client, to prevent the client from requesting this whenever they want. */
|
||||
wlr_log(WLR_INFO, "Request resize");
|
||||
struct wlr_xdg_toplevel_resize_event *event = data;
|
||||
struct diyac_view *toplevel = wl_container_of(listener, toplevel, request_resize);
|
||||
begin_interactive(toplevel, DIYAC_CURSOR_RESIZE, event->edges);
|
||||
@@ -158,18 +146,24 @@ static void xdg_toplevel_request_maximize(
|
||||
}
|
||||
else
|
||||
{
|
||||
wlr_xdg_toplevel_set_maximized(toplevel->xdg_toplevel, true);
|
||||
wlr_xdg_toplevel_set_maximized(toplevel->xdg_toplevel, true);
|
||||
toplevel->state = DIYAC_VIEW_MAXIMIZE;
|
||||
}
|
||||
diyac_view_update_geometry(toplevel, false);
|
||||
//wlr_xdg_surface_schedule_configure(toplevel->xdg_toplevel->base);
|
||||
// wlr_xdg_surface_schedule_configure(toplevel->xdg_toplevel->base);
|
||||
}
|
||||
|
||||
static void xdg_toplevel_request_fullscreen(
|
||||
struct wl_listener *listener, void *data)
|
||||
static void xdg_toplevel_request_fullscreen(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct diyac_view *toplevel =
|
||||
wl_container_of(listener, toplevel, request_fullscreen);
|
||||
wlr_log(WLR_INFO, "Cursor state %d", toplevel->server->seat.cursor_mode);
|
||||
if (toplevel->server->seat.cursor_mode != DIYAC_CURSOR_PASSTHROUGH)
|
||||
{
|
||||
wlr_log(WLR_INFO, "The view is under move/resize, disable fullcreen event");
|
||||
wlr_xdg_toplevel_set_fullscreen(toplevel->xdg_toplevel, false);
|
||||
return;
|
||||
}
|
||||
if (!toplevel->mapped)
|
||||
{
|
||||
wlr_xdg_toplevel_set_fullscreen(toplevel->xdg_toplevel, false);
|
||||
@@ -181,7 +175,7 @@ static void xdg_toplevel_request_fullscreen(
|
||||
diyac_reset_cursor_mode(toplevel->server);
|
||||
wlr_xdg_toplevel_set_fullscreen(toplevel->xdg_toplevel, false);
|
||||
/*
|
||||
|
||||
|
||||
if (toplevel->state == DIYAC_VIEW_FULL_SCREEN)
|
||||
{
|
||||
toplevel->state = DIYAC_VIEW_NORMAL;
|
||||
@@ -194,7 +188,7 @@ static void xdg_toplevel_request_fullscreen(
|
||||
}
|
||||
|
||||
*/
|
||||
diyac_view_update_geometry(toplevel, false);
|
||||
// diyac_view_update_geometry(toplevel, false);
|
||||
}
|
||||
|
||||
static void xdg_toplevel_request_minimize(struct wl_listener *listener, void *data)
|
||||
@@ -218,6 +212,16 @@ 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);
|
||||
@@ -262,14 +266,14 @@ static void popup_unconstrain(struct diyac_popup *popup)
|
||||
static void handle_xdg_popup_commit(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct diyac_popup *popup = wl_container_of(listener, popup, commit);
|
||||
struct wlr_box popup_box ;
|
||||
struct wlr_box popup_box;
|
||||
wlr_xdg_surface_get_geometry(popup->wlr_popup->base, &popup_box);
|
||||
popup_unconstrain(popup);
|
||||
if (!wlr_box_empty(&popup_box))
|
||||
//if (popup->wlr_popup->base->initial_commit)
|
||||
// if (popup->wlr_popup->base->initial_commit)
|
||||
{
|
||||
struct diyac_view *view = popup->parent;
|
||||
//wlr_output_commit(view->output->wlr_output);
|
||||
// wlr_output_commit(view->output->wlr_output);
|
||||
/* Prevent getting called over and over again */
|
||||
wl_list_remove(&popup->commit.link);
|
||||
popup->commit.notify = NULL;
|
||||
@@ -330,10 +334,10 @@ static void xdg_popup_create(struct diyac_view *view, struct wlr_xdg_popup *wlr_
|
||||
wlr_scene_node_set_position(&view->server->xdg_popup_tree->node,
|
||||
box.x, box.y);
|
||||
}
|
||||
struct wlr_scene_tree* tree= wlr_scene_xdg_surface_create(parent_tree, wlr_popup->base);
|
||||
struct wlr_scene_tree *tree = wlr_scene_xdg_surface_create(parent_tree, wlr_popup->base);
|
||||
wlr_popup->base->surface->data = tree;
|
||||
|
||||
//wlr_scene_node_set_enabled(&parent_tree->node, false);
|
||||
|
||||
// wlr_scene_node_set_enabled(&parent_tree->node, false);
|
||||
diyac_node_descriptor_create(wlr_popup->base->surface->data,
|
||||
DIYAC_NODE_XDG_POPUP, view);
|
||||
}
|
||||
@@ -381,7 +385,6 @@ void diyac_new_xdg_surface(struct wl_listener *listener, void *data)
|
||||
assert(xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL);
|
||||
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));
|
||||
toplevel->state = DIYAC_VIEW_NORMAL;
|
||||
@@ -393,6 +396,13 @@ void diyac_new_xdg_surface(struct wl_listener *listener, void *data)
|
||||
toplevel->scene_tree = wlr_scene_xdg_surface_create(
|
||||
toplevel->server->view_tree, toplevel->xdg_toplevel->base);
|
||||
xdg_surface->data = toplevel;
|
||||
|
||||
if (toplevel->output)
|
||||
{
|
||||
wlr_fractional_scale_v1_notify_scale(xdg_surface->surface,
|
||||
toplevel->output->wlr_output->scale);
|
||||
}
|
||||
|
||||
wlr_scene_node_set_enabled(&toplevel->scene_tree->node, false);
|
||||
diyac_node_descriptor_create(&toplevel->scene_tree->node,
|
||||
DIYAC_NODE_VIEW, toplevel);
|
||||
|
Reference in New Issue
Block a user