[maemo-commits] [maemo-commits] r18561 - in projects/haf/trunk/libmatchbox2: . matchbox/comp-mgr

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Mon Jun 1 13:33:13 EEST 2009
Author: kihamala
Date: 2009-06-01 13:33:02 +0300 (Mon, 01 Jun 2009)
New Revision: 18561

Modified:
   projects/haf/trunk/libmatchbox2/ChangeLog
   projects/haf/trunk/libmatchbox2/matchbox/comp-mgr/mb-wm-comp-mgr-clutter.c
   projects/haf/trunk/libmatchbox2/matchbox/comp-mgr/mb-wm-comp-mgr-clutter.h
Log:
fixes for non-composited mode: now we don't listen to damage events and
consume CPU...


Modified: projects/haf/trunk/libmatchbox2/ChangeLog
===================================================================
--- projects/haf/trunk/libmatchbox2/ChangeLog	2009-06-01 09:00:11 UTC (rev 18560)
+++ projects/haf/trunk/libmatchbox2/ChangeLog	2009-06-01 10:33:02 UTC (rev 18561)
@@ -3,6 +3,17 @@
 	* matchbox/comp-mgr/mb-wm-comp-mgr-clutter.c
 	(mb_wm_comp_mgr_clutter_handle_damage): Don't handle damage in
 	non-composited mode.
+	(mb_wm_comp_mgr_clutter_client_track_damage): New function to toggle
+	damage event subscription on/off.
+	(mb_wm_comp_mgr_clutter_map_notify_real): Call
+	mb_wm_comp_mgr_clutter_client_track_damage to setup damage tracking.
+	Tries to handle the case when damage tracking is re-enabled after a
+	pause in the tracking.
+	(mb_wm_comp_mgr_clutter_client_destroy): Call
+	mb_wm_comp_mgr_clutter_client_track_damage to tear down damage
+	tracking.
+	(mb_wm_comp_mgr_clutter_fetch_texture): Set bound=FALSE if the window
+	is invalid (allows the caller to check for success).
 
 	Release 0.2.41
 

Modified: projects/haf/trunk/libmatchbox2/matchbox/comp-mgr/mb-wm-comp-mgr-clutter.c
===================================================================
--- projects/haf/trunk/libmatchbox2/matchbox/comp-mgr/mb-wm-comp-mgr-clutter.c	2009-06-01 09:00:11 UTC (rev 18560)
+++ projects/haf/trunk/libmatchbox2/matchbox/comp-mgr/mb-wm-comp-mgr-clutter.c	2009-06-01 10:33:02 UTC (rev 18561)
@@ -207,6 +207,7 @@
     {
       g_debug ("%s: BadDrawable for %lx", __FUNCTION__,
                client->wm_client->window->xwindow);
+      cclient->priv->bound = FALSE;
       return;
     }
 
@@ -282,9 +283,7 @@
 static void
 mb_wm_comp_mgr_clutter_client_destroy (MBWMObject* obj)
 {
-  MBWMCompMgrClient        * c   = MB_WM_COMP_MGR_CLIENT (obj);
-  MBWMCompMgrClutterClient * cclient = MB_WM_COMP_MGR_CLUTTER_CLIENT (obj);
-  MBWindowManager          * wm  = c->wm;
+  MBWMCompMgrClutterClient *cclient = MB_WM_COMP_MGR_CLUTTER_CLIENT (obj);
 
   /* We just unref our actors here and clutter will free them if required */
   if (cclient->priv->actor)
@@ -330,19 +329,8 @@
     }
 
   if (cclient->priv->window_damage)
-    {
-      int err;
+    mb_wm_comp_mgr_clutter_client_track_damage (cclient, False);
 
-      /* Sing after me: "untrap" without XSync() is un*re*li*ab*le! */
-      mb_wm_util_trap_x_errors();
-      XDamageDestroy (wm->xdpy, cclient->priv->window_damage);
-      XSync (wm->xdpy, False);
-      if ((err = mb_wm_util_untrap_x_errors()) != 0)
-        g_debug ("XDamageDestroy(0x%lx) for %p: %d",
-                 cclient->priv->window_damage, c, err);
-      cclient->priv->window_damage = 0;
-    }
-
   free (cclient->priv);
   cclient->priv = NULL;
 }
@@ -809,8 +797,7 @@
   Damage                      damage;
 
   if (wm->non_redirection)
-    /* TODO: remember to refresh the client when we return to
-     * composited mode */
+    /* avoid some Clutter/EGL errors when in non-composited mode */
     return False;
 
   c = mb_wm_managed_client_from_frame (wm, de->drawable);
@@ -992,6 +979,59 @@
     }
 }
 
+/* Enable/disable damage tracking for a client */
+void
+mb_wm_comp_mgr_clutter_client_track_damage (MBWMCompMgrClutterClient *cclient,
+                                            Bool track_damage)
+{
+  MBWindowManager *wm = MB_WM_COMP_MGR_CLIENT (cclient)->wm;
+  MBWindowManagerClient *c = MB_WM_COMP_MGR_CLIENT (cclient)->wm_client;
+
+  /* printf ("%s: client win %lx\n", __func__,
+          c && c->window ? c->window->xwindow : 0); */
+
+  if (track_damage)
+    {
+      if (!cclient->priv->window_damage)
+        {
+          cclient->priv->window_damage = XDamageCreate (wm->xdpy,
+				   c->window->xwindow,
+				   XDamageReportNonEmpty);
+
+          /* re-fetch the texture if there was an old texture, because it has
+           * probably missed damage events */
+          if (cclient->priv->texture)
+            {
+              guint w, h;
+
+              mb_wm_comp_mgr_clutter_fetch_texture (
+                                MB_WM_COMP_MGR_CLIENT (cclient));
+
+              if (cclient->priv->bound)
+                {
+                  clutter_actor_get_size (cclient->priv->texture, &w, &h);
+                  clutter_x11_texture_pixmap_update_area (
+			CLUTTER_X11_TEXTURE_PIXMAP (cclient->priv->texture),
+			0, 0, w, h);
+                }
+            }
+        }
+    }
+  else if (cclient->priv->window_damage)
+    {
+      int err;
+
+      /* Sing after me: "untrap" without XSync() is un*re*li*ab*le! */
+      mb_wm_util_trap_x_errors();
+      XDamageDestroy (wm->xdpy, cclient->priv->window_damage);
+      XSync (wm->xdpy, False);
+      if ((err = mb_wm_util_untrap_x_errors()) != 0)
+        g_debug ("XDamageDestroy(0x%lx) for %p: %d",
+                 cclient->priv->window_damage, c, err);
+      cclient->priv->window_damage = 0;
+    }
+}
+
 static void
 mb_wm_comp_mgr_clutter_map_notify_real (MBWMCompMgr *mgr,
 					MBWindowManagerClient *c)
@@ -999,7 +1039,6 @@
   MBWMCompMgrClutter        * cmgr    = MB_WM_COMP_MGR_CLUTTER (mgr);
   MBWMCompMgrClient         * client  = c->cm_client;
   MBWMCompMgrClutterClient  * cclient = MB_WM_COMP_MGR_CLUTTER_CLIENT(client);
-  MBWindowManager           * wm      = client->wm;
   ClutterActor              * texture;
 #if SGX_CORRUPTION_WORKAROUND
   MBWMClientType              ctype = MB_WM_CLIENT_CLIENT_TYPE (c);
@@ -1032,9 +1071,7 @@
 
   cclient->priv->flags |= MBWMCompMgrClutterClientMapped;
 
-  cclient->priv->window_damage = XDamageCreate (wm->xdpy,
-				   c->window->xwindow,
-				   XDamageReportNonEmpty);
+  mb_wm_comp_mgr_clutter_client_track_damage (cclient, True);
 
   g_snprintf(actor_name, 64, "window_0x%lx", c->window->xwindow);
   clutter_actor_set_name(cclient->priv->actor, actor_name);
@@ -1079,7 +1116,8 @@
   clutter_actor_set_visibility_detect(texture, TRUE);
   clutter_actor_show (texture);
 
-  clutter_container_add_actor (CLUTTER_CONTAINER (cclient->priv->actor), texture);
+  clutter_container_add_actor (CLUTTER_CONTAINER (cclient->priv->actor),
+                               texture);
   /* We want to lower this below any decor */
   clutter_actor_lower_bottom(texture);
 

Modified: projects/haf/trunk/libmatchbox2/matchbox/comp-mgr/mb-wm-comp-mgr-clutter.h
===================================================================
--- projects/haf/trunk/libmatchbox2/matchbox/comp-mgr/mb-wm-comp-mgr-clutter.h	2009-06-01 09:00:11 UTC (rev 18560)
+++ projects/haf/trunk/libmatchbox2/matchbox/comp-mgr/mb-wm-comp-mgr-clutter.h	2009-06-01 10:33:02 UTC (rev 18561)
@@ -107,6 +107,10 @@
 mb_wm_comp_mgr_clutter_client_unset_flags (MBWMCompMgrClutterClient  *cclient,
 					   MBWMCompMgrClutterClientFlags flags);
 
+void
+mb_wm_comp_mgr_clutter_client_track_damage (MBWMCompMgrClutterClient *cclient,
+                                            Bool track_damage);
+
 MBWMCompMgrClutterClientFlags
 mb_wm_comp_mgr_clutter_client_get_flags (MBWMCompMgrClutterClient  *cclient);
 


More information about the maemo-commits mailing list