cursor-renderer: Track cursor position using floats
To be able to render the pointer cursor sprite at sub-(logical)-pixel positions, track the pointer position using floats instead of ints. This also requires users of the cursor sprite rect to deal with floating points, when e.g. finding the logical monitor etc. https://bugzilla.gnome.org/show_bug.cgi?id=765011
This commit is contained in:
parent
9ab338d7b6
commit
197401fbf8
@ -37,7 +37,8 @@
|
|||||||
|
|
||||||
struct _MetaCursorRendererPrivate
|
struct _MetaCursorRendererPrivate
|
||||||
{
|
{
|
||||||
int current_x, current_y;
|
float current_x;
|
||||||
|
float current_y;
|
||||||
|
|
||||||
MetaCursorSprite *displayed_cursor;
|
MetaCursorSprite *displayed_cursor;
|
||||||
MetaOverlay *stage_overlay;
|
MetaOverlay *stage_overlay;
|
||||||
@ -69,7 +70,7 @@ queue_redraw (MetaCursorRenderer *renderer,
|
|||||||
MetaBackend *backend = meta_get_backend ();
|
MetaBackend *backend = meta_get_backend ();
|
||||||
ClutterActor *stage = meta_backend_get_stage (backend);
|
ClutterActor *stage = meta_backend_get_stage (backend);
|
||||||
CoglTexture *texture;
|
CoglTexture *texture;
|
||||||
MetaRectangle rect = { 0 };
|
ClutterRect rect = { 0 };
|
||||||
|
|
||||||
if (cursor_sprite)
|
if (cursor_sprite)
|
||||||
rect = meta_cursor_renderer_calculate_rect (renderer, cursor_sprite);
|
rect = meta_cursor_renderer_calculate_rect (renderer, cursor_sprite);
|
||||||
@ -159,7 +160,7 @@ meta_cursor_renderer_init (MetaCursorRenderer *renderer)
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaRectangle
|
ClutterRect
|
||||||
meta_cursor_renderer_calculate_rect (MetaCursorRenderer *renderer,
|
meta_cursor_renderer_calculate_rect (MetaCursorRenderer *renderer,
|
||||||
MetaCursorSprite *cursor_sprite)
|
MetaCursorSprite *cursor_sprite)
|
||||||
{
|
{
|
||||||
@ -172,18 +173,22 @@ meta_cursor_renderer_calculate_rect (MetaCursorRenderer *renderer,
|
|||||||
|
|
||||||
texture = meta_cursor_sprite_get_cogl_texture (cursor_sprite);
|
texture = meta_cursor_sprite_get_cogl_texture (cursor_sprite);
|
||||||
if (!texture)
|
if (!texture)
|
||||||
return (MetaRectangle) { 0 };
|
return (ClutterRect) { 0 };
|
||||||
|
|
||||||
meta_cursor_sprite_get_hotspot (cursor_sprite, &hot_x, &hot_y);
|
meta_cursor_sprite_get_hotspot (cursor_sprite, &hot_x, &hot_y);
|
||||||
texture_scale = meta_cursor_sprite_get_texture_scale (cursor_sprite);
|
texture_scale = meta_cursor_sprite_get_texture_scale (cursor_sprite);
|
||||||
width = cogl_texture_get_width (texture);
|
width = cogl_texture_get_width (texture);
|
||||||
height = cogl_texture_get_height (texture);
|
height = cogl_texture_get_height (texture);
|
||||||
|
|
||||||
return (MetaRectangle) {
|
return (ClutterRect) {
|
||||||
.x = (int)roundf (priv->current_x - (hot_x * texture_scale)),
|
.origin = {
|
||||||
.y = (int)roundf (priv->current_y - (hot_y * texture_scale)),
|
.x = priv->current_x - (hot_x * texture_scale),
|
||||||
.width = (int)roundf (width * texture_scale),
|
.y = priv->current_y - (hot_y * texture_scale)
|
||||||
.height = (int)roundf (height * texture_scale),
|
},
|
||||||
|
.size = {
|
||||||
|
.width = width * texture_scale,
|
||||||
|
.height = height * texture_scale
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,8 +202,8 @@ update_cursor (MetaCursorRenderer *renderer,
|
|||||||
|
|
||||||
if (cursor_sprite)
|
if (cursor_sprite)
|
||||||
meta_cursor_sprite_prepare_at (cursor_sprite,
|
meta_cursor_sprite_prepare_at (cursor_sprite,
|
||||||
priv->current_x,
|
(int) priv->current_x,
|
||||||
priv->current_y);
|
(int) priv->current_y);
|
||||||
|
|
||||||
handled_by_backend =
|
handled_by_backend =
|
||||||
META_CURSOR_RENDERER_GET_CLASS (renderer)->update_cursor (renderer,
|
META_CURSOR_RENDERER_GET_CLASS (renderer)->update_cursor (renderer,
|
||||||
@ -246,7 +251,8 @@ meta_cursor_renderer_force_update (MetaCursorRenderer *renderer)
|
|||||||
|
|
||||||
void
|
void
|
||||||
meta_cursor_renderer_set_position (MetaCursorRenderer *renderer,
|
meta_cursor_renderer_set_position (MetaCursorRenderer *renderer,
|
||||||
int x, int y)
|
float x,
|
||||||
|
float y)
|
||||||
{
|
{
|
||||||
MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
|
MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
|
||||||
|
|
||||||
|
@ -60,12 +60,13 @@ void meta_cursor_renderer_set_cursor (MetaCursorRenderer *renderer,
|
|||||||
MetaCursorSprite *cursor_sprite);
|
MetaCursorSprite *cursor_sprite);
|
||||||
|
|
||||||
void meta_cursor_renderer_set_position (MetaCursorRenderer *renderer,
|
void meta_cursor_renderer_set_position (MetaCursorRenderer *renderer,
|
||||||
int x, int y);
|
float x,
|
||||||
|
float y);
|
||||||
void meta_cursor_renderer_force_update (MetaCursorRenderer *renderer);
|
void meta_cursor_renderer_force_update (MetaCursorRenderer *renderer);
|
||||||
|
|
||||||
MetaCursorSprite * meta_cursor_renderer_get_cursor (MetaCursorRenderer *renderer);
|
MetaCursorSprite * meta_cursor_renderer_get_cursor (MetaCursorRenderer *renderer);
|
||||||
|
|
||||||
MetaRectangle meta_cursor_renderer_calculate_rect (MetaCursorRenderer *renderer,
|
ClutterRect meta_cursor_renderer_calculate_rect (MetaCursorRenderer *renderer,
|
||||||
MetaCursorSprite *cursor_sprite);
|
MetaCursorSprite *cursor_sprite);
|
||||||
|
|
||||||
#ifdef HAVE_WAYLAND
|
#ifdef HAVE_WAYLAND
|
||||||
|
@ -62,8 +62,8 @@ void meta_cursor_tracker_set_root_cursor (MetaCursorTracker *tracker,
|
|||||||
MetaCursorSprite *cursor_sprite);
|
MetaCursorSprite *cursor_sprite);
|
||||||
|
|
||||||
void meta_cursor_tracker_update_position (MetaCursorTracker *tracker,
|
void meta_cursor_tracker_update_position (MetaCursorTracker *tracker,
|
||||||
int new_x,
|
float new_x,
|
||||||
int new_y);
|
float new_y);
|
||||||
|
|
||||||
MetaCursorSprite * meta_cursor_tracker_get_displayed_cursor (MetaCursorTracker *tracker);
|
MetaCursorSprite * meta_cursor_tracker_get_displayed_cursor (MetaCursorTracker *tracker);
|
||||||
|
|
||||||
|
@ -350,8 +350,8 @@ meta_cursor_tracker_set_root_cursor (MetaCursorTracker *tracker,
|
|||||||
|
|
||||||
void
|
void
|
||||||
meta_cursor_tracker_update_position (MetaCursorTracker *tracker,
|
meta_cursor_tracker_update_position (MetaCursorTracker *tracker,
|
||||||
int new_x,
|
float new_x,
|
||||||
int new_y)
|
float new_y)
|
||||||
{
|
{
|
||||||
MetaBackend *backend = meta_get_backend ();
|
MetaBackend *backend = meta_get_backend ();
|
||||||
MetaCursorRenderer *cursor_renderer =
|
MetaCursorRenderer *cursor_renderer =
|
||||||
|
@ -36,8 +36,8 @@ struct _MetaOverlay {
|
|||||||
CoglPipeline *pipeline;
|
CoglPipeline *pipeline;
|
||||||
CoglTexture *texture;
|
CoglTexture *texture;
|
||||||
|
|
||||||
MetaRectangle current_rect;
|
ClutterRect current_rect;
|
||||||
MetaRectangle previous_rect;
|
ClutterRect previous_rect;
|
||||||
gboolean previous_is_valid;
|
gboolean previous_is_valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ meta_overlay_free (MetaOverlay *overlay)
|
|||||||
static void
|
static void
|
||||||
meta_overlay_set (MetaOverlay *overlay,
|
meta_overlay_set (MetaOverlay *overlay,
|
||||||
CoglTexture *texture,
|
CoglTexture *texture,
|
||||||
MetaRectangle *rect)
|
ClutterRect *rect)
|
||||||
{
|
{
|
||||||
if (overlay->texture != texture)
|
if (overlay->texture != texture)
|
||||||
{
|
{
|
||||||
@ -104,12 +104,12 @@ meta_overlay_paint (MetaOverlay *overlay)
|
|||||||
|
|
||||||
cogl_framebuffer_draw_rectangle (cogl_get_draw_framebuffer (),
|
cogl_framebuffer_draw_rectangle (cogl_get_draw_framebuffer (),
|
||||||
overlay->pipeline,
|
overlay->pipeline,
|
||||||
overlay->current_rect.x,
|
overlay->current_rect.origin.x,
|
||||||
overlay->current_rect.y,
|
overlay->current_rect.origin.y,
|
||||||
overlay->current_rect.x +
|
(overlay->current_rect.origin.x +
|
||||||
overlay->current_rect.width,
|
overlay->current_rect.size.width),
|
||||||
overlay->current_rect.y +
|
(overlay->current_rect.origin.y +
|
||||||
overlay->current_rect.height);
|
overlay->current_rect.size.height));
|
||||||
|
|
||||||
overlay->previous_rect = overlay->current_rect;
|
overlay->previous_rect = overlay->current_rect;
|
||||||
overlay->previous_is_valid = TRUE;
|
overlay->previous_is_valid = TRUE;
|
||||||
@ -204,10 +204,10 @@ queue_redraw_for_overlay (MetaStage *stage,
|
|||||||
/* Clear the location the overlay was at before, if we need to. */
|
/* Clear the location the overlay was at before, if we need to. */
|
||||||
if (overlay->previous_is_valid)
|
if (overlay->previous_is_valid)
|
||||||
{
|
{
|
||||||
clip.x = overlay->previous_rect.x;
|
clip.x = floorf (overlay->previous_rect.origin.x),
|
||||||
clip.y = overlay->previous_rect.y;
|
clip.y = floorf (overlay->previous_rect.origin.y),
|
||||||
clip.width = overlay->previous_rect.width;
|
clip.width = ceilf (overlay->previous_rect.size.width),
|
||||||
clip.height = overlay->previous_rect.height;
|
clip.height = ceilf (overlay->previous_rect.size.height),
|
||||||
clutter_actor_queue_redraw_with_clip (CLUTTER_ACTOR (stage), &clip);
|
clutter_actor_queue_redraw_with_clip (CLUTTER_ACTOR (stage), &clip);
|
||||||
overlay->previous_is_valid = FALSE;
|
overlay->previous_is_valid = FALSE;
|
||||||
}
|
}
|
||||||
@ -215,10 +215,10 @@ queue_redraw_for_overlay (MetaStage *stage,
|
|||||||
/* Draw the overlay at the new position */
|
/* Draw the overlay at the new position */
|
||||||
if (overlay->enabled)
|
if (overlay->enabled)
|
||||||
{
|
{
|
||||||
clip.x = overlay->current_rect.x;
|
clip.x = floorf (overlay->current_rect.origin.x),
|
||||||
clip.y = overlay->current_rect.y;
|
clip.y = floorf (overlay->current_rect.origin.y),
|
||||||
clip.width = overlay->current_rect.width;
|
clip.width = ceilf (overlay->current_rect.size.width),
|
||||||
clip.height = overlay->current_rect.height;
|
clip.height = ceilf (overlay->current_rect.size.height),
|
||||||
clutter_actor_queue_redraw_with_clip (CLUTTER_ACTOR (stage), &clip);
|
clutter_actor_queue_redraw_with_clip (CLUTTER_ACTOR (stage), &clip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,7 +254,7 @@ void
|
|||||||
meta_stage_update_cursor_overlay (MetaStage *stage,
|
meta_stage_update_cursor_overlay (MetaStage *stage,
|
||||||
MetaOverlay *overlay,
|
MetaOverlay *overlay,
|
||||||
CoglTexture *texture,
|
CoglTexture *texture,
|
||||||
MetaRectangle *rect)
|
ClutterRect *rect)
|
||||||
{
|
{
|
||||||
g_assert (meta_is_wayland_compositor () || texture == NULL);
|
g_assert (meta_is_wayland_compositor () || texture == NULL);
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ void meta_stage_remove_cursor_overlay (MetaStage *stage,
|
|||||||
void meta_stage_update_cursor_overlay (MetaStage *stage,
|
void meta_stage_update_cursor_overlay (MetaStage *stage,
|
||||||
MetaOverlay *overlay,
|
MetaOverlay *overlay,
|
||||||
CoglTexture *texture,
|
CoglTexture *texture,
|
||||||
MetaRectangle *rect);
|
ClutterRect *rect);
|
||||||
|
|
||||||
void meta_stage_set_active (MetaStage *stage,
|
void meta_stage_set_active (MetaStage *stage,
|
||||||
gboolean is_active);
|
gboolean is_active);
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "backends/meta-monitor.h"
|
#include "backends/meta-monitor.h"
|
||||||
#include "backends/meta-monitor-manager-private.h"
|
#include "backends/meta-monitor-manager-private.h"
|
||||||
#include "backends/native/meta-renderer-native.h"
|
#include "backends/native/meta-renderer-native.h"
|
||||||
|
#include "core/boxes-private.h"
|
||||||
#include "meta/boxes.h"
|
#include "meta/boxes.h"
|
||||||
|
|
||||||
#ifndef DRM_CAP_CURSOR_WIDTH
|
#ifndef DRM_CAP_CURSOR_WIDTH
|
||||||
@ -220,7 +221,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
MetaCursorRendererNative *in_cursor_renderer_native;
|
MetaCursorRendererNative *in_cursor_renderer_native;
|
||||||
MetaLogicalMonitor *in_logical_monitor;
|
MetaLogicalMonitor *in_logical_monitor;
|
||||||
MetaRectangle in_local_cursor_rect;
|
ClutterRect in_local_cursor_rect;
|
||||||
MetaCursorSprite *in_cursor_sprite;
|
MetaCursorSprite *in_cursor_sprite;
|
||||||
|
|
||||||
gboolean out_painted;
|
gboolean out_painted;
|
||||||
@ -238,7 +239,7 @@ update_monitor_crtc_cursor (MetaMonitor *monitor,
|
|||||||
data->in_cursor_renderer_native;
|
data->in_cursor_renderer_native;
|
||||||
MetaCursorRendererNativePrivate *priv =
|
MetaCursorRendererNativePrivate *priv =
|
||||||
meta_cursor_renderer_native_get_instance_private (cursor_renderer_native);
|
meta_cursor_renderer_native_get_instance_private (cursor_renderer_native);
|
||||||
MetaRectangle scaled_crtc_rect;
|
ClutterRect scaled_crtc_rect;
|
||||||
float scale;
|
float scale;
|
||||||
int crtc_x, crtc_y;
|
int crtc_x, crtc_y;
|
||||||
|
|
||||||
@ -252,29 +253,36 @@ update_monitor_crtc_cursor (MetaMonitor *monitor,
|
|||||||
META_MONITOR_TRANSFORM_NORMAL,
|
META_MONITOR_TRANSFORM_NORMAL,
|
||||||
&crtc_x, &crtc_y);
|
&crtc_x, &crtc_y);
|
||||||
|
|
||||||
scaled_crtc_rect = (MetaRectangle) {
|
scaled_crtc_rect = (ClutterRect) {
|
||||||
|
.origin = {
|
||||||
.x = crtc_x / scale,
|
.x = crtc_x / scale,
|
||||||
.y = crtc_y / scale,
|
.y = crtc_y / scale
|
||||||
|
},
|
||||||
|
.size = {
|
||||||
.width = monitor_crtc_mode->crtc_mode->width / scale,
|
.width = monitor_crtc_mode->crtc_mode->width / scale,
|
||||||
.height = monitor_crtc_mode->crtc_mode->height / scale
|
.height = monitor_crtc_mode->crtc_mode->height / scale
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (priv->has_hw_cursor &&
|
if (priv->has_hw_cursor &&
|
||||||
meta_rectangle_overlap (&scaled_crtc_rect,
|
clutter_rect_intersection (&scaled_crtc_rect,
|
||||||
&data->in_local_cursor_rect))
|
&data->in_local_cursor_rect,
|
||||||
|
NULL))
|
||||||
{
|
{
|
||||||
int crtc_cursor_x, crtc_cursor_y;
|
float crtc_cursor_x, crtc_cursor_y;
|
||||||
|
|
||||||
set_crtc_cursor (data->in_cursor_renderer_native,
|
set_crtc_cursor (data->in_cursor_renderer_native,
|
||||||
monitor_crtc_mode->output->crtc,
|
monitor_crtc_mode->output->crtc,
|
||||||
data->in_cursor_sprite);
|
data->in_cursor_sprite);
|
||||||
|
|
||||||
crtc_cursor_x = (data->in_local_cursor_rect.x - scaled_crtc_rect.x) * scale;
|
crtc_cursor_x = (data->in_local_cursor_rect.origin.x -
|
||||||
crtc_cursor_y = (data->in_local_cursor_rect.y - scaled_crtc_rect.y) * scale;
|
scaled_crtc_rect.origin.x) * scale;
|
||||||
|
crtc_cursor_y = (data->in_local_cursor_rect.origin.y -
|
||||||
|
scaled_crtc_rect.origin.y) * scale;
|
||||||
drmModeMoveCursor (priv->drm_fd,
|
drmModeMoveCursor (priv->drm_fd,
|
||||||
monitor_crtc_mode->output->crtc->crtc_id,
|
monitor_crtc_mode->output->crtc->crtc_id,
|
||||||
crtc_cursor_x,
|
roundf (crtc_cursor_x),
|
||||||
crtc_cursor_y);
|
roundf (crtc_cursor_y));
|
||||||
|
|
||||||
data->out_painted = data->out_painted || TRUE;
|
data->out_painted = data->out_painted || TRUE;
|
||||||
}
|
}
|
||||||
@ -298,13 +306,13 @@ update_hw_cursor (MetaCursorRendererNative *native,
|
|||||||
meta_backend_get_monitor_manager (backend);
|
meta_backend_get_monitor_manager (backend);
|
||||||
GList *logical_monitors;
|
GList *logical_monitors;
|
||||||
GList *l;
|
GList *l;
|
||||||
MetaRectangle rect;
|
ClutterRect rect;
|
||||||
gboolean painted = FALSE;
|
gboolean painted = FALSE;
|
||||||
|
|
||||||
if (cursor_sprite)
|
if (cursor_sprite)
|
||||||
rect = meta_cursor_renderer_calculate_rect (renderer, cursor_sprite);
|
rect = meta_cursor_renderer_calculate_rect (renderer, cursor_sprite);
|
||||||
else
|
else
|
||||||
rect = (MetaRectangle) { 0 };
|
rect = (ClutterRect) { 0 };
|
||||||
|
|
||||||
logical_monitors =
|
logical_monitors =
|
||||||
meta_monitor_manager_get_logical_monitors (monitor_manager);
|
meta_monitor_manager_get_logical_monitors (monitor_manager);
|
||||||
@ -318,11 +326,12 @@ update_hw_cursor (MetaCursorRendererNative *native,
|
|||||||
data = (UpdateCrtcCursorData) {
|
data = (UpdateCrtcCursorData) {
|
||||||
.in_cursor_renderer_native = native,
|
.in_cursor_renderer_native = native,
|
||||||
.in_logical_monitor = logical_monitor,
|
.in_logical_monitor = logical_monitor,
|
||||||
.in_local_cursor_rect = (MetaRectangle) {
|
.in_local_cursor_rect = (ClutterRect) {
|
||||||
.x = rect.x - logical_monitor->rect.x,
|
.origin = {
|
||||||
.y = rect.y - logical_monitor->rect.y,
|
.x = rect.origin.x - logical_monitor->rect.x,
|
||||||
.width = rect.width,
|
.y = rect.origin.y - logical_monitor->rect.y
|
||||||
.height = rect.height
|
},
|
||||||
|
.size = rect.size
|
||||||
},
|
},
|
||||||
.in_cursor_sprite = cursor_sprite
|
.in_cursor_sprite = cursor_sprite
|
||||||
};
|
};
|
||||||
@ -380,7 +389,7 @@ cursor_over_transformed_crtc (MetaCursorRenderer *renderer,
|
|||||||
MetaMonitorManager *monitors;
|
MetaMonitorManager *monitors;
|
||||||
MetaCrtc *crtcs;
|
MetaCrtc *crtcs;
|
||||||
unsigned int i, n_crtcs;
|
unsigned int i, n_crtcs;
|
||||||
MetaRectangle rect;
|
ClutterRect rect;
|
||||||
|
|
||||||
monitors = meta_monitor_manager_get ();
|
monitors = meta_monitor_manager_get ();
|
||||||
meta_monitor_manager_get_resources (monitors, NULL, NULL,
|
meta_monitor_manager_get_resources (monitors, NULL, NULL,
|
||||||
@ -389,10 +398,13 @@ cursor_over_transformed_crtc (MetaCursorRenderer *renderer,
|
|||||||
|
|
||||||
for (i = 0; i < n_crtcs; i++)
|
for (i = 0; i < n_crtcs; i++)
|
||||||
{
|
{
|
||||||
if (!meta_rectangle_overlap (&rect, &crtcs[i].rect))
|
MetaCrtc *crtc = &crtcs[i];
|
||||||
|
ClutterRect crtc_rect = meta_rectangle_to_clutter_rect (&crtc->rect);
|
||||||
|
|
||||||
|
if (!clutter_rect_intersection (&rect, &crtc_rect, NULL))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (crtcs[i].transform != META_MONITOR_TRANSFORM_NORMAL)
|
if (crtc->transform != META_MONITOR_TRANSFORM_NORMAL)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,7 +425,7 @@ can_draw_cursor_unscaled (MetaCursorRenderer *renderer,
|
|||||||
{
|
{
|
||||||
MetaBackend *backend;
|
MetaBackend *backend;
|
||||||
MetaMonitorManager *monitor_manager;
|
MetaMonitorManager *monitor_manager;
|
||||||
MetaRectangle cursor_rect;
|
ClutterRect cursor_rect;
|
||||||
GList *logical_monitors;
|
GList *logical_monitors;
|
||||||
GList *l;
|
GList *l;
|
||||||
gboolean has_visible_crtc_sprite = FALSE;
|
gboolean has_visible_crtc_sprite = FALSE;
|
||||||
@ -434,8 +446,12 @@ can_draw_cursor_unscaled (MetaCursorRenderer *renderer,
|
|||||||
for (l = logical_monitors; l; l = l->next)
|
for (l = logical_monitors; l; l = l->next)
|
||||||
{
|
{
|
||||||
MetaLogicalMonitor *logical_monitor = l->data;
|
MetaLogicalMonitor *logical_monitor = l->data;
|
||||||
|
ClutterRect logical_monitor_rect =
|
||||||
|
meta_rectangle_to_clutter_rect (&logical_monitor->rect);
|
||||||
|
|
||||||
if (!meta_rectangle_overlap (&cursor_rect, &logical_monitor->rect))
|
if (!clutter_rect_intersection (&cursor_rect,
|
||||||
|
&logical_monitor_rect,
|
||||||
|
NULL))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (calculate_cursor_crtc_sprite_scale (cursor_sprite,
|
if (calculate_cursor_crtc_sprite_scale (cursor_sprite,
|
||||||
|
@ -218,4 +218,19 @@ GList* meta_rectangle_find_nonintersected_monitor_edges (
|
|||||||
gboolean meta_rectangle_is_adjecent_to (MetaRectangle *rect,
|
gboolean meta_rectangle_is_adjecent_to (MetaRectangle *rect,
|
||||||
MetaRectangle *other);
|
MetaRectangle *other);
|
||||||
|
|
||||||
|
static inline ClutterRect
|
||||||
|
meta_rectangle_to_clutter_rect (MetaRectangle *rect)
|
||||||
|
{
|
||||||
|
return (ClutterRect) {
|
||||||
|
.origin = {
|
||||||
|
.x = rect->x,
|
||||||
|
.y = rect->y
|
||||||
|
},
|
||||||
|
.size = {
|
||||||
|
.width = rect->width,
|
||||||
|
.height = rect->height
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* META_BOXES_PRIVATE_H */
|
#endif /* META_BOXES_PRIVATE_H */
|
||||||
|
@ -1286,7 +1286,7 @@ find_highest_logical_monitor_scale (MetaBackend *backend,
|
|||||||
meta_backend_get_monitor_manager (backend);
|
meta_backend_get_monitor_manager (backend);
|
||||||
MetaCursorRenderer *cursor_renderer =
|
MetaCursorRenderer *cursor_renderer =
|
||||||
meta_backend_get_cursor_renderer (backend);
|
meta_backend_get_cursor_renderer (backend);
|
||||||
MetaRectangle cursor_rect;
|
ClutterRect cursor_rect;
|
||||||
GList *logical_monitors;
|
GList *logical_monitors;
|
||||||
GList *l;
|
GList *l;
|
||||||
int highest_scale = 0.0;
|
int highest_scale = 0.0;
|
||||||
@ -1299,8 +1299,12 @@ find_highest_logical_monitor_scale (MetaBackend *backend,
|
|||||||
for (l = logical_monitors; l; l = l->next)
|
for (l = logical_monitors; l; l = l->next)
|
||||||
{
|
{
|
||||||
MetaLogicalMonitor *logical_monitor = l->data;
|
MetaLogicalMonitor *logical_monitor = l->data;
|
||||||
|
ClutterRect logical_monitor_rect =
|
||||||
|
meta_rectangle_to_clutter_rect (&logical_monitor->rect);
|
||||||
|
|
||||||
if (!meta_rectangle_overlap (&cursor_rect, &logical_monitor->rect))
|
if (!clutter_rect_intersection (&cursor_rect,
|
||||||
|
&logical_monitor_rect,
|
||||||
|
NULL))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
highest_scale = MAX (highest_scale, logical_monitor->scale);
|
highest_scale = MAX (highest_scale, logical_monitor->scale);
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "meta-wayland-private.h"
|
#include "meta-wayland-private.h"
|
||||||
#include "backends/meta-backend-private.h"
|
#include "backends/meta-backend-private.h"
|
||||||
#include "backends/meta-logical-monitor.h"
|
#include "backends/meta-logical-monitor.h"
|
||||||
|
#include "core/boxes-private.h"
|
||||||
|
|
||||||
typedef struct _MetaWaylandSurfaceRoleCursorPrivate MetaWaylandSurfaceRoleCursorPrivate;
|
typedef struct _MetaWaylandSurfaceRoleCursorPrivate MetaWaylandSurfaceRoleCursorPrivate;
|
||||||
|
|
||||||
@ -194,11 +195,14 @@ cursor_surface_role_is_on_logical_monitor (MetaWaylandSurfaceRole *role,
|
|||||||
META_WAYLAND_SURFACE_ROLE_CURSOR (surface->role);
|
META_WAYLAND_SURFACE_ROLE_CURSOR (surface->role);
|
||||||
MetaWaylandSurfaceRoleCursorPrivate *priv =
|
MetaWaylandSurfaceRoleCursorPrivate *priv =
|
||||||
meta_wayland_surface_role_cursor_get_instance_private (cursor_role);
|
meta_wayland_surface_role_cursor_get_instance_private (cursor_role);
|
||||||
MetaRectangle rect;
|
ClutterRect rect;
|
||||||
|
ClutterRect logical_monitor_rect;
|
||||||
|
|
||||||
rect = meta_cursor_renderer_calculate_rect (priv->cursor_renderer,
|
rect = meta_cursor_renderer_calculate_rect (priv->cursor_renderer,
|
||||||
priv->cursor_sprite);
|
priv->cursor_sprite);
|
||||||
return meta_rectangle_overlap (&rect, &logical_monitor->rect);
|
logical_monitor_rect =
|
||||||
|
meta_rectangle_to_clutter_rect (&logical_monitor->rect);
|
||||||
|
return clutter_rect_intersection (&rect, &logical_monitor_rect, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -921,8 +921,8 @@ meta_wayland_tablet_tool_handle_event (MetaWaylandTabletTool *tool,
|
|||||||
|
|
||||||
void
|
void
|
||||||
meta_wayland_tablet_tool_set_cursor_position (MetaWaylandTabletTool *tool,
|
meta_wayland_tablet_tool_set_cursor_position (MetaWaylandTabletTool *tool,
|
||||||
int new_x,
|
float new_x,
|
||||||
int new_y)
|
float new_y)
|
||||||
{
|
{
|
||||||
if (tool->cursor_renderer)
|
if (tool->cursor_renderer)
|
||||||
meta_cursor_renderer_set_position (tool->cursor_renderer, new_x, new_y);
|
meta_cursor_renderer_set_position (tool->cursor_renderer, new_x, new_y);
|
||||||
|
@ -79,8 +79,8 @@ gboolean meta_wayland_tablet_tool_handle_event (MetaWaylandTabletTool *t
|
|||||||
const ClutterEvent *event);
|
const ClutterEvent *event);
|
||||||
|
|
||||||
void meta_wayland_tablet_tool_set_cursor_position (MetaWaylandTabletTool *tool,
|
void meta_wayland_tablet_tool_set_cursor_position (MetaWaylandTabletTool *tool,
|
||||||
int new_x,
|
float new_x,
|
||||||
int new_y);
|
float new_y);
|
||||||
|
|
||||||
gboolean meta_wayland_tablet_tool_can_grab_surface (MetaWaylandTabletTool *tool,
|
gboolean meta_wayland_tablet_tool_can_grab_surface (MetaWaylandTabletTool *tool,
|
||||||
MetaWaylandSurface *surface,
|
MetaWaylandSurface *surface,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user