mirror of
https://github.com/brl/mutter.git
synced 2024-11-24 17:10:40 -05:00
backends: Unify cursor visibility checks
Instead of having device type checks spread around, unify cursor visibility dependent on device availability on a single function.
This commit is contained in:
parent
92cccf53df
commit
0fea0e383c
@ -293,13 +293,6 @@ on_device_added (ClutterDeviceManager *device_manager,
|
|||||||
create_device_monitor (backend, device_id);
|
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
|
static inline gboolean
|
||||||
check_has_pointing_device (ClutterDeviceManager *manager)
|
check_has_pointing_device (ClutterDeviceManager *manager)
|
||||||
{
|
{
|
||||||
@ -324,9 +317,10 @@ check_has_pointing_device (ClutterDeviceManager *manager)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline gboolean
|
static inline gboolean
|
||||||
check_has_slave_touchscreen (ClutterDeviceManager *manager)
|
check_pointer_visibility (ClutterDeviceManager *manager)
|
||||||
{
|
{
|
||||||
const GSList *devices;
|
const GSList *devices;
|
||||||
|
gboolean pointer_visible = TRUE;
|
||||||
|
|
||||||
devices = clutter_device_manager_peek_devices (manager);
|
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 &&
|
if (clutter_input_device_get_device_mode (device) != CLUTTER_INPUT_MODE_MASTER &&
|
||||||
clutter_input_device_get_device_type (device) == CLUTTER_TOUCHSCREEN_DEVICE)
|
clutter_input_device_get_device_type (device) == CLUTTER_TOUCHSCREEN_DEVICE)
|
||||||
return TRUE;
|
{
|
||||||
|
pointer_visible = FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return pointer_visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -359,26 +356,16 @@ on_device_removed (ClutterDeviceManager *device_manager,
|
|||||||
if (priv->current_device_id == device_id)
|
if (priv->current_device_id == device_id)
|
||||||
{
|
{
|
||||||
MetaCursorTracker *cursor_tracker = priv->cursor_tracker;
|
MetaCursorTracker *cursor_tracker = priv->cursor_tracker;
|
||||||
gboolean has_touchscreen, has_pointing_device;
|
gboolean pointer_hidden, has_pointing_device;
|
||||||
ClutterInputDeviceType device_type;
|
|
||||||
|
|
||||||
priv->current_device_id = 0;
|
priv->current_device_id = 0;
|
||||||
|
|
||||||
device_type = clutter_input_device_get_device_type (device);
|
pointer_hidden = !check_pointer_visibility (device_manager);
|
||||||
has_touchscreen = check_has_slave_touchscreen (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);
|
has_pointing_device = check_has_pointing_device (device_manager);
|
||||||
|
|
||||||
meta_cursor_tracker_set_pointer_visible (cursor_tracker,
|
meta_cursor_tracker_set_pointer_visible (cursor_tracker,
|
||||||
has_pointing_device &&
|
has_pointing_device &&
|
||||||
!has_touchscreen);
|
!pointer_hidden);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,20 +392,11 @@ set_initial_pointer_visibility (MetaBackend *backend,
|
|||||||
ClutterDeviceManager *device_manager)
|
ClutterDeviceManager *device_manager)
|
||||||
{
|
{
|
||||||
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
||||||
const GSList *devices;
|
gboolean pointer_visible;
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
pointer_visible = check_pointer_visibility (device_manager);
|
||||||
meta_cursor_tracker_set_pointer_visible (priv->cursor_tracker,
|
meta_cursor_tracker_set_pointer_visible (priv->cursor_tracker,
|
||||||
!has_touchscreen);
|
pointer_visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
static MetaInputSettings *
|
static MetaInputSettings *
|
||||||
|
Loading…
Reference in New Issue
Block a user