[clutter] x11/stage: fix multi-stage support



commit 4d42904fcc748df33adaa3b76f6d6fc664bf1842
Author: Lionel Landwerlin <llandwerlin gmail com>
Date:   Sat Mar 17 23:52:48 2012 +0000

    x11/stage: fix multi-stage support
    
    When handling Configure events from the X server we update the
    internal copy of the window size. Unfortunately we may be updating the
    wrong stage implementation because we use the one related to the event
    translator (which is the first created stage).
    
    This patch fix flickering/redrawning issues with multi-stage by
    looking for the right stage implementation associated with an XEvent.
    
    Signed-off-by: Lionel Landwerlin <lionel g landwerlin linux intel com>

 clutter/x11/clutter-stage-x11.c |   37 +++++++++++++++++++++++++------------
 1 files changed, 25 insertions(+), 12 deletions(-)
---
diff --git a/clutter/x11/clutter-stage-x11.c b/clutter/x11/clutter-stage-x11.c
index 69536fe..48d71f4 100644
--- a/clutter/x11/clutter-stage-x11.c
+++ b/clutter/x11/clutter-stage-x11.c
@@ -56,6 +56,8 @@ static ClutterStageWindowIface *clutter_stage_window_parent_iface = NULL;
 static void clutter_stage_window_iface_init     (ClutterStageWindowIface     *iface);
 static void clutter_event_translator_iface_init (ClutterEventTranslatorIface *iface);
 
+static ClutterStageCogl *clutter_x11_get_stage_window_from_window (Window win);
+
 static GHashTable *clutter_stages_by_xid = NULL;
 
 #define clutter_stage_x11_get_type      _clutter_stage_x11_get_type
@@ -927,18 +929,23 @@ clutter_stage_x11_translate_event (ClutterEventTranslator *translator,
                                    gpointer                native,
                                    ClutterEvent           *event)
 {
-  ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (translator);
-  ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (translator);
+  ClutterStageX11 *stage_x11;
+  ClutterStageCogl *stage_cogl;
   ClutterTranslateReturn res = CLUTTER_TRANSLATE_CONTINUE;
-  ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (stage_cogl->backend);
-  Window stage_xwindow = stage_x11->xwin;
+  ClutterBackendX11 *backend_x11;
+  Window stage_xwindow;
   XEvent *xevent = native;
   ClutterStage *stage;
 
-  stage = clutter_x11_get_stage_from_window (xevent->xany.window);
-  if (stage == NULL)
+  stage_cogl = clutter_x11_get_stage_window_from_window (xevent->xany.window);
+  if (stage_cogl == NULL)
     return CLUTTER_TRANSLATE_CONTINUE;
 
+  stage = stage_cogl->wrapper;
+  stage_x11 = CLUTTER_STAGE_X11 (stage_cogl);
+  backend_x11 = CLUTTER_BACKEND_X11 (stage_cogl->backend);
+  stage_xwindow = stage_x11->xwin;
+
   switch (xevent->type)
     {
     case ConfigureNotify:
@@ -1194,11 +1201,21 @@ clutter_x11_get_stage_window (ClutterStage *stage)
   return CLUTTER_STAGE_X11 (impl)->xwin;
 }
 
+static ClutterStageCogl *
+clutter_x11_get_stage_window_from_window (Window win)
+{
+  if (clutter_stages_by_xid == NULL)
+    return NULL;
+
+  return g_hash_table_lookup (clutter_stages_by_xid,
+                              GINT_TO_POINTER (win));
+}
+
 /**
  * clutter_x11_get_stage_from_window:
  * @win: an X Window ID
  *
- * Gets the stage for a particular X window.  
+ * Gets the stage for a particular X window.
  *
  * Return value: (transfer none): A #ClutterStage, or% NULL if a stage
  *   does not exist for the window
@@ -1210,11 +1227,7 @@ clutter_x11_get_stage_from_window (Window win)
 {
   ClutterStageCogl *stage_cogl;
 
-  if (clutter_stages_by_xid == NULL)
-    return NULL;
-
-  stage_cogl = g_hash_table_lookup (clutter_stages_by_xid,
-				    GINT_TO_POINTER (win));
+  stage_cogl = clutter_x11_get_stage_window_from_window (win);
 
   if (stage_cogl != NULL)
     return stage_cogl->wrapper;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]