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
This commit is contained in:
Jonas Ådahl 2017-04-12 14:09:58 +08:00
parent 8a32b42172
commit a119e58773
2 changed files with 16 additions and 6 deletions

View File

@ -100,6 +100,8 @@ struct _MetaBackendPrivate
ClutterBackend *clutter_backend; ClutterBackend *clutter_backend;
ClutterActor *stage; ClutterActor *stage;
gboolean is_pointer_position_initialized;
guint device_update_idle_id; guint device_update_idle_id;
GHashTable *device_monitors; GHashTable *device_monitors;
@ -185,10 +187,14 @@ meta_backend_monitors_changed (MetaBackend *backend)
if (clutter_input_device_get_coords (device, NULL, &point)) if (clutter_input_device_get_coords (device, NULL, &point))
{ {
/* If we're outside all monitors, warp the pointer back inside */ /* If we're outside all monitors, warp the pointer back inside */
if (!meta_monitor_manager_get_logical_monitor_at (monitor_manager, if ((!meta_monitor_manager_get_logical_monitor_at (monitor_manager,
point.x, point.y) && point.x, point.y) ||
!priv->is_pointer_position_initialized) &&
!meta_monitor_manager_is_headless (monitor_manager)) !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); 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); priv->input_settings = meta_backend_create_input_settings (backend);
center_pointer (backend);
#ifdef HAVE_REMOTE_DESKTOP #ifdef HAVE_REMOTE_DESKTOP
priv->dbus_session_watcher = g_object_new (META_TYPE_DBUS_SESSION_WATCHER, NULL); priv->dbus_session_watcher = g_object_new (META_TYPE_DBUS_SESSION_WATCHER, NULL);
if (is_screen_cast_enabled (backend)) if (is_screen_cast_enabled (backend))
@ -465,6 +469,12 @@ meta_backend_real_post_init (MetaBackend *backend)
if (is_remote_desktop_enabled (backend)) if (is_remote_desktop_enabled (backend))
priv->remote_desktop = meta_remote_desktop_new (priv->dbus_session_watcher); priv->remote_desktop = meta_remote_desktop_new (priv->dbus_session_watcher);
#endif /* HAVE_REMOTE_DESKTOP */ #endif /* HAVE_REMOTE_DESKTOP */
if (!meta_monitor_manager_is_headless (priv->monitor_manager))
{
center_pointer (backend);
priv->is_pointer_position_initialized = TRUE;
}
} }
static MetaCursorRenderer * static MetaCursorRenderer *

View File

@ -355,7 +355,7 @@ meta_monitor_manager_is_lid_closed (MetaMonitorManager *manager)
gboolean gboolean
meta_monitor_manager_is_headless (MetaMonitorManager *manager) meta_monitor_manager_is_headless (MetaMonitorManager *manager)
{ {
return !manager->monitors; return !manager->logical_monitors;
} }
float float