shell-screenshot: Initialize cursor tracker in draw cursor function
Avoid code duplication, since we're using this only if the cursor has to be painted differently. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/5
This commit is contained in:
parent
6f027ee7dc
commit
02c3980b83
@ -257,21 +257,26 @@ do_grab_screenshot (ShellScreenshot *screenshot,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_draw_cursor_image (MetaCursorTracker *tracker,
|
draw_cursor_image (cairo_surface_t *surface,
|
||||||
cairo_surface_t *surface,
|
cairo_rectangle_int_t area)
|
||||||
cairo_rectangle_int_t area)
|
|
||||||
{
|
{
|
||||||
CoglTexture *texture;
|
CoglTexture *texture;
|
||||||
int width, height;
|
int width, height;
|
||||||
int stride;
|
int stride;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
|
MetaDisplay *display;
|
||||||
|
MetaCursorTracker *tracker;
|
||||||
cairo_surface_t *cursor_surface;
|
cairo_surface_t *cursor_surface;
|
||||||
cairo_region_t *screenshot_region;
|
cairo_region_t *screenshot_region;
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
int x, y;
|
int x, y;
|
||||||
int xhot, yhot;
|
int xhot, yhot;
|
||||||
|
double xscale, yscale;
|
||||||
|
|
||||||
|
display = shell_global_get_display (shell_global_get ());
|
||||||
|
tracker = meta_cursor_tracker_get_for_display (display);
|
||||||
texture = meta_cursor_tracker_get_sprite (tracker);
|
texture = meta_cursor_tracker_get_sprite (tracker);
|
||||||
|
|
||||||
if (!texture)
|
if (!texture)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -315,7 +320,6 @@ grab_screenshot (ClutterActor *stage,
|
|||||||
GTask *result)
|
GTask *result)
|
||||||
{
|
{
|
||||||
MetaDisplay *display;
|
MetaDisplay *display;
|
||||||
MetaCursorTracker *tracker;
|
|
||||||
int width, height;
|
int width, height;
|
||||||
GSettings *settings;
|
GSettings *settings;
|
||||||
ShellScreenshot *screenshot = g_task_get_source_object (result);
|
ShellScreenshot *screenshot = g_task_get_source_object (result);
|
||||||
@ -374,10 +378,8 @@ grab_screenshot (ClutterActor *stage,
|
|||||||
settings = g_settings_new (A11Y_APPS_SCHEMA);
|
settings = g_settings_new (A11Y_APPS_SCHEMA);
|
||||||
if (priv->include_cursor &&
|
if (priv->include_cursor &&
|
||||||
!g_settings_get_boolean (settings, MAGNIFIER_ACTIVE_KEY))
|
!g_settings_get_boolean (settings, MAGNIFIER_ACTIVE_KEY))
|
||||||
{
|
draw_cursor_image (priv->image, priv->screenshot_area);
|
||||||
tracker = meta_cursor_tracker_get_for_display (display);
|
|
||||||
_draw_cursor_image (tracker, priv->image, priv->screenshot_area);
|
|
||||||
}
|
|
||||||
g_object_unref (settings);
|
g_object_unref (settings);
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_func (stage, grab_screenshot, result);
|
g_signal_handlers_disconnect_by_func (stage, grab_screenshot, result);
|
||||||
@ -417,7 +419,6 @@ grab_window_screenshot (ClutterActor *stage,
|
|||||||
GTask *task;
|
GTask *task;
|
||||||
GSettings *settings;
|
GSettings *settings;
|
||||||
MetaDisplay *display = shell_global_get_display (priv->global);
|
MetaDisplay *display = shell_global_get_display (priv->global);
|
||||||
MetaCursorTracker *tracker;
|
|
||||||
MetaWindow *window = meta_display_get_focus_window (display);
|
MetaWindow *window = meta_display_get_focus_window (display);
|
||||||
ClutterActor *window_actor;
|
ClutterActor *window_actor;
|
||||||
gfloat actor_x, actor_y;
|
gfloat actor_x, actor_y;
|
||||||
@ -447,10 +448,8 @@ grab_window_screenshot (ClutterActor *stage,
|
|||||||
|
|
||||||
settings = g_settings_new (A11Y_APPS_SCHEMA);
|
settings = g_settings_new (A11Y_APPS_SCHEMA);
|
||||||
if (priv->include_cursor && !g_settings_get_boolean (settings, MAGNIFIER_ACTIVE_KEY))
|
if (priv->include_cursor && !g_settings_get_boolean (settings, MAGNIFIER_ACTIVE_KEY))
|
||||||
{
|
draw_cursor_image (priv->image, priv->screenshot_area);
|
||||||
tracker = meta_cursor_tracker_get_for_display (display);
|
|
||||||
_draw_cursor_image (tracker, priv->image, priv->screenshot_area);
|
|
||||||
}
|
|
||||||
g_object_unref (settings);
|
g_object_unref (settings);
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_func (stage, grab_window_screenshot, result);
|
g_signal_handlers_disconnect_by_func (stage, grab_window_screenshot, result);
|
||||||
|
Loading…
Reference in New Issue
Block a user