From 1e2bdcc3c5cbf8df59e0fb3ddfb2f4cfe6d909ce Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Sun, 30 Mar 2014 20:50:03 -0400 Subject: [PATCH] idle-monitor: Move reset_idletime handling to events.c It's not specific to the Wayland protocol at all, and it's not really a Wayland compositor thing. This should eventually be in the native backend. --- src/core/events.c | 34 ++++++++++++++++++++++++++++++ src/wayland/meta-wayland-surface.c | 1 - src/wayland/meta-wayland.c | 25 ---------------------- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/core/events.c b/src/core/events.c index aaf97f9f7..3d113bdf4 100644 --- a/src/core/events.c +++ b/src/core/events.c @@ -1850,6 +1850,38 @@ meta_display_handle_xevent (MetaDisplay *display, return bypass_gtk; } +static void +handle_idletime_for_event (const ClutterEvent *event) +{ + ClutterInputDevice *device, *source_device; + MetaIdleMonitor *core_monitor, *device_monitor; + int device_id; + + /* This is handled by XSync under X11. */ + if (!meta_is_wayland_compositor ()) + return; + + device = clutter_event_get_device (event); + if (device == NULL) + 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 meta_display_handle_event (MetaDisplay *display, const ClutterEvent *event) @@ -1864,6 +1896,8 @@ meta_display_handle_event (MetaDisplay *display, meta_wayland_compositor_update (compositor, event); } + handle_idletime_for_event (event); + window = get_window_for_event (display, event); display->current_time = event->any.time; diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index 39239ef71..77ea2e563 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -55,7 +55,6 @@ #include #include #include "frame.h" -#include "meta-idle-monitor-private.h" #include "monitor-private.h" #include "meta-surface-actor.h" diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c index 12c1935c4..6a4a0ce4c 100644 --- a/src/wayland/meta-wayland.c +++ b/src/wayland/meta-wayland.c @@ -51,7 +51,6 @@ #include #include #include "frame.h" -#include "meta-idle-monitor-private.h" #include "meta-weston-launch.h" #include "monitor-private.h" @@ -520,30 +519,6 @@ void meta_wayland_compositor_update (MetaWaylandCompositor *compositor, 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; - - 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); - } - meta_wayland_seat_update (compositor->seat, event); }