From c98bab83270c68dfac4e479cbe957387e1c2e5c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 1 Dec 2016 15:37:32 +0800 Subject: [PATCH] monitor-manager: Make logical monitor from point API take floats Change meta_monitor_manager_get_logical_monitor_at() to use floats, replace users of meta_monitor_manager_get_monitor_at_point() to use the API that returns a logical monitor and remove the now unused function. https://bugzilla.gnome.org/show_bug.cgi?id=777732 --- src/backends/meta-backend.c | 4 +-- src/backends/meta-monitor-manager-private.h | 8 ++---- src/backends/meta-monitor-manager.c | 28 ++------------------- src/backends/native/meta-backend-native.c | 3 ++- 4 files changed, 8 insertions(+), 35 deletions(-) diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c index 1f24a907c..06d435d02 100644 --- a/src/backends/meta-backend.c +++ b/src/backends/meta-backend.c @@ -146,8 +146,8 @@ 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_monitor_at_point (monitor_manager, - point.x, point.y) < 0) + if (!meta_monitor_manager_get_logical_monitor_at (monitor_manager, + point.x, point.y)) center_pointer (backend); } } diff --git a/src/backends/meta-monitor-manager-private.h b/src/backends/meta-monitor-manager-private.h index a34cc2eec..0754628dc 100644 --- a/src/backends/meta-monitor-manager-private.h +++ b/src/backends/meta-monitor-manager-private.h @@ -374,8 +374,8 @@ MetaLogicalMonitor *meta_monitor_manager_get_logical_monitor_from_number (MetaMo MetaLogicalMonitor *meta_monitor_manager_get_primary_logical_monitor (MetaMonitorManager *manager); MetaLogicalMonitor *meta_monitor_manager_get_logical_monitor_at (MetaMonitorManager *manager, - int x, - int y); + float x, + float y); MetaLogicalMonitor *meta_monitor_manager_get_logical_monitor_from_rect (MetaMonitorManager *manager, MetaRectangle *rect); @@ -427,10 +427,6 @@ gboolean meta_monitor_manager_get_monitor_matrix (MetaMonitorManager * MetaOutput *output, gfloat matrix[6]); -gint meta_monitor_manager_get_monitor_at_point (MetaMonitorManager *manager, - gfloat x, - gfloat y); - void meta_monitor_manager_clear_output (MetaOutput *output); void meta_monitor_manager_clear_mode (MetaMonitorMode *mode); void meta_monitor_manager_clear_crtc (MetaCRTC *crtc); diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c index 5b5b8983a..b67be4ab9 100644 --- a/src/backends/meta-monitor-manager.c +++ b/src/backends/meta-monitor-manager.c @@ -1331,8 +1331,8 @@ meta_monitor_manager_get_primary_logical_monitor (MetaMonitorManager *manager) MetaLogicalMonitor * meta_monitor_manager_get_logical_monitor_at (MetaMonitorManager *manager, - int x, - int y) + float x, + float y) { unsigned int i; @@ -1726,30 +1726,6 @@ meta_monitor_manager_get_monitor_for_output (MetaMonitorManager *manager, return -1; } -gint -meta_monitor_manager_get_monitor_at_point (MetaMonitorManager *manager, - gfloat x, - gfloat y) -{ - unsigned int i; - - for (i = 0; i < manager->n_logical_monitors; i++) - { - MetaLogicalMonitor *logical_monitor = &manager->logical_monitors[i]; - int left, right, top, bottom; - - left = logical_monitor->rect.x; - right = left + logical_monitor->rect.width; - top = logical_monitor->rect.y; - bottom = top + logical_monitor->rect.height; - - if ((x >= left) && (x < right) && (y >= top) && (y < bottom)) - return i; - } - - return -1; -} - gboolean meta_monitor_manager_get_is_builtin_display_on (MetaMonitorManager *manager) { diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c index 90949b483..63d548d3b 100644 --- a/src/backends/native/meta-backend-native.c +++ b/src/backends/native/meta-backend-native.c @@ -247,7 +247,8 @@ pointer_constrain_callback (ClutterInputDevice *device, &n_logical_monitors); /* if we're moving inside a monitor, we're fine */ - if (meta_monitor_manager_get_monitor_at_point (monitor_manager, *new_x, *new_y) >= 0) + if (meta_monitor_manager_get_logical_monitor_at (monitor_manager, + *new_x, *new_y)) return; /* if we're trying to escape, clamp to the CRTC we're coming from */