libgtkstylus: use alt-tap for rightclick sz_152
authorGrazvydas Ignotas <notasas@gmail.com>
Tue, 16 Oct 2012 21:18:26 +0000 (00:18 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Tue, 16 Oct 2012 21:18:26 +0000 (00:18 +0300)
also add ability to configure this

recipes/libgtkstylus/files/alt_rightclick.patch [new file with mode: 0644]
recipes/libgtkstylus/libgtkstylus_0.3.bb

diff --git a/recipes/libgtkstylus/files/alt_rightclick.patch b/recipes/libgtkstylus/files/alt_rightclick.patch
new file mode 100644 (file)
index 0000000..c6d7f25
--- /dev/null
@@ -0,0 +1,69 @@
+diff -urp libgtkstylus-0.3_/tap.c libgtkstylus-0.3/tap.c
+--- libgtkstylus-0.3_/tap.c    2012-10-16 15:25:07.900784038 +0300
++++ libgtkstylus-0.3/tap.c     2012-10-16 23:48:51.280784004 +0300
+@@ -17,6 +17,7 @@
+  * Boston, MA 02111-1307, USA.
+  */
++#include <stdio.h>
+ #include <string.h>
+ #include <stdlib.h>
+@@ -102,11 +103,56 @@ filter (GdkEvent *ev, gpointer data)
+   gtk_main_do_event (ev);
+ }
++static guint modifiers = GDK_MOD1_MASK;
++static int right_pressed;
++
++static void
++filter2 (GdkEvent *ev, gpointer data)
++{
++  if (ev->type == GDK_BUTTON_PRESS 
++      && ev->button.button == 1
++      && (ev->button.state & modifiers))
++    {
++      ev->button.button = 3;
++      right_pressed = 1;
++    }
++  else if (ev->type == GDK_BUTTON_RELEASE 
++         && ev->button.button == 1 
++         && right_pressed)
++    {
++      ev->button.button = 3;
++      right_pressed = 0;
++    }
++
++  gtk_main_do_event (ev);
++}
++
+ void
+ gtk_module_init (gint *argc, gchar ***argv)
+ {
++  char buf[256];
++  int mode = 1;
++  int val;
++  char *home;
++  FILE *f;
++
+   if (getenv ("GTK_STYLUS_DO_FN"))
+     do_fn = 1;
+-  gdk_event_handler_set (filter, NULL, NULL);
++  home = getenv("XDG_CONFIG_HOME");
++  if (home == NULL)
++    home = getenv("HOME");
++  snprintf(buf, sizeof(buf), "%s/libgtkstylus.conf", home);
++  f = fopen(buf, "r");
++  if (f != NULL) {
++    while (fgets(buf, sizeof(buf), f)) {
++      if (sscanf(buf, "mode = %d", &val) == 1)
++        mode = val;
++      else if (sscanf(buf, "modifiers = %d", &val) == 1)
++        modifiers = val;
++    }
++    fclose(f);
++  }
++
++  gdk_event_handler_set (mode ? filter2 : filter, NULL, NULL);
+ }
index 5912b2d..c14a595 100644 (file)
@@ -2,12 +2,13 @@ DESCRIPTION = "GTK plugin for stylus based systems"
 SECTION = "libs"
 DEPENDS = "gtk+"
 LICENSE = "LGPL"
-PR = "r6"
+PR = "r7"
 
 inherit autotools
 
 SRC_URI = "${GPE_MIRROR}/${PN}-${PV}.tar.bz2 \
        file://makefile.patch;patch=1 \
+       file://alt_rightclick.patch;patch=1 \
        file://gtkstylus.sh"
 
 do_install_append() {