CasildaCompositor: add viewporter support
- Send scale to surfaces for fractional scaling to work. - Use surface viewport data for snapshot
This commit is contained in:
parent
c0ef004bb9
commit
dd96aea9e2
1 changed files with 24 additions and 7 deletions
|
|
@ -189,6 +189,7 @@
|
|||
#include <wlr/types/wlr_xcursor_manager.h>
|
||||
#include <wlr/types/wlr_xdg_activation_v1.h>
|
||||
#include <wlr/types/wlr_xdg_shell.h>
|
||||
#include <wlr/types/wlr_viewporter.h>
|
||||
#include <wlr/types/wlr_fractional_scale_v1.h>
|
||||
#include "xdg-shell-protocol.h"
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
|
|
@ -642,7 +643,6 @@ static void texture_debug_add_weak (gpointer object)
|
|||
typedef struct {
|
||||
GtkSnapshot *snapshot;
|
||||
GdkGLContext *gl_context;
|
||||
gfloat scale;
|
||||
struct timespec now;
|
||||
} SnapshotData;
|
||||
|
||||
|
|
@ -662,12 +662,23 @@ snapshot_surfaces (struct wlr_surface *surface, int sx, int sy, void *data)
|
|||
gtk_snapshot_save (sdata->snapshot);
|
||||
gtk_snapshot_translate (sdata->snapshot, &GRAPHENE_POINT_INIT (sx, sy));
|
||||
|
||||
if (sdata->scale > 1.0) {
|
||||
w = w / sdata->scale;
|
||||
h = h / sdata->scale;
|
||||
}
|
||||
if (surface->current.viewport.has_src)
|
||||
{
|
||||
struct wlr_fbox *src = &surface->current.viewport.src;
|
||||
gtk_snapshot_push_clip (sdata->snapshot, &GRAPHENE_RECT_INIT (src->x, src->y, src->width, src->height));
|
||||
}
|
||||
|
||||
if (surface->current.viewport.has_dst)
|
||||
{
|
||||
w = surface->current.viewport.dst_width;
|
||||
h = surface->current.viewport.dst_height;
|
||||
}
|
||||
|
||||
gdk_paintable_snapshot (GDK_PAINTABLE (tex), sdata->snapshot, w, h);
|
||||
|
||||
if (surface->current.viewport.has_src)
|
||||
gtk_snapshot_pop (sdata->snapshot);
|
||||
|
||||
gtk_snapshot_restore (sdata->snapshot);
|
||||
|
||||
wlr_surface_send_frame_done (surface, &sdata->now);
|
||||
|
|
@ -769,10 +780,9 @@ static void
|
|||
casilda_compositor_snapshot (GtkWidget *widget, GtkSnapshot *snapshot)
|
||||
{
|
||||
CasildaCompositorPrivate *priv = GET_PRIVATE (widget);
|
||||
SnapshotData data = { snapshot, priv->gl_context, 1.0, {0, } };
|
||||
SnapshotData data = { snapshot, priv->gl_context, {0, } };
|
||||
gint x, y;
|
||||
|
||||
data.scale = gdk_surface_get_scale (gtk_native_get_surface (gtk_widget_get_native (widget)));
|
||||
clock_gettime (CLOCK_MONOTONIC, &data.now);
|
||||
|
||||
/* Translate by scrollable offset */
|
||||
|
|
@ -2278,6 +2288,8 @@ xdg_subsurface_new_subsurface (struct wl_listener *listener, void *data)
|
|||
|
||||
subsurface->destroy.notify = xdg_subsurface_destroy;
|
||||
wl_signal_add (&wlr_subsurface->events.destroy, &subsurface->destroy);
|
||||
|
||||
wlr_fractional_scale_v1_notify_scale(wlr_subsurface->surface, subsurface->priv->output.scale);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2475,6 +2487,8 @@ server_new_xdg_toplevel (struct wl_listener *listener, void *data)
|
|||
|
||||
toplevel->set_app_id.notify = xdg_toplevel_set_app_id;
|
||||
wl_signal_add (&xdg_toplevel->events.set_app_id, &toplevel->set_app_id);
|
||||
|
||||
wlr_fractional_scale_v1_notify_scale(xdg_toplevel->base->surface, priv->output.scale);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -2557,6 +2571,8 @@ server_new_xdg_popup (G_GNUC_UNUSED struct wl_listener *listener, void *data)
|
|||
|
||||
compositor_subsurfaces_init (&popup->subsurfaces, xdg_popup->base->surface);
|
||||
|
||||
wlr_fractional_scale_v1_notify_scale(xdg_popup->base->surface, priv->output.scale);
|
||||
|
||||
casilda_compositor_queue_draw (popup->priv);
|
||||
}
|
||||
|
||||
|
|
@ -2712,6 +2728,7 @@ casilda_compositor_wlr_init (CasildaCompositorPrivate *priv)
|
|||
wlr_subcompositor_create (priv->wl_display);
|
||||
wlr_data_device_manager_create (priv->wl_display);
|
||||
|
||||
wlr_viewporter_create (priv->wl_display);
|
||||
wlr_fractional_scale_manager_v1_create (priv->wl_display, 1);
|
||||
|
||||
/* Set up xdg-shell version 3 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue