From: Marco Peereboom Date: Mon, 8 Aug 2011 22:41:51 +0000 (+0000) Subject: Add a fake mouse button 2 press for mouse starved machines and xterm X-Git-Url: https://jasonwoof.com/gitweb/?a=commitdiff_plain;h=5d36a5c683aec0e180b5c03bc132a55b2cf8c47b;p=spectrwm.git Add a fake mouse button 2 press for mouse starved machines and xterm convenience. So now one can paste using M-v. --- diff --git a/scrotwm.1 b/scrotwm.1 index a8cfac6..1053b90 100644 --- 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: diff --git a/scrotwm.c b/scrotwm.c index 227c3f4..09f2529 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -87,6 +87,7 @@ static const char *cvstag = #include #include #include +#include #ifdef __OSX__ #include @@ -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(); diff --git a/scrotwm.conf b/scrotwm.conf index 4d272a5..d67087e 100644 --- a/scrotwm.conf +++ b/scrotwm.conf @@ -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