diff --git a/clutter/clutter/Makefile.am b/clutter/clutter/Makefile.am index 31506f401..c588d6866 100644 --- a/clutter/clutter/Makefile.am +++ b/clutter/clutter/Makefile.am @@ -168,6 +168,7 @@ source_c = \ clutter-image.c \ clutter-input-device.c \ clutter-input-device-tool.c \ + clutter-virtual-input-device.c \ clutter-interval.c \ clutter-keyframe-transition.c \ clutter-keysyms-table.c \ @@ -239,6 +240,7 @@ source_h_priv = \ clutter-stage-manager-private.h \ clutter-stage-private.h \ clutter-stage-window.h \ + clutter-virtual-input-device.h \ $(NULL) # private source code; these should not be introspected @@ -418,6 +420,14 @@ x11_source_h_priv += \ x11/clutter-input-device-xi2.h \ $(NULL) +x11_source_c += \ + x11/clutter-virtual-input-device-x11.c \ + $(NULL) + +x11_source_h_priv += \ + x11/clutter-virtual-input-device-x11.h \ + $(NULL) + backend_source_h += $(x11_source_h) backend_source_c += $(x11_source_c) backend_source_h_priv += $(x11_source_h_priv) @@ -458,6 +468,7 @@ backend_source_c += $(glx_source_c) evdev_c_priv = \ evdev/clutter-device-manager-evdev.c \ evdev/clutter-input-device-evdev.c \ + evdev/clutter-virtual-input-device-evdev.c \ evdev/clutter-event-evdev.c \ evdev/clutter-input-device-tool-evdev.c \ $(NULL) @@ -465,6 +476,7 @@ evdev_h_priv = \ evdev/clutter-device-manager-evdev.h \ evdev/clutter-input-device-evdev.h \ evdev/clutter-input-device-tool-evdev.h \ + evdev/clutter-virtual-input-device-evdev.h \ $(NULL) evdev_h = evdev/clutter-evdev.h diff --git a/clutter/clutter/clutter-device-manager.c b/clutter/clutter/clutter-device-manager.c index 885f9735e..e532bbe7e 100644 --- a/clutter/clutter/clutter-device-manager.c +++ b/clutter/clutter/clutter-device-manager.c @@ -47,6 +47,7 @@ #include "clutter-marshal.h" #include "clutter-private.h" #include "clutter-stage-private.h" +#include "clutter-virtual-input-device.h" struct _ClutterDeviceManagerPrivate { @@ -435,3 +436,16 @@ _clutter_device_manager_get_backend (ClutterDeviceManager *manager) return manager->priv->backend; } + +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); +} diff --git a/clutter/clutter/clutter-device-manager.h b/clutter/clutter/clutter-device-manager.h index 0bb9041ef..da6bd2cb2 100644 --- a/clutter/clutter/clutter-device-manager.h +++ b/clutter/clutter/clutter-device-manager.h @@ -83,6 +83,8 @@ struct _ClutterDeviceManagerClass ClutterInputDevice *device); void (* select_stage_events) (ClutterDeviceManager *manager, ClutterStage *stage); + ClutterVirtualInputDevice *(* create_virtual_device) (ClutterDeviceManager *manager, + ClutterInputDeviceType device_type); /* padding */ gpointer _padding[7]; @@ -105,6 +107,10 @@ CLUTTER_AVAILABLE_IN_1_2 ClutterInputDevice * clutter_device_manager_get_core_device (ClutterDeviceManager *device_manager, ClutterInputDeviceType device_type); +CLUTTER_AVAILABLE_IN_ALL +ClutterVirtualInputDevice *clutter_device_manager_create_virtual_device (ClutterDeviceManager *device_manager, + ClutterInputDeviceType device_type); + G_END_DECLS #endif /* __CLUTTER_DEVICE_MANAGER_H__ */ diff --git a/clutter/clutter/clutter-types.h b/clutter/clutter/clutter-types.h index 1e26105fb..bc71c7d00 100644 --- a/clutter/clutter/clutter-types.h +++ b/clutter/clutter/clutter-types.h @@ -95,6 +95,7 @@ typedef struct _ClutterState ClutterState; typedef struct _ClutterInputDeviceTool ClutterInputDeviceTool; typedef struct _ClutterInputDevice ClutterInputDevice; +typedef struct _ClutterVirtualInputDevice ClutterVirtualInputDevice; typedef CoglMatrix ClutterMatrix; diff --git a/clutter/clutter/clutter-virtual-input-device.c b/clutter/clutter/clutter-virtual-input-device.c new file mode 100644 index 000000000..7ac35a1c0 --- /dev/null +++ b/clutter/clutter/clutter-virtual-input-device.c @@ -0,0 +1,92 @@ +/* + * Clutter. + * + * An OpenGL based 'interactive canvas' library. + * + * Copyright (C) 2016 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 . + * + * Author: Jonas Ådahl + */ + +#ifdef HAVE_CONFIG_H +#include "clutter-build-config.h" +#endif + +#include + +#include "clutter-virtual-input-device.h" + +G_DEFINE_TYPE (ClutterVirtualInputDevice, + clutter_virtual_input_device, + G_TYPE_OBJECT) + +static void +clutter_virtual_input_device_init (ClutterVirtualInputDevice *virtual_device) +{ +} + +static void +clutter_virtual_input_device_class_init (ClutterVirtualInputDeviceClass *klass) +{ +} + +void +clutter_virtual_input_device_notify_relative_motion (ClutterVirtualInputDevice *virtual_device, + uint64_t time_us, + double dx, + double dy) +{ + ClutterVirtualInputDeviceClass *klass = + CLUTTER_VIRTUAL_INPUT_DEVICE_GET_CLASS (virtual_device); + + klass->notify_relative_motion (virtual_device, time_us, dx, dy); +} + +void +clutter_virtual_input_device_notify_absolute_motion (ClutterVirtualInputDevice *virtual_device, + uint64_t time_us, + double x, + double y) +{ + ClutterVirtualInputDeviceClass *klass = + CLUTTER_VIRTUAL_INPUT_DEVICE_GET_CLASS (virtual_device); + + klass->notify_absolute_motion (virtual_device, time_us, x, y); +} + +void +clutter_virtual_input_device_notify_button (ClutterVirtualInputDevice *virtual_device, + uint64_t time_us, + uint32_t button, + ClutterButtonState button_state) +{ + ClutterVirtualInputDeviceClass *klass = + CLUTTER_VIRTUAL_INPUT_DEVICE_GET_CLASS (virtual_device); + + klass->notify_button (virtual_device, time_us, button, button_state); +} + +void +clutter_virtual_input_device_notify_key (ClutterVirtualInputDevice *virtual_device, + uint64_t time_us, + uint32_t key, + ClutterKeyState key_state) +{ + ClutterVirtualInputDeviceClass *klass = + CLUTTER_VIRTUAL_INPUT_DEVICE_GET_CLASS (virtual_device); + + klass->notify_key (virtual_device, time_us, key, key_state); +} diff --git a/clutter/clutter/clutter-virtual-input-device.h b/clutter/clutter/clutter-virtual-input-device.h new file mode 100644 index 000000000..c51152118 --- /dev/null +++ b/clutter/clutter/clutter-virtual-input-device.h @@ -0,0 +1,93 @@ +/* + * Clutter. + * + * An OpenGL based 'interactive canvas' library. + * + * Copyright (C) 2016 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 . + * + * Author: Jonas Ådahl + */ + +#ifndef __CLUTTER_VIRTUAL_INPUT_DEVICE_H__ +#define __CLUTTER_VIRTUAL_INPUT_DEVICE_H__ + +#include +#include + +#define CLUTTER_TYPE_VIRTUAL_INPUT_DEVICE (clutter_virtual_input_device_get_type ()) +G_DECLARE_DERIVABLE_TYPE (ClutterVirtualInputDevice, + clutter_virtual_input_device, + CLUTTER, VIRTUAL_INPUT_DEVICE, + GObject) + +typedef enum _ClutterButtonState +{ + CLUTTER_BUTTON_STATE_RELEASED, + CLUTTER_BUTTON_STATE_PRESSED +} ClutterButtonState; + +typedef enum _ClutterKeyState +{ + CLUTTER_KEY_STATE_RELEASED, + CLUTTER_KEY_STATE_PRESSED +} ClutterKeyState; + +struct _ClutterVirtualInputDeviceClass +{ + GObjectClass parent_class; + + void (*notify_relative_motion) (ClutterVirtualInputDevice *virtual_device, + uint64_t time_us, + double dx, + double dy); + + void (*notify_absolute_motion) (ClutterVirtualInputDevice *virtual_device, + uint64_t time_us, + double x, + double y); + + void (*notify_button) (ClutterVirtualInputDevice *virtual_device, + uint64_t time_us, + uint32_t button, + ClutterButtonState button_state); + + void (*notify_key) (ClutterVirtualInputDevice *virtual_device, + uint64_t time_us, + uint32_t key, + ClutterKeyState key_state); +}; + +void clutter_virtual_input_device_notify_relative_motion (ClutterVirtualInputDevice *virtual_device, + uint64_t time_us, + double dx, + double dy); + +void clutter_virtual_input_device_notify_absolute_motion (ClutterVirtualInputDevice *virtual_device, + uint64_t time_us, + double x, + double y); + +void clutter_virtual_input_device_notify_button (ClutterVirtualInputDevice *virtual_device, + uint64_t time_us, + uint32_t button, + ClutterButtonState button_state); + +void clutter_virtual_input_device_notify_key (ClutterVirtualInputDevice *virtual_device, + uint64_t time_us, + uint32_t key, + ClutterKeyState key_state); + +#endif /* __CLUTTER_VIRTUAL_INPUT_DEVICE_H__ */ diff --git a/clutter/clutter/clutter.h b/clutter/clutter/clutter.h index 6f6a37d7a..cdf54ac01 100644 --- a/clutter/clutter/clutter.h +++ b/clutter/clutter/clutter.h @@ -107,6 +107,7 @@ #include "clutter-transition.h" #include "clutter-units.h" #include "clutter-version.h" +#include "clutter-virtual-input-device.h" #include "clutter-zoom-action.h" #include "clutter-deprecated.h" diff --git a/clutter/clutter/evdev/clutter-device-manager-evdev.c b/clutter/clutter/evdev/clutter-device-manager-evdev.c index 1a86030a3..865f461eb 100644 --- a/clutter/clutter/evdev/clutter-device-manager-evdev.c +++ b/clutter/clutter/evdev/clutter-device-manager-evdev.c @@ -46,6 +46,7 @@ #include "clutter-device-manager-private.h" #include "clutter-event-private.h" #include "clutter-input-device-evdev.h" +#include "clutter-virtual-input-device-evdev.h" #include "clutter-main.h" #include "clutter-private.h" #include "clutter-stage-manager.h" @@ -2413,6 +2414,13 @@ static const struct libinput_interface libinput_interface = { close_restricted }; +static ClutterVirtualInputDevice * +clutter_device_manager_evdev_create_virtual_device (ClutterDeviceManager *manager, + ClutterInputDeviceType device_type) +{ + return g_object_new (CLUTTER_TYPE_VIRTUAL_INPUT_DEVICE_EVDEV, NULL); +} + /* * GObject implementation */ @@ -2539,6 +2547,7 @@ clutter_device_manager_evdev_class_init (ClutterDeviceManagerEvdevClass *klass) manager_class->get_devices = clutter_device_manager_evdev_get_devices; manager_class->get_core_device = clutter_device_manager_evdev_get_core_device; manager_class->get_device = clutter_device_manager_evdev_get_device; + manager_class->create_virtual_device = clutter_device_manager_evdev_create_virtual_device; } static void diff --git a/clutter/clutter/evdev/clutter-virtual-input-device-evdev.c b/clutter/clutter/evdev/clutter-virtual-input-device-evdev.c new file mode 100644 index 000000000..f8786bdd6 --- /dev/null +++ b/clutter/clutter/evdev/clutter-virtual-input-device-evdev.c @@ -0,0 +1,89 @@ +/* + * Clutter. + * + * An OpenGL based 'interactive canvas' library. + * + * Copyright (C) 2016 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 . + * + * Author: Jonas Ådahl + */ + +#ifdef HAVE_CONFIG_H +#include "clutter-build-config.h" +#endif + +#include + +#include "clutter-virtual-input-device.h" +#include "evdev/clutter-virtual-input-device-evdev.h" + +struct _ClutterVirtualInputDeviceEvdev +{ + ClutterVirtualInputDevice parent; +}; + +G_DEFINE_TYPE (ClutterVirtualInputDeviceEvdev, + clutter_virtual_input_device_evdev, + CLUTTER_TYPE_VIRTUAL_INPUT_DEVICE) + +static void +clutter_virtual_input_device_evdev_notify_relative_motion (ClutterVirtualInputDevice *virtual_device, + uint64_t time_us, + double dx, + double dy) +{ +} + +static void +clutter_virtual_input_device_evdev_notify_absolute_motion (ClutterVirtualInputDevice *virtual_device, + uint64_t time_us, + double x, + double y) +{ +} + +static void +clutter_virtual_input_device_evdev_notify_button (ClutterVirtualInputDevice *virtual_device, + uint64_t time_us, + uint32_t button, + ClutterButtonState button_state) +{ +} + +static void +clutter_virtual_input_device_evdev_notify_key (ClutterVirtualInputDevice *virtual_device, + uint64_t time_us, + uint32_t key, + ClutterKeyState key_state) +{ +} + +static void +clutter_virtual_input_device_evdev_init (ClutterVirtualInputDeviceEvdev *virtual_device_evdev) +{ +} + +static void +clutter_virtual_input_device_evdev_class_init (ClutterVirtualInputDeviceEvdevClass *klass) +{ + ClutterVirtualInputDeviceClass *virtual_input_device_class = + CLUTTER_VIRTUAL_INPUT_DEVICE_CLASS (klass); + + virtual_input_device_class->notify_relative_motion = clutter_virtual_input_device_evdev_notify_relative_motion; + virtual_input_device_class->notify_absolute_motion = clutter_virtual_input_device_evdev_notify_absolute_motion; + virtual_input_device_class->notify_button = clutter_virtual_input_device_evdev_notify_button; + virtual_input_device_class->notify_key = clutter_virtual_input_device_evdev_notify_key; +} diff --git a/clutter/clutter/evdev/clutter-virtual-input-device-evdev.h b/clutter/clutter/evdev/clutter-virtual-input-device-evdev.h new file mode 100644 index 000000000..9bb8db016 --- /dev/null +++ b/clutter/clutter/evdev/clutter-virtual-input-device-evdev.h @@ -0,0 +1,35 @@ +/* + * Clutter. + * + * An OpenGL based 'interactive canvas' library. + * + * Copyright (C) 2016 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 . + * + * Author: Jonas Ådahl + */ + +#ifndef __CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV_H__ +#define __CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV_H__ + +#include "clutter-virtual-input-device.h" + +#define CLUTTER_TYPE_VIRTUAL_INPUT_DEVICE_EVDEV (clutter_virtual_input_device_evdev_get_type ()) +G_DECLARE_FINAL_TYPE (ClutterVirtualInputDeviceEvdev, + clutter_virtual_input_device_evdev, + CLUTTER, VIRTUAL_INPUT_DEVICE_EVDEV, + ClutterVirtualInputDevice) + +#endif /* __CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV_H__ */ diff --git a/clutter/clutter/x11/clutter-device-manager-core-x11.c b/clutter/clutter/x11/clutter-device-manager-core-x11.c index 497b40bb0..a4106000c 100644 --- a/clutter/clutter/x11/clutter-device-manager-core-x11.c +++ b/clutter/clutter/x11/clutter-device-manager-core-x11.c @@ -28,6 +28,7 @@ #include "clutter-backend-x11.h" #include "clutter-input-device-core-x11.h" #include "clutter-stage-x11.h" +#include "clutter-virtual-input-device-x11.h" #include "clutter-backend.h" #include "clutter-debug.h" @@ -480,6 +481,13 @@ clutter_device_manager_x11_get_device (ClutterDeviceManager *manager, GINT_TO_POINTER (id)); } +static ClutterVirtualInputDevice * +clutter_device_manager_x11_create_virtual_device (ClutterDeviceManager *device_manager, + ClutterInputDeviceType device_type) +{ + return g_object_new (CLUTTER_TYPE_VIRTUAL_INPUT_DEVICE_X11, NULL); +} + static void clutter_device_manager_x11_set_property (GObject *gobject, guint prop_id, @@ -526,6 +534,7 @@ clutter_device_manager_x11_class_init (ClutterDeviceManagerX11Class *klass) manager_class->get_devices = clutter_device_manager_x11_get_devices; manager_class->get_core_device = clutter_device_manager_x11_get_core_device; manager_class->get_device = clutter_device_manager_x11_get_device; + manager_class->create_virtual_device = clutter_device_manager_x11_create_virtual_device; } static void diff --git a/clutter/clutter/x11/clutter-virtual-input-device-x11.c b/clutter/clutter/x11/clutter-virtual-input-device-x11.c new file mode 100644 index 000000000..a13915b12 --- /dev/null +++ b/clutter/clutter/x11/clutter-virtual-input-device-x11.c @@ -0,0 +1,89 @@ +/* + * Clutter. + * + * An OpenGL based 'interactive canvas' library. + * + * Copyright (C) 2016 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 . + * + * Author: Jonas Ådahl + */ + +#ifdef HAVE_CONFIG_H +#include "clutter-build-config.h" +#endif + +#include + +#include "clutter-virtual-input-device.h" +#include "x11/clutter-virtual-input-device-x11.h" + +struct _ClutterVirtualInputDeviceX11 +{ + ClutterVirtualInputDevice parent; +}; + +G_DEFINE_TYPE (ClutterVirtualInputDeviceX11, + clutter_virtual_input_device_x11, + CLUTTER_TYPE_VIRTUAL_INPUT_DEVICE) + +static void +clutter_virtual_input_device_x11_notify_relative_motion (ClutterVirtualInputDevice *virtual_device, + uint64_t time_us, + double dx, + double dy) +{ +} + +static void +clutter_virtual_input_device_x11_notify_absolute_motion (ClutterVirtualInputDevice *virtual_device, + uint64_t time_us, + double x, + double y) +{ +} + +static void +clutter_virtual_input_device_x11_notify_button (ClutterVirtualInputDevice *virtual_device, + uint64_t time_us, + uint32_t button, + ClutterButtonState button_state) +{ +} + +static void +clutter_virtual_input_device_x11_notify_key (ClutterVirtualInputDevice *virtual_device, + uint64_t time_us, + uint32_t key, + ClutterKeyState key_state) +{ +} + +static void +clutter_virtual_input_device_x11_init (ClutterVirtualInputDeviceX11 *virtual_device_x11) +{ +} + +static void +clutter_virtual_input_device_x11_class_init (ClutterVirtualInputDeviceX11Class *klass) +{ + ClutterVirtualInputDeviceClass *virtual_input_device_class = + CLUTTER_VIRTUAL_INPUT_DEVICE_CLASS (klass); + + virtual_input_device_class->notify_relative_motion = clutter_virtual_input_device_x11_notify_relative_motion; + virtual_input_device_class->notify_absolute_motion = clutter_virtual_input_device_x11_notify_absolute_motion; + virtual_input_device_class->notify_button = clutter_virtual_input_device_x11_notify_button; + virtual_input_device_class->notify_key = clutter_virtual_input_device_x11_notify_key; +} diff --git a/clutter/clutter/x11/clutter-virtual-input-device-x11.h b/clutter/clutter/x11/clutter-virtual-input-device-x11.h new file mode 100644 index 000000000..b1bb101bf --- /dev/null +++ b/clutter/clutter/x11/clutter-virtual-input-device-x11.h @@ -0,0 +1,35 @@ +/* + * Clutter. + * + * An OpenGL based 'interactive canvas' library. + * + * Copyright (C) 2016 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 . + * + * Author: Jonas Ådahl + */ + +#ifndef __CLUTTER_VIRTUAL_INPUT_DEVICE_X11_H__ +#define __CLUTTER_VIRTUAL_INPUT_DEVICE_X11_H__ + +#include "clutter-virtual-input-device.h" + +#define CLUTTER_TYPE_VIRTUAL_INPUT_DEVICE_X11 (clutter_virtual_input_device_x11_get_type ()) +G_DECLARE_FINAL_TYPE (ClutterVirtualInputDeviceX11, + clutter_virtual_input_device_x11, + CLUTTER, VIRTUAL_INPUT_DEVICE_X11, + ClutterVirtualInputDevice) + +#endif /* __CLUTTER_VIRTUAL_INPUT_DEVICE_X11_H__ */