mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
clutter: Add ClutterSeat object
This object will take most responsibilities away from ClutterDeviceManager, with the peculiarity that it'll express the per-seat device tree. https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
This commit is contained in:
parent
88fb003cdc
commit
467e94f858
@ -25,6 +25,7 @@
|
||||
#include <clutter/clutter-backend.h>
|
||||
#include <clutter/clutter-device-manager.h>
|
||||
#include <clutter/clutter-keymap.h>
|
||||
#include <clutter/clutter-seat.h>
|
||||
#include <clutter/clutter-stage-window.h>
|
||||
|
||||
#define CLUTTER_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_BACKEND, ClutterBackendClass))
|
||||
@ -101,6 +102,8 @@ struct _ClutterBackendClass
|
||||
|
||||
ClutterKeymap * (* get_keymap) (ClutterBackend *backend);
|
||||
|
||||
ClutterSeat * (* get_default_seat) (ClutterBackend *backend);
|
||||
|
||||
/* signals */
|
||||
void (* resolution_changed) (ClutterBackend *backend);
|
||||
void (* font_changed) (ClutterBackend *backend);
|
||||
|
@ -1078,3 +1078,19 @@ clutter_backend_get_stage_window (ClutterBackend *backend)
|
||||
{
|
||||
return backend->stage_window;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_backend_get_default_seat:
|
||||
* @backend: the #ClutterBackend
|
||||
*
|
||||
* Returns the default seat
|
||||
*
|
||||
* Returns: (transfer none): the default seat
|
||||
**/
|
||||
ClutterSeat *
|
||||
clutter_backend_get_default_seat (ClutterBackend *backend)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), NULL);
|
||||
|
||||
return CLUTTER_BACKEND_GET_CLASS (backend)->get_default_seat (backend);
|
||||
}
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <clutter/clutter-config.h>
|
||||
#include <clutter/clutter-keymap.h>
|
||||
#include <clutter/clutter-types.h>
|
||||
#include <clutter/clutter-seat.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -84,6 +85,9 @@ void clutter_backend_set_input_method (Clutter
|
||||
CLUTTER_EXPORT
|
||||
ClutterKeymap * clutter_backend_get_keymap (ClutterBackend *backend);
|
||||
|
||||
CLUTTER_EXPORT
|
||||
ClutterSeat * clutter_backend_get_default_seat (ClutterBackend *backend);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __CLUTTER_BACKEND_H__ */
|
||||
|
@ -98,6 +98,7 @@ struct _ClutterInputDevice
|
||||
gchar *device_name;
|
||||
|
||||
ClutterDeviceManager *device_manager;
|
||||
ClutterSeat *seat;
|
||||
|
||||
ClutterBackend *backend;
|
||||
|
||||
|
@ -58,6 +58,7 @@ enum
|
||||
|
||||
PROP_DEVICE_TYPE,
|
||||
PROP_DEVICE_MANAGER,
|
||||
PROP_SEAT,
|
||||
PROP_DEVICE_MODE,
|
||||
|
||||
PROP_HAS_CURSOR,
|
||||
@ -174,6 +175,10 @@ clutter_input_device_set_property (GObject *gobject,
|
||||
self->device_manager = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
case PROP_SEAT:
|
||||
self->seat = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
case PROP_DEVICE_MODE:
|
||||
self->device_mode = g_value_get_enum (value);
|
||||
break;
|
||||
@ -250,6 +255,10 @@ clutter_input_device_get_property (GObject *gobject,
|
||||
g_value_set_object (value, self->device_manager);
|
||||
break;
|
||||
|
||||
case PROP_SEAT:
|
||||
g_value_set_object (value, self->seat);
|
||||
break;
|
||||
|
||||
case PROP_DEVICE_MODE:
|
||||
g_value_set_enum (value, self->device_mode);
|
||||
break;
|
||||
@ -374,6 +383,18 @@ clutter_input_device_class_init (ClutterInputDeviceClass *klass)
|
||||
CLUTTER_TYPE_DEVICE_MANAGER,
|
||||
CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
|
||||
/**
|
||||
* ClutterInputDevice:seat:
|
||||
*
|
||||
* The #ClutterSeat instance which owns the device
|
||||
*/
|
||||
obj_props[PROP_SEAT] =
|
||||
g_param_spec_object ("seat",
|
||||
P_("Seat"),
|
||||
P_("Seat"),
|
||||
CLUTTER_TYPE_SEAT,
|
||||
CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
|
||||
/**
|
||||
* ClutterInputDevice:mode:
|
||||
*
|
||||
@ -1224,11 +1245,11 @@ clutter_input_device_get_device_mode (ClutterInputDevice *device)
|
||||
*
|
||||
* translate_native_event_to_clutter (native_event, &c_event);
|
||||
*
|
||||
* // get the device manager
|
||||
* manager = clutter_device_manager_get_default ();
|
||||
* // get the seat
|
||||
* seat = clutter_backend_get_deafult_seat (clutter_get_default_backend ());
|
||||
*
|
||||
* // use the default Core Pointer that Clutter backends register by default
|
||||
* device = clutter_device_manager_get_core_device (manager, %CLUTTER_POINTER_DEVICE);
|
||||
* device = clutter_seat_get_pointer (seat);
|
||||
*
|
||||
* // update the state of the input device
|
||||
* clutter_input_device_update_from_event (device, &c_event, FALSE);
|
||||
@ -2441,3 +2462,19 @@ clutter_input_device_is_grouped (ClutterInputDevice *device,
|
||||
|
||||
return CLUTTER_INPUT_DEVICE_GET_CLASS (device)->is_grouped (device, other_device);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_input_device_get_seat:
|
||||
* @device: a #ClutterInputDevice
|
||||
*
|
||||
* Returns the seat the device belongs to
|
||||
*
|
||||
* Returns: (transfer none): the device seat
|
||||
**/
|
||||
ClutterSeat *
|
||||
clutter_input_device_get_seat (ClutterInputDevice *device)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL);
|
||||
|
||||
return device->seat;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
#endif
|
||||
|
||||
#include <clutter/clutter-types.h>
|
||||
#include <clutter/clutter-seat.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -171,6 +172,8 @@ void clutter_input_device_set_mapping_mode (ClutterInputDev
|
||||
CLUTTER_EXPORT
|
||||
gboolean clutter_input_device_is_grouped (ClutterInputDevice *device,
|
||||
ClutterInputDevice *other_device);
|
||||
CLUTTER_EXPORT
|
||||
ClutterSeat * clutter_input_device_get_seat (ClutterInputDevice *device);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
210
clutter/clutter/clutter-seat.c
Normal file
210
clutter/clutter/clutter-seat.c
Normal file
@ -0,0 +1,210 @@
|
||||
/*
|
||||
* Clutter.
|
||||
*
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Copyright (C) 2019 Red Hat Inc.
|
||||
*
|
||||
* 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: Carlos Garnacho <carlosg@gnome.org>
|
||||
*/
|
||||
|
||||
#include "clutter-build-config.h"
|
||||
|
||||
#include "clutter-backend-private.h"
|
||||
#include "clutter-input-device-tool.h"
|
||||
#include "clutter-marshal.h"
|
||||
#include "clutter-private.h"
|
||||
#include "clutter-seat.h"
|
||||
|
||||
enum
|
||||
{
|
||||
DEVICE_ADDED,
|
||||
DEVICE_REMOVED,
|
||||
TOOL_CHANGED,
|
||||
N_SIGNALS,
|
||||
};
|
||||
|
||||
static guint signals[N_SIGNALS] = { 0 };
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_BACKEND,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
static GParamSpec *props[N_PROPS];
|
||||
|
||||
typedef struct _ClutterSeatPrivate ClutterSeatPrivate;
|
||||
|
||||
struct _ClutterSeatPrivate
|
||||
{
|
||||
ClutterBackend *backend;
|
||||
};
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (ClutterSeat, clutter_seat, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
clutter_seat_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ClutterSeat *seat = CLUTTER_SEAT (object);
|
||||
ClutterSeatPrivate *priv = clutter_seat_get_instance_private (seat);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_BACKEND:
|
||||
priv->backend = g_value_get_object (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_seat_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ClutterSeat *seat = CLUTTER_SEAT (object);
|
||||
ClutterSeatPrivate *priv = clutter_seat_get_instance_private (seat);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_BACKEND:
|
||||
g_value_set_object (value, priv->backend);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_seat_finalize (GObject *object)
|
||||
{
|
||||
ClutterSeat *seat = CLUTTER_SEAT (object);
|
||||
ClutterSeatPrivate *priv = clutter_seat_get_instance_private (seat);
|
||||
|
||||
g_clear_object (&priv->backend);
|
||||
|
||||
G_OBJECT_CLASS (clutter_seat_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_seat_class_init (ClutterSeatClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->set_property = clutter_seat_set_property;
|
||||
object_class->get_property = clutter_seat_get_property;
|
||||
object_class->finalize = clutter_seat_finalize;
|
||||
|
||||
signals[DEVICE_ADDED] =
|
||||
g_signal_new (I_("device-added"),
|
||||
G_TYPE_FROM_CLASS (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0, NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 1,
|
||||
CLUTTER_TYPE_INPUT_DEVICE);
|
||||
|
||||
signals[DEVICE_REMOVED] =
|
||||
g_signal_new (I_("device-removed"),
|
||||
G_TYPE_FROM_CLASS (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0, NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 1,
|
||||
CLUTTER_TYPE_INPUT_DEVICE);
|
||||
signals[TOOL_CHANGED] =
|
||||
g_signal_new (I_("tool-changed"),
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0, NULL, NULL,
|
||||
_clutter_marshal_VOID__OBJECT_OBJECT,
|
||||
G_TYPE_NONE, 2,
|
||||
CLUTTER_TYPE_INPUT_DEVICE,
|
||||
CLUTTER_TYPE_INPUT_DEVICE_TOOL);
|
||||
g_signal_set_va_marshaller (signals[TOOL_CHANGED],
|
||||
G_TYPE_FROM_CLASS (object_class),
|
||||
_clutter_marshal_VOID__OBJECT_OBJECTv);
|
||||
|
||||
props[PROP_BACKEND] =
|
||||
g_param_spec_object ("backend",
|
||||
P_("Backend"),
|
||||
P_("Backend"),
|
||||
CLUTTER_TYPE_BACKEND,
|
||||
CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, props);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_seat_init (ClutterSeat *seat)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_seat_get_pointer:
|
||||
* @seat: a #ClutterSeat
|
||||
*
|
||||
* Returns the master pointer
|
||||
*
|
||||
* Returns: (transfer none): the master pointer
|
||||
**/
|
||||
ClutterInputDevice *
|
||||
clutter_seat_get_pointer (ClutterSeat *seat)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_SEAT (seat), NULL);
|
||||
|
||||
return CLUTTER_SEAT_GET_CLASS (seat)->get_pointer (seat);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_seat_get_keyboard:
|
||||
* @seat: a #ClutterSeat
|
||||
*
|
||||
* Returns the master keyboard
|
||||
*
|
||||
* Returns: (transfer none): the master keyboard
|
||||
**/
|
||||
ClutterInputDevice *
|
||||
clutter_seat_get_keyboard (ClutterSeat *seat)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_SEAT (seat), NULL);
|
||||
|
||||
return CLUTTER_SEAT_GET_CLASS (seat)->get_keyboard (seat);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_seat_list_devices:
|
||||
* @seat: a #ClutterSeat
|
||||
*
|
||||
* Returns the list of HW devices
|
||||
*
|
||||
* Returns: (transfer container) (element-type Clutter.InputDevice): A list
|
||||
* of #ClutterInputDevice. The elements of the returned list are owned by
|
||||
* Clutter and may not be freed, the returned list should be freed using
|
||||
* g_list_free() when done.
|
||||
**/
|
||||
GList *
|
||||
clutter_seat_list_devices (ClutterSeat *seat)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_SEAT (seat), NULL);
|
||||
|
||||
return CLUTTER_SEAT_GET_CLASS (seat)->list_devices (seat);
|
||||
}
|
57
clutter/clutter/clutter-seat.h
Normal file
57
clutter/clutter/clutter-seat.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Clutter.
|
||||
*
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Copyright (C) 2019 Red Hat Inc.
|
||||
*
|
||||
* 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: Carlos Garnacho <carlosg@gnome.org>
|
||||
*/
|
||||
#ifndef CLUTTER_SEAT_H
|
||||
#define CLUTTER_SEAT_H
|
||||
|
||||
#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
||||
#error "Only <clutter/clutter.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include "clutter/clutter-types.h"
|
||||
|
||||
#define CLUTTER_TYPE_SEAT (clutter_seat_get_type ())
|
||||
|
||||
CLUTTER_EXPORT
|
||||
G_DECLARE_DERIVABLE_TYPE (ClutterSeat, clutter_seat,
|
||||
CLUTTER, SEAT, GObject)
|
||||
|
||||
typedef struct _ClutterSeatClass ClutterSeatClass;
|
||||
|
||||
struct _ClutterSeatClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
ClutterInputDevice * (* get_pointer) (ClutterSeat *seat);
|
||||
ClutterInputDevice * (* get_keyboard) (ClutterSeat *seat);
|
||||
|
||||
GList * (* list_devices) (ClutterSeat *seat);
|
||||
};
|
||||
|
||||
CLUTTER_EXPORT
|
||||
ClutterInputDevice * clutter_seat_get_pointer (ClutterSeat *seat);
|
||||
CLUTTER_EXPORT
|
||||
ClutterInputDevice * clutter_seat_get_keyboard (ClutterSeat *seat);
|
||||
CLUTTER_EXPORT
|
||||
GList * clutter_seat_list_devices (ClutterSeat *seat);
|
||||
|
||||
#endif /* CLUTTER_SEAT_H */
|
@ -70,6 +70,7 @@ clutter_headers = [
|
||||
'clutter-script.h',
|
||||
'clutter-scriptable.h',
|
||||
'clutter-scroll-actor.h',
|
||||
'clutter-seat.h',
|
||||
'clutter-settings.h',
|
||||
'clutter-shader-effect.h',
|
||||
'clutter-shader-types.h',
|
||||
@ -161,6 +162,7 @@ clutter_sources = [
|
||||
'clutter-script-parser.c',
|
||||
'clutter-scriptable.c',
|
||||
'clutter-scroll-actor.c',
|
||||
'clutter-seat.c',
|
||||
'clutter-settings.c',
|
||||
'clutter-shader-effect.c',
|
||||
'clutter-shader-types.c',
|
||||
|
Loading…
Reference in New Issue
Block a user