mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-23 12:20:08 +00:00
Merge branch 'pointer-viewporter-again' into 'main'
wayland: Bring back the pointer viewporter See merge request GNOME/gtk!7760
This commit is contained in:
commit
cbadb1ed8e
@ -402,6 +402,38 @@ _XcursorFindBestSize (XcursorFileHeader *fileHeader,
|
|||||||
if (fileHeader->tocs[n].type != XCURSOR_IMAGE_TYPE)
|
if (fileHeader->tocs[n].type != XCURSOR_IMAGE_TYPE)
|
||||||
continue;
|
continue;
|
||||||
thisSize = fileHeader->tocs[n].subtype;
|
thisSize = fileHeader->tocs[n].subtype;
|
||||||
|
if (thisSize == size)
|
||||||
|
{
|
||||||
|
bestSize = size;
|
||||||
|
nsizes++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bestSize)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
for (n = 0; n < fileHeader->ntoc; n++)
|
||||||
|
{
|
||||||
|
if (fileHeader->tocs[n].type != XCURSOR_IMAGE_TYPE)
|
||||||
|
continue;
|
||||||
|
thisSize = fileHeader->tocs[n].subtype;
|
||||||
|
if (thisSize == 2 * size)
|
||||||
|
{
|
||||||
|
bestSize = 2 * size;
|
||||||
|
nsizes++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bestSize)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
for (n = 0; n < fileHeader->ntoc; n++)
|
||||||
|
{
|
||||||
|
if (fileHeader->tocs[n].type != XCURSOR_IMAGE_TYPE)
|
||||||
|
continue;
|
||||||
|
thisSize = fileHeader->tocs[n].subtype;
|
||||||
|
if (thisSize < size)
|
||||||
|
continue;
|
||||||
if (!bestSize || dist (thisSize, size) < dist (bestSize, size))
|
if (!bestSize || dist (thisSize, size) < dist (bestSize, size))
|
||||||
{
|
{
|
||||||
bestSize = thisSize;
|
bestSize = thisSize;
|
||||||
@ -410,6 +442,25 @@ _XcursorFindBestSize (XcursorFileHeader *fileHeader,
|
|||||||
else if (thisSize == bestSize)
|
else if (thisSize == bestSize)
|
||||||
nsizes++;
|
nsizes++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bestSize)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
for (n = 0; n < fileHeader->ntoc; n++)
|
||||||
|
{
|
||||||
|
if (fileHeader->tocs[n].type != XCURSOR_IMAGE_TYPE)
|
||||||
|
continue;
|
||||||
|
thisSize = fileHeader->tocs[n].subtype;
|
||||||
|
if (!bestSize || dist (thisSize, size) < dist (bestSize, size))
|
||||||
|
{
|
||||||
|
bestSize = thisSize;
|
||||||
|
nsizes = 1;
|
||||||
|
}
|
||||||
|
else if (thisSize == bestSize)
|
||||||
|
nsizes++;
|
||||||
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
*nsizesp = nsizes;
|
*nsizesp = nsizes;
|
||||||
return bestSize;
|
return bestSize;
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,8 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
|
|||||||
int *hotspot_x,
|
int *hotspot_x,
|
||||||
int *hotspot_y,
|
int *hotspot_y,
|
||||||
int *width,
|
int *width,
|
||||||
int *height)
|
int *height,
|
||||||
|
double *scale)
|
||||||
{
|
{
|
||||||
GdkTexture *texture;
|
GdkTexture *texture;
|
||||||
|
|
||||||
@ -172,6 +173,7 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
|
|||||||
{
|
{
|
||||||
*hotspot_x = *hotspot_y = 0;
|
*hotspot_x = *hotspot_y = 0;
|
||||||
*width = *height = 0;
|
*width = *height = 0;
|
||||||
|
*scale = 1;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,10 +196,12 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
|
|||||||
|
|
||||||
image = c->images[image_index];
|
image = c->images[image_index];
|
||||||
|
|
||||||
*width = image->width;
|
*scale = c->size / (double) display->cursor_theme_size;
|
||||||
*height = image->height;
|
|
||||||
*hotspot_x = image->hotspot_x;
|
*width = image->width / *scale;
|
||||||
*hotspot_y = image->hotspot_y;
|
*height = image->height / *scale;
|
||||||
|
*hotspot_x = image->hotspot_x / *scale;
|
||||||
|
*hotspot_y = image->hotspot_y / *scale;
|
||||||
|
|
||||||
return wl_cursor_image_get_buffer (image);
|
return wl_cursor_image_get_buffer (image);
|
||||||
}
|
}
|
||||||
@ -231,6 +235,7 @@ from_texture:
|
|||||||
*hotspot_y = gdk_cursor_get_hotspot_y (cursor);
|
*hotspot_y = gdk_cursor_get_hotspot_y (cursor);
|
||||||
*width = gdk_texture_get_width (texture);
|
*width = gdk_texture_get_width (texture);
|
||||||
*height = gdk_texture_get_height (texture);
|
*height = gdk_texture_get_height (texture);
|
||||||
|
*scale = 1;
|
||||||
|
|
||||||
cairo_surface_reference (surface);
|
cairo_surface_reference (surface);
|
||||||
buffer = _gdk_wayland_shm_surface_get_wl_buffer (surface);
|
buffer = _gdk_wayland_shm_surface_get_wl_buffer (surface);
|
||||||
@ -242,6 +247,8 @@ from_texture:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
*scale = desired_scale;
|
||||||
|
|
||||||
texture = gdk_cursor_get_texture_for_size (cursor,
|
texture = gdk_cursor_get_texture_for_size (cursor,
|
||||||
display->cursor_theme_size,
|
display->cursor_theme_size,
|
||||||
desired_scale,
|
desired_scale,
|
||||||
@ -281,7 +288,8 @@ from_texture:
|
|||||||
desired_scale,
|
desired_scale,
|
||||||
image_index,
|
image_index,
|
||||||
hotspot_x, hotspot_y,
|
hotspot_x, hotspot_y,
|
||||||
width, height);
|
width, height,
|
||||||
|
scale);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -62,6 +62,7 @@ struct _GdkWaylandPointerData {
|
|||||||
uint32_t grab_time;
|
uint32_t grab_time;
|
||||||
|
|
||||||
struct wl_surface *pointer_surface;
|
struct wl_surface *pointer_surface;
|
||||||
|
struct wp_viewport *pointer_surface_viewport;
|
||||||
guint cursor_is_default: 1;
|
guint cursor_is_default: 1;
|
||||||
GdkCursor *cursor;
|
GdkCursor *cursor;
|
||||||
guint cursor_timeout_id;
|
guint cursor_timeout_id;
|
||||||
|
@ -261,6 +261,7 @@ gdk_wayland_device_update_surface_cursor (GdkDevice *device)
|
|||||||
gdk_wayland_device_get_pointer (wayland_device);
|
gdk_wayland_device_get_pointer (wayland_device);
|
||||||
struct wl_buffer *buffer;
|
struct wl_buffer *buffer;
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
|
double scale;
|
||||||
guint next_image_index, next_image_delay;
|
guint next_image_index, next_image_delay;
|
||||||
gboolean retval = G_SOURCE_REMOVE;
|
gboolean retval = G_SOURCE_REMOVE;
|
||||||
GdkWaylandTabletData *tablet;
|
GdkWaylandTabletData *tablet;
|
||||||
@ -273,7 +274,8 @@ gdk_wayland_device_update_surface_cursor (GdkDevice *device)
|
|||||||
pointer->cursor,
|
pointer->cursor,
|
||||||
pointer->current_output_scale,
|
pointer->current_output_scale,
|
||||||
pointer->cursor_image_index,
|
pointer->cursor_image_index,
|
||||||
&x, &y, &w, &h);
|
&x, &y, &w, &h,
|
||||||
|
&scale);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -310,6 +312,15 @@ gdk_wayland_device_update_surface_cursor (GdkDevice *device)
|
|||||||
if (buffer)
|
if (buffer)
|
||||||
{
|
{
|
||||||
wl_surface_attach (pointer->pointer_surface, buffer, 0, 0);
|
wl_surface_attach (pointer->pointer_surface, buffer, 0, 0);
|
||||||
|
if (pointer->pointer_surface_viewport)
|
||||||
|
{
|
||||||
|
wp_viewport_set_source (pointer->pointer_surface_viewport,
|
||||||
|
wl_fixed_from_int (0),
|
||||||
|
wl_fixed_from_int (0),
|
||||||
|
wl_fixed_from_double (w * scale),
|
||||||
|
wl_fixed_from_double (h * scale));
|
||||||
|
wp_viewport_set_destination (pointer->pointer_surface_viewport, w, h);
|
||||||
|
}
|
||||||
wl_surface_damage (pointer->pointer_surface, 0, 0, w, h);
|
wl_surface_damage (pointer->pointer_surface, 0, 0, w, h);
|
||||||
wl_surface_commit (pointer->pointer_surface);
|
wl_surface_commit (pointer->pointer_surface);
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,8 @@ struct wl_buffer *_gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
|
|||||||
int *hotspot_x,
|
int *hotspot_x,
|
||||||
int *hotspot_y,
|
int *hotspot_y,
|
||||||
int *w,
|
int *w,
|
||||||
int *h);
|
int *h,
|
||||||
|
double *scale);
|
||||||
guint _gdk_wayland_cursor_get_next_image_index (GdkWaylandDisplay *display,
|
guint _gdk_wayland_cursor_get_next_image_index (GdkWaylandDisplay *display,
|
||||||
GdkCursor *cursor,
|
GdkCursor *cursor,
|
||||||
guint scale,
|
guint scale,
|
||||||
|
@ -3894,6 +3894,7 @@ gdk_wayland_pointer_data_finalize (GdkWaylandPointerData *pointer)
|
|||||||
g_clear_object (&pointer->cursor);
|
g_clear_object (&pointer->cursor);
|
||||||
wl_surface_destroy (pointer->pointer_surface);
|
wl_surface_destroy (pointer->pointer_surface);
|
||||||
g_slist_free (pointer->pointer_surface_outputs);
|
g_slist_free (pointer->pointer_surface_outputs);
|
||||||
|
g_clear_pointer (&pointer->pointer_surface_viewport, wp_viewport_destroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -4260,6 +4261,8 @@ init_pointer_data (GdkWaylandPointerData *pointer_data,
|
|||||||
wl_surface_add_listener (pointer_data->pointer_surface,
|
wl_surface_add_listener (pointer_data->pointer_surface,
|
||||||
&pointer_surface_listener,
|
&pointer_surface_listener,
|
||||||
logical_device);
|
logical_device);
|
||||||
|
if (display_wayland->viewporter)
|
||||||
|
pointer_data->pointer_surface_viewport = wp_viewporter_get_viewport (display_wayland->viewporter, pointer_data->pointer_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user