2007-03-22 18:21:59 +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-03-22 18:21:59 +00: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 17:47:55 +00:00
|
|
|
#include <fcntl.h>
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2009-01-06 12:11:07 +00:00
|
|
|
#include <glib/gi18n-lib.h>
|
|
|
|
|
2007-05-16 09:08:30 +00:00
|
|
|
#include <GL/glx.h>
|
2009-11-12 20:37:01 +00:00
|
|
|
#include <GL/glxext.h>
|
2007-05-16 09:08:30 +00:00
|
|
|
#include <GL/gl.h>
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
#include "clutter-backend-glx.h"
|
|
|
|
#include "clutter-stage-glx.h"
|
2007-05-16 09:08:30 +00:00
|
|
|
#include "clutter-glx.h"
|
2009-03-30 15:41:02 +00:00
|
|
|
#include "clutter-profile.h"
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2010-10-21 10:29:09 +00: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 12:32:04 +00:00
|
|
|
#include "clutter-event-translator.h"
|
2010-10-21 10:29:09 +00:00
|
|
|
#include "clutter-event.h"
|
|
|
|
#include "clutter-main.h"
|
|
|
|
#include "clutter-private.h"
|
|
|
|
#include "clutter-stage-private.h"
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2011-02-22 15:51:13 +00:00
|
|
|
#include <cogl/cogl.h>
|
2007-05-16 09:08:30 +00:00
|
|
|
|
2011-01-21 10:49:12 +00:00
|
|
|
#define clutter_backend_glx_get_type _clutter_backend_glx_get_type
|
2009-03-30 15:41:02 +00:00
|
|
|
|
2011-01-21 10:49:12 +00:00
|
|
|
G_DEFINE_TYPE (ClutterBackendGLX, clutter_backend_glx, CLUTTER_TYPE_BACKEND_X11);
|
2007-03-22 18:21:59 +00:00
|
|
|
|
|
|
|
/* singleton object */
|
2007-05-31 11:13:43 +00:00
|
|
|
static ClutterBackendGLX *backend_singleton = NULL;
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2010-11-05 12:28:33 +00:00
|
|
|
static gchar *clutter_vblank = NULL;
|
2007-05-16 09:08:30 +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 gchar *
|
2010-11-05 12:28:33 +00:00
|
|
|
_clutter_backend_glx_get_vblank (void)
|
2007-05-16 09:08:30 +00:00
|
|
|
{
|
2010-11-05 12:28:33 +00:00
|
|
|
if (clutter_vblank && strcmp (clutter_vblank, "0") == 0)
|
|
|
|
return "none";
|
|
|
|
else
|
|
|
|
return clutter_vblank;
|
2007-05-16 09:08:30 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
static gboolean
|
|
|
|
clutter_backend_glx_pre_parse (ClutterBackend *backend,
|
|
|
|
GError **error)
|
|
|
|
{
|
2011-01-20 15:39:28 +00:00
|
|
|
ClutterBackendClass *parent_class =
|
2011-01-21 10:49:12 +00:00
|
|
|
CLUTTER_BACKEND_CLASS (clutter_backend_glx_parent_class);
|
2007-03-22 18:21:59 +00:00
|
|
|
const gchar *env_string;
|
|
|
|
|
2007-05-16 09:08:30 +00:00
|
|
|
env_string = g_getenv ("CLUTTER_VBLANK");
|
|
|
|
if (env_string)
|
|
|
|
{
|
2010-11-05 12:28:33 +00:00
|
|
|
clutter_vblank = g_strdup (env_string);
|
2007-05-16 09:08:30 +00:00
|
|
|
env_string = NULL;
|
|
|
|
}
|
|
|
|
|
2011-01-20 15:39:28 +00:00
|
|
|
return parent_class->pre_parse (backend, error);
|
2007-03-22 18:21:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
clutter_backend_glx_post_parse (ClutterBackend *backend,
|
|
|
|
GError **error)
|
|
|
|
{
|
2011-01-20 15:39:28 +00:00
|
|
|
ClutterBackendClass *parent_class =
|
2011-01-21 10:49:12 +00:00
|
|
|
CLUTTER_BACKEND_CLASS (clutter_backend_glx_parent_class);
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2011-01-20 15:39:28 +00:00
|
|
|
if (!parent_class->post_parse (backend, error))
|
2009-11-12 20:37:01 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const GOptionEntry entries[] =
|
|
|
|
{
|
2009-07-31 19:39:28 +00:00
|
|
|
{ "vblank", 0,
|
|
|
|
0,
|
2010-11-05 12:28:33 +00:00
|
|
|
G_OPTION_ARG_STRING, &clutter_vblank,
|
|
|
|
N_("Set to 'none' or '0' to disable throttling "
|
|
|
|
"framerate to vblank"), "OPTION"
|
2007-05-16 09:08:30 +00:00
|
|
|
},
|
2007-03-22 18:21:59 +00:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_backend_glx_add_options (ClutterBackend *backend,
|
|
|
|
GOptionGroup *group)
|
|
|
|
{
|
2011-01-20 15:39:28 +00:00
|
|
|
ClutterBackendClass *parent_class =
|
2011-01-21 10:49:12 +00:00
|
|
|
CLUTTER_BACKEND_CLASS (clutter_backend_glx_parent_class);
|
2011-01-20 15:39:28 +00:00
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
g_option_group_add_entries (group, entries);
|
2011-01-20 15:39:28 +00:00
|
|
|
|
|
|
|
parent_class->add_options (backend, group);
|
2007-03-22 18:21:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_backend_glx_finalize (GObject *gobject)
|
|
|
|
{
|
|
|
|
if (backend_singleton)
|
|
|
|
backend_singleton = NULL;
|
|
|
|
|
2011-01-21 10:49:12 +00:00
|
|
|
G_OBJECT_CLASS (clutter_backend_glx_parent_class)->finalize (gobject);
|
2007-03-22 18:21:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_backend_glx_dispose (GObject *gobject)
|
|
|
|
{
|
2010-11-05 12:28:33 +00:00
|
|
|
ClutterBackend *backend = CLUTTER_BACKEND (gobject);
|
2008-04-04 15:02:11 +00:00
|
|
|
|
2008-05-13 10:42:36 +00:00
|
|
|
/* Unrealize all shaders, since the GL context is going away */
|
2010-11-05 12:28:33 +00:00
|
|
|
/* XXX: Why isn't this done in
|
|
|
|
* clutter-backend.c:clutter_backend_dispose ?
|
|
|
|
*/
|
2008-05-13 10:42:36 +00:00
|
|
|
_clutter_shader_release_all ();
|
|
|
|
|
2010-11-05 12:28:33 +00: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 10:49:12 +00:00
|
|
|
G_OBJECT_CLASS (clutter_backend_glx_parent_class)->dispose (gobject);
|
2010-11-05 12:28:33 +00:00
|
|
|
|
2011-04-20 10:10:54 +00:00
|
|
|
if (backend->cogl_context)
|
|
|
|
{
|
|
|
|
cogl_object_unref (backend->cogl_context);
|
|
|
|
backend->cogl_context = NULL;
|
|
|
|
}
|
2007-03-22 18:21:59 +00: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 10:49:12 +00:00
|
|
|
parent_class = G_OBJECT_CLASS (clutter_backend_glx_parent_class);
|
2007-03-22 18:21:59 +00: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 19:39:28 +00:00
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
return g_object_ref (backend_singleton);
|
|
|
|
}
|
|
|
|
|
2007-05-16 09:08:30 +00:00
|
|
|
static ClutterFeatureFlags
|
|
|
|
clutter_backend_glx_get_features (ClutterBackend *backend)
|
|
|
|
{
|
2009-12-03 17:13:44 +00:00
|
|
|
ClutterBackendGLX *backend_glx = CLUTTER_BACKEND_GLX (backend);
|
2011-01-20 15:39:28 +00:00
|
|
|
ClutterBackendClass *parent_class;
|
2008-04-04 15:02:11 +00:00
|
|
|
ClutterFeatureFlags flags;
|
2009-07-31 19:39:28 +00:00
|
|
|
|
2011-01-21 10:49:12 +00:00
|
|
|
parent_class = CLUTTER_BACKEND_CLASS (clutter_backend_glx_parent_class);
|
2011-01-20 15:39:28 +00:00
|
|
|
|
|
|
|
flags = parent_class->get_features (backend);
|
2009-12-03 17:13:44 +00:00
|
|
|
|
2010-11-05 12:28:33 +00:00
|
|
|
if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_MULTIPLE_ONSCREEN))
|
2010-06-03 19:03:20 +00:00
|
|
|
{
|
2010-11-05 12:28:33 +00:00
|
|
|
CLUTTER_NOTE (BACKEND, "Cogl supports multiple onscreen framebuffers");
|
|
|
|
flags |= CLUTTER_FEATURE_STAGE_MULTIPLE;
|
2010-06-03 19:03:20 +00:00
|
|
|
}
|
2010-11-05 12:28:33 +00:00
|
|
|
else
|
2007-05-16 09:08:30 +00:00
|
|
|
{
|
2010-11-05 12:28:33 +00:00
|
|
|
CLUTTER_NOTE (BACKEND, "Cogl only supports one onscreen framebuffer");
|
|
|
|
flags |= CLUTTER_FEATURE_STAGE_STATIC;
|
2007-05-16 09:08:30 +00:00
|
|
|
}
|
2010-02-25 18:28:37 +00:00
|
|
|
|
2010-11-05 12:28:33 +00:00
|
|
|
if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_THROTTLE))
|
2007-05-16 09:08:30 +00:00
|
|
|
{
|
2010-11-05 12:28:33 +00:00
|
|
|
CLUTTER_NOTE (BACKEND, "Cogl supports swap buffers throttling");
|
2010-02-25 18:28:37 +00:00
|
|
|
flags |= CLUTTER_FEATURE_SYNC_TO_VBLANK;
|
|
|
|
}
|
2010-11-05 12:28:33 +00:00
|
|
|
else
|
|
|
|
CLUTTER_NOTE (BACKEND, "Cogl doesn't support swap buffers throttling");
|
2010-02-25 18:28:37 +00:00
|
|
|
|
2010-11-05 12:28:33 +00:00
|
|
|
if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_BUFFERS_EVENT))
|
2010-02-25 18:28:37 +00:00
|
|
|
{
|
2010-11-05 12:28:33 +00:00
|
|
|
CLUTTER_NOTE (BACKEND, "Cogl supports swap buffers complete events");
|
|
|
|
flags |= CLUTTER_FEATURE_SWAP_EVENTS;
|
2007-05-16 09:08:30 +00:00
|
|
|
}
|
|
|
|
|
2010-11-05 12:28:33 +00:00
|
|
|
if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_REGION))
|
2009-11-30 17:47:55 +00:00
|
|
|
{
|
2010-11-05 12:28:33 +00:00
|
|
|
CLUTTER_NOTE (BACKEND, "Cogl supports swapping buffer regions");
|
2010-06-05 10:51:32 +00:00
|
|
|
backend_glx->can_blit_sub_buffer = TRUE;
|
2009-11-30 17:47:55 +00:00
|
|
|
}
|
|
|
|
|
2009-12-03 17:13:44 +00:00
|
|
|
CLUTTER_NOTE (BACKEND, "backend features checked");
|
|
|
|
|
2008-04-04 15:02:11 +00:00
|
|
|
return flags;
|
2007-05-16 09:08:30 +00:00
|
|
|
}
|
|
|
|
|
2009-07-31 16:07:10 +00:00
|
|
|
static XVisualInfo *
|
|
|
|
clutter_backend_glx_get_visual_info (ClutterBackendX11 *backend_x11)
|
|
|
|
{
|
2010-11-05 12:28:33 +00:00
|
|
|
return cogl_clutter_winsys_xlib_get_visual_info ();
|
2009-07-31 16:07:10 +00:00
|
|
|
}
|
|
|
|
|
2009-05-13 21:21:48 +00:00
|
|
|
static gboolean
|
|
|
|
clutter_backend_glx_create_context (ClutterBackend *backend,
|
|
|
|
GError **error)
|
|
|
|
{
|
2010-01-14 14:03:23 +00:00
|
|
|
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
|
2010-11-05 12:28:33 +00:00
|
|
|
CoglSwapChain *swap_chain = NULL;
|
|
|
|
CoglOnscreenTemplate *onscreen_template = NULL;
|
2009-12-03 20:49:54 +00:00
|
|
|
|
2010-11-05 12:28:33 +00:00
|
|
|
if (backend->cogl_context)
|
|
|
|
return TRUE;
|
2009-12-03 20:49:54 +00:00
|
|
|
|
2010-11-05 12:28:33 +00: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 21:21:48 +00:00
|
|
|
|
2010-11-05 12:28:33 +00:00
|
|
|
swap_chain = cogl_swap_chain_new ();
|
|
|
|
cogl_swap_chain_set_has_alpha (swap_chain,
|
|
|
|
clutter_x11_get_use_argb_visual ());
|
2009-12-01 16:18:39 +00:00
|
|
|
|
2010-11-05 12:28:33 +00:00
|
|
|
onscreen_template = cogl_onscreen_template_new (swap_chain);
|
|
|
|
cogl_object_unref (swap_chain);
|
2010-01-14 14:03:23 +00:00
|
|
|
|
2010-11-05 12:28:33 +00:00
|
|
|
if (!cogl_renderer_check_onscreen_template (backend->cogl_renderer,
|
|
|
|
onscreen_template,
|
|
|
|
error))
|
|
|
|
goto error;
|
2010-01-14 14:03:23 +00:00
|
|
|
|
2010-11-05 12:28:33 +00: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 18:56:14 +00:00
|
|
|
|
2010-11-05 12:28:33 +00:00
|
|
|
if (!cogl_display_setup (backend->cogl_display, error))
|
|
|
|
goto error;
|
2009-05-13 21:21:48 +00:00
|
|
|
|
2010-11-05 12:28:33 +00:00
|
|
|
backend->cogl_context = cogl_context_new (backend->cogl_display, error);
|
|
|
|
if (!backend->cogl_context)
|
|
|
|
goto error;
|
2010-02-04 13:56:33 +00:00
|
|
|
|
2010-11-05 12:28:33 +00: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 21:21:48 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
2010-11-05 12:28:33 +00:00
|
|
|
error:
|
|
|
|
if (backend->cogl_display)
|
2008-04-01 14:04:46 +00:00
|
|
|
{
|
2010-11-05 12:28:33 +00:00
|
|
|
cogl_object_unref (backend->cogl_display);
|
|
|
|
backend->cogl_display = NULL;
|
|
|
|
}
|
2008-04-04 15:02:11 +00:00
|
|
|
|
2010-11-05 12:28:33 +00:00
|
|
|
if (onscreen_template)
|
|
|
|
cogl_object_unref (onscreen_template);
|
|
|
|
if (swap_chain)
|
|
|
|
cogl_object_unref (swap_chain);
|
2008-03-28 22:50:55 +00:00
|
|
|
|
2010-11-05 12:28:33 +00:00
|
|
|
if (backend->cogl_renderer)
|
2008-04-01 14:04:46 +00:00
|
|
|
{
|
2010-11-05 12:28:33 +00:00
|
|
|
cogl_object_unref (backend->cogl_renderer);
|
|
|
|
backend->cogl_renderer = NULL;
|
2008-04-01 14:04:46 +00:00
|
|
|
}
|
2010-11-05 12:28:33 +00:00
|
|
|
return FALSE;
|
2008-03-28 22:50:55 +00:00
|
|
|
}
|
|
|
|
|
2009-08-13 11:34:07 +00:00
|
|
|
static ClutterStageWindow *
|
2008-03-28 22:50:55 +00:00
|
|
|
clutter_backend_glx_create_stage (ClutterBackend *backend,
|
2008-04-04 15:02:11 +00:00
|
|
|
ClutterStage *wrapper,
|
2008-03-28 22:50:55 +00:00
|
|
|
GError **error)
|
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
|
|
|
ClutterEventTranslator *translator;
|
2009-08-13 11:34:07 +00:00
|
|
|
ClutterStageWindow *stage_window;
|
|
|
|
ClutterStageX11 *stage_x11;
|
2007-11-15 14:45:27 +00:00
|
|
|
|
2009-08-13 11:34:07 +00:00
|
|
|
stage_window = g_object_new (CLUTTER_TYPE_STAGE_GLX, NULL);
|
2007-11-15 14:45:27 +00:00
|
|
|
|
2008-03-28 22:50:55 +00:00
|
|
|
/* copy backend data into the stage */
|
2009-08-13 11:34:07 +00:00
|
|
|
stage_x11 = CLUTTER_STAGE_X11 (stage_window);
|
2008-04-04 15:02:11 +00:00
|
|
|
stage_x11->wrapper = wrapper;
|
2011-01-26 11:58:08 +00:00
|
|
|
stage_x11->backend = backend_x11;
|
2008-04-04 15:02:11 +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
|
|
|
translator = CLUTTER_EVENT_TRANSLATOR (stage_x11);
|
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
|
|
|
|
2009-05-08 16:17:48 +00:00
|
|
|
CLUTTER_NOTE (BACKEND,
|
|
|
|
"GLX stage created[%p] (dpy:%p, screen:%d, root:%u, wrap:%p)",
|
2009-08-13 11:34:07 +00:00
|
|
|
stage_window,
|
2009-08-03 13:50:10 +00:00
|
|
|
backend_x11->xdpy,
|
|
|
|
backend_x11->xscreen_num,
|
|
|
|
(unsigned int) backend_x11->xwin_root,
|
2009-05-08 16:17:48 +00:00
|
|
|
wrapper);
|
2007-11-15 14:45:27 +00:00
|
|
|
|
2009-08-13 11:34:07 +00:00
|
|
|
return stage_window;
|
2007-05-28 18:49:34 +00:00
|
|
|
}
|
|
|
|
|
2010-11-05 12:28:33 +00:00
|
|
|
static void
|
|
|
|
clutter_backend_glx_ensure_context (ClutterBackend *backend,
|
|
|
|
ClutterStage *stage)
|
|
|
|
{
|
2011-06-14 14:50:21 +00:00
|
|
|
ClutterStageGLX *stage_glx;
|
|
|
|
|
|
|
|
/* ignore ensuring the context on an empty stage */
|
|
|
|
if (stage == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
stage_glx =
|
2010-11-05 12:28:33 +00:00
|
|
|
CLUTTER_STAGE_GLX (_clutter_stage_get_window (stage));
|
|
|
|
|
|
|
|
cogl_set_framebuffer (COGL_FRAMEBUFFER (stage_glx->onscreen));
|
|
|
|
}
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
static void
|
2011-01-21 10:49:12 +00:00
|
|
|
clutter_backend_glx_class_init (ClutterBackendGLXClass *klass)
|
2007-03-22 18:21:59 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
ClutterBackendClass *backend_class = CLUTTER_BACKEND_CLASS (klass);
|
2009-05-13 20:49:45 +00:00
|
|
|
ClutterBackendX11Class *backendx11_class = CLUTTER_BACKEND_X11_CLASS (klass);
|
2007-03-22 18:21:59 +00:00
|
|
|
|
|
|
|
gobject_class->constructor = clutter_backend_glx_constructor;
|
2008-03-28 22:50:55 +00:00
|
|
|
gobject_class->dispose = clutter_backend_glx_dispose;
|
|
|
|
gobject_class->finalize = clutter_backend_glx_finalize;
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2008-04-04 15:02:11 +00: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 21:21:48 +00:00
|
|
|
backend_class->create_context = clutter_backend_glx_create_context;
|
2008-03-28 22:50:55 +00:00
|
|
|
backend_class->ensure_context = clutter_backend_glx_ensure_context;
|
2009-05-13 20:49:45 +00:00
|
|
|
|
|
|
|
backendx11_class->get_visual_info = clutter_backend_glx_get_visual_info;
|
2007-03-22 18:21:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-01-21 10:49:12 +00:00
|
|
|
clutter_backend_glx_init (ClutterBackendGLX *backend_glx)
|
2007-03-22 18:21:59 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* every backend must implement this function */
|
|
|
|
GType
|
|
|
|
_clutter_backend_impl_get_type (void)
|
|
|
|
{
|
2010-08-13 14:48:30 +00:00
|
|
|
return _clutter_backend_glx_get_type ();
|
2007-03-22 18:21:59 +00:00
|
|
|
}
|