From 4533e37744f8751e254741104d27b7b37e2fdfd7 Mon Sep 17 00:00:00 2001 From: Joshua Lock Date: Thu, 5 Nov 2009 15:44:32 +0000 Subject: [PATCH 1/3] osx: Implement the updated ClutterStageWindow interface In the new Clutter world backend stage implementations should be lightweight objects implementing the ClutterStageWindow interface and not ClutterActor subclasses. This patch performs various cut-n-pastes to acheive that for the OSX backend http://bugzilla.openedhand.com/show_bug.cgi?id=1864 --- clutter/osx/clutter-backend-osx.c | 4 +- clutter/osx/clutter-stage-osx.c | 200 +++++++++++++----------------- clutter/osx/clutter-stage-osx.h | 8 +- 3 files changed, 91 insertions(+), 121 deletions(-) diff --git a/clutter/osx/clutter-backend-osx.c b/clutter/osx/clutter-backend-osx.c index 935c5b6d4..f8d9e3146 100644 --- a/clutter/osx/clutter-backend-osx.c +++ b/clutter/osx/clutter-backend-osx.c @@ -96,12 +96,12 @@ clutter_backend_osx_get_features (ClutterBackend *backend) return CLUTTER_FEATURE_STAGE_MULTIPLE|CLUTTER_FEATURE_STAGE_USER_RESIZE; } -static ClutterActor* +static ClutterStageWindow* clutter_backend_osx_create_stage (ClutterBackend *backend, ClutterStage *wrapper, GError **error) { - ClutterActor *impl; + ClutterStageWindow *impl; CLUTTER_NOTE (BACKEND, "create_stage: wrapper=%p", wrapper); diff --git a/clutter/osx/clutter-stage-osx.c b/clutter/osx/clutter-stage-osx.c index 4396e689f..71f67d59a 100644 --- a/clutter/osx/clutter-stage-osx.c +++ b/clutter/osx/clutter-stage-osx.c @@ -31,7 +31,9 @@ static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface); -G_DEFINE_TYPE_WITH_CODE (ClutterStageOSX, clutter_stage_osx, CLUTTER_TYPE_ACTOR, +G_DEFINE_TYPE_WITH_CODE (ClutterStageOSX, + clutter_stage_osx, + G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_STAGE_WINDOW, clutter_stage_window_iface_init)) @@ -213,19 +215,15 @@ clutter_stage_osx_state_update (ClutterStageOSX *self, static void clutter_stage_osx_save_frame (ClutterStageOSX *self) { - if (CLUTTER_ACTOR_IS_REALIZED (CLUTTER_ACTOR (self))) - { - g_assert (self->window != NULL); + g_assert (self->window != NULL); - self->normalFrame = [self->window frame]; - self->haveNormalFrame = TRUE; - } + self->normalFrame = [self->window frame]; + self->haveNormalFrame = TRUE; } static void clutter_stage_osx_set_frame (ClutterStageOSX *self) { - g_assert (CLUTTER_ACTOR_IS_REALIZED (CLUTTER_ACTOR (self))); g_assert (self->window != NULL); if (self->stage_state & CLUTTER_STAGE_STATE_FULLSCREEN) @@ -254,17 +252,14 @@ clutter_stage_osx_set_frame (ClutterStageOSX *self) } /*************************************************************************/ -static void -clutter_stage_osx_realize (ClutterActor *actor) +static gboolean +clutter_stage_osx_realize (ClutterStageWindow *stage_window) { - ClutterStageOSX *self = CLUTTER_STAGE_OSX (actor); + ClutterStageOSX *self = CLUTTER_STAGE_OSX (stage_window); ClutterBackendOSX *backend_osx; CLUTTER_NOTE (BACKEND, "[%p] realize", self); - /* ensure we get realize+unrealize properly paired */ - g_return_if_fail (self->view == NULL && self->window == NULL); - CLUTTER_OSX_POOL_ALLOC(); backend_osx = CLUTTER_BACKEND_OSX (self->backend); @@ -288,12 +283,14 @@ clutter_stage_osx_realize (ClutterActor *actor) CLUTTER_OSX_POOL_RELEASE(); CLUTTER_NOTE (BACKEND, "Stage successfully realized"); + + return TRUE; } static void -clutter_stage_osx_unrealize (ClutterActor *actor) +clutter_stage_osx_unrealize (ClutterStageWindow *stage_window) { - ClutterStageOSX *self = CLUTTER_STAGE_OSX (actor); + ClutterStageOSX *self = CLUTTER_STAGE_OSX (stage_window); CLUTTER_NOTE (BACKEND, "[%p] unrealize", self); @@ -321,7 +318,7 @@ clutter_stage_osx_show (ClutterStageWindow *stage_window, CLUTTER_OSX_POOL_ALLOC(); - clutter_actor_map (CLUTTER_ACTOR (self)); + clutter_stage_osx_realize (stage_window); clutter_actor_map (CLUTTER_ACTOR (self->wrapper)); clutter_stage_osx_set_frame (self); @@ -342,100 +339,75 @@ clutter_stage_osx_hide (ClutterStageWindow *stage_window) [self->window orderOut: nil]; - clutter_actor_unmap (CLUTTER_ACTOR (self)); + clutter_stage_osx_unrealize (stage_window); clutter_actor_unmap (CLUTTER_ACTOR (self->wrapper)); CLUTTER_OSX_POOL_RELEASE(); } static void -clutter_stage_osx_get_preferred_width (ClutterActor *actor, - gfloat for_height, - gfloat *min_width_p, - gfloat *natural_width_p) +clutter_stage_osx_get_geometry (ClutterStageWindow *stage_window, + ClutterGeometry *geometry) { - ClutterStageOSX *self = CLUTTER_STAGE_OSX (actor); - gboolean is_resizable; + ClutterBackend *backend = clutter_get_default_backend (); + ClutterStageOSX *self = CLUTTER_STAGE_OSX (stage_window); + gboolean is_fullscreen, resize; - CLUTTER_OSX_POOL_ALLOC(); + g_return_if_fail (CLUTTER_IS_BACKEND_OSX (backend)); - is_resizable = clutter_stage_get_user_resizable (self->wrapper); + CLUTTER_OSX_POOL_ALLOC (); - if (min_width_p) + is_fullscreen = FALSE; + g_object_get (G_OBJECT (self->wrapper), + "fullscreen-set", &is_fullscreen, + NULL); + + if (is_fullscreen) { - if (is_resizable) - *min_width_p = 1.0; + NSSize size = [[NSScreen mainScreen] frame].size; + + geometry->width = size.width; + geometry->height = size.height; + } + else + { + resize = clutter_stage_get_user_resizable (self->wrapper); + + if (resize) + { + geometry->width = 1; + geometry->height = 1; + } else - *min_width_p = self->requisition_width; + { + geometry->width = self->requisition_width; + geometry->height = self->requisition_height; + } } - if (natural_width_p) - *natural_width_p = self->requisition_width; - - CLUTTER_OSX_POOL_RELEASE(); + CLUTTER_OSX_POOL_RELEASE (); } static void -clutter_stage_osx_get_preferred_height (ClutterActor *actor, - gfloat for_width, - gfloat *min_height_p, - gfloat *natural_height_p) +clutter_stage_osx_resize (ClutterStageWindow *stage_window, + gint width, + gint height) { - ClutterStageOSX *self = CLUTTER_STAGE_OSX (actor); - gboolean is_resizable; + ClutterStageOSX *self = CLUTTER_STAGE_OSX (stage_window); - CLUTTER_OSX_POOL_ALLOC(); + self->requisition_width = width; + self->requisition_height = height; - is_resizable = clutter_stage_get_user_resizable (self->wrapper); + CLUTTER_OSX_POOL_ALLOC (); - if (min_height_p) - { - if (is_resizable) - *min_height_p = 1.0; - else - *min_height_p = self->requisition_height; - } + NSSize size = NSMakeSize (self->requisition_width, + self->requisition_height); + [self->window setContentSize: size]; - if (natural_height_p) - *natural_height_p = self->requisition_height; - - CLUTTER_OSX_POOL_RELEASE(); -} - -static void -clutter_stage_osx_allocate (ClutterActor *actor, - const ClutterActorBox *box, - ClutterAllocationFlags flags) -{ - ClutterStageOSX *self = CLUTTER_STAGE_OSX (actor); - ClutterActorClass *parent_class; - - CLUTTER_NOTE (BACKEND, "[%p], allocate: %d, %d - %d x %d", self, - (int) box->x1, - (int) box->y1, - (int) (box->x2 - box->x1), - (int) (box->y2 - box->y1)); - - self->requisition_width = (int) (box->x2 - box->x1); - self->requisition_height = (int) (box->y2 - box->y1); - - if (CLUTTER_ACTOR_IS_REALIZED (actor)) - { - CLUTTER_OSX_POOL_ALLOC(); - - NSSize size = NSMakeSize(self->requisition_width, - self->requisition_height); - [self->window setContentSize: size]; - - CLUTTER_OSX_POOL_RELEASE(); - } + CLUTTER_OSX_POOL_RELEASE (); /* make sure that the viewport is updated */ CLUTTER_SET_PRIVATE_FLAGS (self->wrapper, CLUTTER_ACTOR_SYNC_MATRICES); - - /* chain up */ - parent_class = CLUTTER_ACTOR_CLASS (clutter_stage_osx_parent_class); - parent_class->allocate (actor, box, flags); } /*************************************************************************/ @@ -457,8 +429,7 @@ clutter_stage_osx_set_title (ClutterStageWindow *stage_window, CLUTTER_OSX_POOL_ALLOC(); - if (CLUTTER_ACTOR_IS_REALIZED (CLUTTER_ACTOR (self))) - [self->window setTitle:[NSString stringWithUTF8String: title ? title : ""]]; + [self->window setTitle:[NSString stringWithUTF8String: title ? title : ""]]; CLUTTER_OSX_POOL_RELEASE(); } @@ -482,27 +453,14 @@ clutter_stage_osx_set_fullscreen (ClutterStageWindow *stage_window, * We do state change first. Not sure there's any difference. */ if (fullscreen) - clutter_stage_osx_state_update (self, 0, CLUTTER_STAGE_STATE_FULLSCREEN); + { + clutter_stage_osx_state_update (self, 0, CLUTTER_STAGE_STATE_FULLSCREEN); + clutter_stage_osx_save_frame (self); + } else clutter_stage_osx_state_update (self, CLUTTER_STAGE_STATE_FULLSCREEN, 0); - if (CLUTTER_ACTOR_IS_REALIZED (CLUTTER_ACTOR (self))) - { - if (fullscreen) - clutter_stage_osx_save_frame (self); - - clutter_stage_osx_set_frame (self); - } - else if (fullscreen) - { - /* FIXME: if you go fullscreen before realize we throw away the normal - * stage size and can't return. Need to maintain them separately. - */ - NSSize size = [[NSScreen mainScreen] frame].size; - - clutter_actor_set_size (CLUTTER_ACTOR (self), - (int)size.width, (int)size.height); - } + clutter_stage_osx_set_frame (self); CLUTTER_OSX_POOL_RELEASE(); } @@ -515,10 +473,14 @@ clutter_stage_window_iface_init (ClutterStageWindowIface *iface) iface->set_fullscreen = clutter_stage_osx_set_fullscreen; iface->show = clutter_stage_osx_show; iface->hide = clutter_stage_osx_hide; + iface->realize = clutter_stage_osx_realize; + iface->unrealize = clutter_stage_osx_unrealize; + iface->get_geometry = clutter_stage_osx_get_geometry; + iface->resize = clutter_stage_osx_resize; } /*************************************************************************/ -ClutterActor * +ClutterStageWindow * clutter_stage_osx_new (ClutterBackend *backend, ClutterStage *wrapper) { @@ -528,7 +490,7 @@ clutter_stage_osx_new (ClutterBackend *backend, self->backend = backend; self->wrapper = wrapper; - return CLUTTER_ACTOR(self); + return CLUTTER_STAGE_WINDOW(self); } /*************************************************************************/ @@ -541,15 +503,23 @@ clutter_stage_osx_init (ClutterStageOSX *self) CLUTTER_SET_PRIVATE_FLAGS(self, CLUTTER_ACTOR_IS_TOPLEVEL); } +static void +clutter_stage_osx_finalize (GObject *gobject) +{ + G_OBJECT_CLASS (clutter_stage_osx_parent_class)->finalize (gobject); +} + +static void +clutter_stage_osx_dispose (GObject *gobject) +{ + G_OBJECT_CLASS (clutter_stage_osx_parent_class)->dispose (gobject); +} + static void clutter_stage_osx_class_init (ClutterStageOSXClass *klass) { - ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - actor_class->realize = clutter_stage_osx_realize; - actor_class->unrealize = clutter_stage_osx_unrealize; - - actor_class->allocate = clutter_stage_osx_allocate; - actor_class->get_preferred_width = clutter_stage_osx_get_preferred_width; - actor_class->get_preferred_height = clutter_stage_osx_get_preferred_height; + gobject_class->finalize = clutter_stage_osx_finalize; + gobject_class->dispose = clutter_stage_osx_dispose; } diff --git a/clutter/osx/clutter-stage-osx.h b/clutter/osx/clutter-stage-osx.h index e24acfad2..89f6a5f73 100644 --- a/clutter/osx/clutter-stage-osx.h +++ b/clutter/osx/clutter-stage-osx.h @@ -50,7 +50,7 @@ typedef struct _ClutterStageOSXClass ClutterStageOSXClass; struct _ClutterStageOSX { - ClutterActor parent; + ClutterGroup parent; ClutterBackend *backend; ClutterStage *wrapper; @@ -69,13 +69,13 @@ struct _ClutterStageOSX struct _ClutterStageOSXClass { - ClutterActorClass parent_class; + ClutterGroupClass parent_class; }; GType clutter_stage_osx_get_type (void) G_GNUC_CONST; -ClutterActor* clutter_stage_osx_new (ClutterBackend *backend, - ClutterStage *wrapper); +ClutterStageWindow* clutter_stage_osx_new (ClutterBackend *backend, + ClutterStage *wrapper); G_END_DECLS From 58f1dfcf35626b8b1ea896dfbd27623b15779fce Mon Sep 17 00:00:00 2001 From: Joshua Lock Date: Thu, 5 Nov 2009 15:31:56 +0000 Subject: [PATCH 2/3] docs: Fix OS X docs to install Ports in correct order The order in which the MacPorts are installed is important otherwise we open the user up to a world of pain. This patch also tweaks the OS X docs to follow the formatting of the rest of the docs and to discuss the option of GtkDoc. http://bugzilla.openedhand.com/show_bug.cgi?id=1865 --- doc/reference/clutter/building-clutter.xml | 75 ++++++++++++---------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/doc/reference/clutter/building-clutter.xml b/doc/reference/clutter/building-clutter.xml index 09def99c3..cf6c0a37b 100644 --- a/doc/reference/clutter/building-clutter.xml +++ b/doc/reference/clutter/building-clutter.xml @@ -237,24 +237,41 @@
- OSX - Currently the only way to install Clutter for developing - applications, or hacking on Clutter itself, is to build it yourself. - The recommended route is to install the dependencies with - the MacPorts - project, by simply invoking: - - - $ sudo port install pango libpixman-devel cairo-devel - - - on a terminal, after installing and updating MacPorts. - This should give you all of the required dependencies for building - Clutter 1.0. + OSX + + Before you start you should install XCode either from the OSX + installation disk or by downloading it from the Apple website. + - XCode should also be installed, either from the OSX installation - disk or downloading it from the Apple website. + Note: These instructions have only been tested on OS X 10.6 + (a.k.a Snow Leopard) + + + + Currently the only way to install Clutter for developing + applications, or hacking on Clutter itself, is to build it yourself. + The recommended route is to install the dependencies with + the MacPorts + project, by simply invoking: + + + + $ sudo port install libpixman-devel cairo-devel pango gtk-doc + + + + on a terminal, after installing and updating MacPorts. + This should give you all of the required dependencies for building + Clutter. + + + + It should be noted that building gtk-doc pulls in a lot of other + MacPorts dependencies and takes some considerable time. You can omit + this dependency so long as you disable documentation when you are + configuring the build with + --disable-gtk-doc --disable-docs @@ -268,29 +285,19 @@ - GTK-Doc is not working on OSX, so API reference generation - should also be disabled when building Clutter, by using - the --disable-docs and - --disable-gtk-doc command line argument - to the configure script. + GTK introspection is untested on OSX (as there isn't a MacPorts + package) so it is recommended that you disable this with the + --disable-introspection. - - GTK introspection and shave support are untested on OSX so it is - also recommended that you disable these with the - --disable-shave and - --disable-introspection. - - - - If building on top of MacPorts, as recommended, the following - configure command should suffice: + + If building on top of MacPorts, as recommended, the following + configure command should suffice: - ./configure --disable-gtk-doc --disable-docs --disable-shave - --with-flavour=osx --disable-introspection --prefix=/opt - + ./configure --with-flavour=osx --disable-introspection --prefix=/opt +
From 031d4d6203f007fea2b95ca883c7113d0160372d Mon Sep 17 00:00:00 2001 From: Joshua Lock Date: Thu, 5 Nov 2009 15:48:25 +0000 Subject: [PATCH 3/3] osx: Fix a warning on Snow Leopard Apple where nice and changed API between releases. This patch checks the version of the compilation environment and tries to use the right parameter type. http://bugzilla.openedhand.com/show_bug.cgi?id=1866 --- clutter/osx/clutter-backend-osx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/clutter/osx/clutter-backend-osx.c b/clutter/osx/clutter-backend-osx.c index f8d9e3146..23267cb50 100644 --- a/clutter/osx/clutter-backend-osx.c +++ b/clutter/osx/clutter-backend-osx.c @@ -68,8 +68,12 @@ clutter_backend_osx_post_parse (ClutterBackend *backend, initWithFormat: self->pixel_format shareContext: nil]; - /* Enable vblank sync - http://developer.apple.com/qa/qa2007/qa1521.html*/ - const long sw = 1; + /* Enable vblank sync - http://developer.apple.com/qa/qa2007/qa1521.html */ + #ifdef MAC_OS_X_VERSION_10_5 + const int sw = 1; + #else + const long sw = 1; + #endif [self->context setValues:&sw forParameter: NSOpenGLCPSwapInterval]; /* FIXME: move the debugging bits to cogl */