Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-25 21:09:18 -04:00
|
|
|
/*
|
|
|
|
* Clutter.
|
|
|
|
*
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
|
|
|
*
|
|
|
|
* Copyright © 2011 Intel Corp.
|
|
|
|
* 2011 Giovanni Campagna <scampa.giovanni@gmail.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Author: Emmanuele Bassi <ebassi@linux.intel.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "clutter-input-device-gdk.h"
|
|
|
|
|
2015-04-22 09:15:42 -04:00
|
|
|
#ifdef GDK_WINDOWING_X11
|
|
|
|
#include <gdk/gdkx.h>
|
|
|
|
#endif
|
|
|
|
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-25 21:09:18 -04:00
|
|
|
#include "clutter-debug.h"
|
|
|
|
#include "clutter-device-manager-private.h"
|
|
|
|
#include "clutter-private.h"
|
|
|
|
#include "clutter-stage-private.h"
|
|
|
|
|
|
|
|
#include "clutter-backend-gdk.h"
|
|
|
|
#include "clutter-stage-gdk.h"
|
|
|
|
|
|
|
|
typedef struct _ClutterInputDeviceClass ClutterInputDeviceGdkClass;
|
|
|
|
|
|
|
|
#define clutter_input_device_gdk_get_type _clutter_input_device_gdk_get_type
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (ClutterInputDeviceGdk,
|
|
|
|
clutter_input_device_gdk,
|
|
|
|
CLUTTER_TYPE_INPUT_DEVICE);
|
|
|
|
|
|
|
|
static int device_int_counter;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PROP_0,
|
|
|
|
PROP_GDK_DEVICE,
|
|
|
|
PROP_LAST
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_input_device_gdk_set_property (GObject *gobject,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
ClutterInputDeviceGdk *self = CLUTTER_INPUT_DEVICE_GDK (gobject);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_GDK_DEVICE:
|
|
|
|
self->gdk_device = GDK_DEVICE (g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_input_device_gdk_class_init (ClutterInputDeviceGdkClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
gobject_class->set_property = clutter_input_device_gdk_set_property;
|
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class, PROP_GDK_DEVICE,
|
|
|
|
g_param_spec_object ("gdk-device",
|
|
|
|
"GdkDevice",
|
|
|
|
"The GDK device",
|
|
|
|
GDK_TYPE_DEVICE,
|
|
|
|
CLUTTER_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_input_device_gdk_init (ClutterInputDeviceGdk *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ClutterInputDevice*
|
|
|
|
_clutter_input_device_gdk_new (ClutterDeviceManager *manager,
|
|
|
|
GdkDevice *device)
|
|
|
|
{
|
|
|
|
ClutterBackend *backend;
|
|
|
|
ClutterInputDevice *clutter_device;
|
|
|
|
ClutterInputMode input_mode = CLUTTER_INPUT_MODE_FLOATING;
|
|
|
|
ClutterInputDeviceType device_type = CLUTTER_EXTENSION_DEVICE;
|
|
|
|
gboolean has_cursor = FALSE;
|
|
|
|
const gchar *name;
|
|
|
|
gboolean is_enabled = FALSE;
|
2015-04-22 09:15:42 -04:00
|
|
|
gint device_id;
|
|
|
|
const char *vendor_id = NULL;
|
|
|
|
const char *product_id = NULL;
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-25 21:09:18 -04:00
|
|
|
|
|
|
|
g_object_get (manager, "backend", &backend, NULL);
|
|
|
|
|
|
|
|
/* yay for name consistency */
|
|
|
|
switch (gdk_device_get_device_type (device))
|
|
|
|
{
|
|
|
|
case GDK_DEVICE_TYPE_MASTER:
|
|
|
|
input_mode = CLUTTER_INPUT_MODE_MASTER;
|
|
|
|
is_enabled = TRUE;
|
|
|
|
break;
|
|
|
|
case GDK_DEVICE_TYPE_SLAVE:
|
|
|
|
input_mode = CLUTTER_INPUT_MODE_SLAVE;
|
|
|
|
is_enabled = FALSE;
|
|
|
|
break;
|
|
|
|
case GDK_DEVICE_TYPE_FLOATING:
|
|
|
|
input_mode = CLUTTER_INPUT_MODE_FLOATING;
|
|
|
|
is_enabled = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (gdk_device_get_source (device))
|
|
|
|
{
|
|
|
|
case GDK_SOURCE_MOUSE:
|
|
|
|
device_type = CLUTTER_POINTER_DEVICE;
|
|
|
|
break;
|
|
|
|
case GDK_SOURCE_PEN:
|
|
|
|
device_type = CLUTTER_PEN_DEVICE;
|
|
|
|
break;
|
|
|
|
case GDK_SOURCE_ERASER:
|
|
|
|
device_type = CLUTTER_ERASER_DEVICE;
|
|
|
|
break;
|
|
|
|
case GDK_SOURCE_CURSOR:
|
|
|
|
device_type = CLUTTER_CURSOR_DEVICE;
|
|
|
|
break;
|
|
|
|
case GDK_SOURCE_KEYBOARD:
|
|
|
|
device_type = CLUTTER_KEYBOARD_DEVICE;
|
|
|
|
break;
|
2012-03-10 10:39:16 -05:00
|
|
|
case GDK_SOURCE_TOUCHSCREEN:
|
|
|
|
device_type = CLUTTER_TOUCHSCREEN_DEVICE;
|
|
|
|
break;
|
|
|
|
case GDK_SOURCE_TOUCHPAD:
|
|
|
|
device_type = CLUTTER_TOUCHPAD_DEVICE;
|
|
|
|
break;
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-25 21:09:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (device_type != CLUTTER_KEYBOARD_DEVICE)
|
|
|
|
has_cursor = gdk_device_get_has_cursor (device);
|
2011-10-03 10:25:40 -04:00
|
|
|
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-25 21:09:18 -04:00
|
|
|
name = gdk_device_get_name (device);
|
|
|
|
|
2015-04-22 09:15:42 -04:00
|
|
|
#if defined(GDK_WINDOWING_X11)
|
|
|
|
/* If we're on X11, keep the device id in sync */
|
|
|
|
if (GDK_IS_X11_DISPLAY (gdk_device_get_display (device)))
|
|
|
|
device_id = gdk_x11_device_get_id (device);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
device_id = device_int_counter++;
|
|
|
|
|
|
|
|
if (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_MASTER)
|
|
|
|
{
|
|
|
|
product_id = gdk_device_get_product_id (device);
|
|
|
|
vendor_id = gdk_device_get_vendor_id (device);
|
|
|
|
}
|
|
|
|
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-25 21:09:18 -04:00
|
|
|
clutter_device = g_object_new (CLUTTER_TYPE_INPUT_DEVICE_GDK,
|
|
|
|
"backend", backend,
|
|
|
|
"device-manager", manager,
|
|
|
|
"device-mode", input_mode,
|
|
|
|
"device-type", device_type,
|
|
|
|
"has-cursor", has_cursor,
|
|
|
|
"gdk-device", device,
|
2015-04-22 09:15:42 -04:00
|
|
|
"id", device_id,
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-25 21:09:18 -04:00
|
|
|
"name", name,
|
|
|
|
"enabled", is_enabled,
|
2015-04-22 09:15:42 -04:00
|
|
|
"product-id", product_id,
|
|
|
|
"vendor-id", vendor_id,
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-25 21:09:18 -04:00
|
|
|
NULL);
|
|
|
|
return clutter_device;
|
|
|
|
}
|