JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
Add a fake mouse button 2 press for mouse starved machines and xterm
authorMarco Peereboom <marco@conformal.com>
Mon, 8 Aug 2011 22:41:51 +0000 (22:41 +0000)
committerMarco Peereboom <marco@conformal.com>
Mon, 8 Aug 2011 22:41:51 +0000 (22:41 +0000)
convenience.  So now one can paste using M-v.

scrotwm.1
scrotwm.c
scrotwm.conf

index a8cfac6..1053b90 100644 (file)
--- a/scrotwm.1
+++ b/scrotwm.1
@@ -405,7 +405,9 @@ iconify
 .It Cm M-S-w
 uniconify
 .It Cm M-S-r
-toggle always_raised
+always_raise
+.It Cm M-v
+button2
 .El
 .Pp
 The action names and descriptions are listed below:
@@ -513,6 +515,8 @@ Minimize (unmap) currently focused window.
 Maximize (map) window returned by dmenu selection.
 .It Cm always_raise
 When set tiled windows are allowed to obscure floating windows.
+.It Cm button2
+Fake a middle mouse button click (mouse button 2).
 .El
 .Pp
 Custom bindings in the configuration file are specified as follows:
index 227c3f4..09f2529 100644 (file)
--- a/scrotwm.c
+++ b/scrotwm.c
@@ -87,6 +87,7 @@ static const char     *cvstag =
 #include <X11/Xproto.h>
 #include <X11/Xutil.h>
 #include <X11/extensions/Xrandr.h>
+#include <X11/extensions/XTest.h>
 
 #ifdef __OSX__
 #include <osx.h>
@@ -3064,6 +3065,14 @@ send_to_ws(struct swm_region *r, union arg *args)
 }
 
 void
+pressbutton(struct swm_region *r, union arg *args)
+{
+fprintf(stderr, "%d\n", args->id);
+       XTestFakeButtonEvent(display, args->id, True, CurrentTime);
+       XTestFakeButtonEvent(display, args->id, False, CurrentTime);
+}
+
+void
 raise_toggle(struct swm_region *r, union arg *args)
 {
        if (r && r->ws == NULL)
@@ -3562,6 +3571,7 @@ enum keyfuncid {
        kf_iconify,
        kf_uniconify,
        kf_raise_toggle,
+       kf_button2,
        kf_dumpwins, /* MUST BE LAST */
        kf_invalid
 };
@@ -3639,6 +3649,7 @@ struct keyfunc {
        { "iconify",            iconify,        {0} },
        { "uniconify",          uniconify,      {0} },
        { "raise_toggle",       raise_toggle,   {0} },
+       { "button2",            pressbutton,    {2} },
        { "dumpwins",           dumpwins,       {0} }, /* MUST BE LAST */
        { "invalid key func",   NULL,           {0} },
 };
@@ -4231,6 +4242,7 @@ setup_keys(void)
        setkeybinding(MODKEY,           XK_w,           kf_iconify,     NULL);
        setkeybinding(MODKEY|ShiftMask, XK_w,           kf_uniconify,   NULL);
        setkeybinding(MODKEY|ShiftMask, XK_r,           kf_raise_toggle,NULL);
+       setkeybinding(MODKEY,           XK_v,           kf_button2,     NULL);
 #ifdef SWM_DEBUG
        setkeybinding(MODKEY|ShiftMask, XK_d,           kf_dumpwins,    NULL);
 #endif
@@ -6195,7 +6207,6 @@ main(int argc, char *argv[])
        setup_ewmh();
        /* set some values to work around bad programs */
        workaround();
-
        /* grab existing windows (before we build the bars) */
        grab_windows();
 
index 4d272a5..d67087e 100644 (file)
@@ -117,6 +117,7 @@ dialog_ratio                = 0.6
 #bind[iconify]         = MOD+w
 #bind[uniconify]       = MOD+Shift+w
 #bind[raise_toggle]    = MOD+Shift+r
+#bind[button2]         = MOD+v
 
 # quirks
 # remove with: quirk[class:name] = NONE