[sawfish] make 9 mousebutton support optional



commit d2aa096c691d221ad67f289c3a44d991beb6ed4e
Author: Christopher Roy Bratusek <chris nanolx org>
Date:   Tue Nov 17 18:58:59 2009 +0100

    make 9 mousebutton support optional

 ChangeLog     |    9 +++++++++
 config.h.in   |    3 +++
 configure.in  |   17 +++++++++++++++++
 man/news.texi |    9 ---------
 src/keys.c    |   18 ++++++++++++++++++
 src/keys.h    |    5 +++++
 6 files changed, 52 insertions(+), 9 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9bd16b5..594bc63 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-11-17  Christopher Bratusek <zanghar freenet de>
+	* src/keys.[ch]: reverted merge of mouse branch
+
+	* man/news.texi: updated
+
+	* configure.in: added --with-nine-mousebuttons to make 9 button support
+			optional, enabled by default, configures ending message
+			shows how many buttons are configured to be supported
+
 2009-11-14  Christopher Bratusek <zanghar freenet de>
 	* lisp/sawfish/wm/user.jl
 	* lisp/sawfish/wm/workspace.jl: removed display-message-with-timeout
diff --git a/config.h.in b/config.h.in
index 615489a..cdf1df3 100644
--- a/config.h.in
+++ b/config.h.in
@@ -54,6 +54,9 @@
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
+/* Support for 9 Mouse Buttons */
+#undef HAVE_NINE_MOUSEBUTTONS
+
 /* Have pango */
 #undef HAVE_PANGO
 
diff --git a/configure.in b/configure.in
index 7376a9d..225bbd6 100644
--- a/configure.in
+++ b/configure.in
@@ -261,6 +261,19 @@ if test "$with_gdk_pixbuf" = "no"; then
 			  ,AC_MSG_ERROR([cannot locate imlib1 library]))
 fi
 
+dnl Check wether to add 9 mouse buttons support
+
+AC_ARG_WITH(nine-mousebuttons,
+	    [ --with-nine-mousebuttons	Add support for mouse-buttons 6 - 9
+	     --without-nine-mouse-buttons], [], [with_nine_mbtns=yes])
+
+if test "$with_nine_mbtns" = "yes"; then
+	AC_DEFINE(HAVE_NINE_MOUSEBUTTONS, 1, [Support for 9 Mouse Buttons])
+	MOUSE_BUTTONS="9"
+else
+	MOUSE_BUTTONS="5"
+fi
+
 dnl Check wether to install mo files
 
 AC_ARG_WITH(nls,
@@ -465,6 +478,10 @@ echo "
 
   == == == == == == == == == == == == ==
 
+  mouse:	$MOUSE_BUTTONS buttons supported
+
+  == == == == == == == == == == == == ==
+
   image loader:	$IMAGE_LOADER
 
   == == == == == == == == == == == == ==
diff --git a/man/news.texi b/man/news.texi
index 1de4c4e..8cf57e4 100644
--- a/man/news.texi
+++ b/man/news.texi
@@ -223,15 +223,6 @@ changes.
 @item @code{raise-lower-button}, a button to perform various raising and lowering actions on a window
 @end itemize
 @end itemize
- item Removed Features:
- itemize @minus
-
- item Built-in support for mouse-buttons 6 to 9 is dropped
-
-X.Org/XF86 Headers only include up to Button5. Our previous support for button 6 to 9 is hackish, and dropped, though technically more are possible.
-A way to bind a command to button > 5 in Sawfish is described in our Wiki. [Timo Korvola]
- end itemize
-
 @item Widget Transistion:
 @itemize @minus
 
diff --git a/src/keys.c b/src/keys.c
index f4d3c64..17d5fce 100644
--- a/src/keys.c
+++ b/src/keys.c
@@ -97,7 +97,11 @@ DEFSYM(super_keysyms, "super-keysyms");
 static void grab_keymap_event (repv km, long code, long mods, bool grab);
 static void grab_all_keylist_events (repv map, bool grab);
 
+#ifdef HAVE_NINE_MOUSEBUTTONS
 static int all_buttons[9] = { Button1, Button2, Button3, Button4, Button5, Button6, Button7, Button8, Button9 };
+#else
+static int all_buttons[5] = { Button1, Button2, Button3, Button4, Button5 };
+#endif
 
 /* locks: currently LockMask, num_lock, and scroll_lock */
 static int total_lock_combs, all_lock_mask;
@@ -262,6 +266,7 @@ translate_event(unsigned long *code, unsigned long *mods, XEvent *xev)
 	case Button5:
 	    *mods |= Button5Mask;
 	    break;
+#ifdef HAVE_NINE_MOUSEBUTTONS
 	case Button6:
 	    *mods |= Button6Mask;
 	    break;
@@ -274,6 +279,7 @@ translate_event(unsigned long *code, unsigned long *mods, XEvent *xev)
 	case Button9:
 	    *mods |= Button9Mask;
 	    break;
+#endif
 	}
 	ret = TRUE;
 	break;
@@ -345,10 +351,12 @@ translate_event_to_x_button (repv ev, unsigned int *button, unsigned int *state)
 	    { Button3, Button3Mask },
 	    { Button4, Button4Mask },
 	    { Button5, Button5Mask },
+#ifdef HAVE_NINE_MOUSEBUTTONS
 	    { Button6, Button6Mask },
 	    { Button7, Button7Mask },
 	    { Button8, Button8Mask },
 	    { Button9, Button9Mask },
+#endif
 	    { 0, 0 }
 	};
 	int i;
@@ -670,10 +678,12 @@ static struct key_def default_mods[] = {
     { "Button3",  Button3Mask },
     { "Button4",  Button4Mask },
     { "Button5",  Button5Mask },
+#ifdef HAVE_NINE_MOUSEBUTTONS
     { "Button6",  Button6Mask },
     { "Button7",  Button7Mask },
     { "Button8",  Button8Mask },
     { "Button9",  Button9Mask },
+#endif
     { "Any",      EV_MOD_ANY },
     { "Release",  EV_MOD_RELEASE },
     { 0, 0 }
@@ -1706,7 +1716,11 @@ grab_event (Window grab_win, repv ev)
 	    {
 		/* sawfish treats mouse buttons as modifiers, not as
 		   codes, so for us AnyModifier includes all buttons.. */
+#ifdef HAVE_NINE_MOUSEBUTTONS
 		for (i = 0; i < 9; i++)
+#else
+		for (i = 0; i < 5; i++)
+#endif
 		{
 		    XGrabButton (dpy, all_buttons[i], AnyModifier,
 				 grab_win, False, POINTER_GRAB_EVENTS,
@@ -1758,7 +1772,11 @@ ungrab_event (Window grab_win, repv ev)
 	    }
 	    else
 	    {
+#ifdef HAVE_NINE_MOUSEBUTTONS
 		for (i = 0; i < 9; i++)
+#else
+		for (i = 0; i < 5; i++)
+#endif
 		    XUngrabButton (dpy, all_buttons[i], AnyModifier, grab_win);
 	    }
 	}
diff --git a/src/keys.h b/src/keys.h
index c6b0395..f9d7006 100644
--- a/src/keys.h
+++ b/src/keys.h
@@ -71,6 +71,7 @@ enum {
     EV_VIRT_MOD_MASK = 0x0ff00000
 };
 
+#ifdef HAVE_NINE_MOUSEBUTTONS
 /* Support for buttons 6, 7, 8 and 9.
 
    <X11/X.h> doesn't define these, even though XFree supports them.. */
@@ -122,6 +123,10 @@ enum {
 			     | Button4Mask | Button5Mask | Button6Mask \
 			     | Button7Mask | Button8Mask | Button9Mask)
 #endif
+#else
+# define EV_MOD_BUTTON_MASK (Button1Mask | Button2Mask | Button3Mask \
+			     | Button4Mask | Button5Mask)
+#endif
 
 /* In key maps, a `key' is (COMMAND . EVENT) */
 



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