2007-03-22 14:21:59 -04: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 07:56:10 -05:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*
|
2007-03-22 14:21:59 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
2009-11-30 12:47:55 -05:00
|
|
|
#include <fcntl.h>
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2009-01-06 07:11:07 -05:00
|
|
|
#include <glib/gi18n-lib.h>
|
|
|
|
|
2007-05-16 05:08:30 -04:00
|
|
|
#include <GL/glx.h>
|
2009-11-12 15:37:01 -05:00
|
|
|
#include <GL/glxext.h>
|
2007-05-16 05:08:30 -04:00
|
|
|
#include <GL/gl.h>
|
|
|
|
|
2007-03-22 14:21:59 -04:00
|
|
|
#include "clutter-backend-glx.h"
|
|
|
|
#include "clutter-stage-glx.h"
|
2007-05-16 05:08:30 -04:00
|
|
|
#include "clutter-glx.h"
|
2009-03-30 11:41:02 -04:00
|
|
|
#include "clutter-profile.h"
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2010-10-21 06:29:09 -04:00
|
|
|
#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 07:32:04 -05:00
|
|
|
#include "clutter-event-translator.h"
|
2010-10-21 06:29:09 -04:00
|
|
|
#include "clutter-event.h"
|
|
|
|
#include "clutter-main.h"
|
|
|
|
#include "clutter-private.h"
|
|
|
|
#include "clutter-stage-private.h"
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2011-02-22 10:51:13 -05:00
|
|
|
#include <cogl/cogl.h>
|
2007-05-16 05:08:30 -04:00
|
|
|
|
2011-01-21 05:49:12 -05:00
|
|
|
#define clutter_backend_glx_get_type _clutter_backend_glx_get_type
|
2009-03-30 11:41:02 -04:00
|
|
|
|
2011-01-21 05:49:12 -05:00
|
|
|
G_DEFINE_TYPE (ClutterBackendGLX, clutter_backend_glx, CLUTTER_TYPE_BACKEND_X11);
|
2007-03-22 14:21:59 -04:00
|
|
|
|
|
|
|
/* singleton object */
|
2007-05-31 07:13:43 -04:00
|
|
|
static ClutterBackendGLX *backend_singleton = NULL;
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2010-11-05 08:28:33 -04:00
|
|
|
static gchar *clutter_vblank = NULL;
|
2007-05-16 05:08:30 -04:00
|
|
|
|
|
|
|
G_CONST_RETURN gchar*
|
2010-11-05 08:28:33 -04:00
|
|
|
_clutter_backend_glx_get_vblank (void)
|
2007-05-16 05:08:30 -04:00
|
|
|
{
|
2010-11-05 08:28:33 -04:00
|
|
|
if (clutter_vblank && strcmp (clutter_vblank, "0") == 0)
|
|
|
|
return "none";
|
|
|
|
else
|
|
|
|
return clutter_vblank;
|
2007-05-16 05:08:30 -04:00
|
|
|
}
|
|
|
|
|
2007-03-22 14:21:59 -04:00
|
|
|
static gboolean
|
|
|
|
clutter_backend_glx_pre_parse (ClutterBackend *backend,
|
|
|
|
GError **error)
|
|
|
|
{
|
2011-01-20 10:39:28 -05:00
|
|
|
ClutterBackendClass *parent_class =
|
2011-01-21 05:49:12 -05:00
|
|
|
CLUTTER_BACKEND_CLASS (clutter_backend_glx_parent_class);
|
2007-03-22 14:21:59 -04:00
|
|
|
const gchar *env_string;
|
|
|
|
|
2007-05-16 05:08:30 -04:00
|
|
|
env_string = g_getenv ("CLUTTER_VBLANK");
|
|
|
|
if (env_string)
|
|
|
|
{
|
2010-11-05 08:28:33 -04:00
|
|
|
clutter_vblank = g_strdup (env_string);
|
2007-05-16 05:08:30 -04:00
|
|
|
env_string = NULL;
|
|
|
|
}
|
|
|
|
|
2011-01-20 10:39:28 -05:00
|
|
|
return parent_class->pre_parse (backend, error);
|
2007-03-22 14:21:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
clutter_backend_glx_post_parse (ClutterBackend *backend,
|
|
|
|
GError **error)
|
|
|
|
{
|
2011-01-20 10:39:28 -05:00
|
|
|
ClutterBackendClass *parent_class =
|
2011-01-21 05:49:12 -05:00
|
|
|
CLUTTER_BACKEND_CLASS (clutter_backend_glx_parent_class);
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2011-01-20 10:39:28 -05:00
|
|
|
if (!parent_class->post_parse (backend, error))
|
2009-11-12 15:37:01 -05:00
|
|
|
return FALSE;
|
|
|
|
|
2007-03-22 14:21:59 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const GOptionEntry entries[] =
|
|
|
|
{
|
2009-07-31 15:39:28 -04:00
|
|
|
{ "vblank", 0,
|
|
|
|
0,
|
2010-11-05 08:28:33 -04:00
|
|
|
G_OPTION_ARG_STRING, &clutter_vblank,
|
|
|
|
N_("Set to 'none' or '0' to disable throttling "
|
|
|
|
"framerate to vblank"), "OPTION"
|
2007-05-16 05:08:30 -04:00
|
|
|
},
|
2007-03-22 14:21:59 -04:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_backend_glx_add_options (ClutterBackend *backend,
|
|
|
|
GOptionGroup *group)
|
|
|
|
{
|
2011-01-20 10:39:28 -05:00
|
|
|
ClutterBackendClass *parent_class =
|
2011-01-21 05:49:12 -05:00
|
|
|
CLUTTER_BACKEND_CLASS (clutter_backend_glx_parent_class);
|
2011-01-20 10:39:28 -05:00
|
|
|
|
2007-03-22 14:21:59 -04:00
|
|
|
g_option_group_add_entries (group, entries);
|
2011-01-20 10:39:28 -05:00
|
|
|
|
|
|
|
parent_class->add_options (backend, group);
|
2007-03-22 14:21:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_backend_glx_finalize (GObject *gobject)
|
|
|
|
{
|
|
|
|
if (backend_singleton)
|
|
|
|
backend_singleton = NULL;
|
|
|
|
|
2011-01-21 05:49:12 -05:00
|
|
|
G_OBJECT_CLASS (clutter_backend_glx_parent_class)->finalize (gobject);
|
2007-03-22 14:21:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_backend_glx_dispose (GObject *gobject)
|
|
|
|
{
|
2010-11-05 08:28:33 -04:00
|
|
|
ClutterBackend *backend = CLUTTER_BACKEND (gobject);
|
2008-04-04 11:02:11 -04:00
|
|
|
|
2008-05-13 06:42:36 -04:00
|
|
|
/* Unrealize all shaders, since the GL context is going away */
|
2010-11-05 08:28:33 -04:00
|
|
|
/* XXX: Why isn't this done in
|
|
|
|
* clutter-backend.c:clutter_backend_dispose ?
|
|
|
|
*/
|
2008-05-13 06:42:36 -04:00
|
|
|
_clutter_shader_release_all ();
|
|
|
|
|
2010-11-05 08:28:33 -04:00
|
|
|
/* We chain up before disposing our CoglContext so that we will
|
|
|
|
* destroy all of the stages first. Otherwise the actors may try to
|
|
|
|
* make Cogl calls during destruction which would cause a crash */
|
2011-01-21 05:49:12 -05:00
|
|
|
G_OBJECT_CLASS (clutter_backend_glx_parent_class)->dispose (gobject);
|
2010-11-05 08:28:33 -04:00
|
|
|
|
|
|
|
cogl_object_unref (backend->cogl_context);
|
2007-03-22 14:21:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static GObject *
|
|
|
|
clutter_backend_glx_constructor (GType gtype,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params)
|
|
|
|
{
|
|
|
|
GObjectClass *parent_class;
|
|
|
|
GObject *retval;
|
|
|
|
|
|
|
|
if (!backend_singleton)
|
|
|
|
{
|
2011-01-21 05:49:12 -05:00
|
|
|
parent_class = G_OBJECT_CLASS (clutter_backend_glx_parent_class);
|
2007-03-22 14:21:59 -04:00
|
|
|
retval = parent_class->constructor (gtype, n_params, params);
|
|
|
|
|
|
|
|
backend_singleton = CLUTTER_BACKEND_GLX (retval);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_warning ("Attempting to create a new backend object. This should "
|
|
|
|
"never happen, so we return the singleton instance.");
|
2009-07-31 15:39:28 -04:00
|
|
|
|
2007-03-22 14:21:59 -04:00
|
|
|
return g_object_ref (backend_singleton);
|
|
|
|
}
|
|
|
|
|
2007-05-16 05:08:30 -04:00
|
|
|
static ClutterFeatureFlags
|
|
|
|
clutter_backend_glx_get_features (ClutterBackend *backend)
|
|
|
|
{
|
2009-12-03 12:13:44 -05:00
|
|
|
ClutterBackendGLX *backend_glx = CLUTTER_BACKEND_GLX (backend);
|
2011-01-20 10:39:28 -05:00
|
|
|
ClutterBackendClass *parent_class;
|
2008-04-04 11:02:11 -04:00
|
|
|
ClutterFeatureFlags flags;
|
2009-07-31 15:39:28 -04:00
|
|
|
|
2011-01-21 05:49:12 -05:00
|
|
|
parent_class = CLUTTER_BACKEND_CLASS (clutter_backend_glx_parent_class);
|
2011-01-20 10:39:28 -05:00
|
|
|
|
|
|
|
flags = parent_class->get_features (backend);
|
2009-12-03 12:13:44 -05:00
|
|
|
|
2010-11-05 08:28:33 -04:00
|
|
|
if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_MULTIPLE_ONSCREEN))
|
2010-06-03 15:03:20 -04:00
|
|
|
{
|
2010-11-05 08:28:33 -04:00
|
|
|
CLUTTER_NOTE (BACKEND, "Cogl supports multiple onscreen framebuffers");
|
|
|
|
flags |= CLUTTER_FEATURE_STAGE_MULTIPLE;
|
2010-06-03 15:03:20 -04:00
|
|
|
}
|
2010-11-05 08:28:33 -04:00
|
|
|
else
|
2007-05-16 05:08:30 -04:00
|
|
|
{
|
2010-11-05 08:28:33 -04:00
|
|
|
CLUTTER_NOTE (BACKEND, "Cogl only supports one onscreen framebuffer");
|
|
|
|
flags |= CLUTTER_FEATURE_STAGE_STATIC;
|
2007-05-16 05:08:30 -04:00
|
|
|
}
|
2010-02-25 13:28:37 -05:00
|
|
|
|
2010-11-05 08:28:33 -04:00
|
|
|
if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_THROTTLE))
|
2007-05-16 05:08:30 -04:00
|
|
|
{
|
2010-11-05 08:28:33 -04:00
|
|
|
CLUTTER_NOTE (BACKEND, "Cogl supports swap buffers throttling");
|
2010-02-25 13:28:37 -05:00
|
|
|
flags |= CLUTTER_FEATURE_SYNC_TO_VBLANK;
|
|
|
|
}
|
2010-11-05 08:28:33 -04:00
|
|
|
else
|
|
|
|
CLUTTER_NOTE (BACKEND, "Cogl doesn't support swap buffers throttling");
|
2010-02-25 13:28:37 -05:00
|
|
|
|
2010-11-05 08:28:33 -04:00
|
|
|
if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_BUFFERS_EVENT))
|
2010-02-25 13:28:37 -05:00
|
|
|
{
|
2010-11-05 08:28:33 -04:00
|
|
|
CLUTTER_NOTE (BACKEND, "Cogl supports swap buffers complete events");
|
|
|
|
flags |= CLUTTER_FEATURE_SWAP_EVENTS;
|
2007-05-16 05:08:30 -04:00
|
|
|
}
|
|
|
|
|
2010-11-05 08:28:33 -04:00
|
|
|
if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_REGION))
|
2009-11-30 12:47:55 -05:00
|
|
|
{
|
2010-11-05 08:28:33 -04:00
|
|
|
CLUTTER_NOTE (BACKEND, "Cogl supports swapping buffer regions");
|
2010-06-05 06:51:32 -04:00
|
|
|
backend_glx->can_blit_sub_buffer = TRUE;
|
2009-11-30 12:47:55 -05:00
|
|
|
}
|
|
|
|
|
2009-12-03 12:13:44 -05:00
|
|
|
CLUTTER_NOTE (BACKEND, "backend features checked");
|
|
|
|
|
2008-04-04 11:02:11 -04:00
|
|
|
return flags;
|
2007-05-16 05:08:30 -04:00
|
|
|
}
|
|
|
|
|
2009-07-31 12:07:10 -04:00
|
|
|
static XVisualInfo *
|
|
|
|
clutter_backend_glx_get_visual_info (ClutterBackendX11 *backend_x11)
|
|
|
|
{
|
2010-11-05 08:28:33 -04:00
|
|
|
return cogl_clutter_winsys_xlib_get_visual_info ();
|
2009-07-31 12:07:10 -04:00
|
|
|
}
|
|
|
|
|
2009-05-13 17:21:48 -04:00
|
|
|
static gboolean
|
|
|
|
clutter_backend_glx_create_context (ClutterBackend *backend,
|
|
|
|
GError **error)
|
|
|
|
{
|
2010-01-14 09:03:23 -05:00
|
|
|
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
|
2010-11-05 08:28:33 -04:00
|
|
|
CoglSwapChain *swap_chain = NULL;
|
|
|
|
CoglOnscreenTemplate *onscreen_template = NULL;
|
2009-12-03 15:49:54 -05:00
|
|
|
|
2010-11-05 08:28:33 -04:00
|
|
|
if (backend->cogl_context)
|
|
|
|
return TRUE;
|
2009-12-03 15:49:54 -05:00
|
|
|
|
2010-11-05 08:28:33 -04:00
|
|
|
backend->cogl_renderer = cogl_renderer_new ();
|
|
|
|
cogl_renderer_xlib_set_foreign_display (backend->cogl_renderer,
|
|
|
|
backend_x11->xdpy);
|
|
|
|
if (!cogl_renderer_connect (backend->cogl_renderer, error))
|
|
|
|
goto error;
|
2009-05-13 17:21:48 -04:00
|
|
|
|
2010-11-05 08:28:33 -04:00
|
|
|
swap_chain = cogl_swap_chain_new ();
|
|
|
|
cogl_swap_chain_set_has_alpha (swap_chain,
|
|
|
|
clutter_x11_get_use_argb_visual ());
|
2009-12-01 11:18:39 -05:00
|
|
|
|
2010-11-05 08:28:33 -04:00
|
|
|
onscreen_template = cogl_onscreen_template_new (swap_chain);
|
|
|
|
cogl_object_unref (swap_chain);
|
2010-01-14 09:03:23 -05:00
|
|
|
|
2010-11-05 08:28:33 -04:00
|
|
|
if (!cogl_renderer_check_onscreen_template (backend->cogl_renderer,
|
|
|
|
onscreen_template,
|
|
|
|
error))
|
|
|
|
goto error;
|
2010-01-14 09:03:23 -05:00
|
|
|
|
2010-11-05 08:28:33 -04:00
|
|
|
backend->cogl_display = cogl_display_new (backend->cogl_renderer,
|
|
|
|
onscreen_template);
|
|
|
|
cogl_object_unref (backend->cogl_renderer);
|
|
|
|
cogl_object_unref (onscreen_template);
|
2009-12-06 13:56:14 -05:00
|
|
|
|
2010-11-05 08:28:33 -04:00
|
|
|
if (!cogl_display_setup (backend->cogl_display, error))
|
|
|
|
goto error;
|
2009-05-13 17:21:48 -04:00
|
|
|
|
2010-11-05 08:28:33 -04:00
|
|
|
backend->cogl_context = cogl_context_new (backend->cogl_display, error);
|
|
|
|
if (!backend->cogl_context)
|
|
|
|
goto error;
|
2010-02-04 08:56:33 -05:00
|
|
|
|
2010-11-05 08:28:33 -04:00
|
|
|
/* XXX: eventually this should go away but a lot of Cogl code still
|
|
|
|
* depends on a global default context. */
|
|
|
|
cogl_set_default_context (backend->cogl_context);
|
2009-05-13 17:21:48 -04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
2010-11-05 08:28:33 -04:00
|
|
|
error:
|
|
|
|
if (backend->cogl_display)
|
2008-04-01 10:04:46 -04:00
|
|
|
{
|
2010-11-05 08:28:33 -04:00
|
|
|
cogl_object_unref (backend->cogl_display);
|
|
|
|
backend->cogl_display = NULL;
|
|
|
|
}
|
2008-04-04 11:02:11 -04:00
|
|
|
|
2010-11-05 08:28:33 -04:00
|
|
|
if (onscreen_template)
|
|
|
|
cogl_object_unref (onscreen_template);
|
|
|
|
if (swap_chain)
|
|
|
|
cogl_object_unref (swap_chain);
|
2008-03-28 18:50:55 -04:00
|
|
|
|
2010-11-05 08:28:33 -04:00
|
|
|
if (backend->cogl_renderer)
|
2008-04-01 10:04:46 -04:00
|
|
|
{
|
2010-11-05 08:28:33 -04:00
|
|
|
cogl_object_unref (backend->cogl_renderer);
|
|
|
|
backend->cogl_renderer = NULL;
|
2008-04-01 10:04:46 -04:00
|
|
|
}
|
2010-11-05 08:28:33 -04:00
|
|
|
return FALSE;
|
2008-03-28 18:50:55 -04:00
|
|
|
}
|
|
|
|
|
2009-08-13 07:34:07 -04:00
|
|
|
static ClutterStageWindow *
|
2008-03-28 18:50:55 -04:00
|
|
|
clutter_backend_glx_create_stage (ClutterBackend *backend,
|
2008-04-04 11:02:11 -04:00
|
|
|
ClutterStage *wrapper,
|
2008-03-28 18:50:55 -04:00
|
|
|
GError **error)
|
2007-11-15 09:45:27 -05: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 07:32:04 -05:00
|
|
|
ClutterEventTranslator *translator;
|
2009-08-13 07:34:07 -04:00
|
|
|
ClutterStageWindow *stage_window;
|
|
|
|
ClutterStageX11 *stage_x11;
|
2007-11-15 09:45:27 -05:00
|
|
|
|
2009-08-13 07:34:07 -04:00
|
|
|
stage_window = g_object_new (CLUTTER_TYPE_STAGE_GLX, NULL);
|
2007-11-15 09:45:27 -05:00
|
|
|
|
2008-03-28 18:50:55 -04:00
|
|
|
/* copy backend data into the stage */
|
2009-08-13 07:34:07 -04:00
|
|
|
stage_x11 = CLUTTER_STAGE_X11 (stage_window);
|
2008-04-04 11:02:11 -04:00
|
|
|
stage_x11->wrapper = wrapper;
|
2011-01-26 06:58:08 -05:00
|
|
|
stage_x11->backend = backend_x11;
|
2008-04-04 11:02:11 -04: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 07:32:04 -05:00
|
|
|
translator = CLUTTER_EVENT_TRANSLATOR (stage_x11);
|
2011-02-09 07:20:56 -05: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 07:32:04 -05:00
|
|
|
|
2009-05-08 12:17:48 -04:00
|
|
|
CLUTTER_NOTE (BACKEND,
|
|
|
|
"GLX stage created[%p] (dpy:%p, screen:%d, root:%u, wrap:%p)",
|
2009-08-13 07:34:07 -04:00
|
|
|
stage_window,
|
2009-08-03 09:50:10 -04:00
|
|
|
backend_x11->xdpy,
|
|
|
|
backend_x11->xscreen_num,
|
|
|
|
(unsigned int) backend_x11->xwin_root,
|
2009-05-08 12:17:48 -04:00
|
|
|
wrapper);
|
2007-11-15 09:45:27 -05:00
|
|
|
|
2009-08-13 07:34:07 -04:00
|
|
|
return stage_window;
|
2007-05-28 14:49:34 -04:00
|
|
|
}
|
|
|
|
|
2010-11-05 08:28:33 -04:00
|
|
|
static void
|
|
|
|
clutter_backend_glx_ensure_context (ClutterBackend *backend,
|
|
|
|
ClutterStage *stage)
|
|
|
|
{
|
|
|
|
ClutterStageGLX *stage_glx =
|
|
|
|
CLUTTER_STAGE_GLX (_clutter_stage_get_window (stage));
|
|
|
|
|
|
|
|
cogl_set_framebuffer (COGL_FRAMEBUFFER (stage_glx->onscreen));
|
|
|
|
}
|
|
|
|
|
2007-03-22 14:21:59 -04:00
|
|
|
static void
|
2011-01-21 05:49:12 -05:00
|
|
|
clutter_backend_glx_class_init (ClutterBackendGLXClass *klass)
|
2007-03-22 14:21:59 -04:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
ClutterBackendClass *backend_class = CLUTTER_BACKEND_CLASS (klass);
|
2009-05-13 16:49:45 -04:00
|
|
|
ClutterBackendX11Class *backendx11_class = CLUTTER_BACKEND_X11_CLASS (klass);
|
2007-03-22 14:21:59 -04:00
|
|
|
|
|
|
|
gobject_class->constructor = clutter_backend_glx_constructor;
|
2008-03-28 18:50:55 -04:00
|
|
|
gobject_class->dispose = clutter_backend_glx_dispose;
|
|
|
|
gobject_class->finalize = clutter_backend_glx_finalize;
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2008-04-04 11:02:11 -04:00
|
|
|
backend_class->pre_parse = clutter_backend_glx_pre_parse;
|
|
|
|
backend_class->post_parse = clutter_backend_glx_post_parse;
|
|
|
|
backend_class->create_stage = clutter_backend_glx_create_stage;
|
|
|
|
backend_class->add_options = clutter_backend_glx_add_options;
|
|
|
|
backend_class->get_features = clutter_backend_glx_get_features;
|
2009-05-13 17:21:48 -04:00
|
|
|
backend_class->create_context = clutter_backend_glx_create_context;
|
2008-03-28 18:50:55 -04:00
|
|
|
backend_class->ensure_context = clutter_backend_glx_ensure_context;
|
2009-05-13 16:49:45 -04:00
|
|
|
|
|
|
|
backendx11_class->get_visual_info = clutter_backend_glx_get_visual_info;
|
2007-03-22 14:21:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-01-21 05:49:12 -05:00
|
|
|
clutter_backend_glx_init (ClutterBackendGLX *backend_glx)
|
2007-03-22 14:21:59 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* every backend must implement this function */
|
|
|
|
GType
|
|
|
|
_clutter_backend_impl_get_type (void)
|
|
|
|
{
|
2010-08-13 10:48:30 -04:00
|
|
|
return _clutter_backend_glx_get_type ();
|
2007-03-22 14:21:59 -04:00
|
|
|
}
|