diff --git a/clutter/clutter/clutter-mutter.h b/clutter/clutter/clutter-mutter.h index 458871dff..bb2140e47 100644 --- a/clutter/clutter/clutter-mutter.h +++ b/clutter/clutter/clutter-mutter.h @@ -46,6 +46,12 @@ void clutter_stage_capture_into (ClutterStage *stage, cairo_rectangle_int_t *rect, uint8_t *data); +CLUTTER_EXPORT +void clutter_stage_freeze_updates (ClutterStage *stage); + +CLUTTER_EXPORT +void clutter_stage_thaw_updates (ClutterStage *stage); + #undef __CLUTTER_H_INSIDE__ #endif /* __CLUTTER_MUTTER_H__ */ diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c index f8d9e5222..533663f09 100644 --- a/clutter/clutter/clutter-stage.c +++ b/clutter/clutter/clutter-stage.c @@ -146,6 +146,8 @@ struct _ClutterStagePrivate gpointer paint_data; GDestroyNotify paint_notify; + int update_freeze_count; + guint relayout_pending : 1; guint redraw_pending : 1; guint is_fullscreen : 1; @@ -4900,3 +4902,58 @@ clutter_stage_capture_into (ClutterStage *stage, view = get_view_at_rect (stage, rect); capture_view_into (stage, paint, view, rect, data, rect->width * bpp); } + +/** + * clutter_stage_freeze_updates: + * + * Freezing updates makes Clutter stop processing events, + * redrawing, and advancing timelines, by pausing the master clock. This is + * necessary when implementing a display server, to ensure that Clutter doesn't + * keep trying to page flip when DRM master has been dropped, e.g. when VT + * switched away. + * + * The master clock starts out running, so if you are VT switched away on + * startup, you need to call this immediately. + * + * To thaw updates, use clutter_stage_thaw_updates(). + */ +void +clutter_stage_freeze_updates (ClutterStage *stage) +{ + ClutterStagePrivate *priv = stage->priv; + + priv->update_freeze_count++; + if (priv->update_freeze_count == 1) + { + ClutterMasterClock *master_clock; + + master_clock = _clutter_master_clock_get_default (); + _clutter_master_clock_set_paused (master_clock, TRUE); + } +} + +/** + * clutter_stage_thaw_updates: + * + * Resumes a master clock that has previously been frozen with + * clutter_stage_freeze_updates(), and start pumping the master clock + * again at the next iteration. Note that if you're switching back to your + * own VT, you should probably also queue a stage redraw with + * clutter_stage_ensure_redraw(). + */ +void +clutter_stage_thaw_updates (ClutterStage *stage) +{ + ClutterStagePrivate *priv = stage->priv; + + g_assert (priv->update_freeze_count > 0); + + priv->update_freeze_count--; + if (priv->update_freeze_count == 0) + { + ClutterMasterClock *master_clock; + + master_clock = _clutter_master_clock_get_default (); + _clutter_master_clock_set_paused (master_clock, FALSE); + } +} diff --git a/clutter/clutter/egl/clutter-backend-eglnative.c b/clutter/clutter/egl/clutter-backend-eglnative.c index 3221d40c7..ec02147f6 100644 --- a/clutter/clutter/egl/clutter-backend-eglnative.c +++ b/clutter/clutter/egl/clutter-backend-eglnative.c @@ -333,57 +333,3 @@ clutter_egl_get_egl_display (void) return 0; #endif } - -/** - * clutter_egl_freeze_master_clock: - * - * Freezing the master clock makes Clutter stop processing events, - * redrawing, and advancing timelines. This is necessary when implementing - * a display server, to ensure that Clutter doesn't keep trying to page - * flip when DRM master has been dropped, e.g. when VT switched away. - * - * The master clock starts out running, so if you are VT switched away on - * startup, you need to call this immediately. - * - * If you're also using the evdev backend, make sure to also use - * clutter_evdev_release_devices() to make sure that Clutter doesn't also - * access revoked evdev devices when VT switched away. - * - * To unthaw a frozen master clock, use clutter_egl_thaw_master_clock(). - * - * Since: 1.20 - */ -void -clutter_egl_freeze_master_clock (void) -{ - ClutterMasterClock *master_clock; - - g_return_if_fail (CLUTTER_IS_BACKEND_EGL_NATIVE (clutter_get_default_backend ())); - - master_clock = _clutter_master_clock_get_default (); - _clutter_master_clock_set_paused (master_clock, TRUE); -} - -/** - * clutter_egl_thaw_master_clock: - * - * Thaws a master clock that has previously been frozen with - * clutter_egl_freeze_master_clock(), and start pumping the master clock - * again at the next iteration. Note that if you're switching back to your - * own VT, you should probably also queue a stage redraw with - * clutter_stage_ensure_redraw(). - * - * Since: 1.20 - */ -void -clutter_egl_thaw_master_clock (void) -{ - ClutterMasterClock *master_clock; - - g_return_if_fail (CLUTTER_IS_BACKEND_EGL_NATIVE (clutter_get_default_backend ())); - - master_clock = _clutter_master_clock_get_default (); - _clutter_master_clock_set_paused (master_clock, FALSE); - - _clutter_master_clock_start_running (master_clock); -} diff --git a/clutter/clutter/egl/clutter-egl.h b/clutter/clutter/egl/clutter-egl.h index 52fc57ebc..a4287beae 100644 --- a/clutter/clutter/egl/clutter-egl.h +++ b/clutter/clutter/egl/clutter-egl.h @@ -87,11 +87,6 @@ EGLDisplay clutter_egl_display (void); CLUTTER_EXPORT EGLDisplay clutter_egl_get_egl_display (void); -CLUTTER_EXPORT -void clutter_egl_freeze_master_clock (void); -CLUTTER_EXPORT -void clutter_egl_thaw_master_clock (void); - G_END_DECLS #endif /* __CLUTTER_EGL_H__ */ diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c index b52d83573..b8ea93da9 100644 --- a/src/backends/native/meta-backend-native.c +++ b/src/backends/native/meta-backend-native.c @@ -44,8 +44,6 @@ #include "backends/native/meta-renderer-native.h" #include "backends/native/meta-stage-native.h" #include "clutter/evdev/clutter-evdev.h" -#include "clutter/egl/clutter-egl.h" -#include "clutter/evdev/clutter-evdev.h" #include "core/meta-border.h" #include "meta/main.h" @@ -625,13 +623,14 @@ void meta_backend_native_pause (MetaBackendNative *native) { MetaBackend *backend = META_BACKEND (native); + ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend)); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); MetaMonitorManagerKms *monitor_manager_kms = META_MONITOR_MANAGER_KMS (monitor_manager); clutter_evdev_release_devices (); - clutter_egl_freeze_master_clock (); + clutter_stage_freeze_updates (stage); meta_monitor_manager_kms_pause (monitor_manager_kms); } @@ -639,20 +638,19 @@ meta_backend_native_pause (MetaBackendNative *native) void meta_backend_native_resume (MetaBackendNative *native) { MetaBackend *backend = META_BACKEND (native); + ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend)); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); MetaMonitorManagerKms *monitor_manager_kms = META_MONITOR_MANAGER_KMS (monitor_manager); - ClutterActor *stage; MetaIdleMonitor *idle_monitor; meta_monitor_manager_kms_resume (monitor_manager_kms); clutter_evdev_reclaim_devices (); - clutter_egl_thaw_master_clock (); + clutter_stage_thaw_updates (stage); - stage = meta_backend_get_stage (backend); - clutter_actor_queue_redraw (stage); + clutter_actor_queue_redraw (CLUTTER_ACTOR (stage)); idle_monitor = meta_backend_get_idle_monitor (backend, 0); meta_idle_monitor_reset_idletime (idle_monitor);