From 19ff11ac933cbfcc1f87c5914d36a85ee014f8e9 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 25 Jan 2012 21:24:47 +0000 Subject: [PATCH 1/7] stage: Add state tracking State changes on the Stage are currently deferred to the windowing system backends, but the code is generally the same, and it should be abstracted neatly inside the Stage class itself. There's also the extra caveat for backends that state changes on a Stage must also emit a ClutterEvent of type CLUTTER_STAGE_STATE, a requirement that needlessly complicates the backend code. --- clutter/clutter-stage-private.h | 7 ++ clutter/clutter-stage.c | 121 +++++++++++++++++++++++++++----- 2 files changed, 111 insertions(+), 17 deletions(-) diff --git a/clutter/clutter-stage-private.h b/clutter/clutter-stage-private.h index a4f9ef54f..d2c7f7845 100644 --- a/clutter/clutter-stage-private.h +++ b/clutter/clutter-stage-private.h @@ -109,6 +109,13 @@ ClutterActor * _clutter_stage_get_drag_actor (ClutterStage *sta void _clutter_stage_remove_drag_actor (ClutterStage *stage, ClutterInputDevice *device); +ClutterStageState _clutter_stage_get_state (ClutterStage *stage); +gboolean _clutter_stage_is_activated (ClutterStage *stage); +gboolean _clutter_stage_is_fullscreen (ClutterStage *stage); +gboolean _clutter_stage_update_state (ClutterStage *stage, + ClutterStageState unset_state, + ClutterStageState set_state); + G_END_DECLS #endif /* __CLUTTER_STAGE_PRIVATE_H__ */ diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index 85fe3da17..8cd091bb7 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -121,32 +121,33 @@ struct _ClutterStagePrivate /* the stage implementation */ ClutterStageWindow *impl; - ClutterColor color; - ClutterPerspective perspective; - CoglMatrix projection; - CoglMatrix inverse_projection; - CoglMatrix view; - float viewport[4]; - ClutterFog fog; + ClutterColor color; + ClutterPerspective perspective; + CoglMatrix projection; + CoglMatrix inverse_projection; + CoglMatrix view; + float viewport[4]; - gchar *title; - ClutterActor *key_focused_actor; + ClutterFog fog; - GQueue *event_queue; + gchar *title; + ClutterActor *key_focused_actor; - ClutterStageHint stage_hints; + GQueue *event_queue; - gint picks_per_frame; + ClutterStageHint stage_hints; - GArray *paint_volume_stack; + gint picks_per_frame; - ClutterPlane current_clip_planes[4]; + GArray *paint_volume_stack; - GList *pending_queue_redraws; + ClutterPlane current_clip_planes[4]; - ClutterPickMode pick_buffer_mode; + GList *pending_queue_redraws; - CoglFramebuffer *active_framebuffer; + ClutterPickMode pick_buffer_mode; + + CoglFramebuffer *active_framebuffer; GHashTable *devices; @@ -159,6 +160,8 @@ struct _ClutterStagePrivate gulong redraw_count; #endif /* CLUTTER_ENABLE_DEBUG */ + ClutterStageState current_state; + guint relayout_pending : 1; guint redraw_pending : 1; guint is_fullscreen : 1; @@ -4397,3 +4400,87 @@ _clutter_stage_remove_drag_actor (ClutterStage *stage, if (g_hash_table_size (drag_actors) == 0) g_object_set_data (G_OBJECT (stage), "__clutter_stage_drag_actors", NULL); } + +/*< private > + * _clutter_stage_get_state: + * @stage: a #ClutterStage + * + * Retrieves the current #ClutterStageState flags associated to the @stage. + * + * Return value: a bitwise OR of #ClutterStageState flags + */ +ClutterStageState +_clutter_stage_get_state (ClutterStage *stage) +{ + return stage->priv->current_state; +} + +/*< private > + * _clutter_stage_is_activated: + * @stage: a #ClutterStage + * + * Checks whether the @stage state includes %CLUTTER_STAGE_STATE_ACTIVATED. + * + * Return value: %TRUE if the @stage is active + */ +gboolean +_clutter_stage_is_activated (ClutterStage *stage) +{ + return (stage->priv->current_state & CLUTTER_STAGE_STATE_ACTIVATED) != 0; +} + +/*< private > + * _clutter_stage_is_fullscreen: + * @stage: a #ClutterStage + * + * Checks whether the @stage state includes %CLUTTER_STAGE_STATE_FULLSCREEN. + * + * Return value: %TRUE if the @stage is fullscreen + */ +gboolean +_clutter_stage_is_fullscreen (ClutterStage *stage) +{ + return (stage->priv->current_state & CLUTTER_STAGE_STATE_FULLSCREEN) != 0; +} + +/*< private > + * _clutter_stage_update_state: + * @stage: a #ClutterStage + * @unset_flags: flags to unset + * @set_flags: flags to set + * + * Updates the state of @stage, by unsetting the @unset_flags and setting + * the @set_flags. + * + * If the stage state has been changed, this function will queue a + * #ClutterEvent of type %CLUTTER_STAGE_STATE. + * + * Return value: %TRUE if the state was updated, and %FALSE otherwise + */ +gboolean +_clutter_stage_update_state (ClutterStage *stage, + ClutterStageState unset_flags, + ClutterStageState set_flags) +{ + ClutterStageState new_state; + ClutterEvent *event; + + new_state = stage->priv->current_state; + new_state |= set_flags; + new_state &= ~unset_flags; + + if (new_state == stage->priv->current_state) + return FALSE; + + event = clutter_event_new (CLUTTER_STAGE_STATE); + clutter_event_set_stage (event, stage); + + event->stage_state.new_state = new_state; + event->stage_state.changed_mask = new_state ^ stage->priv->current_state; + + stage->priv->current_state = new_state; + + _clutter_event_push (event, FALSE); + + return TRUE; +} From 2c9a693c14fb97dfb091ff00109e084de4b9caca Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 25 Jan 2012 21:25:59 +0000 Subject: [PATCH 2/7] osx: Use the Stage state tracking --- clutter/osx/clutter-stage-osx.c | 60 +++++++++++++-------------------- clutter/osx/clutter-stage-osx.h | 2 -- 2 files changed, 23 insertions(+), 39 deletions(-) diff --git a/clutter/osx/clutter-stage-osx.c b/clutter/osx/clutter-stage-osx.c index c93c066c4..8363ea3ec 100644 --- a/clutter/osx/clutter-stage-osx.c +++ b/clutter/osx/clutter-stage-osx.c @@ -50,12 +50,6 @@ G_DEFINE_TYPE_WITH_CODE (ClutterStageOSX, G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_STAGE_WINDOW, clutter_stage_window_iface_init)) -/* FIXME: this should be in clutter-stage.c */ -static void -clutter_stage_osx_state_update (ClutterStageOSX *self, - ClutterStageState unset_flags, - ClutterStageState set_flags); - static ClutterActor * clutter_stage_osx_get_wrapper (ClutterStageWindow *stage_window); @@ -87,7 +81,7 @@ clutter_stage_osx_get_wrapper (ClutterStageWindow *stage_window); CLUTTER_NOTE (BACKEND, "[%p] windowShouldClose", self->stage_osx); event.type = CLUTTER_DELETE; - event.any.stage = CLUTTER_STAGE (self->stage_osx->wrapper); + event.any.stage = self->stage_osx->wrapper; clutter_event_put (&event); return NO; @@ -104,26 +98,34 @@ clutter_stage_osx_get_wrapper (ClutterStageWindow *stage_window); - (void) windowDidBecomeKey:(NSNotification*)aNotification { + ClutterStage *stage; + CLUTTER_NOTE (BACKEND, "[%p] windowDidBecomeKey", self->stage_osx); - if (self->stage_osx->stage_state & CLUTTER_STAGE_STATE_FULLSCREEN) + stage = self->stage_osx->wrapper; + + if (_clutter_stage_is_fullscreen (stage)) [self setLevel: CLUTTER_OSX_FULLSCREEN_WINDOW_LEVEL]; - clutter_stage_osx_state_update (self->stage_osx, 0, CLUTTER_STAGE_STATE_ACTIVATED); + _clutter_stage_update_state (stage, 0, CLUTTER_STAGE_STATE_ACTIVATED); } - (void) windowDidResignKey:(NSNotification*)aNotification { + ClutterStage *stage; + CLUTTER_NOTE (BACKEND, "[%p] windowDidResignKey", self->stage_osx); - if (self->stage_osx->stage_state & CLUTTER_STAGE_STATE_FULLSCREEN) + stage = self->stage_osx->wrapper; + + if (_clutter_stage_is_fullscreen (stage)) { [self setLevel: NSNormalWindowLevel]; if (!self->stage_osx->isHiding) [self orderBack: nil]; } - clutter_stage_osx_state_update (self->stage_osx, CLUTTER_STAGE_STATE_ACTIVATED, 0); + _clutter_stage_update_state (stage, CLUTTER_STAGE_STATE_ACTIVATED, 0); } - (NSSize) windowWillResize:(NSWindow *) sender toSize:(NSSize) frameSize @@ -143,7 +145,7 @@ clutter_stage_osx_get_wrapper (ClutterStageWindow *stage_window); - (void)windowDidChangeScreen:(NSNotification *)notification { - clutter_stage_ensure_redraw (CLUTTER_STAGE (self->stage_osx->wrapper)); + clutter_stage_ensure_redraw (self->stage_osx->wrapper); } @end @@ -244,28 +246,6 @@ EVENT_HANDLER(tabletProximity) @end /*************************************************************************/ -static void -clutter_stage_osx_state_update (ClutterStageOSX *self, - ClutterStageState unset_flags, - ClutterStageState set_flags) -{ - ClutterStageStateEvent event; - - event.new_state = self->stage_state; - event.new_state |= set_flags; - event.new_state &= ~unset_flags; - - if (event.new_state == self->stage_state) - return; - - event.changed_mask = event.new_state ^ self->stage_state; - - self->stage_state = event.new_state; - - event.type = CLUTTER_STAGE_STATE; - event.stage = CLUTTER_STAGE (self->wrapper); - clutter_event_put ((ClutterEvent*)&event); -} static void clutter_stage_osx_save_frame (ClutterStageOSX *self) @@ -281,7 +261,7 @@ clutter_stage_osx_set_frame (ClutterStageOSX *self) { g_assert (self->window != NULL); - if (self->stage_state & CLUTTER_STAGE_STATE_FULLSCREEN) + if (_clutter_stage_is_fullscreen (self->wrapper)) { /* Raise above the menubar (and dock) covering the whole screen. * @@ -528,11 +508,17 @@ clutter_stage_osx_set_fullscreen (ClutterStageWindow *stage_window, */ if (fullscreen) { - clutter_stage_osx_state_update (self, 0, CLUTTER_STAGE_STATE_FULLSCREEN); + _clutter_stage_update_state (CLUTTER_STAGE (self->wrapper), + 0, + CLUTTER_STAGE_STATE_FULLSCREEN); clutter_stage_osx_save_frame (self); } else - clutter_stage_osx_state_update (self, CLUTTER_STAGE_STATE_FULLSCREEN, 0); + { + _clutter_stage_update_state (CLUTTER_STAGE (self->wrapper), + CLUTTER_STAGE_STATE_FULLSCREEN, + 0); + } clutter_stage_osx_set_frame (self); diff --git a/clutter/osx/clutter-stage-osx.h b/clutter/osx/clutter-stage-osx.h index be1f338bd..cb2c1267e 100644 --- a/clutter/osx/clutter-stage-osx.h +++ b/clutter/osx/clutter-stage-osx.h @@ -65,8 +65,6 @@ struct _ClutterStageOSX gint requisition_width; gint requisition_height; - ClutterStageState stage_state; - gboolean acceptFocus; gboolean isHiding; gboolean haveRealized; From 12e4f300a7d360b4efda714ce038da7057fb3ed9 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 25 Jan 2012 21:36:55 +0000 Subject: [PATCH 3/7] x11: Use the Stage state tracking --- clutter/x11/clutter-stage-x11.c | 72 ++++++++++++--------------------- clutter/x11/clutter-stage-x11.h | 2 - 2 files changed, 26 insertions(+), 48 deletions(-) diff --git a/clutter/x11/clutter-stage-x11.c b/clutter/x11/clutter-stage-x11.c index 861b6b68e..8d301fd58 100644 --- a/clutter/x11/clutter-stage-x11.c +++ b/clutter/x11/clutter-stage-x11.c @@ -207,7 +207,7 @@ clutter_stage_x11_get_geometry (ClutterStageWindow *stage_window, geometry->x = geometry->y = 0; /* If we're fullscreen, return the size of the display. */ - if ((stage_x11->state & CLUTTER_STAGE_STATE_FULLSCREEN) && + if (_clutter_stage_is_fullscreen (stage_x11->wrapper) && stage_x11->fullscreening) { geometry->width = DisplayWidth (backend_x11->xdpy, backend_x11->xscreen_num); @@ -524,7 +524,7 @@ clutter_stage_x11_set_fullscreen (ClutterStageWindow *stage_window, if (stage == NULL || CLUTTER_ACTOR_IN_DESTRUCTION (stage)) return; - was_fullscreen = ((stage_x11->state & CLUTTER_STAGE_STATE_FULLSCREEN) != 0); + was_fullscreen = _clutter_stage_is_fullscreen (stage); is_fullscreen = !!is_fullscreen; if (was_fullscreen == is_fullscreen) @@ -681,9 +681,9 @@ clutter_stage_x11_set_accept_focus (ClutterStageWindow *stage_window, } static void -set_stage_state (ClutterStageX11 *stage_x11, - ClutterStageX11State unset_flags, - ClutterStageX11State set_flags) +set_stage_x11_state (ClutterStageX11 *stage_x11, + ClutterStageX11State unset_flags, + ClutterStageX11State set_flags) { ClutterStageX11State new_stage_state, old_stage_state; @@ -721,7 +721,7 @@ clutter_stage_x11_show (ClutterStageWindow *stage_window, CLUTTER_NOTE (BACKEND, "Mapping stage[%lu]", (unsigned long) stage_x11->xwin); - set_stage_state (stage_x11, STAGE_X11_WITHDRAWN, 0); + set_stage_x11_state (stage_x11, STAGE_X11_WITHDRAWN, 0); update_wm_hints (stage_x11); @@ -750,7 +750,7 @@ clutter_stage_x11_hide (ClutterStageWindow *stage_window) if (stage_x11->xwin != None) { if (STAGE_X11_IS_MAPPED (stage_x11)) - set_stage_state (stage_x11, 0, STAGE_X11_WITHDRAWN); + set_stage_x11_state (stage_x11, 0, STAGE_X11_WITHDRAWN); g_assert (!STAGE_X11_IS_MAPPED (stage_x11)); @@ -939,7 +939,7 @@ clutter_stage_x11_translate_event (ClutterEventTranslator *translator, /* When fullscreen, we'll keep the xwin_width/height variables to track the old size of the window and we'll assume all ConfigureNotifies constitute a size change */ - if ((stage_x11->state & CLUTTER_STAGE_STATE_FULLSCREEN)) + if (_clutter_stage_is_fullscreen (stage)) size_changed = TRUE; else if ((stage_x11->xwin_width != xevent->xconfigure.width) || (stage_x11->xwin_height != xevent->xconfigure.height)) @@ -1039,9 +1039,9 @@ clutter_stage_x11_translate_event (ClutterEventTranslator *translator, if (type != None && data != NULL) { + gboolean is_fullscreen = FALSE; Atom *atoms = (Atom *) data; gulong i; - gboolean is_fullscreen = FALSE; for (i = 0; i < n_items; i++) { @@ -1049,26 +1049,20 @@ clutter_stage_x11_translate_event (ClutterEventTranslator *translator, fullscreen_set = TRUE; } - is_fullscreen = - (stage_x11->state & CLUTTER_STAGE_STATE_FULLSCREEN); + is_fullscreen = _clutter_stage_is_fullscreen (stage_x11->wrapper); if (fullscreen_set != is_fullscreen) { + ClutterStageState new_state; + if (fullscreen_set) - stage_x11->state |= CLUTTER_STAGE_STATE_FULLSCREEN; + _clutter_stage_update_state (stage_x11->wrapper, + 0, + CLUTTER_STAGE_STATE_FULLSCREEN); else - stage_x11->state &= ~CLUTTER_STAGE_STATE_FULLSCREEN; - - stage_x11->fullscreening = fullscreen_set; - - event->any.type = CLUTTER_STAGE_STATE; - event->any.source = CLUTTER_ACTOR (stage); - event->any.stage = stage; - event->stage_state.changed_mask = - CLUTTER_STAGE_STATE_FULLSCREEN; - event->stage_state.new_state = stage_x11->state; - - res = CLUTTER_TRANSLATE_QUEUE; + _clutter_stage_update_state (stage_x11->wrapper, + CLUTTER_STAGE_STATE_FULLSCREEN, + 0); } XFree (data); @@ -1077,34 +1071,20 @@ clutter_stage_x11_translate_event (ClutterEventTranslator *translator, break; case FocusIn: - if (!(stage_x11->state & CLUTTER_STAGE_STATE_ACTIVATED)) + if (!_clutter_stage_is_activated (stage_x11->wrapper)) { - /* TODO: check the detail? */ - stage_x11->state |= CLUTTER_STAGE_STATE_ACTIVATED; - - event->type = CLUTTER_STAGE_STATE; - event->any.source = CLUTTER_ACTOR (stage); - event->any.stage = stage; - event->stage_state.changed_mask = CLUTTER_STAGE_STATE_ACTIVATED; - event->stage_state.new_state = stage_x11->state; - - res = CLUTTER_TRANSLATE_QUEUE; + _clutter_stage_update_state (stage_x11->wrapper, + 0, + CLUTTER_STAGE_STATE_ACTIVATED); } break; case FocusOut: - if (stage_x11->state & CLUTTER_STAGE_STATE_ACTIVATED) + if (_clutter_stage_is_activated (stage_x11->wrapper)) { - /* TODO: check the detail? */ - stage_x11->state &= ~CLUTTER_STAGE_STATE_ACTIVATED; - - event->any.type = CLUTTER_STAGE_STATE; - event->any.source = CLUTTER_ACTOR (stage); - event->any.stage = stage; - event->stage_state.changed_mask = CLUTTER_STAGE_STATE_ACTIVATED; - event->stage_state.new_state = stage_x11->state; - - res = CLUTTER_TRANSLATE_QUEUE; + _clutter_stage_update_state (stage_x11->wrapper, + CLUTTER_STAGE_STATE_ACTIVATED, + 0); } break; diff --git a/clutter/x11/clutter-stage-x11.h b/clutter/x11/clutter-stage-x11.h index 3e2ae2776..a605eec45 100644 --- a/clutter/x11/clutter-stage-x11.h +++ b/clutter/x11/clutter-stage-x11.h @@ -59,8 +59,6 @@ struct _ClutterStageX11 guint clipped_redraws_cool_off; - ClutterStageState state; - ClutterStageX11State wm_state; guint is_foreign_xwin : 1; From e73c2bf4ea3dcc72e32e1814e5cc6d64ed377e0f Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 26 Jan 2012 08:27:08 +0000 Subject: [PATCH 4/7] win32: Use the Stage state tracking --- clutter/win32/clutter-event-win32.c | 28 ++++++++------------------ clutter/win32/clutter-stage-win32.c | 31 +++++++++++++++-------------- clutter/win32/clutter-stage-win32.h | 1 - 3 files changed, 24 insertions(+), 36 deletions(-) diff --git a/clutter/win32/clutter-event-win32.c b/clutter/win32/clutter-event-win32.c index 197f665ad..7274c8c4d 100644 --- a/clutter/win32/clutter-event-win32.c +++ b/clutter/win32/clutter-event-win32.c @@ -412,30 +412,18 @@ clutter_win32_handle_event (const MSG *msg) case WM_ACTIVATE: if (msg->wParam == WA_INACTIVE) { - if (stage_win32->state & CLUTTER_STAGE_STATE_ACTIVATED) + if (_clutter_stage_is_activated (stage_win32->wrapper)) { - ClutterEvent *event = clutter_event_new (CLUTTER_STAGE_STATE); - - stage_win32->state &= ~CLUTTER_STAGE_STATE_ACTIVATED; - - event->any.stage = stage; - event->stage_state.changed_mask = CLUTTER_STAGE_STATE_ACTIVATED; - event->stage_state.new_state = stage_win32->state; - - take_and_queue_event (event); + _clutter_stage_update_state (stage_win32->wrapper, + CLUTTER_STAGE_STATE_ACTIVATED, + 0); } } - else if (!(stage_win32->state & CLUTTER_STAGE_STATE_ACTIVATED)) + else if (!_clutter_stage_is_activated (stage_win32->wrapper)) { - ClutterEvent *event = clutter_event_new (CLUTTER_STAGE_STATE); - - stage_win32->state |= CLUTTER_STAGE_STATE_ACTIVATED; - - event->any.stage = stage; - event->stage_state.changed_mask = CLUTTER_STAGE_STATE_ACTIVATED; - event->stage_state.new_state = stage_win32->state; - - take_and_queue_event (event); + _clutter_stage_update_state (stage_win32->wrapper, + 0, + CLUTTER_STAGE_STATE_ACTIVATED); } break; diff --git a/clutter/win32/clutter-stage-win32.c b/clutter/win32/clutter-stage-win32.c index e89c81769..ef80c764c 100644 --- a/clutter/win32/clutter-stage-win32.c +++ b/clutter/win32/clutter-stage-win32.c @@ -92,7 +92,7 @@ clutter_stage_win32_get_geometry (ClutterStageWindow *stage_window, { ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (stage_window); - if ((stage_win32->state & CLUTTER_STAGE_STATE_FULLSCREEN)) + if (_clutter_stage_is_fullscreen (stage_win32->wrapper)) { geometry->width = stage_win32->fullscreen_rect.right - stage_win32->fullscreen_rect.left; @@ -177,7 +177,7 @@ clutter_stage_win32_resize (ClutterStageWindow *stage_window, if (width != stage_win32->win_width || height != stage_win32->win_height) { /* Ignore size requests if we are in full screen mode */ - if ((stage_win32->state & CLUTTER_STAGE_STATE_FULLSCREEN) == 0) + if (!_clutter_stage_is_fullscreen (stage_win32->wrapper)) { stage_win32->win_width = width; stage_win32->win_height = height; @@ -272,7 +272,7 @@ get_window_style (ClutterStageWin32 *stage_win32) ClutterStage *wrapper = stage_win32->wrapper; /* Fullscreen mode shouldn't have any borders */ - if ((stage_win32->state & CLUTTER_STAGE_STATE_FULLSCREEN)) + if (_clutter_stage_is_fullscreen (wrapper)) return WS_POPUP; /* Otherwise it's an overlapped window but if it isn't resizable then it shouldn't have a thick frame */ @@ -323,11 +323,6 @@ clutter_stage_win32_set_fullscreen (ClutterStageWindow *stage_window, LONG old_style = GetWindowLongW (hwnd, GWL_STYLE); ClutterStageStateEvent event; - if (value) - stage_win32->state |= CLUTTER_STAGE_STATE_FULLSCREEN; - else - stage_win32->state &= ~CLUTTER_STAGE_STATE_FULLSCREEN; - if (hwnd) { /* Update the window style but preserve the visibility */ @@ -364,12 +359,18 @@ clutter_stage_win32_set_fullscreen (ClutterStageWindow *stage_window, } /* Report the state change */ - memset (&event, 0, sizeof (event)); - event.type = CLUTTER_STAGE_STATE; - event.stage = CLUTTER_STAGE (stage_win32->wrapper); - event.new_state = stage_win32->state; - event.changed_mask = CLUTTER_STAGE_STATE_FULLSCREEN; - clutter_event_put ((ClutterEvent *) &event); + if (value) + { + _clutter_stage_update_state (stage_win32->wrapper, + 0, + CLUTTER_STAGE_STATE_FULLSCREEN); + } + else + { + _clutter_stage_update_state (stage_win32->wrapper, + CLUTTER_STAGE_STATE_FULLSCREEN, + 0); + } } static ATOM @@ -431,7 +432,7 @@ clutter_stage_win32_realize (ClutterStageWindow *stage_window) /* If we're in fullscreen mode then use the fullscreen rect instead */ - if ((stage_win32->state & CLUTTER_STAGE_STATE_FULLSCREEN)) + if (_clutter_stage_is_fullscreen (stage_win32->wrapper)) { get_fullscreen_rect (stage_win32); win_xpos = stage_win32->fullscreen_rect.left; diff --git a/clutter/win32/clutter-stage-win32.h b/clutter/win32/clutter-stage-win32.h index 241893634..0aa259796 100644 --- a/clutter/win32/clutter-stage-win32.h +++ b/clutter/win32/clutter-stage-win32.h @@ -54,7 +54,6 @@ struct _ClutterStageWin32 wchar_t *wtitle; ClutterBackendWin32 *backend; - ClutterStageState state; ClutterStage *wrapper; From 8c184f53cb3d01ef8cbefbf856e173b7f6555a45 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 26 Jan 2012 08:27:25 +0000 Subject: [PATCH 5/7] gdk: Use the Stage state tracking --- clutter/gdk/clutter-event-gdk.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/clutter/gdk/clutter-event-gdk.c b/clutter/gdk/clutter-event-gdk.c index 5d8f1a781..4e0e22fb8 100644 --- a/clutter/gdk/clutter-event-gdk.c +++ b/clutter/gdk/clutter-event-gdk.c @@ -226,12 +226,10 @@ clutter_gdk_handle_event (GdkEvent *gdk_event) break; case GDK_FOCUS_CHANGE: - event = clutter_event_new (CLUTTER_STAGE_STATE); - event->stage_state.time = 0; /* XXX: there is no timestamp in this GdkEvent */ - event->stage_state.changed_mask = CLUTTER_STAGE_STATE_ACTIVATED; - event->stage_state.new_state = gdk_event->focus_change.in - ? CLUTTER_STAGE_STATE_ACTIVATED - : 0; + if (gdk_event->focus_change.in) + _clutter_stage_update_state (stage, 0, CLUTTER_STAGE_STATE_ACTIVATED); + else + _clutter_stage_update_state (stage, CLUTTER_STAGE_STATE_ACTIVATED, 0); break; case GDK_CONFIGURE: @@ -263,23 +261,15 @@ clutter_gdk_handle_event (GdkEvent *gdk_event) break; case GDK_WINDOW_STATE: - event = clutter_event_new (CLUTTER_STAGE_STATE); - event->stage_state.changed_mask = 0; - event->stage_state.new_state = 0; - if (gdk_event->window_state.changed_mask & GDK_WINDOW_STATE_WITHDRAWN) - { - event->stage_state.changed_mask |= CLUTTER_STAGE_STATE_OFFSCREEN; - event->stage_state.new_state |= (gdk_event->window_state.new_window_state & GDK_WINDOW_STATE_WITHDRAWN) - ? CLUTTER_STAGE_STATE_OFFSCREEN - : 0; - } - if (gdk_event->window_state.changed_mask & GDK_WINDOW_STATE_FULLSCREEN) { - event->stage_state.changed_mask |= CLUTTER_STAGE_STATE_FULLSCREEN; - event->stage_state.new_state |= (gdk_event->window_state.new_window_state & GDK_WINDOW_STATE_FULLSCREEN) - ? CLUTTER_STAGE_STATE_FULLSCREEN - : 0; + gboolean is_fullscreen; + + is_fullscreen = (gdk_event->window_state.new_window_state & GDK_WINDOW_STATE_FULLSCREEN) != 0; + if (is_fullscreen) + _clutter_stage_update_state (stage, 0, CLUTTER_STAGE_STATE_FULLSCREEN); + else + _clutter_stage_update_state (stage, CLUTTER_STAGE_STATE_FULLSCREEN, 0); } break; From 2b547442a373794fd0b3dbb5799ad732bf091d03 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 26 Jan 2012 08:27:39 +0000 Subject: [PATCH 6/7] wayland: Use the Stage state tracking --- .../wayland/clutter-input-device-wayland.c | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/clutter/wayland/clutter-input-device-wayland.c b/clutter/wayland/clutter-input-device-wayland.c index 1abd57ad1..af5aed286 100644 --- a/clutter/wayland/clutter-input-device-wayland.c +++ b/clutter/wayland/clutter-input-device-wayland.c @@ -211,7 +211,6 @@ clutter_wayland_handle_keyboard_focus (void *data, { ClutterInputDeviceWayland *device = data; ClutterStageCogl *stage_cogl; - ClutterEvent *event; uint32_t *k, *end; if (device->keyboard_focus) @@ -219,14 +218,9 @@ clutter_wayland_handle_keyboard_focus (void *data, stage_cogl = device->keyboard_focus; device->keyboard_focus = NULL; - event = clutter_event_new (CLUTTER_STAGE_STATE); - event->stage_state.time = _time; - event->stage_state.stage = stage_cogl->wrapper; - event->stage_state.stage = stage_cogl->wrapper; - event->stage_state.changed_mask = CLUTTER_STAGE_STATE_ACTIVATED; - event->stage_state.new_state = 0; - - _clutter_event_push (event, FALSE); + _clutter_stage_update_state (stage_cogl->wrapper, + CLUTTER_STAGE_STATE_ACTIVATED, + 0); } if (surface) @@ -234,17 +228,14 @@ clutter_wayland_handle_keyboard_focus (void *data, stage_cogl = wl_surface_get_user_data (surface); device->keyboard_focus = stage_cogl; - event = clutter_event_new (CLUTTER_STAGE_STATE); - event->stage_state.stage = stage_cogl->wrapper; - event->stage_state.changed_mask = CLUTTER_STAGE_STATE_ACTIVATED; - event->stage_state.new_state = CLUTTER_STAGE_STATE_ACTIVATED; + _clutter_stage_update_state (stage_cogl->wrapper, + 0, + CLUTTER_STAGE_STATE_ACTIVATED); end = (uint32_t *)((guint8 *)keys->data + keys->size); device->modifier_state = 0; for (k = keys->data; k < end; k++) device->modifier_state |= device->xkb->map->modmap[*k]; - - _clutter_event_push (event, FALSE); } } From 9dab33401f69c7b03c7205ab3a521ec90a98b1e7 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 26 Jan 2012 08:33:45 +0000 Subject: [PATCH 7/7] docs: Update ClutterStageState flags --- clutter/clutter-enums.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/clutter/clutter-enums.h b/clutter/clutter-enums.h index 5d6b81257..82fcf003a 100644 --- a/clutter/clutter-enums.h +++ b/clutter/clutter-enums.h @@ -742,17 +742,17 @@ typedef enum { /*< prefix=CLUTTER_SCROLL >*/ /** * ClutterStageState: * @CLUTTER_STAGE_STATE_FULLSCREEN: Fullscreen mask - * @CLUTTER_STAGE_STATE_OFFSCREEN: Offscreen mask + * @CLUTTER_STAGE_STATE_OFFSCREEN: Offscreen mask (deprecated) * @CLUTTER_STAGE_STATE_ACTIVATED: Activated mask * - * Stage state masks + * Stage state masks, used by the #ClutterEvent of type %CLUTTER_STAGE_STATE. * * Since: 0.4 */ typedef enum { - CLUTTER_STAGE_STATE_FULLSCREEN = (1<<1), - CLUTTER_STAGE_STATE_OFFSCREEN = (1<<2), - CLUTTER_STAGE_STATE_ACTIVATED = (1<<3) + CLUTTER_STAGE_STATE_FULLSCREEN = (1 << 1), + CLUTTER_STAGE_STATE_OFFSCREEN = (1 << 2), + CLUTTER_STAGE_STATE_ACTIVATED = (1 << 3) } ClutterStageState; /**