From a119e5877367204a29823ff3d5e480a98010f695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 12 Apr 2017 14:09:58 +0800 Subject: [PATCH] backend: Only try to center pointer when there not headless Don't attempt to center the pointer when there is nothing to center on. https://bugzilla.gnome.org/show_bug.cgi?id=730551 --- src/backends/meta-backend.c | 20 +++++++++++++++----- src/backends/meta-monitor-manager.c | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c index ba293b62d..faa8d6fdc 100644 --- a/src/backends/meta-backend.c +++ b/src/backends/meta-backend.c @@ -100,6 +100,8 @@ struct _MetaBackendPrivate ClutterBackend *clutter_backend; ClutterActor *stage; + gboolean is_pointer_position_initialized; + guint device_update_idle_id; GHashTable *device_monitors; @@ -185,10 +187,14 @@ meta_backend_monitors_changed (MetaBackend *backend) if (clutter_input_device_get_coords (device, NULL, &point)) { /* If we're outside all monitors, warp the pointer back inside */ - if (!meta_monitor_manager_get_logical_monitor_at (monitor_manager, - point.x, point.y) && + if ((!meta_monitor_manager_get_logical_monitor_at (monitor_manager, + point.x, point.y) || + !priv->is_pointer_position_initialized) && !meta_monitor_manager_is_headless (monitor_manager)) - center_pointer (backend); + { + center_pointer (backend); + priv->is_pointer_position_initialized = TRUE; + } } meta_settings_update_ui_scaling_factor (priv->settings); @@ -456,8 +462,6 @@ meta_backend_real_post_init (MetaBackend *backend) priv->input_settings = meta_backend_create_input_settings (backend); - center_pointer (backend); - #ifdef HAVE_REMOTE_DESKTOP priv->dbus_session_watcher = g_object_new (META_TYPE_DBUS_SESSION_WATCHER, NULL); if (is_screen_cast_enabled (backend)) @@ -465,6 +469,12 @@ meta_backend_real_post_init (MetaBackend *backend) if (is_remote_desktop_enabled (backend)) priv->remote_desktop = meta_remote_desktop_new (priv->dbus_session_watcher); #endif /* HAVE_REMOTE_DESKTOP */ + + if (!meta_monitor_manager_is_headless (priv->monitor_manager)) + { + center_pointer (backend); + priv->is_pointer_position_initialized = TRUE; + } } static MetaCursorRenderer * diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c index 1dd7c2081..404dbcddd 100644 --- a/src/backends/meta-monitor-manager.c +++ b/src/backends/meta-monitor-manager.c @@ -355,7 +355,7 @@ meta_monitor_manager_is_lid_closed (MetaMonitorManager *manager) gboolean meta_monitor_manager_is_headless (MetaMonitorManager *manager) { - return !manager->monitors; + return !manager->logical_monitors; } float