mousetweaks r194 - in trunk: . src



Author: gerdk
Date: Mon Jun 23 22:08:29 2008
New Revision: 194
URL: http://svn.gnome.org/viewvc/mousetweaks?rev=194&view=rev

Log:
2008-06-23 Gerd Kohlberger <gerdk svn gnome org>

	* src/mt-common.c: Fix compiler warnings
	* src/mt-main.c: (main): Report at-spi leaks if there are any.
	(within_tolerance): rename function to below_threshold and
	remove sqrt() and pow() calls.



Modified:
   trunk/ChangeLog
   trunk/src/mt-common.c
   trunk/src/mt-main.c

Modified: trunk/src/mt-common.c
==============================================================================
--- trunk/src/mt-common.c	(original)
+++ trunk/src/mt-common.c	Mon Jun 23 22:08:29 2008
@@ -30,12 +30,12 @@
     gint ret;
 
     dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR,
-				     GTK_BUTTONS_NONE, primary);
+				     GTK_BUTTONS_NONE, "%s", primary);
     gtk_window_set_title (GTK_WINDOW (dialog), g_get_application_name ());
     gtk_window_set_icon_name (GTK_WINDOW (dialog), MT_ICON_NAME);
     gtk_window_set_keep_above (GTK_WINDOW (dialog), TRUE);
     gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-					      secondary);
+					      "%s", secondary);
     switch (type) {
     case MT_MESSAGE_QUESTION:
 	g_object_set (dialog, "message-type", GTK_MESSAGE_QUESTION, NULL);

Modified: trunk/src/mt-main.c
==============================================================================
--- trunk/src/mt-main.c	(original)
+++ trunk/src/mt-main.c	Mon Jun 23 22:08:29 2008
@@ -96,13 +96,14 @@
 }
 
 static inline gboolean
-within_tolerance (MTClosure *mt, gint x, gint y)
+below_threshold (MTClosure *mt, gint x, gint y)
 {
-    gdouble distance;
+    gint dx, dy;
 
-    distance = sqrt(pow(x - mt->pointer_x, 2.) + pow(y - mt->pointer_y, 2.));
+    dx = x - mt->pointer_x;
+    dy = y - mt->pointer_y;
 
-    return distance < mt->threshold;
+    return (dx * dx + dy * dy) < (mt->threshold * mt->threshold);
 }
 
 static gboolean
@@ -110,10 +111,10 @@
 {
     gint gd, i, dx, dy;
 
-    dx = ABS(x - mt->pointer_x);
-    dy = ABS(y - mt->pointer_y);
+    dx = ABS (x - mt->pointer_x);
+    dy = ABS (y - mt->pointer_y);
 
-    if (within_tolerance (mt, x, y))
+    if (below_threshold (mt, x, y))
 	return FALSE;
 
     /* find direction */
@@ -265,7 +266,7 @@
     MTClosure *mt = data;
 
     if (mt->dwell_enabled) {
-	if (!within_tolerance (mt, event->detail1, event->detail2) &&
+	if (!below_threshold (mt, event->detail1, event->detail2) &&
 	    !mt->dwell_gesture_started) {
 	    mt->pointer_x = (gint) event->detail1;
 	    mt->pointer_y = (gint) event->detail2;
@@ -283,7 +284,7 @@
 	}
     }
     if (mt_timer_is_running (mt->delay_timer)) {
-	if (!within_tolerance (mt, event->detail1, event->detail2)) {
+	if (!below_threshold (mt, event->detail1, event->detail2)) {
 	    mt_timer_stop (mt->delay_timer);
 	    mt_cursor_manager_restore_all (mt_cursor_manager_get_default ());
 	}
@@ -347,7 +348,7 @@
     return TRUE;
 }
 
-void
+static void
 mt_update_cursor (MtCursor *cursor, MtTimer *timer, gdouble time)
 {
     guchar *image;
@@ -669,6 +670,7 @@
 	MtCursorManager *manager;
 	AccessibleEventListener *bl, *ml;
 	gint spi_status;
+	gint spi_leaks;
 
 	if (mt_pidfile_create () < 0)
 	    return 1;
@@ -686,6 +688,7 @@
 	if (!mt)
 	    goto FINISH;
 
+	spi_leaks = 0;
 	spi_status = SPI_init ();
 	if (!accessibility_enabled (mt, spi_status)) {
 	    mt_closure_free (mt);
@@ -747,11 +750,14 @@
 	    AccessibleEventListener_unref (bl);
 	    SPI_deregisterGlobalEventListenerAll (ml);
 	    AccessibleEventListener_unref (ml);
-	    SPI_exit ();
+	    spi_leaks = SPI_exit ();
 	    mt_closure_free (mt);
 	FINISH:
 	    mt_pidfile_remove ();
 	    g_object_unref (program);
+
+	if (spi_leaks)
+	    g_warning ("AT-SPI reported %i leaks", spi_leaks);
     }
     return 0;
 }



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