osx: Code style cleanups

This commit is contained in:
Emmanuele Bassi 2011-07-13 19:32:47 +01:00
parent c8e3db105c
commit 18b3da95ef
2 changed files with 38 additions and 15 deletions

View File

@ -153,17 +153,18 @@ clutter_backend_osx_create_context (ClutterBackend *backend,
#endif #endif
backend_osx->pixel_format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs]; backend_osx->pixel_format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs];
backend_osx->context = [[NSOpenGLContext alloc]
initWithFormat: backend_osx->pixel_format backend_osx->context = [[NSOpenGLContext alloc] initWithFormat: backend_osx->pixel_format
shareContext: nil]; shareContext: nil];
/* Enable vblank sync - http://developer.apple.com/qa/qa2007/qa1521.html */ /* Enable vblank sync - http://developer.apple.com/qa/qa2007/qa1521.html */
[backend_osx->context setValues:&sw forParameter: NSOpenGLCPSwapInterval]; [backend_osx->context setValues:&sw forParameter: NSOpenGLCPSwapInterval];
CLUTTER_NOTE (BACKEND, "Context was created");
} }
[backend_osx->context makeCurrentContext]; [backend_osx->context makeCurrentContext];
CLUTTER_NOTE (BACKEND, "Context was created");
CLUTTER_OSX_POOL_RELEASE(); CLUTTER_OSX_POOL_RELEASE();
return TRUE; return TRUE;

View File

@ -148,7 +148,10 @@ clutter_stage_osx_get_wrapper (ClutterStageWindow *stage_window);
if ((self = [super initWithFrame:aFrame pixelFormat:aFormat]) != nil) if ((self = [super initWithFrame:aFrame pixelFormat:aFormat]) != nil)
{ {
self->stage_osx = aStage; self->stage_osx = aStage;
tracking_rect = [self addTrackingRect:[self bounds] owner:self userData:NULL assumeInside:NO]; tracking_rect = [self addTrackingRect:[self bounds]
owner:self
userData:NULL
assumeInside:NO];
} }
return self; return self;
@ -173,22 +176,36 @@ clutter_stage_osx_get_wrapper (ClutterStageWindow *stage_window);
return YES; return YES;
} }
- (BOOL) isOpaque
{
if (clutter_stage_get_use_alpha (CLUTTER_STAGE (self->stage_osx->wrapper)))
return NO;
return YES;
}
- (void) reshape - (void) reshape
{ {
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, (int)[self bounds].size.height); (int)[self bounds].size.width,
(int)[self bounds].size.height);
[self removeTrackingRect:tracking_rect]; [self removeTrackingRect:tracking_rect];
tracking_rect = [self addTrackingRect:[self bounds] owner:self userData:NULL assumeInside:NO]; tracking_rect = [self addTrackingRect:[self bounds]
owner:self
userData:NULL
assumeInside:NO];
} }
/* Simply forward all events that reach our view to clutter. */ /* Simply forward all events that reach our view to clutter. */
#define EVENT_HANDLER(event) -(void)event:(NSEvent *)theEvent { \ #define EVENT_HANDLER(event) \
-(void)event:(NSEvent *) theEvent { \
_clutter_event_osx_put (theEvent, self->stage_osx->wrapper); \ _clutter_event_osx_put (theEvent, self->stage_osx->wrapper); \
} }
EVENT_HANDLER(mouseDown) EVENT_HANDLER(mouseDown)
EVENT_HANDLER(mouseDragged) EVENT_HANDLER(mouseDragged)
EVENT_HANDLER(mouseUp) EVENT_HANDLER(mouseUp)
@ -261,7 +278,8 @@ clutter_stage_osx_set_frame (ClutterStageOSX *self)
*/ */
[self->window setLevel: CLUTTER_OSX_FULLSCREEN_WINDOW_LEVEL]; [self->window setLevel: CLUTTER_OSX_FULLSCREEN_WINDOW_LEVEL];
[self->window setFrame: [self->window frameRectForContentRect: [[self->window screen] frame]] display: NO]; [self->window setFrame: [self->window frameRectForContentRect: [[self->window screen] frame]]
display: NO];
} }
else else
{ {
@ -270,10 +288,12 @@ clutter_stage_osx_set_frame (ClutterStageOSX *self)
if (self->haveNormalFrame) if (self->haveNormalFrame)
[self->window setFrame: self->normalFrame display: NO]; [self->window setFrame: self->normalFrame display: NO];
else else
{
/* looks better than positioning to 0,0 (bottom right) */ /* looks better than positioning to 0,0 (bottom right) */
[self->window center]; [self->window center];
} }
} }
}
/*************************************************************************/ /*************************************************************************/
static gboolean static gboolean
@ -289,6 +309,7 @@ clutter_stage_osx_realize (ClutterStageWindow *stage_window)
CLUTTER_NOTE (BACKEND, "[%p] realize", self); CLUTTER_NOTE (BACKEND, "[%p] realize", self);
backend_osx = CLUTTER_BACKEND_OSX (self->backend); backend_osx = CLUTTER_BACKEND_OSX (self->backend);
/* Call get_size - this will either get the geometry size (which /* Call get_size - this will either get the geometry size (which
* before we create the window is set to 640x480), or if a size * before we create the window is set to 640x480), or if a size
* is set, it will get that. This lets you set a size on the * is set, it will get that. This lets you set a size on the
@ -423,6 +444,7 @@ clutter_stage_osx_resize (ClutterStageWindow *stage_window,
clutter_stage_get_minimum_size (CLUTTER_STAGE (actor), clutter_stage_get_minimum_size (CLUTTER_STAGE (actor),
&min_width, &min_width,
&min_height); &min_height);
[self->window setContentMinSize: NSMakeSize (min_width, min_height)]; [self->window setContentMinSize: NSMakeSize (min_width, min_height)];
width = width < min_width ? min_width : width; width = width < min_width ? min_width : width;