[mutter/wip/texture-purge-on-nvidia: 13/17] backend/native: update idletime even when frameclock is frozen
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/texture-purge-on-nvidia: 13/17] backend/native: update idletime even when frameclock is frozen
- Date: Fri, 11 Jan 2019 23:51:24 +0000 (UTC)
commit fca4eb371b9d362a9f298d3385222ba0ea9cddc1
Author: Ray Strode <rstrode redhat com>
Date: Wed Jan 9 16:54:20 2019 -0500
backend/native: update idletime even when frameclock is frozen
This commit uses the new clutter stage filter apis to detect
when the user is active, even if the frame clock is frozen.
src/backends/native/meta-backend-native.c | 63 ++++++++++++++++++++++++++++++-
1 file changed, 62 insertions(+), 1 deletion(-)
---
diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c
index 0f6a00248..d10b7d6b5 100644
--- a/src/backends/native/meta-backend-native.c
+++ b/src/backends/native/meta-backend-native.c
@@ -647,6 +647,54 @@ meta_backend_native_thaw_frame_clock (MetaBackendNative *native)
clutter_egl_thaw_master_clock ();
}
+/* FIXME: this is shamefully duplicated from core/events.c
+ */
+static void
+handle_idletime_for_event (const ClutterEvent *event)
+{
+ ClutterInputDevice *device, *source_device;
+ MetaIdleMonitor *core_monitor, *device_monitor;
+ int device_id;
+
+ device = clutter_event_get_device (event);
+ if (device == NULL)
+ return;
+
+ if (event->any.flags & CLUTTER_EVENT_FLAG_SYNTHETIC ||
+ event->type == CLUTTER_ENTER ||
+ event->type == CLUTTER_LEAVE ||
+ event->type == CLUTTER_STAGE_STATE ||
+ event->type == CLUTTER_DESTROY_NOTIFY ||
+ event->type == CLUTTER_CLIENT_MESSAGE ||
+ event->type == CLUTTER_DELETE)
+ return;
+
+ device_id = clutter_input_device_get_device_id (device);
+
+ core_monitor = meta_idle_monitor_get_core ();
+ device_monitor = meta_idle_monitor_get_for_device (device_id);
+
+ meta_idle_monitor_reset_idletime (core_monitor);
+ meta_idle_monitor_reset_idletime (device_monitor);
+
+ source_device = clutter_event_get_source_device (event);
+ if (source_device != device)
+ {
+ device_id = clutter_input_device_get_device_id (device);
+ device_monitor = meta_idle_monitor_get_for_device (device_id);
+ meta_idle_monitor_reset_idletime (device_monitor);
+ }
+}
+
+static gboolean
+stage_filter_func (const ClutterEvent *event,
+ MetaBackendNative *native)
+{
+ handle_idletime_for_event (event);
+
+ return CLUTTER_EVENT_PROPAGATE;
+}
+
void
meta_backend_native_pause (MetaBackendNative *native)
{
@@ -655,12 +703,17 @@ meta_backend_native_pause (MetaBackendNative *native)
meta_backend_get_monitor_manager (backend);
MetaMonitorManagerKms *monitor_manager_kms =
META_MONITOR_MANAGER_KMS (monitor_manager);
+ ClutterActor *stage;
+
+ stage = meta_backend_get_stage (backend);
clutter_evdev_release_devices ();
meta_backend_native_freeze_frame_clock (native);
meta_monitor_manager_kms_pause (monitor_manager_kms);
+
+ clutter_stage_remove_filter (stage, stage_filter_func, native);
}
void meta_backend_native_resume (MetaBackendNative *native)
@@ -670,16 +723,24 @@ void meta_backend_native_resume (MetaBackendNative *native)
meta_backend_get_monitor_manager (backend);
MetaMonitorManagerKms *monitor_manager_kms =
META_MONITOR_MANAGER_KMS (monitor_manager);
+ MetaDisplay *display = meta_get_display ();
ClutterActor *stage;
MetaIdleMonitor *idle_monitor;
+ stage = meta_backend_get_stage (backend);
+
+ clutter_stage_add_filter (stage, stage_filter_func, native);
+
+ clutter_clear_glyph_cache ();
+ meta_screen_update_cursor (display->screen);
+ g_signal_emit_by_name (display, "gl-video-memory-purged");
+
meta_monitor_manager_kms_resume (monitor_manager_kms);
clutter_evdev_reclaim_devices ();
meta_backend_native_thaw_frame_clock (native);
- stage = meta_backend_get_stage (backend);
clutter_actor_queue_redraw (stage);
idle_monitor = meta_backend_get_idle_monitor (backend, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]