[mutter/wip/carlosg/there-can-be-only-one: 1/3] backends: Unify cursor visibility checks
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/there-can-be-only-one: 1/3] backends: Unify cursor visibility checks
- Date: Fri, 2 Nov 2018 15:16:00 +0000 (UTC)
commit 0fea0e383c1709f94974b3f1a650fc08502295dc
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Nov 2 15:49:01 2018 +0100
backends: Unify cursor visibility checks
Instead of having device type checks spread around, unify cursor
visibility dependent on device availability on a single function.
src/backends/meta-backend.c | 54 ++++++++++++++-------------------------------
1 file changed, 16 insertions(+), 38 deletions(-)
---
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
index 6d1c22e65..afbb41dc7 100644
--- a/src/backends/meta-backend.c
+++ b/src/backends/meta-backend.c
@@ -293,13 +293,6 @@ on_device_added (ClutterDeviceManager *device_manager,
create_device_monitor (backend, device_id);
}
-static inline gboolean
-device_is_slave_touchscreen (ClutterInputDevice *device)
-{
- return (clutter_input_device_get_device_mode (device) != CLUTTER_INPUT_MODE_MASTER &&
- clutter_input_device_get_device_type (device) == CLUTTER_TOUCHSCREEN_DEVICE);
-}
-
static inline gboolean
check_has_pointing_device (ClutterDeviceManager *manager)
{
@@ -324,9 +317,10 @@ check_has_pointing_device (ClutterDeviceManager *manager)
}
static inline gboolean
-check_has_slave_touchscreen (ClutterDeviceManager *manager)
+check_pointer_visibility (ClutterDeviceManager *manager)
{
const GSList *devices;
+ gboolean pointer_visible = TRUE;
devices = clutter_device_manager_peek_devices (manager);
@@ -336,10 +330,13 @@ check_has_slave_touchscreen (ClutterDeviceManager *manager)
if (clutter_input_device_get_device_mode (device) != CLUTTER_INPUT_MODE_MASTER &&
clutter_input_device_get_device_type (device) == CLUTTER_TOUCHSCREEN_DEVICE)
- return TRUE;
+ {
+ pointer_visible = FALSE;
+ break;
+ }
}
- return FALSE;
+ return pointer_visible;
}
static void
@@ -359,26 +356,16 @@ on_device_removed (ClutterDeviceManager *device_manager,
if (priv->current_device_id == device_id)
{
MetaCursorTracker *cursor_tracker = priv->cursor_tracker;
- gboolean has_touchscreen, has_pointing_device;
- ClutterInputDeviceType device_type;
+ gboolean pointer_hidden, has_pointing_device;
priv->current_device_id = 0;
- device_type = clutter_input_device_get_device_type (device);
- has_touchscreen = check_has_slave_touchscreen (device_manager);
+ pointer_hidden = !check_pointer_visibility (device_manager);
+ has_pointing_device = check_has_pointing_device (device_manager);
- if (device_type == CLUTTER_TOUCHSCREEN_DEVICE && has_touchscreen)
- {
- /* There's more touchscreens left, keep the pointer hidden */
- meta_cursor_tracker_set_pointer_visible (cursor_tracker, FALSE);
- }
- else if (device_type != CLUTTER_KEYBOARD_DEVICE)
- {
- has_pointing_device = check_has_pointing_device (device_manager);
- meta_cursor_tracker_set_pointer_visible (cursor_tracker,
- has_pointing_device &&
- !has_touchscreen);
- }
+ meta_cursor_tracker_set_pointer_visible (cursor_tracker,
+ has_pointing_device &&
+ !pointer_hidden);
}
}
@@ -405,20 +392,11 @@ set_initial_pointer_visibility (MetaBackend *backend,
ClutterDeviceManager *device_manager)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
- const GSList *devices;
- const GSList *l;
- gboolean has_touchscreen = FALSE;
-
- devices = clutter_device_manager_peek_devices (device_manager);
- for (l = devices; l; l = l->next)
- {
- ClutterInputDevice *device = l->data;
-
- has_touchscreen |= device_is_slave_touchscreen (device);
- }
+ gboolean pointer_visible;
+ pointer_visible = check_pointer_visibility (device_manager);
meta_cursor_tracker_set_pointer_visible (priv->cursor_tracker,
- !has_touchscreen);
+ pointer_visible);
}
static MetaInputSettings *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]