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
|
|
|
|
* 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-backend-glx.h"
|
|
|
|
#include "clutter-stage-glx.h"
|
|
|
|
#include "clutter-glx.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"
|
2007-05-22 09:31:40 +00:00
|
|
|
#include "../clutter-units.h"
|
2007-12-03 16:29:18 +00:00
|
|
|
#include "../clutter-shader.h"
|
2008-01-21 11:39:23 +00:00
|
|
|
#include "../clutter-group.h"
|
|
|
|
#include "../clutter-container.h"
|
2008-03-28 22:50:55 +00:00
|
|
|
#include "../clutter-stage.h"
|
2008-04-04 15:02:11 +00:00
|
|
|
#include "../clutter-stage-window.h"
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
#include "cogl/cogl.h"
|
2007-04-27 21:13:06 +00:00
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
#include <GL/glx.h>
|
|
|
|
#include <GL/gl.h>
|
|
|
|
|
2008-04-04 15:02:11 +00:00
|
|
|
static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (ClutterStageGLX,
|
|
|
|
clutter_stage_glx,
|
|
|
|
CLUTTER_TYPE_STAGE_X11,
|
|
|
|
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_STAGE_WINDOW,
|
|
|
|
clutter_stage_window_iface_init));
|
2007-03-22 18:21:59 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_glx_unrealize (ClutterActor *actor)
|
|
|
|
{
|
2007-11-15 14:45:27 +00:00
|
|
|
ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (actor);
|
2007-05-31 11:13:43 +00:00
|
|
|
ClutterStageGLX *stage_glx = CLUTTER_STAGE_GLX (actor);
|
2007-03-22 18:21:59 +00:00
|
|
|
gboolean was_offscreen;
|
|
|
|
|
2008-04-04 15:02:11 +00:00
|
|
|
/* Note unrealize should free up any backend stage related resources */
|
2008-04-04 17:26:26 +00:00
|
|
|
CLUTTER_NOTE (BACKEND, "Unrealizing stage");
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2008-04-04 15:02:11 +00:00
|
|
|
g_object_get (stage_x11->wrapper, "offscreen", &was_offscreen, NULL);
|
2007-03-22 18:21:59 +00:00
|
|
|
|
Enforce invariants on mapped, realized, visibility states
Bug 1138 - No trackable "mapped" state
* Add a VISIBLE flag tracking application programmer's
expected showing-state for the actor, allowing us to
always ensure we keep what the app wants while tracking
internal implementation state separately.
* Make MAPPED reflect whether the actor will be painted;
add notification on a ClutterActor::mapped property.
Keep MAPPED state updated as the actor is shown,
ancestors are shown, actor is reparented, etc.
* Require a stage and realized parents to realize; this means
at realization time the correct window system and GL resources
are known. But unparented actors can no longer be realized.
* Allow children to be unrealized even if parent is realized.
Otherwise in effect either all actors or no actors are realized,
i.e. it becomes a stage-global flag.
* Allow clutter_actor_realize() to "fail" if not inside a toplevel
* Rework clutter_actor_unrealize() so internally we have
a flavor that does not mess with visibility flag
* Add _clutter_actor_rerealize() to encapsulate a somewhat
tricky operation we were doing in a couple of places
* Do not realize/unrealize children in ClutterGroup,
ClutterActor already does it
* Do not realize impl by hand in clutter_stage_show(),
since showing impl already does that
* Do not unrealize in various dispose() methods, since
ClutterActor dispose implementation already does it
and chaining up is mandatory
* ClutterTexture uses COGL while unrealizable (before it's
added to a stage). Previously this breakage was affecting
ClutterActor because we had to allow realize outside
a stage. Move the breakage to ClutterTexture, by making
ClutterTexture just use COGL while not realized.
* Unrealize before we set parent to NULL in clutter_actor_unparent().
This means unrealize() implementations can get to the stage.
Because actors need the stage in order to detach from stage.
* Update clutter-actor-invariants.txt to reflect latest changes
* Remove explicit hide/unrealize from ClutterActor::dispose since
unparent already forces those
Instead just assert that unparent() occurred and did the right thing.
* Check whether parent implements unrealize before chaining up
Needed because ClutterGroup no longer has to implement unrealize.
* Perform unrealize in the default handler for the signal.
This allows non-containers that have children to work properly,
and allows containers to override how it's done.
* Add map/unmap virtual methods and set MAPPED flag on self and
children in there. This allows subclasses to hook map/unmap.
These are not signals, because notify::mapped is better for
anything it's legitimate for a non-subclass to do.
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-04-02 13:16:43 +00:00
|
|
|
if (CLUTTER_ACTOR_CLASS (clutter_stage_glx_parent_class)->unrealize != NULL)
|
|
|
|
CLUTTER_ACTOR_CLASS (clutter_stage_glx_parent_class)->unrealize (actor);
|
2008-01-21 11:39:23 +00:00
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
clutter_x11_trap_x_errors ();
|
2007-07-06 09:22:43 +00:00
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
if (G_UNLIKELY (was_offscreen))
|
|
|
|
{
|
|
|
|
if (stage_glx->glxpixmap)
|
2008-01-31 23:10:30 +00:00
|
|
|
{
|
|
|
|
glXDestroyGLXPixmap (stage_x11->xdpy,stage_glx->glxpixmap);
|
|
|
|
stage_glx->glxpixmap = None;
|
|
|
|
}
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
if (stage_x11->xpixmap)
|
2008-01-31 23:10:30 +00:00
|
|
|
{
|
|
|
|
XFreePixmap (stage_x11->xdpy, stage_x11->xpixmap);
|
|
|
|
stage_x11->xpixmap = None;
|
|
|
|
}
|
2007-03-22 18:21:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-11-15 14:45:27 +00:00
|
|
|
if (!stage_x11->is_foreign_xwin && stage_x11->xwin != None)
|
2008-01-31 23:10:30 +00:00
|
|
|
{
|
|
|
|
XDestroyWindow (stage_x11->xdpy, stage_x11->xwin);
|
|
|
|
stage_x11->xwin = None;
|
|
|
|
}
|
2007-03-22 18:21:59 +00:00
|
|
|
else
|
2008-01-31 23:10:30 +00:00
|
|
|
stage_x11->xwin = None;
|
2007-03-22 18:21:59 +00:00
|
|
|
}
|
|
|
|
|
2009-05-13 21:21:48 +00:00
|
|
|
if (stage_x11->xvisinfo != None)
|
|
|
|
{
|
|
|
|
XFree (stage_x11->xvisinfo);
|
|
|
|
stage_x11->xvisinfo = None;
|
|
|
|
}
|
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
XSync (stage_x11->xdpy, False);
|
2007-07-22 22:40:18 +00:00
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
clutter_x11_untrap_x_errors ();
|
2007-07-22 22:40:18 +00:00
|
|
|
|
|
|
|
CLUTTER_MARK ();
|
2007-03-22 18:21:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_glx_realize (ClutterActor *actor)
|
|
|
|
{
|
2008-05-12 Emmanuele Bassi <ebassi@openedhand.com>
Rework the stage wrapper/implementation relation: remove
duplicated code and all the bookkeeping from the backends into
ClutterStage whenever possible, to reduce the amount of work a
backend must do (and possibly get wrong). Thanks to Tommi
Komulainen.
* clutter/clutter-main.c:
(clutter_init_with_args), (clutter_init): Realize the default
stage after creation. The default stage is special, because we
use it in the initialization sequence. This removes the burden
from the backends and reduces the things a backend can get
wrong.
* clutter/clutter-stage.c:
(clutter_stage_show): Make sure to realize the implementation if
it hasn't been realized yet.
(clutter_stage_realize): Set the REALIZED flag and call
clutter_stage_ensure_current() if the implementation was
successfully realized.
(clutter_stage_unrealized): Call clutter_stage_ensure_current()
on unrealize.
* clutter/glx/clutter-backend-glx.c:
(clutter_backend_glx_create_stage): Do not realize the stage anymore
when creating it, and let the normal realization sequence take
place.
(clutter_backend_glx_ensure_context): Trap for X11 errors.
* clutter/glx/clutter-stage-glx.c:
(clutter_stage_glx_realize): Chain up to the X11 implementation
so that we can set up the window state (title, cursor visibility)
when we actually have a X window. Also, do not call
clutter_stage_ensure_current(), and rely on the wrapper to do
it for us. This means we can drop setting the REALIZED flag on
the wrapper.
(clutter_stage_glx_unrealize): Do not call
clutter_stage_ensure_current() ourselves, and rely on the wrapper
to do it for us.
* clutter/x11/clutter-stage-x11.c:
(set_wm_title), (set_cursor_visible): Move the WM title and
cursor visibility code inside their own functions.
(clutter_stage_x11_realize): Set the window title and whether the
cursor is visible or not after realizing the stage.
(clutter_stage_x11_set_cursor_visible),
(clutter_stage_x11_set_title): Call set_wm_title() and
set_cursor_visible().
(clutter_stage_x11_finalize): Free the title string.
* clutter/x11/clutter-stage-x11.h: Save more of the stage state,
so that we can set it even when the stage hasn't been realized
yet.
* clutter/eglnative/clutter-backend-egl.c:
(clutter_backend_egl_create_stage):
* clutter/eglnative/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglnative backend.
* clutter/eglx/clutter-backend-egl.c:
(clutter_backend_egl_ensure_context),
(clutter_backend_egl_create_stage):
* clutter/eglx/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglx backend.
* clutter/sdl/clutter-backend-sdl.c:
(clutter_backend_sdl_create_stage):
* clutter/sdl/clutter-stage-sdl.c:
(clutter_stage_sdl_realize): Update the sdl backend.
* clutter/fruity/clutter-backend-fruity.c:
(clutter_backend_fruity_create_stage):
* clutter/sdl/clutter-stage-fruity.c:
(clutter_stage_fruity_realize): Update the fruity backend.
* tests/test-multistage.c (on_button_press): Bail out if
clutter_stage_new() returns NULL.
* HACKING.backends: Update backend writing documentation.
2008-05-12 15:26:37 +00:00
|
|
|
ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (actor);
|
|
|
|
ClutterStageGLX *stage_glx = CLUTTER_STAGE_GLX (actor);
|
2009-05-13 21:21:48 +00:00
|
|
|
ClutterBackend *backend;
|
2008-03-28 22:50:55 +00:00
|
|
|
ClutterBackendGLX *backend_glx;
|
2008-06-23 09:55:42 +00:00
|
|
|
ClutterBackendX11 *backend_x11;
|
2008-05-12 Emmanuele Bassi <ebassi@openedhand.com>
Rework the stage wrapper/implementation relation: remove
duplicated code and all the bookkeeping from the backends into
ClutterStage whenever possible, to reduce the amount of work a
backend must do (and possibly get wrong). Thanks to Tommi
Komulainen.
* clutter/clutter-main.c:
(clutter_init_with_args), (clutter_init): Realize the default
stage after creation. The default stage is special, because we
use it in the initialization sequence. This removes the burden
from the backends and reduces the things a backend can get
wrong.
* clutter/clutter-stage.c:
(clutter_stage_show): Make sure to realize the implementation if
it hasn't been realized yet.
(clutter_stage_realize): Set the REALIZED flag and call
clutter_stage_ensure_current() if the implementation was
successfully realized.
(clutter_stage_unrealized): Call clutter_stage_ensure_current()
on unrealize.
* clutter/glx/clutter-backend-glx.c:
(clutter_backend_glx_create_stage): Do not realize the stage anymore
when creating it, and let the normal realization sequence take
place.
(clutter_backend_glx_ensure_context): Trap for X11 errors.
* clutter/glx/clutter-stage-glx.c:
(clutter_stage_glx_realize): Chain up to the X11 implementation
so that we can set up the window state (title, cursor visibility)
when we actually have a X window. Also, do not call
clutter_stage_ensure_current(), and rely on the wrapper to do
it for us. This means we can drop setting the REALIZED flag on
the wrapper.
(clutter_stage_glx_unrealize): Do not call
clutter_stage_ensure_current() ourselves, and rely on the wrapper
to do it for us.
* clutter/x11/clutter-stage-x11.c:
(set_wm_title), (set_cursor_visible): Move the WM title and
cursor visibility code inside their own functions.
(clutter_stage_x11_realize): Set the window title and whether the
cursor is visible or not after realizing the stage.
(clutter_stage_x11_set_cursor_visible),
(clutter_stage_x11_set_title): Call set_wm_title() and
set_cursor_visible().
(clutter_stage_x11_finalize): Free the title string.
* clutter/x11/clutter-stage-x11.h: Save more of the stage state,
so that we can set it even when the stage hasn't been realized
yet.
* clutter/eglnative/clutter-backend-egl.c:
(clutter_backend_egl_create_stage):
* clutter/eglnative/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglnative backend.
* clutter/eglx/clutter-backend-egl.c:
(clutter_backend_egl_ensure_context),
(clutter_backend_egl_create_stage):
* clutter/eglx/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglx backend.
* clutter/sdl/clutter-backend-sdl.c:
(clutter_backend_sdl_create_stage):
* clutter/sdl/clutter-stage-sdl.c:
(clutter_stage_sdl_realize): Update the sdl backend.
* clutter/fruity/clutter-backend-fruity.c:
(clutter_backend_fruity_create_stage):
* clutter/sdl/clutter-stage-fruity.c:
(clutter_stage_fruity_realize): Update the fruity backend.
* tests/test-multistage.c (on_button_press): Bail out if
clutter_stage_new() returns NULL.
* HACKING.backends: Update backend writing documentation.
2008-05-12 15:26:37 +00:00
|
|
|
gboolean is_offscreen;
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2009-05-11 11:36:14 +00:00
|
|
|
CLUTTER_NOTE (ACTOR, "Realizing stage '%s' [%p]",
|
|
|
|
G_OBJECT_TYPE_NAME (actor),
|
|
|
|
actor);
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2008-04-04 15:02:11 +00:00
|
|
|
g_object_get (stage_x11->wrapper, "offscreen", &is_offscreen, NULL);
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2009-05-13 21:21:48 +00:00
|
|
|
backend = clutter_get_default_backend ();
|
|
|
|
backend_glx = CLUTTER_BACKEND_GLX (backend);
|
|
|
|
backend_x11 = CLUTTER_BACKEND_X11 (backend);
|
2008-03-28 22:50:55 +00:00
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
if (G_LIKELY (!is_offscreen))
|
|
|
|
{
|
2009-05-13 21:21:48 +00:00
|
|
|
GError *error;
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2009-05-13 20:49:45 +00:00
|
|
|
stage_x11->xvisinfo =
|
|
|
|
clutter_backend_x11_get_visual_info (backend_x11, FALSE);
|
2009-05-13 21:21:48 +00:00
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
if (stage_x11->xvisinfo == None)
|
2008-01-31 23:10:30 +00:00
|
|
|
{
|
|
|
|
g_critical ("Unable to find suitable GL visual.");
|
2008-05-12 10:17:55 +00:00
|
|
|
goto fail;
|
2008-01-31 23:10:30 +00:00
|
|
|
}
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
if (stage_x11->xwin == None)
|
2007-03-22 18:21:59 +00:00
|
|
|
{
|
2008-01-31 23:10:30 +00:00
|
|
|
XSetWindowAttributes xattr;
|
|
|
|
unsigned long mask;
|
|
|
|
|
|
|
|
CLUTTER_NOTE (MISC, "Creating stage X window");
|
|
|
|
|
|
|
|
/* window attributes */
|
|
|
|
xattr.background_pixel = WhitePixel (stage_x11->xdpy,
|
|
|
|
stage_x11->xscreen);
|
|
|
|
xattr.border_pixel = 0;
|
|
|
|
xattr.colormap = XCreateColormap (stage_x11->xdpy,
|
2007-11-15 14:45:27 +00:00
|
|
|
stage_x11->xwin_root,
|
|
|
|
stage_x11->xvisinfo->visual,
|
2008-01-31 23:10:30 +00:00
|
|
|
AllocNone);
|
2008-09-17 13:25:50 +00:00
|
|
|
mask = CWBorderPixel | CWColormap;
|
2008-01-31 23:10:30 +00:00
|
|
|
stage_x11->xwin = XCreateWindow (stage_x11->xdpy,
|
2008-04-04 15:02:11 +00:00
|
|
|
stage_x11->xwin_root,
|
|
|
|
0, 0,
|
|
|
|
stage_x11->xwin_width,
|
|
|
|
stage_x11->xwin_height,
|
|
|
|
0,
|
|
|
|
stage_x11->xvisinfo->depth,
|
|
|
|
InputOutput,
|
|
|
|
stage_x11->xvisinfo->visual,
|
|
|
|
mask, &xattr);
|
2007-03-22 18:21:59 +00:00
|
|
|
}
|
2008-01-31 23:10:30 +00:00
|
|
|
|
2008-07-01 13:41:23 +00:00
|
|
|
if (clutter_x11_has_event_retrieval())
|
2008-06-23 09:55:42 +00:00
|
|
|
{
|
2008-06-27 23:02:30 +00:00
|
|
|
if (clutter_x11_has_xinput())
|
|
|
|
{
|
|
|
|
XSelectInput (stage_x11->xdpy, stage_x11->xwin,
|
|
|
|
StructureNotifyMask |
|
|
|
|
FocusChangeMask |
|
|
|
|
ExposureMask |
|
2008-06-30 14:01:03 +00:00
|
|
|
KeyPressMask | KeyReleaseMask |
|
2009-02-12 17:21:18 +00:00
|
|
|
EnterWindowMask | LeaveWindowMask |
|
2008-06-27 23:02:30 +00:00
|
|
|
PropertyChangeMask);
|
2008-06-23 09:55:42 +00:00
|
|
|
#ifdef USE_XINPUT
|
2008-06-27 23:02:30 +00:00
|
|
|
_clutter_x11_select_events (stage_x11->xwin);
|
2008-06-23 09:55:42 +00:00
|
|
|
#endif
|
2008-06-27 23:02:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
XSelectInput (stage_x11->xdpy, stage_x11->xwin,
|
|
|
|
StructureNotifyMask |
|
|
|
|
FocusChangeMask |
|
|
|
|
ExposureMask |
|
|
|
|
PointerMotionMask |
|
|
|
|
KeyPressMask | KeyReleaseMask |
|
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
2009-02-12 17:21:18 +00:00
|
|
|
EnterWindowMask | LeaveWindowMask |
|
2008-06-27 23:02:30 +00:00
|
|
|
PropertyChangeMask);
|
2008-06-23 09:55:42 +00:00
|
|
|
}
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2007-07-25 22:09:53 +00:00
|
|
|
/* no user resize.. */
|
2009-06-04 15:27:21 +00:00
|
|
|
clutter_stage_x11_fix_window_size (stage_x11, -1, -1);
|
2007-11-17 18:11:14 +00:00
|
|
|
clutter_stage_x11_set_wm_protocols (stage_x11);
|
2007-04-19 15:26:54 +00:00
|
|
|
|
2009-05-13 21:21:48 +00:00
|
|
|
/* ask for a context; a no-op, if a context already exists */
|
|
|
|
error = NULL;
|
|
|
|
_clutter_backend_create_context (backend, FALSE, &error);
|
|
|
|
if (error)
|
2008-01-31 23:10:30 +00:00
|
|
|
{
|
2009-05-13 21:21:48 +00:00
|
|
|
g_critical ("Unable to realize stage: %s", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
goto fail;
|
2008-01-31 23:10:30 +00:00
|
|
|
}
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2009-06-06 13:55:00 +00:00
|
|
|
CLUTTER_NOTE (BACKEND, "Successfully realized stage");
|
2007-03-22 18:21:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-05-13 21:21:48 +00:00
|
|
|
GError *error;
|
|
|
|
|
2009-05-13 20:49:45 +00:00
|
|
|
if (stage_x11->xvisinfo != None)
|
|
|
|
{
|
|
|
|
XFree (stage_x11->xvisinfo);
|
|
|
|
stage_x11->xvisinfo = None;
|
|
|
|
}
|
|
|
|
|
|
|
|
stage_x11->xvisinfo =
|
|
|
|
clutter_backend_x11_get_visual_info (backend_x11, TRUE);
|
2009-05-13 21:21:48 +00:00
|
|
|
|
2009-05-13 20:49:45 +00:00
|
|
|
if (stage_x11->xvisinfo == None)
|
2008-01-31 23:10:30 +00:00
|
|
|
{
|
|
|
|
g_critical ("Unable to find suitable GL visual.");
|
|
|
|
goto fail;
|
|
|
|
}
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2007-11-15 14:45:27 +00:00
|
|
|
stage_x11->xpixmap = XCreatePixmap (stage_x11->xdpy,
|
2008-01-31 23:10:30 +00:00
|
|
|
stage_x11->xwin_root,
|
|
|
|
stage_x11->xwin_width,
|
|
|
|
stage_x11->xwin_height,
|
|
|
|
DefaultDepth (stage_x11->xdpy,
|
|
|
|
stage_x11->xscreen));
|
2007-11-15 14:45:27 +00:00
|
|
|
|
|
|
|
stage_glx->glxpixmap = glXCreateGLXPixmap (stage_x11->xdpy,
|
2008-01-31 23:10:30 +00:00
|
|
|
stage_x11->xvisinfo,
|
|
|
|
stage_x11->xpixmap);
|
|
|
|
|
2009-05-13 21:21:48 +00:00
|
|
|
/* ask for a context; a no-op, if a context already exists
|
|
|
|
*
|
|
|
|
* FIXME: we probably need a seperate offscreen context here
|
|
|
|
* - though it likely makes most sense to drop offscreen stages
|
|
|
|
* and rely on FBO's instead and GLXPixmaps seems mostly broken
|
|
|
|
* anyway..
|
|
|
|
*/
|
|
|
|
error = NULL;
|
|
|
|
_clutter_backend_create_context (backend, TRUE, &error);
|
|
|
|
if (error)
|
2008-03-28 22:50:55 +00:00
|
|
|
{
|
2009-05-13 21:21:48 +00:00
|
|
|
g_critical ("Unable to realize stage: %s", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
goto fail;
|
2008-03-28 22:50:55 +00:00
|
|
|
}
|
2007-05-25 10:56:09 +00:00
|
|
|
|
2009-06-06 13:55:00 +00:00
|
|
|
CLUTTER_NOTE (BACKEND, "Successfully realized stage");
|
2007-03-22 18:21:59 +00:00
|
|
|
}
|
|
|
|
|
2008-05-12 Emmanuele Bassi <ebassi@openedhand.com>
Rework the stage wrapper/implementation relation: remove
duplicated code and all the bookkeeping from the backends into
ClutterStage whenever possible, to reduce the amount of work a
backend must do (and possibly get wrong). Thanks to Tommi
Komulainen.
* clutter/clutter-main.c:
(clutter_init_with_args), (clutter_init): Realize the default
stage after creation. The default stage is special, because we
use it in the initialization sequence. This removes the burden
from the backends and reduces the things a backend can get
wrong.
* clutter/clutter-stage.c:
(clutter_stage_show): Make sure to realize the implementation if
it hasn't been realized yet.
(clutter_stage_realize): Set the REALIZED flag and call
clutter_stage_ensure_current() if the implementation was
successfully realized.
(clutter_stage_unrealized): Call clutter_stage_ensure_current()
on unrealize.
* clutter/glx/clutter-backend-glx.c:
(clutter_backend_glx_create_stage): Do not realize the stage anymore
when creating it, and let the normal realization sequence take
place.
(clutter_backend_glx_ensure_context): Trap for X11 errors.
* clutter/glx/clutter-stage-glx.c:
(clutter_stage_glx_realize): Chain up to the X11 implementation
so that we can set up the window state (title, cursor visibility)
when we actually have a X window. Also, do not call
clutter_stage_ensure_current(), and rely on the wrapper to do
it for us. This means we can drop setting the REALIZED flag on
the wrapper.
(clutter_stage_glx_unrealize): Do not call
clutter_stage_ensure_current() ourselves, and rely on the wrapper
to do it for us.
* clutter/x11/clutter-stage-x11.c:
(set_wm_title), (set_cursor_visible): Move the WM title and
cursor visibility code inside their own functions.
(clutter_stage_x11_realize): Set the window title and whether the
cursor is visible or not after realizing the stage.
(clutter_stage_x11_set_cursor_visible),
(clutter_stage_x11_set_title): Call set_wm_title() and
set_cursor_visible().
(clutter_stage_x11_finalize): Free the title string.
* clutter/x11/clutter-stage-x11.h: Save more of the stage state,
so that we can set it even when the stage hasn't been realized
yet.
* clutter/eglnative/clutter-backend-egl.c:
(clutter_backend_egl_create_stage):
* clutter/eglnative/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglnative backend.
* clutter/eglx/clutter-backend-egl.c:
(clutter_backend_egl_ensure_context),
(clutter_backend_egl_create_stage):
* clutter/eglx/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglx backend.
* clutter/sdl/clutter-backend-sdl.c:
(clutter_backend_sdl_create_stage):
* clutter/sdl/clutter-stage-sdl.c:
(clutter_stage_sdl_realize): Update the sdl backend.
* clutter/fruity/clutter-backend-fruity.c:
(clutter_backend_fruity_create_stage):
* clutter/sdl/clutter-stage-fruity.c:
(clutter_stage_fruity_realize): Update the fruity backend.
* tests/test-multistage.c (on_button_press): Bail out if
clutter_stage_new() returns NULL.
* HACKING.backends: Update backend writing documentation.
2008-05-12 15:26:37 +00:00
|
|
|
/* we need to chain up to the X11 stage implementation in order to
|
|
|
|
* set the window state in case we set it before realizing the stage
|
|
|
|
*/
|
|
|
|
CLUTTER_ACTOR_CLASS (clutter_stage_glx_parent_class)->realize (actor);
|
2007-05-25 10:56:09 +00:00
|
|
|
return;
|
|
|
|
|
2008-04-04 15:02:11 +00:00
|
|
|
fail:
|
2007-05-25 10:56:09 +00:00
|
|
|
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
|
2007-03-22 18:21:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_glx_dispose (GObject *gobject)
|
|
|
|
{
|
|
|
|
G_OBJECT_CLASS (clutter_stage_glx_parent_class)->dispose (gobject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-05-31 11:13:43 +00:00
|
|
|
clutter_stage_glx_class_init (ClutterStageGLXClass *klass)
|
2007-03-22 18:21:59 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
|
|
|
|
|
|
|
gobject_class->dispose = clutter_stage_glx_dispose;
|
|
|
|
|
|
|
|
actor_class->realize = clutter_stage_glx_realize;
|
|
|
|
actor_class->unrealize = clutter_stage_glx_unrealize;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-05-31 11:13:43 +00:00
|
|
|
clutter_stage_glx_init (ClutterStageGLX *stage)
|
2007-03-22 18:21:59 +00:00
|
|
|
{
|
2008-04-04 15:02:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
|
|
|
|
{
|
|
|
|
/* the rest is inherited from ClutterStageX11 */
|
2007-03-22 18:21:59 +00:00
|
|
|
}
|