[maemo-commits] [maemo-commits] r17198 - in projects/haf/trunk/libmatchbox2: . matchbox/core tests

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Fri Jan 16 06:57:07 EET 2009
Author: tthurman
Date: 2009-01-16 06:57:03 +0200 (Fri, 16 Jan 2009)
New Revision: 17198

Modified:
   projects/haf/trunk/libmatchbox2/ChangeLog
   projects/haf/trunk/libmatchbox2/matchbox/core/mb-window-manager.c
   projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-client-base.c
   projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-client.c
   projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-client.h
   projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-stack.c
   projects/haf/trunk/libmatchbox2/tests/test-transience.c
Log:
	* matchbox/core/mb-wm-client-base.c: remove irrelevant stacking
	  according to stanza 4 of bug #96965.
	* matchbox/core/mb-wm-client.[ch]: add
	  mb_wm_client_get_next_focused_client() and
          mb_wm_client_get_last_focused_transient(); remove the corresponding
	  attributes of MBWindowManagerClient according to stanzas 1 and 2
	  of bug #96965.
	* matchbox/core/mb-window-manager.c: rewrite anywhere which used the
          removed attributes of MBWindowManager to use the new methods.
	  mb_wm_unfocus_client() does not show the desktop if a client cannot
	  be focussed, in case we have another client on top which can,
	  according to stanzas 1 and 2 of bug #96965.
	* matchbox/core/mb-wm-stack.c: mb_wm_stack_dump() should always dump.
	* tests/test-transience.c: regularise test to use Hildon window types
	  (but this could still be improved since it checks focus rather
	   than stacking as stuch; correctness of changes above was checked
	   using debug print statements).
         Closes #96965.



Modified: projects/haf/trunk/libmatchbox2/ChangeLog
===================================================================
--- projects/haf/trunk/libmatchbox2/ChangeLog	2009-01-15 16:53:23 UTC (rev 17197)
+++ projects/haf/trunk/libmatchbox2/ChangeLog	2009-01-16 04:57:03 UTC (rev 17198)
@@ -1,3 +1,25 @@
+2009-01-15  Thomas Thurman  <thomas.thurman at collabora.co.uk>
+
+	* matchbox/core/mb-wm-client-base.c: remove irrelevant stacking
+	  according to stanza 4 of bug #96965.
+	* matchbox/core/mb-wm-client.[ch]: add
+	  mb_wm_client_get_next_focused_client() and
+          mb_wm_client_get_last_focused_transient(); remove the corresponding
+	  attributes of MBWindowManagerClient according to stanzas 1 and 2
+	  of bug #96965.
+	* matchbox/core/mb-window-manager.c: rewrite anywhere which used the
+          removed attributes of MBWindowManager to use the new methods.
+	  mb_wm_unfocus_client() does not show the desktop if a client cannot
+	  be focussed, in case we have another client on top which can,
+	  according to stanzas 1 and 2 of bug #96965.
+	* matchbox/core/mb-wm-stack.c: mb_wm_stack_dump() should always dump.
+	* tests/test-transience.c: regularise test to use Hildon window types
+	  (but this could still be improved since it checks focus rather
+	   than stacking as stuch; correctness of changes above was checked
+	   using debug print statements).
+
+         Closes #96965.
+
 2009-01-15  Kimmo Hämäläinen  <kimmo.hamalainen at nokia.com>
 
 	Patch from Laszlo Pere:

Modified: projects/haf/trunk/libmatchbox2/matchbox/core/mb-window-manager.c
===================================================================
--- projects/haf/trunk/libmatchbox2/matchbox/core/mb-window-manager.c	2009-01-15 16:53:23 UTC (rev 17197)
+++ projects/haf/trunk/libmatchbox2/matchbox/core/mb-window-manager.c	2009-01-16 04:57:03 UTC (rev 17198)
@@ -1180,21 +1180,6 @@
    */
   mb_wm_client_detransitise (client);
 
-  next_focused = client->next_focused_client;
-  mb_wm_stack_enumerate (wm, c)
-    {
-      /*
-       * Must avoid circular dependcy here
-       */
-      if (c->next_focused_client == client)
-	{
-	  if (c != next_focused)
-	    c->next_focused_client = next_focused;
-	  else
-	    c->next_focused_client = NULL;
-	}
-    }
-
 #if ENABLE_COMPOSITE
   if (mb_wm_comp_mgr_enabled (wm->comp_mgr))
     {
@@ -1796,7 +1781,7 @@
   Bool was_desktop;
   Bool is_desktop;
   MBWindowManagerClient * c_focus = c;
-  MBWindowManagerClient * trans;
+  MBWindowManagerClient * trans, *last_focused_transient;
 
   if (c == NULL)
     return False;
@@ -1836,15 +1821,12 @@
 
   mb_wm_client_show (c);
 
-  /* If the next focused client after this one is transient for it,
-   * activate it instead
-   */
-  if (c->last_focused_transient &&
-      c->last_focused_transient->transient_for == c)
-    {
-      c_focus = c->last_focused_transient;
-    }
+  last_focused_transient = mb_wm_client_get_last_focused_transient (c);
 
+  if (last_focused_transient) {
+    c_focus = last_focused_transient;
+  }
+
   mb_wm_focus_client (wm, c_focus);
   mb_wm_client_stack (c, 0);
 
@@ -1942,16 +1924,20 @@
 static Bool
 mb_wm_focus_client (MBWindowManager *wm, MBWindowManagerClient *c)
 {
-  MBWindowManagerClient * client = c;
+  MBWindowManagerClient *client = c,
+                        *last_focused_transient;
+ 
+  last_focused_transient = mb_wm_client_get_last_focused_transient (c);
 
   /*
-   * The last focused transient for this client is modal, we try to focus
+   * If the last focused transient for this client is modal, we try to focus
    * the transient rather than the client itself
    */
-  if (c->last_focused_transient &&
-      mb_wm_client_is_modal (c->last_focused_transient))
+
+  if (last_focused_transient &&
+      mb_wm_client_is_modal (last_focused_transient))
     {
-      client = c->last_focused_transient;
+      client = last_focused_transient;
     }
 
   /*
@@ -2009,20 +1995,6 @@
 
 	  while (trans_new->transient_for)
 	    trans_new = trans_new->transient_for;
-
-	  client->next_focused_client = NULL;
-
-	  /*
-	   * Are we both transient for the same thing ?
-	   */
-	  if (trans_new && trans_new == trans_old)
-	    client->next_focused_client = wm->focused_client;
-
-	  /* From regular dialog to transient for root dialogs */
-	  if (MB_WM_IS_CLIENT_DIALOG (client) &&
-	      !client->transient_for &&
-	      MB_WM_IS_CLIENT_DIALOG (wm->focused_client))
-	    client->next_focused_client = wm->focused_client;
 	}
 
       wm->focused_client = client;
@@ -2040,10 +2012,7 @@
   if (client != wm->focused_client)
     return;
 
-  /*
-   * Remove this client from any other's next_focused_client
-   */
-  next = client->next_focused_client;
+  next = mb_wm_client_get_next_focused_client (client);
 
   if (!next && wm->stack_top)
     {
@@ -2060,10 +2029,6 @@
     }
 
   wm->focused_client = NULL;
-
-  /* Show the desktop if we cannot focus @next. */
-  if (next && !mb_wm_focus_client (wm, next))
-    mb_wm_handle_show_desktop (wm, True);
 }
 
 void

Modified: projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-client-base.c
===================================================================
--- projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-client-base.c	2009-01-15 16:53:23 UTC (rev 17197)
+++ projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-client-base.c	2009-01-16 04:57:03 UTC (rev 17198)
@@ -288,12 +288,6 @@
 
   mb_wm_util_list_foreach (t, (MBWMListForEachCB)mb_wm_client_stack,
 			   (void*)flags);
-  for (li = t; li; li = li->next)
-    if (li->data == client->wmref->focused_client)
-      {
-        mb_wm_stack_move_top ((MBWindowManagerClient *)li->data);
-        break;
-      }
 
   mb_wm_util_list_free (t);
 }

Modified: projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-client.c
===================================================================
--- projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-client.c	2009-01-15 16:53:23 UTC (rev 17197)
+++ projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-client.c	2009-01-16 04:57:03 UTC (rev 17198)
@@ -447,18 +447,6 @@
   if (klass->focus)
     ret = klass->focus(client);
 
-  if (ret)
-    {
-      /*
-       * If this client is transient, store it with the parent; if it is not
-       * transient, reset the last transient field
-       */
-      if (client->transient_for)
-	client->transient_for->last_focused_transient = client;
-      else
-	client->last_focused_transient = NULL;
-    }
-
   return ret;
 }
 
@@ -616,11 +604,50 @@
   transient->transient_for = NULL;
 
   client->transients = mb_wm_util_list_remove(client->transients, transient);
+}
 
-  if (client->last_focused_transient == transient)
-    client->last_focused_transient = transient->next_focused_client;
+/**
+ * Returns the client next above the given client in the
+ * stacking order.  Returns NULL if the client does not
+ * exist or is the topmost client.
+ */
+MBWindowManagerClient*
+mb_wm_client_get_next_focused_client (MBWindowManagerClient *client)
+{
+  MBWindowManagerClient *c;
+  gboolean get_this_one = FALSE;
+
+  /* enumerate goes from bottom to top, as opposed to enumerate_reverse
+   * which goes from top to bottom.
+   */
+  mb_wm_stack_enumerate (client->wmref, c)
+    {
+      if (get_this_one)
+        return c;
+      else if (c == client)
+        get_this_one = TRUE;
+    }
+
+  return NULL; /* oops, fell off the end. */
 }
 
+/**
+ * Returns the transient of client "client" which was most recently
+ * focused (i.e. which is closest to the top, in our model).
+ * Returns NULL if there are no transients for the given client.
+ */
+MBWindowManagerClient*
+mb_wm_client_get_last_focused_transient (MBWindowManagerClient *client)
+{
+  MBWindowManagerClient *result=NULL, *c;
+
+  mb_wm_stack_enumerate (client->wmref, c)
+      if (c->transient_for == client)
+        result = c;
+
+  return result;
+}
+
 MBWMList*
 mb_wm_client_get_transients (MBWindowManagerClient *client)
 {

Modified: projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-client.h
===================================================================
--- projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-client.h	2009-01-15 16:53:23 UTC (rev 17197)
+++ projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-client.h	2009-01-16 04:57:03 UTC (rev 17198)
@@ -150,13 +150,11 @@
   MBWMClientLayoutHints        layout_hints;
 
   MBWindowManagerClient       *stacked_above, *stacked_below;
-  MBWindowManagerClient       *next_focused_client;
 
   MBGeometry frame_geometry;  /* FIXME: in ->priv ? */
   MBWMList                    *decor;
   MBWMList                    *transients;
   MBWindowManagerClient       *transient_for;
-  MBWindowManagerClient       *last_focused_transient;
 
   int                          skip_unmaps;
 
@@ -294,6 +292,12 @@
 mb_wm_client_remove_transient (MBWindowManagerClient *client,
 			       MBWindowManagerClient *transient);
 
+MBWindowManagerClient*
+mb_wm_client_get_next_focused_client (MBWindowManagerClient *client);
+
+MBWindowManagerClient*
+mb_wm_client_get_last_focused_transient (MBWindowManagerClient *client);
+
 MBWMList*
 mb_wm_client_get_transients (MBWindowManagerClient *client);
 

Modified: projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-stack.c
===================================================================
--- projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-stack.c	2009-01-15 16:53:23 UTC (rev 17197)
+++ projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-stack.c	2009-01-16 04:57:03 UTC (rev 17198)
@@ -37,11 +37,12 @@
 void
 mb_wm_stack_dump (MBWindowManager *wm)
 {
-#if (MBWM_WANT_DEBUG)
+//#if (MBWM_WANT_DEBUG)
+#if 1
   MBWindowManagerClient *client;
   MBWMStackLayerType     stacking_layer;
 
-  fprintf(stderr, "\n==== window stack =====\n");
+  g_warning ("\n==== window stack =====\n");
 
   mb_wm_stack_enumerate_reverse (wm, client)
     {
@@ -62,7 +63,7 @@
 
       stacking_layer = mb_wm_client_get_stacking_layer (client);
 
-      fprintf(stderr, "%s XID: %lx NAME: %s, type %d, layer %d\n",
+      g_warning ("%s XID: %lx NAME: %s, type %d, layer %d\n",
 	      prefix,
 	      MB_WM_CLIENT_XWIN(client),
 	      client->window->name ? client->window->name : "unknown",
@@ -70,7 +71,7 @@
 	      stacking_layer);
     }
 
-  fprintf(stderr, "======================\n\n");
+  g_warning ("======================\n\n");
 #endif
 }
 

Modified: projects/haf/trunk/libmatchbox2/tests/test-transience.c
===================================================================
--- projects/haf/trunk/libmatchbox2/tests/test-transience.c	2009-01-15 16:53:23 UTC (rev 17197)
+++ projects/haf/trunk/libmatchbox2/tests/test-transience.c	2009-01-16 04:57:03 UTC (rev 17198)
@@ -23,15 +23,18 @@
 #include <gtk/gtk.h>
 #include <gdk/gdkx.h>
 
-GtkWidget *a, *b, *c;
+#include "hildon.h"
 
+GtkWidget *a;
+HildonDialog *b, *c;
+
 static char current_window (void)
 {
-	if (gtk_window_has_toplevel_focus (GTK_WINDOW (a)))
+	if (a && gtk_window_has_toplevel_focus (GTK_WINDOW (a)))
 		return 'a';
-	else if (gtk_window_has_toplevel_focus (GTK_WINDOW (b)))
+	else if (b && gtk_window_has_toplevel_focus (GTK_WINDOW (b)))
 		return 'b';
-	else if (gtk_window_has_toplevel_focus (GTK_WINDOW (c)))
+	else if (c && gtk_window_has_toplevel_focus (GTK_WINDOW (c)))
 		return 'c';
 	else
 		return '?';
@@ -45,37 +48,43 @@
 	switch (count++)
 	{
 		case 0:
-			a = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-			gtk_widget_show_all (a);
-			g_warning ("Opened one window a");
+			a = hildon_window_new ();
+			gtk_window_set_title ( GTK_WINDOW (a), "a (should have two transients)");
+			gtk_widget_show_all (GTK_WIDGET (a));
+			g_warning ("Opened a window 'a'");
 			expecting = 'a';
 			break;
-			
+
 		case 2:
-			b = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-			gtk_widget_show_all (b);
-			gtk_window_set_transient_for (GTK_WINDOW (a), GTK_WINDOW (b));
-			g_warning ("Opened another window b, and set 'a' transient to 'b'");
+			b = HILDON_DIALOG (hildon_dialog_new ());
+			gtk_window_set_transient_for (GTK_WINDOW (b), GTK_WINDOW (a));
+			gtk_window_set_title ( GTK_WINDOW (b), "b (should be transient to a)");
+			gtk_widget_show_all (GTK_WIDGET (b));
+			g_warning ("Opened another window 'b' and set it transient to 'a'");
 			expecting = 'b';
 			break;
 
+
 		case 4:
-			c = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-			gtk_widget_show_all (c);
-			gtk_window_set_transient_for (GTK_WINDOW (c), GTK_WINDOW (b));
-			g_warning ("Opened a third window c, and set 'c' transient to 'b'");
+			c = HILDON_DIALOG (hildon_dialog_new ());
+			gtk_window_set_title (GTK_WINDOW (c), "c (should also be transient to a)");
+			gtk_window_set_transient_for (GTK_WINDOW (c), GTK_WINDOW (a));
+			gtk_widget_show_all (GTK_WIDGET (c));
+			g_warning ("Opened a third window 'c', and set 'c' transient to 'a'");
 			expecting = 'c';
 			break;
-	
+
 		case 6:
-			gtk_widget_hide_all (c);
+			gtk_object_destroy (GTK_OBJECT (c)); c = NULL;
 
-			g_warning ("Hidden that third window 'c'; focus should now pass to the other transient, 'a'");
-			expecting = 'a';
+			g_warning ("Destroyed that third window 'c'; focus should now pass to the other transient, 'b'");
+			expecting = 'b';
 			break;
 
 		case 8:
 			g_warning ("Pass.");
+			gtk_object_destroy (GTK_OBJECT (a));  a = NULL;
+			gtk_object_destroy (GTK_OBJECT (b));  b = NULL;
 			gtk_main_quit ();
 			break;
 
@@ -85,13 +94,13 @@
 			else
 			{
 				g_warning ("Fail: %c is focussed but we expected %c.", current_window (),
-					expecting);
-				gtk_main_quit ();
+						expecting);
+				//	gtk_main_quit ();
 			}
 	}
 }
 
-int
+	int
 main (int argc, char **argv)
 {
 


More information about the maemo-commits mailing list