diff --git a/Makefile b/Makefile index 07b2c5b..b844e7e 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ include config.mk -SRC = atoms.c drw.c dwm.c services/datetime.c services/status.c util.c +SRC = atoms.c drw.c dwm.c services/datetime.c services/status.c settings.c util.c OBJ = ${SRC:.c=.o} all: options dwm diff --git a/config.def.h b/config.def.h index b045474..35559ed 100644 --- a/config.def.h +++ b/config.def.h @@ -5,7 +5,6 @@ static const unsigned int borderpx = 2; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ -static const int focusonwheel = 1; static const char *fonts[] = { "monospace:size=10" }; static const char dmenufont[] = "monospace:size=10"; static const char col_gray1[] = "#222222"; diff --git a/dwm.c b/dwm.c index 6cd5548..42b9eda 100644 --- a/dwm.c +++ b/dwm.c @@ -45,6 +45,7 @@ #include "drw.h" #include "services/datetime.h" #include "services/status.h" +#include "settings.h" #include "util.h" /* macros */ @@ -468,7 +469,7 @@ buttonpress(XEvent *e) click = ClkRootWin; /* focus monitor if necessary */ if ((m = wintomon(ev->window)) && m != selmon - && (focusonwheel || (ev->button != Button4 && ev->button != Button5))) { + && (settings_get_focus_on_wheel() || (ev->button != Button4 && ev->button != Button5))) { unfocus(selmon->sel, 1); selmon = m; focus(NULL); @@ -493,7 +494,7 @@ buttonpress(XEvent *e) else click = ClkWinTitle; } else if ((c = wintoclient(ev->window))) { - if (focusonwheel || (ev->button != Button4 && ev->button != Button5)) + if (settings_get_focus_on_wheel() || (ev->button != Button4 && ev->button != Button5)) focus(c); XAllowEvents(dpy, ReplayPointer, CurrentTime); click = ClkClientWin; diff --git a/settings.c b/settings.c new file mode 100644 index 0000000..f035d0e --- /dev/null +++ b/settings.c @@ -0,0 +1,13 @@ +#include "settings.h" + +static bool focus_on_wheel = true; + +bool settings_get_focus_on_wheel() +{ + return focus_on_wheel; +} + +void settings_set_focus_on_wheel(const bool new_focus_on_wheel) +{ + focus_on_wheel = new_focus_on_wheel; +} diff --git a/settings.h b/settings.h new file mode 100644 index 0000000..09ae635 --- /dev/null +++ b/settings.h @@ -0,0 +1,9 @@ +#ifndef _SETTINGS_H +#define _SETTINGS_H + +#include + +bool settings_get_focus_on_wheel(); +void settings_set_focus_on_wheel(bool new_focus_on_wheel); + +#endif // _SETTINGS_H