mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
backends: Make meta_backend_update_last_device() take a clutter device
Instead of a pretty x11 specific device ID. This also updates the argument of the ::last-device-changed signal to be a ClutterInputDevice. https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
This commit is contained in:
parent
4761c4ee1c
commit
f55d4f33af
@ -168,7 +168,7 @@ void meta_backend_freeze_updates (MetaBackend *backend);
|
||||
void meta_backend_thaw_updates (MetaBackend *backend);
|
||||
|
||||
void meta_backend_update_last_device (MetaBackend *backend,
|
||||
int device_id);
|
||||
ClutterInputDevice *device);
|
||||
|
||||
gboolean meta_backend_get_relative_motion_deltas (MetaBackend *backend,
|
||||
const ClutterEvent *event,
|
||||
|
@ -148,7 +148,7 @@ struct _MetaBackendPrivate
|
||||
|
||||
GHashTable *device_monitors;
|
||||
|
||||
int current_device_id;
|
||||
ClutterInputDevice *current_device;
|
||||
|
||||
MetaPointerConstraint *client_pointer_constraint;
|
||||
MetaDnd *dnd;
|
||||
@ -425,13 +425,13 @@ on_device_removed (ClutterDeviceManager *device_manager,
|
||||
/* If the device the user last interacted goes away, check again pointer
|
||||
* visibility.
|
||||
*/
|
||||
if (priv->current_device_id == device_id)
|
||||
if (priv->current_device == device)
|
||||
{
|
||||
MetaCursorTracker *cursor_tracker = priv->cursor_tracker;
|
||||
gboolean has_touchscreen, has_pointing_device;
|
||||
ClutterInputDeviceType device_type;
|
||||
|
||||
priv->current_device_id = 0;
|
||||
priv->current_device = NULL;
|
||||
|
||||
device_type = clutter_input_device_get_device_type (device);
|
||||
has_touchscreen = check_has_slave_touchscreen (device_manager);
|
||||
@ -770,7 +770,7 @@ meta_backend_class_init (MetaBackendClass *klass)
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0,
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 1, G_TYPE_INT);
|
||||
G_TYPE_NONE, 1, CLUTTER_TYPE_INPUT_DEVICE);
|
||||
signals[LID_IS_CLOSED_CHANGED] =
|
||||
g_signal_new ("lid-is-closed-changed",
|
||||
G_TYPE_FROM_CLASS (object_class),
|
||||
@ -1171,17 +1171,12 @@ update_last_device (MetaBackend *backend)
|
||||
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
||||
MetaCursorTracker *cursor_tracker = priv->cursor_tracker;
|
||||
ClutterInputDeviceType device_type;
|
||||
ClutterDeviceManager *manager;
|
||||
ClutterInputDevice *device;
|
||||
|
||||
priv->device_update_idle_id = 0;
|
||||
manager = clutter_device_manager_get_default ();
|
||||
device = clutter_device_manager_get_device (manager,
|
||||
priv->current_device_id);
|
||||
device_type = clutter_input_device_get_device_type (device);
|
||||
device_type = clutter_input_device_get_device_type (priv->current_device);
|
||||
|
||||
g_signal_emit (backend, signals[LAST_DEVICE_CHANGED], 0,
|
||||
priv->current_device_id);
|
||||
priv->current_device);
|
||||
|
||||
switch (device_type)
|
||||
{
|
||||
@ -1200,23 +1195,18 @@ update_last_device (MetaBackend *backend)
|
||||
|
||||
void
|
||||
meta_backend_update_last_device (MetaBackend *backend,
|
||||
int device_id)
|
||||
ClutterInputDevice *device)
|
||||
{
|
||||
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
||||
ClutterDeviceManager *manager;
|
||||
ClutterInputDevice *device;
|
||||
|
||||
if (priv->current_device_id == device_id)
|
||||
if (priv->current_device == device)
|
||||
return;
|
||||
|
||||
manager = clutter_device_manager_get_default ();
|
||||
device = clutter_device_manager_get_device (manager, device_id);
|
||||
|
||||
if (!device ||
|
||||
clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_MASTER)
|
||||
return;
|
||||
|
||||
priv->current_device_id = device_id;
|
||||
priv->current_device = device;
|
||||
|
||||
if (priv->device_update_idle_id == 0)
|
||||
{
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "backends/meta-stage-private.h"
|
||||
#include "backends/x11/meta-clutter-backend-x11.h"
|
||||
#include "backends/x11/meta-event-x11.h"
|
||||
#include "backends/x11/meta-seat-x11.h"
|
||||
#include "backends/x11/meta-stage-x11.h"
|
||||
#include "backends/x11/meta-renderer-x11.h"
|
||||
#include "clutter/clutter.h"
|
||||
@ -242,6 +243,9 @@ handle_device_change (MetaBackendX11 *x11,
|
||||
XIEvent *event)
|
||||
{
|
||||
XIDeviceChangedEvent *device_changed;
|
||||
ClutterInputDevice *device;
|
||||
ClutterBackend *backend;
|
||||
ClutterSeat *seat;
|
||||
|
||||
if (event->evtype != XI_DeviceChanged)
|
||||
return;
|
||||
@ -251,8 +255,11 @@ handle_device_change (MetaBackendX11 *x11,
|
||||
if (device_changed->reason != XISlaveSwitch)
|
||||
return;
|
||||
|
||||
meta_backend_update_last_device (META_BACKEND (x11),
|
||||
backend = meta_backend_get_clutter_backend (META_BACKEND (x11));
|
||||
seat = clutter_backend_get_default_seat (backend);
|
||||
device = meta_seat_x11_lookup_device_id (META_SEAT_X11 (seat),
|
||||
device_changed->sourceid);
|
||||
meta_backend_update_last_device (META_BACKEND (x11), device);
|
||||
}
|
||||
|
||||
/* Clutter makes the assumption that there is only one X window
|
||||
|
@ -273,10 +273,7 @@ meta_display_handle_event (MetaDisplay *display,
|
||||
source = clutter_event_get_source_device (event);
|
||||
|
||||
if (source)
|
||||
{
|
||||
meta_backend_update_last_device (backend,
|
||||
clutter_input_device_get_device_id (source));
|
||||
}
|
||||
meta_backend_update_last_device (backend, source);
|
||||
|
||||
#ifdef HAVE_WAYLAND
|
||||
if (meta_is_wayland_compositor () && event->type == CLUTTER_MOTION)
|
||||
|
Loading…
Reference in New Issue
Block a user