osx: Implement the set_accept_focus() vfunc

Like the x11 and win32 backends, the quartz backend should allow setting
the key focus when showing the stage window.
This commit is contained in:
Emmanuele Bassi 2010-12-28 22:21:09 +00:00
parent 9d6a33d0c8
commit 2fe20ff3c5
2 changed files with 25 additions and 6 deletions

View File

@ -345,16 +345,21 @@ clutter_stage_osx_show (ClutterStageWindow *stage_window,
clutter_actor_map (CLUTTER_ACTOR (self->wrapper)); clutter_actor_map (CLUTTER_ACTOR (self->wrapper));
clutter_stage_osx_set_frame (self); clutter_stage_osx_set_frame (self);
/* Draw view should be avoided and it is the reason why /* Draw view should be avoided and it is the reason why
we should hide OpenGL view while we showing the stage. * we should hide OpenGL view while we showing the stage.
*/ */
BOOL isViewHidden = [self->view isHidden]; BOOL isViewHidden = [self->view isHidden];
if ( isViewHidden == NO) if ( isViewHidden == NO)
{ [self->view setHidden:YES];
[self->view setHidden:YES];
} if (self->acceptFocus)
[self->window makeKeyAndOrderFront: nil]; [self->window makeKeyAndOrderFront: nil];
else
[self->window orderFront: nil];
[self->view setHidden:isViewHidden]; [self->view setHidden:isViewHidden];
/* /*
* After hiding we cease to be first responder. * After hiding we cease to be first responder.
*/ */
@ -498,6 +503,16 @@ clutter_stage_osx_set_user_resizable (ClutterStageWindow *stage_window,
CLUTTER_OSX_POOL_RELEASE(); CLUTTER_OSX_POOL_RELEASE();
} }
static void
clutter_stage_osx_set_accept_focus (ClutterStageWindow *stage_window,
gboolean accept_focus)
{
CLUTTER_OSX_POOL_ALLOC();
ClutterStageOSX *self = CLUTTER_STAGE_OSX (stage_window);
self->acceptFocus = !!accept_focus;
CLUTTER_OSX_POOL_RELEASE();
}
static void static void
clutter_stage_window_iface_init (ClutterStageWindowIface *iface) clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
{ {
@ -512,6 +527,7 @@ clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
iface->resize = clutter_stage_osx_resize; iface->resize = clutter_stage_osx_resize;
iface->set_cursor_visible = clutter_stage_osx_set_cursor_visible; iface->set_cursor_visible = clutter_stage_osx_set_cursor_visible;
iface->set_user_resizable = clutter_stage_osx_set_user_resizable; iface->set_user_resizable = clutter_stage_osx_set_user_resizable;
iface->set_accept_focus = clutter_stage_osx_set_accept_focus;
} }
/*************************************************************************/ /*************************************************************************/
@ -534,6 +550,7 @@ 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;
} }
static void static void

View File

@ -65,6 +65,8 @@ struct _ClutterStageOSX
gint requisition_height; gint requisition_height;
ClutterStageState stage_state; ClutterStageState stage_state;
gboolean acceptFocus;
}; };
struct _ClutterStageOSXClass struct _ClutterStageOSXClass