[3ddesktop-dev] [PATCH] Alternate mouse (trivial changes)

i did a little hacking, i'm not very good at this but i did come up with a few things. how do i make a proper diff? i tried (attached files) and well, if it's not okay, i tried. really i did.

...does anyone even want it?

NEW:
--altwheel [me]
--altbuttons [me]
--dontexit [brad]

GOOD:
* 'alternate_mousewheel' option switches the direction of the mouse's scroll wheel. i'm used to "down" movement going to the right.
* 'alternate_mousebuttons' option changes the behavior of the mouse buttons. L now activates, M rotates to the workspace you were at before changing workspaces, R does the same thing as M but also activates it, button 6 goes left, button 7 goes right.
* 'disable_exit_after_goto' option will not exit the desk-changing mode of 3ddesk when --gotoleft or --gotoright are specified after changing initially. this was already in CVS, thanks to brad.


BAD:
* i made a previously-local variable global static. it's marked with a FIXME.
* there was no way i could figure out how to disable the GL visual and simply update the image stash. i got lost.


UGLY:
* my 6 lines of code, the whitespace isn't right.

IDEAS:
* when --gotoleft or --gotoright are specified, the "goto" (spinning) action should happen immediately before completely zoomed out. it would be more intuitive as such.
* interface for mattel powerglove **JOKE** when Xinerama support is in, to grab windows from one screen and drag them over to the visual display device from MINORITY REPORT movie. or PAYCHECK.



why are we setting the state to STATE_GOTO before goto_... ?


what should i do about that static variable thing... and..

Brad, would you like the actual function of [keys / mouse buttons] to be defined in a config file somewhere? (or is that bloat)


regards,


-Eric

ATTACHED: a whole bunch of patch files. implements '--altwheel' and '--altbuttons' with no change in default behavior.
Index: 3ddesk.cpp
===================================================================
RCS file: /cvsroot/desk3d/3ddesktop/3ddesk.cpp,v
retrieving revision 1.7
diff -u -r1.7 3ddesk.cpp
--- 3ddesk.cpp  8 Jan 2004 00:44:26 -0000       1.7
+++ 3ddesk.cpp  11 Jan 2004 13:21:24 -0000
@@ -58,6 +58,8 @@
             "     --gotocolumn=#    Goto specified column\n"
             "     --gotorow=#       Goto specified row\n"
             "     --dontexit        Don't exit after a goto\n"
+           "     --altwheel        Change direction of mouse wheel\n"
+           "     --altbuttons      Change function of mouse buttons\n"
             "     --stop            Stop 3ddesktop (kill 3ddeskd daemon)\n"
             "     --reload          Force a reload of 3ddesktop.conf\n\n"
         );
@@ -90,6 +92,8 @@
         {"changespeed", 1, 0, 0},
         {"zoomspeed", 1, 0, 0},
         {"dontexit", 0, 0, 0},
+       {"altwheel", 0, 0, 0},
+       {"altbuttons", 0, 0, 0},
         {0, 0, 0, 0}
     };
 
@@ -196,6 +200,12 @@
             case 17: // 'dontexit'
                 msgmgr.msg.disable_exit_after_goto = 1;
                 break;
+            case 18: // 'altwheel'
+               msgmgr.msg.alternate_mousewheel = 1;
+               break;
+           case 19: // 'altbuttons'
+               msgmgr.msg.alternate_mousebuttons = 1;
+               break;
             }
             break;
         case 'v':
Index: 3ddeskd.cpp
===================================================================
RCS file: /cvsroot/desk3d/3ddesktop/3ddeskd.cpp,v
retrieving revision 1.12
diff -u -r1.12 3ddeskd.cpp
--- 3ddeskd.cpp 10 Jan 2004 22:54:48 -0000      1.12
+++ 3ddeskd.cpp 11 Jan 2004 13:21:26 -0000
@@ -77,6 +77,7 @@
 #include <X11/extensions/xf86vmode.h>
 #include <X11/keysym.h>
 
+static  desktop_coords_t  current_coords;  // FIXME: static vars are teh evil
 
 Config *cfg;
 
@@ -948,19 +949,53 @@
 
     switch (button) {
     case 1: // left
+       if (!cfg->options->alternate_mousebuttons)
+           faces->goto_left();
+       else
+           begin_exit();
+       break;
+
+    case 7: // extra button on some mice, do we use this?
+       if (cfg->options->alternate_mousebuttons)
+           faces->goto_left();
+       break;
+
     case 5: // mouse wheel down
-        faces->goto_left();
+        if (!cfg->options->alternate_mousewheel)
+            faces->goto_left();
+        else
+            faces->goto_right();
         break;
 
     case 3: // right
+       if (!cfg->options->alternate_mousebuttons) {
+            faces->goto_right();
+       } else {
+            state = STATE_GOTO;
+            faces->goto_face(current_coords);
+           begin_exit();
+       }
+       break;
+
+    case 6: // extra button on some mice, do we use this?
+       if (cfg->options->alternate_mousebuttons)
+            faces->goto_right();
+        break;
+
     case 4: // mouse wheel up
-        faces->goto_right();
+        if (!cfg->options->alternate_mousewheel)
+            faces->goto_right();
+        else
+            faces->goto_left();
         break;
 
     case 2: // middle
-
-        begin_exit();
-
+       if (!cfg->options->alternate_mousebuttons) {
+            begin_exit();
+       } else {
+            state = STATE_GOTO;
+            faces->goto_face(current_coords);
+       }
         break;
     }
 } // END mouse_pressed
@@ -1500,6 +1535,12 @@
             if (msgmgr.msg.disable_exit_after_goto)
                 cfg->options->disable_exit_after_goto = true;
 
+           if (msgmgr.msg.alternate_mousewheel)
+               cfg->options->alternate_mousewheel = true;
+
+           if (msgmgr.msg.alternate_mousebuttons)
+               cfg->options->alternate_mousebuttons = true;
+
             // if we are asked to goto the current row and column then
             // do nothing
             if (goto_coords.column == (current_col + 1)
@@ -1655,7 +1696,7 @@
 
     desktop_coords_t  goto_coords;
     desktop_coords_t  current_count;
-    desktop_coords_t  current_coords;
+//    desktop_coords_t  current_coords;
 
     while(!quit) {
 
Index: 3ddesktop.conf
===================================================================
RCS file: /cvsroot/desk3d/3ddesktop/3ddesktop.conf,v
retrieving revision 1.8
diff -u -r1.8 3ddesktop.conf
--- 3ddesktop.conf      8 Jan 2004 23:12:41 -0000       1.8
+++ 3ddesktop.conf      11 Jan 2004 13:21:27 -0000
@@ -72,6 +72,9 @@
 #   gotocolumn  - goto desktop to the specified column
 #   gotorow     - goto desktop to the specified row
 #   dontexit    - don't exit after an automated goto operation
+#   altwheel    - mouse wheel up/down reversed
+#   altbuttons  - mouse button 1 activates, 2 goes back and exits,
+#                 3 goes back, 6 goes left, 7 goes right.
 #   linear_spacing  - space between desktops in "linear" mode (default 2.0)
 #   use_breathing   - turn on/off the ambient light dimming
 #   animation_speed - number of milliseconds between animation steps
Index: ChangeLog
===================================================================
RCS file: /cvsroot/desk3d/3ddesktop/ChangeLog,v
retrieving revision 1.6
diff -u -r1.6 ChangeLog
--- ChangeLog   22 Mar 2003 17:44:31 -0000      1.6
+++ ChangeLog   11 Jan 2004 13:21:28 -0000
@@ -1,3 +1,9 @@
+Release 0.2.6
+-------------
+ * Add option to change direction of mouse scroll wheel [Eric Shattow]
+ * Add option for alternate mouse button functionality [Eric Shattow]
+ * Add option to temporarily disable exit on gotoleft/gotoright
+
 Release 0.2.5
 -------------
  * Add option to indicate when vdesktop change happens
Index: README
===================================================================
RCS file: /cvsroot/desk3d/3ddesktop/README,v
retrieving revision 1.10
diff -u -r1.10 README
--- README      22 Mar 2003 17:44:31 -0000      1.10
+++ README      11 Jan 2004 13:21:30 -0000
@@ -235,5 +235,6 @@
 Olivier Samyn
 Marcelo Magallon
 Tilmann Bitterberg
+Eric Shattow
 
 Much thanks! (and let me know if I missed ya!)
Index: config.hpp
===================================================================
RCS file: /cvsroot/desk3d/3ddesktop/config.hpp,v
retrieving revision 1.17
diff -u -r1.17 config.hpp
--- config.hpp  8 Jan 2004 23:12:41 -0000       1.17
+++ config.hpp  11 Jan 2004 13:21:29 -0000
@@ -131,6 +131,10 @@
 
     int disable_exit_after_goto;
 
+    int alternate_mousewheel;
+
+    int alternate_mousebuttons;
+
     // ---------
     //Arrangement *arrangement;
 
@@ -187,6 +191,10 @@
 
         disable_exit_after_goto = 0;
 
+       alternate_mousewheel = 0;
+
+       alternate_mousebuttons = 0;
+
        // ----
         //arrangement = NULL;
 
@@ -456,6 +464,12 @@
             
         } else if (strcmp(option, "dontexit") == 0) {
             disable_exit_after_goto = get_boolean (value);
+
+        } else if (strcmp(option, "altwheel") == 0) {
+            alternate_mousewheel = get_boolean (value);
+
+        } else if (strcmp(option, "altbuttons") == 0) {
+            alternate_mousebuttons = get_boolean (value);
 
         } else if (strcmp(option, "glcompression") == 0) {
             glcompression = get_boolean (value);
Index: message.hpp
===================================================================
RCS file: /cvsroot/desk3d/3ddesktop/message.hpp,v
retrieving revision 1.7
diff -u -r1.7 message.hpp
--- message.hpp 10 Jan 2004 22:54:48 -0000      1.7
+++ message.hpp 11 Jan 2004 13:21:29 -0000
@@ -38,6 +38,8 @@
     float face_change_steps;
     float zoom_steps;
     int disable_exit_after_goto;
+    int alternate_mousewheel;
+    int alternate_mousebuttons;
 } threedeedesk_command_t;
 
 
@@ -79,6 +81,8 @@
         msg.face_change_steps = 0;
         msg.zoom_steps = 0;
         msg.disable_exit_after_goto = 0;
+       msg.alternate_mousewheel = 0;
+       msg.alternate_mousebuttons = 0;
     };
 
 

Other related posts: