dvtm

dynamic virtual terminal manager - with my changes
git clone https://pi.duncano.de/git/dvtm.git
Log | Files | Refs | README | LICENSE

commit 5bb0fa919bca92b917e237a0aee70ed6b1074682
parent 1167b9201e610c8014fba3a247865df8256bd39b
Author: Marc Andre Tanner <mat@brain-dump.org>
Date:   Thu, 26 May 2011 20:20:40 +0200

Improve mouse event enabling/disabling

Disabling mouse support at runtime should now immediately
allow text selection under X (without the need to hold SHIFT
down).

Signed-off-by: Marc Andre Tanner <mat@brain-dump.org>

Diffstat:
config.h | 2++
mouse.c | 21++++++++++++---------
2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/config.h b/config.h @@ -130,6 +130,8 @@ static const ColorRule colorrules[] = { * REPORT_MOUSE_POSITION report mouse movement */ +#define ENABLE_MOUSE true /* whether to enable mouse events by default */ + Button buttons[] = { { BUTTON1_CLICKED, { mouse_focus, { NULL } } }, { BUTTON1_DOUBLE_CLICKED, { mouse_fullscreen, { "[ ]" } } }, diff --git a/mouse.c b/mouse.c @@ -1,5 +1,5 @@ static Client *msel = NULL; -static bool mouse_events_enabled = true; +static bool mouse_events_enabled = ENABLE_MOUSE; static void mouse_focus(const char *args[]) { @@ -60,11 +60,9 @@ handle_mouse() { madtty_mouse(msel->term, event.x - msel->x, event.y - msel->y, event.bstate); - if (mouse_events_enabled) { - for (i = 0; i < countof(buttons); i++) { - if (event.bstate & buttons[i].mask) - buttons[i].action.cmd(buttons[i].action.args); - } + for (i = 0; i < countof(buttons); i++) { + if (event.bstate & buttons[i].mask) + buttons[i].action.cmd(buttons[i].action.args); } msel = NULL; @@ -72,13 +70,18 @@ handle_mouse() { static void mouse_setup() { - mmask_t mask = BUTTON1_CLICKED | BUTTON2_CLICKED; - for (unsigned int i = 0; i < countof(buttons); i++) - mask |= buttons[i].mask; + mmask_t mask = 0; + + if (mouse_events_enabled) { + mask = BUTTON1_CLICKED | BUTTON2_CLICKED; + for (unsigned int i = 0; i < countof(buttons); i++) + mask |= buttons[i].mask; + } mousemask(mask, NULL); } static void mouse_toggle() { mouse_events_enabled = !mouse_events_enabled; + mouse_setup(); }