Description: Automatically generated patches until 20041213-9
 * Makefile tweak to link math library
Author: Barak A. Pearlmutter <bap@debian.org>
Last-Update: 2011-11-13

--- gromit-20041213.orig/gromit.c
+++ gromit-20041213/gromit.c
@@ -29,6 +29,8 @@
 #include <math.h>
 #include <stdlib.h>
 
+int debug = 0;
+
 #include "paint_cursor.xbm"
 #include "paint_cursor_mask.xbm"
 #include "erase_cursor.xbm"
@@ -93,6 +95,7 @@ typedef struct
   GdkPixmap   *pixmap;
   GdkDisplay  *display;
   GdkScreen   *screen;
+  gboolean     xinerama;
   GdkWindow   *root;
   gchar       *hot_keyval;
   guint        hot_keycode;
@@ -403,29 +406,6 @@ gromit_acquire_grab (GromitData *data)
 }
 
 
-void
-gromit_toggle_grab (GromitData *data)
-{
-  if (data->hard_grab)
-    gromit_release_grab (data);
-  else
-    gromit_acquire_grab (data);
-}
-
-
-void
-gromit_clear_screen (GromitData *data)
-{
-  gdk_gc_set_foreground (data->shape_gc, data->transparent);
-  gdk_draw_rectangle (data->shape, data->shape_gc, 1,
-                      0, 0, data->width, data->height);
-  gtk_widget_shape_combine_mask (data->win, data->shape, 0,0);
-  if (!data->hard_grab)
-    gromit_hide_window (data);
-  data->painted = 0;
-}
-
-
 gint
 reshape (gpointer user_data)
 {
@@ -449,6 +429,32 @@ reshape (gpointer user_data)
 
 
 void
+gromit_toggle_grab (GromitData *data)
+{
+  if (data->hard_grab) {
+    gtk_timeout_remove (data->timeout_id);
+    gromit_release_grab (data);
+  } else {
+    data->timeout_id = gtk_timeout_add (20, reshape, data);
+    gromit_acquire_grab (data);
+  }
+}
+
+
+void
+gromit_clear_screen (GromitData *data)
+{
+  gdk_gc_set_foreground (data->shape_gc, data->transparent);
+  gdk_draw_rectangle (data->shape, data->shape_gc, 1,
+                      0, 0, data->width, data->height);
+  gtk_widget_shape_combine_mask (data->win, data->shape, 0,0);
+  if (!data->hard_grab)
+    gromit_hide_window (data);
+  data->painted = 0;
+}
+
+
+void
 gromit_select_tool (GromitData *data, GdkDevice *device, guint state)
 {
   guint buttons = 0, modifier = 0, len = 0;
@@ -527,6 +533,15 @@ gromit_draw_line (GromitData *data, gint
                   gint x2, gint y2)
 {
   GdkRectangle rect;
+  static gint prev_x1=0, prev_y1=0, prev_x2=0, prev_y2=0;
+
+  if (debug) fprintf(stderr, "line (%d,%d) (%d,%d)\n", x1, y1, x2, y2);
+
+  // strange left-corner line bugfix
+  if (x1) prev_x1 = x1; else x1 = prev_x1;
+  if (y1) prev_y1 = y1; else y1 = prev_y1;
+  if (x2) prev_x2 = x2; else x2 = prev_x2;
+  if (y2) prev_y2 = y2; else y2 = prev_y2;
 
   rect.x = MIN (x1,x2) - data->maxwidth / 2;
   rect.y = MIN (y1,y2) - data->maxwidth / 2;
@@ -731,7 +746,7 @@ paintto (GtkWidget *win,
                                 &coords, &nevents);
 
   /* g_printerr ("Got %d coords\n", nevents); */
-  if (coords)
+  if (!data->xinerama && nevents > 0)
     {
       for (i=0; i < nevents; i++)
         {
@@ -991,10 +1006,10 @@ parse_name (GScanner *scanner)
         {
           if (token == G_TOKEN_SYMBOL)
             {
-              if ((guint) scanner->value.v_symbol < 11)
-                 buttons |= 1 << ((guint) scanner->value.v_symbol - 1);
+              if ((gulong) scanner->value.v_symbol < 11)
+                 buttons |= 1 << ((gulong) scanner->value.v_symbol - 1);
               else
-                 modifier |= 1 << ((guint) scanner->value.v_symbol - 11);
+                 modifier |= 1 << ((gulong) scanner->value.v_symbol - 11);
             }
           else if (token == G_TOKEN_INT)
             {
@@ -1043,9 +1058,17 @@ parse_config (GromitData *data)
 
   if (file < 0)
     {
-      g_printerr ("Could not open %s: %s\n", filename, g_strerror (errno));
+      /* try global config file */
       g_free (filename);
-      return;
+      filename = g_strdup ("/etc/gromit/gromitrc");
+      file = open (filename, O_RDONLY);
+
+      if (file < 0)
+        {
+          g_printerr ("Could not open %s: %s\n", filename, g_strerror (errno));
+          g_free (filename);
+          return;
+        }
     }
 
   scanner = g_scanner_new (NULL);
@@ -1152,7 +1175,7 @@ parse_config (GromitData *data)
                 {
                   if (token == G_TOKEN_SYMBOL)
                     {
-                      if ((guint) scanner->value.v_symbol == 1)
+                      if ((gulong) scanner->value.v_symbol == 1)
                         {
                           token = g_scanner_get_next_token (scanner);
                           if (token != G_TOKEN_EQUAL_SIGN)
@@ -1168,7 +1191,7 @@ parse_config (GromitData *data)
                             }
                           width = (guint) (scanner->value.v_float + 0.5);
                         }
-                      else if ((guint) scanner->value.v_symbol == 2)
+                      else if ((gulong) scanner->value.v_symbol == 2)
                         {
                           token = g_scanner_get_next_token (scanner);
                           if (token != G_TOKEN_EQUAL_SIGN)
@@ -1207,7 +1230,7 @@ parse_config (GromitData *data)
                             }
                           color = NULL;
                         }
-                      else if ((guint) scanner->value.v_symbol == 3)
+                      else if ((gulong) scanner->value.v_symbol == 3)
                         {
                           token = g_scanner_get_next_token (scanner);
                           if (token != G_TOKEN_EQUAL_SIGN)
@@ -1306,6 +1329,7 @@ setup_client_app (GromitData *data)
 {
   data->display = gdk_display_get_default ();
   data->screen = gdk_display_get_default_screen (data->display);
+  data->xinerama = gdk_screen_get_n_monitors (data->screen) > 1;
   data->root = gdk_screen_get_root_window (data->screen);
   data->width = gdk_screen_get_width (data->screen);
   data->height = gdk_screen_get_height (data->screen);
@@ -1420,7 +1444,7 @@ setup_main_app (GromitData *data, gboole
   data->painted = 0;
   gromit_hide_window (data);
 
-  data->timeout_id = gtk_timeout_add (20, reshape, data);
+  /* data->timeout_id = gtk_timeout_add (20, reshape, data); */
   data->coordlist = NULL;
   data->modified = 0;
 
@@ -1529,7 +1553,6 @@ app_parse_args (int argc, char **argv, G
    gchar    *arg;
    gboolean  wrong_arg = FALSE;
    gboolean  activate = FALSE;
-   gboolean  dump = FALSE;
 
    data->hot_keyval = "Pause";
    data->hot_keycode = 0;
@@ -1545,7 +1568,7 @@ app_parse_args (int argc, char **argv, G
        else if (strcmp (arg, "-d") == 0 ||
                 strcmp (arg, "--debug") == 0)
          {
-           dump = TRUE;
+           debug += 1;
          }
        else if (strcmp (arg, "-k") == 0 ||
                 strcmp (arg, "--key") == 0)
@@ -1579,13 +1602,13 @@ app_parse_args (int argc, char **argv, G
          }
        else
          {
-           g_printerr ("Unknown Option: \"%s\"\n", arg);
+           g_printerr ("Unknown Option for Gromit startup: \"%s\"\n", arg);
            wrong_arg = TRUE;
          }
 
        if (!wrong_arg)
          {
-          if (dump)
+          if (debug >= 2)
             {
               g_printerr ("\n-----------------------------\n");
               g_hash_table_foreach (data->tool_config, parse_print_help, NULL);
@@ -1594,7 +1617,7 @@ app_parse_args (int argc, char **argv, G
          }
        else
          {
-           g_printerr ("Please see the Gromit README for the correct usage\n");
+           g_printerr ("Please see the Gromit manpage for the correct usage\n");
            exit (1);
          }
      }
@@ -1641,7 +1664,7 @@ main_client (int argc, char **argv, Grom
          }
        else
          {
-           g_printerr ("Unknown Option: \"%s\"\n", arg);
+           g_printerr ("Unknown Option to control a running Gromit process: \"%s\"\n", arg);
            wrong_arg = TRUE;
          }
 
@@ -1653,7 +1676,7 @@ main_client (int argc, char **argv, Grom
          }
        else
          {
-           g_printerr ("Please see the Gromit README for the correct usage\n");
+           g_printerr ("Please see the Gromit manpage for the correct usage\n");
            return 1;
          }
      }
--- gromit-20041213.orig/Makefile
+++ gromit-20041213/Makefile
@@ -1,10 +1,18 @@
 all: gromit
 
-proptest: proptest.c
-	gcc -o proptest proptest.c `gtk-config --libs --cflags`
+CPPFLAGS += -DG_DISABLE_DEPRECATED
+CPPFLAGS += -DGDK_PIXBUF_DISABLE_DEPRECATED
+# CPPFLAGS += -DGDK_DISABLE_DEPRECATED
+CPPFLAGS += -DPANGO_DISABLE_DEPRECATED
+CPPFLAGS += -DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE
 
-propertywatch: propertywatch.c
-	gcc -o propertywatch propertywatch.c `gtk-config --libs --cflags`
+CPPFLAGS += $(shell pkg-config --cflags-only-I gtk+-2.0 x11)
 
-gromit: gromit.c Makefile
-	gcc -DG_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DPANGO_DISABLE_DEPRECATED -DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE -o gromit gromit.c -Wall `pkg-config --libs --cflags gtk+-2.0`
+CFLAGS += -Wall -Wno-pointer-sign
+CFLAGS += -O2
+CFLAGS += -g
+
+CFLAGS += $(shell pkg-config --cflags-only-other gtk+-2.0 x11)
+
+LOADLIBES += $(shell pkg-config --libs gtk+-2.0 x11)
+LOADLIBES += -lm
