diff --git a/src/backends/meta-backend-private.h b/src/backends/meta-backend-private.h index 9ac20eec8..6782d7774 100644 --- a/src/backends/meta-backend-private.h +++ b/src/backends/meta-backend-private.h @@ -196,4 +196,12 @@ GList * meta_backend_get_gpus (MetaBackend *backend); WacomDeviceDatabase * meta_backend_get_wacom_database (MetaBackend *backend); #endif +void meta_backend_add_hw_cursor_inhibitor (MetaBackend *backend, + MetaHwCursorInhibitor *inhibitor); + +void meta_backend_remove_hw_cursor_inhibitor (MetaBackend *backend, + MetaHwCursorInhibitor *inhibitor); + +gboolean meta_backend_is_hw_cursors_inhibited (MetaBackend *backend); + #endif /* META_BACKEND_PRIVATE_H */ diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c index 7a72d068d..e837b19a6 100644 --- a/src/backends/meta-backend.c +++ b/src/backends/meta-backend.c @@ -53,6 +53,7 @@ #include +#include "backends/meta-cursor-renderer.h" #include "backends/meta-cursor-tracker-private.h" #include "backends/meta-idle-monitor-private.h" #include "backends/meta-input-settings-private.h" @@ -150,6 +151,7 @@ struct _MetaBackendPrivate ClutterActor *stage; GList *gpus; + GList *hw_cursor_inhibitors; gboolean is_pointer_position_initialized; @@ -1503,3 +1505,40 @@ meta_backend_get_wacom_database (MetaBackend *backend) return priv->wacom_db; } #endif + +void +meta_backend_add_hw_cursor_inhibitor (MetaBackend *backend, + MetaHwCursorInhibitor *inhibitor) +{ + MetaBackendPrivate *priv = meta_backend_get_instance_private (backend); + + priv->hw_cursor_inhibitors = g_list_prepend (priv->hw_cursor_inhibitors, + inhibitor); +} + +void +meta_backend_remove_hw_cursor_inhibitor (MetaBackend *backend, + MetaHwCursorInhibitor *inhibitor) +{ + MetaBackendPrivate *priv = meta_backend_get_instance_private (backend); + + priv->hw_cursor_inhibitors = g_list_remove (priv->hw_cursor_inhibitors, + inhibitor); +} + +gboolean +meta_backend_is_hw_cursors_inhibited (MetaBackend *backend) +{ + MetaBackendPrivate *priv = meta_backend_get_instance_private (backend); + GList *l; + + for (l = priv->hw_cursor_inhibitors; l; l = l->next) + { + MetaHwCursorInhibitor *inhibitor = l->data; + + if (meta_hw_cursor_inhibitor_is_cursor_inhibited (inhibitor)) + return TRUE; + } + + return FALSE; +} diff --git a/src/backends/meta-cursor-renderer.c b/src/backends/meta-cursor-renderer.c index 9111dc5c0..879a4f797 100644 --- a/src/backends/meta-cursor-renderer.c +++ b/src/backends/meta-cursor-renderer.c @@ -81,7 +81,7 @@ static guint signals[LAST_SIGNAL]; G_DEFINE_TYPE_WITH_PRIVATE (MetaCursorRenderer, meta_cursor_renderer, G_TYPE_OBJECT); -static gboolean +gboolean meta_hw_cursor_inhibitor_is_cursor_inhibited (MetaHwCursorInhibitor *inhibitor) { MetaHwCursorInhibitorInterface *iface = @@ -475,46 +475,6 @@ meta_cursor_renderer_is_overlay_visible (MetaCursorRenderer *renderer) return meta_overlay_is_visible (priv->stage_overlay); } -void -meta_cursor_renderer_add_hw_cursor_inhibitor (MetaCursorRenderer *renderer, - MetaHwCursorInhibitor *inhibitor) -{ - MetaCursorRendererPrivate *priv = - meta_cursor_renderer_get_instance_private (renderer); - - priv->hw_cursor_inhibitors = g_list_prepend (priv->hw_cursor_inhibitors, - inhibitor); -} - -void -meta_cursor_renderer_remove_hw_cursor_inhibitor (MetaCursorRenderer *renderer, - MetaHwCursorInhibitor *inhibitor) -{ - MetaCursorRendererPrivate *priv = - meta_cursor_renderer_get_instance_private (renderer); - - priv->hw_cursor_inhibitors = g_list_remove (priv->hw_cursor_inhibitors, - inhibitor); -} - -gboolean -meta_cursor_renderer_is_hw_cursors_inhibited (MetaCursorRenderer *renderer) -{ - MetaCursorRendererPrivate *priv = - meta_cursor_renderer_get_instance_private (renderer); - GList *l; - - for (l = priv->hw_cursor_inhibitors; l; l = l->next) - { - MetaHwCursorInhibitor *inhibitor = l->data; - - if (meta_hw_cursor_inhibitor_is_cursor_inhibited (inhibitor)) - return TRUE; - } - - return FALSE; -} - ClutterInputDevice * meta_cursor_renderer_get_input_device (MetaCursorRenderer *renderer) { diff --git a/src/backends/meta-cursor-renderer.h b/src/backends/meta-cursor-renderer.h index b16d5cbe2..8d23cc6f5 100644 --- a/src/backends/meta-cursor-renderer.h +++ b/src/backends/meta-cursor-renderer.h @@ -41,6 +41,8 @@ struct _MetaHwCursorInhibitorInterface gboolean (* is_cursor_inhibited) (MetaHwCursorInhibitor *inhibitor); }; +gboolean meta_hw_cursor_inhibitor_is_cursor_inhibited (MetaHwCursorInhibitor *inhibitor); + #define META_TYPE_CURSOR_RENDERER (meta_cursor_renderer_get_type ()) G_DECLARE_DERIVABLE_TYPE (MetaCursorRenderer, meta_cursor_renderer, META, CURSOR_RENDERER, GObject); @@ -66,14 +68,6 @@ MetaCursorSprite * meta_cursor_renderer_get_cursor (MetaCursorRenderer *renderer gboolean meta_cursor_renderer_is_overlay_visible (MetaCursorRenderer *renderer); -void meta_cursor_renderer_add_hw_cursor_inhibitor (MetaCursorRenderer *renderer, - MetaHwCursorInhibitor *inhibitor); - -void meta_cursor_renderer_remove_hw_cursor_inhibitor (MetaCursorRenderer *renderer, - MetaHwCursorInhibitor *inhibitor); - -gboolean meta_cursor_renderer_is_hw_cursors_inhibited (MetaCursorRenderer *renderer); - graphene_rect_t meta_cursor_renderer_calculate_rect (MetaCursorRenderer *renderer, MetaCursorSprite *cursor_sprite); diff --git a/src/backends/meta-screen-cast-area-stream-src.c b/src/backends/meta-screen-cast-area-stream-src.c index 2d5d295d5..64138795b 100644 --- a/src/backends/meta-screen-cast-area-stream-src.c +++ b/src/backends/meta-screen-cast-area-stream-src.c @@ -83,19 +83,6 @@ get_backend (MetaScreenCastAreaStreamSrc *area_src) return meta_screen_cast_get_backend (screen_cast); } -static MetaCursorRenderer * -get_cursor_renderer (MetaScreenCastAreaStreamSrc *area_src) -{ - MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (area_src); - MetaScreenCastStream *stream = meta_screen_cast_stream_src_get_stream (src); - MetaScreenCastSession *session = meta_screen_cast_stream_get_session (stream); - MetaScreenCast *screen_cast = - meta_screen_cast_session_get_screen_cast (session); - MetaBackend *backend = meta_screen_cast_get_backend (screen_cast); - - return meta_backend_get_cursor_renderer (backend); -} - static void meta_screen_cast_area_stream_src_get_specs (MetaScreenCastStreamSrc *src, int *width, @@ -202,14 +189,14 @@ cursor_changed (MetaCursorTracker *cursor_tracker, static void inhibit_hw_cursor (MetaScreenCastAreaStreamSrc *area_src) { - MetaCursorRenderer *cursor_renderer; MetaHwCursorInhibitor *inhibitor; + MetaBackend *backend; g_return_if_fail (!area_src->hw_cursor_inhibited); - cursor_renderer = get_cursor_renderer (area_src); + backend = get_backend (area_src); inhibitor = META_HW_CURSOR_INHIBITOR (area_src); - meta_cursor_renderer_add_hw_cursor_inhibitor (cursor_renderer, inhibitor); + meta_backend_add_hw_cursor_inhibitor (backend, inhibitor); area_src->hw_cursor_inhibited = TRUE; } @@ -217,14 +204,14 @@ inhibit_hw_cursor (MetaScreenCastAreaStreamSrc *area_src) static void uninhibit_hw_cursor (MetaScreenCastAreaStreamSrc *area_src) { - MetaCursorRenderer *cursor_renderer; MetaHwCursorInhibitor *inhibitor; + MetaBackend *backend; g_return_if_fail (area_src->hw_cursor_inhibited); - cursor_renderer = get_cursor_renderer (area_src); + backend = get_backend (area_src); inhibitor = META_HW_CURSOR_INHIBITOR (area_src); - meta_cursor_renderer_remove_hw_cursor_inhibitor (cursor_renderer, inhibitor); + meta_backend_remove_hw_cursor_inhibitor (backend, inhibitor); area_src->hw_cursor_inhibited = FALSE; } diff --git a/src/backends/meta-screen-cast-monitor-stream-src.c b/src/backends/meta-screen-cast-monitor-stream-src.c index 775a83bea..e12c3e42b 100644 --- a/src/backends/meta-screen-cast-monitor-stream-src.c +++ b/src/backends/meta-screen-cast-monitor-stream-src.c @@ -236,30 +236,17 @@ cursor_changed (MetaCursorTracker *cursor_tracker, sync_cursor_state (monitor_src); } -static MetaCursorRenderer * -get_cursor_renderer (MetaScreenCastMonitorStreamSrc *monitor_src) -{ - MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (monitor_src); - MetaScreenCastStream *stream = meta_screen_cast_stream_src_get_stream (src); - MetaScreenCastSession *session = meta_screen_cast_stream_get_session (stream); - MetaScreenCast *screen_cast = - meta_screen_cast_session_get_screen_cast (session); - MetaBackend *backend = meta_screen_cast_get_backend (screen_cast); - - return meta_backend_get_cursor_renderer (backend); -} - static void inhibit_hw_cursor (MetaScreenCastMonitorStreamSrc *monitor_src) { - MetaCursorRenderer *cursor_renderer; MetaHwCursorInhibitor *inhibitor; + MetaBackend *backend; g_return_if_fail (!monitor_src->hw_cursor_inhibited); - cursor_renderer = get_cursor_renderer (monitor_src); + backend = get_backend (monitor_src); inhibitor = META_HW_CURSOR_INHIBITOR (monitor_src); - meta_cursor_renderer_add_hw_cursor_inhibitor (cursor_renderer, inhibitor); + meta_backend_add_hw_cursor_inhibitor (backend, inhibitor); monitor_src->hw_cursor_inhibited = TRUE; } @@ -267,14 +254,14 @@ inhibit_hw_cursor (MetaScreenCastMonitorStreamSrc *monitor_src) static void uninhibit_hw_cursor (MetaScreenCastMonitorStreamSrc *monitor_src) { - MetaCursorRenderer *cursor_renderer; MetaHwCursorInhibitor *inhibitor; + MetaBackend *backend; g_return_if_fail (monitor_src->hw_cursor_inhibited); - cursor_renderer = get_cursor_renderer (monitor_src); + backend = get_backend (monitor_src); inhibitor = META_HW_CURSOR_INHIBITOR (monitor_src); - meta_cursor_renderer_remove_hw_cursor_inhibitor (cursor_renderer, inhibitor); + meta_backend_remove_hw_cursor_inhibitor (backend, inhibitor); monitor_src->hw_cursor_inhibited = FALSE; } diff --git a/src/backends/native/meta-cursor-renderer-native.c b/src/backends/native/meta-cursor-renderer-native.c index f37f84cc1..223eec529 100644 --- a/src/backends/native/meta-cursor-renderer-native.c +++ b/src/backends/native/meta-cursor-renderer-native.c @@ -872,6 +872,10 @@ should_have_hw_cursor (MetaCursorRenderer *renderer, MetaCursorSprite *cursor_sprite, GList *gpus) { + MetaCursorRendererNative *cursor_renderer_native = + META_CURSOR_RENDERER_NATIVE (renderer); + MetaCursorRendererNativePrivate *priv = + meta_cursor_renderer_native_get_instance_private (cursor_renderer_native); CoglTexture *texture; MetaMonitorTransform transform; float scale; @@ -880,7 +884,7 @@ should_have_hw_cursor (MetaCursorRenderer *renderer, if (!cursor_sprite) return FALSE; - if (meta_cursor_renderer_is_hw_cursors_inhibited (renderer)) + if (meta_backend_is_hw_cursors_inhibited (priv->backend)) return FALSE; for (l = gpus; l; l = l->next)