commit a9d731141e507eb942990019fd512b0e8bf8feff
parent b8cbdaa04f3b31aa35f068be4c945e658c8b9773
Author: seninha <lucas@seninha.org>
Date: Fri, 11 Mar 2022 18:39:13 -0300
add -s, readd -m, change resources name again
Diffstat:
M | README | | | 32 | -------------------------------- |
M | config.h | | | 5 | +++++ |
M | shod.1 | | | 35 | ++++++++++++++++++++++++++--------- |
M | shod.c | | | 103 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------- |
4 files changed, 106 insertions(+), 69 deletions(-)
diff --git a/README b/README
@@ -38,35 +38,3 @@ Screenshots:
TODO:
• Add support for dropdown (quake-like) windows.
-
- * * *
-
-WARNING!
-Shod now names Xresources for colors just like how motif names them.
-Your Xresources may affect Shod. To avoid this, copy the following
-lines to your ~/.Xresources, or ~/.Xdefaults, or any other file read
-by xrdb(1).
-
-shod*background: #3465A4
-shod*topShadowColor: #729FCF
-shod*bottomShadowColor: #204A87
-shod.inactive.background: #555753
-shod.inactive.topShadowColor: #888A85
-shod.inactive.bottomShadowColor: #2E3436
-shod.urgent.background: #CC0000
-shod.urgent.topShadowColor: #EF2929
-shod.urgent.bottomShadowColor: #A40000
-shod.dock.background: #121212
-shod.dock.topShadowColor: #2E3436
-shod.dock.bottomShadowColor: #000000
-shod.borderWidth: 6
-shod.dockGravity: E
-shod.dockWidth: 64
-shod.numOfDesktops: 10
-shod.notifGap: 3
-shod.notifGravity: NE
-shod.shadowThickness: 2
-shod.snapProximity: 8
-shod.title.font: fixed
-shod.title.foreground: FG
-shod.titleWidth: 17
diff --git a/config.h b/config.h
@@ -6,7 +6,12 @@ struct Config config = {
* and the color of the dark 3D shadow.
*/
+ /* 0-or-1 flags */
+ .sloppyfocus = 0, /* set to 1 to use sloppy focus */
+ .honorconfig = 0, /* set to 1 to honor configure requests */
+
/* general configuration */
+ .modifier = Mod1Mask, /* Modifier button */
.snap = 8, /* proximity of container edges to perform snap attraction */
.font = "fixed", /* font for titles in titlebars */
.ndesktops = 10, /* number of desktops per monitor */
diff --git a/shod.1 b/shod.1
@@ -4,7 +4,9 @@
\- mouse-focused window manager
.SH SYNOPSIS
.B shod
-.RB [ \-c ]
+.RB [ \-cs ]
+.RB [ \-m
+.IR modifier ]
.PP
.B shodc close
.RI [ win_id ]
@@ -77,6 +79,21 @@ but they can be honored by invoking
with the
.B \-c
command-line option.
+.TP
+\fB\-m\fP \fImodifier\fP
+Which modifier, from
+.B Mod1
+to
+.B Mod5
+is used to move and resize windows with the mouse pointer.
+By default,
+.B shod
+uses
+.B Mod1
+(Alt) as modifier.
+.TP
+.B \-s
+Use sloppy focus rather than click-to-focus.
.PP
.B shodc
is the remote controller for
@@ -551,11 +568,11 @@ and all of them must be set for a consistent theme.
.B shod.borderWidth
The width of the borders and divisions.
.TP
-.B shod.active.background, shod.active.topShadowColor, shod.active.bottomShadowColor
+.B shod.activeBackground, shod.activeTopShadowColor, shod.activeBottomShadowColor
The body color, light shadow color, and dark shadow color for the 3D
effect of the borders and title bars of active windows.
.TP
-.B shod.dock.background, shod.dock.topShadowColor, shod.dock.bottomShadowColor
+.B shod.dockBackground, shod.dockTopShadowColor, shod.dockBottomShadowColor
The body color, light shadow color, and dark shadow color for the 3D
effect of the dock.
.TP
@@ -577,7 +594,7 @@ alligned to its center.
The width (for vertical docks) or height (for horizontal dock) of the dock in pixels.
Defaults to 64 (the size of most dockapps).
.TP
-.B shod.inactive.background, shod.inactive.topShadowColor, shod.inactive.bottomShadowColor
+.B shod.inactiveBackground, shod.inactiveTopShadowColor, shod.inactiveBottomShadowColor
The body color, light shadow color, and dark shadow color for the 3D
effect of the borders and title bars of inactive windows.
.TP
@@ -585,7 +602,7 @@ effect of the borders and title bars of inactive windows.
The number of desktops for each monitor.
The default is 10 desktops for each monitor.
.TP
-.B shod.notif.background, shod.notif.topShadowColor, shod.notif.bottomShadowColor
+.B shod.notifBackground, shod.notifTopShadowColor, shod.notifBottomShadowColor
The body color, light shadow color, and dark shadow color for the 3D
effect of the notification borders.
.TP
@@ -598,7 +615,7 @@ For example, a value of "N" will place notifications centered on the north edge
A value of "E" will place notifications centered on the east edge of the screen.
A value of "NE" (the default) will place notifications on the northeast corner of the screen.
.TP
-.B shod.prompt.background, shod.prompt.topShadowColor, shod.prompt.bottomShadowColor
+.B shod.promptBackground, shod.promptTopShadowColor, shod.promptBottomShadowColor
The body color, light shadow color, and dark shadow color for the 3D
effect of the prompt borders.
.TP
@@ -611,16 +628,16 @@ The proximity of edges of a container in pixels for the snap attraction to occur
If set to zero, no snap attraction occurs.
The default is 8 pixels.
.TP
-.B shod.title.font
+.B shod.font
The font of the text in the title bar.
.TP
-.B shod.title.foreground
+.B shod.foreground
The color of the text in the title bar.
.TP
.B shod.titleWidth
The width of the title bar.
.TP
-.B shod.urgent.background, shod.urgent.topShadowColor, shod.urgent.bottomShadowColor
+.B shod.urgentBackground, shod.urgentTopShadowColor, shod.urgentBottomShadowColor
The body color, light shadow color, and dark shadow color for the 3D
effect of the borders and title bars of urgent windows.
.SS Window-dependent resources
diff --git a/shod.c b/shod.c
@@ -16,7 +16,6 @@
#include <X11/extensions/Xinerama.h>
#include <X11/extensions/Xrender.h>
-#define MODIFIER Mod1Mask
#define DIV 15 /* see containerplace() for details */
#define IGNOREUNMAP 6 /* number of unmap notifies to ignore while scanning existing clients */
#define NAMEMAXLEN 1024 /* maximum length of window's name */
@@ -527,6 +526,9 @@ struct WM {
/* configuration */
struct Config {
+ unsigned int modifier;
+ int honorconfig;
+ int sloppyfocus;
int ndesktops;
int notifgap;
int dockwidth, dockspace;
@@ -567,7 +569,6 @@ static struct Dock dock;
static unsigned long clientmask = CWEventMask | CWColormap | CWBackPixel | CWBorderPixel;
static unsigned int depth;
static int screen, screenw, screenh;
-static int cflag = 0;
static char *wmname;
static char *xrm;
volatile sig_atomic_t running = 1;
@@ -578,7 +579,7 @@ volatile sig_atomic_t running = 1;
static void
usage(void)
{
- (void)fprintf(stderr, "usage: shod [-c]\n");
+ (void)fprintf(stderr, "usage: shod [-cs] [-m modifier]\n");
exit(1);
}
@@ -677,6 +678,25 @@ siginthandler(int signo)
running = 0;
}
+/* parse modifier string */
+static unsigned int
+parsemodifier(const char *s)
+{
+ if (strcasecmp(s, "Mod1") == 0)
+ return Mod1Mask;
+ else if (strcasecmp(s, "Mod2") == 0)
+ return Mod2Mask;
+ else if (strcasecmp(s, "Mod3") == 0)
+ return Mod3Mask;
+ else if (strcasecmp(s, "Mod4") == 0)
+ return Mod4Mask;
+ else if (strcasecmp(s, "Mod5") == 0)
+ return Mod5Mask;
+ else
+ errx(1, "improper modifier string %s", s);
+ return 0;
+}
+
/* read xrdb for configuration options */
static void
getresources(void)
@@ -688,54 +708,54 @@ getresources(void)
if (xrm == NULL || xdb == NULL)
return;
- if (XrmGetResource(xdb, "shod.title.font", "*", &type, &xval) == True)
+ if (XrmGetResource(xdb, "shod.font", "*", &type, &xval) == True)
config.font = xval.addr;
- if (XrmGetResource(xdb, "shod.title.foreground", "*", &type, &xval) == True) {
+ if (XrmGetResource(xdb, "shod.foreground", "*", &type, &xval) == True) {
config.foreground[0] = xval.addr;
config.foreground[1] = xval.addr;
config.foreground[2] = xval.addr;
}
- if (XrmGetResource(xdb, "shod.dock.background", "*", &type, &xval) == True)
+ if (XrmGetResource(xdb, "shod.dockBackground", "*", &type, &xval) == True)
config.dockcolors[COLOR_MID] = xval.addr;
- if (XrmGetResource(xdb, "shod.dock.topShadowColor", "*", &type, &xval) == True)
+ if (XrmGetResource(xdb, "shod.dockTopShadowColor", "*", &type, &xval) == True)
config.dockcolors[COLOR_LIGHT] = xval.addr;
- if (XrmGetResource(xdb, "shod.dock.bottomShadowColor", "*", &type, &xval) == True)
+ if (XrmGetResource(xdb, "shod.dockBottomShadowColor", "*", &type, &xval) == True)
config.dockcolors[COLOR_DARK] = xval.addr;
- if (XrmGetResource(xdb, "shod.notif.background", "*", &type, &xval) == True)
+ if (XrmGetResource(xdb, "shod.notifBackground", "*", &type, &xval) == True)
config.notifcolors[COLOR_MID] = xval.addr;
- if (XrmGetResource(xdb, "shod.notif.topShadowColor", "*", &type, &xval) == True)
+ if (XrmGetResource(xdb, "shod.notifTopShadowColor", "*", &type, &xval) == True)
config.notifcolors[COLOR_LIGHT] = xval.addr;
- if (XrmGetResource(xdb, "shod.notif.bottomShadowColor", "*", &type, &xval) == True)
+ if (XrmGetResource(xdb, "shod.notifBottomShadowColor", "*", &type, &xval) == True)
config.notifcolors[COLOR_DARK] = xval.addr;
- if (XrmGetResource(xdb, "shod.prompt.background", "*", &type, &xval) == True)
+ if (XrmGetResource(xdb, "shod.promptBackground", "*", &type, &xval) == True)
config.promptcolors[COLOR_MID] = xval.addr;
- if (XrmGetResource(xdb, "shod.prompt.topShadowColor", "*", &type, &xval) == True)
+ if (XrmGetResource(xdb, "shod.promptTopShadowColor", "*", &type, &xval) == True)
config.promptcolors[COLOR_LIGHT] = xval.addr;
- if (XrmGetResource(xdb, "shod.prompt.bottomShadowColor", "*", &type, &xval) == True)
+ if (XrmGetResource(xdb, "shod.promptBottomShadowColor", "*", &type, &xval) == True)
config.promptcolors[COLOR_DARK] = xval.addr;
- if (XrmGetResource(xdb, "shod.active.background", "*", &type, &xval) == True)
+ if (XrmGetResource(xdb, "shod.activeBackground", "*", &type, &xval) == True)
config.bordercolors[FOCUSED][COLOR_MID] = xval.addr;
- if (XrmGetResource(xdb, "shod.active.topShadowColor", "*", &type, &xval) == True)
+ if (XrmGetResource(xdb, "shod.activeTopShadowColor", "*", &type, &xval) == True)
config.bordercolors[FOCUSED][COLOR_LIGHT] = xval.addr;
- if (XrmGetResource(xdb, "shod.active.bottomShadowColor", "*", &type, &xval) == True)
+ if (XrmGetResource(xdb, "shod.activeBottomShadowColor", "*", &type, &xval) == True)
config.bordercolors[FOCUSED][COLOR_DARK] = xval.addr;
- if (XrmGetResource(xdb, "shod.inactive.background", "*", &type, &xval) == True)
+ if (XrmGetResource(xdb, "shod.inactiveBackground", "*", &type, &xval) == True)
config.bordercolors[UNFOCUSED][COLOR_MID] = xval.addr;
- if (XrmGetResource(xdb, "shod.inactive.topShadowColor", "*", &type, &xval) == True)
+ if (XrmGetResource(xdb, "shod.inactiveTopShadowColor", "*", &type, &xval) == True)
config.bordercolors[UNFOCUSED][COLOR_LIGHT] = xval.addr;
- if (XrmGetResource(xdb, "shod.inactive.bottomShadowColor", "*", &type, &xval) == True)
+ if (XrmGetResource(xdb, "shod.inactiveBottomShadowColor", "*", &type, &xval) == True)
config.bordercolors[UNFOCUSED][COLOR_DARK] = xval.addr;
- if (XrmGetResource(xdb, "shod.urgent.background", "*", &type, &xval) == True)
+ if (XrmGetResource(xdb, "shod.urgentBackground", "*", &type, &xval) == True)
config.bordercolors[URGENT][COLOR_MID] = xval.addr;
- if (XrmGetResource(xdb, "shod.urgent.topShadowColor", "*", &type, &xval) == True)
+ if (XrmGetResource(xdb, "shod.urgentTopShadowColor", "*", &type, &xval) == True)
config.bordercolors[URGENT][COLOR_LIGHT] = xval.addr;
- if (XrmGetResource(xdb, "shod.urgent.bottomShadowColor", "*", &type, &xval) == True)
+ if (XrmGetResource(xdb, "shod.urgentBottomShadowColor", "*", &type, &xval) == True)
config.bordercolors[URGENT][COLOR_DARK] = xval.addr;
if (XrmGetResource(xdb, "shod.borderWidth", "*", &type, &xval) == True)
@@ -778,10 +798,16 @@ getoptions(int argc, char *argv[])
wmname++;
else
wmname = argv[0];
- while ((c = getopt(argc, argv, "c")) != -1) {
+ while ((c = getopt(argc, argv, "cm:s")) != -1) {
switch (c) {
case 'c':
- cflag = 1;
+ config.honorconfig = 1;
+ break;
+ case 'm':
+ config.modifier = parsemodifier(optarg);
+ break;
+ case 's':
+ config.sloppyfocus = 1;
break;
default:
usage();
@@ -5901,11 +5927,11 @@ xeventbuttonpress(XEvent *e)
mouseretile(c, cdiv, rdiv, ev->x_root, ev->y_root);
}
} else if (!c->isfullscreen && !c->isminimized && !c->ismaximized) {
- if (ev->state == MODIFIER && ev->button == Button1) {
+ if (ev->state == config.modifier && ev->button == Button1) {
mousemove(FLOAT_CONTAINER, c, ev->x_root, ev->y_root, 0);
} else if (ev->window == c->frame && ev->button == Button3) {
mousemove(FLOAT_CONTAINER, c, ev->x_root, ev->y_root, o);
- } else if ((ev->state == MODIFIER && ev->button == Button3) ||
+ } else if ((ev->state == config.modifier && ev->button == Button3) ||
(o != C && ev->window == c->frame && ev->button == Button1)) {
if (o == C) {
if (x >= c->w / 2 && y >= c->h / 2) {
@@ -6198,7 +6224,7 @@ xeventconfigurerequest(XEvent *e)
if (res.d != NULL) {
dialogconfigure(res.d, ev->value_mask, &wc);
} else if (res.c != NULL) {
- if (cflag) {
+ if (config.honorconfig) {
containerconfigure(res.c, ev->value_mask, &wc);
} else {
containermoveresize(res.c);
@@ -6239,6 +6265,22 @@ xeventdestroynotify(XEvent *e)
ewmhsetclientsstacking();
}
+/* focus window when cursor enter it (only if there is no focus button) */
+static void
+xevententernotify(XEvent *e)
+{
+ struct Winres res;
+
+ if (!config.sloppyfocus)
+ return;
+ while (XCheckTypedEvent(dpy, EnterNotify, e))
+ ;
+ res = getwin(e->xcrossing.window);
+ if (res.t != NULL) {
+ tabfocus(res.t, 1);
+ }
+}
+
/* redraw window decoration */
static void
xeventexpose(XEvent *e)
@@ -6437,6 +6479,7 @@ main(int argc, char *argv[])
[ConfigureNotify] = xeventconfigurenotify,
[ConfigureRequest] = xeventconfigurerequest,
[DestroyNotify] = xeventdestroynotify,
+ [EnterNotify] = xevententernotify,
[Expose] = xeventexpose,
[FocusIn] = xeventfocusin,
[MapRequest] = xeventmaprequest,
@@ -6462,6 +6505,10 @@ main(int argc, char *argv[])
getresources();
getoptions(argc, argv);
+ /* check sloppy focus */
+ if (config.sloppyfocus)
+ clientswa.event_mask |= EnterWindowMask;
+
/* initialize */
xinitvisual();
initsignal();