From 9521d3504d8b7a295cba52ea217f58a9417d0310 Mon Sep 17 00:00:00 2001
From: David Maciejak <david.maciejak@gmail.com>
Date: Thu, 28 Aug 2014 11:07:05 +0700
Subject: [PATCH] wmaker: make disable mouse actions a live set

This patch is allowing to enable or disable the 'disable mouse actions'
from the WPrefs app without requiring to restart the session.
---
 src/defaults.c | 4 ++--
 src/event.c    | 2 +-
 src/screen.c   | 5 -----
 3 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/src/defaults.c b/src/defaults.c
index 2b938a3..df7e919 100644
--- a/src/defaults.c
+++ b/src/defaults.c
@@ -324,8 +324,6 @@ WDefaultEntry staticOptionList[] = {
 	    &wPreferences.icon_size, getInt, NULL, NULL, NULL},
 	{"ModifierKey", "Mod1", NULL,
 	    &wPreferences.modifier_mask, getModMask, NULL, NULL, NULL},
-	{"DisableWSMouseActions", "NO", NULL,
-	    &wPreferences.disable_root_mouse, getBool, NULL, NULL, NULL},
 	{"FocusMode", "manual", seFocusModes,				/* have a problem when switching from */
 	    &wPreferences.focus_mode, getEnum, NULL, NULL, NULL},	/* manual to sloppy without restart */
 	{"NewStyle", "new", seTitlebarModes,
@@ -353,6 +351,8 @@ WDefaultEntry optionList[] = {
 	    &wPreferences.icon_yard, getEnum, setIconPosition, NULL, NULL},
 	{"IconificationStyle", "Zoom", seIconificationStyles,
 	    &wPreferences.iconification_style, getEnum, NULL, NULL, NULL},
+	{"DisableWSMouseActions", "NO", NULL,
+	    &wPreferences.disable_root_mouse, getBool, NULL, NULL, NULL},
 	{"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions,
 	    &wPreferences.mouse_button1, getEnum, NULL, NULL, NULL},
 	{"MouseMiddleButtonAction", "OpenWindowListMenu", seMouseButtonActions,
diff --git a/src/event.c b/src/event.c
index 9e41dc9..0ec1b77 100644
--- a/src/event.c
+++ b/src/event.c
@@ -745,7 +745,7 @@ static void handleButtonPress(XEvent * event)
 	wBalloonHide(scr);
 #endif
 
-	if (event->xbutton.window == scr->root_win) {
+	if (!wPreferences.disable_root_mouse && event->xbutton.window == scr->root_win) {
 		if (event->xbutton.button == Button1 && wPreferences.mouse_button1 != WA_NONE) {
 			executeButtonAction(scr, event, wPreferences.mouse_button1);
 		} else if (event->xbutton.button == Button2 && wPreferences.mouse_button2 != WA_NONE) {
diff --git a/src/screen.c b/src/screen.c
index 250f996..da578c2 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -524,11 +524,6 @@ WScreen *wScreenInit(int screen_number)
 	oldHandler = XSetErrorHandler(alreadyRunningError);
 
 	event_mask = EVENT_MASK;
-
-	if (wPreferences.disable_root_mouse) {
-		event_mask &= ~(ButtonPressMask | ButtonReleaseMask);
-	}
-
 	XSelectInput(dpy, scr->root_win, event_mask);
 
 #ifdef KEEP_XKB_LOCK_STATUS
-- 
1.8.3.2

