mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
Remove the SDL backend
The SDL API is far too limited for the windowing system needs of Clutter; the status of the SDL backend was always experimental, and since the Windows platform is supported by a native backend there is no point in having the SDL backend around any more.
This commit is contained in:
parent
ae188d203c
commit
d8d728a8d7
8
README
8
README
@ -135,7 +135,7 @@ Clutter has additional command line options for the configure script:
|
||||
--enable-conform=[yes/no]
|
||||
Build the Clutter conformance test suite.
|
||||
|
||||
--with-flavour=[glx/eglx/eglnative/sdl/osx/win32/fruity]
|
||||
--with-flavour=[glx/eglx/eglnative/osx/win32/fruity]
|
||||
Select the Clutter backend: (default=glx)
|
||||
|
||||
glx:
|
||||
@ -150,10 +150,6 @@ Clutter has additional command line options for the configure script:
|
||||
a createNativeWindow() call. Also it optionally supports
|
||||
tslib for touchscreen events.
|
||||
|
||||
sdl:
|
||||
Basic SDL backend, using Open GL. Should provide portability
|
||||
to Windows and possibly other OS's. (DEPRECATED)
|
||||
|
||||
osx:
|
||||
OS X backend. (EXPERIMENTAL)
|
||||
|
||||
@ -168,7 +164,7 @@ Clutter has additional command line options for the configure script:
|
||||
|
||||
gdk-pixbuf:
|
||||
Depend on gdk-pixbuf-2.0 (default for the glx, eglx,
|
||||
eglnative, sdl, win32 flavours and recommended)
|
||||
eglnative, win32 flavours and recommended)
|
||||
|
||||
quartz:
|
||||
Depend on CoreGraphics (default for the osx flavour)
|
||||
|
@ -12,7 +12,7 @@ clutter_json_libadd = $(top_builddir)/clutter/json/libclutter-json.la
|
||||
clutter_json_gir = ClutterJson-@CLUTTER_API_VERSION@.gir
|
||||
endif
|
||||
|
||||
DIST_SUBDIRS = glx eglx eglnative cogl sdl json osx x11 win32 fruity
|
||||
DIST_SUBDIRS = glx eglx eglnative cogl json osx x11 win32 fruity
|
||||
|
||||
# common definitions
|
||||
CLEANFILES =
|
||||
|
@ -1,26 +0,0 @@
|
||||
libclutterincludedir = $(includedir)/clutter-@CLUTTER_API_VERSION@/clutter
|
||||
libclutterinclude_HEADERS = clutter-sdl.h
|
||||
|
||||
INCLUDES = \
|
||||
-DG_LOG_DOMAIN=\"ClutterSDL\" \
|
||||
-DCLUTTER_COMPILATION \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/clutter/ \
|
||||
-I$(top_srcdir)/clutter/cogl \
|
||||
-I$(top_builddir)/clutter/ \
|
||||
-I$(top_builddir)/clutter/cogl \
|
||||
$(CLUTTER_CFLAGS) \
|
||||
$(CLUTTER_DEBUG_CFLAGS) \
|
||||
$(MAINTAINER_CFLAGS)
|
||||
|
||||
LDADD = $(CLUTTER_LIBS)
|
||||
|
||||
noinst_LTLIBRARIES = libclutter-sdl.la
|
||||
|
||||
libclutter_sdl_la_SOURCES = \
|
||||
clutter-backend-sdl.h \
|
||||
clutter-backend-sdl.c \
|
||||
clutter-event-sdl.c \
|
||||
clutter-stage-sdl.h \
|
||||
clutter-stage-sdl.c \
|
||||
clutter-sdl.h
|
@ -1,207 +0,0 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "clutter-backend-sdl.h"
|
||||
#include "clutter-stage-sdl.h"
|
||||
#include "../clutter-private.h"
|
||||
#include "../clutter-main.h"
|
||||
#include "../clutter-debug.h"
|
||||
|
||||
static ClutterBackendSDL *backend_singleton = NULL;
|
||||
|
||||
|
||||
G_DEFINE_TYPE (ClutterBackendSDL, clutter_backend_sdl, CLUTTER_TYPE_BACKEND);
|
||||
|
||||
static gboolean
|
||||
clutter_backend_sdl_pre_parse (ClutterBackend *backend,
|
||||
GError **error)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
clutter_backend_sdl_post_parse (ClutterBackend *backend,
|
||||
GError **error)
|
||||
{
|
||||
int err;
|
||||
|
||||
if (SDL_Init (SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0)
|
||||
{
|
||||
g_set_error (error, CLUTTER_INIT_ERROR,
|
||||
CLUTTER_INIT_ERROR_BACKEND,
|
||||
"Unable to Initialize SDL");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if defined(WIN32)
|
||||
err = SDL_GL_LoadLibrary ("opengl32.dll");
|
||||
#elif defined(__linux__) || defined(__FreeBSD__)
|
||||
err = SDL_GL_LoadLibrary ("libGL.so");
|
||||
#else
|
||||
#error Your platform is not supported
|
||||
err = 1;
|
||||
#endif
|
||||
|
||||
if (err != 0)
|
||||
{
|
||||
g_set_error (error, CLUTTER_INIT_ERROR,
|
||||
CLUTTER_INIT_ERROR_BACKEND,
|
||||
"%s", SDL_GetError ());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
CLUTTER_NOTE (BACKEND, "SDL successfully initialized");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_backend_sdl_ensure_context (ClutterBackend *backend,
|
||||
ClutterStage *stage)
|
||||
{
|
||||
/* no context to ensure */
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_backend_sdl_redraw (ClutterBackend *backend,
|
||||
ClutterStage *stage)
|
||||
{
|
||||
clutter_actor_paint (CLUTTER_ACTOR (stage));
|
||||
cogl_flush ();
|
||||
|
||||
SDL_GL_SwapBuffers();
|
||||
}
|
||||
|
||||
static ClutterStageWindow *
|
||||
clutter_backend_sdl_create_stage (ClutterBackend *backend,
|
||||
ClutterStage *wrapper,
|
||||
GError **error)
|
||||
{
|
||||
ClutterBackendSDL *backend_sdl = CLUTTER_BACKEND_SDL (backend);
|
||||
ClutterStageSDL *stage_sdl;
|
||||
ClutterStageWindow *stage;
|
||||
|
||||
if (backend_sdl->stage)
|
||||
{
|
||||
g_warning ("The SDL backend does not support multiple stages");
|
||||
return CLUTTER_STAGE_WINDOW (backend_sdl->stage);
|
||||
}
|
||||
|
||||
stage = g_object_new (CLUTTER_TYPE_STAGE_SDL, NULL);
|
||||
|
||||
/* copy backend data into the stage */
|
||||
stage_sdl = CLUTTER_STAGE_SDL (stage);
|
||||
stage_sdl->wrapper = wrapper;
|
||||
|
||||
backend_sdl->stage = stage_sdl;
|
||||
|
||||
return stage;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_backend_sdl_init_events (ClutterBackend *backend)
|
||||
{
|
||||
_clutter_events_init (backend);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_backend_sdl_finalize (GObject *gobject)
|
||||
{
|
||||
SDL_Quit();
|
||||
|
||||
if (backend_singleton)
|
||||
backend_singleton = NULL;
|
||||
|
||||
G_OBJECT_CLASS (clutter_backend_sdl_parent_class)->finalize (gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_backend_sdl_dispose (GObject *gobject)
|
||||
{
|
||||
ClutterBackendSDL *backend_sdl = CLUTTER_BACKEND_SDL (gobject);
|
||||
|
||||
_clutter_events_uninit (CLUTTER_BACKEND (backend_sdl));
|
||||
|
||||
if (backend_sdl->stage)
|
||||
{
|
||||
g_object_unref (backend_sdl->stage);
|
||||
backend_sdl->stage = NULL;
|
||||
}
|
||||
|
||||
if (backend_sdl->timer)
|
||||
{
|
||||
g_timer_destroy (backend_sdl->timer);
|
||||
backend_sdl->timer = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (clutter_backend_sdl_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
static GObject *
|
||||
clutter_backend_sdl_constructor (GType gtype,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params)
|
||||
{
|
||||
GObjectClass *parent_class;
|
||||
GObject *retval;
|
||||
|
||||
if (!backend_singleton)
|
||||
{
|
||||
parent_class = G_OBJECT_CLASS (clutter_backend_sdl_parent_class);
|
||||
retval = parent_class->constructor (gtype, n_params, params);
|
||||
|
||||
backend_singleton = CLUTTER_BACKEND_SDL (retval);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
g_warning ("Attempting to create a new backend object. This should "
|
||||
"never happen, so we return the singleton instance.");
|
||||
|
||||
return g_object_ref (backend_singleton);
|
||||
}
|
||||
|
||||
static ClutterFeatureFlags
|
||||
clutter_backend_sdl_get_features (ClutterBackend *backend)
|
||||
{
|
||||
return CLUTTER_FEATURE_STAGE_CURSOR;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_backend_sdl_class_init (ClutterBackendSDLClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
ClutterBackendClass *backend_class = CLUTTER_BACKEND_CLASS (klass);
|
||||
|
||||
gobject_class->constructor = clutter_backend_sdl_constructor;
|
||||
gobject_class->dispose = clutter_backend_sdl_dispose;
|
||||
gobject_class->finalize = clutter_backend_sdl_finalize;
|
||||
|
||||
backend_class->pre_parse = clutter_backend_sdl_pre_parse;
|
||||
backend_class->post_parse = clutter_backend_sdl_post_parse;
|
||||
backend_class->init_events = clutter_backend_sdl_init_events;
|
||||
backend_class->create_stage = clutter_backend_sdl_create_stage;
|
||||
backend_class->ensure_context = clutter_backend_sdl_ensure_context;
|
||||
backend_class->redraw = clutter_backend_sdl_redraw;
|
||||
backend_class->get_features = clutter_backend_sdl_get_features;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_backend_sdl_init (ClutterBackendSDL *backend_sdl)
|
||||
{
|
||||
ClutterBackend *backend = CLUTTER_BACKEND (backend_sdl);
|
||||
|
||||
clutter_backend_set_resolution (backend, 96.0);
|
||||
clutter_backend_set_double_click_time (backend, 250);
|
||||
clutter_backend_set_double_click_distance (backend, 5);
|
||||
|
||||
backend_sdl->timer = g_timer_new ();
|
||||
}
|
||||
|
||||
GType
|
||||
_clutter_backend_impl_get_type (void)
|
||||
{
|
||||
return clutter_backend_sdl_get_type ();
|
||||
}
|
||||
|
@ -1,70 +0,0 @@
|
||||
/* 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
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __CLUTTER_BACKEND_SDL_H__
|
||||
#define __CLUTTER_BACKEND_SDL_H__
|
||||
|
||||
#include <SDL.h>
|
||||
#include <glib-object.h>
|
||||
#include <clutter/clutter-backend.h>
|
||||
#include "clutter-stage-sdl.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CLUTTER_TYPE_BACKEND_SDL (clutter_backend_sdl_get_type ())
|
||||
#define CLUTTER_BACKEND_SDL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BACKEND_SDL, ClutterBackendSDL))
|
||||
#define CLUTTER_IS_BACKEND_SDL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_BACKEND_SDL))
|
||||
#define CLUTTER_BACKEND_SDL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_BACKEND_SDL, ClutterBackendSDLClass))
|
||||
#define CLUTTER_IS_BACKEND_SDL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_BACKEND_SDL))
|
||||
#define CLUTTER_BACKEND_SDL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_BACKEND_SDL, ClutterBackendSDLClass))
|
||||
|
||||
typedef struct _ClutterBackendSDL ClutterBackendSDL;
|
||||
typedef struct _ClutterBackendSDLClass ClutterBackendSDLClass;
|
||||
|
||||
struct _ClutterBackendSDL
|
||||
{
|
||||
ClutterBackend parent_instance;
|
||||
|
||||
/* main stage singleton */
|
||||
ClutterStageSDL *stage;
|
||||
|
||||
/* event source */
|
||||
GSource *event_source;
|
||||
|
||||
/* our own timer for events */
|
||||
GTimer *timer;
|
||||
|
||||
/*< private >*/
|
||||
};
|
||||
|
||||
struct _ClutterBackendSDLClass
|
||||
{
|
||||
ClutterBackendClass parent_class;
|
||||
};
|
||||
|
||||
GType clutter_backend_sdl_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void _clutter_events_init (ClutterBackend *backend);
|
||||
void _clutter_events_uninit (ClutterBackend *backend);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __CLUTTER_BACKEND_SDL_H__ */
|
@ -1,377 +0,0 @@
|
||||
/* 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
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "clutter-stage-sdl.h"
|
||||
#include "clutter-backend-sdl.h"
|
||||
#include "clutter-sdl.h"
|
||||
|
||||
#include "../clutter-backend.h"
|
||||
#include "../clutter-event.h"
|
||||
#include "../clutter-private.h"
|
||||
#include "../clutter-debug.h"
|
||||
#include "../clutter-main.h"
|
||||
#include "../clutter-keysyms.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
|
||||
typedef struct _ClutterEventSource ClutterEventSource;
|
||||
|
||||
struct _ClutterEventSource
|
||||
{
|
||||
GSource source;
|
||||
|
||||
ClutterBackend *backend;
|
||||
};
|
||||
|
||||
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 guint32
|
||||
get_backend_time (void)
|
||||
{
|
||||
ClutterBackendSDL *backend_sdl;
|
||||
gdouble elapsed;
|
||||
|
||||
backend_sdl = CLUTTER_BACKEND_SDL (clutter_get_default_backend ());
|
||||
|
||||
elapsed = g_timer_elapsed (backend_sdl->timer, NULL);
|
||||
|
||||
return (elapsed * 1000.0);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void
|
||||
_clutter_events_init (ClutterBackend *backend)
|
||||
{
|
||||
GSource *source;
|
||||
ClutterEventSource *event_source;
|
||||
ClutterBackendSDL *backend_sdl = CLUTTER_BACKEND_SDL (backend);
|
||||
|
||||
CLUTTER_NOTE (EVENT, "Starting timer");
|
||||
g_assert (backend_sdl->timer != NULL);
|
||||
g_timer_start (backend_sdl->timer);
|
||||
|
||||
CLUTTER_NOTE (EVENT, "Creating event source");
|
||||
source = backend_sdl->event_source = clutter_event_source_new (backend);
|
||||
event_source = (ClutterEventSource *) source;
|
||||
g_source_set_priority (source, CLUTTER_PRIORITY_EVENTS);
|
||||
|
||||
event_sources = g_list_prepend (event_sources, event_source);
|
||||
|
||||
g_source_set_can_recurse (source, TRUE);
|
||||
g_source_attach (source, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
_clutter_events_uninit (ClutterBackend *backend)
|
||||
{
|
||||
ClutterBackendSDL *backend_sdl = CLUTTER_BACKEND_SDL (backend);
|
||||
|
||||
if (backend_sdl->event_source)
|
||||
{
|
||||
CLUTTER_NOTE (EVENT, "Stopping the timer");
|
||||
g_timer_stop (backend_sdl->timer);
|
||||
|
||||
CLUTTER_NOTE (EVENT, "Destroying the event source");
|
||||
event_sources = g_list_remove (event_sources,
|
||||
backend_sdl->event_source);
|
||||
|
||||
g_source_destroy (backend_sdl->event_source);
|
||||
g_source_unref (backend_sdl->event_source);
|
||||
backend_sdl->event_source = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
clutter_event_prepare (GSource *source,
|
||||
gint *timeout)
|
||||
{
|
||||
SDL_Event events;
|
||||
int num_events;
|
||||
gboolean retval;
|
||||
|
||||
clutter_threads_enter ();
|
||||
|
||||
num_events = SDL_PeepEvents(&events, 1, SDL_PEEKEVENT, SDL_ALLEVENTS);
|
||||
|
||||
if (num_events == 1)
|
||||
{
|
||||
clutter_threads_leave ();
|
||||
|
||||
*timeout = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (num_events == -1)
|
||||
g_warning("Error polling SDL: %s", SDL_GetError());
|
||||
|
||||
*timeout = 50;
|
||||
|
||||
retval = clutter_events_pending ();
|
||||
|
||||
clutter_threads_leave ();
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
clutter_event_check (GSource *source)
|
||||
{
|
||||
SDL_Event events;
|
||||
int num_events;
|
||||
gboolean retval;
|
||||
|
||||
clutter_threads_enter ();
|
||||
|
||||
/* Pump SDL */
|
||||
SDL_PumpEvents();
|
||||
|
||||
num_events = SDL_PeepEvents(&events, 1, SDL_PEEKEVENT, SDL_ALLEVENTS);
|
||||
|
||||
if (num_events == -1)
|
||||
g_warning("Error polling SDL: %s", SDL_GetError());
|
||||
|
||||
retval = (num_events == 1 || clutter_events_pending ());
|
||||
|
||||
clutter_threads_leave ();
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void
|
||||
key_event_translate (ClutterEvent *event,
|
||||
SDL_Event *sdl_event)
|
||||
{
|
||||
event->key.time = get_backend_time ();
|
||||
|
||||
/* FIXME: This is just a quick hack to make SDL keys roughly work.
|
||||
* Fixing it properly is left as a exercise to someone who enjoys
|
||||
* battleing the SDL API.
|
||||
*
|
||||
* We probably need to use sdl_event->key.keysym.unicode to do lookups
|
||||
* and I have no idea how to get shifted keysyms. It looks quite easy
|
||||
* if you drop into xlib but that then avoids the whole point of using
|
||||
* SDL in the first place (More portability than just GLX)
|
||||
*/
|
||||
|
||||
switch (sdl_event->key.keysym.sym)
|
||||
{
|
||||
case SDLK_UP: event->key.keyval = CLUTTER_Up; break;
|
||||
case SDLK_DOWN: event->key.keyval = CLUTTER_Down; break;
|
||||
case SDLK_LEFT: event->key.keyval = CLUTTER_Left; break;
|
||||
case SDLK_RIGHT: event->key.keyval = CLUTTER_Right; break;
|
||||
case SDLK_HOME: event->key.keyval = CLUTTER_Home; break;
|
||||
case SDLK_END: event->key.keyval = CLUTTER_End; break;
|
||||
case SDLK_PAGEUP: event->key.keyval = CLUTTER_Page_Up; break;
|
||||
case SDLK_PAGEDOWN: event->key.keyval = CLUTTER_Page_Down; break;
|
||||
case SDLK_BACKSPACE: event->key.keyval = CLUTTER_BackSpace; break;
|
||||
case SDLK_DELETE: event->key.keyval = CLUTTER_Delete; break;
|
||||
default:
|
||||
event->key.keyval = sdl_event->key.keysym.sym;
|
||||
}
|
||||
|
||||
event->key.hardware_keycode = sdl_event->key.keysym.scancode;
|
||||
|
||||
if (sdl_event->key.keysym.mod & KMOD_CTRL)
|
||||
event->key.modifier_state
|
||||
= event->key.modifier_state & CLUTTER_CONTROL_MASK;
|
||||
|
||||
if (sdl_event->key.keysym.mod & KMOD_SHIFT)
|
||||
event->key.modifier_state
|
||||
= event->key.modifier_state & CLUTTER_SHIFT_MASK;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
event_translate (ClutterBackend *backend,
|
||||
ClutterEvent *event,
|
||||
SDL_Event *sdl_event)
|
||||
{
|
||||
ClutterBackendSDL *backend_sdl;
|
||||
gboolean res;
|
||||
|
||||
backend_sdl = CLUTTER_BACKEND_SDL (clutter_get_default_backend ());
|
||||
|
||||
res = TRUE;
|
||||
|
||||
switch (sdl_event->type)
|
||||
{
|
||||
case SDL_KEYDOWN:
|
||||
event->type = CLUTTER_KEY_PRESS;
|
||||
key_event_translate (event, sdl_event);
|
||||
break;
|
||||
|
||||
case SDL_KEYUP:
|
||||
event->type = CLUTTER_KEY_RELEASE;
|
||||
key_event_translate (event, sdl_event);
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
switch (sdl_event->button.button)
|
||||
{
|
||||
case 4: /* up */
|
||||
case 5: /* down */
|
||||
case 6: /* left */
|
||||
case 7: /* right */
|
||||
event->scroll.type = event->type = CLUTTER_SCROLL;
|
||||
|
||||
if (sdl_event->button.button == 4)
|
||||
event->scroll.direction = CLUTTER_SCROLL_UP;
|
||||
else if (sdl_event->button.button == 5)
|
||||
event->scroll.direction = CLUTTER_SCROLL_DOWN;
|
||||
else if (sdl_event->button.button == 6)
|
||||
event->scroll.direction = CLUTTER_SCROLL_LEFT;
|
||||
else
|
||||
event->scroll.direction = CLUTTER_SCROLL_RIGHT;
|
||||
|
||||
event->scroll.time = get_backend_time ();
|
||||
event->scroll.x = sdl_event->button.x;
|
||||
event->scroll.y = sdl_event->button.y;
|
||||
event->scroll.modifier_state = sdl_event->button.state;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
event->button.type = event->type = CLUTTER_BUTTON_PRESS;
|
||||
event->button.time = get_backend_time ();
|
||||
event->button.x = sdl_event->button.x;
|
||||
event->button.y = sdl_event->button.y;
|
||||
event->button.modifier_state = sdl_event->button.state;
|
||||
event->button.button = sdl_event->button.button;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
/* scroll events don't have a corresponding release */
|
||||
if (sdl_event->button.button == 4 ||
|
||||
sdl_event->button.button == 5 ||
|
||||
sdl_event->button.button == 6 ||
|
||||
sdl_event->button.button == 7)
|
||||
{
|
||||
res = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
event->button.type = event->type = CLUTTER_BUTTON_RELEASE;
|
||||
event->button.time = get_backend_time ();
|
||||
event->button.x = sdl_event->button.x;
|
||||
event->button.y = sdl_event->button.y;
|
||||
event->button.modifier_state = sdl_event->button.state;
|
||||
event->button.button = sdl_event->button.button;
|
||||
break;
|
||||
|
||||
case SDL_MOUSEMOTION:
|
||||
event->motion.type = event->type = CLUTTER_MOTION;
|
||||
event->motion.time = get_backend_time ();
|
||||
event->motion.x = sdl_event->motion.x;
|
||||
event->motion.y = sdl_event->motion.y;
|
||||
event->motion.modifier_state = sdl_event->motion.state;
|
||||
break;
|
||||
|
||||
default:
|
||||
res = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
clutter_event_dispatch (GSource *source,
|
||||
GSourceFunc callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
SDL_Event sdl_event;
|
||||
ClutterEvent *event = NULL;
|
||||
ClutterBackend *backend = ((ClutterEventSource *) source)->backend;
|
||||
ClutterMainContext *clutter_context;
|
||||
|
||||
clutter_threads_enter ();
|
||||
|
||||
clutter_context = _clutter_context_get_default ();
|
||||
|
||||
while (SDL_PollEvent(&sdl_event))
|
||||
{
|
||||
/* FIXME: essentially translate events and push them onto the queue
|
||||
* below will then pop them out via _clutter_events_queue.
|
||||
*/
|
||||
if (sdl_event.type == SDL_QUIT)
|
||||
{
|
||||
SDL_Quit();
|
||||
exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
event = clutter_event_new (CLUTTER_NOTHING);
|
||||
|
||||
event->any.stage = CLUTTER_STAGE (clutter_stage_get_default ());
|
||||
|
||||
if (event_translate (backend, event, &sdl_event))
|
||||
{
|
||||
/* push directly here to avoid copy of queue_put */
|
||||
g_queue_push_head (clutter_context->events_queue, event);
|
||||
}
|
||||
else
|
||||
clutter_event_free (event);
|
||||
}
|
||||
}
|
||||
|
||||
event = clutter_event_get ();
|
||||
|
||||
if (event)
|
||||
{
|
||||
clutter_do_event(event);
|
||||
clutter_event_free (event);
|
||||
}
|
||||
|
||||
clutter_threads_leave ();
|
||||
|
||||
return TRUE;
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Clutter.
|
||||
*
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2006 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
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __CLUTTER_SDL_H__
|
||||
#define __CLUTTER_SDL_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <SDL.h>
|
||||
|
||||
#include <clutter/clutter-stage.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __CLUTTER_SDL_H__ */
|
@ -1,197 +0,0 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "clutter-stage-sdl.h"
|
||||
#include "clutter-sdl.h"
|
||||
|
||||
#include "../clutter-main.h"
|
||||
#include "../clutter-feature.h"
|
||||
#include "../clutter-color.h"
|
||||
#include "../clutter-util.h"
|
||||
#include "../clutter-event.h"
|
||||
#include "../clutter-enum-types.h"
|
||||
#include "../clutter-private.h"
|
||||
#include "../clutter-debug.h"
|
||||
#include "../clutter-units.h"
|
||||
#include "../clutter-stage-window.h"
|
||||
|
||||
#include "cogl/cogl.h"
|
||||
|
||||
static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (ClutterStageSDL,
|
||||
clutter_stage_sdl,
|
||||
G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_STAGE_WINDOW,
|
||||
clutter_stage_window_iface_init));
|
||||
|
||||
static ClutterActor *
|
||||
clutter_stage_sdl_get_wrapper (ClutterStageWindow *stage_window)
|
||||
{
|
||||
return CLUTTER_ACTOR (CLUTTER_STAGE_SDL (stage_window)->wrapper);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_sdl_show (ClutterStageWindow *stage_window,
|
||||
gboolean do_raise G_GNUC_UNUSED)
|
||||
{
|
||||
clutter_actor_map (clutter_stage_sdl_get_wrapper (stage_window));
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_sdl_hide (ClutterStageWindow *stage_window)
|
||||
{
|
||||
clutter_actor_unmap (clutter_stage_sdl_get_wrapper (stage_window));
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_sdl_unrealize (ClutterStageWindow *stage_window)
|
||||
{
|
||||
}
|
||||
|
||||
static gboolean
|
||||
clutter_stage_sdl_realize (ClutterStageWindow *stage_window)
|
||||
{
|
||||
ClutterStageSDL *stage_sdl = CLUTTER_STAGE_SDL (stage_window);
|
||||
gboolean is_fullscreen = FALSE;
|
||||
gint flags = SDL_OPENGL;
|
||||
|
||||
CLUTTER_NOTE (BACKEND, "Realizing main stage");
|
||||
|
||||
g_object_get (stage_sdl->wrapper,
|
||||
"fullscreen-set", &is_fullscreen,
|
||||
NULL);
|
||||
|
||||
if (is_fullscreen)
|
||||
flags |= SDL_FULLSCREEN;
|
||||
|
||||
SDL_GL_SetAttribute (SDL_GL_ACCUM_RED_SIZE, 0);
|
||||
SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0);
|
||||
SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0);
|
||||
SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0);
|
||||
|
||||
if (SDL_SetVideoMode (stage_sdl->win_width,
|
||||
stage_sdl->win_height,
|
||||
0, flags) == NULL)
|
||||
{
|
||||
CLUTTER_NOTE (BACKEND, "SDL appears not to handle this mode - %s",
|
||||
SDL_GetError ());
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_sdl_get_geometry (ClutterStageWindow *stage_window,
|
||||
ClutterGeometry *geometry)
|
||||
{
|
||||
ClutterStageSDL *stage_sdl = CLUTTER_STAGE_SDL (stage_window);
|
||||
gboolean is_fullscreen = FALSE;
|
||||
|
||||
is_fullscreen = clutter_stage_get_fullscreen (stage_sdl->wrapper);
|
||||
|
||||
if (is_fullscreen)
|
||||
{
|
||||
const SDL_VideoInfo *v_info;
|
||||
|
||||
v_info = SDL_GetVideoInfo ();
|
||||
|
||||
geometry->width = v_info->current_w;
|
||||
geometry->height = v_info->current_h;
|
||||
}
|
||||
else
|
||||
{
|
||||
geometry->width = stage_sdl->win_width;
|
||||
geometry->height = stage_sdl->win_height;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_sdl_resize (ClutterStageWindow *stage_window,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
ClutterStageSDL *stage_sdl = CLUTTER_STAGE_SDL (stage_window);
|
||||
|
||||
if (width != stage_sdl->win_width ||
|
||||
height != stage_sdl->win_height)
|
||||
{
|
||||
if (SDL_SetVideoMode (width, height, 0, SDL_OPENGL) == NULL)
|
||||
{
|
||||
/* Failed */
|
||||
return;
|
||||
}
|
||||
|
||||
stage_sdl->win_width = width;
|
||||
stage_sdl->win_height = height;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_sdl_set_fullscreen (ClutterStageWindow *stage_window,
|
||||
gboolean fullscreen)
|
||||
{
|
||||
ClutterStageSDL *stage_sdl = CLUTTER_STAGE_SDL (stage_window);
|
||||
int flags = SDL_OPENGL;
|
||||
|
||||
if (fullscreen)
|
||||
flags |= SDL_FULLSCREEN;
|
||||
|
||||
SDL_SetVideoMode (stage_sdl->win_width,
|
||||
stage_sdl->win_height,
|
||||
0, flags);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_sdl_set_cursor_visible (ClutterStageWindow *stage_window,
|
||||
gboolean show_cursor)
|
||||
{
|
||||
SDL_ShowCursor (show_cursor);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_sdl_set_title (ClutterStageWindow *stage_window,
|
||||
const gchar *title)
|
||||
{
|
||||
SDL_WM_SetCaption (title, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_sdl_dispose (GObject *gobject)
|
||||
{
|
||||
G_OBJECT_CLASS (clutter_stage_sdl_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_sdl_class_init (ClutterStageSDLClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
gobject_class->dispose = clutter_stage_sdl_dispose;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
|
||||
{
|
||||
iface->set_fullscreen = clutter_stage_sdl_set_fullscreen;
|
||||
iface->set_cursor_visible = clutter_stage_sdl_set_cursor_visible;
|
||||
iface->set_title = clutter_stage_sdl_set_title;
|
||||
iface->show = clutter_stage_sdl_show;
|
||||
iface->hide = clutter_stage_sdl_hide;
|
||||
iface->realize = clutter_stage_sdl_realize;
|
||||
iface->unrealize = clutter_stage_sdl_unrealize;
|
||||
iface->resize = clutter_stage_sdl_resize;
|
||||
iface->get_geometry = clutter_stage_sdl_get_geometry;
|
||||
iface->get_wrapper = clutter_stage_sdl_get_wrapper;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_sdl_init (ClutterStageSDL *stage)
|
||||
{
|
||||
stage->win_width = 640;
|
||||
stage->win_height = 480;
|
||||
}
|
||||
|
@ -1,34 +0,0 @@
|
||||
#ifndef __CLUTTER_STAGE_SDL_H__
|
||||
#define __CLUTTER_STAGE_SDL_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <clutter/clutter-stage.h>
|
||||
|
||||
#define CLUTTER_TYPE_STAGE_SDL (clutter_stage_sdl_get_type ())
|
||||
#define CLUTTER_STAGE_SDL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_STAGE_SDL, ClutterStageSDL))
|
||||
#define CLUTTER_IS_STAGE_SDL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_STAGE_SDL))
|
||||
#define CLUTTER_STAGE_SDL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_STAGE_SDL, ClutterStageSDLClass))
|
||||
#define CLUTTER_IS_STAGE_SDL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_STAGE_SDL))
|
||||
#define CLUTTER_STAGE_SDL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_STAGE_SDL, ClutterStageSDLClass))
|
||||
|
||||
typedef struct _ClutterStageSDL ClutterStageSDL;
|
||||
typedef struct _ClutterStageSDLClass ClutterStageSDLClass;
|
||||
|
||||
struct _ClutterStageSDL
|
||||
{
|
||||
ClutterActor parent_instance;
|
||||
|
||||
gint win_width;
|
||||
gint win_height;
|
||||
|
||||
ClutterStage *wrapper;
|
||||
};
|
||||
|
||||
struct _ClutterStageSDLClass
|
||||
{
|
||||
ClutterActorClass parent_class;
|
||||
};
|
||||
|
||||
GType clutter_stage_sdl_get_type (void) G_GNUC_CONST;
|
||||
|
||||
#endif /* __CLUTTER_STAGE_SDL_H__ */
|
41
configure.ac
41
configure.ac
@ -123,7 +123,7 @@ experimental_backend=no
|
||||
experimental_image=no
|
||||
|
||||
AC_ARG_WITH([flavour],
|
||||
[AC_HELP_STRING([--with-flavour=@<:@glx/eglx/eglnative/sdl/osx/win32/fruity@:>@],
|
||||
[AC_HELP_STRING([--with-flavour=@<:@glx/eglx/eglnative/osx/win32/fruity@:>@],
|
||||
[Select the Clutter window system backend])],
|
||||
[CLUTTER_WINSYS=$with_flavour])
|
||||
|
||||
@ -234,42 +234,6 @@ dnl === Clutter windowing system backend ======================================
|
||||
|
||||
AS_CASE([$CLUTTER_WINSYS],
|
||||
|
||||
[sdl],
|
||||
[
|
||||
experimental_backend="yes"
|
||||
clutter_gl_header="GL/gl.h"
|
||||
CLUTTER_STAGE_TYPE="CLUTTER_TYPE_STAGE_SDL"
|
||||
AC_DEFINE([HAVE_CLUTTER_SDL], [1], [Have the SDL backend])
|
||||
|
||||
COGL_DRIVER="gl"
|
||||
AC_DEFINE([HAVE_COGL_GL], [1], [Have GL for rendering])
|
||||
|
||||
AC_PATH_PROG(SDL_CONFIG, [sdl-config])
|
||||
AS_IF([test "x$SDL_CONFIG" = "x"],
|
||||
[AC_MSG_ERROR([No sdl-config binary found in path])],
|
||||
[
|
||||
SDL_CFLAGS=`$SDL_CONFIG --cflags`
|
||||
SDL_LIBS=`$SDL_CONFIG --libs`
|
||||
|
||||
AS_CASE([$host],
|
||||
|
||||
[*mingw32*],
|
||||
[
|
||||
# Use -lopengl32 under Windows instead of -lGL
|
||||
SDL_LIBS="$SDL_LIBS -lopengl32"
|
||||
CLUTTER_LT_LDFLAGS="$CLUTTER_LT_LDFLAGS -no-undefined"
|
||||
],
|
||||
|
||||
[
|
||||
AC_CHECK_LIB(GL, [glEnable], [HAVE_LIBGL=yes], [HAVE_LIBGL=no])
|
||||
AS_IF([test "x$HAVE_LIBGL" = "xno"], [AC_MSG_ERROR([libGL not found])])
|
||||
SDL_LIBS="$SDL_LIBS -lGL"
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
],
|
||||
|
||||
[glx],
|
||||
[
|
||||
clutter_gl_header="GL/gl.h"
|
||||
@ -371,7 +335,7 @@ AS_CASE([$CLUTTER_WINSYS],
|
||||
fi
|
||||
],
|
||||
|
||||
[AC_MSG_ERROR([Invalid backend for Clutter: use glx, sdl, osx, win32, eglx, eglnative or fruity])]
|
||||
[AC_MSG_ERROR([Invalid backend for Clutter: use glx, osx, win32, eglx, eglnative or fruity])]
|
||||
)
|
||||
|
||||
AM_CONDITIONAL(WINSYS_WIN32, [test "x$CLUTTER_WINSYS" = "xwin32"])
|
||||
@ -915,7 +879,6 @@ AC_CONFIG_FILES([
|
||||
clutter/osx/Makefile
|
||||
clutter/win32/Makefile
|
||||
clutter/win32/clutter-win32.pc
|
||||
clutter/sdl/Makefile
|
||||
clutter/cogl/Makefile
|
||||
clutter/cogl/cogl/Makefile
|
||||
clutter/cogl/cogl/driver/gl/cogl-defines.h
|
||||
|
Loading…
Reference in New Issue
Block a user