CasildaCompositor: add support for popup positioner
Fix issue #19 "Add support for popups reposition"
This commit is contained in:
parent
c801382458
commit
73a101e4dc
1 changed files with 22 additions and 2 deletions
|
|
@ -2625,15 +2625,35 @@ server_new_xdg_toplevel (struct wl_listener *listener, void *data)
|
|||
surface_notify_scale (xdg_toplevel->base->surface, priv->scale);
|
||||
}
|
||||
|
||||
/* Leave a margin so that popups are not right next to the compositor border */
|
||||
#define POSITIONER_MARGIN 4
|
||||
|
||||
static void
|
||||
xdg_popup_commit (struct wl_listener *listener, G_GNUC_UNUSED void *data)
|
||||
{
|
||||
CasildaCompositorPopup *popup = wl_container_of (listener, popup, commit);
|
||||
CasildaCompositorPrivate *priv = popup->priv;
|
||||
|
||||
if (popup->xdg_popup->base->initial_commit)
|
||||
wlr_xdg_surface_schedule_configure (popup->xdg_popup->base);
|
||||
{
|
||||
CasildaCompositorToplevel *toplevel = popup->toplevel;
|
||||
struct wlr_box *geo = &toplevel->xdg_toplevel->base->geometry;
|
||||
gint offset_x, offset_y;
|
||||
|
||||
casilda_compositor_queue_draw (popup->priv);
|
||||
casilda_compositor_get_scroll_offset (priv, &offset_x, &offset_y);
|
||||
|
||||
struct wlr_box box = {
|
||||
.x = offset_x + ((toplevel->x - geo->x) * -1) + POSITIONER_MARGIN,
|
||||
.y = offset_y + ((toplevel->y - geo->y) * -1) + POSITIONER_MARGIN,
|
||||
.width = gtk_widget_get_width (priv->self) - POSITIONER_MARGIN * 2,
|
||||
.height = gtk_widget_get_height (priv->self) - POSITIONER_MARGIN * 2,
|
||||
};
|
||||
|
||||
/* Define popup position box in parent toplevel coordinates */
|
||||
wlr_xdg_popup_unconstrain_from_box (popup->xdg_popup, &box);
|
||||
}
|
||||
|
||||
casilda_compositor_queue_draw (priv);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue