osx: Clean up the backend implementation
Instead of implementing create_stage() and a constructor for ClutterStageOSX, we can use the default implementations in ClutterBackend, and spare us some code duplication.
This commit is contained in:
parent
88b27beea4
commit
6d68ac2e8b
@ -71,27 +71,8 @@ clutter_backend_osx_post_parse (ClutterBackend *backend,
|
|||||||
static ClutterFeatureFlags
|
static ClutterFeatureFlags
|
||||||
clutter_backend_osx_get_features (ClutterBackend *backend)
|
clutter_backend_osx_get_features (ClutterBackend *backend)
|
||||||
{
|
{
|
||||||
return CLUTTER_FEATURE_STAGE_MULTIPLE|CLUTTER_FEATURE_STAGE_USER_RESIZE;
|
return CLUTTER_FEATURE_STAGE_MULTIPLE
|
||||||
}
|
| CLUTTER_FEATURE_STAGE_USER_RESIZE;
|
||||||
|
|
||||||
static ClutterStageWindow*
|
|
||||||
clutter_backend_osx_create_stage (ClutterBackend *backend,
|
|
||||||
ClutterStage *wrapper,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
ClutterStageWindow *impl;
|
|
||||||
|
|
||||||
CLUTTER_OSX_POOL_ALLOC();
|
|
||||||
|
|
||||||
impl = _clutter_stage_osx_new (backend, wrapper);
|
|
||||||
|
|
||||||
CLUTTER_NOTE (BACKEND, "create_stage: wrapper=%p - impl=%p",
|
|
||||||
wrapper,
|
|
||||||
impl);
|
|
||||||
|
|
||||||
CLUTTER_OSX_POOL_RELEASE();
|
|
||||||
|
|
||||||
return impl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -127,7 +108,7 @@ clutter_backend_osx_create_context (ClutterBackend *backend,
|
|||||||
*/
|
*/
|
||||||
NSOpenGLPixelFormatAttribute attrs[] = {
|
NSOpenGLPixelFormatAttribute attrs[] = {
|
||||||
NSOpenGLPFADoubleBuffer,
|
NSOpenGLPFADoubleBuffer,
|
||||||
NSOpenGLPFADepthSize, 24,
|
NSOpenGLPFADepthSize, 32,
|
||||||
NSOpenGLPFAStencilSize, 8,
|
NSOpenGLPFAStencilSize, 8,
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
@ -174,6 +155,7 @@ clutter_backend_osx_ensure_context (ClutterBackend *backend,
|
|||||||
g_assert (CLUTTER_IS_STAGE_OSX (impl));
|
g_assert (CLUTTER_IS_STAGE_OSX (impl));
|
||||||
stage_osx = CLUTTER_STAGE_OSX (impl);
|
stage_osx = CLUTTER_STAGE_OSX (impl);
|
||||||
|
|
||||||
|
[backend_osx->context clearDrawable];
|
||||||
[backend_osx->context setView:stage_osx->view];
|
[backend_osx->context setView:stage_osx->view];
|
||||||
[backend_osx->context makeCurrentContext];
|
[backend_osx->context makeCurrentContext];
|
||||||
}
|
}
|
||||||
@ -235,7 +217,6 @@ clutter_backend_osx_class_init (ClutterBackendOSXClass *klass)
|
|||||||
|
|
||||||
backend_class->post_parse = clutter_backend_osx_post_parse;
|
backend_class->post_parse = clutter_backend_osx_post_parse;
|
||||||
backend_class->get_features = clutter_backend_osx_get_features;
|
backend_class->get_features = clutter_backend_osx_get_features;
|
||||||
backend_class->create_stage = clutter_backend_osx_create_stage;
|
|
||||||
backend_class->create_context = clutter_backend_osx_create_context;
|
backend_class->create_context = clutter_backend_osx_create_context;
|
||||||
backend_class->ensure_context = clutter_backend_osx_ensure_context;
|
backend_class->ensure_context = clutter_backend_osx_ensure_context;
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ clutter_stage_osx_get_wrapper (ClutterStageWindow *stage_window);
|
|||||||
|
|
||||||
- (NSSize) windowWillResize:(NSWindow *) sender toSize:(NSSize) frameSize
|
- (NSSize) windowWillResize:(NSWindow *) sender toSize:(NSSize) frameSize
|
||||||
{
|
{
|
||||||
if ( clutter_stage_get_user_resizable (self->stage_osx->wrapper) )
|
if (clutter_stage_get_user_resizable (self->stage_osx->wrapper))
|
||||||
{
|
{
|
||||||
guint min_width, min_height;
|
guint min_width, min_height;
|
||||||
clutter_stage_get_minimum_size (self->stage_osx->wrapper,
|
clutter_stage_get_minimum_size (self->stage_osx->wrapper,
|
||||||
@ -143,7 +143,7 @@ clutter_stage_osx_get_wrapper (ClutterStageWindow *stage_window);
|
|||||||
|
|
||||||
- (void)windowDidChangeScreen:(NSNotification *)notification
|
- (void)windowDidChangeScreen:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
clutter_stage_ensure_redraw (CLUTTER_STAGE(self->stage_osx->wrapper));
|
clutter_stage_ensure_redraw (CLUTTER_STAGE (self->stage_osx->wrapper));
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -203,8 +203,8 @@ clutter_stage_osx_get_wrapper (ClutterStageWindow *stage_window);
|
|||||||
stage_osx->requisition_width = [self bounds].size.width;
|
stage_osx->requisition_width = [self bounds].size.width;
|
||||||
stage_osx->requisition_height = [self bounds].size.height;
|
stage_osx->requisition_height = [self bounds].size.height;
|
||||||
clutter_actor_set_size (CLUTTER_ACTOR (self->stage_osx->wrapper),
|
clutter_actor_set_size (CLUTTER_ACTOR (self->stage_osx->wrapper),
|
||||||
(int)[self bounds].size.width,
|
stage_osx->requisition_width,
|
||||||
(int)[self bounds].size.height);
|
stage_osx->requisition_height);
|
||||||
|
|
||||||
[self removeTrackingRect:tracking_rect];
|
[self removeTrackingRect:tracking_rect];
|
||||||
tracking_rect = [self addTrackingRect:[self bounds]
|
tracking_rect = [self addTrackingRect:[self bounds]
|
||||||
@ -609,26 +609,6 @@ clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
|
|||||||
iface->redraw = clutter_stage_osx_redraw;
|
iface->redraw = clutter_stage_osx_redraw;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************/
|
|
||||||
ClutterStageWindow *
|
|
||||||
_clutter_stage_osx_new (ClutterBackend *backend,
|
|
||||||
ClutterStage *wrapper)
|
|
||||||
{
|
|
||||||
ClutterStageOSX *self;
|
|
||||||
|
|
||||||
self = g_object_new (CLUTTER_TYPE_STAGE_OSX,
|
|
||||||
"backend", backend,
|
|
||||||
"wrapper", wrapper,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
self->isHiding = false;
|
|
||||||
self->haveRealized = false;
|
|
||||||
self->view = NULL;
|
|
||||||
self->window = NULL;
|
|
||||||
|
|
||||||
return CLUTTER_STAGE_WINDOW (self);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
static void
|
static void
|
||||||
clutter_stage_osx_init (ClutterStageOSX *self)
|
clutter_stage_osx_init (ClutterStageOSX *self)
|
||||||
@ -636,6 +616,11 @@ clutter_stage_osx_init (ClutterStageOSX *self)
|
|||||||
self->requisition_width = 640;
|
self->requisition_width = 640;
|
||||||
self->requisition_height = 480;
|
self->requisition_height = 480;
|
||||||
self->acceptFocus = TRUE;
|
self->acceptFocus = TRUE;
|
||||||
|
|
||||||
|
self->isHiding = false;
|
||||||
|
self->haveRealized = false;
|
||||||
|
self->view = NULL;
|
||||||
|
self->window = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -82,9 +82,6 @@ struct _ClutterStageOSXClass
|
|||||||
|
|
||||||
GType _clutter_stage_osx_get_type (void) G_GNUC_CONST;
|
GType _clutter_stage_osx_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
ClutterStageWindow * _clutter_stage_osx_new (ClutterBackend *backend,
|
|
||||||
ClutterStage *wrapper);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __CLUTTER_STAGE_OSX_H__ */
|
#endif /* __CLUTTER_STAGE_OSX_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user