Create settings module

This commit is contained in:
Alex Kotov 2021-11-13 21:31:28 +05:00
parent e213029729
commit 24a42e8607
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
5 changed files with 26 additions and 4 deletions

View File

@ -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

View File

@ -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";

5
dwm.c
View File

@ -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;

13
settings.c Normal file
View File

@ -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;
}

9
settings.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef _SETTINGS_H
#define _SETTINGS_H
#include <stdbool.h>
bool settings_get_focus_on_wheel();
void settings_set_focus_on_wheel(bool new_focus_on_wheel);
#endif // _SETTINGS_H