clutter: Drop ClutterDeviceManager

This is mostly replaced by ClutterSeat, which offers a per-seat instead
of a global device abstraction.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
This commit is contained in:
Carlos Garnacho
2019-10-04 23:01:54 +02:00
parent 873449d0f9
commit d3160d095d
25 changed files with 292 additions and 1446 deletions

View File

@ -44,7 +44,6 @@
#include "backends/meta-backend-private.h"
#include "backends/meta-renderer.h"
#include "backends/native/meta-device-manager-native.h"
#include "backends/native/meta-seat-native.h"
#include "backends/native/meta-stage-native.h"
#include "clutter/clutter.h"
@ -57,7 +56,6 @@ struct _MetaClutterBackendNative
MetaSeatNative *main_seat;
MetaStageNative *stage_native;
MetaDeviceManagerNative *device_manager;
};
static gchar *evdev_seat_id;
@ -101,14 +99,6 @@ meta_clutter_backend_native_create_stage (ClutterBackend *backend,
return CLUTTER_STAGE_WINDOW (clutter_backend_native->stage_native);
}
static ClutterDeviceManager *
meta_clutter_backend_native_get_device_manager (ClutterBackend *backend)
{
MetaClutterBackendNative *backend_native = META_CLUTTER_BACKEND_NATIVE (backend);
return CLUTTER_DEVICE_MANAGER (backend_native->device_manager);
}
static void
meta_clutter_backend_native_init_events (ClutterBackend *backend)
{
@ -119,8 +109,6 @@ meta_clutter_backend_native_init_events (ClutterBackend *backend)
"backend", backend,
"seat-id", seat_id,
NULL);
backend_native->device_manager =
meta_device_manager_native_new (backend, backend_native->main_seat);
}
static ClutterSeat *
@ -143,7 +131,6 @@ meta_clutter_backend_native_class_init (MetaClutterBackendNativeClass *klass)
clutter_backend_class->get_renderer = meta_clutter_backend_native_get_renderer;
clutter_backend_class->create_stage = meta_clutter_backend_native_create_stage;
clutter_backend_class->get_device_manager = meta_clutter_backend_native_get_device_manager;
clutter_backend_class->init_events = meta_clutter_backend_native_init_events;
clutter_backend_class->get_default_seat = meta_clutter_backend_native_get_default_seat;
}

View File

@ -1,210 +0,0 @@
/*
* Copyright (C) 2010 Intel Corp.
* Copyright (C) 2014 Jonas Ådahl
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Author: Damien Lespiau <damien.lespiau@intel.com>
* Author: Jonas Ådahl <jadahl@gmail.com>
*/
#include "config.h"
#include <math.h>
#include <float.h>
#include <linux/input.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <glib.h>
#include "backends/native/meta-device-manager-native.h"
#include "backends/native/meta-event-native.h"
#include "backends/native/meta-input-device-native.h"
#include "backends/native/meta-input-device-tool-native.h"
#include "backends/native/meta-keymap-native.h"
#include "backends/native/meta-seat-native.h"
#include "backends/native/meta-virtual-input-device-native.h"
#include "backends/native/meta-xkb-utils.h"
#include "clutter/clutter-mutter.h"
struct _MetaDeviceManagerNativePrivate
{
MetaSeatNative *main_seat;
};
G_DEFINE_TYPE_WITH_CODE (MetaDeviceManagerNative,
meta_device_manager_native,
CLUTTER_TYPE_DEVICE_MANAGER,
G_ADD_PRIVATE (MetaDeviceManagerNative))
/*
* ClutterDeviceManager implementation
*/
static void
meta_device_manager_native_add_device (ClutterDeviceManager *manager,
ClutterInputDevice *device)
{
}
static void
meta_device_manager_native_remove_device (ClutterDeviceManager *manager,
ClutterInputDevice *device)
{
}
static const GSList *
meta_device_manager_native_get_devices (ClutterDeviceManager *manager)
{
ClutterBackend *clutter_backend = clutter_get_default_backend ();
ClutterSeat *seat = clutter_backend_get_default_seat (clutter_backend);
GSList *retval = NULL;
retval = g_slist_copy (META_SEAT_NATIVE (seat)->devices);
retval = g_slist_prepend (retval, clutter_seat_get_pointer (seat));
retval = g_slist_prepend (retval, clutter_seat_get_keyboard (seat));
return retval;
}
static ClutterInputDevice *
meta_device_manager_native_get_core_device (ClutterDeviceManager *manager,
ClutterInputDeviceType type)
{
MetaDeviceManagerNative *manager_evdev;
MetaDeviceManagerNativePrivate *priv;
manager_evdev = META_DEVICE_MANAGER_NATIVE (manager);
priv = manager_evdev->priv;
switch (type)
{
case CLUTTER_POINTER_DEVICE:
return priv->main_seat->core_pointer;
case CLUTTER_KEYBOARD_DEVICE:
return priv->main_seat->core_keyboard;
case CLUTTER_EXTENSION_DEVICE:
default:
return NULL;
}
return NULL;
}
static ClutterInputDevice *
meta_device_manager_native_get_device (ClutterDeviceManager *manager,
gint id)
{
MetaDeviceManagerNative *manager_evdev;
MetaSeatNative *seat;
ClutterInputDevice *device;
manager_evdev = META_DEVICE_MANAGER_NATIVE (manager);
seat = manager_evdev->priv->main_seat;
device = meta_seat_native_get_device (seat, id);
if (device)
return device;
return NULL;
}
static void
on_device_added (ClutterSeat *seat,
ClutterInputDevice *parent,
ClutterInputDevice *device,
ClutterDeviceManager *manager)
{
g_signal_emit_by_name (manager, "device-added", device);
}
static void
on_device_removed (ClutterSeat *seat,
ClutterInputDevice *parent,
ClutterInputDevice *device,
ClutterDeviceManager *manager)
{
g_signal_emit_by_name (manager, "device-removed", device);
}
static void
on_tool_changed (ClutterSeat *seat,
ClutterInputDevice *device,
ClutterInputDeviceTool *tool,
ClutterDeviceManager *manager)
{
g_signal_emit_by_name (manager, "tool-changed", device, tool);
}
static void
meta_device_manager_native_constructed (GObject *object)
{
MetaDeviceManagerNative *manager_native = META_DEVICE_MANAGER_NATIVE (object);
g_signal_connect (manager_native->priv->main_seat, "device-added",
G_CALLBACK (on_device_added), manager_native);
g_signal_connect (manager_native->priv->main_seat, "device-added",
G_CALLBACK (on_device_removed), manager_native);
g_signal_connect (manager_native->priv->main_seat, "tool-changed",
G_CALLBACK (on_tool_changed), manager_native);
if (G_OBJECT_CLASS (meta_device_manager_native_parent_class)->constructed)
G_OBJECT_CLASS (meta_device_manager_native_parent_class)->constructed (object);
}
/*
* GObject implementation
*/
static void
meta_device_manager_native_class_init (MetaDeviceManagerNativeClass *klass)
{
ClutterDeviceManagerClass *manager_class;
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (klass);
object_class->constructed = meta_device_manager_native_constructed;
manager_class = CLUTTER_DEVICE_MANAGER_CLASS (klass);
manager_class->add_device = meta_device_manager_native_add_device;
manager_class->remove_device = meta_device_manager_native_remove_device;
manager_class->get_devices = meta_device_manager_native_get_devices;
manager_class->get_core_device = meta_device_manager_native_get_core_device;
manager_class->get_device = meta_device_manager_native_get_device;
}
static void
meta_device_manager_native_init (MetaDeviceManagerNative *self)
{
}
MetaDeviceManagerNative *
meta_device_manager_native_new (ClutterBackend *backend,
MetaSeatNative *seat)
{
MetaDeviceManagerNative *manager_native;
manager_native = g_object_new (META_TYPE_DEVICE_MANAGER_NATIVE,
"backend", backend,
NULL);
manager_native->priv->main_seat = seat;
return manager_native;
}

View File

@ -1,57 +0,0 @@
/*
* Copyright (C) 2010 Intel Corp.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Author: Damien Lespiau <damien.lespiau@intel.com>
*/
#ifndef META_DEVICE_MANAGER_NATIVE_H
#define META_DEVICE_MANAGER_NATIVE_H
#include <libinput.h>
#include <xkbcommon/xkbcommon.h>
#include "backends/native/meta-seat-native.h"
#include "clutter/clutter-mutter.h"
#define META_TYPE_DEVICE_MANAGER_NATIVE (meta_device_manager_native_get_type ())
#define META_DEVICE_MANAGER_NATIVE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_DEVICE_MANAGER_NATIVE, MetaDeviceManagerNative))
#define META_IS_DEVICE_MANAGER_NATIVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_DEVICE_MANAGER_NATIVE))
#define META_DEVICE_MANAGER_NATIVE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_DEVICE_MANAGER_NATIVE, MetaDeviceManagerNativeClass))
#define META_IS_DEVICE_MANAGER_NATIVE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_DEVICE_MANAGER_NATIVE))
#define META_DEVICE_MANAGER_NATIVE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_DEVICE_MANAGER_NATIVE, MetaDeviceManagerNativeClass))
typedef struct _MetaDeviceManagerNative MetaDeviceManagerNative;
typedef struct _MetaDeviceManagerNativeClass MetaDeviceManagerNativeClass;
typedef struct _MetaDeviceManagerNativePrivate MetaDeviceManagerNativePrivate;
struct _MetaDeviceManagerNative
{
ClutterDeviceManager parent_instance;
MetaDeviceManagerNativePrivate *priv;
};
struct _MetaDeviceManagerNativeClass
{
ClutterDeviceManagerClass parent_class;
};
GType meta_device_manager_native_get_type (void) G_GNUC_CONST;
MetaDeviceManagerNative * meta_device_manager_native_new (ClutterBackend *backend,
MetaSeatNative *seat);
#endif /* META_DEVICE_MANAGER_NATIVE_H */

View File

@ -29,7 +29,6 @@
#include "backends/meta-backend-private.h"
#include "backends/meta-renderer.h"
#include "backends/x11/meta-clutter-backend-x11.h"
#include "backends/x11/meta-device-manager-x11.h"
#include "backends/x11/meta-keymap-x11.h"
#include "backends/x11/meta-seat-x11.h"
#include "backends/x11/meta-xkb-a11y-x11.h"
@ -42,7 +41,6 @@
struct _MetaClutterBackendX11
{
ClutterBackendX11 parent;
MetaDeviceManagerX11 *device_manager;
MetaSeatX11 *core_seat;
};
@ -79,14 +77,6 @@ meta_clutter_backend_x11_create_stage (ClutterBackend *backend,
return stage;
}
static ClutterDeviceManager *
meta_clutter_backend_x11_get_device_manager (ClutterBackend *backend)
{
MetaClutterBackendX11 *backend_x11 = META_CLUTTER_BACKEND_X11 (backend);
return CLUTTER_DEVICE_MANAGER (backend_x11->device_manager);
}
static gboolean
meta_clutter_backend_x11_translate_event (ClutterBackend *backend,
gpointer native,
@ -133,13 +123,6 @@ meta_clutter_backend_x11_init_events (ClutterBackend *backend)
meta_seat_x11_new (event_base,
META_VIRTUAL_CORE_POINTER_ID,
META_VIRTUAL_CORE_KEYBOARD_ID);
g_debug ("Creating XI2 device manager");
backend_x11->device_manager =
g_object_new (META_TYPE_DEVICE_MANAGER_X11,
"backend", backend_x11,
"seat", backend_x11->core_seat,
NULL);
}
}
@ -167,7 +150,6 @@ meta_clutter_backend_x11_class_init (MetaClutterBackendX11Class *klass)
clutter_backend_class->get_renderer = meta_clutter_backend_x11_get_renderer;
clutter_backend_class->create_stage = meta_clutter_backend_x11_create_stage;
clutter_backend_class->get_device_manager = meta_clutter_backend_x11_get_device_manager;
clutter_backend_class->translate_event = meta_clutter_backend_x11_translate_event;
clutter_backend_class->init_events = meta_clutter_backend_x11_init_events;
clutter_backend_class->get_default_seat = meta_clutter_backend_x11_get_default_seat;

View File

@ -1,225 +0,0 @@
/*
* Copyright © 2011 Intel Corp.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Author: Emmanuele Bassi <ebassi@linux.intel.com>
*/
#include "config.h"
#include <stdint.h>
#include <X11/extensions/XInput2.h>
#include "backends/x11/meta-backend-x11.h"
#include "backends/x11/meta-device-manager-x11.h"
#include "backends/x11/meta-event-x11.h"
#include "backends/x11/meta-input-device-x11.h"
#include "backends/x11/meta-input-device-tool-x11.h"
#include "backends/x11/meta-keymap-x11.h"
#include "backends/x11/meta-seat-x11.h"
#include "backends/x11/meta-stage-x11.h"
#include "backends/x11/meta-virtual-input-device-x11.h"
#include "clutter/clutter-mutter.h"
#include "clutter/x11/clutter-x11.h"
#include "core/display-private.h"
#include "meta/meta-x11-errors.h"
enum
{
PROP_0,
PROP_SEAT,
PROP_LAST
};
static GParamSpec *obj_props[PROP_LAST] = { NULL, };
G_DEFINE_TYPE (MetaDeviceManagerX11,
meta_device_manager_x11,
CLUTTER_TYPE_DEVICE_MANAGER)
static void
meta_device_manager_x11_add_device (ClutterDeviceManager *manager,
ClutterInputDevice *device)
{
/* XXX implement */
}
static void
meta_device_manager_x11_remove_device (ClutterDeviceManager *manager,
ClutterInputDevice *device)
{
/* XXX implement */
}
static const GSList *
meta_device_manager_x11_get_devices (ClutterDeviceManager *manager)
{
MetaDeviceManagerX11 *manager_xi2 = META_DEVICE_MANAGER_X11 (manager);
ClutterBackend *backend = clutter_get_default_backend ();
ClutterSeat *seat = clutter_backend_get_default_seat (backend);
GSList *all_devices = NULL;
GList *l, *devices;
if (manager_xi2->all_devices != NULL)
return manager_xi2->all_devices;
all_devices = g_slist_prepend (all_devices,
clutter_seat_get_pointer (seat));
all_devices = g_slist_prepend (all_devices,
clutter_seat_get_keyboard (seat));
devices = clutter_seat_list_devices (seat, clutter_seat_get_pointer (seat));
for (l = devices; l; l = l->next)
all_devices = g_slist_prepend (all_devices, l->data);
g_list_free (devices);
devices = clutter_seat_list_devices (seat, clutter_seat_get_keyboard (seat));
for (l = devices; l; l = l->next)
all_devices = g_slist_prepend (all_devices, l->data);
g_list_free (devices);
manager_xi2->all_devices = g_slist_reverse (all_devices);
return manager_xi2->all_devices;
}
static ClutterInputDevice *
meta_device_manager_x11_get_device (ClutterDeviceManager *manager,
gint id)
{
ClutterBackend *backend = clutter_get_default_backend ();
ClutterSeat *seat = clutter_backend_get_default_seat (backend);
return meta_seat_x11_lookup_device_id (META_SEAT_X11 (seat), id);
}
static ClutterInputDevice *
meta_device_manager_x11_get_core_device (ClutterDeviceManager *manager,
ClutterInputDeviceType device_type)
{
ClutterBackend *backend = clutter_get_default_backend ();
ClutterSeat *seat = clutter_backend_get_default_seat (backend);
switch (device_type)
{
case CLUTTER_POINTER_DEVICE:
return clutter_seat_get_pointer (seat);;
case CLUTTER_KEYBOARD_DEVICE:
return clutter_seat_get_keyboard (seat);;
default:
break;
}
return NULL;
}
static void
on_device_added (ClutterSeat *seat,
ClutterInputDevice *parent,
ClutterInputDevice *device,
ClutterDeviceManager *manager)
{
g_signal_emit_by_name (manager, "device-added", device);
}
static void
on_device_removed (ClutterSeat *seat,
ClutterInputDevice *parent,
ClutterInputDevice *device,
ClutterDeviceManager *manager)
{
g_signal_emit_by_name (manager, "device-removed", device);
}
static void
on_tool_changed (ClutterSeat *seat,
ClutterInputDevice *device,
ClutterInputDeviceTool *tool,
ClutterDeviceManager *manager)
{
g_signal_emit_by_name (manager, "tool-changed", device, tool);
}
static void
meta_device_manager_x11_constructed (GObject *object)
{
MetaDeviceManagerX11 *manager_xi2 = META_DEVICE_MANAGER_X11 (object);
g_signal_connect (manager_xi2->seat, "device-added",
G_CALLBACK (on_device_added), manager_xi2);
g_signal_connect (manager_xi2->seat, "device-added",
G_CALLBACK (on_device_removed), manager_xi2);
g_signal_connect (manager_xi2->seat, "tool-changed",
G_CALLBACK (on_tool_changed), manager_xi2);
if (G_OBJECT_CLASS (meta_device_manager_x11_parent_class)->constructed)
G_OBJECT_CLASS (meta_device_manager_x11_parent_class)->constructed (object);
}
static void
meta_device_manager_x11_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
MetaDeviceManagerX11 *manager_xi2 = META_DEVICE_MANAGER_X11 (object);
switch (prop_id)
{
case PROP_SEAT:
manager_xi2->seat = g_value_get_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
meta_device_manager_x11_class_init (MetaDeviceManagerX11Class *klass)
{
ClutterDeviceManagerClass *manager_class;
GObjectClass *gobject_class;
obj_props[PROP_SEAT] =
g_param_spec_object ("seat",
"Seat",
"Seat",
CLUTTER_TYPE_SEAT,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->constructed = meta_device_manager_x11_constructed;
gobject_class->set_property = meta_device_manager_x11_set_property;
g_object_class_install_properties (gobject_class, PROP_LAST, obj_props);
manager_class = CLUTTER_DEVICE_MANAGER_CLASS (klass);
manager_class->add_device = meta_device_manager_x11_add_device;
manager_class->remove_device = meta_device_manager_x11_remove_device;
manager_class->get_devices = meta_device_manager_x11_get_devices;
manager_class->get_core_device = meta_device_manager_x11_get_core_device;
manager_class->get_device = meta_device_manager_x11_get_device;
}
static void
meta_device_manager_x11_init (MetaDeviceManagerX11 *self)
{
}

View File

@ -1,49 +0,0 @@
/*
* Copyright © 2011 Intel Corp.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Author: Emmanuele Bassi <ebassi@linux.intel.com>
*/
#ifndef META_DEVICE_MANAGER_X11_H
#define META_DEVICE_MANAGER_X11_H
#include <clutter/clutter.h>
#ifdef HAVE_LIBWACOM
#include <libwacom/libwacom.h>
#endif
G_BEGIN_DECLS
#define META_TYPE_DEVICE_MANAGER_X11 (meta_device_manager_x11_get_type ())
G_DECLARE_FINAL_TYPE (MetaDeviceManagerX11, meta_device_manager_x11,
META, DEVICE_MANAGER_X11, ClutterDeviceManager)
struct _MetaDeviceManagerX11
{
ClutterDeviceManager parent_instance;
GSList *all_devices;
ClutterSeat *seat;
};
gboolean meta_device_manager_x11_translate_event (MetaDeviceManagerX11 *manager_xi2,
XEvent *xevent,
ClutterEvent *event);
G_END_DECLS
#endif /* META_DEVICE_MANAGER_X11_H */