2007-11-15 14:45:27 +00:00
|
|
|
/* Clutter.
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
|
|
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
|
|
|
* Copyright (C) 2006-2007 OpenedHand
|
|
|
|
*
|
|
|
|
* 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
|
2010-03-01 12:56:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*
|
2007-11-15 14:45:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2009-01-06 12:11:07 +00:00
|
|
|
#include <glib/gi18n-lib.h>
|
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
#include <string.h>
|
2010-03-01 11:12:16 +00:00
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <sys/ioctl.h>
|
2010-03-01 11:12:16 +00:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
#include <fcntl.h>
|
2010-03-01 11:12:16 +00:00
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include "clutter-backend-x11.h"
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
#include "clutter-device-manager-core-x11.h"
|
|
|
|
#include "clutter-device-manager-xi2.h"
|
2010-06-21 14:43:31 +00:00
|
|
|
#include "clutter-settings-x11.h"
|
2007-11-15 14:45:27 +00:00
|
|
|
#include "clutter-stage-x11.h"
|
|
|
|
#include "clutter-x11.h"
|
2009-06-04 12:41:32 +00:00
|
|
|
|
2010-06-21 14:43:31 +00:00
|
|
|
#include "xsettings/xsettings-common.h"
|
|
|
|
|
2010-10-19 09:40:57 +00:00
|
|
|
#if HAVE_XCOMPOSITE
|
2008-06-30 14:36:49 +00:00
|
|
|
#include <X11/extensions/Xcomposite.h>
|
2010-10-19 09:40:57 +00:00
|
|
|
#endif
|
2008-06-23 09:55:42 +00:00
|
|
|
|
2010-10-19 09:40:57 +00:00
|
|
|
#if HAVE_XINPUT
|
2009-06-04 12:41:32 +00:00
|
|
|
#include <X11/extensions/XInput.h>
|
|
|
|
#endif
|
|
|
|
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
#if HAVE_XINPUT_2
|
|
|
|
#include <X11/extensions/XInput2.h>
|
|
|
|
#endif
|
|
|
|
|
2011-02-22 15:51:13 +00:00
|
|
|
#include <cogl/cogl.h>
|
2011-11-01 15:47:43 +00:00
|
|
|
#include <cogl/cogl-xlib.h>
|
2009-11-20 15:36:43 +00:00
|
|
|
|
2010-09-13 10:30:30 +00:00
|
|
|
#include "clutter-backend.h"
|
|
|
|
#include "clutter-debug.h"
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
#include "clutter-device-manager-private.h"
|
2011-02-18 16:27:49 +00:00
|
|
|
#include "clutter-event-private.h"
|
2010-09-13 10:30:30 +00:00
|
|
|
#include "clutter-main.h"
|
|
|
|
#include "clutter-private.h"
|
2007-11-15 14:45:27 +00:00
|
|
|
|
2011-01-20 15:39:28 +00:00
|
|
|
#define clutter_backend_x11_get_type _clutter_backend_x11_get_type
|
|
|
|
|
2011-11-04 16:52:44 +00:00
|
|
|
G_DEFINE_TYPE (ClutterBackendX11, clutter_backend_x11, CLUTTER_TYPE_BACKEND);
|
2007-11-15 14:45:27 +00:00
|
|
|
|
2007-11-17 18:11:14 +00:00
|
|
|
/* atoms; remember to add the code that assigns the atom value to
|
|
|
|
* the member of the ClutterBackendX11 structure if you add an
|
|
|
|
* atom name here. do not change the order!
|
|
|
|
*/
|
|
|
|
static const gchar *atom_names[] = {
|
2009-08-04 14:06:27 +00:00
|
|
|
"_NET_WM_PID",
|
2007-11-17 18:11:14 +00:00
|
|
|
"_NET_WM_PING",
|
|
|
|
"_NET_WM_STATE",
|
|
|
|
"_NET_WM_STATE_FULLSCREEN",
|
|
|
|
"_NET_WM_USER_TIME",
|
|
|
|
"WM_PROTOCOLS",
|
|
|
|
"WM_DELETE_WINDOW",
|
|
|
|
"_XEMBED",
|
|
|
|
"_XEMBED_INFO",
|
|
|
|
"_NET_WM_NAME",
|
|
|
|
"UTF8_STRING",
|
|
|
|
};
|
|
|
|
|
2010-10-25 12:07:50 +00:00
|
|
|
#define N_ATOM_NAMES G_N_ELEMENTS (atom_names)
|
2007-11-17 18:11:14 +00:00
|
|
|
|
2008-07-01 13:41:23 +00:00
|
|
|
/* various flags corresponding to pre init setup calls */
|
|
|
|
static gboolean _no_xevent_retrieval = FALSE;
|
2012-10-07 21:57:04 +00:00
|
|
|
static gboolean clutter_enable_xinput = TRUE;
|
2010-01-08 15:04:56 +00:00
|
|
|
static gboolean clutter_enable_argb = FALSE;
|
2008-07-01 13:41:23 +00:00
|
|
|
static Display *_foreign_dpy = NULL;
|
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
/* options */
|
|
|
|
static gchar *clutter_display_name = NULL;
|
2009-05-06 17:32:17 +00:00
|
|
|
static gint clutter_screen = -1;
|
2007-11-15 14:45:27 +00:00
|
|
|
static gboolean clutter_synchronise = FALSE;
|
|
|
|
|
|
|
|
/* X error trap */
|
|
|
|
static int TrappedErrorCode = 0;
|
|
|
|
static int (* old_error_handler) (Display *, XErrorEvent *);
|
|
|
|
|
2010-06-28 09:32:54 +00:00
|
|
|
static ClutterX11FilterReturn
|
|
|
|
xsettings_filter (XEvent *xevent,
|
|
|
|
ClutterEvent *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
ClutterBackendX11 *backend_x11 = data;
|
|
|
|
|
2010-07-06 16:13:55 +00:00
|
|
|
_clutter_xsettings_client_process_event (backend_x11->xsettings, xevent);
|
|
|
|
|
|
|
|
/* we always want the rest of the stack to get XSettings events, even
|
|
|
|
* if Clutter already handled them
|
|
|
|
*/
|
|
|
|
|
|
|
|
return CLUTTER_X11_FILTER_CONTINUE;
|
2010-06-28 09:32:54 +00:00
|
|
|
}
|
|
|
|
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
static ClutterX11FilterReturn
|
|
|
|
cogl_xlib_filter (XEvent *xevent,
|
|
|
|
ClutterEvent *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
ClutterX11FilterReturn retval;
|
2011-04-13 15:41:41 +00:00
|
|
|
CoglFilterReturn ret;
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
|
2010-11-05 12:28:33 +00:00
|
|
|
ret = cogl_xlib_handle_event (xevent);
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
switch (ret)
|
|
|
|
{
|
2011-04-13 15:41:41 +00:00
|
|
|
case COGL_FILTER_REMOVE:
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
retval = CLUTTER_X11_FILTER_REMOVE;
|
|
|
|
break;
|
|
|
|
|
2011-04-13 15:41:41 +00:00
|
|
|
case COGL_FILTER_CONTINUE:
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
default:
|
|
|
|
retval = CLUTTER_X11_FILTER_CONTINUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2010-06-21 14:43:31 +00:00
|
|
|
static void
|
|
|
|
clutter_backend_x11_xsettings_notify (const char *name,
|
|
|
|
XSettingsAction action,
|
|
|
|
XSettingsSetting *setting,
|
|
|
|
void *cb_data)
|
|
|
|
{
|
|
|
|
ClutterSettings *settings = clutter_settings_get_default ();
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
if (name == NULL || *name == '\0')
|
|
|
|
return;
|
|
|
|
|
2010-11-23 10:26:15 +00:00
|
|
|
if (setting == NULL)
|
|
|
|
return;
|
|
|
|
|
2010-06-21 15:10:49 +00:00
|
|
|
g_object_freeze_notify (G_OBJECT (settings));
|
|
|
|
|
2010-06-21 14:43:31 +00:00
|
|
|
for (i = 0; i < _n_clutter_settings_map; i++)
|
|
|
|
{
|
|
|
|
if (g_strcmp0 (name, CLUTTER_SETTING_X11_NAME (i)) == 0)
|
|
|
|
{
|
|
|
|
GValue value = { 0, };
|
|
|
|
|
|
|
|
switch (setting->type)
|
|
|
|
{
|
|
|
|
case XSETTINGS_TYPE_INT:
|
|
|
|
g_value_init (&value, G_TYPE_INT);
|
|
|
|
g_value_set_int (&value, setting->data.v_int);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XSETTINGS_TYPE_STRING:
|
|
|
|
g_value_init (&value, G_TYPE_STRING);
|
|
|
|
g_value_set_string (&value, setting->data.v_string);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XSETTINGS_TYPE_COLOR:
|
|
|
|
{
|
|
|
|
ClutterColor color;
|
|
|
|
|
|
|
|
color.red = (guint8) ((float) setting->data.v_color.red
|
|
|
|
/ 65535.0 * 255);
|
|
|
|
color.green = (guint8) ((float) setting->data.v_color.green
|
|
|
|
/ 65535.0 * 255);
|
|
|
|
color.blue = (guint8) ((float) setting->data.v_color.blue
|
|
|
|
/ 65535.0 * 255);
|
|
|
|
color.alpha = (guint8) ((float) setting->data.v_color.alpha
|
|
|
|
/ 65535.0 * 255);
|
|
|
|
|
|
|
|
g_value_init (&value, G_TYPE_BOXED);
|
|
|
|
clutter_value_set_color (&value, &color);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
CLUTTER_NOTE (BACKEND,
|
|
|
|
"Mapping XSETTING '%s' to 'ClutterSettings:%s'",
|
|
|
|
CLUTTER_SETTING_X11_NAME (i),
|
|
|
|
CLUTTER_SETTING_PROPERTY (i));
|
|
|
|
|
|
|
|
g_object_set_property (G_OBJECT (settings),
|
|
|
|
CLUTTER_SETTING_PROPERTY (i),
|
|
|
|
&value);
|
|
|
|
|
|
|
|
g_value_unset (&value);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-06-21 15:10:49 +00:00
|
|
|
|
|
|
|
g_object_thaw_notify (G_OBJECT (settings));
|
2010-06-21 14:43:31 +00:00
|
|
|
}
|
|
|
|
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
static void
|
|
|
|
clutter_backend_x11_create_device_manager (ClutterBackendX11 *backend_x11)
|
|
|
|
{
|
|
|
|
if (G_UNLIKELY (backend_x11->device_manager == NULL))
|
|
|
|
{
|
|
|
|
ClutterEventTranslator *translator;
|
2011-02-09 12:20:56 +00:00
|
|
|
ClutterBackend *backend;
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
|
|
|
|
#if defined(HAVE_XINPUT) || defined(HAVE_XINPUT_2)
|
|
|
|
if (clutter_enable_xinput)
|
|
|
|
{
|
|
|
|
int event_base, first_event, first_error;
|
|
|
|
|
|
|
|
if (XQueryExtension (backend_x11->xdpy, "XInputExtension",
|
|
|
|
&event_base,
|
|
|
|
&first_event,
|
|
|
|
&first_error))
|
|
|
|
{
|
2011-01-18 12:57:50 +00:00
|
|
|
#ifdef HAVE_XINPUT_2
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
int major = 2;
|
2012-03-19 12:16:53 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_XINPUT_2_2
|
|
|
|
int minor = 2;
|
|
|
|
#else
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
int minor = 0;
|
2012-03-19 12:16:53 +00:00
|
|
|
#endif /* HAVE_XINPUT_2_2 */
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
|
|
|
|
if (XIQueryVersion (backend_x11->xdpy, &major, &minor) != BadRequest)
|
|
|
|
{
|
|
|
|
CLUTTER_NOTE (BACKEND, "Creating XI2 device manager");
|
2011-01-18 13:15:20 +00:00
|
|
|
backend_x11->has_xinput = TRUE;
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
backend_x11->device_manager =
|
|
|
|
g_object_new (CLUTTER_TYPE_DEVICE_MANAGER_XI2,
|
|
|
|
"backend", backend_x11,
|
|
|
|
"opcode", event_base,
|
|
|
|
NULL);
|
2012-03-19 14:28:34 +00:00
|
|
|
|
|
|
|
backend_x11->xi_minor = minor;
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
}
|
|
|
|
else
|
2011-01-18 12:57:50 +00:00
|
|
|
#endif /* HAVE_XINPUT_2 */
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
{
|
|
|
|
CLUTTER_NOTE (BACKEND, "Creating Core+XI device manager");
|
2011-01-18 13:15:20 +00:00
|
|
|
backend_x11->has_xinput = TRUE;
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
backend_x11->device_manager =
|
|
|
|
g_object_new (CLUTTER_TYPE_DEVICE_MANAGER_X11,
|
|
|
|
"backend", backend_x11,
|
|
|
|
"event-base", first_event,
|
|
|
|
NULL);
|
2011-01-18 13:15:20 +00:00
|
|
|
|
2012-03-19 14:28:34 +00:00
|
|
|
backend_x11->xi_minor = -1;
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif /* HAVE_XINPUT || HAVE_XINPUT_2 */
|
|
|
|
{
|
|
|
|
CLUTTER_NOTE (BACKEND, "Creating Core device manager");
|
2011-01-18 13:15:20 +00:00
|
|
|
backend_x11->has_xinput = FALSE;
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
backend_x11->device_manager =
|
|
|
|
g_object_new (CLUTTER_TYPE_DEVICE_MANAGER_X11,
|
|
|
|
"backend", backend_x11,
|
|
|
|
NULL);
|
2012-03-19 14:28:34 +00:00
|
|
|
|
|
|
|
backend_x11->xi_minor = -1;
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
}
|
|
|
|
|
2011-02-09 12:20:56 +00:00
|
|
|
backend = CLUTTER_BACKEND (backend_x11);
|
2011-11-04 19:25:54 +00:00
|
|
|
backend->device_manager = backend_x11->device_manager;
|
|
|
|
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
translator = CLUTTER_EVENT_TRANSLATOR (backend_x11->device_manager);
|
2011-02-09 12:20:56 +00:00
|
|
|
_clutter_backend_add_event_translator (backend, translator);
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-18 12:57:50 +00:00
|
|
|
static void
|
|
|
|
clutter_backend_x11_create_keymap (ClutterBackendX11 *backend_x11)
|
|
|
|
{
|
|
|
|
if (backend_x11->keymap == NULL)
|
|
|
|
{
|
2011-02-09 12:20:56 +00:00
|
|
|
ClutterEventTranslator *translator;
|
|
|
|
ClutterBackend *backend;
|
|
|
|
|
2011-01-18 12:57:50 +00:00
|
|
|
backend_x11->keymap =
|
|
|
|
g_object_new (CLUTTER_TYPE_KEYMAP_X11,
|
|
|
|
"backend", backend_x11,
|
|
|
|
NULL);
|
2011-02-09 12:20:56 +00:00
|
|
|
|
|
|
|
backend = CLUTTER_BACKEND (backend_x11);
|
|
|
|
translator = CLUTTER_EVENT_TRANSLATOR (backend_x11->keymap);
|
|
|
|
_clutter_backend_add_event_translator (backend, translator);
|
2011-01-18 12:57:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-07 12:06:24 +00:00
|
|
|
static gboolean
|
|
|
|
clutter_backend_x11_pre_parse (ClutterBackend *backend,
|
|
|
|
GError **error)
|
2007-11-15 14:45:27 +00:00
|
|
|
{
|
|
|
|
const gchar *env_string;
|
|
|
|
|
|
|
|
/* we don't fail here if DISPLAY is not set, as the user
|
|
|
|
* might pass the --display command line switch
|
|
|
|
*/
|
|
|
|
env_string = g_getenv ("DISPLAY");
|
|
|
|
if (env_string)
|
|
|
|
{
|
|
|
|
clutter_display_name = g_strdup (env_string);
|
|
|
|
env_string = NULL;
|
|
|
|
}
|
|
|
|
|
2009-12-01 16:18:39 +00:00
|
|
|
env_string = g_getenv ("CLUTTER_DISABLE_ARGB_VISUAL");
|
|
|
|
if (env_string)
|
|
|
|
{
|
|
|
|
clutter_enable_argb = FALSE;
|
|
|
|
env_string = NULL;
|
|
|
|
}
|
|
|
|
|
2012-10-07 21:57:04 +00:00
|
|
|
env_string = g_getenv ("CLUTTER_DISABLE_XINPUT");
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
if (env_string)
|
|
|
|
{
|
2012-10-07 21:57:04 +00:00
|
|
|
clutter_enable_xinput = FALSE;
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
env_string = NULL;
|
|
|
|
}
|
|
|
|
|
2011-11-04 16:39:52 +00:00
|
|
|
return TRUE;
|
2007-11-15 14:45:27 +00:00
|
|
|
}
|
|
|
|
|
2012-03-07 12:06:24 +00:00
|
|
|
static gboolean
|
|
|
|
clutter_backend_x11_post_parse (ClutterBackend *backend,
|
|
|
|
GError **error)
|
2007-11-15 14:45:27 +00:00
|
|
|
{
|
|
|
|
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
|
2011-09-27 12:24:52 +00:00
|
|
|
ClutterSettings *settings;
|
|
|
|
Atom atoms[N_ATOM_NAMES];
|
|
|
|
double dpi;
|
2007-11-15 14:45:27 +00:00
|
|
|
|
2008-07-01 13:41:23 +00:00
|
|
|
if (_foreign_dpy)
|
|
|
|
backend_x11->xdpy = _foreign_dpy;
|
2011-09-27 12:24:52 +00:00
|
|
|
|
|
|
|
/* Only open connection if not already set by prior call to
|
2008-02-20 14:16:54 +00:00
|
|
|
* clutter_x11_set_display()
|
|
|
|
*/
|
2011-03-04 23:53:45 +00:00
|
|
|
if (backend_x11->xdpy == NULL)
|
2007-11-15 14:45:27 +00:00
|
|
|
{
|
2011-03-04 23:53:45 +00:00
|
|
|
if (clutter_display_name != NULL &&
|
|
|
|
*clutter_display_name != '\0')
|
2008-02-20 14:16:54 +00:00
|
|
|
{
|
2011-03-04 23:53:45 +00:00
|
|
|
CLUTTER_NOTE (BACKEND, "XOpenDisplay on '%s'", clutter_display_name);
|
|
|
|
|
2008-02-20 14:16:54 +00:00
|
|
|
backend_x11->xdpy = XOpenDisplay (clutter_display_name);
|
2010-05-27 08:07:11 +00:00
|
|
|
if (backend_x11->xdpy == NULL)
|
2008-10-31 12:48:26 +00:00
|
|
|
{
|
|
|
|
g_set_error (error, CLUTTER_INIT_ERROR,
|
|
|
|
CLUTTER_INIT_ERROR_BACKEND,
|
2009-03-17 14:12:01 +00:00
|
|
|
"Unable to open display '%s'",
|
2008-10-31 12:48:26 +00:00
|
|
|
clutter_display_name);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-02-20 14:16:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-04 23:53:45 +00:00
|
|
|
g_set_error_literal (error, CLUTTER_INIT_ERROR,
|
|
|
|
CLUTTER_INIT_ERROR_BACKEND,
|
|
|
|
"Unable to open display. You have to set the "
|
|
|
|
"DISPLAY environment variable, or use the "
|
|
|
|
"--display command line argument");
|
2008-02-20 14:16:54 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2007-11-15 14:45:27 +00:00
|
|
|
}
|
|
|
|
|
2011-03-04 23:53:45 +00:00
|
|
|
g_assert (backend_x11->xdpy != NULL);
|
|
|
|
|
2011-09-27 12:24:52 +00:00
|
|
|
CLUTTER_NOTE (BACKEND, "Getting the X screen");
|
2007-11-15 14:45:27 +00:00
|
|
|
|
2011-09-27 12:24:52 +00:00
|
|
|
settings = clutter_settings_get_default ();
|
2007-11-15 14:45:27 +00:00
|
|
|
|
2011-09-27 12:24:52 +00:00
|
|
|
/* Cogl needs to know the Xlib display connection for
|
|
|
|
CoglTexturePixmapX11 */
|
|
|
|
cogl_xlib_set_display (backend_x11->xdpy);
|
2010-09-13 10:30:30 +00:00
|
|
|
|
2011-09-27 12:24:52 +00:00
|
|
|
/* add event filter for Cogl events */
|
|
|
|
clutter_x11_add_filter (cogl_xlib_filter, NULL);
|
2010-05-19 15:13:07 +00:00
|
|
|
|
2011-09-27 12:24:52 +00:00
|
|
|
if (clutter_screen == -1)
|
|
|
|
backend_x11->xscreen = DefaultScreenOfDisplay (backend_x11->xdpy);
|
|
|
|
else
|
|
|
|
backend_x11->xscreen = ScreenOfDisplay (backend_x11->xdpy,
|
|
|
|
clutter_screen);
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
|
2011-09-27 12:24:52 +00:00
|
|
|
backend_x11->xscreen_num = XScreenNumberOfScreen (backend_x11->xscreen);
|
|
|
|
backend_x11->xscreen_width = WidthOfScreen (backend_x11->xscreen);
|
|
|
|
backend_x11->xscreen_height = HeightOfScreen (backend_x11->xscreen);
|
|
|
|
|
|
|
|
backend_x11->xwin_root = RootWindow (backend_x11->xdpy,
|
|
|
|
backend_x11->xscreen_num);
|
|
|
|
|
|
|
|
backend_x11->display_name = g_strdup (clutter_display_name);
|
|
|
|
|
|
|
|
dpi = (((double) DisplayHeight (backend_x11->xdpy, backend_x11->xscreen_num) * 25.4)
|
|
|
|
/ (double) DisplayHeightMM (backend_x11->xdpy, backend_x11->xscreen_num));
|
|
|
|
|
|
|
|
g_object_set (settings, "font-dpi", (int) dpi * 1024, NULL);
|
|
|
|
|
|
|
|
/* create XSETTINGS client */
|
|
|
|
backend_x11->xsettings =
|
|
|
|
_clutter_xsettings_client_new (backend_x11->xdpy,
|
|
|
|
backend_x11->xscreen_num,
|
|
|
|
clutter_backend_x11_xsettings_notify,
|
|
|
|
NULL,
|
|
|
|
backend_x11);
|
|
|
|
|
|
|
|
/* add event filter for XSETTINGS events */
|
|
|
|
clutter_x11_add_filter (xsettings_filter, backend_x11);
|
|
|
|
|
|
|
|
if (clutter_synchronise)
|
|
|
|
XSynchronize (backend_x11->xdpy, True);
|
|
|
|
|
|
|
|
XInternAtoms (backend_x11->xdpy,
|
|
|
|
(char **) atom_names, N_ATOM_NAMES,
|
|
|
|
False, atoms);
|
|
|
|
|
|
|
|
backend_x11->atom_NET_WM_PID = atoms[0];
|
|
|
|
backend_x11->atom_NET_WM_PING = atoms[1];
|
|
|
|
backend_x11->atom_NET_WM_STATE = atoms[2];
|
|
|
|
backend_x11->atom_NET_WM_STATE_FULLSCREEN = atoms[3];
|
|
|
|
backend_x11->atom_NET_WM_USER_TIME = atoms[4];
|
|
|
|
backend_x11->atom_WM_PROTOCOLS = atoms[5];
|
|
|
|
backend_x11->atom_WM_DELETE_WINDOW = atoms[6];
|
|
|
|
backend_x11->atom_XEMBED = atoms[7];
|
|
|
|
backend_x11->atom_XEMBED_INFO = atoms[8];
|
|
|
|
backend_x11->atom_NET_WM_NAME = atoms[9];
|
|
|
|
backend_x11->atom_UTF8_STRING = atoms[10];
|
2007-11-15 14:45:27 +00:00
|
|
|
|
|
|
|
g_free (clutter_display_name);
|
2008-02-20 14:16:54 +00:00
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
CLUTTER_NOTE (BACKEND,
|
2009-03-17 14:12:01 +00:00
|
|
|
"X Display '%s'[%p] opened (screen:%d, root:%u, dpi:%f)",
|
2007-11-15 14:45:27 +00:00
|
|
|
backend_x11->display_name,
|
|
|
|
backend_x11->xdpy,
|
|
|
|
backend_x11->xscreen_num,
|
|
|
|
(unsigned int) backend_x11->xwin_root,
|
|
|
|
clutter_backend_get_resolution (backend));
|
|
|
|
|
2011-11-04 16:39:52 +00:00
|
|
|
return TRUE;
|
2007-11-15 14:45:27 +00:00
|
|
|
}
|
|
|
|
|
2011-11-03 17:53:54 +00:00
|
|
|
void
|
|
|
|
_clutter_backend_x11_events_init (ClutterBackend *backend)
|
2007-11-15 14:45:27 +00:00
|
|
|
{
|
2011-11-03 17:53:54 +00:00
|
|
|
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
|
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
CLUTTER_NOTE (EVENT, "initialising the event loop");
|
|
|
|
|
2011-11-03 17:53:54 +00:00
|
|
|
/* the event source is optional */
|
2008-07-01 13:41:23 +00:00
|
|
|
if (!_no_xevent_retrieval)
|
2011-11-03 17:53:54 +00:00
|
|
|
{
|
|
|
|
GSource *source;
|
|
|
|
|
|
|
|
source = _clutter_x11_event_source_new (backend_x11);
|
|
|
|
|
|
|
|
/* default priority for events
|
|
|
|
*
|
|
|
|
* XXX - at some point we'll have a common EventSource API that
|
|
|
|
* is created by the backend, and this code will most likely go
|
|
|
|
* into the default implementation of ClutterBackend
|
|
|
|
*/
|
|
|
|
g_source_set_priority (source, CLUTTER_PRIORITY_EVENTS);
|
|
|
|
|
|
|
|
/* attach the source to the default context, and transfer the
|
|
|
|
* ownership to the GMainContext itself
|
|
|
|
*/
|
|
|
|
g_source_attach (source, NULL);
|
|
|
|
g_source_unref (source);
|
|
|
|
|
|
|
|
backend_x11->event_source = source;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create the device manager; we need this because we can effectively
|
|
|
|
* choose between core+XI1 and XI2 input events
|
|
|
|
*/
|
|
|
|
clutter_backend_x11_create_device_manager (backend_x11);
|
|
|
|
|
|
|
|
/* register keymap; unless we create a generic Keymap object, I'm
|
|
|
|
* afraid this will have to stay
|
|
|
|
*/
|
|
|
|
clutter_backend_x11_create_keymap (backend_x11);
|
2007-11-15 14:45:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const GOptionEntry entries[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"display", 0,
|
|
|
|
G_OPTION_FLAG_IN_MAIN,
|
|
|
|
G_OPTION_ARG_STRING, &clutter_display_name,
|
2009-01-06 12:11:07 +00:00
|
|
|
N_("X display to use"), "DISPLAY"
|
2007-11-15 14:45:27 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"screen", 0,
|
|
|
|
G_OPTION_FLAG_IN_MAIN,
|
|
|
|
G_OPTION_ARG_INT, &clutter_screen,
|
2009-01-06 12:11:07 +00:00
|
|
|
N_("X screen to use"), "SCREEN"
|
2007-11-15 14:45:27 +00:00
|
|
|
},
|
|
|
|
{ "synch", 0,
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_NONE, &clutter_synchronise,
|
2009-06-19 13:32:37 +00:00
|
|
|
N_("Make X calls synchronous"), NULL
|
2007-11-15 14:45:27 +00:00
|
|
|
},
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
#if defined(HAVE_XINPUT) || defined(HAVE_XINPUT_2)
|
2009-06-19 13:32:37 +00:00
|
|
|
{
|
2012-10-07 21:57:04 +00:00
|
|
|
"disable-xinput", 0,
|
|
|
|
G_OPTION_FLAG_REVERSE,
|
2009-06-19 13:32:37 +00:00
|
|
|
G_OPTION_ARG_NONE, &clutter_enable_xinput,
|
2012-10-07 21:57:04 +00:00
|
|
|
N_("Disable XInput support"), NULL
|
2009-06-19 13:32:37 +00:00
|
|
|
},
|
|
|
|
#endif /* HAVE_XINPUT */
|
2007-11-15 14:45:27 +00:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
2011-01-25 11:00:20 +00:00
|
|
|
static void
|
2007-11-15 14:45:27 +00:00
|
|
|
clutter_backend_x11_add_options (ClutterBackend *backend,
|
|
|
|
GOptionGroup *group)
|
|
|
|
{
|
|
|
|
g_option_group_add_entries (group, entries);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_backend_x11_finalize (GObject *gobject)
|
|
|
|
{
|
|
|
|
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (gobject);
|
|
|
|
|
|
|
|
g_free (backend_x11->display_name);
|
|
|
|
|
2011-01-18 12:57:50 +00:00
|
|
|
clutter_x11_remove_filter (cogl_xlib_filter, NULL);
|
|
|
|
|
2010-11-12 23:53:51 +00:00
|
|
|
clutter_x11_remove_filter (xsettings_filter, backend_x11);
|
2010-06-21 17:56:16 +00:00
|
|
|
_clutter_xsettings_client_destroy (backend_x11->xsettings);
|
2010-06-21 14:43:31 +00:00
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
XCloseDisplay (backend_x11->xdpy);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (clutter_backend_x11_parent_class)->finalize (gobject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_backend_x11_dispose (GObject *gobject)
|
|
|
|
{
|
|
|
|
G_OBJECT_CLASS (clutter_backend_x11_parent_class)->dispose (gobject);
|
|
|
|
}
|
|
|
|
|
2011-01-25 11:00:20 +00:00
|
|
|
static ClutterFeatureFlags
|
2007-11-15 14:45:27 +00:00
|
|
|
clutter_backend_x11_get_features (ClutterBackend *backend)
|
|
|
|
{
|
2011-09-27 12:24:52 +00:00
|
|
|
ClutterFeatureFlags flags = CLUTTER_FEATURE_STAGE_USER_RESIZE
|
|
|
|
| CLUTTER_FEATURE_STAGE_CURSOR;
|
2011-08-26 22:16:12 +00:00
|
|
|
|
|
|
|
flags |= CLUTTER_BACKEND_CLASS (clutter_backend_x11_parent_class)->get_features (backend);
|
|
|
|
|
|
|
|
return flags;
|
2007-11-15 14:45:27 +00:00
|
|
|
}
|
|
|
|
|
2010-07-08 14:47:18 +00:00
|
|
|
static void
|
2010-09-08 14:15:57 +00:00
|
|
|
clutter_backend_x11_copy_event_data (ClutterBackend *backend,
|
|
|
|
const ClutterEvent *src,
|
|
|
|
ClutterEvent *dest)
|
2010-07-08 14:47:18 +00:00
|
|
|
{
|
|
|
|
gpointer event_x11;
|
|
|
|
|
|
|
|
event_x11 = _clutter_event_get_platform_data (src);
|
|
|
|
if (event_x11 != NULL)
|
|
|
|
_clutter_event_set_platform_data (dest, _clutter_event_x11_copy (event_x11));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_backend_x11_free_event_data (ClutterBackend *backend,
|
|
|
|
ClutterEvent *event)
|
|
|
|
{
|
|
|
|
gpointer event_x11;
|
|
|
|
|
|
|
|
event_x11 = _clutter_event_get_platform_data (event);
|
|
|
|
if (event_x11 != NULL)
|
|
|
|
_clutter_event_x11_free (event_x11);
|
|
|
|
}
|
|
|
|
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
static void
|
|
|
|
update_last_event_time (ClutterBackendX11 *backend_x11,
|
|
|
|
XEvent *xevent)
|
|
|
|
{
|
|
|
|
Time current_time = CurrentTime;
|
|
|
|
Time last_time = backend_x11->last_event_time;
|
|
|
|
|
|
|
|
switch (xevent->type)
|
|
|
|
{
|
|
|
|
case KeyPress:
|
|
|
|
case KeyRelease:
|
|
|
|
current_time = xevent->xkey.time;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ButtonPress:
|
|
|
|
case ButtonRelease:
|
|
|
|
current_time = xevent->xbutton.time;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MotionNotify:
|
|
|
|
current_time = xevent->xmotion.time;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EnterNotify:
|
|
|
|
case LeaveNotify:
|
|
|
|
current_time = xevent->xcrossing.time;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PropertyNotify:
|
|
|
|
current_time = xevent->xproperty.time;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* only change the current event time if it's after the previous event
|
|
|
|
* time, or if it is at least 30 seconds earlier - in case the system
|
|
|
|
* clock was changed
|
|
|
|
*/
|
|
|
|
if ((current_time != CurrentTime) &&
|
|
|
|
(current_time > last_time || (last_time - current_time > (30 * 1000))))
|
|
|
|
backend_x11->last_event_time = current_time;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
clutter_backend_x11_translate_event (ClutterBackend *backend,
|
|
|
|
gpointer native,
|
|
|
|
ClutterEvent *event)
|
2010-02-17 17:06:25 +00:00
|
|
|
{
|
|
|
|
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
|
2011-02-09 12:20:56 +00:00
|
|
|
ClutterBackendClass *parent_class;
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
XEvent *xevent = native;
|
2010-02-17 17:06:25 +00:00
|
|
|
|
2011-02-09 12:20:56 +00:00
|
|
|
/* X11 filter functions have a higher priority */
|
|
|
|
if (backend_x11->event_filters != NULL)
|
2010-02-17 17:06:25 +00:00
|
|
|
{
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
GSList *node = backend_x11->event_filters;
|
|
|
|
|
|
|
|
while (node != NULL)
|
|
|
|
{
|
|
|
|
ClutterX11EventFilter *filter = node->data;
|
|
|
|
|
|
|
|
switch (filter->func (xevent, event, filter->data))
|
|
|
|
{
|
|
|
|
case CLUTTER_X11_FILTER_CONTINUE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_X11_FILTER_TRANSLATE:
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case CLUTTER_X11_FILTER_REMOVE:
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
node = node->next;
|
|
|
|
}
|
2010-02-17 17:06:25 +00:00
|
|
|
}
|
|
|
|
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
/* we update the event time only for events that can
|
|
|
|
* actually reach Clutter's event queue
|
|
|
|
*/
|
|
|
|
update_last_event_time (backend_x11, xevent);
|
|
|
|
|
2011-02-09 12:20:56 +00:00
|
|
|
/* chain up to the parent implementation, which will handle
|
|
|
|
* event translators
|
|
|
|
*/
|
|
|
|
parent_class = CLUTTER_BACKEND_CLASS (clutter_backend_x11_parent_class);
|
|
|
|
return parent_class->translate_event (backend, native, event);
|
2010-02-17 17:06:25 +00:00
|
|
|
}
|
|
|
|
|
2011-11-04 15:53:47 +00:00
|
|
|
static CoglRenderer *
|
|
|
|
clutter_backend_x11_get_renderer (ClutterBackend *backend,
|
|
|
|
GError **error)
|
2011-08-26 22:16:12 +00:00
|
|
|
{
|
|
|
|
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
|
2011-11-04 15:53:47 +00:00
|
|
|
Display *xdisplay = backend_x11->xdpy;
|
|
|
|
CoglRenderer *renderer;
|
|
|
|
|
|
|
|
CLUTTER_NOTE (BACKEND, "Creating a new Xlib renderer");
|
|
|
|
|
|
|
|
renderer = cogl_renderer_new ();
|
|
|
|
|
2012-02-29 16:35:48 +00:00
|
|
|
cogl_renderer_add_constraint (renderer, COGL_RENDERER_CONSTRAINT_USES_X11);
|
|
|
|
|
2011-11-04 15:53:47 +00:00
|
|
|
/* set the display object we're using */
|
|
|
|
cogl_xlib_renderer_set_foreign_display (renderer, xdisplay);
|
|
|
|
|
|
|
|
return renderer;
|
|
|
|
}
|
2011-08-26 22:16:12 +00:00
|
|
|
|
2011-11-04 15:53:47 +00:00
|
|
|
static CoglDisplay *
|
|
|
|
clutter_backend_x11_get_display (ClutterBackend *backend,
|
|
|
|
CoglRenderer *renderer,
|
|
|
|
CoglSwapChain *swap_chain,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
CoglOnscreenTemplate *onscreen_template;
|
|
|
|
GError *internal_error = NULL;
|
|
|
|
CoglDisplay *display;
|
|
|
|
gboolean res;
|
2011-08-26 22:16:12 +00:00
|
|
|
|
2011-11-04 15:53:47 +00:00
|
|
|
CLUTTER_NOTE (BACKEND, "Alpha on Cogl swap chain: %s",
|
|
|
|
clutter_enable_argb ? "enabled" : "disabled");
|
2011-08-26 22:16:12 +00:00
|
|
|
|
2011-11-03 14:02:43 +00:00
|
|
|
cogl_swap_chain_set_has_alpha (swap_chain, clutter_enable_argb);
|
2011-08-26 22:16:12 +00:00
|
|
|
|
|
|
|
onscreen_template = cogl_onscreen_template_new (swap_chain);
|
|
|
|
|
2011-11-04 15:53:47 +00:00
|
|
|
res = cogl_renderer_check_onscreen_template (renderer,
|
|
|
|
onscreen_template,
|
|
|
|
&internal_error);
|
|
|
|
if (!res && clutter_enable_argb)
|
2011-08-26 22:16:12 +00:00
|
|
|
{
|
2011-11-03 14:02:43 +00:00
|
|
|
CLUTTER_NOTE (BACKEND,
|
|
|
|
"Creation of a context with a ARGB visual failed: %s",
|
|
|
|
internal_error != NULL ? internal_error->message
|
|
|
|
: "Unknown reason");
|
|
|
|
|
|
|
|
g_clear_error (&internal_error);
|
2011-08-26 22:16:12 +00:00
|
|
|
|
|
|
|
/* It's possible that the current renderer doesn't support transparency
|
|
|
|
* in a swap_chain so lets see if we can fallback to not having any
|
|
|
|
* transparency...
|
|
|
|
*
|
|
|
|
* XXX: It might be nice to have a CoglRenderer feature we could
|
|
|
|
* explicitly check for ahead of time.
|
|
|
|
*/
|
2011-11-03 14:02:43 +00:00
|
|
|
clutter_enable_argb = FALSE;
|
2011-08-26 22:16:12 +00:00
|
|
|
cogl_swap_chain_set_has_alpha (swap_chain, FALSE);
|
2011-11-04 15:53:47 +00:00
|
|
|
res = cogl_renderer_check_onscreen_template (renderer,
|
|
|
|
onscreen_template,
|
|
|
|
&internal_error);
|
2011-08-26 22:16:12 +00:00
|
|
|
}
|
|
|
|
|
2011-11-04 15:53:47 +00:00
|
|
|
if (!res)
|
2011-11-03 14:02:43 +00:00
|
|
|
{
|
|
|
|
g_set_error_literal (error, CLUTTER_INIT_ERROR,
|
|
|
|
CLUTTER_INIT_ERROR_BACKEND,
|
|
|
|
internal_error->message);
|
2011-11-04 15:53:47 +00:00
|
|
|
|
2011-11-03 14:02:43 +00:00
|
|
|
g_error_free (internal_error);
|
2011-11-04 15:53:47 +00:00
|
|
|
cogl_object_unref (onscreen_template);
|
2011-11-03 14:02:43 +00:00
|
|
|
|
2011-11-04 15:53:47 +00:00
|
|
|
return NULL;
|
2011-08-26 22:16:12 +00:00
|
|
|
}
|
|
|
|
|
2011-11-04 15:53:47 +00:00
|
|
|
display = cogl_display_new (renderer, onscreen_template);
|
|
|
|
cogl_object_unref (onscreen_template);
|
2011-09-27 12:24:52 +00:00
|
|
|
|
2011-11-04 15:53:47 +00:00
|
|
|
return display;
|
2011-08-26 22:16:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static ClutterStageWindow *
|
|
|
|
clutter_backend_x11_create_stage (ClutterBackend *backend,
|
|
|
|
ClutterStage *wrapper,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
|
|
|
|
ClutterEventTranslator *translator;
|
|
|
|
ClutterStageWindow *stage;
|
|
|
|
|
|
|
|
stage = g_object_new (CLUTTER_TYPE_STAGE_X11,
|
|
|
|
"backend", backend,
|
|
|
|
"wrapper", wrapper,
|
|
|
|
NULL);
|
|
|
|
|
2011-09-27 12:24:52 +00:00
|
|
|
/* the X11 stage does event translation */
|
2011-08-26 22:16:12 +00:00
|
|
|
translator = CLUTTER_EVENT_TRANSLATOR (stage);
|
|
|
|
_clutter_backend_add_event_translator (backend, translator);
|
|
|
|
|
2011-09-27 12:24:52 +00:00
|
|
|
CLUTTER_NOTE (MISC, "X11 stage created (display:%p, screen:%d, root:%u)",
|
2011-08-26 22:16:12 +00:00
|
|
|
backend_x11->xdpy,
|
|
|
|
backend_x11->xscreen_num,
|
|
|
|
(unsigned int) backend_x11->xwin_root);
|
|
|
|
|
|
|
|
return stage;
|
|
|
|
}
|
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
static void
|
|
|
|
clutter_backend_x11_class_init (ClutterBackendX11Class *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
ClutterBackendClass *backend_class = CLUTTER_BACKEND_CLASS (klass);
|
|
|
|
|
|
|
|
gobject_class->dispose = clutter_backend_x11_dispose;
|
|
|
|
gobject_class->finalize = clutter_backend_x11_finalize;
|
|
|
|
|
2011-11-04 18:27:08 +00:00
|
|
|
backend_class->stage_window_type = CLUTTER_TYPE_STAGE_X11;
|
|
|
|
|
2012-03-07 12:06:24 +00:00
|
|
|
backend_class->pre_parse = clutter_backend_x11_pre_parse;
|
|
|
|
backend_class->post_parse = clutter_backend_x11_post_parse;
|
2010-02-17 17:06:25 +00:00
|
|
|
backend_class->add_options = clutter_backend_x11_add_options;
|
|
|
|
backend_class->get_features = clutter_backend_x11_get_features;
|
2011-11-04 18:27:08 +00:00
|
|
|
|
2010-07-08 14:47:18 +00:00
|
|
|
backend_class->copy_event_data = clutter_backend_x11_copy_event_data;
|
|
|
|
backend_class->free_event_data = clutter_backend_x11_free_event_data;
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
backend_class->translate_event = clutter_backend_x11_translate_event;
|
2011-11-04 18:27:08 +00:00
|
|
|
|
2011-11-04 15:53:47 +00:00
|
|
|
backend_class->get_renderer = clutter_backend_x11_get_renderer;
|
|
|
|
backend_class->get_display = clutter_backend_x11_get_display;
|
2011-08-26 22:16:12 +00:00
|
|
|
backend_class->create_stage = clutter_backend_x11_create_stage;
|
2007-11-15 14:45:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_backend_x11_init (ClutterBackendX11 *backend_x11)
|
|
|
|
{
|
2009-02-18 09:45:26 +00:00
|
|
|
backend_x11->last_event_time = CurrentTime;
|
2007-11-15 14:45:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
error_handler(Display *xdpy,
|
2008-01-31 11:24:11 +00:00
|
|
|
XErrorEvent *error)
|
2007-11-15 14:45:27 +00:00
|
|
|
{
|
|
|
|
TrappedErrorCode = error->error_code;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_x11_trap_x_errors:
|
|
|
|
*
|
2007-11-18 15:41:47 +00:00
|
|
|
* Traps every X error until clutter_x11_untrap_x_errors() is called.
|
2007-11-15 14:45:27 +00:00
|
|
|
*
|
2007-11-18 15:41:47 +00:00
|
|
|
* Since: 0.6
|
2007-11-15 14:45:27 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_x11_trap_x_errors (void)
|
|
|
|
{
|
|
|
|
TrappedErrorCode = 0;
|
|
|
|
old_error_handler = XSetErrorHandler (error_handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_x11_untrap_x_errors:
|
|
|
|
*
|
2007-11-18 15:41:47 +00:00
|
|
|
* Removes the X error trap and returns the current status.
|
2007-11-15 14:45:27 +00:00
|
|
|
*
|
2007-11-18 15:41:47 +00:00
|
|
|
* Return value: the trapped error code, or 0 for success
|
2007-11-15 14:45:27 +00:00
|
|
|
*
|
|
|
|
* Since: 0.4
|
|
|
|
*/
|
|
|
|
gint
|
|
|
|
clutter_x11_untrap_x_errors (void)
|
|
|
|
{
|
|
|
|
XSetErrorHandler (old_error_handler);
|
|
|
|
|
|
|
|
return TrappedErrorCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_x11_get_default_display:
|
2008-02-20 14:16:54 +00:00
|
|
|
*
|
2007-11-18 15:41:47 +00:00
|
|
|
* Retrieves the pointer to the default display.
|
2007-11-15 14:45:27 +00:00
|
|
|
*
|
2010-12-09 12:36:50 +00:00
|
|
|
* Return value: (transfer none): the default display
|
2007-11-15 14:45:27 +00:00
|
|
|
*
|
2007-11-18 15:41:47 +00:00
|
|
|
* Since: 0.6
|
2007-11-15 14:45:27 +00:00
|
|
|
*/
|
|
|
|
Display *
|
|
|
|
clutter_x11_get_default_display (void)
|
|
|
|
{
|
2011-08-26 22:16:12 +00:00
|
|
|
ClutterBackend *backend = clutter_get_default_backend ();
|
|
|
|
|
2011-09-21 17:05:03 +00:00
|
|
|
if (backend == NULL)
|
2007-11-15 14:45:27 +00:00
|
|
|
{
|
2011-09-21 17:05:03 +00:00
|
|
|
g_critical ("The Clutter backend has not been initialised");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!CLUTTER_IS_BACKEND_X11 (backend))
|
|
|
|
{
|
|
|
|
g_critical ("The Clutter backend is not a X11 backend");
|
2007-11-15 14:45:27 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-08-26 22:16:12 +00:00
|
|
|
return CLUTTER_BACKEND_X11 (backend)->xdpy;
|
2007-11-15 14:45:27 +00:00
|
|
|
}
|
|
|
|
|
2008-02-20 14:16:54 +00:00
|
|
|
/**
|
|
|
|
* clutter_x11_set_display:
|
|
|
|
* @xdpy: pointer to a X display connection.
|
2008-05-15 14:31:43 +00:00
|
|
|
*
|
2008-09-19 10:28:51 +00:00
|
|
|
* Sets the display connection Clutter should use; must be called
|
|
|
|
* before clutter_init(), clutter_init_with_args() or other functions
|
|
|
|
* pertaining Clutter's initialization process.
|
|
|
|
*
|
|
|
|
* If you are parsing the command line arguments by retrieving Clutter's
|
|
|
|
* #GOptionGroup with clutter_get_option_group() and calling
|
|
|
|
* g_option_context_parse() yourself, you should also call
|
|
|
|
* clutter_x11_set_display() before g_option_context_parse().
|
2008-02-20 14:16:54 +00:00
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_x11_set_display (Display *xdpy)
|
|
|
|
{
|
2009-06-19 13:12:36 +00:00
|
|
|
if (_clutter_context_is_initialized ())
|
2008-02-20 14:16:54 +00:00
|
|
|
{
|
2011-01-18 12:57:50 +00:00
|
|
|
g_warning ("%s() can only be used before calling clutter_init()",
|
|
|
|
G_STRFUNC);
|
2008-07-01 13:41:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-02-20 14:16:54 +00:00
|
|
|
|
2008-07-01 13:41:23 +00:00
|
|
|
_foreign_dpy= xdpy;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_x11_enable_xinput:
|
|
|
|
*
|
|
|
|
* Enables the use of the XInput extension if present on connected
|
2010-02-17 17:06:25 +00:00
|
|
|
* XServer and support built into Clutter. XInput allows for multiple
|
|
|
|
* pointing devices to be used.
|
|
|
|
*
|
|
|
|
* This function must be called before clutter_init().
|
2008-07-01 13:41:23 +00:00
|
|
|
*
|
2010-02-17 17:06:25 +00:00
|
|
|
* Since XInput might not be supported by the X server, you might
|
|
|
|
* want to use clutter_x11_has_xinput() to see if support was enabled.
|
2008-07-01 13:41:23 +00:00
|
|
|
*
|
|
|
|
* Since: 0.8
|
2012-10-07 21:57:04 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 1.14: This function does not do anything; XInput support
|
|
|
|
* is enabled by default in Clutter. Use the CLUTTER_DISABLE_XINPUT
|
|
|
|
* environment variable to disable XInput support and use Xlib core
|
|
|
|
* events instead.
|
2008-07-01 13:41:23 +00:00
|
|
|
*/
|
|
|
|
void
|
2009-06-19 13:32:37 +00:00
|
|
|
clutter_x11_enable_xinput (void)
|
2008-07-01 13:41:23 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-07-22 09:48:21 +00:00
|
|
|
* clutter_x11_disable_event_retrieval:
|
2008-07-01 13:41:23 +00:00
|
|
|
*
|
2010-08-03 15:30:04 +00:00
|
|
|
* Disables the internal polling of X11 events in the main loop.
|
2008-07-01 13:41:23 +00:00
|
|
|
*
|
2010-07-22 09:48:21 +00:00
|
|
|
* Libraries or applications calling this function will be responsible of
|
2010-08-03 15:30:04 +00:00
|
|
|
* polling all X11 events.
|
2010-07-22 09:48:21 +00:00
|
|
|
*
|
|
|
|
* You also must call clutter_x11_handle_event() to let Clutter process
|
|
|
|
* events and maintain its internal state.
|
|
|
|
*
|
2010-08-03 15:30:04 +00:00
|
|
|
* <warning>This function can only be called before calling
|
|
|
|
* clutter_init().</warning>
|
|
|
|
*
|
|
|
|
* <note>Even with event handling disabled, Clutter will still select
|
|
|
|
* all the events required to maintain its internal state on the stage
|
2010-08-03 15:48:53 +00:00
|
|
|
* Window; compositors using Clutter and input regions to pass events
|
|
|
|
* through to application windows should not rely on an empty input
|
|
|
|
* region, and should instead clear it themselves explicitly using the
|
|
|
|
* XFixes extension.</note>
|
2010-08-03 15:30:04 +00:00
|
|
|
*
|
|
|
|
* This function should not be normally used by applications.
|
2008-07-01 13:41:23 +00:00
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_x11_disable_event_retrieval (void)
|
|
|
|
{
|
2009-06-19 13:12:36 +00:00
|
|
|
if (_clutter_context_is_initialized ())
|
2008-02-20 14:16:54 +00:00
|
|
|
{
|
2011-01-18 12:57:50 +00:00
|
|
|
g_warning ("%s() can only be used before calling clutter_init()",
|
|
|
|
G_STRFUNC);
|
2008-09-23 07:03:35 +00:00
|
|
|
return;
|
2008-02-20 14:16:54 +00:00
|
|
|
}
|
|
|
|
|
2008-07-01 13:41:23 +00:00
|
|
|
_no_xevent_retrieval = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-07-22 09:48:21 +00:00
|
|
|
* clutter_x11_has_event_retrieval:
|
2008-07-01 13:41:23 +00:00
|
|
|
*
|
|
|
|
* Queries the X11 backend to check if event collection has been disabled.
|
|
|
|
*
|
|
|
|
* Return value: TRUE if event retrival has been disabled. FALSE otherwise.
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
clutter_x11_has_event_retrieval (void)
|
|
|
|
{
|
|
|
|
return !_no_xevent_retrieval;
|
2008-02-20 14:16:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
/**
|
|
|
|
* clutter_x11_get_default_screen:
|
2008-02-20 14:16:54 +00:00
|
|
|
*
|
2007-11-18 15:41:47 +00:00
|
|
|
* Gets the number of the default X Screen object.
|
2007-11-15 14:45:27 +00:00
|
|
|
*
|
2007-11-18 15:41:47 +00:00
|
|
|
* Return value: the number of the default screen
|
2007-11-15 14:45:27 +00:00
|
|
|
*
|
2007-11-18 15:41:47 +00:00
|
|
|
* Since: 0.6
|
2007-11-15 14:45:27 +00:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
clutter_x11_get_default_screen (void)
|
|
|
|
{
|
2011-08-26 22:16:12 +00:00
|
|
|
ClutterBackend *backend = clutter_get_default_backend ();
|
|
|
|
|
2011-09-21 17:05:03 +00:00
|
|
|
if (backend == NULL)
|
2007-11-15 14:45:27 +00:00
|
|
|
{
|
2011-09-21 17:05:03 +00:00
|
|
|
g_critical ("The Clutter backend has not been initialised");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!CLUTTER_IS_BACKEND_X11 (backend))
|
|
|
|
{
|
|
|
|
g_critical ("The Clutter backend is not a X11 backend");
|
2007-11-15 14:45:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-08-26 22:16:12 +00:00
|
|
|
return CLUTTER_BACKEND_X11 (backend)->xscreen_num;
|
2007-11-15 14:45:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-02-08 15:31:20 +00:00
|
|
|
* clutter_x11_get_root_window: (skip)
|
2008-02-20 14:16:54 +00:00
|
|
|
*
|
2007-11-18 15:41:47 +00:00
|
|
|
* Retrieves the root window.
|
2007-11-15 14:45:27 +00:00
|
|
|
*
|
2007-11-18 15:41:47 +00:00
|
|
|
* Return value: the id of the root window
|
2007-11-15 14:45:27 +00:00
|
|
|
*
|
2007-11-18 15:41:47 +00:00
|
|
|
* Since: 0.6
|
2007-11-15 14:45:27 +00:00
|
|
|
*/
|
|
|
|
Window
|
|
|
|
clutter_x11_get_root_window (void)
|
|
|
|
{
|
2011-08-26 22:16:12 +00:00
|
|
|
ClutterBackend *backend = clutter_get_default_backend ();
|
|
|
|
|
2011-09-21 17:05:03 +00:00
|
|
|
if (backend == NULL)
|
2007-11-15 14:45:27 +00:00
|
|
|
{
|
2011-09-21 17:05:03 +00:00
|
|
|
g_critical ("The Clutter backend has not been initialised");
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!CLUTTER_IS_BACKEND_X11 (backend))
|
|
|
|
{
|
|
|
|
g_critical ("The Clutter backend is not a X11 backend");
|
2007-11-15 14:45:27 +00:00
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
2011-08-26 22:16:12 +00:00
|
|
|
return CLUTTER_BACKEND_X11 (backend)->xwin_root;
|
2007-11-15 14:45:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-02-08 15:31:20 +00:00
|
|
|
* clutter_x11_add_filter: (skip)
|
2007-11-18 15:41:47 +00:00
|
|
|
* @func: a filter function
|
|
|
|
* @data: user data to be passed to the filter function, or %NULL
|
2007-11-15 14:45:27 +00:00
|
|
|
*
|
2007-11-18 15:41:47 +00:00
|
|
|
* Adds an event filter function.
|
2007-11-15 14:45:27 +00:00
|
|
|
*
|
2007-11-18 15:41:47 +00:00
|
|
|
* Since: 0.6
|
2007-11-15 14:45:27 +00:00
|
|
|
*/
|
|
|
|
void
|
2007-11-18 15:41:47 +00:00
|
|
|
clutter_x11_add_filter (ClutterX11FilterFunc func,
|
|
|
|
gpointer data)
|
2007-11-15 14:45:27 +00:00
|
|
|
{
|
|
|
|
ClutterX11EventFilter *filter;
|
2011-08-26 22:16:12 +00:00
|
|
|
ClutterBackend *backend = clutter_get_default_backend ();
|
|
|
|
ClutterBackendX11 *backend_x11;
|
2007-11-15 14:45:27 +00:00
|
|
|
|
|
|
|
g_return_if_fail (func != NULL);
|
|
|
|
|
2011-09-21 17:05:03 +00:00
|
|
|
if (backend == NULL)
|
2007-11-15 14:45:27 +00:00
|
|
|
{
|
2011-09-21 17:05:03 +00:00
|
|
|
g_critical ("The Clutter backend has not been initialised");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!CLUTTER_IS_BACKEND_X11 (backend))
|
|
|
|
{
|
|
|
|
g_critical ("The Clutter backend is not a X11 backend");
|
2007-11-15 14:45:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-08-26 22:16:12 +00:00
|
|
|
backend_x11 = CLUTTER_BACKEND_X11 (backend);
|
|
|
|
|
2007-11-18 15:41:47 +00:00
|
|
|
filter = g_new0 (ClutterX11EventFilter, 1);
|
2007-11-15 14:45:27 +00:00
|
|
|
filter->func = func;
|
|
|
|
filter->data = data;
|
|
|
|
|
2011-08-26 22:16:12 +00:00
|
|
|
backend_x11->event_filters =
|
|
|
|
g_slist_append (backend_x11->event_filters, filter);
|
2007-11-15 14:45:27 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-02-08 15:31:20 +00:00
|
|
|
* clutter_x11_remove_filter: (skip)
|
2007-11-18 15:41:47 +00:00
|
|
|
* @func: a filter function
|
|
|
|
* @data: user data to be passed to the filter function, or %NULL
|
2007-11-15 14:45:27 +00:00
|
|
|
*
|
2007-11-18 15:41:47 +00:00
|
|
|
* Removes the given filter function.
|
2007-11-15 14:45:27 +00:00
|
|
|
*
|
2007-11-18 15:41:47 +00:00
|
|
|
* Since: 0.6
|
2007-11-15 14:45:27 +00:00
|
|
|
*/
|
|
|
|
void
|
2007-11-18 15:41:47 +00:00
|
|
|
clutter_x11_remove_filter (ClutterX11FilterFunc func,
|
|
|
|
gpointer data)
|
2007-11-15 14:45:27 +00:00
|
|
|
{
|
|
|
|
GSList *tmp_list, *this;
|
|
|
|
ClutterX11EventFilter *filter;
|
2011-08-26 22:16:12 +00:00
|
|
|
ClutterBackend *backend = clutter_get_default_backend ();
|
|
|
|
ClutterBackendX11 *backend_x11;
|
2007-11-15 14:45:27 +00:00
|
|
|
|
2008-04-15 21:18:13 +00:00
|
|
|
g_return_if_fail (func != NULL);
|
2007-11-15 14:45:27 +00:00
|
|
|
|
2011-09-21 17:05:03 +00:00
|
|
|
if (backend == NULL)
|
2011-08-26 22:16:12 +00:00
|
|
|
{
|
2011-09-21 17:05:03 +00:00
|
|
|
g_critical ("The Clutter backend has not been initialised");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!CLUTTER_IS_BACKEND_X11 (backend))
|
|
|
|
{
|
|
|
|
g_critical ("The Clutter backend is not a X11 backend");
|
2011-08-26 22:16:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
backend_x11 = CLUTTER_BACKEND_X11 (backend);
|
|
|
|
|
|
|
|
tmp_list = backend_x11->event_filters;
|
2007-11-15 14:45:27 +00:00
|
|
|
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
2007-11-18 15:41:47 +00:00
|
|
|
filter = tmp_list->data;
|
2007-11-15 14:45:27 +00:00
|
|
|
this = tmp_list;
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
|
|
|
|
if (filter->func == func && filter->data == data)
|
|
|
|
{
|
2011-08-26 22:16:12 +00:00
|
|
|
backend_x11->event_filters =
|
|
|
|
g_slist_remove_link (backend_x11->event_filters, this);
|
2007-11-15 14:45:27 +00:00
|
|
|
|
|
|
|
g_slist_free_1 (this);
|
|
|
|
g_free (filter);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-06-23 09:55:42 +00:00
|
|
|
|
2009-11-20 15:36:43 +00:00
|
|
|
/**
|
|
|
|
* clutter_x11_get_input_devices:
|
|
|
|
*
|
|
|
|
* Retrieves a pointer to the list of input devices
|
|
|
|
*
|
|
|
|
* Deprecated: 1.2: Use clutter_device_manager_peek_devices() instead
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*
|
2010-12-09 12:36:50 +00:00
|
|
|
* Return value: (transfer none) (element-type Clutter.InputDevice): a
|
|
|
|
* pointer to the internal list of input devices; the returned list is
|
|
|
|
* owned by Clutter and should not be modified or freed
|
2009-11-20 15:36:43 +00:00
|
|
|
*/
|
Eliminate G_CONST_RETURN
The G_CONST_RETURN define in GLib is, and has always been, a bit fuzzy.
We always used it to conform to the platform, at least for public-facing
API.
At first I assumed it has something to do with brain-damaged compilers
or with weird platforms where const was not really supported; sadly,
it's something much, much worse: it's a define that can be toggled at
compile-time to remove const from the signature of public API. This is a
truly terrifying feature that I assume was added in the past century,
and whose inception clearly had something to do with massive doses of
absynthe and opium — because any other explanation would make the
existence of such a feature even worse than assuming drugs had anything
to do with it.
Anyway, and pleasing the gods, this dubious feature is being
removed/deprecated in GLib; see bug:
https://bugzilla.gnome.org/show_bug.cgi?id=644611
Before deprecation, though, we should just remove its usage from the
whole API. We should especially remove its usage from Cally's internals,
since there it never made sense in the first place.
2011-06-07 14:49:20 +00:00
|
|
|
const GSList *
|
2008-06-23 09:55:42 +00:00
|
|
|
clutter_x11_get_input_devices (void)
|
|
|
|
{
|
2009-11-20 15:36:43 +00:00
|
|
|
ClutterDeviceManager *manager;
|
2008-06-23 09:55:42 +00:00
|
|
|
|
2009-11-20 15:36:43 +00:00
|
|
|
manager = clutter_device_manager_get_default ();
|
2012-04-26 12:23:29 +00:00
|
|
|
if (manager == NULL)
|
|
|
|
return NULL;
|
2008-06-23 09:55:42 +00:00
|
|
|
|
2009-11-20 15:36:43 +00:00
|
|
|
return clutter_device_manager_peek_devices (manager);
|
2008-06-23 09:55:42 +00:00
|
|
|
}
|
|
|
|
|
2008-06-27 21:13:19 +00:00
|
|
|
/**
|
|
|
|
* clutter_x11_has_xinput:
|
2008-09-23 07:03:35 +00:00
|
|
|
*
|
2008-06-27 21:13:19 +00:00
|
|
|
* Gets whether Clutter has XInput support.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if Clutter was compiled with XInput support
|
|
|
|
* and XInput support is available at run time.
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
2008-06-23 09:55:42 +00:00
|
|
|
gboolean
|
|
|
|
clutter_x11_has_xinput (void)
|
|
|
|
{
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
#if defined(HAVE_XINPUT) || defined(HAVE_XINPUT_2)
|
2011-08-26 22:16:12 +00:00
|
|
|
ClutterBackend *backend = clutter_get_default_backend ();
|
2011-01-18 13:15:20 +00:00
|
|
|
|
2011-09-21 17:05:03 +00:00
|
|
|
if (backend == NULL)
|
2011-08-26 22:16:12 +00:00
|
|
|
{
|
2011-09-21 17:05:03 +00:00
|
|
|
g_critical ("The Clutter backend has not been initialised");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!CLUTTER_IS_BACKEND_X11 (backend))
|
|
|
|
{
|
|
|
|
g_critical ("The Clutter backend is not a X11 backend.");
|
2011-08-26 22:16:12 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CLUTTER_BACKEND_X11 (backend)->has_xinput;
|
2008-06-23 09:55:42 +00:00
|
|
|
#else
|
|
|
|
return FALSE;
|
|
|
|
#endif
|
|
|
|
}
|
2008-06-30 14:36:49 +00:00
|
|
|
|
2010-03-02 09:53:55 +00:00
|
|
|
/**
|
|
|
|
* clutter_x11_has_composite_extension:
|
|
|
|
*
|
|
|
|
* Retrieves whether Clutter is running on an X11 server with the
|
|
|
|
* XComposite extension
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if the XComposite extension is available
|
|
|
|
*/
|
2008-06-30 14:36:49 +00:00
|
|
|
gboolean
|
|
|
|
clutter_x11_has_composite_extension (void)
|
|
|
|
{
|
2010-10-19 09:40:57 +00:00
|
|
|
#if HAVE_XCOMPOSITE
|
2009-06-05 11:26:29 +00:00
|
|
|
static gboolean have_composite = FALSE, done_check = FALSE;
|
|
|
|
int error = 0, event = 0;
|
|
|
|
Display *dpy;
|
2008-06-30 14:36:49 +00:00
|
|
|
|
|
|
|
if (done_check)
|
|
|
|
return have_composite;
|
|
|
|
|
2011-01-18 12:57:50 +00:00
|
|
|
if (!_clutter_context_is_initialized ())
|
2008-06-30 14:36:49 +00:00
|
|
|
{
|
|
|
|
g_critical ("X11 backend has not been initialised");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
dpy = clutter_x11_get_default_display();
|
2011-09-21 17:05:03 +00:00
|
|
|
if (dpy == NULL)
|
|
|
|
return FALSE;
|
2008-06-30 14:36:49 +00:00
|
|
|
|
|
|
|
if (XCompositeQueryExtension (dpy, &event, &error))
|
|
|
|
{
|
|
|
|
int major = 0, minor = 0;
|
2008-09-23 07:03:35 +00:00
|
|
|
if (XCompositeQueryVersion (dpy, &major, &minor))
|
2008-06-30 14:36:49 +00:00
|
|
|
{
|
2008-09-23 07:03:35 +00:00
|
|
|
if (major >= 0 && minor >= 3)
|
2008-06-30 14:36:49 +00:00
|
|
|
have_composite = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
done_check = TRUE;
|
|
|
|
|
|
|
|
return have_composite;
|
2010-10-19 09:40:57 +00:00
|
|
|
#else
|
|
|
|
return FALSE;
|
|
|
|
#endif /* HAVE_XCOMPOSITE */
|
2008-06-30 14:36:49 +00:00
|
|
|
}
|
|
|
|
|
2010-01-08 15:04:56 +00:00
|
|
|
/**
|
|
|
|
* clutter_x11_set_use_argb_visual:
|
|
|
|
* @use_argb: %TRUE if ARGB visuals should be requested by default
|
|
|
|
*
|
|
|
|
* Sets whether the Clutter X11 backend should request ARGB visuals by default
|
|
|
|
* or not.
|
|
|
|
*
|
|
|
|
* By default, Clutter requests RGB visuals.
|
|
|
|
*
|
|
|
|
* <note>If no ARGB visuals are found, the X11 backend will fall back to
|
|
|
|
* requesting a RGB visual instead.</note>
|
|
|
|
*
|
|
|
|
* ARGB visuals are required for the #ClutterStage:use-alpha property to work.
|
|
|
|
*
|
|
|
|
* <note>This function can only be called once, and before clutter_init() is
|
|
|
|
* called.</note>
|
|
|
|
*
|
|
|
|
* Since: 1.2
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_x11_set_use_argb_visual (gboolean use_argb)
|
|
|
|
{
|
2010-11-24 12:02:38 +00:00
|
|
|
if (_clutter_context_is_initialized ())
|
2010-01-08 15:04:56 +00:00
|
|
|
{
|
|
|
|
g_warning ("%s() can only be used before calling clutter_init()",
|
|
|
|
G_STRFUNC);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CLUTTER_NOTE (BACKEND, "ARGB visuals are %s",
|
|
|
|
use_argb ? "enabled" : "disabled");
|
|
|
|
|
|
|
|
clutter_enable_argb = use_argb;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_x11_get_use_argb_visual:
|
|
|
|
*
|
|
|
|
* Retrieves whether the Clutter X11 backend is using ARGB visuals by default
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if ARGB visuals are queried by default
|
|
|
|
*
|
|
|
|
* Since: 1.2
|
|
|
|
*/
|
2009-12-01 16:18:39 +00:00
|
|
|
gboolean
|
2010-01-08 15:04:56 +00:00
|
|
|
clutter_x11_get_use_argb_visual (void)
|
2009-12-01 16:18:39 +00:00
|
|
|
{
|
|
|
|
return clutter_enable_argb;
|
|
|
|
}
|
|
|
|
|
2009-05-13 20:49:45 +00:00
|
|
|
XVisualInfo *
|
2011-01-20 15:39:28 +00:00
|
|
|
_clutter_backend_x11_get_visual_info (ClutterBackendX11 *backend_x11)
|
2009-05-13 20:49:45 +00:00
|
|
|
{
|
2011-08-26 22:16:12 +00:00
|
|
|
return cogl_clutter_winsys_xlib_get_visual_info ();
|
2009-05-13 20:49:45 +00:00
|
|
|
}
|
2010-01-08 15:04:56 +00:00
|
|
|
|
|
|
|
/**
|
2011-02-08 15:31:20 +00:00
|
|
|
* clutter_x11_get_visual_info: (skip)
|
2010-01-08 15:04:56 +00:00
|
|
|
*
|
|
|
|
* Retrieves the <structname>XVisualInfo</structname> used by the Clutter X11
|
|
|
|
* backend.
|
|
|
|
*
|
2010-12-09 12:36:50 +00:00
|
|
|
* Return value: (transfer full): a <structname>XVisualInfo</structname>, or
|
2010-01-08 15:04:56 +00:00
|
|
|
* <varname>None</varname>. The returned value should be freed using XFree()
|
|
|
|
* when done
|
|
|
|
*
|
|
|
|
* Since: 1.2
|
|
|
|
*/
|
|
|
|
XVisualInfo *
|
|
|
|
clutter_x11_get_visual_info (void)
|
|
|
|
{
|
|
|
|
ClutterBackendX11 *backend_x11;
|
2011-09-21 17:05:03 +00:00
|
|
|
ClutterBackend *backend;
|
2010-01-08 15:04:56 +00:00
|
|
|
|
2011-09-21 17:05:03 +00:00
|
|
|
backend = clutter_get_default_backend ();
|
|
|
|
if (!CLUTTER_IS_BACKEND_X11 (backend))
|
|
|
|
{
|
|
|
|
g_critical ("The Clutter backend is not a X11 backend.");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
backend_x11 = CLUTTER_BACKEND_X11 (backend);
|
2010-01-08 15:04:56 +00:00
|
|
|
|
2011-01-20 15:39:28 +00:00
|
|
|
return _clutter_backend_x11_get_visual_info (backend_x11);
|
2010-01-08 15:04:56 +00:00
|
|
|
}
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
|
|
|
|
gboolean
|
|
|
|
_clutter_x11_input_device_translate_screen_coord (ClutterInputDevice *device,
|
|
|
|
gint stage_root_x,
|
|
|
|
gint stage_root_y,
|
|
|
|
guint index_,
|
|
|
|
gdouble value,
|
|
|
|
gdouble *axis_value)
|
|
|
|
{
|
|
|
|
ClutterAxisInfo *info;
|
|
|
|
ClutterBackendX11 *backend_x11;
|
|
|
|
gdouble width, scale, offset;
|
|
|
|
|
|
|
|
backend_x11 = CLUTTER_BACKEND_X11 (device->backend);
|
|
|
|
|
|
|
|
if (device->axes == NULL || index_ >= device->axes->len)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
info = &g_array_index (device->axes, ClutterAxisInfo, index_);
|
|
|
|
if (info->axis != CLUTTER_INPUT_AXIS_X ||
|
|
|
|
info->axis != CLUTTER_INPUT_AXIS_Y)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
width = info->max_value - info->min_value;
|
|
|
|
|
|
|
|
if (info->axis == CLUTTER_INPUT_AXIS_X)
|
|
|
|
{
|
|
|
|
if (width > 0)
|
|
|
|
scale = backend_x11->xscreen_width / width;
|
|
|
|
else
|
|
|
|
scale = 1;
|
|
|
|
|
|
|
|
offset = - stage_root_x;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (width > 0)
|
|
|
|
scale = backend_x11->xscreen_height / width;
|
|
|
|
else
|
|
|
|
scale = 1;
|
|
|
|
|
|
|
|
offset = - stage_root_y;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (axis_value)
|
|
|
|
*axis_value = offset + scale * (value - info->min_value);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|