diff --git a/README.md b/README.md index 592a5b2..6c5fe63 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t ### Changelog: -2019-09-15 - Added xrdb, viewontag, urgentborder and winview patches +2019-09-15 - Added focusonclick, xrdb, viewontag, urgentborder and winview patches 2019-09-14 - Added setborderpx, selfrestart and push (no master variant), sticky and warp patches @@ -91,6 +91,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - [floatbordercolor](https://dwm.suckless.org/patches/float_border_color/) - this patch allows a different border color to be chosen for floating windows + - [focusonclick](https://dwm.suckless.org/patches/focusonclick/) + - this patch makes you switch focus only by mouse click and not sloppy (focus follows mouse pointer) + - [focusonnetactive](https://dwm.suckless.org/patches/focusonnetactive/) - by default, dwm responds to \_NET_ACTIVE_WINDOW client messages by setting the urgency bit on the named window - this patch activates the window instead diff --git a/config.def.h b/config.def.h index ea2acb8..e264434 100644 --- a/config.def.h +++ b/config.def.h @@ -1,20 +1,23 @@ /* See LICENSE file for copyright and license details. */ /* appearance */ -static const unsigned int borderpx = 1; /* border pixel of windows */ -static const unsigned int snap = 32; /* snap pixel */ +static const unsigned int borderpx = 1; /* border pixel of windows */ +static const unsigned int snap = 32; /* snap pixel */ #if VANITYGAPS_PATCH -static const unsigned int gappih = 20; /* horiz inner gap between windows */ -static const unsigned int gappiv = 10; /* vert inner gap between windows */ -static const unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */ -static const unsigned int gappov = 30; /* vert outer gap between windows and screen edge */ -static int smartgaps = 0; /* 1 means no outer gap when there is only one window */ +static const unsigned int gappih = 20; /* horiz inner gap between windows */ +static const unsigned int gappiv = 10; /* vert inner gap between windows */ +static const unsigned int gappoh = 10 /* horiz outer gap between windows and screen edge */ +static const unsigned int gappov = 30 /* vert outer gap between windows and screen edge */ +static const int smartgaps = 0; /* 1 means no outer gap when there is only one window */ #endif // VANITYGAPS_PATCH -static const int showbar = 1; /* 0 means no bar */ -static const int topbar = 1; /* 0 means bottom bar */ +static const int showbar = 1; /* 0 means no bar */ +static const int topbar = 1; /* 0 means bottom bar */ +#if FOCUSONCLICK_PATCH +static const int focusonwheel = 0; +#endif // FOCUSONCLICK_PATCH #if STATUSPADDING_PATCH -static const int horizpadbar = 2; /* horizontal padding for statusbar */ -static const int vertpadbar = 0; /* vertical padding for statusbar */ +static const int horizpadbar = 2; /* horizontal padding for statusbar */ +static const int vertpadbar = 0; /* vertical padding for statusbar */ #endif // STATUSPADDING_PATCH #if SYSTRAY_PATCH static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */ @@ -22,8 +25,8 @@ static const unsigned int systrayspacing = 2; /* systray spacing */ static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/ static const int showsystray = 1; /* 0 means no systray */ #endif // SYSTRAY_PATCH -static const char *fonts[] = { "monospace:size=10" }; -static const char dmenufont[] = "monospace:size=10"; +static const char *fonts[] = { "monospace:size=10" }; +static const char dmenufont[] = "monospace:size=10"; static char normfgcolor[] = "#bbbbbb"; static char normbgcolor[] = "#222222"; diff --git a/dwm.c b/dwm.c index 0793985..093a9f8 100644 --- a/dwm.c +++ b/dwm.c @@ -265,7 +265,9 @@ static void detachstack(Client *c); static Monitor *dirtomon(int dir); static void drawbar(Monitor *m); static void drawbars(void); +#if !FOCUSONCLICK_PATCH static void enternotify(XEvent *e); +#endif // FOCUSONCLICK_PATCH static void expose(XEvent *e); static void focus(Client *c); static void focusin(XEvent *e); @@ -282,7 +284,9 @@ static void killclient(const Arg *arg); static void manage(Window w, XWindowAttributes *wa); static void mappingnotify(XEvent *e); static void maprequest(XEvent *e); +#if !FOCUSONCLICK_PATCH static void motionnotify(XEvent *e); +#endif // FOCUSONCLICK_PATCH static void movemouse(const Arg *arg); static Client *nexttiled(Client *c); #if !ZOOMSWAP_PATCH @@ -360,7 +364,9 @@ static void (*handler[LASTEvent]) (XEvent *) = { [ConfigureRequest] = configurerequest, [ConfigureNotify] = configurenotify, [DestroyNotify] = destroynotify, + #if !FOCUSONCLICK_PATCH [EnterNotify] = enternotify, + #endif // FOCUSONCLICK_PATCH [Expose] = expose, [FocusIn] = focusin, [KeyPress] = keypress, @@ -369,7 +375,9 @@ static void (*handler[LASTEvent]) (XEvent *) = { #endif // COMBO_PATCH [MappingNotify] = mappingnotify, [MapRequest] = maprequest, + #if !FOCUSONCLICK_PATCH [MotionNotify] = motionnotify, + #endif // FOCUSONCLICK_PATCH [PropertyNotify] = propertynotify, #if SYSTRAY_PATCH [ResizeRequest] = resizerequest, @@ -574,7 +582,11 @@ buttonpress(XEvent *e) click = ClkRootWin; /* focus monitor if necessary */ - if ((m = wintomon(ev->window)) && m != selmon) { + if ((m = wintomon(ev->window)) && m != selmon + #if FOCUSONCLICK_PATCH + && (focusonwheel || (ev->button != Button4 && ev->button != Button5)) + #endif // FOCUSONCLICK_PATCH + ) { unfocus(selmon->sel, 1); selmon = m; focus(NULL); @@ -622,8 +634,13 @@ buttonpress(XEvent *e) click = ClkWinTitle; #endif // AWESOMEBAR_PATCH } else if ((c = wintoclient(ev->window))) { + #if FOCUSONCLICK_PATCH + if (focusonwheel || (ev->button != Button4 && ev->button != Button5)) + focus(c); + #else focus(c); restack(selmon); + #endif // FOCUSONCLICK_PATCH XAllowEvents(dpy, ReplayPointer, CurrentTime); click = ClkClientWin; } @@ -1235,6 +1252,7 @@ drawbars(void) #endif // SYSTRAY_PATCH } +#if !FOCUSONCLICK_PATCH void enternotify(XEvent *e) { @@ -1253,6 +1271,7 @@ enternotify(XEvent *e) return; focus(c); } +#endif // FOCUSONCLICK_PATCH void expose(XEvent *e) @@ -1692,6 +1711,7 @@ maprequest(XEvent *e) manage(ev->window, &wa); } +#if !FOCUSONCLICK_PATCH void motionnotify(XEvent *e) { @@ -1708,6 +1728,7 @@ motionnotify(XEvent *e) } mon = m; } +#endif // FOCUSONCLICK_PATCH void movemouse(const Arg *arg) diff --git a/patches.h b/patches.h index 5fa77b2..4bef728 100644 --- a/patches.h +++ b/patches.h @@ -21,13 +21,13 @@ /* The alpha patch adds transparency for the status bar. * https://dwm.suckless.org/patches/alpha/ */ -#define ALPHA_PATCH 1 +#define ALPHA_PATCH 0 /* This patch introduces alternative tags which can be switched on the fly for the * sole purpose of providing visual aid. * https://dwm.suckless.org/patches/alternativetags/ */ -#define ALTERNATIVE_TAGS_PATCH 1 +#define ALTERNATIVE_TAGS_PATCH 0 /* This patch prevents the focus to drift from the active fullscreen client when * using focusstack(). @@ -46,7 +46,7 @@ * This patch takes precedence over ATTACHBELOW_PATCH. * https://dwm.suckless.org/patches/attachaside/ */ -#define ATTACHASIDE_PATCH 1 +#define ATTACHASIDE_PATCH 0 /* This patch adds new clients below the selected client. * This patch takes precedence over ATTACHBOTTOM_PATCH. @@ -65,57 +65,57 @@ * than the original ~/.dwm folder. * https://dwm.suckless.org/patches/autostart/ */ -#define AUTOSTART_PATCH 1 +#define AUTOSTART_PATCH 0 /* By default, windows that are not visible when requesting a resize/move will not * get resized/moved. With this patch, they will. * https://dwm.suckless.org/patches/autoresize/ */ -#define AUTORESIZE_PATCH 1 +#define AUTORESIZE_PATCH 0 /* Enhanced taskbar that shows the titles of all visible windows in the status bar * and allows focus / hiding / unhiding of windows by clicking on the status bar. * Awesomebar takes precedence over fancybar. * https://dwm.suckless.org/patches/awesomebar/ */ -#define AWESOMEBAR_PATCH 1 +#define AWESOMEBAR_PATCH 0 /* This patch adds an iscentered rule to automatically center clients on the current monitor. * This patch takes precedence over centeredwindowname and fancybar patches. * https://dwm.suckless.org/patches/center/ */ -#define CENTER_PATCH 1 +#define CENTER_PATCH 0 /* This patch centers the WM_NAME of the currently selected window on the status bar. * Both fancybar and awesomebar patches take precedence over this patch. * https://dwm.suckless.org/patches/centeredwindowname/ */ -#define CENTEREDWINDOWNAME_PATCH 1 +#define CENTEREDWINDOWNAME_PATCH 0 /* This patch provides the ability to assign different weights to clients in their * respective stack in tiled layout. * https://dwm.suckless.org/patches/cfacts/ */ -#define CFACTS_PATCH 1 +#define CFACTS_PATCH 0 /* This patch tweaks the tagging interface so that you can select multiple tags for tag * or view by pressing all the right keys as a combo. For example to view tags 1 and 3, * hold MOD and then press and hold 1 and 3 together. * https://dwm.suckless.org/patches/combo/ */ -#define COMBO_PATCH 1 +#define COMBO_PATCH 0 /* The cyclelayouts patch lets you cycle through all your layouts. * https://dwm.suckless.org/patches/cyclelayouts/ */ -#define CYCLELAYOUTS_PATCH 1 +#define CYCLELAYOUTS_PATCH 0 /* Adds EWMH support for _NET_NUMBER_OF_DESKTOPS, _NET_CURRENT_DESKTOP, _NET_DESKTOP_NAMES * and _NET_DESKTOP_VIEWPORT, which allows for compatibility with other bars and programs * that request workspace information. For example polybar's xworkspaces module. * https://dwm.suckless.org/patches/ewmhtags/ */ -#define EWMHTAGS_PATCH 1 +#define EWMHTAGS_PATCH 0 /* This patch shows the titles of all visible windows in the status bar * (as opposed to showing only the selected one). @@ -125,16 +125,21 @@ */ #define FANCYBAR_PATCH 0 +/* Switch focus only by mouse click and not sloppy (focus follows mouse pointer). + * https://dwm.suckless.org/patches/focusonclick/ + */ +#define FOCUSONCLICK_PATCH 0 + /* This patch allows a different border color to be chosen for floating windows. * https://dwm.suckless.org/patches/float_border_color/ */ -#define FLOAT_BORDER_COLOR_PATCH 1 +#define FLOAT_BORDER_COLOR_PATCH 0 /* By default, dwm responds to _NET_ACTIVE_WINDOW client messages by setting * the urgency bit on the named window. This patch activates the window instead. * https://dwm.suckless.org/patches/focusonnetactive/ */ -#define FOCUSONNETACTIVE_PATCH 1 +#define FOCUSONNETACTIVE_PATCH 0 /* By default in dwm it is possible to make an application fullscreen, then use * the focusstack keybindings to focus on other windows beneath the current window. @@ -143,7 +148,7 @@ * in such scenarios the previous window loses fullscreen. * https://github.com/bakkeby/dwm-vanitygaps/blob/master/patches/dwm-losefullscreen-6.2.diff */ -#define LOSEFULLSCREEN_PATCH 1 +#define LOSEFULLSCREEN_PATCH 0 /* Adds rules per monitor, e.g. have default layouts per monitor. * The use case for this is if the second monitor is vertical (i.e. rotated) then @@ -151,23 +156,23 @@ * used for the main monitor. E.g. normal vertical split for main monitor and * horizontal split for the second. */ -#define MONITOR_RULES_PATCH 1 +#define MONITOR_RULES_PATCH 0 /* The pertag patch adds nmaster, mfacts and layouts per tag rather than per * monitor (default). * https://dwm.suckless.org/patches/pertag/ */ -#define PERTAG_PATCH 1 +#define PERTAG_PATCH 0 /* This controls whether or not to also store bar position on a per * tag basis, or leave it as one bar per monitor. */ -#define PERTAGBAR_PATCH 1 +#define PERTAGBAR_PATCH 0 /* This patch provides a way to move clients up and down inside the client list. * https://dwm.suckless.org/patches/push/ */ -#define PUSH_PATCH 1 +#define PUSH_PATCH 0 /* This patch provides a way to move clients up and down inside the client list, * but does not push up or down into the master area (except that it does not take @@ -181,44 +186,44 @@ * patch the mouse is warped to the nearest corner and you resize from there. * https://dwm.suckless.org/patches/resizecorners/ */ -#define RESIZECORNERS_PATCH 1 +#define RESIZECORNERS_PATCH 0 /* This patch let's you rotate through the stack using keyboard shortcuts. * https://dwm.suckless.org/patches/rotatestack/ */ -#define ROTATESTACK_PATCH 1 +#define ROTATESTACK_PATCH 0 /* This patch aves size and position of every floating window before it is forced * into tiled mode. If the window is made floating again then the old dimensions * will be restored. * https://dwm.suckless.org/patches/save_floats/ */ -#define SAVEFLOATS_PATCH 1 +#define SAVEFLOATS_PATCH 0 /* Allows restarting dwm without the dependency of an external script. * https://dwm.suckless.org/patches/selfrestart/ */ -#define SELFRESTART_PATCH 1 +#define SELFRESTART_PATCH 0 /* This patch allows border pixels to be changed during runtime. * https://dwm.suckless.org/patches/setborderpx/ */ -#define SETBORDERPX_PATCH 1 +#define SETBORDERPX_PATCH 0 /* This patch adds configuration options for horizontal and vertical padding in the status bar. * https://dwm.suckless.org/patches/statuspadding/ */ -#define STATUSPADDING_PATCH 1 +#define STATUSPADDING_PATCH 0 /* Adds toggleable keyboard shortcut to make a client 'sticky', i.e. visible on all tags. * https://dwm.suckless.org/patches/sticky/ */ -#define STICKY_PATCH 1 +#define STICKY_PATCH 0 /* The systray patch adds systray for the status bar. * https://dwm.suckless.org/patches/systray/ */ -#define SYSTRAY_PATCH 1 +#define SYSTRAY_PATCH 0 /* By default dwm allow you to set application specific rules so that you can have your browser, * for example, start up on tag 9 optionally on a given monitor when you open your browser it is @@ -231,12 +236,12 @@ * https://github.com/bakkeby/dwm-vanitygaps/blob/master/patches/dwm-switchtag-6.2.diff */ -#define SWITCHTAG_PATCH 1 +#define SWITCHTAG_PATCH 0 /* This patch allows you to move all visible windows on a monitor to an adjacent monitor. * https://github.com/bakkeby/dwm-vanitygaps/blob/master/patches/dwm-tagallmon-6.2.diff */ -#define TAGALLMON_PATCH 1 +#define TAGALLMON_PATCH 0 /* If you try to send a fullscreen window to an adjacent monitor using tagmon then * the window is moved behind the scenes, but it remains in fullscreen on the original @@ -245,35 +250,35 @@ * while remaining in fullscreen. * https://github.com/bakkeby/dwm-vanitygaps/blob/master/patches/dwm-tagmonfixfs-6.2.diff */ -#define TAGMONFIXFS_PATCH 1 +#define TAGMONFIXFS_PATCH 0 /* This patch allows you to swap all visible windows on one monitor with those of an * adjacent monitor. * https://github.com/bakkeby/dwm-vanitygaps/blob/master/patches/dwm-tagswapmon-6.2.diff */ -#define TAGSWAPMON_PATCH 1 +#define TAGSWAPMON_PATCH 0 /* Adds a new color scheme used by the (selected) window title in the bar. * https://dwm.suckless.org/patches/titlecolor/ */ -#define TITLECOLOR_PATCH 1 +#define TITLECOLOR_PATCH 0 /* This patch allows you to toggle fullscreen on and off using a single shortcut key. * https://github.com/bakkeby/dwm-vanitygaps/blob/master/patches/dwm-togglefullscreen-6.2.diff */ -#define TOGGLEFULLSCREEN_PATCH 1 +#define TOGGLEFULLSCREEN_PATCH 0 /* This patch makes "urgent" windows have different colors. * https://dwm.suckless.org/patches/urgentborder/ */ -#define URGENTBORDER_PATCH 1 +#define URGENTBORDER_PATCH 0 /* This patch adds configurable gaps between windows differentiating between outer, inner, * horizontal and vertical gaps. * https://github.com/bakkeby/dwm-vanitygaps/blob/master/patches/dwm-vanitygaps-6.2.diff * https://github.com/bakkeby/dwm-vanitygaps/blob/master/patches/dwm-vanitygaps-cfacts-6.2.diff */ -#define VANITYGAPS_PATCH 1 +#define VANITYGAPS_PATCH 0 /* Follow a window to the tag it is being moved to. * https://dwm.suckless.org/patches/viewontag/ @@ -293,42 +298,42 @@ * or Google-chrome "browser" vs "pop-up". * https://github.com/bakkeby/dwm-vanitygaps/blob/master/patches/dwm-windowrolerule-6.2.diff */ -#define WINDOWROLERULE_PATCH 1 +#define WINDOWROLERULE_PATCH 0 /* The winview patch allows switching the view to that of a given client from the all-window * view (Mod-0) using a keyboard shortcut. * http://dwm.suckless.org/patches/winview/ */ -#define WINVIEW_PATCH 1 +#define WINVIEW_PATCH 0 /* Allows dwm to read colors from xrdb (.Xresources) during runtime. Compatible with * the float border color, awesomebar, urgentborder and titlecolor patches. * https://dwm.suckless.org/patches/xrdb/ */ -#define XRDB_PATCH 1 +#define XRDB_PATCH 0 /* The zoomswap patch allows a master and a stack window to swap places * rather than every window on the screen changing position. * https://dwm.suckless.org/patches/zoomswap/ */ -#define ZOOMSWAP_PATCH 1 +#define ZOOMSWAP_PATCH 0 /* Layouts */ /* Bottomstack layout. * https://dwm.suckless.org/patches/bottomstack/ */ -#define BSTACK_LAYOUT 1 +#define BSTACK_LAYOUT 0 /* Bottomstack horizontal layout. * https://dwm.suckless.org/patches/bottomstack/ */ -#define BSTACKHORIZ_LAYOUT 1 +#define BSTACKHORIZ_LAYOUT 0 /* Centered master layout. * https://dwm.suckless.org/patches/centeredmaster/ */ -#define CENTEREDMASTER_LAYOUT 1 +#define CENTEREDMASTER_LAYOUT 0 /* Centered floating master layout. * https://dwm.suckless.org/patches/centeredmaster/ @@ -338,7 +343,7 @@ /* Deck layout. * https://dwm.suckless.org/patches/deck/ */ -#define DECK_LAYOUT 1 +#define DECK_LAYOUT 0 /* Fibonacci dwindle layout. * https://dwm.suckless.org/patches/fibonacci/ @@ -353,7 +358,7 @@ /* Flextile layout. * https://dwm.suckless.org/patches/flextile/ */ -#define FLEXTILE_LAYOUT 1 +#define FLEXTILE_LAYOUT 0 /* Gappless grid layout. * https://dwm.suckless.org/patches/gaplessgrid/ @@ -378,9 +383,9 @@ /* The default tile layout. * This can be optionally disabled in favour of other layouts. */ -#define TILE_LAYOUT 0 +#define TILE_LAYOUT 1 /* Monocle layout (default). * This can be optionally disabled in favour of other layouts. */ -#define MONOCLE_LAYOUT 0 +#define MONOCLE_LAYOUT 1