2007-03-22 18:21:59 +00:00
|
|
|
/* Clutter.
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
2010-01-15 16:28:00 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2006, 2007, 2008 OpenedHand Ltd
|
|
|
|
* Copyright (C) 2009, 2010 Intel Corp.
|
2007-03-22 18:21:59 +00:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*
|
|
|
|
*
|
2010-01-15 16:28:00 +00:00
|
|
|
*
|
|
|
|
* Authored by:
|
|
|
|
* Matthew Allum <mallum@openedhand.com>
|
|
|
|
* Emmanuele Bassi <ebassi@linux.intel.com>
|
2007-03-22 18:21:59 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
#include "clutter-backend-x11.h"
|
|
|
|
#include "clutter-x11.h"
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2010-10-21 11:16:05 +00:00
|
|
|
#include "clutter-backend-private.h"
|
2010-10-21 09:54:14 +00:00
|
|
|
#include "clutter-debug.h"
|
2011-02-18 16:27:49 +00:00
|
|
|
#include "clutter-event-private.h"
|
2010-10-21 09:54:14 +00:00
|
|
|
#include "clutter-main.h"
|
2010-05-19 15:13:07 +00:00
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <glib.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
|
|
|
#if 0
|
2007-04-19 15:24:57 +00:00
|
|
|
/* XEMBED protocol support for toolkit embedding */
|
|
|
|
#define XEMBED_MAPPED (1 << 0)
|
|
|
|
#define MAX_SUPPORTED_XEMBED_VERSION 1
|
|
|
|
|
|
|
|
#define XEMBED_EMBEDDED_NOTIFY 0
|
|
|
|
#define XEMBED_WINDOW_ACTIVATE 1
|
|
|
|
#define XEMBED_WINDOW_DEACTIVATE 2
|
|
|
|
#define XEMBED_REQUEST_FOCUS 3
|
|
|
|
#define XEMBED_FOCUS_IN 4
|
|
|
|
#define XEMBED_FOCUS_OUT 5
|
|
|
|
#define XEMBED_FOCUS_NEXT 6
|
|
|
|
#define XEMBED_FOCUS_PREV 7
|
|
|
|
/* 8-9 were used for XEMBED_GRAB_KEY/XEMBED_UNGRAB_KEY */
|
|
|
|
#define XEMBED_MODALITY_ON 10
|
|
|
|
#define XEMBED_MODALITY_OFF 11
|
|
|
|
#define XEMBED_REGISTER_ACCELERATOR 12
|
|
|
|
#define XEMBED_UNREGISTER_ACCELERATOR 13
|
|
|
|
#define XEMBED_ACTIVATE_ACCELERATOR 14
|
|
|
|
|
|
|
|
static Window ParentEmbedderWin = None;
|
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
|
|
|
#endif
|
2007-04-19 15:24:57 +00:00
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
typedef struct _ClutterEventSource ClutterEventSource;
|
|
|
|
|
|
|
|
struct _ClutterEventSource
|
|
|
|
{
|
|
|
|
GSource source;
|
|
|
|
|
|
|
|
ClutterBackend *backend;
|
|
|
|
GPollFD event_poll_fd;
|
|
|
|
};
|
|
|
|
|
2010-07-08 14:47:18 +00:00
|
|
|
ClutterEventX11 *
|
|
|
|
_clutter_event_x11_new (void)
|
|
|
|
{
|
|
|
|
return g_slice_new0 (ClutterEventX11);
|
|
|
|
}
|
|
|
|
|
|
|
|
ClutterEventX11 *
|
|
|
|
_clutter_event_x11_copy (ClutterEventX11 *event_x11)
|
|
|
|
{
|
|
|
|
if (event_x11 != NULL)
|
|
|
|
return g_slice_dup (ClutterEventX11, event_x11);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_clutter_event_x11_free (ClutterEventX11 *event_x11)
|
|
|
|
{
|
|
|
|
if (event_x11 != NULL)
|
|
|
|
g_slice_free (ClutterEventX11, event_x11);
|
|
|
|
}
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
static gboolean clutter_event_prepare (GSource *source,
|
|
|
|
gint *timeout);
|
|
|
|
static gboolean clutter_event_check (GSource *source);
|
|
|
|
static gboolean clutter_event_dispatch (GSource *source,
|
|
|
|
GSourceFunc callback,
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
static GList *event_sources = NULL;
|
|
|
|
|
|
|
|
static GSourceFuncs event_funcs = {
|
|
|
|
clutter_event_prepare,
|
|
|
|
clutter_event_check,
|
|
|
|
clutter_event_dispatch,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static GSource *
|
|
|
|
clutter_event_source_new (ClutterBackend *backend)
|
|
|
|
{
|
|
|
|
GSource *source = g_source_new (&event_funcs, sizeof (ClutterEventSource));
|
|
|
|
ClutterEventSource *event_source = (ClutterEventSource *) source;
|
|
|
|
|
|
|
|
event_source->backend = backend;
|
|
|
|
|
|
|
|
return source;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2007-05-09 23:31:08 +00:00
|
|
|
check_xpending (ClutterBackend *backend)
|
2007-03-22 18:21:59 +00:00
|
|
|
{
|
2007-11-15 14:45:27 +00:00
|
|
|
return XPending (CLUTTER_BACKEND_X11 (backend)->xdpy);
|
2007-03-22 18:21:59 +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 0
|
2007-04-19 15:24:57 +00:00
|
|
|
static gboolean
|
2007-11-17 18:11:14 +00:00
|
|
|
xembed_send_message (ClutterBackendX11 *backend_x11,
|
|
|
|
Window window,
|
2008-01-31 11:24:11 +00:00
|
|
|
long message,
|
|
|
|
long detail,
|
2008-02-12 12:39:22 +00:00
|
|
|
long data1,
|
2008-01-31 11:24:11 +00:00
|
|
|
long data2)
|
2007-04-19 15:24:57 +00:00
|
|
|
{
|
|
|
|
XEvent ev;
|
|
|
|
|
|
|
|
memset (&ev, 0, sizeof (ev));
|
|
|
|
|
|
|
|
ev.xclient.type = ClientMessage;
|
|
|
|
ev.xclient.window = window;
|
2007-11-17 18:11:14 +00:00
|
|
|
ev.xclient.message_type = backend_x11->atom_XEMBED;
|
2007-04-19 15:24:57 +00:00
|
|
|
ev.xclient.format = 32;
|
|
|
|
ev.xclient.data.l[0] = CurrentTime;
|
|
|
|
ev.xclient.data.l[1] = message;
|
|
|
|
ev.xclient.data.l[2] = detail;
|
|
|
|
ev.xclient.data.l[3] = data1;
|
|
|
|
ev.xclient.data.l[4] = data2;
|
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
clutter_x11_trap_x_errors ();
|
2007-04-19 15:24:57 +00:00
|
|
|
|
2007-11-17 18:11:14 +00:00
|
|
|
XSendEvent (backend_x11->xdpy, window, False, NoEventMask, &ev);
|
|
|
|
XSync (backend_x11->xdpy, False);
|
2007-04-19 15:24:57 +00:00
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
if (clutter_x11_untrap_x_errors ())
|
2007-04-19 15:24:57 +00:00
|
|
|
return False;
|
|
|
|
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-11-17 18:11:14 +00:00
|
|
|
xembed_set_info (ClutterBackendX11 *backend_x11,
|
|
|
|
Window window,
|
|
|
|
gint flags)
|
2007-04-19 15:24:57 +00:00
|
|
|
{
|
|
|
|
gint32 list[2];
|
|
|
|
|
|
|
|
list[0] = MAX_SUPPORTED_XEMBED_VERSION;
|
|
|
|
list[1] = XEMBED_MAPPED;
|
|
|
|
|
2007-11-17 18:11:14 +00:00
|
|
|
XChangeProperty (backend_x11->xdpy, window,
|
|
|
|
backend_x11->atom_XEMBED_INFO,
|
|
|
|
backend_x11->atom_XEMBED_INFO, 32,
|
2007-04-19 15:24:57 +00:00
|
|
|
PropModeReplace, (unsigned char *) list, 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
|
|
|
#endif
|
2007-03-22 18:21:59 +00:00
|
|
|
|
|
|
|
void
|
2007-11-15 14:45:27 +00:00
|
|
|
_clutter_backend_x11_events_init (ClutterBackend *backend)
|
2007-03-22 18:21:59 +00:00
|
|
|
{
|
2007-11-17 18:11:14 +00:00
|
|
|
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
|
2007-03-22 18:21:59 +00:00
|
|
|
GSource *source;
|
|
|
|
ClutterEventSource *event_source;
|
|
|
|
int connection_number;
|
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
|
|
|
gchar *name;
|
2008-02-12 12:39:22 +00:00
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
connection_number = ConnectionNumber (backend_x11->xdpy);
|
2007-03-22 18:21:59 +00:00
|
|
|
CLUTTER_NOTE (EVENT, "Connection number: %d", connection_number);
|
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
source = backend_x11->event_source = clutter_event_source_new (backend);
|
2007-03-22 18:21:59 +00:00
|
|
|
event_source = (ClutterEventSource *) source;
|
|
|
|
g_source_set_priority (source, CLUTTER_PRIORITY_EVENTS);
|
|
|
|
|
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
|
|
|
name = g_strdup_printf ("Clutter X11 Event (connection: %d)",
|
|
|
|
connection_number);
|
|
|
|
g_source_set_name (source, name);
|
|
|
|
g_free (name);
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
event_source->event_poll_fd.fd = connection_number;
|
|
|
|
event_source->event_poll_fd.events = G_IO_IN;
|
|
|
|
|
|
|
|
event_sources = g_list_prepend (event_sources, event_source);
|
|
|
|
|
|
|
|
g_source_add_poll (source, &event_source->event_poll_fd);
|
|
|
|
g_source_set_can_recurse (source, TRUE);
|
|
|
|
g_source_attach (source, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-11-15 14:45:27 +00:00
|
|
|
_clutter_backend_x11_events_uninit (ClutterBackend *backend)
|
2007-03-22 18:21:59 +00:00
|
|
|
{
|
2007-11-15 14:45:27 +00:00
|
|
|
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
if (backend_x11->event_source)
|
2007-03-22 18:21:59 +00:00
|
|
|
{
|
|
|
|
CLUTTER_NOTE (EVENT, "Destroying the event source");
|
|
|
|
|
|
|
|
event_sources = g_list_remove (event_sources,
|
2007-11-15 14:45:27 +00:00
|
|
|
backend_x11->event_source);
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
g_source_destroy (backend_x11->event_source);
|
|
|
|
g_source_unref (backend_x11->event_source);
|
|
|
|
backend_x11->event_source = NULL;
|
2007-03-22 18:21:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-09 23:31:08 +00:00
|
|
|
static void
|
|
|
|
events_queue (ClutterBackend *backend)
|
2007-03-22 18:21:59 +00:00
|
|
|
{
|
2007-11-15 14:45:27 +00:00
|
|
|
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (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
|
|
|
Display *xdisplay = backend_x11->xdpy;
|
|
|
|
ClutterEvent *event;
|
|
|
|
XEvent xevent;
|
2007-05-09 23:31:08 +00:00
|
|
|
|
|
|
|
while (!clutter_events_pending () && XPending (xdisplay))
|
2007-03-22 18:21:59 +00:00
|
|
|
{
|
|
|
|
XNextEvent (xdisplay, &xevent);
|
|
|
|
|
|
|
|
event = clutter_event_new (CLUTTER_NOTHING);
|
2007-05-09 23:31:08 +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 (_clutter_backend_translate_event (backend, &xevent, event))
|
|
|
|
_clutter_event_push (event, FALSE);
|
2007-03-22 18:21:59 +00:00
|
|
|
else
|
2010-07-08 14:47:18 +00:00
|
|
|
clutter_event_free (event);
|
2007-03-22 18:21:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-21 15:18:14 +00:00
|
|
|
/**
|
2008-06-10 17:11:14 +00:00
|
|
|
* clutter_x11_handle_event:
|
2008-02-21 15:18:14 +00:00
|
|
|
* @xevent: pointer to XEvent structure
|
|
|
|
*
|
|
|
|
* This function processes a single X event; it can be used to hook
|
2010-07-22 09:48:21 +00:00
|
|
|
* into external X11 event processing (for example, a GDK filter
|
|
|
|
* function).
|
|
|
|
*
|
|
|
|
* If clutter_x11_disable_event_retrieval() has been called, you must
|
|
|
|
* let this function process events to update Clutter's internal state.
|
2008-02-21 15:18:14 +00:00
|
|
|
*
|
2008-12-22 13:11:59 +00:00
|
|
|
* Return value: #ClutterX11FilterReturn. %CLUTTER_X11_FILTER_REMOVE
|
|
|
|
* indicates that Clutter has internally handled the event and the
|
|
|
|
* caller should do no further processing. %CLUTTER_X11_FILTER_CONTINUE
|
|
|
|
* indicates that Clutter is either not interested in the event,
|
|
|
|
* or has used the event to update internal state without taking
|
|
|
|
* any exclusive action. %CLUTTER_X11_FILTER_TRANSLATE will not
|
|
|
|
* occur.
|
2008-02-21 15:18:14 +00:00
|
|
|
*
|
2010-07-22 09:48:21 +00:00
|
|
|
* Since: 0.8
|
2008-02-21 15:18:14 +00:00
|
|
|
*/
|
|
|
|
ClutterX11FilterReturn
|
|
|
|
clutter_x11_handle_event (XEvent *xevent)
|
|
|
|
{
|
2008-12-22 13:11:59 +00:00
|
|
|
ClutterX11FilterReturn result;
|
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
|
|
|
ClutterBackend *backend;
|
|
|
|
ClutterEvent *event;
|
|
|
|
gint spin = 1;
|
2008-12-22 13:11:59 +00:00
|
|
|
|
|
|
|
/* The return values here are someone approximate; we return
|
2010-04-30 18:50:11 +00:00
|
|
|
* CLUTTER_X11_FILTER_REMOVE if a clutter event is
|
2008-12-22 13:11:59 +00:00
|
|
|
* generated for the event. This mostly, but not entirely,
|
|
|
|
* corresponds to whether other event processing should be
|
|
|
|
* excluded. As long as the stage window is not shared with another
|
|
|
|
* toolkit it should be safe, and never return
|
|
|
|
* %CLUTTER_X11_FILTER_REMOVE when more processing is needed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
result = CLUTTER_X11_FILTER_CONTINUE;
|
2008-02-21 15:18:14 +00:00
|
|
|
|
|
|
|
clutter_threads_enter ();
|
|
|
|
|
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 = clutter_get_default_backend ();
|
2010-04-30 18:50:11 +00:00
|
|
|
|
2008-02-21 15:18:14 +00:00
|
|
|
event = clutter_event_new (CLUTTER_NOTHING);
|
|
|
|
|
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 (_clutter_backend_translate_event (backend, xevent, event))
|
2008-02-21 15:18:14 +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
|
|
|
_clutter_event_push (event, FALSE);
|
|
|
|
|
2008-12-22 13:11:59 +00:00
|
|
|
result = CLUTTER_X11_FILTER_REMOVE;
|
2008-02-21 15:18:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
clutter_event_free (event);
|
2008-12-22 13:11:59 +00:00
|
|
|
goto out;
|
2008-02-21 15:18:14 +00:00
|
|
|
}
|
|
|
|
|
2009-01-27 16:37:55 +00:00
|
|
|
/*
|
|
|
|
* Motion events can generate synthetic enter and leave events, so if we
|
|
|
|
* are processing a motion event, we need to spin the event loop at least
|
|
|
|
* two extra times to pump the enter/leave events through (otherwise they
|
|
|
|
* just get pushed down the queue and never processed).
|
|
|
|
*/
|
|
|
|
if (event->type == CLUTTER_MOTION)
|
|
|
|
spin += 2;
|
2008-02-21 15:18:14 +00:00
|
|
|
|
2009-01-27 16:37:55 +00:00
|
|
|
while (spin > 0 && (event = clutter_event_get ()))
|
2008-02-21 15:18:14 +00:00
|
|
|
{
|
|
|
|
/* forward the event into clutter for emission etc. */
|
|
|
|
clutter_do_event (event);
|
|
|
|
clutter_event_free (event);
|
2009-01-27 16:37:55 +00:00
|
|
|
--spin;
|
2008-02-21 15:18:14 +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
|
|
|
out:
|
2008-02-21 15:18:14 +00:00
|
|
|
clutter_threads_leave ();
|
|
|
|
|
2008-12-22 13:11:59 +00:00
|
|
|
return result;
|
2008-02-21 15:18:14 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
static gboolean
|
|
|
|
clutter_event_prepare (GSource *source,
|
|
|
|
gint *timeout)
|
|
|
|
{
|
|
|
|
ClutterBackend *backend = ((ClutterEventSource *) source)->backend;
|
|
|
|
gboolean retval;
|
|
|
|
|
2007-08-08 10:20:14 +00:00
|
|
|
clutter_threads_enter ();
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
*timeout = -1;
|
2007-05-09 23:31:08 +00:00
|
|
|
retval = (clutter_events_pending () || check_xpending (backend));
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2007-08-08 10:20:14 +00:00
|
|
|
clutter_threads_leave ();
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
clutter_event_check (GSource *source)
|
|
|
|
{
|
|
|
|
ClutterEventSource *event_source = (ClutterEventSource *) source;
|
|
|
|
ClutterBackend *backend = event_source->backend;
|
|
|
|
gboolean retval;
|
|
|
|
|
2007-08-08 10:20:14 +00:00
|
|
|
clutter_threads_enter ();
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
if (event_source->event_poll_fd.revents & G_IO_IN)
|
2007-05-09 23:31:08 +00:00
|
|
|
retval = (clutter_events_pending () || check_xpending (backend));
|
2007-03-22 18:21:59 +00:00
|
|
|
else
|
|
|
|
retval = FALSE;
|
|
|
|
|
2007-08-08 10:20:14 +00:00
|
|
|
clutter_threads_leave ();
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
clutter_event_dispatch (GSource *source,
|
|
|
|
GSourceFunc callback,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
ClutterBackend *backend = ((ClutterEventSource *) source)->backend;
|
|
|
|
ClutterEvent *event;
|
|
|
|
|
2007-08-08 10:20:14 +00:00
|
|
|
clutter_threads_enter ();
|
|
|
|
|
2008-02-12 12:39:22 +00:00
|
|
|
/* Grab the event(s), translate and figure out double click.
|
2007-05-09 23:31:08 +00:00
|
|
|
* The push onto queue (stack) if valid.
|
|
|
|
*/
|
|
|
|
events_queue (backend);
|
|
|
|
|
|
|
|
/* Pop an event off the queue if any */
|
|
|
|
event = clutter_event_get ();
|
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 (event != NULL)
|
2007-03-22 18:21:59 +00:00
|
|
|
{
|
2007-05-09 23:31:08 +00:00
|
|
|
/* forward the event into clutter for emission etc. */
|
|
|
|
clutter_do_event (event);
|
2007-03-22 18:21:59 +00:00
|
|
|
clutter_event_free (event);
|
|
|
|
}
|
|
|
|
|
2007-08-08 10:20:14 +00:00
|
|
|
clutter_threads_leave ();
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2009-02-18 09:45:26 +00:00
|
|
|
|
|
|
|
/**
|
2011-02-08 15:31:20 +00:00
|
|
|
* clutter_x11_get_current_event_time: (skip)
|
2009-02-18 09:45:26 +00:00
|
|
|
*
|
|
|
|
* Retrieves the timestamp of the last X11 event processed by
|
|
|
|
* Clutter. This might be different from the timestamp returned
|
|
|
|
* by clutter_get_current_event_time(), as Clutter may synthesize
|
|
|
|
* or throttle events.
|
|
|
|
*
|
|
|
|
* Return value: a timestamp, in milliseconds
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
Time
|
|
|
|
clutter_x11_get_current_event_time (void)
|
|
|
|
{
|
|
|
|
ClutterBackend *backend = clutter_get_default_backend ();
|
|
|
|
|
|
|
|
return CLUTTER_BACKEND_X11 (backend)->last_event_time;
|
|
|
|
}
|
2010-07-08 14:47:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_x11_event_get_key_group:
|
|
|
|
* @event: a #ClutterEvent of type %CLUTTER_KEY_PRESS or %CLUTTER_KEY_RELEASE
|
|
|
|
*
|
|
|
|
* Retrieves the group for the modifiers set in @event
|
|
|
|
*
|
|
|
|
* Return value: the group id
|
|
|
|
*
|
|
|
|
* Since: 1.4
|
|
|
|
*/
|
|
|
|
gint
|
|
|
|
clutter_x11_event_get_key_group (const ClutterEvent *event)
|
|
|
|
{
|
|
|
|
ClutterEventX11 *event_x11;
|
|
|
|
|
|
|
|
g_return_val_if_fail (event != NULL, 0);
|
|
|
|
g_return_val_if_fail (event->type == CLUTTER_KEY_PRESS ||
|
|
|
|
event->type == CLUTTER_KEY_RELEASE, 0);
|
|
|
|
|
|
|
|
event_x11 = _clutter_event_get_platform_data (event);
|
|
|
|
if (event_x11 == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return event_x11->key_group;
|
|
|
|
}
|