[maemo-commits] [maemo-commits] r18089 - in projects/haf/trunk/libmatchbox2: . debian matchbox/core

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Thu Apr 16 19:01:38 EEST 2009
Author: kihamala
Date: 2009-04-16 19:01:36 +0300 (Thu, 16 Apr 2009)
New Revision: 18089

Modified:
   projects/haf/trunk/libmatchbox2/ChangeLog
   projects/haf/trunk/libmatchbox2/debian/changelog
   projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-decor.c
Log:
fix a bug


Modified: projects/haf/trunk/libmatchbox2/ChangeLog
===================================================================
--- projects/haf/trunk/libmatchbox2/ChangeLog	2009-04-16 13:50:32 UTC (rev 18088)
+++ projects/haf/trunk/libmatchbox2/ChangeLog	2009-04-16 16:01:36 UTC (rev 18089)
@@ -1,3 +1,12 @@
+2009-04-16  Kimmo Hämäläinen  <kimmo.hamalainen at nokia.com>
+
+	* matchbox/core/mb-wm-decor.c (mb_wm_decor_press_handler): Remove the
+	ButtonRelease handler if we catch ButtonRelease in the loop.
+	(mb_wm_decor_button_press_handler): Set up ButtonRelease handler to
+	catch ButtonRelease events that are caught while we spin in the main
+	loop. Also repaint the button to remove the pressed state effect if
+	the handler was called. Fixes: NB#110052
+
 2009-04-14  Kimmo Hämäläinen  <kimmo.hamalainen at nokia.com>
 
 	Release 0.2.32

Modified: projects/haf/trunk/libmatchbox2/debian/changelog
===================================================================
--- projects/haf/trunk/libmatchbox2/debian/changelog	2009-04-16 13:50:32 UTC (rev 18088)
+++ projects/haf/trunk/libmatchbox2/debian/changelog	2009-04-16 16:01:36 UTC (rev 18089)
@@ -1,3 +1,10 @@
+matchbox-window-manager-2 (0.2.33-1~unreleased) unstable; urgency=low
+
+  * Fixes: NB#110052 - Tapping on [X] icon does not always succeed in closing
+    applications
+
+ -- Kimmo Hämäläinen <kimmo.hamalainen at nokia.com>  Thu, 16 Apr 2009 18:55:46 +0300
+
 matchbox-window-manager-2 (0.2.32-1) unstable; urgency=low
 
   * Move XFlush after the corresponding XUngrabServer call.

Modified: projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-decor.c
===================================================================
--- projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-decor.c	2009-04-16 13:50:32 UTC (rev 18088)
+++ projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-decor.c	2009-04-16 16:01:36 UTC (rev 18089)
@@ -267,12 +267,11 @@
 
 	  for (;;)
 	    {
-	      /*
-	       * If we have no release_cb installed, i.e., the ButtonRelease
-	       * has already happened, quit this loop.
-	       */
-	      if (!decor->release_cb_id)
-		break;
+              if (!decor->release_cb_id)
+                {
+                  /* the handler was called while we spinned the loop */
+		  return False;
+                }
 
 	      XMaskEvent(wm->xdpy,
 			 ButtonPressMask|ButtonReleaseMask|
@@ -308,6 +307,10 @@
 		  break;
 		case ButtonRelease:
 		  {
+                    mb_wm_main_context_x_event_handler_remove (
+                                   wm->main_ctx, ButtonRelease,
+			           decor->release_cb_id);
+                    decor->release_cb_id = 0;
 		    XUngrabPointer (wm->xdpy, CurrentTime);
 		    return False;
 		  }
@@ -868,6 +871,14 @@
 			   GrabModeAsync,
 			   None, None, CurrentTime) == GrabSuccess)
 	    {
+              /* set up release handler to catch ButtonRelease while we
+               * are spinning the main loop */
+	      decor->release_cb_id = mb_wm_main_context_x_event_handler_add (
+				 wm->main_ctx,
+			         xev->subwindow,
+			         ButtonRelease,
+			         (MBWMXEventFunc)mb_wm_decor_release_handler,
+			         decor);
 	      if (button->state == MBWMDecorButtonStateInactive)
 		{
 		  button->state = MBWMDecorButtonStatePressed;
@@ -882,15 +893,34 @@
 		   * are interested in are actually intercepted here).
 		   */
 		  XSync (wm->xdpy, False);
+
 		  /*
 		   * Someone might destroy the window while we are waiting for
 		   * the events here.
 		   */
-		  if (!button->realized) {
+		  if (!button->realized)
+                  {
+                    /* if the window disappeared, ungrab was done by X.
+                       Just remove the handler */
+                    mb_wm_main_context_x_event_handler_remove (
+                                   wm->main_ctx, ButtonRelease,
+			           decor->release_cb_id);
+                    decor->release_cb_id = 0;
 		    mb_wm_object_unref (MB_WM_OBJECT(button));
 		    return False;
 		  }
 
+                  if (!decor->release_cb_id)
+                    {
+                     /* the handler was called while we spinned the loop */
+		     if (button->state == MBWMDecorButtonStatePressed)
+		       {
+                         button->state = MBWMDecorButtonStateInactive;
+                         mb_wm_theme_paint_button (wm->theme, button);
+                       }
+		     return False;
+                    }
+
 		  if (XCheckMaskEvent(wm->xdpy,
 				      ButtonPressMask|ButtonReleaseMask|
 				      PointerMotionMask|EnterWindowMask|
@@ -952,6 +982,11 @@
 			    XUngrabPointer (wm->xdpy, CurrentTime);
 			    XSync (wm->xdpy, False); /* necessary */
 
+                            mb_wm_main_context_x_event_handler_remove (
+                                   wm->main_ctx, ButtonRelease,
+			           decor->release_cb_id);
+                            decor->release_cb_id = 0;
+
 			    if (pev->x < xmin || pev->x > xmax ||
 				pev->y < ymin || pev->y > ymax)
 			      {
@@ -975,7 +1010,9 @@
 		       * No pending X event, so spin the main loop (this allows
 		       * things like timers to work.
 		       */
-		      mb_wm_main_context_spin_loop (wm->main_ctx);
+		      if (!mb_wm_main_context_spin_loop (wm->main_ctx))
+                        /* no events, sleep a while so we don't busy loop */
+                        g_usleep (1000 * 100);
 		    }
 		}
 	    }


More information about the maemo-commits mailing list