Compare commits

...

26 Commits

Author SHA1 Message Date
Carlos Garnacho
1c31fe8e65 backends: Move warp_pointer() to ClutterSeat
The onscreen pointer sprite is a per-seat element, so it makes sense
to move pointer warping over there too.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2019-11-22 22:26:24 +01:00
Carlos Garnacho
819ea8c0a6 backends: Set pointer constrain/relative motion hooks before backend init
The backend being initialized triggers a pointer warp (and motion event)
where we want to observe the callbacks put in place. So ensure we set
up the hooks before that could happen.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2019-11-22 22:26:24 +01:00
Carlos Garnacho
f0241114f6 backends: Use latest pointer position if no pointer constrain exists
The meta_seat_native_constrain_pointer() function receives the current
pointer position, and the new pointer position as in/out parameters.
We were however calculating the new coordinates based on the last pointer
position if there was no pointer constrain in place.

Fortunately to us, this didn't use to happen often/ever, as a pointer
constrain function is set on MetaBackend initialization. This behavior
did also exist previously in MetaDeviceManagerNative.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2019-11-22 22:26:24 +01:00
Carlos Garnacho
987cd7e821 backends: Drop get_relative_motion_deltas() vfunc
Just go ATM through backend checks, and looking up directly the
native event data, pretty much like the rest of the places do that...
Eventually would be nice to have this information in ClutterEvent,
but let's not have it clutter the MetaBackend class.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2019-11-22 22:26:24 +01:00
Carlos Garnacho
a4a7f9a660 backends: Do not use device IDs on idle monitors
Device IDs are somewhat x11 specific, seems better to avoid those
on public API. We can rely everywhere on ClutterInputDevice, so use
it instead.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2019-11-22 22:26:24 +01:00
Carlos Garnacho
993b0b2758 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
2019-11-22 22:26:24 +01:00
Carlos Garnacho
9bddda584b tests: Replace ClutterDeviceManager usage in favor of ClutterSeat
https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2019-11-22 22:26:24 +01:00
Carlos Garnacho
81b0802eab backends: Replace ClutterDeviceManager usage in favor of ClutterSeat
https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2019-11-22 22:26:24 +01:00
Carlos Garnacho
5de6d032d6 clutter: Replace ClutterDeviceManager usage in favor of ClutterSeat
https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2019-11-22 22:26:24 +01:00
Carlos Garnacho
a4d39bdabc 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
2019-11-22 22:24:07 +01:00
Carlos Garnacho
4e12be36d1 backends: Move native keymap manipulation functions to MetaSeatNative
Since the ClutterKeymap is obtained through the ClutterSeat, it makes
sense to have these manipulation functions in the ClutterSeat impl.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2019-11-22 22:24:07 +01:00
Carlos Garnacho
1c70f6894f core: Replace ClutterDeviceManager usage in favor of ClutterSeat
https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2019-11-22 22:24:07 +01:00
Carlos Garnacho
ef2acde122 wayland: Replace ClutterDeviceManager usage in favor of ClutterSeat
https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2019-11-22 22:24:07 +01:00
Carlos Garnacho
a8c6fab3b8 clutter: Drop select_stage_events() device manager vfunc
This is specific to X11, so handle it within the X11 backend.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2019-11-22 22:24:07 +01:00
Carlos Garnacho
b8c8b59dc8 clutter: Move motion compression handling to ClutterSeat
Another responsibility taken away from ClutterDeviceManager

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2019-11-22 22:24:07 +01:00
Carlos Garnacho
efe698f6e1 clutter: Move virtual device management to ClutterSeat
A11y in general may be considered a per-seat feature.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2019-11-22 22:24:07 +01:00
Carlos Garnacho
75ad578a7d clutter: Move pointer a11y from ClutterDeviceManager to ClutterSeat
A11y in general may be considered a per-seat feature.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2019-11-22 22:24:07 +01:00
Carlos Garnacho
77d0ec12b1 clutter: Move keyboard a11y from ClutterDeviceManager to ClutterSeat
A11y in general may be considered a per-seat feature.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2019-11-22 22:24:07 +01:00
Carlos Garnacho
11f3db6693 clutter: Move platform event data management to ClutterSeat
https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2019-11-22 22:24:07 +01:00
Carlos Garnacho
c5b89d9a86 clutter: Move keymap from ClutterBackend to ClutterSeat
Keymaps are a per-seat feature, so move it there.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2019-11-22 22:24:07 +01:00
Carlos Garnacho
ed4c96c751 clutter: Move bell_notify() from ClutterBackend to ClutterSeat
Bells can be considered to be a per-seat feature, so move it there.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2019-11-22 22:24:07 +01:00
Carlos Garnacho
2001bdd863 clutter: Move keymap direction from ClutterBackend to ClutterKeymap
This makes more sense to have in the ClutterKeymap, since we have it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2019-11-22 22:24:07 +01:00
Carlos Garnacho
9577475453 native: Implement ClutterSeat
We had the MetaSeatNative struct around, so use it as the base of
this Clutter object. A few responsibilities were drawn from
ClutterDeviceManager.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2019-11-22 22:24:07 +01:00
Carlos Garnacho
ea099a871c x11: Implement ClutterSeat
The ClutterDeviceManager signaling becomes implemented on top of this.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2019-11-22 22:24:07 +01:00
Carlos Garnacho
454e104d6f 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
2019-11-22 22:24:07 +01:00
Carlos Garnacho
127df62a02 x11: Drop subscription for input event from floating devices
This is unlikely to happen, and unlikely to be right (eg. we don't translate
input event coordinates, since those are not in display coordinate space, we
don't offer any feedback for those either).

This can simply be dropped, we listen to XIAllMasterDevices, which suffices
for what we want to do.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2019-11-22 22:24:07 +01:00
81 changed files with 5041 additions and 5825 deletions

View File

@ -23,8 +23,7 @@
#define __CLUTTER_BACKEND_PRIVATE_H__
#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))
@ -47,8 +46,6 @@ struct _ClutterBackend
CoglOnscreen *dummy_onscreen;
ClutterDeviceManager *device_manager;
cairo_font_options_t *font_options;
gchar *font_name;
@ -59,8 +56,6 @@ struct _ClutterBackend
ClutterStageWindow *stage_window;
ClutterInputMethod *input_method;
ClutterKeymap *keymap;
};
struct _ClutterBackendClass
@ -89,17 +84,12 @@ struct _ClutterBackendClass
GError **error);
gboolean (* create_context) (ClutterBackend *backend,
GError **error);
ClutterDeviceManager *(* get_device_manager) (ClutterBackend *backend);
gboolean (* translate_event) (ClutterBackend *backend,
gpointer native,
ClutterEvent *event);
PangoDirection (* get_keymap_direction) (ClutterBackend *backend);
void (* bell_notify) (ClutterBackend *backend);
ClutterKeymap * (* get_keymap) (ClutterBackend *backend);
ClutterSeat * (* get_default_seat) (ClutterBackend *backend);
/* signals */
void (* resolution_changed) (ClutterBackend *backend);
@ -139,8 +129,6 @@ gfloat _clutter_backend_get_units_per_em (Clutter
PangoFontDescription *font_desc);
gint32 _clutter_backend_get_units_serial (ClutterBackend *backend);
PangoDirection _clutter_backend_get_keymap_direction (ClutterBackend *backend);
CLUTTER_EXPORT
void _clutter_backend_reset_cogl_framebuffer (ClutterBackend *backend);

View File

@ -51,7 +51,6 @@
#include "clutter-stage-manager-private.h"
#include "clutter-stage-private.h"
#include "clutter-stage-window.h"
#include "clutter-device-manager-private.h"
#ifdef CLUTTER_HAS_WAYLAND_COMPOSITOR_SUPPORT
#include "wayland/clutter-wayland-compositor.h"
@ -528,30 +527,6 @@ clutter_backend_real_init_events (ClutterBackend *backend)
g_error ("Unknown input backend");
}
static ClutterDeviceManager *
clutter_backend_real_get_device_manager (ClutterBackend *backend)
{
if (G_UNLIKELY (backend->device_manager == NULL))
{
g_critical ("No device manager available, expect broken input");
return NULL;
}
return backend->device_manager;
}
static ClutterKeymap *
clutter_backend_real_get_keymap (ClutterBackend *backend)
{
if (G_UNLIKELY (backend->keymap == NULL))
{
g_critical ("No keymap available, expect broken keyboard input");
return NULL;
}
return backend->keymap;
}
static void
clutter_backend_class_init (ClutterBackendClass *klass)
{
@ -615,10 +590,8 @@ clutter_backend_class_init (ClutterBackendClass *klass)
klass->font_changed = clutter_backend_real_font_changed;
klass->init_events = clutter_backend_real_init_events;
klass->get_device_manager = clutter_backend_real_get_device_manager;
klass->create_context = clutter_backend_real_create_context;
klass->get_features = clutter_backend_real_get_features;
klass->get_keymap = clutter_backend_real_get_keymap;
}
static void
@ -783,24 +756,24 @@ _clutter_backend_copy_event_data (ClutterBackend *backend,
const ClutterEvent *src,
ClutterEvent *dest)
{
ClutterDeviceManagerClass *device_manager_class;
ClutterDeviceManager *device_manager;
ClutterSeatClass *seat_class;
ClutterSeat *seat;
device_manager = clutter_device_manager_get_default ();
device_manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
device_manager_class->copy_event_data (device_manager, src, dest);
seat = clutter_backend_get_default_seat (backend);
seat_class = CLUTTER_SEAT_GET_CLASS (seat);
seat_class->copy_event_data (seat, src, dest);
}
void
_clutter_backend_free_event_data (ClutterBackend *backend,
ClutterEvent *event)
{
ClutterDeviceManagerClass *device_manager_class;
ClutterDeviceManager *device_manager;
ClutterSeatClass *seat_class;
ClutterSeat *seat;
device_manager = clutter_device_manager_get_default ();
device_manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
device_manager_class->free_event_data (device_manager, event);
seat = clutter_backend_get_default_seat (backend);
seat_class = CLUTTER_SEAT_GET_CLASS (seat);
seat_class->free_event_data (seat, event);
}
/**
@ -997,18 +970,6 @@ clutter_wayland_set_compositor_display (void *display)
}
#endif
PangoDirection
_clutter_backend_get_keymap_direction (ClutterBackend *backend)
{
ClutterBackendClass *klass;
klass = CLUTTER_BACKEND_GET_CLASS (backend);
if (klass->get_keymap_direction != NULL)
return klass->get_keymap_direction (backend);
return PANGO_DIRECTION_NEUTRAL;
}
void
_clutter_backend_reset_cogl_framebuffer (ClutterBackend *backend)
{
@ -1042,16 +1003,6 @@ clutter_set_allowed_drivers (const char *drivers)
allowed_drivers = g_strdup (drivers);
}
void
clutter_backend_bell_notify (ClutterBackend *backend)
{
ClutterBackendClass *klass;
klass = CLUTTER_BACKEND_GET_CLASS (backend);
if (klass->bell_notify)
klass->bell_notify (backend);
}
/**
* clutter_backend_get_input_method:
* @backend: the #CLutterBackend
@ -1080,22 +1031,24 @@ clutter_backend_set_input_method (ClutterBackend *backend,
g_set_object (&backend->input_method, method);
}
/**
* clutter_backend_get_keymap:
* @backend: the #ClutterBackend
*
* Gets the keymap used by Clutter
*
* Returns: (transfer none): the keymap
**/
ClutterKeymap *
clutter_backend_get_keymap (ClutterBackend *backend)
{
return CLUTTER_BACKEND_GET_CLASS (backend)->get_keymap (backend);
}
ClutterStageWindow *
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);
}

View File

@ -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
@ -72,9 +73,6 @@ const cairo_font_options_t * clutter_backend_get_font_options (Clutter
CLUTTER_EXPORT
CoglContext * clutter_backend_get_cogl_context (ClutterBackend *backend);
CLUTTER_EXPORT
void clutter_backend_bell_notify (ClutterBackend *backend);
CLUTTER_EXPORT
ClutterInputMethod * clutter_backend_get_input_method (ClutterBackend *backend);
@ -82,7 +80,7 @@ CLUTTER_EXPORT
void clutter_backend_set_input_method (ClutterBackend *backend,
ClutterInputMethod *method);
CLUTTER_EXPORT
ClutterKeymap * clutter_backend_get_keymap (ClutterBackend *backend);
ClutterSeat * clutter_backend_get_default_seat (ClutterBackend *backend);
G_END_DECLS

View File

@ -1,306 +0,0 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2010 Intel Corporation.
*
* 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 __CLUTTER_DEVICE_MANAGER_PRIVATE_H__
#define __CLUTTER_DEVICE_MANAGER_PRIVATE_H__
#include <clutter/clutter-backend.h>
#include <clutter/clutter-device-manager.h>
#include <clutter/clutter-event.h>
G_BEGIN_DECLS
typedef struct _ClutterAxisInfo
{
ClutterInputAxis axis;
gdouble min_axis;
gdouble max_axis;
gdouble min_value;
gdouble max_value;
gdouble resolution;
} ClutterAxisInfo;
typedef struct _ClutterKeyInfo
{
guint keyval;
ClutterModifierType modifiers;
} ClutterKeyInfo;
typedef struct _ClutterScrollInfo
{
guint axis_id;
ClutterScrollDirection direction;
gdouble increment;
gdouble last_value;
guint last_value_valid : 1;
} ClutterScrollInfo;
typedef struct _ClutterTouchInfo
{
ClutterEventSequence *sequence;
ClutterActor *actor;
gfloat current_x;
gfloat current_y;
} ClutterTouchInfo;
typedef struct _ClutterPtrA11yData
{
int n_btn_pressed;
float current_x;
float current_y;
float dwell_x;
float dwell_y;
gboolean dwell_drag_started;
gboolean dwell_gesture_started;
guint dwell_timer;
guint dwell_position_timer;
guint secondary_click_timer;
gboolean secondary_click_triggered;
} ClutterPtrA11yData;
struct _ClutterInputDevice
{
GObject parent_instance;
gint id;
ClutterInputDeviceType device_type;
ClutterInputMode device_mode;
gchar *device_name;
ClutterDeviceManager *device_manager;
ClutterBackend *backend;
/* the associated device */
ClutterInputDevice *associated;
GList *slaves;
/* the actor underneath the pointer */
ClutterActor *cursor_actor;
GHashTable *inv_touch_sequence_actors;
/* the actor that has a grab in place for the device */
ClutterActor *pointer_grab_actor;
ClutterActor *keyboard_grab_actor;
GHashTable *sequence_grab_actors;
GHashTable *inv_sequence_grab_actors;
/* the current click count */
gint click_count;
/* the stage the device is on */
ClutterStage *stage;
/* the current state */
gfloat current_x;
gfloat current_y;
guint32 current_time;
gint current_button_number;
ClutterModifierType current_state;
/* the current touch points states */
GHashTable *touch_sequences_info;
/* the previous state, used for click count generation */
gint previous_x;
gint previous_y;
guint32 previous_time;
gint previous_button_number;
ClutterModifierType previous_state;
GArray *axes;
guint n_keys;
GArray *keys;
GArray *scroll_info;
gchar *vendor_id;
gchar *product_id;
gchar *node_path;
GPtrArray *tools;
gint n_rings;
gint n_strips;
gint n_mode_groups;
ClutterInputDeviceMapping mapping_mode;
guint has_cursor : 1;
guint is_enabled : 1;
/* Accessiblity */
ClutterVirtualInputDevice *accessibility_virtual_device;
ClutterPtrA11yData *ptr_a11y_data;
};
typedef void (*ClutterEmitInputDeviceEvent) (ClutterEvent *event,
ClutterInputDevice *device);
struct _ClutterInputDeviceClass
{
GObjectClass parent_class;
gboolean (* keycode_to_evdev) (ClutterInputDevice *device,
guint hardware_keycode,
guint *evdev_keycode);
void (* update_from_tool) (ClutterInputDevice *device,
ClutterInputDeviceTool *tool);
gboolean (* is_mode_switch_button) (ClutterInputDevice *device,
guint group,
guint button);
gint (* get_group_n_modes) (ClutterInputDevice *device,
gint group);
gboolean (* is_grouped) (ClutterInputDevice *device,
ClutterInputDevice *other_device);
/* Keyboard accessbility */
void (* process_kbd_a11y_event) (ClutterEvent *event,
ClutterInputDevice *device,
ClutterEmitInputDeviceEvent emit_event_func);
};
/* device manager */
CLUTTER_EXPORT
void _clutter_device_manager_add_device (ClutterDeviceManager *device_manager,
ClutterInputDevice *device);
CLUTTER_EXPORT
void _clutter_device_manager_remove_device (ClutterDeviceManager *device_manager,
ClutterInputDevice *device);
void _clutter_device_manager_update_devices (ClutterDeviceManager *device_manager);
CLUTTER_EXPORT
void _clutter_device_manager_select_stage_events (ClutterDeviceManager *device_manager,
ClutterStage *stage);
ClutterBackend *_clutter_device_manager_get_backend (ClutterDeviceManager *device_manager);
void _clutter_device_manager_compress_motion (ClutterDeviceManager *device_manger,
ClutterEvent *event,
const ClutterEvent *to_discard);
CLUTTER_EXPORT
void clutter_device_manager_ensure_a11y_state (ClutterDeviceManager *device_manager);
/* input device */
CLUTTER_EXPORT
gboolean _clutter_input_device_has_sequence (ClutterInputDevice *device,
ClutterEventSequence *sequence);
CLUTTER_EXPORT
void _clutter_input_device_add_event_sequence (ClutterInputDevice *device,
ClutterEvent *event);
CLUTTER_EXPORT
void _clutter_input_device_remove_event_sequence (ClutterInputDevice *device,
ClutterEvent *event);
CLUTTER_EXPORT
void _clutter_input_device_set_coords (ClutterInputDevice *device,
ClutterEventSequence *sequence,
gfloat x,
gfloat y,
ClutterStage *stage);
CLUTTER_EXPORT
void _clutter_input_device_set_state (ClutterInputDevice *device,
ClutterModifierType state);
CLUTTER_EXPORT
void _clutter_input_device_set_time (ClutterInputDevice *device,
guint32 time_);
CLUTTER_EXPORT
void _clutter_input_device_set_stage (ClutterInputDevice *device,
ClutterStage *stage);
CLUTTER_EXPORT
ClutterStage * _clutter_input_device_get_stage (ClutterInputDevice *device);
void _clutter_input_device_set_actor (ClutterInputDevice *device,
ClutterEventSequence *sequence,
ClutterActor *actor,
gboolean emit_crossing);
ClutterActor * _clutter_input_device_update (ClutterInputDevice *device,
ClutterEventSequence *sequence,
gboolean emit_crossing);
CLUTTER_EXPORT
void _clutter_input_device_set_n_keys (ClutterInputDevice *device,
guint n_keys);
CLUTTER_EXPORT
guint _clutter_input_device_add_axis (ClutterInputDevice *device,
ClutterInputAxis axis,
gdouble min_value,
gdouble max_value,
gdouble resolution);
CLUTTER_EXPORT
void _clutter_input_device_reset_axes (ClutterInputDevice *device);
CLUTTER_EXPORT
void _clutter_input_device_set_associated_device (ClutterInputDevice *device,
ClutterInputDevice *associated);
CLUTTER_EXPORT
void _clutter_input_device_add_slave (ClutterInputDevice *master,
ClutterInputDevice *slave);
CLUTTER_EXPORT
void _clutter_input_device_remove_slave (ClutterInputDevice *master,
ClutterInputDevice *slave);
CLUTTER_EXPORT
gboolean _clutter_input_device_translate_axis (ClutterInputDevice *device,
guint index_,
gdouble value,
gdouble *axis_value);
CLUTTER_EXPORT
void _clutter_input_device_add_scroll_info (ClutterInputDevice *device,
guint index_,
ClutterScrollDirection direction,
gdouble increment);
CLUTTER_EXPORT
void _clutter_input_device_reset_scroll_info (ClutterInputDevice *device);
CLUTTER_EXPORT
gboolean _clutter_input_device_get_scroll_delta (ClutterInputDevice *device,
guint index_,
gdouble value,
ClutterScrollDirection *direction_p,
gdouble *delta_p);
CLUTTER_EXPORT
ClutterInputDeviceTool * clutter_input_device_lookup_tool (ClutterInputDevice *device,
guint64 serial,
ClutterInputDeviceToolType type);
CLUTTER_EXPORT
void clutter_input_device_add_tool (ClutterInputDevice *device,
ClutterInputDeviceTool *tool);
CLUTTER_EXPORT
void clutter_input_device_update_from_tool (ClutterInputDevice *device,
ClutterInputDeviceTool *tool);
G_END_DECLS
#endif /* __CLUTTER_DEVICE_MANAGER_PRIVATE_H__ */

View File

@ -1,753 +0,0 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2009 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>
*/
/**
* SECTION:clutter-device-manager
* @short_description: Maintains the list of input devices
*
* #ClutterDeviceManager is a singleton object, owned by Clutter, which
* maintains the list of #ClutterInputDevice<!-- -->s.
*
* Depending on the backend used by Clutter it is possible to use the
* #ClutterDeviceManager::device-added and
* #ClutterDeviceManager::device-removed to monitor addition and removal
* of devices.
*
* #ClutterDeviceManager is available since Clutter 1.2
*/
#include "clutter-build-config.h"
#include "clutter-backend-private.h"
#include "clutter-debug.h"
#include "clutter-device-manager-private.h"
#include "clutter-enum-types.h"
#include "clutter-marshal.h"
#include "clutter-private.h"
#include "clutter-stage-private.h"
#include "clutter-virtual-input-device.h"
#include "clutter-input-device-tool.h"
#include "clutter-input-pointer-a11y-private.h"
struct _ClutterDeviceManagerPrivate
{
/* back-pointer to the backend */
ClutterBackend *backend;
/* Keyboard a11y */
ClutterKbdA11ySettings kbd_a11y_settings;
/* Pointer a11y */
ClutterPointerA11ySettings pointer_a11y_settings;
};
enum
{
PROP_0,
PROP_BACKEND,
PROP_LAST
};
static GParamSpec *obj_props[PROP_LAST];
enum
{
DEVICE_ADDED,
DEVICE_REMOVED,
TOOL_CHANGED,
KBD_A11Y_MASK_CHANGED,
KBD_A11Y_FLAGS_CHANGED,
PTR_A11Y_DWELL_CLICK_TYPE_CHANGED,
PTR_A11Y_TIMEOUT_STARTED,
PTR_A11Y_TIMEOUT_STOPPED,
LAST_SIGNAL
};
static guint manager_signals[LAST_SIGNAL] = { 0, };
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (ClutterDeviceManager,
clutter_device_manager,
G_TYPE_OBJECT)
static void
clutter_device_manager_set_property (GObject *gobject,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
ClutterDeviceManager *self = CLUTTER_DEVICE_MANAGER (gobject);
ClutterDeviceManagerPrivate *priv = clutter_device_manager_get_instance_private (self);
switch (prop_id)
{
case PROP_BACKEND:
priv->backend = g_value_get_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
}
}
static void
clutter_device_manager_get_property (GObject *gobject,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
ClutterDeviceManager *self = CLUTTER_DEVICE_MANAGER (gobject);
ClutterDeviceManagerPrivate *priv = clutter_device_manager_get_instance_private (self);
switch (prop_id)
{
case PROP_BACKEND:
g_value_set_object (value, priv->backend);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
}
}
static void
clutter_device_manager_class_init (ClutterDeviceManagerClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
obj_props[PROP_BACKEND] =
g_param_spec_object ("backend",
P_("Backend"),
P_("The ClutterBackend of the device manager"),
CLUTTER_TYPE_BACKEND,
CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
gobject_class->set_property = clutter_device_manager_set_property;
gobject_class->get_property = clutter_device_manager_get_property;
g_object_class_install_properties (gobject_class,
PROP_LAST,
obj_props);
/**
* ClutterDeviceManager::device-added:
* @manager: the #ClutterDeviceManager that emitted the signal
* @device: the newly added #ClutterInputDevice
*
* The ::device-added signal is emitted each time a device has been
* added to the #ClutterDeviceManager
*
* Since: 1.2
*/
manager_signals[DEVICE_ADDED] =
g_signal_new (I_("device-added"),
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 1,
CLUTTER_TYPE_INPUT_DEVICE);
/**
* ClutterDeviceManager::device-removed:
* @manager: the #ClutterDeviceManager that emitted the signal
* @device: the removed #ClutterInputDevice
*
* The ::device-removed signal is emitted each time a device has been
* removed from the #ClutterDeviceManager
*
* Since: 1.2
*/
manager_signals[DEVICE_REMOVED] =
g_signal_new (I_("device-removed"),
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 1,
CLUTTER_TYPE_INPUT_DEVICE);
manager_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);
/**
* ClutterDeviceManager::kbd-a11y-mods-state-changed:
* @manager: the #ClutterDeviceManager that emitted the signal
* @latched_mask: the latched modifier mask from stickykeys
* @locked_mask: the locked modifier mask from stickykeys
*
* The ::kbd-a11y-mods-state-changed signal is emitted each time either the
* latched modifiers mask or locked modifiers mask are changed as the
* result of keyboard accessibilty's sticky keys operations.
*/
manager_signals[KBD_A11Y_MASK_CHANGED] =
g_signal_new (I_("kbd-a11y-mods-state-changed"),
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
_clutter_marshal_VOID__UINT_UINT,
G_TYPE_NONE, 2,
G_TYPE_UINT,
G_TYPE_UINT);
/**
* ClutterDeviceManager::kbd-a11y-flags-changed:
* @manager: the #ClutterDeviceManager that emitted the signal
* @settings_flags: the new ClutterKeyboardA11yFlags configuration
* @changed_mask: the ClutterKeyboardA11yFlags changed
*
* The ::kbd-a11y-flags-changed signal is emitted each time the
* ClutterKeyboardA11yFlags configuration is changed as the result of
* keyboard accessibilty operations.
*/
manager_signals[KBD_A11Y_FLAGS_CHANGED] =
g_signal_new (I_("kbd-a11y-flags-changed"),
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
_clutter_marshal_VOID__UINT_UINT,
G_TYPE_NONE, 2,
G_TYPE_UINT,
G_TYPE_UINT);
/**
* ClutterDeviceManager::ptr-a11y-dwell-click-type-changed:
* @manager: the #ClutterDeviceManager that emitted the signal
* @click_type: the new #ClutterPointerA11yDwellClickType mode
*
* The ::ptr-a11y-dwell-click-type-changed signal is emitted each time
* the ClutterPointerA11yDwellClickType mode is changed as the result
* of pointer accessibility operations.
*/
manager_signals[PTR_A11Y_DWELL_CLICK_TYPE_CHANGED] =
g_signal_new (I_("ptr-a11y-dwell-click-type-changed"),
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
g_cclosure_marshal_VOID__FLAGS,
G_TYPE_NONE, 1,
CLUTTER_TYPE_POINTER_A11Y_DWELL_CLICK_TYPE);
/**
* ClutterDeviceManager::ptr-a11y-timeout-started:
* @manager: the #ClutterDeviceManager that emitted the signal
* @device: the core pointer #ClutterInputDevice
* @timeout_type: the type of timeout #ClutterPointerA11yTimeoutType
* @delay: the delay in ms before secondary-click is triggered.
*
* The ::ptr-a11y-timeout-started signal is emitted when a
* pointer accessibility timeout delay is started, so that upper
* layers can notify the user with some visual feedback.
*/
manager_signals[PTR_A11Y_TIMEOUT_STARTED] =
g_signal_new (I_("ptr-a11y-timeout-started"),
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
_clutter_marshal_VOID__OBJECT_FLAGS_UINT,
G_TYPE_NONE, 3,
CLUTTER_TYPE_INPUT_DEVICE,
CLUTTER_TYPE_POINTER_A11Y_TIMEOUT_TYPE,
G_TYPE_UINT);
/**
* ClutterDeviceManager::ptr-a11y-timeout-stopped:
* @manager: the #ClutterDeviceManager that emitted the signal
* @device: the core pointer #ClutterInputDevice
* @timeout_type: the type of timeout #ClutterPointerA11yTimeoutType
* @clicked: %TRUE if the timeout finished and triggered a click
*
* The ::ptr-a11y-timeout-stopped signal is emitted when a running
* pointer accessibility timeout delay is stopped, either because
* it's triggered at the end of the delay or cancelled, so that
* upper layers can notify the user with some visual feedback.
*/
manager_signals[PTR_A11Y_TIMEOUT_STOPPED] =
g_signal_new (I_("ptr-a11y-timeout-stopped"),
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
_clutter_marshal_VOID__OBJECT_FLAGS_BOOLEAN,
G_TYPE_NONE, 3,
CLUTTER_TYPE_INPUT_DEVICE,
CLUTTER_TYPE_POINTER_A11Y_TIMEOUT_TYPE,
G_TYPE_BOOLEAN);
}
static void
clutter_device_manager_init (ClutterDeviceManager *self)
{
}
/**
* clutter_device_manager_get_default:
*
* Retrieves the device manager singleton
*
* Return value: (transfer none): the #ClutterDeviceManager singleton.
* The returned instance is owned by Clutter and it should not be
* modified or freed
*
* Since: 1.2
*/
ClutterDeviceManager *
clutter_device_manager_get_default (void)
{
ClutterBackend *backend = clutter_get_default_backend ();
return CLUTTER_BACKEND_GET_CLASS (backend)->get_device_manager (backend);
}
/**
* clutter_device_manager_list_devices:
* @device_manager: a #ClutterDeviceManager
*
* Lists all currently registered input devices
*
* Return value: (transfer container) (element-type Clutter.InputDevice):
* a newly allocated list of #ClutterInputDevice objects. Use
* g_slist_free() to deallocate it when done
*
* Since: 1.2
*/
GSList *
clutter_device_manager_list_devices (ClutterDeviceManager *device_manager)
{
const GSList *devices;
g_return_val_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager), NULL);
devices = clutter_device_manager_peek_devices (device_manager);
return g_slist_copy ((GSList *) devices);
}
/**
* clutter_device_manager_peek_devices:
* @device_manager: a #ClutterDeviceManager
*
* Lists all currently registered input devices
*
* Return value: (transfer none) (element-type Clutter.InputDevice):
* a pointer to the internal list of #ClutterInputDevice objects. The
* returned list is owned by the #ClutterDeviceManager and should never
* be modified or freed
*
* Since: 1.2
*/
const GSList *
clutter_device_manager_peek_devices (ClutterDeviceManager *device_manager)
{
ClutterDeviceManagerClass *manager_class;
g_return_val_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager), NULL);
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
return manager_class->get_devices (device_manager);
}
/**
* clutter_device_manager_get_device:
* @device_manager: a #ClutterDeviceManager
* @device_id: the integer id of a device
*
* Retrieves the #ClutterInputDevice with the given @device_id
*
* Return value: (transfer none): a #ClutterInputDevice or %NULL. The
* returned device is owned by the #ClutterDeviceManager and should
* never be modified or freed
*
* Since: 1.2
*/
ClutterInputDevice *
clutter_device_manager_get_device (ClutterDeviceManager *device_manager,
gint device_id)
{
ClutterDeviceManagerClass *manager_class;
g_return_val_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager), NULL);
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
return manager_class->get_device (device_manager, device_id);
}
/**
* clutter_device_manager_get_core_device:
* @device_manager: a #ClutterDeviceManager
* @device_type: the type of the core device
*
* Retrieves the core #ClutterInputDevice of type @device_type
*
* Core devices are devices created automatically by the default
* Clutter backend
*
* Return value: (transfer none): a #ClutterInputDevice or %NULL. The
* returned device is owned by the #ClutterDeviceManager and should
* not be modified or freed
*
* Since: 1.2
*/
ClutterInputDevice *
clutter_device_manager_get_core_device (ClutterDeviceManager *device_manager,
ClutterInputDeviceType device_type)
{
ClutterDeviceManagerClass *manager_class;
g_return_val_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager), NULL);
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
return manager_class->get_core_device (device_manager, device_type);
}
void
_clutter_device_manager_select_stage_events (ClutterDeviceManager *device_manager,
ClutterStage *stage)
{
ClutterDeviceManagerClass *manager_class;
g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
if (manager_class->select_stage_events)
manager_class->select_stage_events (device_manager, stage);
}
/*
* _clutter_device_manager_add_device:
* @device_manager: a #ClutterDeviceManager
* @device: a #ClutterInputDevice
*
* Adds @device to the list of #ClutterInputDevice<!-- -->s maintained
* by @device_manager
*
* The reference count of @device is not increased
*
* The #ClutterDeviceManager::device-added signal is emitted after
* adding @device to the list
*/
void
_clutter_device_manager_add_device (ClutterDeviceManager *device_manager,
ClutterInputDevice *device)
{
ClutterDeviceManagerClass *manager_class;
g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
g_assert (manager_class->add_device != NULL);
manager_class->add_device (device_manager, device);
g_signal_emit (device_manager, manager_signals[DEVICE_ADDED], 0, device);
}
/*
* _clutter_device_manager_remove_device:
* @device_manager: a #ClutterDeviceManager
* @device: a #ClutterInputDevice
*
* Removes @device from the list of #ClutterInputDevice<!-- -->s
* maintained by @device_manager
*
* The reference count of @device is not decreased
*
* The #ClutterDeviceManager::device-removed signal is emitted after
* removing @device from the list
*/
void
_clutter_device_manager_remove_device (ClutterDeviceManager *device_manager,
ClutterInputDevice *device)
{
ClutterDeviceManagerClass *manager_class;
g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
g_assert (manager_class->remove_device != NULL);
/* The subclass remove_device() method will likely unref it but we
have to keep it alive during the signal emission. */
g_object_ref (device);
manager_class->remove_device (device_manager, device);
g_signal_emit (device_manager, manager_signals[DEVICE_REMOVED], 0, device);
g_object_unref (device);
}
/*
* _clutter_device_manager_update_devices:
* @device_manager: a #ClutterDeviceManager
*
* Updates every #ClutterInputDevice handled by @device_manager
* by performing a pick paint at the coordinates of each pointer
* device
*/
void
_clutter_device_manager_update_devices (ClutterDeviceManager *device_manager)
{
const GSList *d;
for (d = clutter_device_manager_peek_devices (device_manager);
d != NULL;
d = d->next)
{
ClutterInputDevice *device = d->data;
ClutterInputDeviceType device_type;
/* we only care about pointer devices */
device_type = clutter_input_device_get_device_type (device);
if (device_type != CLUTTER_POINTER_DEVICE)
continue;
/* out of stage */
if (device->stage == NULL)
continue;
/* the user disabled motion events delivery on actors for
* the stage the device is on; we don't perform any picking
* since the source of the events will always be set to be
* the stage
*/
if (!clutter_stage_get_motion_events_enabled (device->stage))
continue;
_clutter_input_device_update (device, NULL, TRUE);
}
}
ClutterBackend *
_clutter_device_manager_get_backend (ClutterDeviceManager *manager)
{
ClutterDeviceManagerPrivate *priv = clutter_device_manager_get_instance_private (manager);
g_return_val_if_fail (CLUTTER_IS_DEVICE_MANAGER (manager), NULL);
return priv->backend;
}
/**
* clutter_device_manager_create_virtual_device:
* @device_manager: a #ClutterDeviceManager
* @device_type: the type of the virtual device
*
* Creates a virtual input device.
*
* Returns: (transfer full): a newly created virtual device
**/
ClutterVirtualInputDevice *
clutter_device_manager_create_virtual_device (ClutterDeviceManager *device_manager,
ClutterInputDeviceType device_type)
{
ClutterDeviceManagerClass *manager_class;
g_return_val_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager), NULL);
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
return manager_class->create_virtual_device (device_manager,
device_type);
}
/**
* clutter_device_manager_supported_virtua_device_types: (skip)
*/
ClutterVirtualDeviceType
clutter_device_manager_get_supported_virtual_device_types (ClutterDeviceManager *device_manager)
{
ClutterDeviceManagerClass *manager_class;
g_return_val_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager),
CLUTTER_VIRTUAL_DEVICE_TYPE_NONE);
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
return manager_class->get_supported_virtual_device_types (device_manager);
}
void
_clutter_device_manager_compress_motion (ClutterDeviceManager *device_manager,
ClutterEvent *event,
const ClutterEvent *to_discard)
{
ClutterDeviceManagerClass *manager_class;
g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
if (!manager_class->compress_motion)
return;
manager_class->compress_motion (device_manager, event, to_discard);
}
void
clutter_device_manager_ensure_a11y_state (ClutterDeviceManager *device_manager)
{
ClutterInputDevice *core_pointer;
core_pointer = clutter_device_manager_get_core_device (device_manager,
CLUTTER_POINTER_DEVICE);
if (core_pointer)
{
if (_clutter_is_input_pointer_a11y_enabled (core_pointer))
_clutter_input_pointer_a11y_add_device (core_pointer);
}
}
static gboolean
are_kbd_a11y_settings_equal (ClutterKbdA11ySettings *a,
ClutterKbdA11ySettings *b)
{
return (memcmp (a, b, sizeof (ClutterKbdA11ySettings)) == 0);
}
void
clutter_device_manager_set_kbd_a11y_settings (ClutterDeviceManager *device_manager,
ClutterKbdA11ySettings *settings)
{
ClutterDeviceManagerClass *manager_class;
ClutterDeviceManagerPrivate *priv = clutter_device_manager_get_instance_private (device_manager);
g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
if (are_kbd_a11y_settings_equal (&priv->kbd_a11y_settings, settings))
return;
priv->kbd_a11y_settings = *settings;
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
if (manager_class->apply_kbd_a11y_settings)
manager_class->apply_kbd_a11y_settings (device_manager, settings);
}
void
clutter_device_manager_get_kbd_a11y_settings (ClutterDeviceManager *device_manager,
ClutterKbdA11ySettings *settings)
{
ClutterDeviceManagerPrivate *priv = clutter_device_manager_get_instance_private (device_manager);
g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
*settings = priv->kbd_a11y_settings;
}
static gboolean
are_pointer_a11y_settings_equal (ClutterPointerA11ySettings *a,
ClutterPointerA11ySettings *b)
{
return (memcmp (a, b, sizeof (ClutterPointerA11ySettings)) == 0);
}
static void
clutter_device_manager_enable_pointer_a11y (ClutterDeviceManager *device_manager)
{
ClutterInputDevice *core_pointer;
core_pointer = clutter_device_manager_get_core_device (device_manager,
CLUTTER_POINTER_DEVICE);
_clutter_input_pointer_a11y_add_device (core_pointer);
}
static void
clutter_device_manager_disable_pointer_a11y (ClutterDeviceManager *device_manager)
{
ClutterInputDevice *core_pointer;
core_pointer = clutter_device_manager_get_core_device (device_manager,
CLUTTER_POINTER_DEVICE);
_clutter_input_pointer_a11y_remove_device (core_pointer);
}
/**
* clutter_device_manager_set_pointer_a11y_settings:
* @device_manager: a #ClutterDeviceManager
* @settings: a pointer to a #ClutterPointerA11ySettings
*
* Sets the pointer accessibility settings
**/
void
clutter_device_manager_set_pointer_a11y_settings (ClutterDeviceManager *device_manager,
ClutterPointerA11ySettings *settings)
{
ClutterDeviceManagerPrivate *priv =
clutter_device_manager_get_instance_private (device_manager);
g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
if (are_pointer_a11y_settings_equal (&priv->pointer_a11y_settings, settings))
return;
if (priv->pointer_a11y_settings.controls == 0 && settings->controls != 0)
clutter_device_manager_enable_pointer_a11y (device_manager);
else if (priv->pointer_a11y_settings.controls != 0 && settings->controls == 0)
clutter_device_manager_disable_pointer_a11y (device_manager);
priv->pointer_a11y_settings = *settings;
}
/**
* clutter_device_manager_get_pointer_a11y_settings:
* @device_manager: a #ClutterDeviceManager
* @settings: a pointer to a #ClutterPointerA11ySettings
*
* Gets the current pointer accessibility settings
**/
void
clutter_device_manager_get_pointer_a11y_settings (ClutterDeviceManager *device_manager,
ClutterPointerA11ySettings *settings)
{
ClutterDeviceManagerPrivate *priv =
clutter_device_manager_get_instance_private (device_manager);
g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
*settings = priv->pointer_a11y_settings;
}
/**
* clutter_device_manager_set_pointer_a11y_dwell_click_type:
* @device_manager: a #ClutterDeviceManager
* @click_type: type of click as #ClutterPointerA11yDwellClickType
*
* Sets the dwell click type
**/
void
clutter_device_manager_set_pointer_a11y_dwell_click_type (ClutterDeviceManager *device_manager,
ClutterPointerA11yDwellClickType click_type)
{
ClutterDeviceManagerPrivate *priv =
clutter_device_manager_get_instance_private (device_manager);
g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
priv->pointer_a11y_settings.dwell_click_type = click_type;
}

View File

@ -1,181 +0,0 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2009 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 __CLUTTER_DEVICE_MANAGER_H__
#define __CLUTTER_DEVICE_MANAGER_H__
#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
#error "Only <clutter/clutter.h> can be included directly."
#endif
#include <clutter/clutter-input-device.h>
#include <clutter/clutter-stage.h>
G_BEGIN_DECLS
#define CLUTTER_TYPE_DEVICE_MANAGER (clutter_device_manager_get_type ())
CLUTTER_EXPORT
G_DECLARE_DERIVABLE_TYPE (ClutterDeviceManager, clutter_device_manager,
CLUTTER, DEVICE_MANAGER, GObject)
typedef struct _ClutterDeviceManagerPrivate ClutterDeviceManagerPrivate;
/**
* ClutterVirtualDeviceType:
*/
typedef enum _ClutterVirtualDeviceType
{
CLUTTER_VIRTUAL_DEVICE_TYPE_NONE = 0,
CLUTTER_VIRTUAL_DEVICE_TYPE_KEYBOARD = 1 << 0,
CLUTTER_VIRTUAL_DEVICE_TYPE_POINTER = 1 << 1,
CLUTTER_VIRTUAL_DEVICE_TYPE_TOUCHSCREEN = 1 << 2,
} ClutterVirtualDeviceType;
/**
* ClutterKbdA11ySettings:
*
* The #ClutterKbdA11ySettings structure contains keyboard accessibility
* settings
*
*/
typedef struct _ClutterKbdA11ySettings
{
ClutterKeyboardA11yFlags controls;
gint slowkeys_delay;
gint debounce_delay;
gint timeout_delay;
gint mousekeys_init_delay;
gint mousekeys_max_speed;
gint mousekeys_accel_time;
} ClutterKbdA11ySettings;
/**
* ClutterPointerA11ySettings:
*
* The #ClutterPointerA11ySettings structure contains pointer accessibility
* settings
*
*/
typedef struct _ClutterPointerA11ySettings
{
ClutterPointerA11yFlags controls;
ClutterPointerA11yDwellClickType dwell_click_type;
ClutterPointerA11yDwellMode dwell_mode;
ClutterPointerA11yDwellDirection dwell_gesture_single;
ClutterPointerA11yDwellDirection dwell_gesture_double;
ClutterPointerA11yDwellDirection dwell_gesture_drag;
ClutterPointerA11yDwellDirection dwell_gesture_secondary;
gint secondary_click_delay;
gint dwell_delay;
gint dwell_threshold;
} ClutterPointerA11ySettings;
/**
* ClutterDeviceManagerClass:
*
* The #ClutterDeviceManagerClass structure contains only private data
*
* Since: 1.2
*/
struct _ClutterDeviceManagerClass
{
/*< private >*/
GObjectClass parent_class;
const GSList * (* get_devices) (ClutterDeviceManager *device_manager);
ClutterInputDevice *(* get_core_device) (ClutterDeviceManager *device_manager,
ClutterInputDeviceType device_type);
ClutterInputDevice *(* get_device) (ClutterDeviceManager *device_manager,
gint device_id);
void (* add_device) (ClutterDeviceManager *manager,
ClutterInputDevice *device);
void (* remove_device) (ClutterDeviceManager *manager,
ClutterInputDevice *device);
void (* select_stage_events) (ClutterDeviceManager *manager,
ClutterStage *stage);
ClutterVirtualInputDevice *(* create_virtual_device) (ClutterDeviceManager *device_manager,
ClutterInputDeviceType device_type);
ClutterVirtualDeviceType (* get_supported_virtual_device_types) (ClutterDeviceManager *device_manager);
void (* compress_motion) (ClutterDeviceManager *device_manger,
ClutterEvent *event,
const ClutterEvent *to_discard);
/* Keyboard accessbility */
void (* apply_kbd_a11y_settings) (ClutterDeviceManager *device_manger,
ClutterKbdA11ySettings *settings);
/* Event platform data */
void (* copy_event_data) (ClutterDeviceManager *device_manager,
const ClutterEvent *src,
ClutterEvent *dest);
void (* free_event_data) (ClutterDeviceManager *device_manager,
ClutterEvent *event);
/* padding */
gpointer _padding[4];
};
CLUTTER_EXPORT
ClutterDeviceManager *clutter_device_manager_get_default (void);
CLUTTER_EXPORT
GSList * clutter_device_manager_list_devices (ClutterDeviceManager *device_manager);
CLUTTER_EXPORT
const GSList * clutter_device_manager_peek_devices (ClutterDeviceManager *device_manager);
CLUTTER_EXPORT
ClutterInputDevice * clutter_device_manager_get_device (ClutterDeviceManager *device_manager,
gint device_id);
CLUTTER_EXPORT
ClutterInputDevice * clutter_device_manager_get_core_device (ClutterDeviceManager *device_manager,
ClutterInputDeviceType device_type);
CLUTTER_EXPORT
ClutterVirtualInputDevice *clutter_device_manager_create_virtual_device (ClutterDeviceManager *device_manager,
ClutterInputDeviceType device_type);
CLUTTER_EXPORT
ClutterVirtualDeviceType clutter_device_manager_get_supported_virtual_device_types (ClutterDeviceManager *device_manager);
CLUTTER_EXPORT
void clutter_device_manager_set_kbd_a11y_settings (ClutterDeviceManager *device_manager,
ClutterKbdA11ySettings *settings);
CLUTTER_EXPORT
void clutter_device_manager_get_kbd_a11y_settings (ClutterDeviceManager *device_manager,
ClutterKbdA11ySettings *settings);
CLUTTER_EXPORT
void clutter_device_manager_set_pointer_a11y_settings (ClutterDeviceManager *device_manager,
ClutterPointerA11ySettings *settings);
CLUTTER_EXPORT
void clutter_device_manager_get_pointer_a11y_settings (ClutterDeviceManager *device_manager,
ClutterPointerA11ySettings *settings);
CLUTTER_EXPORT
void clutter_device_manager_set_pointer_a11y_dwell_click_type (ClutterDeviceManager *device_manager,
ClutterPointerA11yDwellClickType click_type);
G_END_DECLS
#endif /* __CLUTTER_DEVICE_MANAGER_H__ */

View File

@ -0,0 +1,254 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright © 2009, 2010, 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 CLUTTER_INPUT_DEVICE_PRIVATE_H
#define CLUTTER_INPUT_DEVICE_PRIVATE_H
#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
#error "Only <clutter/clutter.h> can be included directly."
#endif
#include <clutter/clutter-input-device.h>
G_BEGIN_DECLS
typedef struct _ClutterAxisInfo
{
ClutterInputAxis axis;
gdouble min_axis;
gdouble max_axis;
gdouble min_value;
gdouble max_value;
gdouble resolution;
} ClutterAxisInfo;
typedef struct _ClutterKeyInfo
{
guint keyval;
ClutterModifierType modifiers;
} ClutterKeyInfo;
typedef struct _ClutterScrollInfo
{
guint axis_id;
ClutterScrollDirection direction;
gdouble increment;
gdouble last_value;
guint last_value_valid : 1;
} ClutterScrollInfo;
typedef struct _ClutterTouchInfo
{
ClutterEventSequence *sequence;
ClutterActor *actor;
gfloat current_x;
gfloat current_y;
} ClutterTouchInfo;
typedef struct _ClutterPtrA11yData
{
int n_btn_pressed;
float current_x;
float current_y;
float dwell_x;
float dwell_y;
gboolean dwell_drag_started;
gboolean dwell_gesture_started;
guint dwell_timer;
guint dwell_position_timer;
guint secondary_click_timer;
gboolean secondary_click_triggered;
} ClutterPtrA11yData;
struct _ClutterInputDevice
{
GObject parent_instance;
gint id;
ClutterInputDeviceType device_type;
ClutterInputMode device_mode;
gchar *device_name;
ClutterSeat *seat;
ClutterBackend *backend;
/* the associated device */
ClutterInputDevice *associated;
GList *slaves;
/* the actor underneath the pointer */
ClutterActor *cursor_actor;
GHashTable *inv_touch_sequence_actors;
/* the actor that has a grab in place for the device */
ClutterActor *pointer_grab_actor;
ClutterActor *keyboard_grab_actor;
GHashTable *sequence_grab_actors;
GHashTable *inv_sequence_grab_actors;
/* the current click count */
gint click_count;
/* the stage the device is on */
ClutterStage *stage;
/* the current state */
gfloat current_x;
gfloat current_y;
guint32 current_time;
gint current_button_number;
ClutterModifierType current_state;
/* the current touch points states */
GHashTable *touch_sequences_info;
/* the previous state, used for click count generation */
gint previous_x;
gint previous_y;
guint32 previous_time;
gint previous_button_number;
ClutterModifierType previous_state;
GArray *axes;
guint n_keys;
GArray *keys;
GArray *scroll_info;
gchar *vendor_id;
gchar *product_id;
gchar *node_path;
GPtrArray *tools;
gint n_rings;
gint n_strips;
gint n_mode_groups;
ClutterInputDeviceMapping mapping_mode;
guint has_cursor : 1;
guint is_enabled : 1;
/* Accessiblity */
ClutterVirtualInputDevice *accessibility_virtual_device;
ClutterPtrA11yData *ptr_a11y_data;
};
CLUTTER_EXPORT
void _clutter_input_device_set_associated_device (ClutterInputDevice *device,
ClutterInputDevice *associated);
CLUTTER_EXPORT
void _clutter_input_device_add_slave (ClutterInputDevice *master,
ClutterInputDevice *slave);
CLUTTER_EXPORT
void _clutter_input_device_remove_slave (ClutterInputDevice *master,
ClutterInputDevice *slave);
CLUTTER_EXPORT
void clutter_input_device_update_from_tool (ClutterInputDevice *device,
ClutterInputDeviceTool *tool);
CLUTTER_EXPORT
ClutterStage * _clutter_input_device_get_stage (ClutterInputDevice *device);
CLUTTER_EXPORT
void _clutter_input_device_set_stage (ClutterInputDevice *device,
ClutterStage *stage);
CLUTTER_EXPORT
void _clutter_input_device_set_coords (ClutterInputDevice *device,
ClutterEventSequence *sequence,
gfloat x,
gfloat y,
ClutterStage *stage);
CLUTTER_EXPORT
void _clutter_input_device_set_state (ClutterInputDevice *device,
ClutterModifierType state);
CLUTTER_EXPORT
void _clutter_input_device_set_time (ClutterInputDevice *device,
guint32 time_);
void _clutter_input_device_set_actor (ClutterInputDevice *device,
ClutterEventSequence *sequence,
ClutterActor *actor,
gboolean emit_crossing);
ClutterActor * _clutter_input_device_update (ClutterInputDevice *device,
ClutterEventSequence *sequence,
gboolean emit_crossing);
CLUTTER_EXPORT
void _clutter_input_device_add_event_sequence (ClutterInputDevice *device,
ClutterEvent *event);
CLUTTER_EXPORT
void _clutter_input_device_remove_event_sequence (ClutterInputDevice *device,
ClutterEvent *event);
CLUTTER_EXPORT
void _clutter_input_device_set_n_keys (ClutterInputDevice *device,
guint n_keys);
CLUTTER_EXPORT
gboolean _clutter_input_device_translate_axis (ClutterInputDevice *device,
guint index_,
gdouble value,
gdouble *axis_value);
CLUTTER_EXPORT
guint _clutter_input_device_add_axis (ClutterInputDevice *device,
ClutterInputAxis axis,
gdouble minimum,
gdouble maximum,
gdouble resolution);
CLUTTER_EXPORT
void _clutter_input_device_reset_axes (ClutterInputDevice *device);
CLUTTER_EXPORT
void _clutter_input_device_add_scroll_info (ClutterInputDevice *device,
guint index_,
ClutterScrollDirection direction,
gdouble increment);
CLUTTER_EXPORT
gboolean _clutter_input_device_get_scroll_delta (ClutterInputDevice *device,
guint index_,
gdouble value,
ClutterScrollDirection *direction_p,
gdouble *delta_p);
CLUTTER_EXPORT
void _clutter_input_device_reset_scroll_info (ClutterInputDevice *device);
CLUTTER_EXPORT
void clutter_input_device_add_tool (ClutterInputDevice *device,
ClutterInputDeviceTool *tool);
CLUTTER_EXPORT
ClutterInputDeviceTool *
clutter_input_device_lookup_tool (ClutterInputDevice *device,
guint64 serial,
ClutterInputDeviceToolType type);
#endif /* CLUTTER_INPUT_DEVICE_PRIVATE_H */

View File

@ -37,12 +37,12 @@
#include "clutter-actor-private.h"
#include "clutter-debug.h"
#include "clutter-device-manager-private.h"
#include "clutter-enum-types.h"
#include "clutter-event-private.h"
#include "clutter-marshal.h"
#include "clutter-private.h"
#include "clutter-stage-private.h"
#include "clutter-input-device-private.h"
#include "clutter-input-device-tool.h"
#include <math.h>
@ -57,7 +57,7 @@ enum
PROP_NAME,
PROP_DEVICE_TYPE,
PROP_DEVICE_MANAGER,
PROP_SEAT,
PROP_DEVICE_MODE,
PROP_HAS_CURSOR,
@ -170,8 +170,8 @@ clutter_input_device_set_property (GObject *gobject,
self->device_type = g_value_get_enum (value);
break;
case PROP_DEVICE_MANAGER:
self->device_manager = g_value_get_object (value);
case PROP_SEAT:
self->seat = g_value_get_object (value);
break;
case PROP_DEVICE_MODE:
@ -246,8 +246,8 @@ clutter_input_device_get_property (GObject *gobject,
g_value_set_enum (value, self->device_type);
break;
case PROP_DEVICE_MANAGER:
g_value_set_object (value, self->device_manager);
case PROP_SEAT:
g_value_set_object (value, self->seat);
break;
case PROP_DEVICE_MODE:
@ -361,17 +361,15 @@ clutter_input_device_class_init (ClutterInputDeviceClass *klass)
G_PARAM_CONSTRUCT_ONLY);
/**
* ClutterInputDevice:device-manager:
* ClutterInputDevice:seat:
*
* The #ClutterDeviceManager instance which owns the device
*
* Since: 1.6
* The #ClutterSeat instance which owns the device
*/
obj_props[PROP_DEVICE_MANAGER] =
g_param_spec_object ("device-manager",
P_("Device Manager"),
P_("The device manager instance"),
CLUTTER_TYPE_DEVICE_MANAGER,
obj_props[PROP_SEAT] =
g_param_spec_object ("seat",
P_("Seat"),
P_("Seat"),
CLUTTER_TYPE_SEAT,
CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
/**
@ -1224,11 +1222,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 +2439,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;
}

View File

@ -28,10 +28,40 @@
#error "Only <clutter/clutter.h> can be included directly."
#endif
#include <clutter/clutter-backend.h>
#include <clutter/clutter-types.h>
#include <clutter/clutter-seat.h>
G_BEGIN_DECLS
typedef void (*ClutterEmitInputDeviceEvent) (ClutterEvent *event,
ClutterInputDevice *device);
struct _ClutterInputDeviceClass
{
GObjectClass parent_class;
gboolean (* keycode_to_evdev) (ClutterInputDevice *device,
guint hardware_keycode,
guint *evdev_keycode);
void (* update_from_tool) (ClutterInputDevice *device,
ClutterInputDeviceTool *tool);
gboolean (* is_mode_switch_button) (ClutterInputDevice *device,
guint group,
guint button);
gint (* get_group_n_modes) (ClutterInputDevice *device,
gint group);
gboolean (* is_grouped) (ClutterInputDevice *device,
ClutterInputDevice *other_device);
/* Keyboard accessbility */
void (* process_kbd_a11y_event) (ClutterEvent *event,
ClutterInputDevice *device,
ClutterEmitInputDeviceEvent emit_event_func);
};
#define CLUTTER_TYPE_INPUT_DEVICE (clutter_input_device_get_type ())
#define CLUTTER_INPUT_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_INPUT_DEVICE, ClutterInputDevice))
#define CLUTTER_IS_INPUT_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_INPUT_DEVICE))
@ -171,6 +201,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

View File

@ -22,10 +22,10 @@
#include "clutter-build-config.h"
#include "clutter-private.h"
#include "clutter/clutter-input-device-private.h"
#include "clutter/clutter-input-method.h"
#include "clutter/clutter-input-method-private.h"
#include "clutter/clutter-input-focus-private.h"
#include "clutter/clutter-device-manager-private.h"
typedef struct _ClutterInputMethodPrivate ClutterInputMethodPrivate;
@ -452,8 +452,8 @@ clutter_input_method_forward_key (ClutterInputMethod *im,
gboolean press)
{
ClutterInputMethodPrivate *priv;
ClutterDeviceManager *device_manager;
ClutterInputDevice *keyboard;
ClutterSeat *seat;
ClutterStage *stage;
ClutterEvent *event;
@ -463,9 +463,8 @@ clutter_input_method_forward_key (ClutterInputMethod *im,
if (!priv->focus)
return;
device_manager = clutter_device_manager_get_default ();
keyboard = clutter_device_manager_get_core_device (device_manager,
CLUTTER_KEYBOARD_DEVICE);
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
keyboard = clutter_seat_get_keyboard (seat);
stage = _clutter_input_device_get_stage (keyboard);
if (stage == NULL)
return;

View File

@ -25,10 +25,9 @@
#include "clutter-build-config.h"
#include "clutter-device-manager.h"
#include "clutter-device-manager-private.h"
#include "clutter-enum-types.h"
#include "clutter-input-device.h"
#include "clutter-input-device-private.h"
#include "clutter-input-pointer-a11y-private.h"
#include "clutter-main.h"
#include "clutter-virtual-input-device.h"
@ -38,7 +37,7 @@ is_secondary_click_enabled (ClutterInputDevice *device)
{
ClutterPointerA11ySettings settings;
clutter_device_manager_get_pointer_a11y_settings (device->device_manager, &settings);
clutter_seat_get_pointer_a11y_settings (device->seat, &settings);
return (settings.controls & CLUTTER_A11Y_SECONDARY_CLICK_ENABLED);
}
@ -48,7 +47,7 @@ is_dwell_click_enabled (ClutterInputDevice *device)
{
ClutterPointerA11ySettings settings;
clutter_device_manager_get_pointer_a11y_settings (device->device_manager, &settings);
clutter_seat_get_pointer_a11y_settings (device->seat, &settings);
return (settings.controls & CLUTTER_A11Y_DWELL_ENABLED);
}
@ -58,7 +57,7 @@ get_secondary_click_delay (ClutterInputDevice *device)
{
ClutterPointerA11ySettings settings;
clutter_device_manager_get_pointer_a11y_settings (device->device_manager, &settings);
clutter_seat_get_pointer_a11y_settings (device->seat, &settings);
return settings.secondary_click_delay;
}
@ -68,7 +67,7 @@ get_dwell_delay (ClutterInputDevice *device)
{
ClutterPointerA11ySettings settings;
clutter_device_manager_get_pointer_a11y_settings (device->device_manager, &settings);
clutter_seat_get_pointer_a11y_settings (device->seat, &settings);
return settings.dwell_delay;
}
@ -78,7 +77,7 @@ get_dwell_threshold (ClutterInputDevice *device)
{
ClutterPointerA11ySettings settings;
clutter_device_manager_get_pointer_a11y_settings (device->device_manager, &settings);
clutter_seat_get_pointer_a11y_settings (device->seat, &settings);
return settings.dwell_threshold;
}
@ -88,7 +87,7 @@ get_dwell_mode (ClutterInputDevice *device)
{
ClutterPointerA11ySettings settings;
clutter_device_manager_get_pointer_a11y_settings (device->device_manager, &settings);
clutter_seat_get_pointer_a11y_settings (device->seat, &settings);
return settings.dwell_mode;
}
@ -98,7 +97,7 @@ get_dwell_click_type (ClutterInputDevice *device)
{
ClutterPointerA11ySettings settings;
clutter_device_manager_get_pointer_a11y_settings (device->device_manager, &settings);
clutter_seat_get_pointer_a11y_settings (device->seat, &settings);
return settings.dwell_click_type;
}
@ -109,7 +108,7 @@ get_dwell_click_type_for_direction (ClutterInputDevice *device,
{
ClutterPointerA11ySettings settings;
clutter_device_manager_get_pointer_a11y_settings (device->device_manager, &settings);
clutter_seat_get_pointer_a11y_settings (device->seat, &settings);
if (direction == settings.dwell_gesture_single)
return CLUTTER_A11Y_DWELL_CLICK_TYPE_PRIMARY;
@ -168,7 +167,7 @@ trigger_secondary_click (gpointer data)
device->ptr_a11y_data->secondary_click_triggered = TRUE;
device->ptr_a11y_data->secondary_click_timer = 0;
g_signal_emit_by_name (device->device_manager,
g_signal_emit_by_name (device->seat,
"ptr-a11y-timeout-stopped",
device,
CLUTTER_A11Y_TIMEOUT_TYPE_SECONDARY_CLICK,
@ -185,7 +184,7 @@ start_secondary_click_timeout (ClutterInputDevice *device)
device->ptr_a11y_data->secondary_click_timer =
clutter_threads_add_timeout (delay, trigger_secondary_click, device);
g_signal_emit_by_name (device->device_manager,
g_signal_emit_by_name (device->seat,
"ptr-a11y-timeout-started",
device,
CLUTTER_A11Y_TIMEOUT_TYPE_SECONDARY_CLICK,
@ -200,7 +199,7 @@ stop_secondary_click_timeout (ClutterInputDevice *device)
g_clear_handle_id (&device->ptr_a11y_data->secondary_click_timer,
g_source_remove);
g_signal_emit_by_name (device->device_manager,
g_signal_emit_by_name (device->seat,
"ptr-a11y-timeout-stopped",
device,
CLUTTER_A11Y_TIMEOUT_TYPE_SECONDARY_CLICK,
@ -304,7 +303,7 @@ update_dwell_click_type (ClutterInputDevice *device)
ClutterPointerA11ySettings settings;
ClutterPointerA11yDwellClickType dwell_click_type;
clutter_device_manager_get_pointer_a11y_settings (device->device_manager, &settings);
clutter_seat_get_pointer_a11y_settings (device->seat, &settings);
dwell_click_type = settings.dwell_click_type;
switch (dwell_click_type)
@ -329,10 +328,9 @@ update_dwell_click_type (ClutterInputDevice *device)
if (dwell_click_type != settings.dwell_click_type)
{
settings.dwell_click_type = dwell_click_type;
clutter_device_manager_set_pointer_a11y_settings (device->device_manager,
&settings);
clutter_seat_set_pointer_a11y_settings (device->seat, &settings);
g_signal_emit_by_name (device->device_manager,
g_signal_emit_by_name (device->seat,
"ptr-a11y-dwell-click-type-changed",
dwell_click_type);
}
@ -437,7 +435,7 @@ trigger_dwell_gesture (gpointer data)
device->ptr_a11y_data->dwell_timer =
clutter_threads_add_timeout (delay, trigger_clear_dwell_gesture, device);
g_signal_emit_by_name (device->device_manager,
g_signal_emit_by_name (device->seat,
"ptr-a11y-timeout-stopped",
device,
CLUTTER_A11Y_TIMEOUT_TYPE_GESTURE,
@ -455,7 +453,7 @@ start_dwell_gesture_timeout (ClutterInputDevice *device)
clutter_threads_add_timeout (delay, trigger_dwell_gesture, device);
device->ptr_a11y_data->dwell_gesture_started = TRUE;
g_signal_emit_by_name (device->device_manager,
g_signal_emit_by_name (device->seat,
"ptr-a11y-timeout-started",
device,
CLUTTER_A11Y_TIMEOUT_TYPE_GESTURE,
@ -469,7 +467,7 @@ trigger_dwell_click (gpointer data)
device->ptr_a11y_data->dwell_timer = 0;
g_signal_emit_by_name (device->device_manager,
g_signal_emit_by_name (device->seat,
"ptr-a11y-timeout-stopped",
device,
CLUTTER_A11Y_TIMEOUT_TYPE_DWELL,
@ -499,7 +497,7 @@ start_dwell_timeout (ClutterInputDevice *device)
device->ptr_a11y_data->dwell_timer =
clutter_threads_add_timeout (delay, trigger_dwell_click, device);
g_signal_emit_by_name (device->device_manager,
g_signal_emit_by_name (device->seat,
"ptr-a11y-timeout-started",
device,
CLUTTER_A11Y_TIMEOUT_TYPE_DWELL,
@ -514,7 +512,7 @@ stop_dwell_timeout (ClutterInputDevice *device)
g_clear_handle_id (&device->ptr_a11y_data->dwell_timer, g_source_remove);
device->ptr_a11y_data->dwell_gesture_started = FALSE;
g_signal_emit_by_name (device->device_manager,
g_signal_emit_by_name (device->seat,
"ptr-a11y-timeout-stopped",
device,
CLUTTER_A11Y_TIMEOUT_TYPE_DWELL,
@ -573,8 +571,7 @@ is_device_core_pointer (ClutterInputDevice *device)
{
ClutterInputDevice *core_pointer;
core_pointer = clutter_device_manager_get_core_device (device->device_manager,
CLUTTER_POINTER_DEVICE);
core_pointer = clutter_seat_get_pointer (device->seat);
if (core_pointer == NULL)
return FALSE;
@ -588,8 +585,8 @@ _clutter_input_pointer_a11y_add_device (ClutterInputDevice *device)
return;
device->accessibility_virtual_device =
clutter_device_manager_create_virtual_device (device->device_manager,
CLUTTER_POINTER_DEVICE);
clutter_seat_create_virtual_device (device->seat,
CLUTTER_POINTER_DEVICE);
device->ptr_a11y_data = g_new0 (ClutterPtrA11yData, 1);
}

View File

@ -62,3 +62,9 @@ clutter_keymap_get_caps_lock_state (ClutterKeymap *keymap)
{
return CLUTTER_KEYMAP_GET_CLASS (keymap)->get_caps_lock_state (keymap);
}
PangoDirection
clutter_keymap_get_direction (ClutterKeymap *keymap)
{
return CLUTTER_KEYMAP_GET_CLASS (keymap)->get_direction (keymap);
}

View File

@ -29,6 +29,7 @@
#include <clutter/clutter-macros.h>
#include <glib-object.h>
#include <pango/pango.h>
typedef struct _ClutterKeymap ClutterKeymap;
typedef struct _ClutterKeymapClass ClutterKeymapClass;
@ -39,6 +40,7 @@ struct _ClutterKeymapClass
gboolean (* get_num_lock_state) (ClutterKeymap *keymap);
gboolean (* get_caps_lock_state) (ClutterKeymap *keymap);
PangoDirection (* get_direction) (ClutterKeymap *keymap);
};
#define CLUTTER_TYPE_KEYMAP (clutter_keymap_get_type ())
@ -53,4 +55,6 @@ gboolean clutter_keymap_get_num_lock_state (ClutterKeymap *keymap);
CLUTTER_EXPORT
gboolean clutter_keymap_get_caps_lock_state (ClutterKeymap *keymap);
PangoDirection clutter_keymap_get_direction (ClutterKeymap *keymap);
#endif /* CLUTTER_KEYMAP_H */

View File

@ -55,9 +55,9 @@
#include "clutter-backend-private.h"
#include "clutter-config.h"
#include "clutter-debug.h"
#include "clutter-device-manager-private.h"
#include "clutter-event-private.h"
#include "clutter-feature.h"
#include "clutter-input-device-private.h"
#include "clutter-input-pointer-a11y-private.h"
#include "clutter-graphene.h"
#include "clutter-main.h"
@ -1838,8 +1838,7 @@ _clutter_process_event_details (ClutterActor *stage,
gfloat x, y;
clutter_event_get_coords (event, &x, &y);
core_pointer = clutter_device_manager_get_core_device (device->device_manager,
CLUTTER_POINTER_DEVICE);
core_pointer = clutter_event_get_device (event);
_clutter_input_pointer_a11y_on_motion_event (core_pointer, x, y);
}
}
@ -1881,9 +1880,7 @@ _clutter_process_event_details (ClutterActor *stage,
{
ClutterInputDevice *core_pointer;
core_pointer = clutter_device_manager_get_core_device (device->device_manager,
CLUTTER_POINTER_DEVICE);
core_pointer = clutter_event_get_device (event);
_clutter_input_pointer_a11y_on_button_event (core_pointer,
event->button.button,
event->type == CLUTTER_BUTTON_PRESS);

View File

@ -26,8 +26,8 @@
#define __CLUTTER_H_INSIDE__
#include "clutter-backend.h"
#include "clutter-device-manager-private.h"
#include "clutter-event-private.h"
#include "clutter-input-device-private.h"
#include "clutter-input-pointer-a11y-private.h"
#include "clutter-macros.h"
#include "clutter-private.h"

View File

@ -0,0 +1,568 @@
/*
* 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-input-pointer-a11y-private.h"
#include "clutter-marshal.h"
#include "clutter-private.h"
#include "clutter-seat.h"
#include "clutter-virtual-input-device.h"
enum
{
DEVICE_ADDED,
DEVICE_REMOVED,
TOOL_CHANGED,
KBD_A11Y_MASK_CHANGED,
KBD_A11Y_FLAGS_CHANGED,
PTR_A11Y_DWELL_CLICK_TYPE_CHANGED,
PTR_A11Y_TIMEOUT_STARTED,
PTR_A11Y_TIMEOUT_STOPPED,
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;
/* Keyboard a11y */
ClutterKbdA11ySettings kbd_a11y_settings;
/* Pointer a11y */
ClutterPointerA11ySettings pointer_a11y_settings;
};
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,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
CLUTTER_TYPE_INPUT_DEVICE);
g_signal_set_va_marshaller (signals[DEVICE_ADDED],
G_TYPE_FROM_CLASS (object_class),
g_cclosure_marshal_VOID__OBJECTv);
signals[DEVICE_REMOVED] =
g_signal_new (I_("device-removed"),
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
CLUTTER_TYPE_INPUT_DEVICE);
g_signal_set_va_marshaller (signals[DEVICE_REMOVED],
G_TYPE_FROM_CLASS (object_class),
g_cclosure_marshal_VOID__OBJECTv);
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);
/**
* ClutterSeat::kbd-a11y-mods-state-changed:
* @seat: the #ClutterSeat that emitted the signal
* @latched_mask: the latched modifier mask from stickykeys
* @locked_mask: the locked modifier mask from stickykeys
*
* The ::kbd-a11y-mods-state-changed signal is emitted each time either the
* latched modifiers mask or locked modifiers mask are changed as the
* result of keyboard accessibilty's sticky keys operations.
*/
signals[KBD_A11Y_MASK_CHANGED] =
g_signal_new (I_("kbd-a11y-mods-state-changed"),
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
_clutter_marshal_VOID__UINT_UINT,
G_TYPE_NONE, 2,
G_TYPE_UINT,
G_TYPE_UINT);
g_signal_set_va_marshaller (signals[KBD_A11Y_MASK_CHANGED],
G_TYPE_FROM_CLASS (object_class),
_clutter_marshal_VOID__UINT_UINTv);
/**
* ClutterSeat::kbd-a11y-flags-changed:
* @seat: the #ClutterSeat that emitted the signal
* @settings_flags: the new ClutterKeyboardA11yFlags configuration
* @changed_mask: the ClutterKeyboardA11yFlags changed
*
* The ::kbd-a11y-flags-changed signal is emitted each time the
* ClutterKeyboardA11yFlags configuration is changed as the result of
* keyboard accessibility operations.
*/
signals[KBD_A11Y_FLAGS_CHANGED] =
g_signal_new (I_("kbd-a11y-flags-changed"),
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
_clutter_marshal_VOID__UINT_UINT,
G_TYPE_NONE, 2,
G_TYPE_UINT,
G_TYPE_UINT);
g_signal_set_va_marshaller (signals[KBD_A11Y_FLAGS_CHANGED],
G_TYPE_FROM_CLASS (object_class),
_clutter_marshal_VOID__UINT_UINTv);
/**
* ClutterSeat::ptr-a11y-dwell-click-type-changed:
* @seat: the #ClutterSeat that emitted the signal
* @click_type: the new #ClutterPointerA11yDwellClickType mode
*
* The ::ptr-a11y-dwell-click-type-changed signal is emitted each time
* the ClutterPointerA11yDwellClickType mode is changed as the result
* of pointer accessibility operations.
*/
signals[PTR_A11Y_DWELL_CLICK_TYPE_CHANGED] =
g_signal_new (I_("ptr-a11y-dwell-click-type-changed"),
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
g_cclosure_marshal_VOID__FLAGS,
G_TYPE_NONE, 1,
CLUTTER_TYPE_POINTER_A11Y_DWELL_CLICK_TYPE);
g_signal_set_va_marshaller (signals[PTR_A11Y_DWELL_CLICK_TYPE_CHANGED],
G_TYPE_FROM_CLASS (object_class),
g_cclosure_marshal_VOID__FLAGSv);
/**
* ClutterSeat::ptr-a11y-timeout-started:
* @seat: the #ClutterSeat that emitted the signal
* @device: the core pointer #ClutterInputDevice
* @timeout_type: the type of timeout #ClutterPointerA11yTimeoutType
* @delay: the delay in ms before secondary-click is triggered.
*
* The ::ptr-a11y-timeout-started signal is emitted when a
* pointer accessibility timeout delay is started, so that upper
* layers can notify the user with some visual feedback.
*/
signals[PTR_A11Y_TIMEOUT_STARTED] =
g_signal_new (I_("ptr-a11y-timeout-started"),
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
_clutter_marshal_VOID__OBJECT_FLAGS_UINT,
G_TYPE_NONE, 3,
CLUTTER_TYPE_INPUT_DEVICE,
CLUTTER_TYPE_POINTER_A11Y_TIMEOUT_TYPE,
G_TYPE_UINT);
g_signal_set_va_marshaller (signals[PTR_A11Y_TIMEOUT_STARTED],
G_TYPE_FROM_CLASS (object_class),
_clutter_marshal_VOID__OBJECT_FLAGS_UINTv);
/**
* ClutterSeat::ptr-a11y-timeout-stopped:
* @seat: the #ClutterSeat that emitted the signal
* @device: the core pointer #ClutterInputDevice
* @timeout_type: the type of timeout #ClutterPointerA11yTimeoutType
* @clicked: %TRUE if the timeout finished and triggered a click
*
* The ::ptr-a11y-timeout-stopped signal is emitted when a running
* pointer accessibility timeout delay is stopped, either because
* it's triggered at the end of the delay or cancelled, so that
* upper layers can notify the user with some visual feedback.
*/
signals[PTR_A11Y_TIMEOUT_STOPPED] =
g_signal_new (I_("ptr-a11y-timeout-stopped"),
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
_clutter_marshal_VOID__OBJECT_FLAGS_BOOLEAN,
G_TYPE_NONE, 3,
CLUTTER_TYPE_INPUT_DEVICE,
CLUTTER_TYPE_POINTER_A11Y_TIMEOUT_TYPE,
G_TYPE_BOOLEAN);
g_signal_set_va_marshaller (signals[PTR_A11Y_TIMEOUT_STOPPED],
G_TYPE_FROM_CLASS (object_class),
_clutter_marshal_VOID__OBJECT_FLAGS_BOOLEANv);
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
**/
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);
}
void
clutter_seat_bell_notify (ClutterSeat *seat)
{
CLUTTER_SEAT_GET_CLASS (seat)->bell_notify (seat);
}
/**
* clutter_seat_get_keymap:
* @seat: a #ClutterSeat
*
* Returns the seat keymap
*
* Returns: (transfer none): the seat keymap
**/
ClutterKeymap *
clutter_seat_get_keymap (ClutterSeat *seat)
{
return CLUTTER_SEAT_GET_CLASS (seat)->get_keymap (seat);
}
static gboolean
are_kbd_a11y_settings_equal (ClutterKbdA11ySettings *a,
ClutterKbdA11ySettings *b)
{
return (memcmp (a, b, sizeof (ClutterKbdA11ySettings)) == 0);
}
void
clutter_seat_set_kbd_a11y_settings (ClutterSeat *seat,
ClutterKbdA11ySettings *settings)
{
ClutterSeatClass *seat_class;
ClutterSeatPrivate *priv = clutter_seat_get_instance_private (seat);
g_return_if_fail (CLUTTER_IS_SEAT (seat));
if (are_kbd_a11y_settings_equal (&priv->kbd_a11y_settings, settings))
return;
priv->kbd_a11y_settings = *settings;
seat_class = CLUTTER_SEAT_GET_CLASS (seat);
if (seat_class->apply_kbd_a11y_settings)
seat_class->apply_kbd_a11y_settings (seat, settings);
}
void
clutter_seat_get_kbd_a11y_settings (ClutterSeat *seat,
ClutterKbdA11ySettings *settings)
{
ClutterSeatPrivate *priv = clutter_seat_get_instance_private (seat);
g_return_if_fail (CLUTTER_IS_SEAT (seat));
*settings = priv->kbd_a11y_settings;
}
void
clutter_seat_ensure_a11y_state (ClutterSeat *seat)
{
ClutterInputDevice *core_pointer;
core_pointer = clutter_seat_get_pointer (seat);
if (core_pointer)
{
if (_clutter_is_input_pointer_a11y_enabled (core_pointer))
_clutter_input_pointer_a11y_add_device (core_pointer);
}
}
static gboolean
are_pointer_a11y_settings_equal (ClutterPointerA11ySettings *a,
ClutterPointerA11ySettings *b)
{
return (memcmp (a, b, sizeof (ClutterPointerA11ySettings)) == 0);
}
static void
clutter_seat_enable_pointer_a11y (ClutterSeat *seat)
{
ClutterInputDevice *core_pointer;
core_pointer = clutter_seat_get_pointer (seat);
_clutter_input_pointer_a11y_add_device (core_pointer);
}
static void
clutter_seat_disable_pointer_a11y (ClutterSeat *seat)
{
ClutterInputDevice *core_pointer;
core_pointer = clutter_seat_get_pointer (seat);
_clutter_input_pointer_a11y_remove_device (core_pointer);
}
/**
* clutter_seat_set_pointer_a11y_settings:
* @seat: a #ClutterSeat
* @settings: a pointer to a #ClutterPointerA11ySettings
*
* Sets the pointer accessibility settings
**/
void
clutter_seat_set_pointer_a11y_settings (ClutterSeat *seat,
ClutterPointerA11ySettings *settings)
{
ClutterSeatPrivate *priv = clutter_seat_get_instance_private (seat);
g_return_if_fail (CLUTTER_IS_SEAT (seat));
if (are_pointer_a11y_settings_equal (&priv->pointer_a11y_settings, settings))
return;
if (priv->pointer_a11y_settings.controls == 0 && settings->controls != 0)
clutter_seat_enable_pointer_a11y (seat);
else if (priv->pointer_a11y_settings.controls != 0 && settings->controls == 0)
clutter_seat_disable_pointer_a11y (seat);
priv->pointer_a11y_settings = *settings;
}
/**
* clutter_seat_get_pointer_a11y_settings:
* @seat: a #ClutterSeat
* @settings: a pointer to a #ClutterPointerA11ySettings
*
* Gets the current pointer accessibility settings
**/
void
clutter_seat_get_pointer_a11y_settings (ClutterSeat *seat,
ClutterPointerA11ySettings *settings)
{
ClutterSeatPrivate *priv = clutter_seat_get_instance_private (seat);
g_return_if_fail (CLUTTER_IS_SEAT (seat));
*settings = priv->pointer_a11y_settings;
}
/**
* clutter_seat_set_pointer_a11y_dwell_click_type:
* @seat: a #ClutterSeat
* @click_type: type of click as #ClutterPointerA11yDwellClickType
*
* Sets the dwell click type
**/
void
clutter_seat_set_pointer_a11y_dwell_click_type (ClutterSeat *seat,
ClutterPointerA11yDwellClickType click_type)
{
ClutterSeatPrivate *priv = clutter_seat_get_instance_private (seat);
g_return_if_fail (CLUTTER_IS_SEAT (seat));
priv->pointer_a11y_settings.dwell_click_type = click_type;
}
/**
* clutter_seat_create_virtual_device:
* @seat: a #ClutterSeat
* @device_type: the type of the virtual device
*
* Creates a virtual input device.
*
* Returns: (transfer full): a newly created virtual device
**/
ClutterVirtualInputDevice *
clutter_seat_create_virtual_device (ClutterSeat *seat,
ClutterInputDeviceType device_type)
{
ClutterSeatClass *seat_class;
g_return_val_if_fail (CLUTTER_IS_SEAT (seat), NULL);
seat_class = CLUTTER_SEAT_GET_CLASS (seat);
return seat_class->create_virtual_device (seat, device_type);
}
/**
* clutter_seat_supported_virtual_device_types: (skip)
*/
ClutterVirtualDeviceType
clutter_seat_get_supported_virtual_device_types (ClutterSeat *seat)
{
ClutterSeatClass *seat_class;
g_return_val_if_fail (CLUTTER_IS_SEAT (seat),
CLUTTER_VIRTUAL_DEVICE_TYPE_NONE);
seat_class = CLUTTER_SEAT_GET_CLASS (seat);
return seat_class->get_supported_virtual_device_types (seat);
}
void
clutter_seat_compress_motion (ClutterSeat *seat,
ClutterEvent *event,
const ClutterEvent *to_discard)
{
ClutterSeatClass *seat_class;
g_return_if_fail (CLUTTER_IS_SEAT (seat));
seat_class = CLUTTER_SEAT_GET_CLASS (seat);
if (!seat_class->compress_motion)
return;
seat_class->compress_motion (seat, event, to_discard);
}
void
clutter_seat_warp_pointer (ClutterSeat *seat,
int x,
int y)
{
g_return_if_fail (CLUTTER_IS_SEAT (seat));
CLUTTER_SEAT_GET_CLASS (seat)->warp_pointer (seat, x, y);
}

View File

@ -0,0 +1,178 @@
/*
* 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"
#include "clutter/clutter-keymap.h"
#include "clutter/clutter-virtual-input-device.h"
#define CLUTTER_TYPE_SEAT (clutter_seat_get_type ())
CLUTTER_EXPORT
G_DECLARE_DERIVABLE_TYPE (ClutterSeat, clutter_seat,
CLUTTER, SEAT, GObject)
/**
* ClutterKbdA11ySettings:
*
* The #ClutterKbdA11ySettings structure contains keyboard accessibility
* settings
*
*/
typedef struct _ClutterKbdA11ySettings
{
ClutterKeyboardA11yFlags controls;
gint slowkeys_delay;
gint debounce_delay;
gint timeout_delay;
gint mousekeys_init_delay;
gint mousekeys_max_speed;
gint mousekeys_accel_time;
} ClutterKbdA11ySettings;
/**
* ClutterPointerA11ySettings:
*
* The #ClutterPointerA11ySettings structure contains pointer accessibility
* settings
*
*/
typedef struct _ClutterPointerA11ySettings
{
ClutterPointerA11yFlags controls;
ClutterPointerA11yDwellClickType dwell_click_type;
ClutterPointerA11yDwellMode dwell_mode;
ClutterPointerA11yDwellDirection dwell_gesture_single;
ClutterPointerA11yDwellDirection dwell_gesture_double;
ClutterPointerA11yDwellDirection dwell_gesture_drag;
ClutterPointerA11yDwellDirection dwell_gesture_secondary;
gint secondary_click_delay;
gint dwell_delay;
gint dwell_threshold;
} ClutterPointerA11ySettings;
/**
* ClutterVirtualDeviceType:
*/
typedef enum
{
CLUTTER_VIRTUAL_DEVICE_TYPE_NONE = 0,
CLUTTER_VIRTUAL_DEVICE_TYPE_KEYBOARD = 1 << 0,
CLUTTER_VIRTUAL_DEVICE_TYPE_POINTER = 1 << 1,
CLUTTER_VIRTUAL_DEVICE_TYPE_TOUCHSCREEN = 1 << 2,
} ClutterVirtualDeviceType;
typedef struct _ClutterSeatClass ClutterSeatClass;
struct _ClutterSeatClass
{
GObjectClass parent_class;
ClutterInputDevice * (* get_pointer) (ClutterSeat *seat);
ClutterInputDevice * (* get_keyboard) (ClutterSeat *seat);
GList * (* list_devices) (ClutterSeat *seat);
void (* bell_notify) (ClutterSeat *seat);
ClutterKeymap * (* get_keymap) (ClutterSeat *seat);
void (* compress_motion) (ClutterSeat *seat,
ClutterEvent *event,
const ClutterEvent *to_discard);
void (* warp_pointer) (ClutterSeat *seat,
int x,
int y);
/* Event platform data */
void (* copy_event_data) (ClutterSeat *seat,
const ClutterEvent *src,
ClutterEvent *dest);
void (* free_event_data) (ClutterSeat *seat,
ClutterEvent *event);
/* Keyboard accessibility */
void (* apply_kbd_a11y_settings) (ClutterSeat *seat,
ClutterKbdA11ySettings *settings);
/* Virtual devices */
ClutterVirtualInputDevice * (* create_virtual_device) (ClutterSeat *seat,
ClutterInputDeviceType device_type);
ClutterVirtualDeviceType (* get_supported_virtual_device_types) (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);
CLUTTER_EXPORT
void clutter_seat_bell_notify (ClutterSeat *seat);
CLUTTER_EXPORT
ClutterKeymap * clutter_seat_get_keymap (ClutterSeat *seat);
CLUTTER_EXPORT
void clutter_seat_set_kbd_a11y_settings (ClutterSeat *seat,
ClutterKbdA11ySettings *settings);
CLUTTER_EXPORT
void clutter_seat_get_kbd_a11y_settings (ClutterSeat *seat,
ClutterKbdA11ySettings *settings);
CLUTTER_EXPORT
void clutter_seat_ensure_a11y_state (ClutterSeat *seat);
CLUTTER_EXPORT
void clutter_seat_set_pointer_a11y_settings (ClutterSeat *seat,
ClutterPointerA11ySettings *settings);
CLUTTER_EXPORT
void clutter_seat_get_pointer_a11y_settings (ClutterSeat *seat,
ClutterPointerA11ySettings *settings);
CLUTTER_EXPORT
void clutter_seat_set_pointer_a11y_dwell_click_type (ClutterSeat *seat,
ClutterPointerA11yDwellClickType click_type);
CLUTTER_EXPORT
ClutterVirtualInputDevice *clutter_seat_create_virtual_device (ClutterSeat *seat,
ClutterInputDeviceType device_type);
CLUTTER_EXPORT
ClutterVirtualDeviceType clutter_seat_get_supported_virtual_device_types (ClutterSeat *seat);
void clutter_seat_compress_motion (ClutterSeat *seat,
ClutterEvent *event,
const ClutterEvent *to_discard);
CLUTTER_EXPORT
void clutter_seat_warp_pointer (ClutterSeat *seat,
int x,
int y);
#endif /* CLUTTER_SEAT_H */

View File

@ -60,10 +60,10 @@
#include "clutter-color.h"
#include "clutter-container.h"
#include "clutter-debug.h"
#include "clutter-device-manager-private.h"
#include "clutter-enum-types.h"
#include "clutter-event-private.h"
#include "clutter-id-pool.h"
#include "clutter-input-device-private.h"
#include "clutter-main.h"
#include "clutter-marshal.h"
#include "clutter-master-clock.h"
@ -1248,11 +1248,9 @@ _clutter_stage_process_queued_events (ClutterStage *stage)
if (next_event->type == CLUTTER_MOTION)
{
ClutterDeviceManager *device_manager =
clutter_device_manager_get_default ();
ClutterSeat *seat = clutter_input_device_get_seat (device);
_clutter_device_manager_compress_motion (device_manager,
next_event, event);
clutter_seat_compress_motion (seat, next_event, event);
}
goto next_event;
@ -1391,20 +1389,22 @@ static GSList *
_clutter_stage_check_updated_pointers (ClutterStage *stage)
{
ClutterStagePrivate *priv = stage->priv;
ClutterDeviceManager *device_manager;
ClutterBackend *backend;
ClutterSeat *seat;
GSList *updating = NULL;
const GSList *devices;
GList *l, *devices;
cairo_region_t *clip;
graphene_point_t point;
clip = _clutter_stage_window_get_redraw_clip (priv->impl);
device_manager = clutter_device_manager_get_default ();
devices = clutter_device_manager_peek_devices (device_manager);
backend = clutter_get_default_backend ();
seat = clutter_backend_get_default_seat (backend);
devices = clutter_seat_list_devices (seat);
for (; devices != NULL; devices = devices->next)
for (l = devices; l; l = l->next)
{
ClutterInputDevice *dev = devices->data;
ClutterInputDevice *dev = l->data;
if (clutter_input_device_get_device_mode (dev) !=
CLUTTER_INPUT_MODE_MASTER)
@ -1433,6 +1433,8 @@ _clutter_stage_check_updated_pointers (ClutterStage *stage)
}
}
g_list_free (devices);
return updating;
}

View File

@ -759,7 +759,14 @@ clutter_text_create_layout_no_cache (ClutterText *text,
ClutterTextDirection text_dir;
if (clutter_actor_has_key_focus (CLUTTER_ACTOR (text)))
pango_dir = _clutter_backend_get_keymap_direction (backend);
{
ClutterSeat *seat;
ClutterKeymap *keymap;
seat = clutter_backend_get_default_seat (backend);
keymap = clutter_seat_get_keymap (seat);
pango_dir = clutter_keymap_get_direction (keymap);
}
else
{
text_dir = clutter_actor_get_text_direction (CLUTTER_ACTOR (text));

View File

@ -27,15 +27,15 @@
#include "clutter-virtual-input-device.h"
#include "clutter-device-manager.h"
#include "clutter-private.h"
#include "clutter-enum-types.h"
#include "clutter-private.h"
#include "clutter-seat.h"
enum
{
PROP_0,
PROP_DEVICE_MANAGER,
PROP_SEAT,
PROP_DEVICE_TYPE,
PROP_LAST
@ -45,7 +45,7 @@ static GParamSpec *obj_props[PROP_LAST];
typedef struct _ClutterVirtualInputDevicePrivate
{
ClutterDeviceManager *manager;
ClutterSeat *seat;
ClutterInputDeviceType device_type;
} ClutterVirtualInputDevicePrivate;
@ -181,23 +181,6 @@ clutter_virtual_input_device_notify_touch_up (ClutterVirtualInputDevice *virtual
slot);
}
/**
* clutter_virtual_input_device_get_manager:
* @virtual_device: a virtual device
*
* Gets the device manager of this virtual device.
*
* Returns: (transfer none): The #ClutterDeviceManager of this virtual device
**/
ClutterDeviceManager *
clutter_virtual_input_device_get_manager (ClutterVirtualInputDevice *virtual_device)
{
ClutterVirtualInputDevicePrivate *priv =
clutter_virtual_input_device_get_instance_private (virtual_device);
return priv->manager;
}
int
clutter_virtual_input_device_get_device_type (ClutterVirtualInputDevice *virtual_device)
{
@ -220,8 +203,8 @@ clutter_virtual_input_device_get_property (GObject *object,
switch (prop_id)
{
case PROP_DEVICE_MANAGER:
g_value_set_object (value, priv->manager);
case PROP_SEAT:
g_value_set_object (value, priv->seat);
break;
case PROP_DEVICE_TYPE:
g_value_set_enum (value, priv->device_type);
@ -245,8 +228,8 @@ clutter_virtual_input_device_set_property (GObject *object,
switch (prop_id)
{
case PROP_DEVICE_MANAGER:
priv->manager = g_value_get_object (value);
case PROP_SEAT:
priv->seat = g_value_get_object (value);
break;
case PROP_DEVICE_TYPE:
priv->device_type = g_value_get_enum (value);
@ -270,11 +253,11 @@ clutter_virtual_input_device_class_init (ClutterVirtualInputDeviceClass *klass)
object_class->get_property = clutter_virtual_input_device_get_property;
object_class->set_property = clutter_virtual_input_device_set_property;
obj_props[PROP_DEVICE_MANAGER] =
g_param_spec_object ("device-manager",
P_("Device Manager"),
P_("The device manager instance"),
CLUTTER_TYPE_DEVICE_MANAGER,
obj_props[PROP_SEAT] =
g_param_spec_object ("seat",
P_("Seat"),
P_("Seat"),
CLUTTER_TYPE_SEAT,
CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
obj_props[PROP_DEVICE_TYPE] =
g_param_spec_enum ("device-type",

View File

@ -27,7 +27,7 @@
#include <glib-object.h>
#include <stdint.h>
#include "clutter-device-manager.h"
#include "clutter-seat.h"
#define CLUTTER_TYPE_VIRTUAL_INPUT_DEVICE (clutter_virtual_input_device_get_type ())
@ -169,9 +169,6 @@ void clutter_virtual_input_device_notify_touch_up (ClutterVirtualInputDevice *vi
uint64_t time_us,
int slot);
CLUTTER_EXPORT
ClutterDeviceManager * clutter_virtual_input_device_get_manager (ClutterVirtualInputDevice *virtual_device);
CLUTTER_EXPORT
int clutter_virtual_input_device_get_device_type (ClutterVirtualInputDevice *virtual_device);

View File

@ -56,7 +56,6 @@
#include "clutter-content.h"
#include "clutter-deform-effect.h"
#include "clutter-desaturate-effect.h"
#include "clutter-device-manager.h"
#include "clutter-drag-action.h"
#include "clutter-drop-action.h"
#include "clutter-effect.h"

View File

@ -27,11 +27,11 @@
#define __CLUTTER_BACKEND_EGL_NATIVE_H__
#include <glib-object.h>
#include <gio/gio.h>
#include <cogl/cogl.h>
#include <cogl/cogl-egl.h>
#include <clutter/clutter-event.h>
#include <clutter/clutter-backend.h>
#include <clutter/clutter-device-manager.h>
#include "clutter-backend-private.h"
@ -53,9 +53,6 @@ struct _ClutterBackendEglNative
{
ClutterBackend parent_instance;
/* device manager (ie evdev) */
ClutterDeviceManager *device_manager;
/* event source */
GSource *event_source;

View File

@ -30,7 +30,6 @@ clutter_headers = [
'clutter-deform-effect.h',
'clutter-deprecated.h',
'clutter-desaturate-effect.h',
'clutter-device-manager.h',
'clutter-drag-action.h',
'clutter-drop-action.h',
'clutter-effect.h',
@ -68,6 +67,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',
@ -116,7 +116,6 @@ clutter_sources = [
'clutter-content.c',
'clutter-deform-effect.c',
'clutter-desaturate-effect.c',
'clutter-device-manager.c',
'clutter-drag-action.c',
'clutter-drop-action.c',
'clutter-effect.c',
@ -157,6 +156,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',
@ -186,7 +186,6 @@ clutter_private_headers = [
'clutter-constraint-private.h',
'clutter-content-private.h',
'clutter-debug.h',
'clutter-device-manager-private.h',
'clutter-easing.h',
'clutter-effect-private.h',
'clutter-event-private.h',
@ -194,6 +193,7 @@ clutter_private_headers = [
'clutter-graphene.h',
'clutter-gesture-action-private.h',
'clutter-id-pool.h',
'clutter-input-device-private.h',
'clutter-input-focus-private.h',
'clutter-input-method-private.h',
'clutter-input-pointer-a11y-private.h',

View File

@ -47,7 +47,6 @@
#include "clutter-backend.h"
#include "clutter-debug.h"
#include "clutter-device-manager-private.h"
#include "clutter-event-private.h"
#include "clutter-main.h"
#include "clutter-private.h"

View File

@ -86,8 +86,6 @@ struct _ClutterBackendX11
Time last_event_time;
ClutterDeviceManager *device_manager;
XSettingsClient *xsettings;
Window xsettings_xwin;
};

View File

@ -82,11 +82,6 @@ struct _MetaBackendClass
void (* finish_touch_sequence) (MetaBackend *backend,
ClutterEventSequence *sequence,
MetaSequenceState state);
void (* warp_pointer) (MetaBackend *backend,
int x,
int y);
MetaLogicalMonitor * (* get_current_logical_monitor) (MetaBackend *backend);
void (* set_keymap) (MetaBackend *backend,
@ -106,12 +101,6 @@ struct _MetaBackendClass
void (* update_screen_size) (MetaBackend *backend, int width, int height);
void (* select_stage_events) (MetaBackend *backend);
gboolean (* get_relative_motion_deltas) (MetaBackend *backend,
const ClutterEvent *event,
double *dx,
double *dy,
double *dx_unaccel,
double *dy_unaccel);
void (* set_numlock) (MetaBackend *backend,
gboolean numlock_state);
@ -121,8 +110,8 @@ void meta_init_backend (GType backend_gtype);
ClutterBackend * meta_backend_get_clutter_backend (MetaBackend *backend);
MetaIdleMonitor * meta_backend_get_idle_monitor (MetaBackend *backend,
int device_id);
MetaIdleMonitor * meta_backend_get_idle_monitor (MetaBackend *backend,
ClutterInputDevice *device);
void meta_backend_foreach_device_monitor (MetaBackend *backend,
GFunc func,
gpointer user_data);
@ -151,10 +140,6 @@ void meta_backend_finish_touch_sequence (MetaBackend *backend,
ClutterEventSequence *sequence,
MetaSequenceState state);
void meta_backend_warp_pointer (MetaBackend *backend,
int x,
int y);
MetaLogicalMonitor * meta_backend_get_current_logical_monitor (MetaBackend *backend);
struct xkb_keymap * meta_backend_get_keymap (MetaBackend *backend);
@ -167,15 +152,8 @@ 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);
gboolean meta_backend_get_relative_motion_deltas (MetaBackend *backend,
const ClutterEvent *event,
double *dx,
double *dy,
double *dx_unaccel,
double *dy_unaccel);
void meta_backend_update_last_device (MetaBackend *backend,
ClutterInputDevice *device);
MetaPointerConstraint * meta_backend_get_client_pointer_constraint (MetaBackend *backend);
void meta_backend_set_client_pointer_constraint (MetaBackend *backend,

View File

@ -81,8 +81,6 @@
#include "backends/native/meta-backend-native.h"
#endif
#define META_IDLE_MONITOR_CORE_DEVICE 0
enum
{
KEYMAP_CHANGED,
@ -148,7 +146,7 @@ struct _MetaBackendPrivate
GHashTable *device_monitors;
int current_device_id;
ClutterInputDevice *current_device;
MetaPointerConstraint *client_pointer_constraint;
MetaDnd *dnd;
@ -181,9 +179,11 @@ meta_backend_finalize (GObject *object)
if (priv->keymap_state_changed_id)
{
ClutterSeat *seat;
ClutterKeymap *keymap;
keymap = clutter_backend_get_keymap (priv->clutter_backend);
seat = clutter_backend_get_default_seat (priv->clutter_backend);
keymap = clutter_seat_get_keymap (seat);
g_clear_signal_handler (&priv->keymap_state_changed_id, keymap);
}
@ -237,6 +237,7 @@ reset_pointer_position (MetaBackend *backend)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
MetaMonitorManager *monitor_manager = priv->monitor_manager;
ClutterSeat *seat = clutter_backend_get_default_seat (priv->clutter_backend);
MetaLogicalMonitor *primary;
primary =
@ -244,7 +245,7 @@ reset_pointer_position (MetaBackend *backend)
/* Move the pointer out of the way to avoid hovering over reactive
* elements (e.g. users list at login) causing undesired behaviour. */
meta_backend_warp_pointer (backend,
clutter_seat_warp_pointer (seat,
primary->rect.x + primary->rect.width * 0.9,
primary->rect.y + primary->rect.height * 0.9);
}
@ -255,8 +256,8 @@ meta_backend_monitors_changed (MetaBackend *backend)
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
ClutterInputDevice *device = clutter_device_manager_get_core_device (manager, CLUTTER_POINTER_DEVICE);
ClutterSeat *seat = clutter_backend_get_default_seat (priv->clutter_backend);
ClutterInputDevice *device = clutter_seat_get_pointer (seat);
graphene_point_t point;
meta_backend_sync_screen_size (backend);
@ -309,55 +310,52 @@ meta_backend_foreach_device_monitor (MetaBackend *backend,
}
static MetaIdleMonitor *
meta_backend_create_idle_monitor (MetaBackend *backend,
int device_id)
meta_backend_create_idle_monitor (MetaBackend *backend,
ClutterInputDevice *device)
{
return g_object_new (META_TYPE_IDLE_MONITOR,
"device-id", device_id,
"device", device,
NULL);
}
static void
create_device_monitor (MetaBackend *backend,
int device_id)
create_device_monitor (MetaBackend *backend,
ClutterInputDevice *device)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
MetaIdleMonitor *idle_monitor;
g_assert (g_hash_table_lookup (priv->device_monitors, &device_id) == NULL);
if (g_hash_table_contains (priv->device_monitors, device))
return;
idle_monitor = meta_backend_create_idle_monitor (backend, device_id);
g_hash_table_insert (priv->device_monitors, &idle_monitor->device_id, idle_monitor);
idle_monitor = meta_backend_create_idle_monitor (backend, device);
g_hash_table_insert (priv->device_monitors, device, idle_monitor);
}
static void
destroy_device_monitor (MetaBackend *backend,
int device_id)
destroy_device_monitor (MetaBackend *backend,
ClutterInputDevice *device)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
g_hash_table_remove (priv->device_monitors, &device_id);
g_hash_table_remove (priv->device_monitors, device);
}
static void
meta_backend_monitor_device (MetaBackend *backend,
ClutterInputDevice *device)
{
int device_id;
device_id = clutter_input_device_get_device_id (device);
create_device_monitor (backend, device_id);
create_device_monitor (backend, device);
}
static void
on_device_added (ClutterDeviceManager *device_manager,
ClutterInputDevice *device,
gpointer user_data)
on_device_added (ClutterSeat *seat,
ClutterInputDevice *device,
gpointer user_data)
{
MetaBackend *backend = META_BACKEND (user_data);
int device_id = clutter_input_device_get_device_id (device);
create_device_monitor (backend, device_id);
create_device_monitor (backend, device);
}
static inline gboolean
@ -368,15 +366,16 @@ device_is_slave_touchscreen (ClutterInputDevice *device)
}
static inline gboolean
check_has_pointing_device (ClutterDeviceManager *manager)
check_has_pointing_device (ClutterSeat *seat)
{
const GSList *devices;
GList *l, *devices;
gboolean found = FALSE;
devices = clutter_device_manager_peek_devices (manager);
devices = clutter_seat_list_devices (seat);
for (; devices; devices = devices->next)
for (l = devices; l; l = l->next)
{
ClutterInputDevice *device = devices->data;
ClutterInputDevice *device = l->data;
if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_MASTER)
continue;
@ -384,55 +383,63 @@ check_has_pointing_device (ClutterDeviceManager *manager)
clutter_input_device_get_device_type (device) == CLUTTER_KEYBOARD_DEVICE)
continue;
return TRUE;
found = TRUE;
break;
}
return FALSE;
g_list_free (devices);
return found;
}
static inline gboolean
check_has_slave_touchscreen (ClutterDeviceManager *manager)
check_has_slave_touchscreen (ClutterSeat *seat)
{
const GSList *devices;
GList *l, *devices;
gboolean found = FALSE;
devices = clutter_device_manager_peek_devices (manager);
devices = clutter_seat_list_devices (seat);
for (; devices; devices = devices->next)
for (l = devices; l; l = l->next)
{
ClutterInputDevice *device = devices->data;
ClutterInputDevice *device = l->data;
if (clutter_input_device_get_device_mode (device) != CLUTTER_INPUT_MODE_MASTER &&
clutter_input_device_get_device_type (device) == CLUTTER_TOUCHSCREEN_DEVICE)
return TRUE;
{
found = TRUE;
break;
}
}
return FALSE;
g_list_free (devices);
return found;
}
static void
on_device_removed (ClutterDeviceManager *device_manager,
ClutterInputDevice *device,
gpointer user_data)
on_device_removed (ClutterSeat *seat,
ClutterInputDevice *device,
gpointer user_data)
{
MetaBackend *backend = META_BACKEND (user_data);
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
int device_id = clutter_input_device_get_device_id (device);
destroy_device_monitor (backend, device_id);
destroy_device_monitor (backend, device);
/* 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);
has_touchscreen = check_has_slave_touchscreen (seat);
if (device_type == CLUTTER_TOUCHSCREEN_DEVICE && has_touchscreen)
{
@ -441,7 +448,7 @@ on_device_removed (ClutterDeviceManager *device_manager,
}
else if (device_type != CLUTTER_KEYBOARD_DEVICE)
{
has_pointing_device = check_has_pointing_device (device_manager);
has_pointing_device = check_has_pointing_device (seat);
meta_cursor_tracker_set_pointer_visible (cursor_tracker,
has_pointing_device &&
!has_touchscreen);
@ -450,33 +457,34 @@ on_device_removed (ClutterDeviceManager *device_manager,
}
static void
create_device_monitors (MetaBackend *backend,
ClutterDeviceManager *device_manager)
create_device_monitors (MetaBackend *backend,
ClutterSeat *seat)
{
const GSList *devices;
const GSList *l;
GList *l, *devices;
create_device_monitor (backend, META_IDLE_MONITOR_CORE_DEVICE);
create_device_monitor (backend, clutter_seat_get_pointer (seat));
create_device_monitor (backend, clutter_seat_get_keyboard (seat));
devices = clutter_device_manager_peek_devices (device_manager);
devices = clutter_seat_list_devices (seat);
for (l = devices; l; l = l->next)
{
ClutterInputDevice *device = l->data;
meta_backend_monitor_device (backend, device);
}
g_list_free (devices);
}
static void
set_initial_pointer_visibility (MetaBackend *backend,
ClutterDeviceManager *device_manager)
set_initial_pointer_visibility (MetaBackend *backend,
ClutterSeat *seat)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
const GSList *devices;
const GSList *l;
GList *l, *devices;
gboolean has_touchscreen = FALSE;
devices = clutter_device_manager_peek_devices (device_manager);
devices = clutter_seat_list_devices (seat);
for (l = devices; l; l = l->next)
{
ClutterInputDevice *device = l->data;
@ -484,6 +492,7 @@ set_initial_pointer_visibility (MetaBackend *backend,
has_touchscreen |= device_is_slave_touchscreen (device);
}
g_list_free (devices);
meta_cursor_tracker_set_pointer_visible (priv->cursor_tracker,
!has_touchscreen);
}
@ -498,8 +507,8 @@ static void
meta_backend_real_post_init (MetaBackend *backend)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
ClutterDeviceManager *device_manager = clutter_device_manager_get_default ();
ClutterKeymap *keymap = clutter_backend_get_keymap (priv->clutter_backend);
ClutterSeat *seat = clutter_backend_get_default_seat (priv->clutter_backend);
ClutterKeymap *keymap = clutter_seat_get_keymap (seat);
priv->stage = meta_stage_new (backend);
clutter_actor_realize (priv->stage);
@ -512,17 +521,16 @@ meta_backend_real_post_init (MetaBackend *backend)
priv->cursor_renderer = META_BACKEND_GET_CLASS (backend)->create_cursor_renderer (backend);
priv->device_monitors =
g_hash_table_new_full (g_int_hash, g_int_equal,
NULL, (GDestroyNotify) g_object_unref);
g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) g_object_unref);
create_device_monitors (backend, device_manager);
create_device_monitors (backend, seat);
g_signal_connect_object (device_manager, "device-added",
g_signal_connect_object (seat, "device-added",
G_CALLBACK (on_device_added), backend, 0);
g_signal_connect_object (device_manager, "device-removed",
g_signal_connect_object (seat, "device-removed",
G_CALLBACK (on_device_removed), backend, 0);
set_initial_pointer_visibility (backend, device_manager);
set_initial_pointer_visibility (backend, seat);
priv->input_settings = meta_backend_create_input_settings (backend);
@ -581,17 +589,6 @@ meta_backend_real_select_stage_events (MetaBackend *backend)
/* Do nothing */
}
static gboolean
meta_backend_real_get_relative_motion_deltas (MetaBackend *backend,
const ClutterEvent *event,
double *dx,
double *dy,
double *dx_unaccel,
double *dy_unaccel)
{
return FALSE;
}
static gboolean
meta_backend_real_is_lid_closed (MetaBackend *backend)
{
@ -744,7 +741,6 @@ meta_backend_class_init (MetaBackendClass *klass)
klass->grab_device = meta_backend_real_grab_device;
klass->ungrab_device = meta_backend_real_ungrab_device;
klass->select_stage_events = meta_backend_real_select_stage_events;
klass->get_relative_motion_deltas = meta_backend_real_get_relative_motion_deltas;
klass->is_lid_closed = meta_backend_real_is_lid_closed;
signals[KEYMAP_CHANGED] =
@ -767,7 +763,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),
@ -921,12 +917,12 @@ meta_backend_post_init (MetaBackend *backend)
* meta_backend_get_idle_monitor: (skip)
*/
MetaIdleMonitor *
meta_backend_get_idle_monitor (MetaBackend *backend,
int device_id)
meta_backend_get_idle_monitor (MetaBackend *backend,
ClutterInputDevice *device)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
return g_hash_table_lookup (priv->device_monitors, &device_id);
return g_hash_table_lookup (priv->device_monitors, device);
}
/**
@ -1072,17 +1068,6 @@ meta_backend_finish_touch_sequence (MetaBackend *backend,
state);
}
/**
* meta_backend_warp_pointer: (skip)
*/
void
meta_backend_warp_pointer (MetaBackend *backend,
int x,
int y)
{
META_BACKEND_GET_CLASS (backend)->warp_pointer (backend, x, y);
}
MetaLogicalMonitor *
meta_backend_get_current_logical_monitor (MetaBackend *backend)
{
@ -1168,17 +1153,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)
{
@ -1196,24 +1176,19 @@ update_last_device (MetaBackend *backend)
}
void
meta_backend_update_last_device (MetaBackend *backend,
int device_id)
meta_backend_update_last_device (MetaBackend *backend,
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)
{
@ -1224,21 +1199,6 @@ meta_backend_update_last_device (MetaBackend *backend,
}
}
gboolean
meta_backend_get_relative_motion_deltas (MetaBackend *backend,
const ClutterEvent *event,
double *dx,
double *dy,
double *dx_unaccel,
double *dy_unaccel)
{
MetaBackendClass *klass = META_BACKEND_GET_CLASS (backend);
return klass->get_relative_motion_deltas (backend,
event,
dx, dy,
dx_unaccel, dy_unaccel);
}
MetaPointerConstraint *
meta_backend_get_client_pointer_constraint (MetaBackend *backend)
{

View File

@ -405,12 +405,12 @@ get_pointer_position_clutter (int *x,
int *y,
int *mods)
{
ClutterDeviceManager *cmanager;
ClutterSeat *seat;
ClutterInputDevice *cdevice;
graphene_point_t point;
cmanager = clutter_device_manager_get_default ();
cdevice = clutter_device_manager_get_core_device (cmanager, CLUTTER_POINTER_DEVICE);
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
cdevice = clutter_seat_get_pointer (seat);
clutter_input_device_get_coords (cdevice, NULL, &point);
if (x)

View File

@ -210,7 +210,7 @@ create_monitor_skeleton (GDBusObjectManagerServer *manager,
}
static void
on_device_added (ClutterDeviceManager *device_manager,
on_device_added (ClutterSeat *seat,
ClutterInputDevice *device,
GDBusObjectManagerServer *manager)
{
@ -220,7 +220,7 @@ on_device_added (ClutterDeviceManager *device_manager,
char *path;
device_id = clutter_input_device_get_device_id (device);
monitor = meta_idle_monitor_get_for_device (device_id);
monitor = meta_idle_monitor_get_for_device (device);
path = g_strdup_printf ("/org/gnome/Mutter/IdleMonitor/Device%d", device_id);
create_monitor_skeleton (manager, monitor, path);
@ -228,7 +228,7 @@ on_device_added (ClutterDeviceManager *device_manager,
}
static void
on_device_removed (ClutterDeviceManager *device_manager,
on_device_removed (ClutterSeat *seat,
ClutterInputDevice *device,
GDBusObjectManagerServer *manager)
{
@ -247,9 +247,9 @@ on_bus_acquired (GDBusConnection *connection,
gpointer user_data)
{
GDBusObjectManagerServer *manager;
ClutterDeviceManager *device_manager;
MetaIdleMonitor *monitor;
GSList *devices, *iter;
ClutterSeat *seat;
GList *devices, *iter;
char *path;
manager = g_dbus_object_manager_server_new ("/org/gnome/Mutter/IdleMonitor");
@ -261,17 +261,17 @@ on_bus_acquired (GDBusConnection *connection,
create_monitor_skeleton (manager, monitor, path);
g_free (path);
device_manager = clutter_device_manager_get_default ();
devices = clutter_device_manager_list_devices (device_manager);
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
devices = clutter_seat_list_devices (seat);
for (iter = devices; iter; iter = iter->next)
on_device_added (device_manager, iter->data, manager);
on_device_added (seat, iter->data, manager);
g_slist_free (devices);
g_list_free (devices);
g_signal_connect_object (device_manager, "device-added",
g_signal_connect_object (seat, "device-added",
G_CALLBACK (on_device_added), manager, 0);
g_signal_connect_object (device_manager, "device-removed",
g_signal_connect_object (seat, "device-removed",
G_CALLBACK (on_device_removed), manager, 0);
g_dbus_object_manager_server_set_connection (manager, connection);

View File

@ -45,7 +45,7 @@ struct _MetaIdleMonitor
GDBusProxy *session_proxy;
gboolean inhibited;
GHashTable *watches;
int device_id;
ClutterInputDevice *device;
guint64 last_event_time;
};

View File

@ -46,7 +46,7 @@ G_STATIC_ASSERT(sizeof(unsigned long) == sizeof(gpointer));
enum
{
PROP_0,
PROP_DEVICE_ID,
PROP_DEVICE,
PROP_LAST,
};
@ -99,8 +99,8 @@ meta_idle_monitor_get_property (GObject *object,
switch (prop_id)
{
case PROP_DEVICE_ID:
g_value_set_int (value, monitor->device_id);
case PROP_DEVICE:
g_value_set_object (value, monitor->device);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -117,8 +117,8 @@ meta_idle_monitor_set_property (GObject *object,
MetaIdleMonitor *monitor = META_IDLE_MONITOR (object);
switch (prop_id)
{
case PROP_DEVICE_ID:
monitor->device_id = g_value_get_int (value);
case PROP_DEVICE:
monitor->device = g_value_get_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -136,17 +136,18 @@ meta_idle_monitor_class_init (MetaIdleMonitorClass *klass)
object_class->set_property = meta_idle_monitor_set_property;
/**
* MetaIdleMonitor:device_id:
* MetaIdleMonitor:device:
*
* The device to listen to idletime on.
*/
obj_props[PROP_DEVICE_ID] =
g_param_spec_int ("device-id",
"Device ID",
"The device to listen to idletime on",
0, 255, 0,
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (object_class, PROP_DEVICE_ID, obj_props[PROP_DEVICE_ID]);
obj_props[PROP_DEVICE] =
g_param_spec_object ("device",
"Device",
"The device to listen to idletime on",
CLUTTER_TYPE_INPUT_DEVICE,
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (object_class, PROP_DEVICE, obj_props[PROP_DEVICE]);
}
static void
@ -276,22 +277,25 @@ MetaIdleMonitor *
meta_idle_monitor_get_core (void)
{
MetaBackend *backend = meta_get_backend ();
return meta_backend_get_idle_monitor (backend, 0);
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
ClutterSeat *seat = clutter_backend_get_default_seat (clutter_backend);
return meta_backend_get_idle_monitor (backend, clutter_seat_get_pointer (seat));
}
/**
* meta_idle_monitor_get_for_device:
* @device_id: the device to get the idle time for.
* @device: the device to get the idle time for.
*
* Returns: (transfer none): a new #MetaIdleMonitor that tracks the
* device-specific idletime for @device. To track server-global idletime
* for all devices, use meta_idle_monitor_get_core().
*/
MetaIdleMonitor *
meta_idle_monitor_get_for_device (int device_id)
meta_idle_monitor_get_for_device (ClutterInputDevice *device)
{
MetaBackend *backend = meta_get_backend ();
return meta_backend_get_idle_monitor (backend, device_id);
return meta_backend_get_idle_monitor (backend, device);
}
static guint32

View File

@ -40,7 +40,7 @@ struct _MetaInputMapper
{
GObject parent_instance;
MetaMonitorManager *monitor_manager;
ClutterDeviceManager *input_device_manager;
ClutterSeat *seat;
GHashTable *input_devices; /* ClutterInputDevice -> MetaMapperInputInfo */
GHashTable *output_devices; /* MetaLogicalMonitor -> MetaMapperOutputInfo */
#ifdef HAVE_LIBGUDEV
@ -525,9 +525,9 @@ input_mapper_monitors_changed_cb (MetaMonitorManager *monitor_manager,
}
static void
input_mapper_device_removed_cb (ClutterDeviceManager *device_manager,
ClutterInputDevice *device,
MetaInputMapper *mapper)
input_mapper_device_removed_cb (ClutterSeat *seat,
ClutterInputDevice *device,
MetaInputMapper *mapper)
{
meta_input_mapper_remove_device (mapper, device);
}
@ -540,7 +540,7 @@ meta_input_mapper_finalize (GObject *object)
g_signal_handlers_disconnect_by_func (mapper->monitor_manager,
input_mapper_monitors_changed_cb,
mapper);
g_signal_handlers_disconnect_by_func (mapper->input_device_manager,
g_signal_handlers_disconnect_by_func (mapper->seat,
input_mapper_device_removed_cb,
mapper);
@ -568,8 +568,8 @@ meta_input_mapper_constructed (GObject *object)
mapper->udev_client = g_udev_client_new (udev_subsystems);
#endif
mapper->input_device_manager = clutter_device_manager_get_default ();
g_signal_connect (mapper->input_device_manager, "device-removed",
mapper->seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
g_signal_connect (mapper->seat, "device-removed",
G_CALLBACK (input_mapper_device_removed_cb), mapper);
backend = meta_get_backend ();

View File

@ -67,7 +67,7 @@ struct _DeviceMappingInfo
struct _MetaInputSettingsPrivate
{
ClutterDeviceManager *device_manager;
ClutterSeat *seat;
MetaMonitorManager *monitor_manager;
gulong monitors_changed_id;
@ -129,15 +129,15 @@ meta_input_settings_get_devices (MetaInputSettings *settings,
ClutterInputDeviceType type)
{
MetaInputSettingsPrivate *priv;
const GSList *devices;
GList *l, *devices;
GSList *list = NULL;
priv = meta_input_settings_get_instance_private (settings);
devices = clutter_device_manager_peek_devices (priv->device_manager);
devices = clutter_seat_list_devices (priv->seat);
while (devices)
for (l = devices; l; l = l->next)
{
ClutterInputDevice *device = devices->data;
ClutterInputDevice *device = l->data;
if (clutter_input_device_get_device_type (device) == type &&
clutter_input_device_get_device_mode (device) != CLUTTER_INPUT_MODE_MASTER)
@ -146,6 +146,8 @@ meta_input_settings_get_devices (MetaInputSettings *settings,
devices = devices->next;
}
g_list_free (devices);
return list;
}
@ -382,10 +384,9 @@ update_pointer_accel_profile (MetaInputSettings *input_settings,
{
MetaInputSettingsPrivate *priv =
meta_input_settings_get_instance_private (input_settings);
const GSList *devices;
const GSList *l;
GList *l, *devices;
devices = clutter_device_manager_peek_devices (priv->device_manager);
devices = clutter_seat_list_devices (priv->seat);
for (l = devices; l; l = l->next)
{
device = l->data;
@ -397,6 +398,8 @@ update_pointer_accel_profile (MetaInputSettings *input_settings,
do_update_pointer_accel_profile (input_settings, settings,
device, profile);
}
g_list_free (devices);
}
}
@ -737,11 +740,11 @@ update_trackball_scroll_button (MetaInputSettings *input_settings,
}
else if (!device)
{
const GSList *devices;
GList *l, *devices;
devices = clutter_device_manager_peek_devices (priv->device_manager);
devices = clutter_seat_list_devices (priv->seat);
while (devices)
for (l = devices; l; l = l->next)
{
device = devices->data;
@ -750,6 +753,8 @@ update_trackball_scroll_button (MetaInputSettings *input_settings,
devices = devices->next;
}
g_list_free (devices);
}
}
@ -1218,9 +1223,11 @@ load_keyboard_a11y_settings (MetaInputSettings *input_settings,
MetaInputSettingsPrivate *priv = meta_input_settings_get_instance_private (input_settings);
ClutterKbdA11ySettings kbd_a11y_settings = { 0 };
ClutterInputDevice *core_keyboard;
ClutterBackend *backend = clutter_get_default_backend ();
ClutterSeat *seat = clutter_backend_get_default_seat (backend);
guint i;
core_keyboard = clutter_device_manager_get_core_device (priv->device_manager, CLUTTER_KEYBOARD_DEVICE);
core_keyboard = clutter_seat_get_keyboard (priv->seat);
if (device && device != core_keyboard)
return;
@ -1244,14 +1251,14 @@ load_keyboard_a11y_settings (MetaInputSettings *input_settings,
kbd_a11y_settings.mousekeys_accel_time = g_settings_get_int (priv->keyboard_a11y_settings,
"mousekeys-accel-time");
clutter_device_manager_set_kbd_a11y_settings (priv->device_manager, &kbd_a11y_settings);
clutter_seat_set_kbd_a11y_settings (seat, &kbd_a11y_settings);
}
static void
on_keyboard_a11y_settings_changed (ClutterDeviceManager *device_manager,
ClutterKeyboardA11yFlags new_flags,
ClutterKeyboardA11yFlags what_changed,
MetaInputSettings *input_settings)
on_keyboard_a11y_settings_changed (ClutterSeat *seat,
ClutterKeyboardA11yFlags new_flags,
ClutterKeyboardA11yFlags what_changed,
MetaInputSettings *input_settings)
{
MetaInputSettingsPrivate *priv = meta_input_settings_get_instance_private (input_settings);
guint i;
@ -1319,14 +1326,14 @@ load_pointer_a11y_settings (MetaInputSettings *input_settings,
ClutterPointerA11ySettings pointer_a11y_settings;
ClutterInputDevice *core_pointer;
GDesktopMouseDwellMode dwell_mode;
guint i;
core_pointer = clutter_device_manager_get_core_device (priv->device_manager, CLUTTER_POINTER_DEVICE);
core_pointer = clutter_seat_get_pointer (priv->seat);
if (device && device != core_pointer)
return;
clutter_device_manager_get_pointer_a11y_settings (priv->device_manager, &pointer_a11y_settings);
clutter_seat_get_pointer_a11y_settings (CLUTTER_SEAT (priv->seat),
&pointer_a11y_settings);
pointer_a11y_settings.controls = 0;
for (i = 0; i < G_N_ELEMENTS (pointer_a11y_settings_flags_pair); i++)
{
@ -1358,7 +1365,8 @@ load_pointer_a11y_settings (MetaInputSettings *input_settings,
pointer_a11y_settings.dwell_gesture_secondary =
pointer_a11y_dwell_direction_from_setting (input_settings, "dwell-gesture-secondary");
clutter_device_manager_set_pointer_a11y_settings (priv->device_manager, &pointer_a11y_settings);
clutter_seat_set_pointer_a11y_settings (CLUTTER_SEAT (priv->seat),
&pointer_a11y_settings);
}
static void
@ -1746,9 +1754,9 @@ evaluate_two_finger_scrolling (MetaInputSettings *input_settings,
}
static void
meta_input_settings_device_added (ClutterDeviceManager *device_manager,
ClutterInputDevice *device,
MetaInputSettings *input_settings)
meta_input_settings_device_added (ClutterSeat *seat,
ClutterInputDevice *device,
MetaInputSettings *input_settings)
{
if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_MASTER)
return;
@ -1760,9 +1768,9 @@ meta_input_settings_device_added (ClutterDeviceManager *device_manager,
}
static void
meta_input_settings_device_removed (ClutterDeviceManager *device_manager,
ClutterInputDevice *device,
MetaInputSettings *input_settings)
meta_input_settings_device_removed (ClutterSeat *seat,
ClutterInputDevice *device,
MetaInputSettings *input_settings)
{
MetaInputSettingsPrivate *priv;
@ -1813,7 +1821,7 @@ current_tool_info_free (CurrentToolInfo *info)
}
static void
meta_input_settings_tool_changed (ClutterDeviceManager *device_manager,
meta_input_settings_tool_changed (ClutterSeat *seat,
ClutterInputDevice *device,
ClutterInputDeviceTool *tool,
MetaInputSettings *input_settings)
@ -1840,10 +1848,10 @@ static void
check_mappable_devices (MetaInputSettings *input_settings)
{
MetaInputSettingsPrivate *priv;
const GSList *devices, *l;
GList *l, *devices;
priv = meta_input_settings_get_instance_private (input_settings);
devices = clutter_device_manager_peek_devices (priv->device_manager);
devices = clutter_seat_list_devices (priv->seat);
for (l = devices; l; l = l->next)
{
@ -1854,6 +1862,8 @@ check_mappable_devices (MetaInputSettings *input_settings)
check_add_mappable_device (input_settings, device);
}
g_list_free (devices);
}
static void
@ -1924,12 +1934,12 @@ meta_input_settings_init (MetaInputSettings *settings)
MetaInputSettingsPrivate *priv;
priv = meta_input_settings_get_instance_private (settings);
priv->device_manager = clutter_device_manager_get_default ();
g_signal_connect (priv->device_manager, "device-added",
priv->seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
g_signal_connect (priv->seat, "device-added",
G_CALLBACK (meta_input_settings_device_added), settings);
g_signal_connect (priv->device_manager, "device-removed",
g_signal_connect (priv->seat, "device-removed",
G_CALLBACK (meta_input_settings_device_removed), settings);
g_signal_connect (priv->device_manager, "tool-changed",
g_signal_connect (priv->seat, "tool-changed",
G_CALLBACK (meta_input_settings_tool_changed), settings);
priv->mouse_settings = g_settings_new ("org.gnome.desktop.peripherals.mouse");
@ -1957,7 +1967,7 @@ meta_input_settings_init (MetaInputSettings *settings)
priv->keyboard_a11y_settings = g_settings_new ("org.gnome.desktop.a11y.keyboard");
g_signal_connect (priv->keyboard_a11y_settings, "changed",
G_CALLBACK (meta_input_keyboard_a11y_settings_changed), settings);
g_signal_connect (priv->device_manager, "kbd-a11y-flags-changed",
g_signal_connect (priv->seat, "kbd-a11y-flags-changed",
G_CALLBACK (on_keyboard_a11y_settings_changed), settings);
priv->mouse_a11y_settings = g_settings_new ("org.gnome.desktop.a11y.mouse");
@ -2228,11 +2238,15 @@ meta_input_settings_emulate_keybinding (MetaInputSettings *input_settings,
if (!priv->virtual_pad_keyboard)
{
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
ClutterBackend *backend;
ClutterSeat *seat;
backend = clutter_get_default_backend ();
seat = clutter_backend_get_default_seat (backend);
priv->virtual_pad_keyboard =
clutter_device_manager_create_virtual_device (manager,
CLUTTER_KEYBOARD_DEVICE);
clutter_seat_create_virtual_device (seat,
CLUTTER_KEYBOARD_DEVICE);
}
state = is_press ? CLUTTER_KEY_STATE_PRESSED : CLUTTER_KEY_STATE_RELEASED;
@ -2613,6 +2627,7 @@ void
meta_input_settings_maybe_save_numlock_state (MetaInputSettings *input_settings)
{
MetaInputSettingsPrivate *priv;
ClutterSeat *seat;
ClutterKeymap *keymap;
gboolean numlock_state;
@ -2621,7 +2636,8 @@ meta_input_settings_maybe_save_numlock_state (MetaInputSettings *input_settings)
if (!g_settings_get_boolean (priv->keyboard_settings, "remember-numlock-state"))
return;
keymap = clutter_backend_get_keymap (clutter_get_default_backend ());
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
keymap = clutter_seat_get_keymap (seat);
numlock_state = clutter_keymap_get_num_lock_state (keymap);
if (numlock_state == g_settings_get_boolean (priv->keyboard_settings, "numlock-state"))

View File

@ -116,8 +116,8 @@ static gboolean
meta_remote_desktop_session_start (MetaRemoteDesktopSession *session,
GError **error)
{
ClutterDeviceManager *device_manager =
clutter_device_manager_get_default ();
ClutterBackend *backend = clutter_get_default_backend ();
ClutterSeat *seat = clutter_backend_get_default_seat (backend);
g_assert (!session->virtual_pointer && !session->virtual_keyboard);
@ -128,15 +128,11 @@ meta_remote_desktop_session_start (MetaRemoteDesktopSession *session,
}
session->virtual_pointer =
clutter_device_manager_create_virtual_device (device_manager,
CLUTTER_POINTER_DEVICE);
clutter_seat_create_virtual_device (seat, CLUTTER_POINTER_DEVICE);
session->virtual_keyboard =
clutter_device_manager_create_virtual_device (device_manager,
CLUTTER_KEYBOARD_DEVICE);
clutter_seat_create_virtual_device (seat, CLUTTER_KEYBOARD_DEVICE);
session->virtual_touchscreen =
clutter_device_manager_create_virtual_device (device_manager,
CLUTTER_TOUCHSCREEN_DEVICE);
clutter_seat_create_virtual_device (seat, CLUTTER_TOUCHSCREEN_DEVICE);
init_remote_access_handle (session);

View File

@ -234,14 +234,14 @@ meta_remote_desktop_new (MetaDbusSessionWatcher *session_watcher)
static MetaRemoteDesktopDeviceTypes
calculate_supported_device_types (void)
{
ClutterDeviceManager *device_manager =
clutter_device_manager_get_default ();
ClutterBackend *backend = clutter_get_default_backend ();
ClutterSeat *seat = clutter_backend_get_default_seat (backend);
ClutterVirtualDeviceType device_types;
MetaRemoteDesktopDeviceTypes supported_devices =
META_REMOTE_DESKTOP_DEVICE_TYPE_NONE;
device_types =
clutter_device_manager_get_supported_virtual_device_types (device_manager);
clutter_seat_get_supported_virtual_device_types (seat);
if (device_types & CLUTTER_VIRTUAL_DEVICE_TYPE_KEYBOARD)
supported_devices |= META_REMOTE_DESKTOP_DEVICE_TYPE_KEYBOARD;

View File

@ -50,7 +50,6 @@
#include "backends/native/meta-barrier-native.h"
#include "backends/native/meta-clutter-backend-native.h"
#include "backends/native/meta-cursor-renderer-native.h"
#include "backends/native/meta-device-manager-native.h"
#include "backends/native/meta-event-native.h"
#include "backends/native/meta-input-settings-native.h"
#include "backends/native/meta-kms.h"
@ -58,6 +57,7 @@
#include "backends/native/meta-launcher.h"
#include "backends/native/meta-monitor-manager-kms.h"
#include "backends/native/meta-renderer-native.h"
#include "backends/native/meta-seat-native.h"
#include "backends/native/meta-stage-native.h"
#include "cogl/cogl-trace.h"
#include "core/meta-border.h"
@ -340,15 +340,18 @@ meta_backend_native_create_clutter_backend (MetaBackend *backend)
static void
meta_backend_native_post_init (MetaBackend *backend)
{
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
ClutterBackend *clutter_backend = clutter_get_default_backend ();
ClutterSeat *seat = clutter_backend_get_default_seat (clutter_backend);
MetaSettings *settings = meta_backend_get_settings (backend);
META_BACKEND_CLASS (meta_backend_native_parent_class)->post_init (backend);
meta_seat_native_set_pointer_constrain_callback (META_SEAT_NATIVE (seat),
pointer_constrain_callback,
NULL, NULL);
meta_seat_native_set_relative_motion_filter (META_SEAT_NATIVE (seat),
relative_motion_filter,
meta_backend_get_monitor_manager (backend));
meta_device_manager_native_set_pointer_constrain_callback (manager, pointer_constrain_callback,
NULL, NULL);
meta_device_manager_native_set_relative_motion_filter (manager, relative_motion_filter,
meta_backend_get_monitor_manager (backend));
META_BACKEND_CLASS (meta_backend_native_parent_class)->post_init (backend);
if (meta_settings_is_experimental_feature_enabled (settings,
META_EXPERIMENTAL_FEATURE_RT_SCHEDULER))
@ -400,25 +403,6 @@ meta_backend_native_create_input_settings (MetaBackend *backend)
return g_object_new (META_TYPE_INPUT_SETTINGS_NATIVE, NULL);
}
static void
meta_backend_native_warp_pointer (MetaBackend *backend,
int x,
int y)
{
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
ClutterInputDevice *device = clutter_device_manager_get_core_device (manager, CLUTTER_POINTER_DEVICE);
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
/* XXX */
guint32 time_ = 0;
/* Warp the input device pointer state. */
meta_device_manager_native_warp_pointer (device, time_, x, y);
/* Warp displayed pointer cursor. */
meta_cursor_tracker_update_position (cursor_tracker, x, y);
}
static MetaLogicalMonitor *
meta_backend_native_get_current_logical_monitor (MetaBackend *backend)
{
@ -437,10 +421,10 @@ meta_backend_native_set_keymap (MetaBackend *backend,
const char *variants,
const char *options)
{
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
struct xkb_rule_names names;
struct xkb_keymap *keymap;
struct xkb_context *context;
ClutterSeat *seat;
names.rules = DEFAULT_XKB_RULES_FILE;
names.model = DEFAULT_XKB_MODEL;
@ -452,7 +436,8 @@ meta_backend_native_set_keymap (MetaBackend *backend,
keymap = xkb_keymap_new_from_names (context, &names, XKB_KEYMAP_COMPILE_NO_FLAGS);
xkb_context_unref (context);
meta_device_manager_native_set_keyboard_map (manager, keymap);
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
meta_seat_native_set_keyboard_map (META_SEAT_NATIVE (seat), keymap);
meta_backend_notify_keymap_changed (backend);
@ -462,30 +447,34 @@ meta_backend_native_set_keymap (MetaBackend *backend,
static struct xkb_keymap *
meta_backend_native_get_keymap (MetaBackend *backend)
{
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
return meta_device_manager_native_get_keyboard_map (manager);
ClutterSeat *seat;
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
return meta_seat_native_get_keyboard_map (META_SEAT_NATIVE (seat));
}
static xkb_layout_index_t
meta_backend_native_get_keymap_layout_group (MetaBackend *backend)
{
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
ClutterSeat *seat;
return meta_device_manager_native_get_keyboard_layout_index (manager);
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
return meta_seat_native_get_keyboard_layout_index (META_SEAT_NATIVE (seat));
}
static void
meta_backend_native_lock_layout_group (MetaBackend *backend,
guint idx)
{
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
xkb_layout_index_t old_idx;
ClutterSeat *seat;
old_idx = meta_backend_native_get_keymap_layout_group (backend);
if (old_idx == idx)
return;
meta_device_manager_native_set_keyboard_layout_index (manager, idx);
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
meta_seat_native_set_keyboard_layout_index (META_SEAT_NATIVE (seat), idx);
meta_backend_notify_keymap_layout_group_changed (backend, idx);
}
@ -493,21 +482,11 @@ static void
meta_backend_native_set_numlock (MetaBackend *backend,
gboolean numlock_state)
{
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
meta_device_manager_native_set_keyboard_numlock (manager, numlock_state);
}
ClutterSeat *seat;
static gboolean
meta_backend_native_get_relative_motion_deltas (MetaBackend *backend,
const ClutterEvent *event,
double *dx,
double *dy,
double *dx_unaccel,
double *dy_unaccel)
{
return meta_event_native_get_relative_motion (event,
dx, dy,
dx_unaccel, dy_unaccel);
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
meta_seat_native_set_keyboard_numlock (META_SEAT_NATIVE (seat),
numlock_state);
}
static void
@ -707,15 +686,12 @@ meta_backend_native_class_init (MetaBackendNativeClass *klass)
backend_class->create_renderer = meta_backend_native_create_renderer;
backend_class->create_input_settings = meta_backend_native_create_input_settings;
backend_class->warp_pointer = meta_backend_native_warp_pointer;
backend_class->get_current_logical_monitor = meta_backend_native_get_current_logical_monitor;
backend_class->set_keymap = meta_backend_native_set_keymap;
backend_class->get_keymap = meta_backend_native_get_keymap;
backend_class->get_keymap_layout_group = meta_backend_native_get_keymap_layout_group;
backend_class->lock_layout_group = meta_backend_native_lock_layout_group;
backend_class->get_relative_motion_deltas = meta_backend_native_get_relative_motion_deltas;
backend_class->update_screen_size = meta_backend_native_update_screen_size;
backend_class->set_numlock = meta_backend_native_set_numlock;
}
@ -797,11 +773,14 @@ meta_backend_native_pause (MetaBackendNative *native)
meta_backend_get_monitor_manager (backend);
MetaMonitorManagerKms *monitor_manager_kms =
META_MONITOR_MANAGER_KMS (monitor_manager);
ClutterBackend *clutter_backend = clutter_get_default_backend ();
MetaSeatNative *seat =
META_SEAT_NATIVE (clutter_backend_get_default_seat (clutter_backend));
COGL_TRACE_BEGIN_SCOPED (MetaBackendNativePause,
"Backend (pause)");
meta_device_manager_native_release_devices ();
meta_seat_native_release_devices (seat);
clutter_stage_freeze_updates (stage);
disconnect_udev_device_added_handler (native);
@ -819,7 +798,9 @@ void meta_backend_native_resume (MetaBackendNative *native)
META_MONITOR_MANAGER_KMS (monitor_manager);
MetaInputSettings *input_settings;
MetaIdleMonitor *idle_monitor;
ClutterDeviceManager *device_manager;
ClutterBackend *clutter_backend = clutter_get_default_backend ();
MetaSeatNative *seat =
META_SEAT_NATIVE (clutter_backend_get_default_seat (clutter_backend));
COGL_TRACE_BEGIN_SCOPED (MetaBackendNativeResume,
"Backend (resume)");
@ -828,7 +809,7 @@ void meta_backend_native_resume (MetaBackendNative *native)
connect_udev_device_added_handler (native);
meta_device_manager_native_reclaim_devices ();
meta_seat_native_reclaim_devices (seat);
clutter_stage_thaw_updates (stage);
clutter_actor_queue_redraw (CLUTTER_ACTOR (stage));
@ -839,6 +820,5 @@ void meta_backend_native_resume (MetaBackendNative *native)
input_settings = meta_backend_get_input_settings (backend);
meta_input_settings_maybe_restore_numlock_state (input_settings);
device_manager = clutter_device_manager_get_default ();
clutter_device_manager_ensure_a11y_state (device_manager);
clutter_seat_ensure_a11y_state (CLUTTER_SEAT (seat));
}

View File

@ -47,4 +47,6 @@ MetaUdev * meta_backend_native_get_udev (MetaBackendNative *native);
MetaKms * meta_backend_native_get_kms (MetaBackendNative *native);
void meta_backend_native_set_seat_id (const gchar *seat_id);
#endif /* META_BACKEND_NATIVE_H */

View File

@ -44,8 +44,7 @@
#include "backends/meta-backend-private.h"
#include "backends/meta-renderer.h"
#include "backends/native/meta-device-manager-native.h"
#include "backends/native/meta-keymap-native.h"
#include "backends/native/meta-seat-native.h"
#include "backends/native/meta-stage-native.h"
#include "clutter/clutter.h"
#include "core/bell.h"
@ -55,11 +54,12 @@ struct _MetaClutterBackendNative
{
ClutterBackendEglNative parent;
MetaSeatNative *main_seat;
MetaStageNative *stage_native;
MetaKeymapNative *keymap;
MetaDeviceManagerNative *device_manager;
};
static gchar *evdev_seat_id;
G_DEFINE_TYPE (MetaClutterBackendNative, meta_clutter_backend_native,
CLUTTER_TYPE_BACKEND_EGL_NATIVE)
@ -99,39 +99,24 @@ meta_clutter_backend_native_create_stage (ClutterBackend *backend,
return CLUTTER_STAGE_WINDOW (clutter_backend_native->stage_native);
}
static void
meta_clutter_backend_native_bell_notify (ClutterBackend *backend)
{
MetaDisplay *display = meta_get_display ();
meta_bell_notify (display, NULL);
}
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 ClutterKeymap *
meta_clutter_backend_native_get_keymap (ClutterBackend *backend)
{
MetaClutterBackendNative *backend_native = META_CLUTTER_BACKEND_NATIVE (backend);
return CLUTTER_KEYMAP (backend_native->keymap);
}
static void
meta_clutter_backend_native_init_events (ClutterBackend *backend)
{
MetaClutterBackendNative *backend_native = META_CLUTTER_BACKEND_NATIVE (backend);
const gchar *seat_id = evdev_seat_id ? evdev_seat_id : "seat0";
backend_native->keymap = g_object_new (META_TYPE_KEYMAP_NATIVE, NULL);
backend_native->device_manager = g_object_new (META_TYPE_DEVICE_MANAGER_NATIVE,
"backend", backend,
NULL);
backend_native->main_seat = g_object_new (META_TYPE_SEAT_NATIVE,
"backend", backend,
"seat-id", seat_id,
NULL);
}
static ClutterSeat *
meta_clutter_backend_native_get_default_seat (ClutterBackend *backend)
{
MetaClutterBackendNative *backend_native = META_CLUTTER_BACKEND_NATIVE (backend);
return CLUTTER_SEAT (backend_native->main_seat);
}
static void
@ -146,8 +131,21 @@ 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->bell_notify = meta_clutter_backend_native_bell_notify;
clutter_backend_class->get_device_manager = meta_clutter_backend_native_get_device_manager;
clutter_backend_class->get_keymap = meta_clutter_backend_native_get_keymap;
clutter_backend_class->init_events = meta_clutter_backend_native_init_events;
clutter_backend_class->get_default_seat = meta_clutter_backend_native_get_default_seat;
}
/**
* meta_cluter_backend_native_set_seat_id:
* @seat_id: The seat ID
*
* Sets the seat to assign to the libinput context.
*
* For reliable effects, this function must be called before clutter_init().
*/
void
meta_clutter_backend_native_set_seat_id (const gchar *seat_id)
{
g_free (evdev_seat_id);
evdev_seat_id = g_strdup (seat_id);
}

View File

@ -38,4 +38,6 @@ G_DECLARE_FINAL_TYPE (MetaClutterBackendNative, meta_clutter_backend_native,
MetaStageNative * meta_clutter_backend_native_get_stage_native (ClutterBackend *backend);
void meta_clutter_backend_native_set_seat_id (const gchar *seat_id);
#endif /* META_CLUTTER_BACKEND_NATIVE_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,194 +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 "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;
gint meta_device_manager_native_acquire_device_id (MetaDeviceManagerNative *manager_evdev);
void meta_device_manager_native_release_device_id (MetaDeviceManagerNative *manager_evdev,
ClutterInputDevice *device);
ClutterStage * meta_device_manager_native_get_stage (MetaDeviceManagerNative *manager_evdev);
void meta_device_manager_native_constrain_pointer (MetaDeviceManagerNative *manager_evdev,
ClutterInputDevice *core_pointer,
uint64_t time_us,
float x,
float y,
float *new_x,
float *new_y);
void meta_device_manager_native_filter_relative_motion (MetaDeviceManagerNative *manager_evdev,
ClutterInputDevice *device,
float x,
float y,
float *dx,
float *dy);
void meta_device_manager_native_dispatch (MetaDeviceManagerNative *manager_evdev);
struct xkb_state * meta_device_manager_native_get_xkb_state (MetaDeviceManagerNative *manager_evdev);
static inline uint64_t
us (uint64_t us)
{
return us;
}
static inline uint64_t
ms2us (uint64_t ms)
{
return us (ms * 1000);
}
static inline uint32_t
us2ms (uint64_t us)
{
return (uint32_t) (us / 1000);
}
/**
* MetaOpenDeviceCallback:
* @path: the device path
* @flags: flags to be passed to open
*
* This callback will be called when Clutter needs to access an input
* device. It should return an open file descriptor for the file at @path,
* or -1 if opening failed.
*/
typedef int (*MetaOpenDeviceCallback) (const char *path,
int flags,
gpointer user_data,
GError **error);
typedef void (*MetaCloseDeviceCallback) (int fd,
gpointer user_data);
void meta_device_manager_native_set_device_callbacks (MetaOpenDeviceCallback open_callback,
MetaCloseDeviceCallback close_callback,
gpointer user_data);
void meta_device_manager_native_set_seat_id (const gchar *seat_id);
void meta_device_manager_native_release_devices (void);
void meta_device_manager_native_reclaim_devices (void);
/**
* MetaPointerConstrainCallback:
* @device: the core pointer device
* @time: the event time in milliseconds
* @x: (inout): the new X coordinate
* @y: (inout): the new Y coordinate
* @user_data: user data passed to this function
*
* This callback will be called for all pointer motion events, and should
* update (@x, @y) to constrain the pointer position appropriately.
* The subsequent motion event will use the updated values as the new coordinates.
* Note that the coordinates are not clamped to the stage size, and the callback
* must make sure that this happens before it returns.
* Also note that the event will be emitted even if the pointer is constrained
* to be in the same position.
*/
typedef void (* MetaPointerConstrainCallback) (ClutterInputDevice *device,
uint32_t time,
float prev_x,
float prev_y,
float *x,
float *y,
gpointer user_data);
void meta_device_manager_native_set_pointer_constrain_callback (ClutterDeviceManager *evdev,
MetaPointerConstrainCallback callback,
gpointer user_data,
GDestroyNotify user_data_notify);
typedef void (* MetaRelativeMotionFilter) (ClutterInputDevice *device,
float x,
float y,
float *dx,
float *dy,
gpointer user_data);
void meta_device_manager_native_set_relative_motion_filter (ClutterDeviceManager *evdev,
MetaRelativeMotionFilter filter,
gpointer user_data);
void meta_device_manager_native_set_keyboard_map (ClutterDeviceManager *evdev,
struct xkb_keymap *keymap);
struct xkb_keymap * meta_device_manager_native_get_keyboard_map (ClutterDeviceManager *evdev);
void meta_device_manager_native_set_keyboard_layout_index (ClutterDeviceManager *evdev,
xkb_layout_index_t idx);
xkb_layout_index_t meta_device_manager_native_get_keyboard_layout_index (ClutterDeviceManager *evdev);
void meta_device_manager_native_set_keyboard_numlock (ClutterDeviceManager *evdev,
gboolean numlock_state);
void meta_device_manager_native_set_keyboard_repeat (ClutterDeviceManager *evdev,
gboolean repeat,
uint32_t delay,
uint32_t interval);
typedef gboolean (* MetaEvdevFilterFunc) (struct libinput_event *event,
gpointer data);
void meta_device_manager_native_add_filter (MetaEvdevFilterFunc func,
gpointer data,
GDestroyNotify destroy_notify);
void meta_device_manager_native_remove_filter (MetaEvdevFilterFunc func,
gpointer data);
void meta_device_manager_native_warp_pointer (ClutterInputDevice *pointer_device,
uint32_t time_,
int x,
int y);
#endif /* META_DEVICE_MANAGER_NATIVE_H */

View File

@ -26,7 +26,6 @@
#include "backends/native/meta-input-device-tool-native.h"
#include "backends/native/meta-input-device-native.h"
#include "backends/native/meta-device-manager-native.h"
#include "backends/native/meta-seat-native.h"
#include "clutter/clutter-mutter.h"
@ -62,8 +61,8 @@ meta_input_device_native_finalize (GObject *object)
{
ClutterInputDevice *device = CLUTTER_INPUT_DEVICE (object);
MetaInputDeviceNative *device_evdev = META_INPUT_DEVICE_NATIVE (object);
MetaDeviceManagerNative *manager_evdev =
META_DEVICE_MANAGER_NATIVE (device->device_manager);
ClutterBackend *backend;
ClutterSeat *seat;
if (device_evdev->libinput_device)
libinput_device_unref (device_evdev->libinput_device);
@ -71,7 +70,9 @@ meta_input_device_native_finalize (GObject *object)
meta_input_device_native_release_touch_slots (device_evdev,
g_get_monotonic_time ());
meta_device_manager_native_release_device_id (manager_evdev, device);
backend = clutter_get_default_backend ();
seat = clutter_backend_get_default_seat (backend);
meta_seat_native_release_device_id (META_SEAT_NATIVE (seat), device);
clear_slow_keys (device_evdev);
stop_bounce_keys (device_evdev);
@ -221,12 +222,9 @@ meta_input_device_native_is_grouped (ClutterInputDevice *device,
}
static void
meta_input_device_native_bell_notify (void)
meta_input_device_native_bell_notify (MetaInputDeviceNative *device)
{
ClutterBackend *backend;
backend = clutter_get_default_backend ();
clutter_backend_bell_notify (backend);
clutter_seat_bell_notify (CLUTTER_SEAT (device->seat));
}
static void
@ -250,10 +248,11 @@ clear_slow_keys (MetaInputDeviceNative *device)
static guint
get_slow_keys_delay (ClutterInputDevice *device)
{
MetaInputDeviceNative *device_native = META_INPUT_DEVICE_NATIVE (device);
ClutterKbdA11ySettings a11y_settings;
clutter_device_manager_get_kbd_a11y_settings (device->device_manager,
&a11y_settings);
clutter_seat_get_kbd_a11y_settings (CLUTTER_SEAT (device_native->seat),
&a11y_settings);
/* Settings use int, we use uint, make sure we dont go negative */
return MAX (0, a11y_settings.slowkeys_delay);
}
@ -275,7 +274,7 @@ trigger_slow_keys (gpointer data)
meta_input_device_native_free_pending_slow_key (slow_keys_event);
if (device->a11y_flags & CLUTTER_A11Y_SLOW_KEYS_BEEP_ACCEPT)
meta_input_device_native_bell_notify ();
meta_input_device_native_bell_notify (device);
return G_SOURCE_REMOVE;
}
@ -313,7 +312,7 @@ start_slow_keys (ClutterEvent *event,
device->slow_keys_list = g_list_append (device->slow_keys_list, slow_keys_event);
if (device->a11y_flags & CLUTTER_A11Y_SLOW_KEYS_BEEP_PRESS)
meta_input_device_native_bell_notify ();
meta_input_device_native_bell_notify (device);
}
static void
@ -333,7 +332,7 @@ stop_slow_keys (ClutterEvent *event,
meta_input_device_native_free_pending_slow_key (slow_keys_event);
if (device->a11y_flags & CLUTTER_A11Y_SLOW_KEYS_BEEP_REJECT)
meta_input_device_native_bell_notify ();
meta_input_device_native_bell_notify (device);
return;
}
@ -345,10 +344,11 @@ stop_slow_keys (ClutterEvent *event,
static guint
get_debounce_delay (ClutterInputDevice *device)
{
MetaInputDeviceNative *device_native = META_INPUT_DEVICE_NATIVE (device);
ClutterKbdA11ySettings a11y_settings;
clutter_device_manager_get_kbd_a11y_settings (device->device_manager,
&a11y_settings);
clutter_seat_get_kbd_a11y_settings (CLUTTER_SEAT (device_native->seat),
&a11y_settings);
/* Settings use int, we use uint, make sure we dont go negative */
return MAX (0, a11y_settings.debounce_delay);
}
@ -387,7 +387,7 @@ static void
notify_bounce_keys_reject (MetaInputDeviceNative *device)
{
if (device->a11y_flags & CLUTTER_A11Y_BOUNCE_KEYS_BEEP_REJECT)
meta_input_device_native_bell_notify ();
meta_input_device_native_bell_notify (device);
}
static gboolean
@ -425,7 +425,7 @@ key_event_is_modifier (ClutterEvent *event)
static void
notify_stickykeys_mask (MetaInputDeviceNative *device)
{
g_signal_emit_by_name (CLUTTER_INPUT_DEVICE (device)->device_manager,
g_signal_emit_by_name (device->seat,
"kbd-a11y-mods-state-changed",
device->stickykeys_latched_mask,
device->stickykeys_locked_mask);
@ -497,7 +497,7 @@ notify_stickykeys_change (MetaInputDeviceNative *device)
device->stickykeys_depressed_mask = 0;
update_internal_xkb_state (device, 0, 0);
g_signal_emit_by_name (CLUTTER_INPUT_DEVICE (device)->device_manager,
g_signal_emit_by_name (CLUTTER_INPUT_DEVICE (device)->seat,
"kbd-a11y-flags-changed",
device->a11y_flags,
CLUTTER_A11Y_STICKY_KEYS_ENABLED);
@ -530,7 +530,7 @@ set_slowkeys_off (MetaInputDeviceNative *device)
{
device->a11y_flags &= ~CLUTTER_A11Y_SLOW_KEYS_ENABLED;
g_signal_emit_by_name (CLUTTER_INPUT_DEVICE (device)->device_manager,
g_signal_emit_by_name (CLUTTER_INPUT_DEVICE (device)->seat,
"kbd-a11y-flags-changed",
device->a11y_flags,
CLUTTER_A11Y_SLOW_KEYS_ENABLED);
@ -541,7 +541,7 @@ set_slowkeys_on (MetaInputDeviceNative *device)
{
device->a11y_flags |= CLUTTER_A11Y_SLOW_KEYS_ENABLED;
g_signal_emit_by_name (CLUTTER_INPUT_DEVICE (device)->device_manager,
g_signal_emit_by_name (CLUTTER_INPUT_DEVICE (device)->seat,
"kbd-a11y-flags-changed",
device->a11y_flags,
CLUTTER_A11Y_SLOW_KEYS_ENABLED);
@ -607,7 +607,7 @@ handle_stickykeys_release (ClutterEvent *event,
if (key_event_is_modifier (event))
{
if (device->a11y_flags & CLUTTER_A11Y_STICKY_KEYS_BEEP)
meta_input_device_native_bell_notify ();
meta_input_device_native_bell_notify (device);
return;
}
@ -626,7 +626,7 @@ trigger_toggle_slowkeys (gpointer data)
device->toggle_slowkeys_timer = 0;
if (device->a11y_flags & CLUTTER_A11Y_FEATURE_STATE_CHANGE_BEEP)
meta_input_device_native_bell_notify ();
meta_input_device_native_bell_notify (device);
if (device->a11y_flags & CLUTTER_A11Y_SLOW_KEYS_ENABLED)
set_slowkeys_off (device);
@ -688,7 +688,7 @@ handle_enablekeys_release (ClutterEvent *event,
device->shift_count = 0;
if (device->a11y_flags & CLUTTER_A11Y_FEATURE_STATE_CHANGE_BEEP)
meta_input_device_native_bell_notify ();
meta_input_device_native_bell_notify (device);
if (device->a11y_flags & CLUTTER_A11Y_STICKY_KEYS_ENABLED)
set_stickykeys_off (device);
@ -850,7 +850,6 @@ static void
enable_mousekeys (MetaInputDeviceNative *device_evdev)
{
ClutterInputDevice *device = CLUTTER_INPUT_DEVICE (device_evdev);
ClutterDeviceManager *manager = device->device_manager;
device_evdev->mousekeys_btn = CLUTTER_BUTTON_PRIMARY;
device_evdev->move_mousekeys_timer = 0;
@ -862,8 +861,8 @@ enable_mousekeys (MetaInputDeviceNative *device_evdev)
return;
device->accessibility_virtual_device =
clutter_device_manager_create_virtual_device (manager,
CLUTTER_POINTER_DEVICE);
clutter_seat_create_virtual_device (CLUTTER_SEAT (device_evdev->seat),
CLUTTER_POINTER_DEVICE);
}
static void
@ -1225,7 +1224,7 @@ void
meta_input_device_native_a11y_maybe_notify_toggle_keys (MetaInputDeviceNative *device)
{
if (device->a11y_flags & CLUTTER_A11Y_TOGGLE_KEYS_ENABLED)
meta_input_device_native_bell_notify ();
meta_input_device_native_bell_notify (device);
}
static void
@ -1320,13 +1319,11 @@ meta_input_device_native_init (MetaInputDeviceNative *self)
* it with the provided seat.
*/
ClutterInputDevice *
meta_input_device_native_new (ClutterDeviceManager *manager,
MetaSeatNative *seat,
meta_input_device_native_new (MetaSeatNative *seat,
struct libinput_device *libinput_device)
{
MetaInputDeviceNative *device;
ClutterInputDeviceType type;
MetaDeviceManagerNative *manager_evdev;
char *vendor, *product;
int device_id, n_rings = 0, n_strips = 0, n_groups = 1;
char *node_path;
@ -1335,8 +1332,7 @@ meta_input_device_native_new (ClutterDeviceManager *manager,
type = meta_input_device_native_determine_type (libinput_device);
vendor = g_strdup_printf ("%.4x", libinput_device_get_id_vendor (libinput_device));
product = g_strdup_printf ("%.4x", libinput_device_get_id_product (libinput_device));
manager_evdev = META_DEVICE_MANAGER_NATIVE (manager);
device_id = meta_device_manager_native_acquire_device_id (manager_evdev);
device_id = meta_seat_native_acquire_device_id (seat);
node_path = g_strdup_printf ("/dev/input/%s", libinput_device_get_sysname (libinput_device));
if (libinput_device_has_capability (libinput_device,
@ -1350,7 +1346,6 @@ meta_input_device_native_new (ClutterDeviceManager *manager,
device = g_object_new (META_TYPE_INPUT_DEVICE_NATIVE,
"id", device_id,
"name", libinput_device_get_name (libinput_device),
"device-manager", manager,
"device-type", type,
"device-mode", CLUTTER_INPUT_MODE_SLAVE,
"enabled", TRUE,
@ -1360,6 +1355,7 @@ meta_input_device_native_new (ClutterDeviceManager *manager,
"n-strips", n_strips,
"n-mode-groups", n_groups,
"device-node", node_path,
"seat", seat,
NULL);
device->seat = seat;
@ -1379,20 +1375,17 @@ meta_input_device_native_new (ClutterDeviceManager *manager,
/*
* meta_input_device_native_new_virtual:
* @manager: the device manager
* @seat: the seat the device will belong to
* @type: the input device type
*
* Create a new virtual ClutterInputDevice of the given type.
*/
ClutterInputDevice *
meta_input_device_native_new_virtual (ClutterDeviceManager *manager,
MetaSeatNative *seat,
meta_input_device_native_new_virtual (MetaSeatNative *seat,
ClutterInputDeviceType type,
ClutterInputMode mode)
{
MetaInputDeviceNative *device;
MetaDeviceManagerNative *manager_evdev;
const char *name;
int device_id;
@ -1412,15 +1405,14 @@ meta_input_device_native_new_virtual (ClutterDeviceManager *manager,
break;
};
manager_evdev = META_DEVICE_MANAGER_NATIVE (manager);
device_id = meta_device_manager_native_acquire_device_id (manager_evdev);
device_id = meta_seat_native_acquire_device_id (seat);
device = g_object_new (META_TYPE_INPUT_DEVICE_NATIVE,
"id", device_id,
"name", name,
"device-manager", manager,
"device-type", type,
"device-mode", mode,
"enabled", TRUE,
"seat", seat,
NULL);
device->seat = seat;

View File

@ -101,12 +101,10 @@ struct _MetaInputDeviceNativeClass
GType meta_input_device_native_get_type (void) G_GNUC_CONST;
ClutterInputDevice * meta_input_device_native_new (ClutterDeviceManager *manager,
MetaSeatNative *seat,
ClutterInputDevice * meta_input_device_native_new (MetaSeatNative *seat,
struct libinput_device *libinput_device);
ClutterInputDevice * meta_input_device_native_new_virtual (ClutterDeviceManager *manager,
MetaSeatNative *seat,
ClutterInputDevice * meta_input_device_native_new_virtual (MetaSeatNative *seat,
ClutterInputDeviceType type,
ClutterInputMode mode);

View File

@ -315,9 +315,11 @@ meta_input_settings_native_set_keyboard_repeat (MetaInputSettings *settings,
guint delay,
guint interval)
{
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
ClutterSeat *seat;
meta_device_manager_native_set_keyboard_repeat (manager, enabled, delay, interval);
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
meta_seat_native_set_keyboard_repeat (META_SEAT_NATIVE (seat),
enabled, delay, interval);
}
static void

View File

@ -21,8 +21,8 @@
#include "config.h"
#include "backends/native/meta-device-manager-native.h"
#include "backends/native/meta-keymap-native.h"
#include "backends/native/meta-seat-native.h"
static const char *option_xkb_layout = "us";
static const char *option_xkb_variant = "";
@ -53,12 +53,11 @@ meta_keymap_native_finalize (GObject *object)
static gboolean
meta_keymap_native_get_num_lock_state (ClutterKeymap *keymap)
{
MetaDeviceManagerNative *device_manager;
struct xkb_state *xkb_state;
ClutterSeat *seat;
device_manager =
META_DEVICE_MANAGER_NATIVE (clutter_device_manager_get_default ());
xkb_state = meta_device_manager_native_get_xkb_state (device_manager);
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
xkb_state = meta_seat_native_get_xkb_state (META_SEAT_NATIVE (seat));
return xkb_state_mod_name_is_active (xkb_state,
XKB_MOD_NAME_NUM,
@ -69,12 +68,11 @@ meta_keymap_native_get_num_lock_state (ClutterKeymap *keymap)
static gboolean
meta_keymap_native_get_caps_lock_state (ClutterKeymap *keymap)
{
MetaDeviceManagerNative *device_manager;
struct xkb_state *xkb_state;
ClutterSeat *seat;
device_manager =
META_DEVICE_MANAGER_NATIVE (clutter_device_manager_get_default ());
xkb_state = meta_device_manager_native_get_xkb_state (device_manager);
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
xkb_state = meta_seat_native_get_xkb_state (META_SEAT_NATIVE (seat));
return xkb_state_mod_name_is_active (xkb_state,
XKB_MOD_NAME_CAPS,
@ -82,6 +80,12 @@ meta_keymap_native_get_caps_lock_state (ClutterKeymap *keymap)
XKB_STATE_MODS_LOCKED);
}
static PangoDirection
meta_keymap_native_get_direction (ClutterKeymap *keymap)
{
return PANGO_DIRECTION_NEUTRAL;
}
static void
meta_keymap_native_class_init (MetaKeymapNativeClass *klass)
{
@ -92,6 +96,7 @@ meta_keymap_native_class_init (MetaKeymapNativeClass *klass)
keymap_class->get_num_lock_state = meta_keymap_native_get_num_lock_state;
keymap_class->get_caps_lock_state = meta_keymap_native_get_caps_lock_state;
keymap_class->get_direction = meta_keymap_native_get_direction;
}
static void

View File

@ -18,6 +18,8 @@
*
* Author: Carlos Garnacho <carlosg@gnome.org>
*/
#ifndef META_KEYMAP_NATIVE_H
#define META_KEYMAP_NATIVE_H
#include "backends/native/meta-xkb-utils.h"
#include "clutter/clutter.h"
@ -30,3 +32,5 @@ G_DECLARE_FINAL_TYPE (MetaKeymapNative, meta_keymap_native,
void meta_keymap_native_set_keyboard_map (MetaKeymapNative *keymap,
struct xkb_keymap *xkb_keymap);
struct xkb_keymap * meta_keymap_native_get_keyboard_map (MetaKeymapNative *keymap);
#endif /* META_KEYMAP_NATIVE_H */

View File

@ -37,9 +37,10 @@
#include "backends/meta-backend-private.h"
#include "backends/native/dbus-utils.h"
#include "backends/native/meta-backend-native.h"
#include "backends/native/meta-clutter-backend-native.h"
#include "backends/native/meta-cursor-renderer-native.h"
#include "backends/native/meta-device-manager-native.h"
#include "backends/native/meta-renderer-native.h"
#include "backends/native/meta-seat-native.h"
#include "clutter/clutter.h"
#include "meta-dbus-login1.h"
@ -525,11 +526,11 @@ meta_launcher_new (GError **error)
self->sysfs_fds = g_hash_table_new (NULL, NULL);
self->session_active = TRUE;
meta_device_manager_native_set_seat_id (self->seat_id);
meta_clutter_backend_native_set_seat_id (self->seat_id);
meta_device_manager_native_set_device_callbacks (on_evdev_device_open,
on_evdev_device_close,
self);
meta_seat_native_set_device_callbacks (on_evdev_device_open,
on_evdev_device_close,
self);
g_signal_connect (self->session_proxy, "notify::active", G_CALLBACK (on_active_changed), self);

File diff suppressed because it is too large Load Diff

View File

@ -26,12 +26,43 @@
#include <libinput.h>
#include <linux/input-event-codes.h>
#include "backends/native/meta-device-manager-native.h"
#include "backends/native/meta-keymap-native.h"
#include "backends/native/meta-xkb-utils.h"
#include "clutter/clutter.h"
typedef struct _MetaTouchState MetaTouchState;
typedef struct _MetaSeatNative MetaSeatNative;
typedef struct _MetaEventSource MetaEventSource;
/**
* MetaPointerConstrainCallback:
* @device: the core pointer device
* @time: the event time in milliseconds
* @x: (inout): the new X coordinate
* @y: (inout): the new Y coordinate
* @user_data: user data passed to this function
*
* This callback will be called for all pointer motion events, and should
* update (@x, @y) to constrain the pointer position appropriately.
* The subsequent motion event will use the updated values as the new coordinates.
* Note that the coordinates are not clamped to the stage size, and the callback
* must make sure that this happens before it returns.
* Also note that the event will be emitted even if the pointer is constrained
* to be in the same position.
*/
typedef void (* MetaPointerConstrainCallback) (ClutterInputDevice *device,
uint32_t time,
float prev_x,
float prev_y,
float *x,
float *y,
gpointer user_data);
typedef void (* MetaRelativeMotionFilter) (ClutterInputDevice *device,
float x,
float y,
float *dx,
float *dy,
gpointer user_data);
struct _MetaTouchState
{
@ -44,8 +75,12 @@ struct _MetaTouchState
struct _MetaSeatNative
{
ClutterSeat parent_instance;
char *seat_id;
MetaEventSource *event_source;
struct libinput *libinput;
struct libinput_seat *libinput_seat;
MetaDeviceManagerNative *manager_evdev;
GSList *devices;
@ -63,6 +98,25 @@ struct _MetaSeatNative
uint32_t button_state;
int button_count[KEY_CNT];
ClutterStage *stage;
ClutterStageManager *stage_manager;
gulong stage_added_handler;
gulong stage_removed_handler;
int device_id_next;
GList *free_device_ids;
MetaPointerConstrainCallback constrain_callback;
gpointer constrain_data;
GDestroyNotify constrain_data_notify;
MetaRelativeMotionFilter relative_motion_filter;
gpointer relative_motion_filter_user_data;
GSList *event_filters;
MetaKeymapNative *keymap;
/* keyboard repeat */
gboolean repeat;
uint32_t repeat_delay;
@ -78,8 +132,32 @@ struct _MetaSeatNative
/* Emulation of discrete scroll events out of smooth ones */
float accum_scroll_dx;
float accum_scroll_dy;
gboolean released;
};
#define META_TYPE_SEAT_NATIVE meta_seat_native_get_type ()
G_DECLARE_FINAL_TYPE (MetaSeatNative, meta_seat_native,
META, SEAT_NATIVE, ClutterSeat)
static inline uint64_t
us (uint64_t us)
{
return us;
}
static inline uint64_t
ms2us (uint64_t ms)
{
return us (ms * 1000);
}
static inline uint32_t
us2ms (uint64_t us)
{
return (uint32_t) (us / 1000);
}
void meta_seat_native_notify_key (MetaSeatNative *seat,
ClutterInputDevice *device,
uint64_t time_us,
@ -145,16 +223,96 @@ MetaTouchState * meta_seat_native_acquire_touch_state (MetaSeatNative *seat,
void meta_seat_native_release_touch_state (MetaSeatNative *seat,
MetaTouchState *touch_state);
MetaTouchState * meta_seat_native_get_touch (MetaSeatNative *seat,
uint32_t id);
void meta_seat_native_set_stage (MetaSeatNative *seat,
ClutterStage *stage);
ClutterStage * meta_seat_native_get_stage (MetaSeatNative *seat);
void meta_seat_native_clear_repeat_timer (MetaSeatNative *seat);
MetaSeatNative * meta_seat_native_new (MetaDeviceManagerNative *manager_evdev);
gint meta_seat_native_acquire_device_id (MetaSeatNative *seat);
void meta_seat_native_release_device_id (MetaSeatNative *seat,
ClutterInputDevice *device);
void meta_seat_native_free (MetaSeatNative *seat);
void meta_seat_native_update_xkb_state (MetaSeatNative *seat);
void meta_seat_native_constrain_pointer (MetaSeatNative *seat,
ClutterInputDevice *core_pointer,
uint64_t time_us,
float x,
float y,
float *new_x,
float *new_y);
void meta_seat_native_filter_relative_motion (MetaSeatNative *seat,
ClutterInputDevice *device,
float x,
float y,
float *dx,
float *dy);
void meta_seat_native_dispatch (MetaSeatNative *seat);
/**
* MetaOpenDeviceCallback:
* @path: the device path
* @flags: flags to be passed to open
*
* This callback will be called when Clutter needs to access an input
* device. It should return an open file descriptor for the file at @path,
* or -1 if opening failed.
*/
typedef int (* MetaOpenDeviceCallback) (const char *path,
int flags,
gpointer user_data,
GError **error);
typedef void (* MetaCloseDeviceCallback) (int fd,
gpointer user_data);
void meta_seat_native_set_device_callbacks (MetaOpenDeviceCallback open_callback,
MetaCloseDeviceCallback close_callback,
gpointer user_data);
void meta_seat_native_release_devices (MetaSeatNative *seat);
void meta_seat_native_reclaim_devices (MetaSeatNative *seat);
void meta_seat_native_set_pointer_constrain_callback (MetaSeatNative *seat,
MetaPointerConstrainCallback callback,
gpointer user_data,
GDestroyNotify user_data_notify);
void meta_seat_native_set_relative_motion_filter (MetaSeatNative *seat,
MetaRelativeMotionFilter filter,
gpointer user_data);
typedef gboolean (* MetaEvdevFilterFunc) (struct libinput_event *event,
gpointer data);
void meta_seat_native_add_filter (MetaSeatNative *seat,
MetaEvdevFilterFunc func,
gpointer data,
GDestroyNotify destroy_notify);
void meta_seat_native_remove_filter (MetaSeatNative *seat,
MetaEvdevFilterFunc func,
gpointer data);
struct xkb_state * meta_seat_native_get_xkb_state (MetaSeatNative *seat);
void meta_seat_native_set_keyboard_map (MetaSeatNative *seat,
struct xkb_keymap *keymap);
struct xkb_keymap * meta_seat_native_get_keyboard_map (MetaSeatNative *seat);
void meta_seat_native_set_keyboard_layout_index (MetaSeatNative *seat,
xkb_layout_index_t idx);
xkb_layout_index_t meta_seat_native_get_keyboard_layout_index (MetaSeatNative *seat);
void meta_seat_native_set_keyboard_numlock (MetaSeatNative *seat,
gboolean numlock_state);
void meta_seat_native_set_keyboard_repeat (MetaSeatNative *seat,
gboolean repeat,
uint32_t delay,
uint32_t interval);
#endif /* META_SEAT_NATIVE_H */

View File

@ -282,13 +282,15 @@ pick_keycode_for_keyval_in_current_group (ClutterVirtualInputDevice *virtual_dev
{
MetaVirtualInputDeviceNative *virtual_evdev =
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
ClutterBackend *backend;
ClutterKeymap *keymap;
struct xkb_keymap *xkb_keymap;
struct xkb_state *state;
guint keycode, layout;
xkb_keycode_t min_keycode, max_keycode;
keymap = clutter_backend_get_keymap (clutter_get_default_backend ());
backend = clutter_get_default_backend ();
keymap = clutter_seat_get_keymap (clutter_backend_get_default_seat (backend));
xkb_keymap = meta_keymap_native_get_keyboard_map (META_KEYMAP_NATIVE (keymap));
state = virtual_evdev->seat->xkb;
@ -630,20 +632,17 @@ meta_virtual_input_device_native_constructed (GObject *object)
CLUTTER_VIRTUAL_INPUT_DEVICE (object);
MetaVirtualInputDeviceNative *virtual_evdev =
META_VIRTUAL_INPUT_DEVICE_NATIVE (object);
ClutterDeviceManager *manager;
ClutterInputDeviceType device_type;
ClutterStage *stage;
manager = clutter_virtual_input_device_get_manager (virtual_device);
device_type = clutter_virtual_input_device_get_device_type (virtual_device);
virtual_evdev->device =
meta_input_device_native_new_virtual (manager,
virtual_evdev->seat,
meta_input_device_native_new_virtual (virtual_evdev->seat,
device_type,
CLUTTER_INPUT_MODE_SLAVE);
stage = meta_device_manager_native_get_stage (META_DEVICE_MANAGER_NATIVE (manager));
stage = meta_seat_native_get_stage (virtual_evdev->seat);
_clutter_input_device_set_stage (virtual_evdev->device, stage);
}

View File

@ -70,9 +70,9 @@ take_touch_grab (MetaBackend *backend)
}
static void
on_device_added (ClutterDeviceManager *device_manager,
ClutterInputDevice *device,
gpointer user_data)
on_device_added (ClutterSeat *seat,
ClutterInputDevice *device,
gpointer user_data)
{
MetaBackendX11 *x11 = META_BACKEND_X11 (user_data);
@ -85,11 +85,12 @@ meta_backend_x11_cm_post_init (MetaBackend *backend)
{
MetaBackendClass *parent_backend_class =
META_BACKEND_CLASS (meta_backend_x11_cm_parent_class);
ClutterSeat *seat;
parent_backend_class->post_init (backend);
g_signal_connect_object (clutter_device_manager_get_default (),
"device-added",
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
g_signal_connect_object (seat, "device-added",
G_CALLBACK (on_device_added), backend, 0);
take_touch_grab (backend);

View File

@ -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"
@ -156,6 +157,9 @@ handle_alarm_notify (MetaBackend *backend,
MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11);
MetaIdleMonitor *idle_monitor;
XSyncAlarmAttributes attr;
ClutterBackend *clutter_backend;
ClutterSeat *seat;
ClutterInputDevice *pointer;
if (alarm_event->state != XSyncAlarmActive ||
alarm_event->alarm != priv->user_active_alarm)
@ -165,7 +169,10 @@ handle_alarm_notify (MetaBackend *backend,
XSyncChangeAlarm (priv->xdisplay, priv->user_active_alarm,
XSyncCAEvents, &attr);
idle_monitor = meta_backend_get_idle_monitor (backend, 0);
clutter_backend = meta_backend_get_clutter_backend (backend);
seat = clutter_backend_get_default_seat (clutter_backend);
pointer = clutter_seat_get_pointer (seat);
idle_monitor = meta_backend_get_idle_monitor (backend, pointer);
meta_idle_monitor_reset_idletime (idle_monitor);
}
@ -242,6 +249,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 +261,11 @@ handle_device_change (MetaBackendX11 *x11,
if (device_changed->reason != XISlaveSwitch)
return;
meta_backend_update_last_device (META_BACKEND (x11),
device_changed->sourceid);
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
@ -657,22 +670,6 @@ meta_backend_x11_finish_touch_sequence (MetaBackend *backend,
}
}
static void
meta_backend_x11_warp_pointer (MetaBackend *backend,
int x,
int y)
{
MetaBackendX11 *x11 = META_BACKEND_X11 (backend);
MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11);
XIWarpPointer (priv->xdisplay,
META_VIRTUAL_CORE_POINTER_ID,
None,
meta_backend_x11_get_xwindow (x11),
0, 0, 0, 0,
x, y);
}
static MetaLogicalMonitor *
meta_backend_x11_get_current_logical_monitor (MetaBackend *backend)
{
@ -849,7 +846,6 @@ meta_backend_x11_class_init (MetaBackendX11Class *klass)
backend_class->grab_device = meta_backend_x11_grab_device;
backend_class->ungrab_device = meta_backend_x11_ungrab_device;
backend_class->finish_touch_sequence = meta_backend_x11_finish_touch_sequence;
backend_class->warp_pointer = meta_backend_x11_warp_pointer;
backend_class->get_current_logical_monitor = meta_backend_x11_get_current_logical_monitor;
backend_class->get_keymap = meta_backend_x11_get_keymap;
backend_class->get_keymap_layout_group = meta_backend_x11_get_keymap_layout_group;

View File

@ -29,8 +29,8 @@
#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"
#include "backends/x11/nested/meta-stage-x11-nested.h"
#include "clutter/clutter-mutter.h"
@ -41,8 +41,7 @@
struct _MetaClutterBackendX11
{
ClutterBackendX11 parent;
MetaKeymapX11 *keymap;
MetaDeviceManagerX11 *device_manager;
MetaSeatX11 *core_seat;
};
G_DEFINE_TYPE (MetaClutterBackendX11, meta_clutter_backend_x11,
@ -78,48 +77,12 @@ meta_clutter_backend_x11_create_stage (ClutterBackend *backend,
return stage;
}
static void
meta_clutter_backend_x11_bell_notify (ClutterBackend *backend)
{
MetaDisplay *display = meta_get_display ();
meta_bell_notify (display, NULL);
}
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 PangoDirection
meta_clutter_backend_x11_get_keymap_direction (ClutterBackend *backend)
{
ClutterKeymap *keymap = clutter_backend_get_keymap (backend);
if (G_UNLIKELY (keymap == NULL))
return PANGO_DIRECTION_NEUTRAL;
return meta_keymap_x11_get_direction (META_KEYMAP_X11 (keymap));
}
static ClutterKeymap *
meta_clutter_backend_x11_get_keymap (ClutterBackend *backend)
{
MetaClutterBackendX11 *backend_x11 = META_CLUTTER_BACKEND_X11 (backend);
return CLUTTER_KEYMAP (backend_x11->keymap);
}
static gboolean
meta_clutter_backend_x11_translate_event (ClutterBackend *backend,
gpointer native,
ClutterEvent *event)
{
MetaClutterBackendX11 *backend_x11 = META_CLUTTER_BACKEND_X11 (backend);
MetaDeviceManagerX11 *device_manager_x11;
MetaStageX11 *stage_x11;
ClutterBackendClass *clutter_backend_class;
@ -128,35 +91,16 @@ meta_clutter_backend_x11_translate_event (ClutterBackend *backend,
if (clutter_backend_class->translate_event (backend, native, event))
return TRUE;
if (meta_keymap_x11_handle_event (backend_x11->keymap, native))
return FALSE;
stage_x11 = META_STAGE_X11 (clutter_backend_get_stage_window (backend));
if (meta_stage_x11_translate_event (stage_x11, native, event))
return TRUE;
device_manager_x11 = META_DEVICE_MANAGER_X11 (backend_x11->device_manager);
if (meta_device_manager_x11_translate_event (device_manager_x11,
native, event))
if (meta_seat_x11_translate_event (backend_x11->core_seat, native, event))
return TRUE;
return FALSE;
}
static void
on_keymap_state_change (MetaKeymapX11 *keymap_x11,
gpointer data)
{
ClutterDeviceManager *device_manager = CLUTTER_DEVICE_MANAGER (data);
ClutterKbdA11ySettings kbd_a11y_settings;
/* On keymaps state change, just reapply the current settings, it'll
* take care of enabling/disabling mousekeys based on NumLock state.
*/
clutter_device_manager_get_kbd_a11y_settings (device_manager, &kbd_a11y_settings);
meta_device_manager_x11_apply_kbd_a11y_settings (device_manager, &kbd_a11y_settings);
}
static void
meta_clutter_backend_x11_init_events (ClutterBackend *backend)
{
@ -175,25 +119,23 @@ meta_clutter_backend_x11_init_events (ClutterBackend *backend)
if (XIQueryVersion (clutter_x11_get_default_display (),
&major, &minor) != BadRequest)
{
g_debug ("Creating XI2 device manager");
backend_x11->device_manager =
g_object_new (META_TYPE_DEVICE_MANAGER_X11,
"backend", backend_x11,
"opcode", event_base,
NULL);
backend_x11->core_seat =
meta_seat_x11_new (event_base,
META_VIRTUAL_CORE_POINTER_ID,
META_VIRTUAL_CORE_KEYBOARD_ID);
}
}
if (!backend_x11->device_manager)
if (!backend_x11->core_seat)
g_error ("No XInput 2.3 support");
}
backend_x11->keymap = g_object_new (META_TYPE_KEYMAP_X11,
"backend", backend_x11,
NULL);
g_signal_connect (backend_x11->keymap,
"state-changed",
G_CALLBACK (on_keymap_state_change),
backend_x11->device_manager);
static ClutterSeat *
meta_clutter_backend_x11_get_default_seat (ClutterBackend *backend)
{
MetaClutterBackendX11 *backend_x11 = META_CLUTTER_BACKEND_X11 (backend);
return CLUTTER_SEAT (backend_x11->core_seat);
}
static void
@ -208,10 +150,7 @@ 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->bell_notify = meta_clutter_backend_x11_bell_notify;
clutter_backend_class->get_device_manager = meta_clutter_backend_x11_get_device_manager;
clutter_backend_class->get_keymap_direction = meta_clutter_backend_x11_get_keymap_direction;
clutter_backend_class->get_keymap = meta_clutter_backend_x11_get_keymap;
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,60 +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;
GHashTable *devices_by_id;
GHashTable *tools_by_serial;
GSList *all_devices;
GList *master_devices;
GList *slave_devices;
int opcode;
#ifdef HAVE_LIBWACOM
WacomDeviceDatabase *wacom_db;
#endif
};
gboolean meta_device_manager_x11_translate_event (MetaDeviceManagerX11 *manager_xi2,
XEvent *xevent,
ClutterEvent *event);
G_END_DECLS
#endif /* META_DEVICE_MANAGER_X11_H */

View File

@ -515,6 +515,34 @@ meta_keymap_x11_get_caps_lock_state (ClutterKeymap *keymap)
return keymap_x11->caps_lock_state;
}
static PangoDirection
meta_keymap_x11_get_direction (ClutterKeymap *keymap)
{
MetaKeymapX11 *keymap_x11;
g_return_val_if_fail (META_IS_KEYMAP_X11 (keymap), PANGO_DIRECTION_NEUTRAL);
keymap_x11 = META_KEYMAP_X11 (keymap);
if (keymap_x11->use_xkb)
{
if (!keymap_x11->has_direction)
{
XkbStateRec state_rec;
XkbGetState (clutter_x11_get_default_display (),
XkbUseCoreKbd, &state_rec);
update_direction (keymap_x11, XkbStateGroup (&state_rec));
}
return keymap_x11->current_direction;
}
else
{
return PANGO_DIRECTION_NEUTRAL;
}
}
static void
meta_keymap_x11_class_init (MetaKeymapX11Class *klass)
{
@ -534,6 +562,7 @@ meta_keymap_x11_class_init (MetaKeymapX11Class *klass)
keymap_class->get_num_lock_state = meta_keymap_x11_get_num_lock_state;
keymap_class->get_caps_lock_state = meta_keymap_x11_get_caps_lock_state;
keymap_class->get_direction = meta_keymap_x11_get_direction;
g_object_class_install_properties (gobject_class, PROP_LAST, obj_props);
}
@ -680,28 +709,6 @@ meta_keymap_x11_get_is_modifier (MetaKeymapX11 *keymap,
return FALSE;
}
PangoDirection
meta_keymap_x11_get_direction (MetaKeymapX11 *keymap)
{
g_return_val_if_fail (META_IS_KEYMAP_X11 (keymap), PANGO_DIRECTION_NEUTRAL);
if (keymap->use_xkb)
{
if (!keymap->has_direction)
{
XkbStateRec state_rec;
XkbGetState (clutter_x11_get_default_display (),
XkbUseCoreKbd, &state_rec);
update_direction (keymap, XkbStateGroup (&state_rec));
}
return keymap->current_direction;
}
else
return PANGO_DIRECTION_NEUTRAL;
}
static gboolean
meta_keymap_x11_get_entries_for_keyval (MetaKeymapX11 *keymap_x11,
uint32_t keyval,

View File

@ -40,8 +40,6 @@ int meta_keymap_x11_translate_key_state (MetaKeymapX11 *keymap,
gboolean meta_keymap_x11_get_is_modifier (MetaKeymapX11 *keymap,
int keycode);
PangoDirection meta_keymap_x11_get_direction (MetaKeymapX11 *keymap);
gboolean meta_keymap_x11_keycode_for_keyval (MetaKeymapX11 *keymap_x11,
guint keyval,
guint *keycode_out,

View File

@ -0,0 +1,42 @@
/*
* 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 META_SEAT_X11_H
#define META_SEAT_X11_H
#include "clutter/clutter.h"
G_BEGIN_DECLS
#define META_TYPE_SEAT_X11 meta_seat_x11_get_type ()
G_DECLARE_FINAL_TYPE (MetaSeatX11, meta_seat_x11, META, SEAT_X11, ClutterSeat)
MetaSeatX11 * meta_seat_x11_new (int opcode,
int master_pointer,
int master_keyboard);
gboolean meta_seat_x11_translate_event (MetaSeatX11 *seat,
XEvent *xevent,
ClutterEvent *event);
ClutterInputDevice * meta_seat_x11_lookup_device_id (MetaSeatX11 *seat_x11,
int device_id);
void meta_seat_x11_select_stage_events (MetaSeatX11 *seat,
ClutterStage *stage);
G_END_DECLS
#endif /* META_SEAT_X11_H */

View File

@ -33,6 +33,7 @@
#include "core/display-private.h"
#include "meta/meta-x11-errors.h"
#include "meta-backend-x11.h"
#include "meta-seat-x11.h"
#include "meta-stage-x11.h"
#define STAGE_X11_IS_MAPPED(s) ((((MetaStageX11 *) (s))->wm_state & STAGE_X11_WITHDRAWN) == 0)
@ -305,31 +306,6 @@ meta_stage_x11_unrealize (ClutterStageWindow *stage_window)
g_clear_pointer (&stage_x11->onscreen, cogl_object_unref);
}
void
meta_stage_x11_events_device_changed (MetaStageX11 *stage_x11,
ClutterInputDevice *device,
ClutterDeviceManager *device_manager)
{
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_x11);
if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_FLOATING)
_clutter_device_manager_select_stage_events (device_manager,
stage_cogl->wrapper);
}
static void
stage_events_device_added (ClutterDeviceManager *device_manager,
ClutterInputDevice *device,
gpointer user_data)
{
ClutterStageWindow *stage_window = user_data;
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_FLOATING)
_clutter_device_manager_select_stage_events (device_manager,
stage_cogl->wrapper);
}
static void
frame_cb (CoglOnscreen *onscreen,
CoglFrameEvent frame_event,
@ -353,8 +329,8 @@ meta_stage_x11_realize (ClutterStageWindow *stage_window)
MetaStageX11 *stage_x11 = META_STAGE_X11 (stage_window);
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
ClutterBackend *backend = CLUTTER_BACKEND (stage_cogl->backend);
MetaSeatX11 *seat_x11 = META_SEAT_X11 (clutter_backend_get_default_seat (backend));
Display *xdisplay = clutter_x11_get_default_display ();
ClutterDeviceManager *device_manager;
float width, height;
GError *error = NULL;
@ -421,20 +397,7 @@ meta_stage_x11_realize (ClutterStageWindow *stage_window)
*/
XSelectInput (xdisplay, stage_x11->xwin, META_STAGE_X11_EVENT_MASK);
/* input events also depent on the actual device, so we need to
* use the device manager to let every device select them, using
* the event mask we passed to XSelectInput as the template
*/
device_manager = clutter_device_manager_get_default ();
if (G_UNLIKELY (device_manager != NULL))
{
_clutter_device_manager_select_stage_events (device_manager,
stage_cogl->wrapper);
g_signal_connect (device_manager, "device-added",
G_CALLBACK (stage_events_device_added),
stage_window);
}
meta_seat_x11_select_stage_events (seat_x11, stage_cogl->wrapper);
meta_stage_x11_fix_window_size (stage_x11,
stage_x11->xwin_width,

View File

@ -80,10 +80,6 @@ struct _MetaStageX11Class
CLUTTER_EXPORT
GType meta_stage_x11_get_type (void) G_GNUC_CONST;
void meta_stage_x11_events_device_changed (MetaStageX11 *stage_x11,
ClutterInputDevice *device,
ClutterDeviceManager *device_manager);
/* Private to subclasses */
void meta_stage_x11_set_user_time (MetaStageX11 *stage_x11,
guint32 user_time);

View File

@ -131,7 +131,8 @@ meta_virtual_input_device_x11_notify_keyval (ClutterVirtualInputDevice *virtual_
ClutterKeyState key_state)
{
ClutterBackend *backend = clutter_get_default_backend ();
MetaKeymapX11 *keymap = META_KEYMAP_X11 (clutter_backend_get_keymap (backend));
ClutterSeat *seat = clutter_backend_get_default_seat (backend);
MetaKeymapX11 *keymap = META_KEYMAP_X11 (clutter_seat_get_keymap (seat));
uint32_t keycode, level;
if (!meta_keymap_x11_keycode_for_keyval (keymap, keyval, &keycode, &level))

View File

@ -75,7 +75,7 @@ set_xkb_desc_rec (Display *xdisplay,
}
static void
check_settings_changed (ClutterDeviceManager *device_manager)
check_settings_changed (ClutterSeat *seat)
{
Display *xdisplay = clutter_x11_get_default_display ();
ClutterKbdA11ySettings kbd_a11y_settings;
@ -86,7 +86,7 @@ check_settings_changed (ClutterDeviceManager *device_manager)
if (!desc)
return;
clutter_device_manager_get_kbd_a11y_settings (device_manager, &kbd_a11y_settings);
clutter_seat_get_kbd_a11y_settings (seat, &kbd_a11y_settings);
if (desc->ctrls->enabled_ctrls & XkbSlowKeysMask &&
!(kbd_a11y_settings.controls & CLUTTER_A11Y_SLOW_KEYS_ENABLED))
@ -115,7 +115,7 @@ check_settings_changed (ClutterDeviceManager *device_manager)
}
if (what_changed)
g_signal_emit_by_name (device_manager,
g_signal_emit_by_name (seat,
"kbd-a11y-flags-changed",
kbd_a11y_settings.controls,
what_changed);
@ -128,7 +128,7 @@ xkb_a11y_event_filter (XEvent *xevent,
ClutterEvent *clutter_event,
gpointer data)
{
ClutterDeviceManager *device_manager = CLUTTER_DEVICE_MANAGER (data);
ClutterSeat *seat = CLUTTER_SEAT (data);
XkbEvent *xkbev = (XkbEvent *) xevent;
/* 'event_type' is set to zero on notifying us of updates in
@ -141,9 +141,9 @@ xkb_a11y_event_filter (XEvent *xevent,
*/
if (xevent->xany.type == (_xkb_event_base + XkbEventCode) &&
xkbev->any.xkb_type == XkbControlsNotify && xkbev->ctrls.event_type != 0)
check_settings_changed (device_manager);
check_settings_changed (seat);
return CLUTTER_X11_FILTER_CONTINUE;
return CLUTTER_X11_FILTER_CONTINUE;
}
static gboolean
@ -194,10 +194,9 @@ set_xkb_ctrl (XkbDescRec *desc,
}
void
meta_device_manager_x11_apply_kbd_a11y_settings (ClutterDeviceManager *device_manager,
ClutterKbdA11ySettings *kbd_a11y_settings)
meta_seat_x11_apply_kbd_a11y_settings (ClutterSeat *seat,
ClutterKbdA11ySettings *kbd_a11y_settings)
{
ClutterBackend *backend;
Display *xdisplay = clutter_x11_get_default_display ();
XkbDescRec *desc;
gboolean enable_accessX;
@ -206,8 +205,6 @@ meta_device_manager_x11_apply_kbd_a11y_settings (ClutterDeviceManager *device_
if (!desc)
return;
backend = clutter_get_default_backend ();
/* general */
enable_accessX = kbd_a11y_settings->controls & CLUTTER_A11Y_KEYBOARD_ENABLED;
@ -245,7 +242,7 @@ meta_device_manager_x11_apply_kbd_a11y_settings (ClutterDeviceManager *device_
}
/* mouse keys */
if (clutter_keymap_get_num_lock_state (clutter_backend_get_keymap (backend)))
if (clutter_keymap_get_num_lock_state (clutter_seat_get_keymap (seat)))
{
/* Disable mousekeys when NumLock is ON */
desc->ctrls->enabled_ctrls &= ~(XkbMouseKeysMask | XkbMouseKeysAccelMask);
@ -316,7 +313,7 @@ meta_device_manager_x11_apply_kbd_a11y_settings (ClutterDeviceManager *device_
}
gboolean
meta_device_manager_x11_a11y_init (ClutterDeviceManager *device_manager)
meta_seat_x11_a11y_init (ClutterSeat *seat)
{
Display *xdisplay = clutter_x11_get_default_display ();
guint event_mask;
@ -328,7 +325,7 @@ meta_device_manager_x11_a11y_init (ClutterDeviceManager *device_manager)
XkbSelectEvents (xdisplay, XkbUseCoreKbd, event_mask, event_mask);
clutter_x11_add_filter (xkb_a11y_event_filter, device_manager);
clutter_x11_add_filter (xkb_a11y_event_filter, seat);
return TRUE;
}

View File

@ -29,10 +29,10 @@
#include "clutter/clutter.h"
void
meta_device_manager_x11_apply_kbd_a11y_settings (ClutterDeviceManager *device_manager,
ClutterKbdA11ySettings *kbd_a11y_settings);
meta_seat_x11_apply_kbd_a11y_settings (ClutterSeat *seat,
ClutterKbdA11ySettings *kbd_a11y_settings);
gboolean
meta_device_manager_x11_a11y_init (ClutterDeviceManager *device_manager);
meta_seat_x11_a11y_init (ClutterSeat *seat);
#endif /* META_XKB_A11Y_X11_H */

View File

@ -103,7 +103,6 @@ handle_idletime_for_event (const ClutterEvent *event)
{
ClutterInputDevice *device, *source_device;
MetaIdleMonitor *core_monitor, *device_monitor;
int device_id;
device = clutter_event_get_device (event);
if (device == NULL)
@ -118,10 +117,8 @@ handle_idletime_for_event (const ClutterEvent *event)
event->type == CLUTTER_DELETE)
return;
device_id = clutter_input_device_get_device_id (device);
core_monitor = meta_idle_monitor_get_core ();
device_monitor = meta_idle_monitor_get_for_device (device_id);
device_monitor = meta_idle_monitor_get_for_device (device);
meta_idle_monitor_reset_idletime (core_monitor);
meta_idle_monitor_reset_idletime (device_monitor);
@ -129,8 +126,7 @@ handle_idletime_for_event (const ClutterEvent *event)
source_device = clutter_event_get_source_device (event);
if (source_device != device)
{
device_id = clutter_input_device_get_device_id (device);
device_monitor = meta_idle_monitor_get_for_device (device_id);
device_monitor = meta_idle_monitor_get_for_device (source_device);
meta_idle_monitor_reset_idletime (device_monitor);
}
}
@ -273,10 +269,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)

View File

@ -6881,8 +6881,10 @@ warp_grab_pointer (MetaWindow *window,
&display->grab_anchor_window_pos);
{
MetaBackend *backend = meta_get_backend ();
meta_backend_warp_pointer (backend, *x, *y);
ClutterSeat *seat;
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
clutter_seat_warp_pointer (seat, *x, *y);
}
if (meta_x11_error_trap_pop_with_return (display->x11_display) != Success)
@ -8119,12 +8121,12 @@ mouse_mode_focus (MetaWindow *window,
static gboolean
window_has_pointer_wayland (MetaWindow *window)
{
ClutterDeviceManager *dm;
ClutterSeat *seat;
ClutterInputDevice *dev;
ClutterActor *pointer_actor, *window_actor;
dm = clutter_device_manager_get_default ();
dev = clutter_device_manager_get_core_device (dm, CLUTTER_POINTER_DEVICE);
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
dev = clutter_seat_get_pointer (seat);
pointer_actor = clutter_input_device_get_pointer_actor (dev);
window_actor = CLUTTER_ACTOR (meta_window_get_compositor_private (window));

View File

@ -244,8 +244,6 @@ mutter_sources = [
'backends/x11/meta-crtc-xrandr.h',
'backends/x11/meta-cursor-renderer-x11.c',
'backends/x11/meta-cursor-renderer-x11.h',
'backends/x11/meta-device-manager-x11.c',
'backends/x11/meta-device-manager-x11.h',
'backends/x11/meta-event-x11.c',
'backends/x11/meta-event-x11.h',
'backends/x11/meta-gpu-xrandr.c',
@ -256,6 +254,8 @@ mutter_sources = [
'backends/x11/meta-input-device-tool-x11.h',
'backends/x11/meta-input-settings-x11.c',
'backends/x11/meta-input-settings-x11.h',
'backends/x11/meta-seat-x11.c',
'backends/x11/meta-seat-x11.h',
'backends/x11/meta-keymap-x11.c',
'backends/x11/meta-keymap-x11.h',
'backends/x11/meta-monitor-manager-xrandr.c',
@ -601,8 +601,6 @@ if have_native_backend
'backends/native/meta-crtc-kms.h',
'backends/native/meta-cursor-renderer-native.c',
'backends/native/meta-cursor-renderer-native.h',
'backends/native/meta-device-manager-native.c',
'backends/native/meta-device-manager-native.h',
'backends/native/meta-drm-buffer-dumb.c',
'backends/native/meta-drm-buffer-dumb.h',
'backends/native/meta-drm-buffer-gbm.c',

View File

@ -44,7 +44,7 @@ META_EXPORT
MetaIdleMonitor *meta_idle_monitor_get_core (void);
META_EXPORT
MetaIdleMonitor *meta_idle_monitor_get_for_device (int device_id);
MetaIdleMonitor *meta_idle_monitor_get_for_device (ClutterInputDevice *device);
META_EXPORT
guint meta_idle_monitor_add_idle_watch (MetaIdleMonitor *monitor,

View File

@ -152,9 +152,9 @@ stage_motion_event_cb (ClutterActor *actor,
}
static void
manager_device_added_cb (ClutterDeviceManager *manager,
ClutterInputDevice *device,
TestDevicesApp *app)
seat_device_added_cb (ClutterSeat *seat,
ClutterInputDevice *device,
TestDevicesApp *app)
{
ClutterInputDeviceType device_type;
ClutterActor *hand = NULL;
@ -185,9 +185,9 @@ manager_device_added_cb (ClutterDeviceManager *manager,
}
static void
manager_device_removed_cb (ClutterDeviceManager *manager,
ClutterInputDevice *device,
TestDevicesApp *app)
seat_device_removed_cb (ClutterSeat *seat,
ClutterInputDevice *device,
TestDevicesApp *app)
{
ClutterInputDeviceType device_type;
ClutterActor *hand = NULL;
@ -215,8 +215,8 @@ test_devices_main (int argc, char **argv)
{
ClutterActor *stage;
TestDevicesApp *app;
ClutterDeviceManager *manager;
const GSList *stage_devices, *l;
ClutterSeat *seat;
GList *stage_devices, *l;
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
@ -241,15 +241,15 @@ test_devices_main (int argc, char **argv)
clutter_actor_show_all (stage);
manager = clutter_device_manager_get_default ();
g_signal_connect (manager,
"device-added", G_CALLBACK (manager_device_added_cb),
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
g_signal_connect (seat,
"device-added", G_CALLBACK (seat_device_added_cb),
app);
g_signal_connect (manager,
"device-removed", G_CALLBACK (manager_device_removed_cb),
g_signal_connect (seat,
"device-removed", G_CALLBACK (seat_device_removed_cb),
app);
stage_devices = clutter_device_manager_peek_devices (manager);
stage_devices = clutter_seat_list_devices (seat);
if (stage_devices == NULL)
g_error ("No input devices found.");
@ -285,6 +285,8 @@ test_devices_main (int argc, char **argv)
}
}
g_list_free (stage_devices);
clutter_main ();
return EXIT_SUCCESS;

View File

@ -192,9 +192,9 @@ cyan_press_cb (ClutterActor *actor,
ClutterEvent *event,
gpointer data)
{
ClutterDeviceManager *dm = clutter_device_manager_get_default ();
ClutterInputDevice *device =
clutter_device_manager_get_core_device (dm, CLUTTER_KEYBOARD_DEVICE);
ClutterBackend *backend = clutter_get_default_backend ();
ClutterSeat *seat = clutter_backend_get_default_seat (backend);
ClutterInputDevice *device = clutter_seat_get_pointer (seat);
if (clutter_input_device_get_grabbed_actor (device) != NULL)
clutter_input_device_ungrab (device);

View File

@ -90,7 +90,10 @@ static gboolean perf_fake_mouse_cb (gpointer stage)
*/
{
ClutterEvent *event2 = clutter_event_new (CLUTTER_ENTER);
device = clutter_device_manager_get_core_device (clutter_device_manager_get_default (), CLUTTER_POINTER_DEVICE);
ClutterBackend *backend = clutter_get_default_backend ();
ClutterSeat *seat = clutter_backend_get_default_seat (backend);
device = clutter_seat_get_pointer (seat);
event2->crossing.stage = stage;
event2->crossing.source = stage;

View File

@ -643,6 +643,7 @@ meta_pointer_confinement_wayland_maybe_warp (MetaPointerConfinementWayland *self
GArray *borders;
float closest_distance_2 = FLT_MAX;
MetaBorder *closest_border = NULL;
ClutterSeat *seat;
unsigned int i;
float x;
float y;
@ -667,7 +668,9 @@ meta_pointer_confinement_wayland_maybe_warp (MetaPointerConfinementWayland *self
warp_to_behind_border (closest_border, &sx, &sy);
meta_wayland_surface_get_absolute_coordinates (surface, sx, sy, &x, &y);
meta_backend_warp_pointer (meta_get_backend (), (int)x, (int)y);
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
clutter_seat_warp_pointer (seat, (int)x, (int)y);
}
cairo_region_destroy (region);

View File

@ -404,6 +404,7 @@ meta_wayland_keyboard_update_xkb_state (MetaWaylandKeyboard *keyboard)
MetaBackend *backend = meta_get_backend ();
xkb_layout_index_t layout_idx;
ClutterKeymap *keymap;
ClutterSeat *seat;
/* Preserve latched/locked modifiers state */
if (xkb_info->state)
@ -417,7 +418,8 @@ meta_wayland_keyboard_update_xkb_state (MetaWaylandKeyboard *keyboard)
latched = locked = 0;
}
keymap = clutter_backend_get_keymap (clutter_get_default_backend ());
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
keymap = clutter_seat_get_keymap (seat);
numlock = (1 << xkb_keymap_mod_get_index (xkb_info->keymap, "Mod2"));
if (clutter_keymap_get_num_lock_state (keymap))
@ -434,10 +436,10 @@ meta_wayland_keyboard_update_xkb_state (MetaWaylandKeyboard *keyboard)
}
static void
on_kbd_a11y_mask_changed (ClutterDeviceManager *device_manager,
xkb_mod_mask_t new_latched_mods,
xkb_mod_mask_t new_locked_mods,
MetaWaylandKeyboard *keyboard)
on_kbd_a11y_mask_changed (ClutterSeat *seat,
xkb_mod_mask_t new_latched_mods,
xkb_mod_mask_t new_locked_mods,
MetaWaylandKeyboard *keyboard)
{
xkb_mod_mask_t latched, locked, depressed, group;
@ -565,6 +567,7 @@ void
meta_wayland_keyboard_enable (MetaWaylandKeyboard *keyboard)
{
MetaBackend *backend = meta_get_backend ();
ClutterBackend *clutter_backend = clutter_get_default_backend ();
keyboard->settings = g_settings_new ("org.gnome.desktop.peripherals.keyboard");
g_signal_connect (keyboard->settings, "changed",
@ -575,7 +578,8 @@ meta_wayland_keyboard_enable (MetaWaylandKeyboard *keyboard)
g_signal_connect (backend, "keymap-layout-group-changed",
G_CALLBACK (on_keymap_layout_group_changed), keyboard);
g_signal_connect (clutter_device_manager_get_default (), "kbd-a11y-mods-state-changed",
g_signal_connect (clutter_backend_get_default_seat (clutter_backend),
"kbd-a11y-mods-state-changed",
G_CALLBACK (on_kbd_a11y_mask_changed), keyboard);
meta_wayland_keyboard_take_keymap (keyboard, meta_backend_get_keymap (backend));

View File

@ -921,7 +921,12 @@ locked_pointer_destroy (struct wl_client *client,
wl_resource_destroy (resource);
if (warp_pointer)
meta_backend_warp_pointer (meta_get_backend (), warp_x, warp_y);
{
ClutterSeat *seat;
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
clutter_seat_warp_pointer (seat, warp_x, warp_y);
}
}
static void

View File

@ -291,16 +291,22 @@ meta_wayland_pointer_send_relative_motion (MetaWaylandPointer *pointer,
uint32_t time_us_lo;
wl_fixed_t dxf, dyf;
wl_fixed_t dx_unaccelf, dy_unaccelf;
MetaBackend *backend = meta_get_backend ();
#ifdef HAVE_NATIVE_BACKEND
if (!META_IS_BACKEND_NATIVE (backend) ||
!meta_event_native_get_relative_motion (event,
&dx, &dy,
&dx_unaccel, &dy_unaccel))
return;
#else
if (META_IS_BACKEND_X11 (backend))
return;
#endif
if (!pointer->focus_client)
return;
if (!meta_backend_get_relative_motion_deltas (meta_get_backend (),
event,
&dx, &dy,
&dx_unaccel, &dy_unaccel))
return;
#ifdef HAVE_NATIVE_BACKEND
time_us = meta_event_native_get_time_usec (event);
if (time_us == 0)
@ -499,7 +505,7 @@ meta_wayland_pointer_enable (MetaWaylandPointer *pointer)
{
MetaBackend *backend = meta_get_backend ();
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
ClutterDeviceManager *manager;
ClutterSeat *clutter_seat;
pointer->pointer_clients =
g_hash_table_new_full (NULL, NULL, NULL,
@ -507,8 +513,8 @@ meta_wayland_pointer_enable (MetaWaylandPointer *pointer)
pointer->cursor_surface = NULL;
manager = clutter_device_manager_get_default ();
pointer->device = clutter_device_manager_get_core_device (manager, CLUTTER_POINTER_DEVICE);
clutter_seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
pointer->device = clutter_seat_get_pointer (clutter_seat);
g_signal_connect (cursor_tracker,
"cursor-changed",

View File

@ -99,12 +99,12 @@ bind_seat (struct wl_client *client,
}
static uint32_t
lookup_device_capabilities (ClutterDeviceManager *device_manager)
lookup_device_capabilities (ClutterSeat *seat)
{
const GSList *devices, *l;
GList *devices, *l;
uint32_t capabilities = 0;
devices = clutter_device_manager_peek_devices (device_manager);
devices = clutter_seat_list_devices (seat);
for (l = devices; l; l = l->next)
{
@ -139,6 +139,8 @@ lookup_device_capabilities (ClutterDeviceManager *device_manager)
}
}
g_list_free (devices);
return capabilities;
}
@ -188,21 +190,21 @@ meta_wayland_seat_set_capabilities (MetaWaylandSeat *seat,
}
static void
meta_wayland_seat_update_capabilities (MetaWaylandSeat *seat,
ClutterDeviceManager *device_manager)
meta_wayland_seat_update_capabilities (MetaWaylandSeat *seat,
ClutterSeat *clutter_seat)
{
uint32_t capabilities;
capabilities = lookup_device_capabilities (device_manager);
capabilities = lookup_device_capabilities (clutter_seat);
meta_wayland_seat_set_capabilities (seat, capabilities);
}
static void
meta_wayland_seat_devices_updated (ClutterDeviceManager *device_manager,
ClutterInputDevice *input_device,
MetaWaylandSeat *seat)
meta_wayland_seat_devices_updated (ClutterSeat *clutter_seat,
ClutterInputDevice *input_device,
MetaWaylandSeat *seat)
{
meta_wayland_seat_update_capabilities (seat, device_manager);
meta_wayland_seat_update_capabilities (seat, clutter_seat);
}
static MetaWaylandSeat *
@ -210,7 +212,7 @@ meta_wayland_seat_new (MetaWaylandCompositor *compositor,
struct wl_display *display)
{
MetaWaylandSeat *seat = g_new0 (MetaWaylandSeat, 1);
ClutterDeviceManager *device_manager;
ClutterSeat *clutter_seat;
wl_list_init (&seat->base_resource_list);
seat->wl_display = display;
@ -230,11 +232,11 @@ meta_wayland_seat_new (MetaWaylandCompositor *compositor,
meta_wayland_data_device_init (&seat->data_device);
device_manager = clutter_device_manager_get_default ();
meta_wayland_seat_update_capabilities (seat, device_manager);
g_signal_connect (device_manager, "device-added",
clutter_seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
meta_wayland_seat_update_capabilities (seat, clutter_seat);
g_signal_connect (clutter_seat, "device-added",
G_CALLBACK (meta_wayland_seat_devices_updated), seat);
g_signal_connect (device_manager, "device-removed",
g_signal_connect (clutter_seat, "device-removed",
G_CALLBACK (meta_wayland_seat_devices_updated), seat);
wl_global_create (display, &wl_seat_interface, META_WL_SEAT_VERSION, seat, bind_seat);
@ -254,10 +256,10 @@ meta_wayland_seat_init (MetaWaylandCompositor *compositor)
void
meta_wayland_seat_free (MetaWaylandSeat *seat)
{
ClutterDeviceManager *device_manager;
ClutterSeat *clutter_seat;
device_manager = clutter_device_manager_get_default ();
g_signal_handlers_disconnect_by_data (device_manager, seat);
clutter_seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
g_signal_handlers_disconnect_by_data (clutter_seat, seat);
meta_wayland_seat_set_capabilities (seat, 0);
g_object_unref (seat->pointer);

View File

@ -131,11 +131,6 @@ meta_wayland_tablet_manager_init (MetaWaylandCompositor *compositor)
void
meta_wayland_tablet_manager_free (MetaWaylandTabletManager *tablet_manager)
{
ClutterDeviceManager *device_manager;
device_manager = clutter_device_manager_get_default ();
g_signal_handlers_disconnect_by_data (device_manager, tablet_manager);
g_hash_table_destroy (tablet_manager->seats);
g_slice_free (MetaWaylandTabletManager, tablet_manager);
}

View File

@ -260,12 +260,12 @@ meta_wayland_tablet_seat_new (MetaWaylandTabletManager *manager,
MetaWaylandSeat *seat)
{
MetaWaylandTabletSeat *tablet_seat;
const GSList *devices, *l;
GList *devices, *l;
tablet_seat = g_slice_new0 (MetaWaylandTabletSeat);
tablet_seat->manager = manager;
tablet_seat->seat = seat;
tablet_seat->device_manager = clutter_device_manager_get_default ();
tablet_seat->clutter_seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
tablet_seat->tablets = g_hash_table_new_full (NULL, NULL, NULL,
(GDestroyNotify) meta_wayland_tablet_free);
tablet_seat->tools = g_hash_table_new_full (NULL, NULL, NULL,
@ -274,18 +274,20 @@ meta_wayland_tablet_seat_new (MetaWaylandTabletManager *manager,
(GDestroyNotify) meta_wayland_tablet_pad_free);
wl_list_init (&tablet_seat->resource_list);
g_signal_connect_swapped (tablet_seat->device_manager, "device-added",
g_signal_connect_swapped (tablet_seat->clutter_seat, "device-added",
G_CALLBACK (meta_wayland_tablet_seat_device_added),
tablet_seat);
g_signal_connect_swapped (tablet_seat->device_manager, "device-removed",
g_signal_connect_swapped (tablet_seat->clutter_seat, "device-removed",
G_CALLBACK (meta_wayland_tablet_seat_device_removed),
tablet_seat);
devices = clutter_device_manager_peek_devices (tablet_seat->device_manager);
devices = clutter_seat_list_devices (tablet_seat->clutter_seat);
for (l = devices; l; l = l->next)
meta_wayland_tablet_seat_device_added (tablet_seat, l->data);
g_list_free (devices);
return tablet_seat;
}
@ -300,7 +302,7 @@ meta_wayland_tablet_seat_free (MetaWaylandTabletSeat *tablet_seat)
wl_list_init (wl_resource_get_link (resource));
}
g_signal_handlers_disconnect_by_data (tablet_seat->device_manager,
g_signal_handlers_disconnect_by_data (tablet_seat->clutter_seat,
tablet_seat);
g_hash_table_destroy (tablet_seat->tablets);
g_hash_table_destroy (tablet_seat->tools);
@ -476,12 +478,12 @@ static GList *
lookup_grouped_devices (ClutterInputDevice *device,
ClutterInputDeviceType type)
{
ClutterDeviceManager *device_manager;
const GSList *devices, *l;
ClutterSeat *clutter_seat;
GList *devices, *l;
GList *group = NULL;
device_manager = clutter_device_manager_get_default ();
devices = clutter_device_manager_peek_devices (device_manager);
clutter_seat = clutter_input_device_get_seat (device);
devices = clutter_seat_list_devices (clutter_seat);
for (l = devices; l; l = l->next)
{
@ -496,6 +498,8 @@ lookup_grouped_devices (ClutterInputDevice *device,
group = g_list_prepend (group, l->data);
}
g_list_free (devices);
return group;
}

View File

@ -31,7 +31,7 @@ struct _MetaWaylandTabletSeat
{
MetaWaylandTabletManager *manager;
MetaWaylandSeat *seat;
ClutterDeviceManager *device_manager;
ClutterSeat *clutter_seat;
struct wl_list resource_list;
GHashTable *tablets;

View File

@ -32,8 +32,8 @@
#ifdef HAVE_NATIVE_BACKEND
#include <libinput.h>
#include "backends/native/meta-backend-native.h"
#include "backends/native/meta-device-manager-native.h"
#include "backends/native/meta-event-native.h"
#include "backends/native/meta-seat-native.h"
#endif
G_DEFINE_TYPE (MetaWaylandTouch, meta_wayland_touch,
@ -553,8 +553,6 @@ evdev_filter_func (struct libinput_event *event,
void
meta_wayland_touch_enable (MetaWaylandTouch *touch)
{
ClutterDeviceManager *manager;
#ifdef HAVE_NATIVE_BACKEND
touch->touch_surfaces = g_hash_table_new_full (NULL, NULL, NULL,
(GDestroyNotify) touch_surface_free);
@ -564,13 +562,16 @@ meta_wayland_touch_enable (MetaWaylandTouch *touch)
wl_list_init (&touch->resource_list);
manager = clutter_device_manager_get_default ();
touch->device = clutter_device_manager_get_core_device (manager, CLUTTER_TOUCHSCREEN_DEVICE);
#ifdef HAVE_NATIVE_BACKEND
MetaBackend *backend = meta_get_backend ();
if (META_IS_BACKEND_NATIVE (backend))
meta_device_manager_native_add_filter (evdev_filter_func, touch, NULL);
{
ClutterBackend *backend = clutter_get_default_backend ();
ClutterSeat *seat = clutter_backend_get_default_seat (backend);
meta_seat_native_add_filter (META_SEAT_NATIVE (seat),
evdev_filter_func, touch, NULL);
}
#endif
}
@ -580,7 +581,13 @@ meta_wayland_touch_disable (MetaWaylandTouch *touch)
#ifdef HAVE_NATIVE_BACKEND
MetaBackend *backend = meta_get_backend ();
if (META_IS_BACKEND_NATIVE (backend))
meta_device_manager_native_remove_filter (evdev_filter_func, touch);
{
ClutterBackend *backend = clutter_get_default_backend ();
ClutterSeat *seat = clutter_backend_get_default_seat (backend);
meta_seat_native_remove_filter (META_SEAT_NATIVE (seat),
evdev_filter_func, touch);
}
#endif
meta_wayland_touch_cancel (touch);

View File

@ -44,7 +44,6 @@ struct _MetaWaylandTouch
GHashTable *touch_surfaces; /* HT of MetaWaylandSurface->MetaWaylandTouchSurface */
GHashTable *touches; /* HT of sequence->MetaWaylandTouchInfo */
ClutterInputDevice *device;
guint64 frame_slots;
};