Compare commits

...

51 Commits
master ... main

Author SHA1 Message Date
David JULIEN 36a8e80ee2 feat: restoreadterrestart patch 2023-01-08 18:11:51 +01:00
David JULIEN 4a476e877c feat: restartsig patch 2023-01-08 15:02:34 +01:00
David JULIEN 16bc69ce1c
Merge branch 'upstream'
update to 6.4
2023-01-08 15:00:38 +01:00
David JULIEN 115058faa8 feat: window selborder gets its own variable 2023-01-08 00:23:43 +01:00
Chris Down 89f9905714 grabkeys: Avoid missing events when a keysym maps to multiple keycodes
It's not uncommon for one keysym to map to multiple keycodes. For
example, the "play" button on my keyboard sends keycode 172, but my
bluetooth headphones send keycode 208, both of which map back to
XF86AudioPlay:

    % xmodmap -pke | grep XF86AudioPlay
    keycode 172 = XF86AudioPlay XF86AudioPause XF86AudioPlay XF86AudioPause
    keycode 208 = XF86AudioPlay NoSymbol XF86AudioPlay
    keycode 215 = XF86AudioPlay NoSymbol XF86AudioPlay

This is a problem because the current code only grabs a single one of
these keycodes, which means that events for any other keycode also
mapping to the bound keysym will not be handled by dwm. In my case, this
means that binding XF86AudioPlay does the right thing and correctly
handles my keyboard's keys, but does nothing on my headphones. I'm not
the only person affected by this, there are other reports[0].

In order to fix this, we look at the mappings between keycodes and
keysyms at grabkeys() time and pick out all matching keycodes rather
than just the first one. The keypress() side of this doesn't need any
changes because the keycode gets converted back to a canonical keysym
before any action is taken.

0: https://github.com/cdown/dwm/issues/11
2022-12-07 23:06:26 +01:00
David JULIEN 4af8e13709 fix: fonts array
fonts not in the array couldn't be tweaked through xrdb
2022-11-04 20:56:14 +01:00
David JULIEN aa43e52021 fix 1b6b09b : make pinentry-gtk-3 floating window 2022-11-04 18:51:25 +01:00
David JULIEN 89d751ef3a feat: support japanese symbols 2022-11-01 23:25:24 +01:00
David JULIEN ad4ddc40f3 feat: normbordercolor makes cindows dinstinguishable 2022-10-31 15:54:27 +01:00
Hiltjo Posthuma ba56fe9fea Revert "Remove dmenumon variable"
This reverts commit c2b748e793.

Revert back this change. It seems to not be an edge-case anymore since
multiple users have asked about this new behaviour now.
2022-10-28 16:37:56 +02:00
David JULIEN 1b6b09b50d feat: make pinentry window a floating window 2022-10-25 11:56:37 +02:00
Hiltjo Posthuma 50ad171eea bump version to 6.4 2022-10-04 19:35:13 +02:00
Hiltjo Posthuma 970f376973 remove workaround for a crash with color emojis on some systems, now fixed in libXft 2.3.5
https://gitlab.freedesktop.org/xorg/lib/libxft/-/blob/libXft-2.3.5/NEWS
2022-09-17 15:32:41 +02:00
Stein c2b748e793 Remove dmenumon variable
Reasoning: Since 2011 dmenu has been capable of working out which
monitor currently has focus in a Xinerama setup, making the use
of the -m flag more or less redundant.

This is easily demonstrated by using dmenu in any other window
manager.

There used to be a nodmenu patch that provided these changes:
https://git.suckless.org/sites/commit/ed68e3629de4ef2ca2d3f8893a79fb570b4c0cbc.html

but this was removed on the basis that it was very easy to work
out and apply manually if needed.

The proposal here is to remove this dependency from dwm. The
mechanism of the dmenumon variable could be provided via a patch
if need be.

The edge case scenario that dmenu does not handle on its own, and
the effect of removing this mechanism, is that if the user trigger
focusmon via keybindings to change focus to another monitor that
has no clients, then dmenu will open on the monitor containing the
window with input focus (or the monitor with the mouse cursor if
no windows have input focus).

If this edge case is important to cover then this can be addressed
by setting input focus to selmon->barwin in the focus function if
there is no client to give focus to (rather than giving focus back
to the root window).
2022-08-28 11:39:43 +02:00
NRK 84d7322113 config.def.h: make keys and buttons const
pretty much all other variables are declared as const when they're not
modified.
2022-08-19 11:47:22 +02:00
Stein 5799dd1fca Remove blw variable in favour of calculating the value when needed
The purpose and reasoning behind the bar layout width (blw) variable
in dwm the way it is today may not be immediately obvious.

The use of the variable makes more sense when looking at commit
2ce37bc from 2009 where blw was initialised in the setup function
and it represented the maximum of all available layout symbols.

	for(blw = i = 0; LENGTH(layouts) > 1 && i < LENGTH(layouts); i++) {
		w = TEXTW(layouts[i].symbol);
		blw = MAX(blw, w);
	}

As such the layout symbol back then was fixed in size and both drawbar
and buttonpress depended on this variable.

The the way the blw variable is set today in drawbar means that it
merely caches the size of the layout symbol for the last bar drawn.

While unlikely to happen in practice it is possible that the last bar
drawn is not that of the currently selected monitor, which can result
in misaligned button clicks if there is a difference in layout symbol
width between monitors.
2022-08-17 13:33:57 +02:00
Stein 44adafe006 Make floating windows spawn within the monitor's window area
This is a follow-up on this thread:
https://lists.suckless.org/hackers/2208/18462.html

The orginal code had constraints such that if a window's starting
attributes (position and size) were to place the window outside of
the edges of the monitor, then the window would be moved into view
at the closest monitor edge.

There was an exception to this where if a top bar is used then the
window should not obscure the bar if present, which meant to place
the window within the window area instead.

The proposed change here makes it the general rule that floating
windows should spawn within the window area rather than within the
monitor area. This makes it simple and consistent with no
exceptions and it makes the intention of the code clear.

This has the benefit of making the behaviour consistent regardless
of whether the user is using a top bar or a bottom bar.

Additionally this will have an effect on patches that modify the
size of the window area. For example if the insets patch is used to
reserve space on the left hand side of the monitor for a dock or a
vertical bar then new floating clients will not obscure that area.
2022-08-12 09:02:34 +02:00
Stein a859676ead Simplify client y-offset correction
The reasoning behind the original line may be lost to time as
it does not make much sense checking the position on the x-axis
to determine how to position the client on the y-axis.

In the context of multi-monitor setups the monitor y position
(m->my) may be greater than 0 (say 500), in which case the window
could be placed out of view if:
   - the window attributes have a 0 value for the y position and
   - we end up using the y position of bh (e.g. 22)

If the aim is to avoid a new floating client covering the bar then
restricting y position to be at least that of the window area
(m->wy) should cover the two cases of using a top bar and using a
bottom bar.
2022-08-10 15:31:21 +02:00
Hiltjo Posthuma e0dee91145 sync code-style patch from libsl 2022-08-08 10:43:09 +02:00
NRK 5e76e7e21d code-style: simplify some checks
main change here is making the `zoom()` logic saner. the rest of the
changes are just small stuff which accumulated on my local branch.

pop() must not be called with NULL. and `zoom()` achieves this, but in a
very (unnecessarily) complicated way:

if c == NULL then nexttiled() will return NULL as well, so we enter this
branch:

	if (c == nexttiled(selmon->clients))

in here the !c check fails and the function returns before calling pop()

		if (!c || !(c = nexttiled(c->next)))
			return;

however, none of this was needed. we can simply return early if c was NULL.
Also `c` is set to `selmon->sel` so we can use `c` in the first check
instead which makes things shorter.
2022-08-06 16:09:01 +02:00
explosion-mental 5b2e5e7a40 spawn: reduce 2 lines, change fprintf() + perror() + exit() to die("... :")
when calling die and the last character of the string corresponds to
':', die() will call perror(). See util.c

Also change EXIT_SUCCESS to EXIT_FAILURE
2022-08-02 18:08:51 +02:00
Stein 786f6e2a6f unmanage: stop listening for events for unmanaged windows
This is in particular to avoid flickering in dwm (and high CPU usage)
when hovering the mouse over a tabbed window that was previously
managed by dwm.

Consider the following two scenarios:

1)

We start tabbed (window 0xc000003), tabbed is managed by the
window manager.
We start st being embedded into tabbed.

$ st -w 0xc000003

What happens here is that:
   - tabbed gets a MapRequest for the st window
   - tabbed reparents the st window
   - tabbed will receive X events for the window

The window manager will have no awareness of the st window and the
X server will not send X events to the window manager relating to
the st window.

There is no flickering or any other issues relating to focus.

2)

We start tabbed (window 0xc000003), tabbed is managed by the
window manager.
We start st as normal (window 0xd400005).

What happens here is that:
   - the window manager gets a MapRequest for the st window
   - dwm manages the st window as a normal client
   - dwm will receive X events for the window

Now we use xdotool to trigger a reparenting of the st window into
tabbed.

$ xdotool windowreparent 0xd400005 0xc000003

What happens here is that:
   - tabbed gets a MapRequest for the st window
   - tabbed reparents the st window
   - the window manager gets an UnmapNotify
   - the window manager no longer manages the st window
   - both the window manager and tabbed will receive X events
     for the st window

In dwm move the mouse cursor over the tabbed window.

What happens now is that:
   - dwm will receive a FocusIn event for the tabbed window
   - dwm will set input focus for the tabbed window
   - tabbed will receive a FocusIn event for the main window
   - tabbed will give focus to the window on the currently selected
     tab
   - which again triggers a FocusIn event which dwm receives
   - dwm determines that the window that the FocusIn event is for
     (0xd400005) is not the currently selected client (tabbed)
   - dwm sets input focus for the tabbed window
   - this causes an infinite loop as long as the mouse cursor hovers
     the tabbed window, resulting in flickering and high CPU usage

The fix here is to tell the X server that we are no longer interested
in receiving events for this window when the window manager stops
managing the window.
2022-08-02 18:04:56 +02:00
Hiltjo Posthuma e03248a4d5 Revert "do not call signal-unsafe function inside sighanlder"
This reverts commit 6613d9f9a1.

Discussed on the mailinglist:
https://lists.suckless.org/hackers/2207/18405.html
2022-07-22 09:18:52 +02:00
NRK 6613d9f9a1 do not call signal-unsafe function inside sighanlder
die() calls vprintf, fputc and exit; none of these are
async-signal-safe, see `man 7 signal-safety`.
2022-07-15 20:53:58 +02:00
NRK 9bffa845fa use named parameter for func prototype
all the other prototypes use names.
2022-07-15 20:53:56 +02:00
Hiltjo Posthuma d3f93c7c1a sync latest drw.{c,h} changes from dmenu 2022-05-10 19:07:56 +02:00
Hiltjo Posthuma cd0773cee9 Makefile: add manual path for OpenBSD
Reported by fossy <fossy@dnmx.org>, thanks
2022-05-01 18:37:54 +02:00
Chris Down 8b48e30973 manage: Make sure c->isfixed is applied before floating checks
Commit 8806b6e237 ("manage: propertynotify: Reduce cost of unused size
hints") mistakenly removed an early size hints update that's needed to
populate c->isfixed for floating checks at manage() time. This resulted
in fixed (size hint min dimensions == max dimensions) subset of windows
not floating when they should.

See https://lists.suckless.org/dev/2204/34730.html for discussion.
2022-04-26 15:50:55 +02:00
Hiltjo Posthuma a83dc20310 LICENSE: add Chris Down 2022-04-26 15:50:32 +02:00
Hiltjo Posthuma a4771de5ba Revert "manage: For isfloating/oldstate check/set, ensure trans client actually exists"
This reverts commit bece862a0f.

It caused a regression, for example:
https://lists.suckless.org/hackers/2203/18220.html
2022-04-26 10:30:59 +02:00
David JULIEN 82003c8dad feat: personnal config 2022-04-23 15:58:34 +02:00
David JULIEN a1ab7f5da7 feat: noboarder patch 2022-04-23 15:57:12 +02:00
David JULIEN 3a5835b297 feat: xresources patch 2022-04-23 14:05:27 +02:00
David JULIEN 65e044bd26 feat: center patch 2022-04-23 13:37:21 +02:00
David JULIEN e382777f81 feat: swallow patch 2022-04-23 13:31:45 +02:00
David JULIEN a7ad711b5a feat: notitle patch 2022-04-23 13:30:27 +02:00
David JULIEN a2dd850d3a feat: hide_vacant_tags patch 2022-04-23 13:29:31 +02:00
David JULIEN 116cf1f7c7 feat: fullgaps patch 2022-04-23 13:28:58 +02:00
David JULIEN 1d38ae649f feat: attachaside patch 2022-04-23 13:27:36 +02:00
David JULIEN c4f556bce0
start fresh for 6.3 2022-04-23 13:10:37 +02:00
Santtu Lakkala d93ff48803 Update monitor positions also on removal
When monitors are removed, the coordinates of existing monitors may
change, if the removed monitors had smaller coordinates than the
remaining ones.

Remove special case handling so that the same update-if-necessary loop
is run also in the case when monitors are removed.
2022-04-16 16:59:03 +02:00
Chris Down 8806b6e237 manage: propertynotify: Reduce cost of unused size hints
This patch defers all size hint calculations until they are actually
needed, drastically reducing the number of calls to updatesizehints(),
which can be expensive when called repeatedly (as it currently is during
resizes).

In my unscientific testing this reduces calls to updatesizehints() by
over 90% during a typical work session. There are no functional changes
for users other than an increase in responsiveness after resizes and
a reduction in CPU time.

In slower environments or X servers, this patch also offers an
improvement in responsiveness that is often tangible after resizing a
client that changes hints during resizes.

There are two main motivations to defer this work to the time of hint
application:

1. Some clients, especially terminals using incremental size hints,
   resend XA_WM_NORMAL_HINTS events on resize to avoid fighting with the
   WM or mouse resizing. For example, some terminals like urxvt clear
   PBaseSize and PResizeInc during XResizeWindow and restore them
   afterwards.

   For this reason, after the resize is concluded, we typically receive
   a backlogged XA_WM_NORMAL_HINTS message for each update period with
   movement, which is useless. In some cases one may get hundreds or
   thousands of XA_WM_NORMAL_HINTS messages on large resizes, and
   currently all of these result in a separate updatesizehints() call,
   of which all but the final one are immediately outdated.

   (We can't just blindly discard these messages during resizes like we
   do for EnterNotify, because some of them might actually be for other
   windows, and may not be XA_WM_NORMAL_HINTS events.)

2. For users which use resizehints=0 most of these updates are unused
   anyway -- in the normal case where the client is not floating these
   values won't be used, so there's no need to calculate them up front.

A synthetic test using the mouse to resize a floating terminal window
from roughly 256x256 to 1024x1024 and back again shows that the number
of calls to updatesizehints() goes from over 500 before this patch (one
for each update interval with movement) to 2 after this patch (one for
each hint application), with no change in user visible behaviour.

This also reduces the delay before dwm is ready to process new events
again after a large resize on such a client, as it avoids the thundering
herd of updatesizehints() calls when hundreds of backlogged
XA_WM_NORMAL_HINTS messages appear at once after a resize is finished.
2022-04-16 16:37:46 +02:00
Miles Alan bece862a0f manage: For isfloating/oldstate check/set, ensure trans client actually exists
In certain instances trans may be set to a window that doesn't actually
map to a client via wintoclient; in this case it doesn't make sense
to set isfloating/oldstate since trans is essentially invalid in that
case / correlates to the above condition check where trans is set /
XGetTransientForHint is called.
2022-03-13 17:32:56 +01:00
NRK 60e9a14998 fix mem leak in cleanup()
maybe leak isn't the best word, given that the object lives for the
entire duration of the program's lifetime.

however, all elements of scheme are free-ed, can't think of any reason
why scheme itself should be an exception.
2022-03-13 10:49:43 +01:00
Hiltjo Posthuma d39e2f3441 bump version to 6.3 2022-01-07 12:39:18 +01:00
Chris Down 8657affa2a drawbar: Don't expend effort drawing bar if it is occluded
I noticed that a non-trivial amount of dwm's work on my machine was from
drw_text, which seemed weird, because I have the bar disabled and we
only use drw_text as part of bar drawing.

Looking more closely, I realised that while we use m->showbar when
updating the monitor bar margins, but don't skip actually drawing the
bar if it is hidden. This patch skips drawing it entirely if that is the
case.

On my machine, this takes 10% of dwm's on-CPU time, primarily from
restack() and focus().

When the bar is toggled on again, the X server will generate an Expose
event, and we'll redraw the bar as normal as part of expose().
2021-12-19 16:16:30 +01:00
Hiltjo Posthuma a786211d6c Revert "Improve speed of drw_text when provided with large strings"
This reverts commit 716233534b.

It causes issues with truncation of characters when the text does not fit and
so on.  The patch should be reworked and properly tested.
2021-08-20 23:09:48 +02:00
Miles Alan 716233534b Improve speed of drw_text when provided with large strings
Calculates len & ew in drw_font_getexts loop by incrementing instead of
decrementing; as such avoids proportional increase in time spent in loop
based on provided strings size.
2021-08-09 18:25:19 +02:00
Quentin Rameau 138b405f0c Add a configuration option for fullscreen locking
Some people are annoyed to have this new behaviour forced for some
application which use fake fullscreen.
2021-07-14 11:26:37 +02:00
Chris Down 67d76bdc68 Do not allow focus to drift from fullscreen client via focusstack()
It generally doesn't make much sense to allow focusstack() to navigate
away from the selected fullscreen client, as you can't even see which
client you're selecting behind it.

I have had this up for a while on the wiki as a separate patch[0], but
it seems reasonable to avoid this behaviour in dwm mainline, since I'm
struggling to think of any reason to navigate away from a fullscreen
client other than a mistake.

0: https://dwm.suckless.org/patches/alwaysfullscreen/
2021-03-29 19:16:27 +02:00
Ian Remmler 61bb8b2241 Fix x coordinate calculation in buttonpress. 2020-08-21 16:13:22 +02:00
20 changed files with 2491 additions and 258 deletions

View File

@ -17,6 +17,7 @@ MIT/X Consortium License
© 2015-2016 Quentin Rameau <quinq@fifth.space>
© 2015-2016 Eric Pruitt <eric.pruitt@gmail.com>
© 2016-2017 Markus Teich <markus.teich@stusta.mhn.de>
© 2020-2022 Chris Down <chris@chrisdown.name>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),

View File

@ -26,7 +26,7 @@ dwm: ${OBJ}
${CC} -o $@ ${OBJ} ${LDFLAGS}
clean:
rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz
rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz config.h
dist: clean
mkdir -p dwm-${VERSION}

View File

@ -1,21 +1,29 @@
/* See LICENSE file for copyright and license details. */
#define SESSION_FILE "/tmp/dwm-session"
/* appearance */
static const unsigned int borderpx = 1; /* 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 char *fonts[] = { "monospace:size=10" };
static const char dmenufont[] = "monospace:size=10";
static const char col_gray1[] = "#222222";
static const char col_gray2[] = "#444444";
static const char col_gray3[] = "#bbbbbb";
static const char col_gray4[] = "#eeeeee";
static const char col_cyan[] = "#005577";
static const char *colors[][3] = {
/* fg bg border */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
static unsigned int borderpx = 1; /* border pixel of windows */
static unsigned int gappx = 5; /* gaps between windows */
static unsigned int snap = 32; /* snap pixel */
static int swallowfloating = 0; /* 1 means swallow floating windows by default */
static int showbar = 1; /* 0 means no bar */
static int topbar = 1; /* 0 means bottom bar */
static char font[] = "monospace:size=10";
static char symbols[] = "monospace:size=10";
static char japan[] = "monospace:size=10";
static char dmenufont[] = "monospace:size=10";
static const char *fonts[] = { font, symbols, japan };
static char normbgcolor[] = "#222222";
static char normbordercolor[] = "#444444";
static char normfgcolor[] = "#bbbbbb";
static char selfgcolor[] = "#eeeeee";
static char selbordercolor[] = "#005577";
static char selbgcolor[] = "#005577";
static char *colors[][3] = {
/* fg bg border */
[SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor },
[SchemeSel] = { selfgcolor, selbgcolor, selbordercolor },
};
/* tagging */
@ -26,15 +34,21 @@ static const Rule rules[] = {
* WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title
*/
/* class instance title tags mask isfloating monitor */
{ "Gimp", NULL, NULL, 0, 1, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 },
/* class instance title tags mask iscentered isfloating isterminal noswallow monitor */
// { "Gimp", NULL, NULL, 0, 0, 1, 0, 0, -1 },
// { "Firefox", NULL, NULL, 1 << 8, 0, 0, 0, -1, -1 },
{ "St", NULL, NULL, 0, 0, 0, 1, -1, -1 },
{ "Pinentry-gtk-2",NULL, NULL, 0, 1, 1, 1, -1, -1 },
{ "Gcr-prompter",NULL, NULL, 0, 1, 1, 1, -1, -1 },
{ "floating",NULL, NULL, 0, 1, 1, 1, -1, -1 },
{ NULL, NULL, "Event Tester", 0, 0, 1, 0, 1, -1 }, /* xev */
};
/* layout(s) */
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
static const int nmaster = 1; /* number of clients in master area */
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
static float mfact = 0.55; /* factor of master area size [0.05..0.95] */
static int nmaster = 1; /* number of clients in master area */
static int resizehints = 1; /* 1 means respect size hints in tiled resizals */
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
static const Layout layouts[] = {
/* symbol arrange function */
@ -44,7 +58,7 @@ static const Layout layouts[] = {
};
/* key definitions */
#define MODKEY Mod1Mask
#define MODKEY Mod4Mask
#define TAGKEYS(KEY,TAG) \
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
@ -56,53 +70,80 @@ static const Layout layouts[] = {
/* commands */
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-p", "run:", NULL };
static const char *termcmd[] = { "st", NULL };
static Key keys[] = {
/*
* Xresources preferences to load at startup
*/
ResourcePref resources[] = {
{ "font", STRING, &font },
{ "symbols", STRING, &symbols },
{ "japan", STRING, &japan },
{ "dmenufont", STRING, &dmenufont },
{ "background", STRING, &normbgcolor },
{ "normforeground", STRING, &normbordercolor },
{ "normforeground", STRING, &normfgcolor },
{ "selbackground", STRING, &selbgcolor },
{ "selborder", STRING, &selbordercolor },
{ "selforeground", STRING, &selfgcolor },
{ "borderpx", INTEGER, &borderpx },
{ "gappx", INTEGER, &gappx },
{ "snap", INTEGER, &snap },
{ "showbar", INTEGER, &showbar },
{ "topbar", INTEGER, &topbar },
{ "nmaster", INTEGER, &nmaster },
{ "resizehints", INTEGER, &resizehints },
{ "mfact", FLOAT, &mfact },
};
static const Key keys[] = {
/* modifier key function argument */
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
// { MODKEY, XK_p, spawn, {.v = dmenucmd } },
// { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
{ MODKEY, XK_b, togglebar, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
{ MODKEY, XK_o, incnmaster, {.i = +1 } },
{ MODKEY, XK_i, incnmaster, {.i = -1 } },
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
{ MODKEY, XK_Return, zoom, {0} },
{ MODKEY, XK_space, zoom, {0} },
{ MODKEY, XK_Tab, view, {0} },
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
{ MODKEY, XK_q, killclient, {0} },
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XK_space, setlayout, {0} },
// { MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ MODKEY, XK_agrave, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_agrave, tag, {.ui = ~0 } },
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
{ MODKEY, XK_period, focusmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2)
TAGKEYS( XK_4, 3)
TAGKEYS( XK_5, 4)
TAGKEYS( XK_6, 5)
TAGKEYS( XK_7, 6)
TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8)
{ MODKEY, XK_less, setgaps, {.i = -1 } },
{ MODKEY|ShiftMask, XK_less, setgaps, {.i = +1 } },
{ MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
TAGKEYS( XK_ampersand, 0)
TAGKEYS( XK_eacute, 1)
TAGKEYS( XK_quotedbl, 2)
TAGKEYS( XK_apostrophe, 3)
TAGKEYS( XK_parenleft, 4)
TAGKEYS( XK_minus, 5)
TAGKEYS( XK_egrave, 6)
TAGKEYS( XK_underscore, 7)
TAGKEYS( XK_ccedilla, 8)
{ MODKEY|ShiftMask, XK_q, quit, {0} },
{ MODKEY|Mod1Mask, XK_q, quit, {1} },
};
/* button definitions */
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
static Button buttons[] = {
static const Button buttons[] = {
/* click event mask button function argument */
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
{ ClkWinTitle, 0, Button2, zoom, {0} },
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },

View File

@ -1,5 +1,5 @@
# dwm version
VERSION = 6.2
VERSION = 6.4
# Customize below to fit your system
@ -19,10 +19,12 @@ FREETYPELIBS = -lfontconfig -lXft
FREETYPEINC = /usr/include/freetype2
# OpenBSD (uncomment)
#FREETYPEINC = ${X11INC}/freetype2
#KVMLIB = -lkvm
#MANPREFIX = ${PREFIX}/man
# includes and libs
INCS = -I${X11INC} -I${FREETYPEINC}
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res ${KVMLIB}
# flags
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}

104
drw.c
View File

@ -133,19 +133,6 @@ xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
die("no font specified.");
}
/* Do not allow using color fonts. This is a workaround for a BadLength
* error from Xft with color glyphs. Modelled on the Xterm workaround. See
* https://bugzilla.redhat.com/show_bug.cgi?id=1498269
* https://lists.suckless.org/dev/1701/30932.html
* https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916349
* and lots more all over the internet.
*/
FcBool iscol;
if(FcPatternGetBool(xfont->pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) {
XftFontClose(drw->dpy, xfont);
return NULL;
}
font = ecalloc(1, sizeof(Fnt));
font->xfont = xfont;
font->pattern = pattern;
@ -208,7 +195,7 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
/* Wrapper to create color schemes. The caller has to call free(3) on the
* returned color scheme when done using it. */
Clr *
drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
drw_scm_create(Drw *drw, char *clrnames[], size_t clrcount)
{
size_t i;
Clr *ret;
@ -251,12 +238,10 @@ drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int
int
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
{
char buf[1024];
int ty;
unsigned int ew;
int i, ty, ellipsis_x = 0;
unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len;
XftDraw *d = NULL;
Fnt *usedfont, *curfont, *nextfont;
size_t i, len;
int utf8strlen, utf8charlen, render = x || y || w || h;
long utf8codepoint = 0;
const char *utf8str;
@ -264,13 +249,17 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
FcPattern *fcpattern;
FcPattern *match;
XftResult result;
int charexists = 0;
int charexists = 0, overflow = 0;
/* keep track of a couple codepoints for which we have no match. */
enum { nomatches_len = 64 };
static struct { long codepoint[nomatches_len]; unsigned int idx; } nomatches;
static unsigned int ellipsis_width = 0;
if (!drw || (render && !drw->scheme) || !text || !drw->fonts)
if (!drw || (render && (!drw->scheme || !w)) || !text || !drw->fonts)
return 0;
if (!render) {
w = ~w;
w = invert ? invert : ~invert;
} else {
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
@ -282,8 +271,10 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
}
usedfont = drw->fonts;
if (!ellipsis_width && render)
ellipsis_width = drw_fontset_getwidth(drw, "...");
while (1) {
utf8strlen = 0;
ew = ellipsis_len = utf8strlen = 0;
utf8str = text;
nextfont = NULL;
while (*text) {
@ -291,9 +282,27 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
for (curfont = drw->fonts; curfont; curfont = curfont->next) {
charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint);
if (charexists) {
if (curfont == usedfont) {
drw_font_getexts(curfont, text, utf8charlen, &tmpw, NULL);
if (ew + ellipsis_width <= w) {
/* keep track where the ellipsis still fits */
ellipsis_x = x + ew;
ellipsis_w = w - ew;
ellipsis_len = utf8strlen;
}
if (ew + tmpw > w) {
overflow = 1;
/* called from drw_fontset_getwidth_clamp():
* it wants the width AFTER the overflow
*/
if (!render)
x += tmpw;
else
utf8strlen = ellipsis_len;
} else if (curfont == usedfont) {
utf8strlen += utf8charlen;
text += utf8charlen;
ew += tmpw;
} else {
nextfont = curfont;
}
@ -301,36 +310,25 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
}
}
if (!charexists || nextfont)
if (overflow || !charexists || nextfont)
break;
else
charexists = 0;
}
if (utf8strlen) {
drw_font_getexts(usedfont, utf8str, utf8strlen, &ew, NULL);
/* shorten text if necessary */
for (len = MIN(utf8strlen, sizeof(buf) - 1); len && ew > w; len--)
drw_font_getexts(usedfont, utf8str, len, &ew, NULL);
if (len) {
memcpy(buf, utf8str, len);
buf[len] = '\0';
if (len < utf8strlen)
for (i = len; i && i > len - 3; buf[--i] = '.')
; /* NOP */
if (render) {
ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent;
XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg],
usedfont->xfont, x, ty, (XftChar8 *)buf, len);
}
x += ew;
w -= ew;
if (render) {
ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent;
XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg],
usedfont->xfont, x, ty, (XftChar8 *)utf8str, utf8strlen);
}
x += ew;
w -= ew;
}
if (render && overflow)
drw_text(drw, ellipsis_x, y, ellipsis_w, h, 0, "...", invert);
if (!*text) {
if (!*text || overflow) {
break;
} else if (nextfont) {
charexists = 0;
@ -340,6 +338,12 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
* character must be drawn. */
charexists = 1;
for (i = 0; i < nomatches_len; ++i) {
/* avoid calling XftFontMatch if we know we won't find a match */
if (utf8codepoint == nomatches.codepoint[i])
goto no_match;
}
fccharset = FcCharSetCreate();
FcCharSetAddChar(fccharset, utf8codepoint);
@ -351,7 +355,6 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
fcpattern = FcPatternDuplicate(drw->fonts->pattern);
FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue);
FcPatternAddBool(fcpattern, FC_COLOR, FcFalse);
FcConfigSubstitute(NULL, fcpattern, FcMatchPattern);
FcDefaultSubstitute(fcpattern);
@ -368,6 +371,8 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
curfont->next = usedfont;
} else {
xfont_free(usedfont);
nomatches.codepoint[++nomatches.idx % nomatches_len] = utf8codepoint;
no_match:
usedfont = drw->fonts;
}
}
@ -397,6 +402,15 @@ drw_fontset_getwidth(Drw *drw, const char *text)
return drw_text(drw, 0, 0, 0, 0, 0, text, 0);
}
unsigned int
drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n)
{
unsigned int tmp = 0;
if (drw && drw->fonts && text && n)
tmp = drw_text(drw, 0, 0, 0, 0, 0, text, n);
return MIN(n, tmp);
}
void
drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h)
{

3
drw.h
View File

@ -35,11 +35,12 @@ void drw_free(Drw *drw);
Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
void drw_fontset_free(Fnt* set);
unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n);
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
/* Colorscheme abstraction */
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
Clr *drw_scm_create(Drw *drw, char *clrnames[], size_t clrcount);
/* Cursor abstraction */
Cur *drw_cur_create(Drw *drw, int shape);

92
dwm.1
View File

@ -25,9 +25,7 @@ layout, the title of the focused window, and the text read from the root window
name property, if the screen is focused. A floating window is indicated with an
empty square and a maximised floating window is indicated with a filled square
before the windows title. The selected tags are indicated with a different
color. The tags of the focused window are indicated with a filled square in the
top left corner. The tags which are applied to one or more windows are
indicated with an empty square in the top left corner.
color.
.P
dwm draws a small border around windows to indicate the focus state.
.SH OPTIONS
@ -49,112 +47,132 @@ label toggles between tiled and floating layout.
.B Button3
click on a tag label adds/removes all windows with that tag to/from the view.
.TP
.B Mod1\-Button1
.B Mod4\-Button1
click on a tag label applies that tag to the focused window.
.TP
.B Mod1\-Button3
.B Mod4\-Button3
click on a tag label adds/removes that tag to/from the focused window.
.SS Keyboard commands
.TP
.B Mod1\-Shift\-Return
.B Mod4\-Shift\-Return
Start
.BR st(1).
.TP
.B Mod1\-p
.B Mod4\-d
Spawn
.BR dmenu(1)
for launching other programs.
.TP
.B Mod1\-,
.B Mod4\-,
Focus previous screen, if any.
.TP
.B Mod1\-.
.B Mod4\-.
Focus next screen, if any.
.TP
.B Mod1\-Shift\-,
.B Mod4\-Shift\-,
Send focused window to previous screen, if any.
.TP
.B Mod1\-Shift\-.
.B Mod4\-Shift\-.
Send focused window to next screen, if any.
.TP
.B Mod1\-b
.B Mod4\-b
Toggles bar on and off.
.TP
.B Mod1\-t
.B Mod4\-t
Sets tiled layout.
.TP
.B Mod1\-f
.B Mod4\-f
Sets floating layout.
.TP
.B Mod1\-m
.B Mod4\-m
Sets monocle layout.
.TP
.B Mod1\-space
Toggles between current and previous layout.
.\" .B Mod4\-space
.\" Toggles between current and previous layout.
.TP
.B Mod1\-j
.B Mod4\-j
Focus next window.
.TP
.B Mod1\-k
.B Mod4\-k
Focus previous window.
.TP
.B Mod1\-i
.B Mod4\-o
Increase number of windows in master area.
.TP
.B Mod1\-d
.B Mod4\-i
Decrease number of windows in master area.
.TP
.B Mod1\-l
.B Mod4\-l
Increase master area size.
.TP
.B Mod1\-h
.B Mod4\-h
Decrease master area size.
.TP
.B Mod1\-Return
.B Mod4\-space
Zooms/cycles focused window to/from master area (tiled layouts only).
.TP
.B Mod1\-Shift\-c
.B Mod4\-q
Close focused window.
.TP
.B Mod1\-Shift\-space
.B Mod4\-Shift\-space
Toggle focused window between tiled and floating state.
.TP
.B Mod1\-Tab
.B Mod4\-Tab
Toggles to the previously selected tags.
.TP
.B Mod1\-Shift\-[1..n]
.B Mod4\-Shift\-[1..n]
Apply nth tag to focused window.
.TP
.B Mod1\-Shift\-0
.B Mod4\-Shift\-0
Apply all tags to focused window.
.TP
.B Mod1\-Control\-Shift\-[1..n]
.B Mod4\-Control\-Shift\-[1..n]
Add/remove nth tag to/from focused window.
.TP
.B Mod1\-[1..n]
.B Mod4\-[1..n]
View all windows with nth tag.
.TP
.B Mod1\-0
.B Mod4\-0
View all windows with any tag.
.TP
.B Mod1\-Control\-[1..n]
.B Mod4\-Control\-[1..n]
Add/remove all windows with nth tag to/from the view.
.TP
.B Mod1\-Shift\-q
.B Mod4\-<
Decrease the gaps around windows.
.TP
.B Mod4\->
Increase the gaps around windows.
.TP
.B Mod4\-Shift-=
Reset the gaps around windows to
.BR 0 .
.TP
.B Mod4\-Shift\-q
Quit dwm.
.TP
.B Mod4\-Mod1\-q
Restart dwm.
.SS Mouse commands
.TP
.B Mod1\-Button1
.B Mod4\-Button1
Move focused window while dragging. Tiled windows will be toggled to the floating state.
.TP
.B Mod1\-Button2
.B Mod4\-Button2
Toggles focused window between floating and tiled state.
.TP
.B Mod1\-Button3
.B Mod4\-Button3
Resize focused window while dragging. Tiled windows will be toggled to the floating state.
.SH CUSTOMIZATION
dwm is customized by creating a custom config.h and (re)compiling the source
code. This keeps it fast, secure and simple.
.SH SIGNALS
.TP
.B SIGHUP - 1
Restart the dwm process.
.TP
.B SIGTERM - 15
Cleanly terminate the dwm process.
.SH SEE ALSO
.BR dmenu (1),
.BR st (1)

658
dwm.c

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,106 @@
From d5eec73302c622f3eba1ad5e3887aaa1d0a8d9e1 Mon Sep 17 00:00:00 2001
From: David JULIEN <swytch@mailo.com>
Date: Sat, 23 Apr 2022 13:24:34 +0200
Subject: [PATCH] fix: patch application
Patch application got broken by a recent commit. This commit fixes it
and allows for a smooth patching process
---
dwm.c | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/dwm.c b/dwm.c
index 0fc328a..c294e72 100644
--- a/dwm.c
+++ b/dwm.c
@@ -49,7 +49,8 @@
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
-#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
+#define ISVISIBLEONTAG(C, T) ((C->tags & T))
+#define ISVISIBLE(C) ISVISIBLEONTAG(C, C->mon->tagset[C->mon->seltags])
#define LENGTH(X) (sizeof X / sizeof X[0])
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
@@ -147,6 +148,7 @@ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interac
static void arrange(Monitor *m);
static void arrangemon(Monitor *m);
static void attach(Client *c);
+static void attachaside(Client *c);
static void attachstack(Client *c);
static void buttonpress(XEvent *e);
static void checkotherwm(void);
@@ -184,6 +186,7 @@ static void maprequest(XEvent *e);
static void monocle(Monitor *m);
static void motionnotify(XEvent *e);
static void movemouse(const Arg *arg);
+static Client *nexttagged(Client *c);
static Client *nexttiled(Client *c);
static void pop(Client *);
static void propertynotify(XEvent *e);
@@ -409,6 +412,17 @@ attach(Client *c)
c->mon->clients = c;
}
+void
+attachaside(Client *c) {
+ Client *at = nexttagged(c);
+ if(!at) {
+ attach(c);
+ return;
+ }
+ c->next = at->next;
+ at->next = c;
+}
+
void
attachstack(Client *c)
{
@@ -1068,7 +1082,7 @@ manage(Window w, XWindowAttributes *wa)
c->isfloating = c->oldstate = t || c->isfixed;
if (c->isfloating)
XRaiseWindow(dpy, c->win);
- attach(c);
+ attachaside(c);
attachstack(c);
XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
(unsigned char *) &(c->win), 1);
@@ -1198,6 +1212,16 @@ movemouse(const Arg *arg)
}
}
+Client *
+nexttagged(Client *c) {
+ Client *walked = c->mon->clients;
+ for(;
+ walked && (walked->isfloating || !ISVISIBLEONTAG(walked, c->tags));
+ walked = walked->next
+ );
+ return walked;
+}
+
Client *
nexttiled(Client *c)
{
@@ -1423,7 +1447,7 @@ sendmon(Client *c, Monitor *m)
detachstack(c);
c->mon = m;
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
- attach(c);
+ attachaside(c);
attachstack(c);
focus(NULL);
arrange(NULL);
@@ -1906,7 +1930,7 @@ updategeom(void)
m->clients = c->next;
detachstack(c);
c->mon = mons;
- attach(c);
+ attachaside(c);
attachstack(c);
}
if (m == selmon)
--
2.35.1

View File

@ -0,0 +1,90 @@
From 69f91089d9248fa9695eb925956e255a215171b8 Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
Date: Tue, 7 Apr 2020 12:29:08 +0200
Subject: [PATCH] Adding 6.2 center patch with multi-monitor fix and
auto-centering of floating popup windows
---
config.def.h | 6 +++---
dwm.c | 13 +++++++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/config.def.h b/config.def.h
index 1c0b587..44b46e5 100644
--- a/config.def.h
+++ b/config.def.h
@@ -26,9 +26,9 @@ static const Rule rules[] = {
* WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title
*/
- /* class instance title tags mask isfloating monitor */
- { "Gimp", NULL, NULL, 0, 1, -1 },
- { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
+ /* class instance title tags mask iscentered isfloating monitor */
+ { "Gimp", NULL, NULL, 0, 0, 1, -1 },
+ { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1 },
};
/* layout(s) */
diff --git a/dwm.c b/dwm.c
index 4465af1..ab33757 100644
--- a/dwm.c
+++ b/dwm.c
@@ -92,7 +92,7 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int bw, oldbw;
unsigned int tags;
- int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
+ int isfixed, iscentered, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
Client *next;
Client *snext;
Monitor *mon;
@@ -137,6 +137,7 @@ typedef struct {
const char *instance;
const char *title;
unsigned int tags;
+ int iscentered;
int isfloating;
int monitor;
} Rule;
@@ -285,6 +286,7 @@ applyrules(Client *c)
XClassHint ch = { NULL, NULL };
/* rule matching */
+ c->iscentered = 0;
c->isfloating = 0;
c->tags = 0;
XGetClassHint(dpy, c->win, &ch);
@@ -297,6 +299,7 @@ applyrules(Client *c)
&& (!r->class || strstr(class, r->class))
&& (!r->instance || strstr(instance, r->instance)))
{
+ c->iscentered = r->iscentered;
c->isfloating = r->isfloating;
c->tags |= r->tags;
for (m = mons; m && m->num != r->monitor; m = m->next);
@@ -1056,6 +1059,10 @@ manage(Window w, XWindowAttributes *wa)
updatewindowtype(c);
updatesizehints(c);
updatewmhints(c);
+ if (c->iscentered) {
+ c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2;
+ c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2;
+ }
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
grabbuttons(c, 0);
if (!c->isfloating)
@@ -2009,8 +2016,10 @@ updatewindowtype(Client *c)
if (state == netatom[NetWMFullscreen])
setfullscreen(c, 1);
- if (wtype == netatom[NetWMWindowTypeDialog])
+ if (wtype == netatom[NetWMWindowTypeDialog]) {
+ c->iscentered = 1;
c->isfloating = 1;
+ }
}
void
--
2.17.1

View File

@ -0,0 +1,138 @@
From 7b7773458c072e4b24d6ea32d0364a8e402e4a43 Mon Sep 17 00:00:00 2001
From: swy7ch <swy7ch@protonmail.com>
Date: Fri, 8 May 2020 19:07:24 +0200
Subject: [PATCH] [PATCH] update dwm-fullgaps patch to be used with tile layout
update
the recent tile layout changes in commit HEAD~1 (f09418b) broke the
patch
this patch adapt the new `if` statements to take gaps into account
this patch also provides manpage entries for the keybindings
---
config.def.h | 4 ++++
dwm.1 | 10 ++++++++++
dwm.c | 33 +++++++++++++++++++++++----------
3 files changed, 37 insertions(+), 10 deletions(-)
diff --git a/config.def.h b/config.def.h
index 1c0b587..38d2f6c 100644
--- a/config.def.h
+++ b/config.def.h
@@ -2,6 +2,7 @@
/* appearance */
static const unsigned int borderpx = 1; /* border pixel of windows */
+static const unsigned int gappx = 5; /* gaps between 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 */
@@ -84,6 +85,9 @@ static Key keys[] = {
{ MODKEY, XK_period, focusmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
+ { MODKEY, XK_minus, setgaps, {.i = -1 } },
+ { MODKEY, XK_equal, setgaps, {.i = +1 } },
+ { MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2)
diff --git a/dwm.1 b/dwm.1
index 13b3729..0202d96 100644
--- a/dwm.1
+++ b/dwm.1
@@ -140,6 +140,16 @@ View all windows with any tag.
.B Mod1\-Control\-[1..n]
Add/remove all windows with nth tag to/from the view.
.TP
+.B Mod1\--
+Decrease the gaps around windows.
+.TP
+.B Mod1\-=
+Increase the gaps around windows.
+.TP
+.B Mod1\-Shift-=
+Reset the gaps around windows to
+.BR 0 .
+.TP
.B Mod1\-Shift\-q
Quit dwm.
.SS Mouse commands
diff --git a/dwm.c b/dwm.c
index 9fd0286..45a58f3 100644
--- a/dwm.c
+++ b/dwm.c
@@ -119,6 +119,7 @@ struct Monitor {
int by; /* bar geometry */
int mx, my, mw, mh; /* screen size */
int wx, wy, ww, wh; /* window area */
+ int gappx; /* gaps between windows */
unsigned int seltags;
unsigned int sellt;
unsigned int tagset[2];
@@ -200,6 +201,7 @@ static void sendmon(Client *c, Monitor *m);
static void setclientstate(Client *c, long state);
static void setfocus(Client *c);
static void setfullscreen(Client *c, int fullscreen);
+static void setgaps(const Arg *arg);
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
static void setup(void);
@@ -639,6 +641,7 @@ createmon(void)
m->nmaster = nmaster;
m->showbar = showbar;
m->topbar = topbar;
+ m->gappx = gappx;
m->lt[0] = &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)];
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
@@ -1498,6 +1501,16 @@ setfullscreen(Client *c, int fullscreen)
}
}
+void
+setgaps(const Arg *arg)
+{
+ if ((arg->i == 0) || (selmon->gappx + arg->i < 0))
+ selmon->gappx = 0;
+ else
+ selmon->gappx += arg->i;
+ arrange(selmon);
+}
+
void
setlayout(const Arg *arg)
{
@@ -1684,18 +1697,18 @@ tile(Monitor *m)
if (n > m->nmaster)
mw = m->nmaster ? m->ww * m->mfact : 0;
else
- mw = m->ww;
- for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
+ mw = m->ww - m->gappx;
+ for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if (i < m->nmaster) {
- h = (m->wh - my) / (MIN(n, m->nmaster) - i);
- resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
- if (my + HEIGHT(c) < m->wh)
- my += HEIGHT(c);
+ h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
+ resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0);
+ if (my + HEIGHT(c) + m->gappx < m->wh)
+ my += HEIGHT(c) + m->gappx;
} else {
- h = (m->wh - ty) / (n - i);
- resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
- if (ty + HEIGHT(c) < m->wh)
- ty += HEIGHT(c);
+ h = (m->wh - ty) / (n - i) - m->gappx;
+ resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0);
+ if (ty + HEIGHT(c) + m->gappx < m->wh)
+ ty += HEIGHT(c) + m->gappx;
}
}
--
2.26.2

View File

@ -0,0 +1,39 @@
diff --git a/dwm.c b/dwm.c
index a96f33c..f2da729 100644
--- a/dwm.c
+++ b/dwm.c
@@ -432,9 +432,15 @@ buttonpress(XEvent *e)
}
if (ev->window == selmon->barwin) {
i = x = 0;
- do
+ unsigned int occ = 0;
+ for(c = m->clients; c; c=c->next)
+ occ |= c->tags;
+ do {
+ /* Do not reserve space for vacant tags */
+ if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
+ continue;
x += TEXTW(tags[i]);
- while (ev->x >= x && ++i < LENGTH(tags));
+ } while (ev->x >= x && ++i < LENGTH(tags));
if (i < LENGTH(tags)) {
click = ClkTagBar;
arg.ui = 1 << i;
@@ -719,13 +725,12 @@ drawbar(Monitor *m)
}
x = 0;
for (i = 0; i < LENGTH(tags); i++) {
+ /* Do not draw vacant tags */
+ if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
+ continue;
w = TEXTW(tags[i]);
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
- if (occ & 1 << i)
- drw_rect(drw, x + boxs, boxs, boxw, boxw,
- m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
- urg & 1 << i);
x += w;
}
w = blw = TEXTW(m->ltsymbol);

View File

@ -0,0 +1,31 @@
From 700b0bdea872f4c00182b2bd925b41fe03f8d222 Mon Sep 17 00:00:00 2001
From: Aidan Hall <aidan.hall@outlook.com>
Date: Tue, 2 Jun 2020 14:41:53 +0000
Subject: [PATCH] Prevents hiding the border if layout is floating.
---
dwm.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/dwm.c b/dwm.c
index 4465af1..2dd959d 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1282,6 +1282,14 @@ resizeclient(Client *c, int x, int y, int w, int h)
c->oldw = c->w; c->w = wc.width = w;
c->oldh = c->h; c->h = wc.height = h;
wc.border_width = c->bw;
+ if (((nexttiled(c->mon->clients) == c && !nexttiled(c->next))
+ || &monocle == c->mon->lt[c->mon->sellt]->arrange)
+ && !c->isfullscreen && !c->isfloating
+ && NULL != c->mon->lt[c->mon->sellt]->arrange) {
+ c->w = wc.width += c->bw * 2;
+ c->h = wc.height += c->bw * 2;
+ wc.border_width = 0;
+ }
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
configure(c);
XSync(dpy, False);
--
2.26.2

View File

@ -0,0 +1,81 @@
From a3a7e94f59553689656871a65ea9ce90169a7c91 Mon Sep 17 00:00:00 2001
From: birdalicous <jack.bird@durham.ac.uk>
Date: Thu, 15 Jul 2021 12:28:29 +0100
Subject: [PATCH] notitle patch applied#
---
config.def.h | 1 -
dwm.c | 20 ++++----------------
2 files changed, 4 insertions(+), 17 deletions(-)
diff --git a/config.def.h b/config.def.h
index a2ac963..eac20b4 100644
--- a/config.def.h
+++ b/config.def.h
@@ -103,7 +103,6 @@ static Button buttons[] = {
/* click event mask button function argument */
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
- { ClkWinTitle, 0, Button2, zoom, {0} },
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
diff --git a/dwm.c b/dwm.c
index 5e4d494..6cd9fb7 100644
--- a/dwm.c
+++ b/dwm.c
@@ -64,8 +64,8 @@ enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
-enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
- ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
+enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkClientWin,
+ ClkRootWin, ClkLast }; /* clicks */
typedef union {
int i;
@@ -440,10 +440,8 @@ buttonpress(XEvent *e)
arg.ui = 1 << i;
} else if (ev->x < x + blw)
click = ClkLtSymbol;
- else if (ev->x > selmon->ww - (int)TEXTW(stext))
- click = ClkStatusText;
else
- click = ClkWinTitle;
+ click = ClkStatusText;
} else if ((c = wintoclient(ev->window))) {
focus(c);
restack(selmon);
@@ -730,15 +728,8 @@ drawbar(Monitor *m)
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
if ((w = m->ww - tw - x) > bh) {
- if (m->sel) {
- drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
- drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
- if (m->sel->isfloating)
- drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
- } else {
drw_setscheme(drw, scheme[SchemeNorm]);
drw_rect(drw, x, 0, w, bh, 1, 1);
- }
}
drw_map(drw, m->barwin, 0, 0, m->ww, bh);
}
@@ -1236,11 +1227,8 @@ propertynotify(XEvent *e)
drawbars();
break;
}
- if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
+ if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName])
updatetitle(c);
- if (c == c->mon->sel)
- drawbar(c->mon);
- }
if (ev->atom == netatom[NetWMWindowType])
updatewindowtype(c);
}
--
2.32.0

View File

@ -0,0 +1,139 @@
From 2991f37f0aaf44b9f9b11e7893ff0af8eb88f649 Mon Sep 17 00:00:00 2001
From: Christopher Drelich <cd@cdrakka.com>
Date: Wed, 23 May 2018 22:50:38 -0400
Subject: [PATCH] Modifies quit to handle restarts and adds SIGHUP and SIGTERM
handlers.
Modified quit() to restart if it receives arg .i = 1
MOD+CTRL+SHIFT+Q was added to confid.def.h to do just that.
Signal handlers were handled for SIGHUP and SIGTERM.
If dwm receives these signals it calls quit() with
arg .i = to 1 or 0, respectively.
To restart dwm:
MOD+CTRL+SHIFT+Q
or
kill -HUP dwmpid
To quit dwm cleanly:
MOD+SHIFT+Q
or
kill -TERM dwmpid
---
config.def.h | 1 +
dwm.1 | 10 ++++++++++
dwm.c | 22 ++++++++++++++++++++++
3 files changed, 33 insertions(+)
diff --git a/config.def.h b/config.def.h
index a9ac303..e559429 100644
--- a/config.def.h
+++ b/config.def.h
@@ -94,6 +94,7 @@ static Key keys[] = {
TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8)
{ MODKEY|ShiftMask, XK_q, quit, {0} },
+ { MODKEY|ControlMask|ShiftMask, XK_q, quit, {1} },
};
/* button definitions */
diff --git a/dwm.1 b/dwm.1
index 13b3729..36a331c 100644
--- a/dwm.1
+++ b/dwm.1
@@ -142,6 +142,9 @@ Add/remove all windows with nth tag to/from the view.
.TP
.B Mod1\-Shift\-q
Quit dwm.
+.TP
+.B Mod1\-Control\-Shift\-q
+Restart dwm.
.SS Mouse commands
.TP
.B Mod1\-Button1
@@ -155,6 +158,13 @@ Resize focused window while dragging. Tiled windows will be toggled to the float
.SH CUSTOMIZATION
dwm is customized by creating a custom config.h and (re)compiling the source
code. This keeps it fast, secure and simple.
+.SH SIGNALS
+.TP
+.B SIGHUP - 1
+Restart the dwm process.
+.TP
+.B SIGTERM - 15
+Cleanly terminate the dwm process.
.SH SEE ALSO
.BR dmenu (1),
.BR st (1)
diff --git a/dwm.c b/dwm.c
index bb95e26..286eecd 100644
--- a/dwm.c
+++ b/dwm.c
@@ -205,6 +205,8 @@ static void setup(void);
static void seturgent(Client *c, int urg);
static void showhide(Client *c);
static void sigchld(int unused);
+static void sighup(int unused);
+static void sigterm(int unused);
static void spawn(const Arg *arg);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
@@ -260,6 +262,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
[UnmapNotify] = unmapnotify
};
static Atom wmatom[WMLast], netatom[NetLast];
+static int restart = 0;
static int running = 1;
static Cur *cursor[CurLast];
static Clr **scheme;
@@ -1248,6 +1251,7 @@ propertynotify(XEvent *e)
void
quit(const Arg *arg)
{
+ if(arg->i) restart = 1;
running = 0;
}
@@ -1536,6 +1540,9 @@ setup(void)
/* clean up any zombies immediately */
sigchld(0);
+ signal(SIGHUP, sighup);
+ signal(SIGTERM, sigterm);
+
/* init screen */
screen = DefaultScreen(dpy);
sw = DisplayWidth(dpy, screen);
@@ -1637,6 +1644,20 @@ sigchld(int unused)
}
void
+sighup(int unused)
+{
+ Arg a = {.i = 1};
+ quit(&a);
+}
+
+void
+sigterm(int unused)
+{
+ Arg a = {.i = 0};
+ quit(&a);
+}
+
+void
spawn(const Arg *arg)
{
if (arg->v == dmenucmd)
@@ -2139,6 +2160,7 @@ main(int argc, char *argv[])
setup();
scan();
run();
+ if(restart) execvp(argv[0], argv);
cleanup();
XCloseDisplay(dpy);
return EXIT_SUCCESS;
--
2.7.4

View File

@ -0,0 +1,101 @@
From 9fd4a02b57aa8a764d8105d5f2f854372f4ef559 Mon Sep 17 00:00:00 2001
From: ViliamKovac1223 <viliamkovac1223@gmail.com>
Date: Sat, 9 Jul 2022 17:35:54 +0200
Subject: [PATCH] add restore patch
---
config.def.h | 2 ++
dwm.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+)
diff --git a/config.def.h b/config.def.h
index 6ec4146..0b91976 100644
--- a/config.def.h
+++ b/config.def.h
@@ -1,5 +1,7 @@
/* See LICENSE file for copyright and license details. */
+#define SESSION_FILE "/tmp/dwm-session"
+
/* appearance */
static const unsigned int borderpx = 1; /* border pixel of windows */
static const unsigned int snap = 32; /* snap pixel */
diff --git a/dwm.c b/dwm.c
index 74cec7e..76b40a2 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1255,11 +1255,63 @@ propertynotify(XEvent *e)
}
}
+void
+saveSession(void)
+{
+ FILE *fw = fopen(SESSION_FILE, "w");
+ for (Client *c = selmon->clients; c != NULL; c = c->next) { // get all the clients with their tags and write them to the file
+ fprintf(fw, "%lu %u\n", c->win, c->tags);
+ }
+ fclose(fw);
+}
+
+void
+restoreSession(void)
+{
+ // restore session
+ FILE *fr = fopen(SESSION_FILE, "r");
+ if (!fr)
+ return;
+
+ char *str = malloc(23 * sizeof(char)); // allocate enough space for excepted input from text file
+ while (fscanf(fr, "%[^\n] ", str) != EOF) { // read file till the end
+ long unsigned int winId;
+ unsigned int tagsForWin;
+ int check = sscanf(str, "%lu %u", &winId, &tagsForWin); // get data
+ if (check != 2) // break loop if data wasn't read correctly
+ break;
+
+ for (Client *c = selmon->clients; c ; c = c->next) { // add tags to every window by winId
+ if (c->win == winId) {
+ c->tags = tagsForWin;
+ break;
+ }
+ }
+ }
+
+ for (Client *c = selmon->clients; c ; c = c->next) { // refocus on windows
+ focus(c);
+ restack(c->mon);
+ }
+
+ for (Monitor *m = selmon; m; m = m->next) // rearrange all monitors
+ arrange(m);
+
+ free(str);
+ fclose(fr);
+
+ // delete a file
+ remove(SESSION_FILE);
+}
+
void
quit(const Arg *arg)
{
if(arg->i) restart = 1;
running = 0;
+
+ if (restart == 1)
+ saveSession();
}
Monitor *
@@ -2173,6 +2225,7 @@ main(int argc, char *argv[])
die("pledge");
#endif /* __OpenBSD__ */
scan();
+ restoreSession();
run();
if(restart) execvp(argv[0], argv);
cleanup();
--
2.35.1

View File

@ -0,0 +1,412 @@
From f0cdf40e0a7126838d051eb84d84b91421b771d6 Mon Sep 17 00:00:00 2001
From: 0x1bi <ben@0x1bi.net>
Date: Fri, 11 Dec 2020 10:16:25 -0500
Subject: [PATCH] fix swallow for openbsd
---
config.def.h | 9 +-
config.mk | 3 +-
dwm.c | 235 +++++++++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 237 insertions(+), 10 deletions(-)
diff --git a/config.def.h b/config.def.h
index 1c0b587..fe51476 100644
--- a/config.def.h
+++ b/config.def.h
@@ -3,6 +3,7 @@
/* appearance */
static const unsigned int borderpx = 1; /* border pixel of windows */
static const unsigned int snap = 32; /* snap pixel */
+static const int swallowfloating = 0; /* 1 means swallow floating windows by default */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
static const char *fonts[] = { "monospace:size=10" };
@@ -26,9 +27,11 @@ static const Rule rules[] = {
* WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title
*/
- /* class instance title tags mask isfloating monitor */
- { "Gimp", NULL, NULL, 0, 1, -1 },
- { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
+ /* class instance title tags mask isfloating isterminal noswallow monitor */
+ { "Gimp", NULL, NULL, 0, 1, 0, 0, -1 },
+ { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1, -1 },
+ { "St", NULL, NULL, 0, 0, 1, 0, -1 },
+ { NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, /* xev */
};
/* layout(s) */
diff --git a/config.mk b/config.mk
index 7084c33..ff9e508 100644
--- a/config.mk
+++ b/config.mk
@@ -19,10 +19,11 @@ FREETYPELIBS = -lfontconfig -lXft
FREETYPEINC = /usr/include/freetype2
# OpenBSD (uncomment)
#FREETYPEINC = ${X11INC}/freetype2
+#KVMLIB = -lkvm
# includes and libs
INCS = -I${X11INC} -I${FREETYPEINC}
-LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
+LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res ${KVMLIB}
# flags
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
diff --git a/dwm.c b/dwm.c
index 664c527..0b20086 100644
--- a/dwm.c
+++ b/dwm.c
@@ -40,6 +40,12 @@
#include <X11/extensions/Xinerama.h>
#endif /* XINERAMA */
#include <X11/Xft/Xft.h>
+#include <X11/Xlib-xcb.h>
+#include <xcb/res.h>
+#ifdef __OpenBSD__
+#include <sys/sysctl.h>
+#include <kvm.h>
+#endif /* __OpenBSD */
#include "drw.h"
#include "util.h"
@@ -92,9 +98,11 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int bw, oldbw;
unsigned int tags;
- int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
+ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow;
+ pid_t pid;
Client *next;
Client *snext;
+ Client *swallowing;
Monitor *mon;
Window win;
};
@@ -138,6 +146,8 @@ typedef struct {
const char *title;
unsigned int tags;
int isfloating;
+ int isterminal;
+ int noswallow;
int monitor;
} Rule;
@@ -235,6 +245,12 @@ static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void zoom(const Arg *arg);
+static pid_t getparentprocess(pid_t p);
+static int isdescprocess(pid_t p, pid_t c);
+static Client *swallowingclient(Window w);
+static Client *termforwin(const Client *c);
+static pid_t winpid(Window w);
+
/* variables */
static const char broken[] = "broken";
static char stext[256];
@@ -269,6 +285,8 @@ static Drw *drw;
static Monitor *mons, *selmon;
static Window root, wmcheckwin;
+static xcb_connection_t *xcon;
+
/* configuration, allows nested code to access above variables */
#include "config.h"
@@ -298,6 +316,8 @@ applyrules(Client *c)
&& (!r->class || strstr(class, r->class))
&& (!r->instance || strstr(instance, r->instance)))
{
+ c->isterminal = r->isterminal;
+ c->noswallow = r->noswallow;
c->isfloating = r->isfloating;
c->tags |= r->tags;
for (m = mons; m && m->num != r->monitor; m = m->next);
@@ -414,6 +434,53 @@ attachstack(Client *c)
c->mon->stack = c;
}
+void
+swallow(Client *p, Client *c)
+{
+
+ if (c->noswallow || c->isterminal)
+ return;
+ if (c->noswallow && !swallowfloating && c->isfloating)
+ return;
+
+ detach(c);
+ detachstack(c);
+
+ setclientstate(c, WithdrawnState);
+ XUnmapWindow(dpy, p->win);
+
+ p->swallowing = c;
+ c->mon = p->mon;
+
+ Window w = p->win;
+ p->win = c->win;
+ c->win = w;
+ updatetitle(p);
+ XMoveResizeWindow(dpy, p->win, p->x, p->y, p->w, p->h);
+ arrange(p->mon);
+ configure(p);
+ updateclientlist();
+}
+
+void
+unswallow(Client *c)
+{
+ c->win = c->swallowing->win;
+
+ free(c->swallowing);
+ c->swallowing = NULL;
+
+ /* unfullscreen the client */
+ setfullscreen(c, 0);
+ updatetitle(c);
+ arrange(c->mon);
+ XMapWindow(dpy, c->win);
+ XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
+ setclientstate(c, NormalState);
+ focus(NULL);
+ arrange(c->mon);
+}
+
void
buttonpress(XEvent *e)
{
@@ -653,6 +720,9 @@ destroynotify(XEvent *e)
if ((c = wintoclient(ev->window)))
unmanage(c, 1);
+
+ else if ((c = swallowingclient(ev->window)))
+ unmanage(c->swallowing, 1);
}
void
@@ -1018,12 +1088,13 @@ killclient(const Arg *arg)
void
manage(Window w, XWindowAttributes *wa)
{
- Client *c, *t = NULL;
+ Client *c, *t = NULL, *term = NULL;
Window trans = None;
XWindowChanges wc;
c = ecalloc(1, sizeof(Client));
c->win = w;
+ c->pid = winpid(w);
/* geometry */
c->x = c->oldx = wa->x;
c->y = c->oldy = wa->y;
@@ -1038,6 +1109,7 @@ manage(Window w, XWindowAttributes *wa)
} else {
c->mon = selmon;
applyrules(c);
+ term = termforwin(c);
}
if (c->x + WIDTH(c) > c->mon->mx + c->mon->mw)
@@ -1074,6 +1146,8 @@ manage(Window w, XWindowAttributes *wa)
c->mon->sel = c;
arrange(c->mon);
XMapWindow(dpy, c->win);
+ if (term)
+ swallow(term, c);
focus(NULL);
}
@@ -1768,6 +1842,20 @@ unmanage(Client *c, int destroyed)
Monitor *m = c->mon;
XWindowChanges wc;
+ if (c->swallowing) {
+ unswallow(c);
+ return;
+ }
+
+ Client *s = swallowingclient(c->win);
+ if (s) {
+ free(s->swallowing);
+ s->swallowing = NULL;
+ arrange(m);
+ focus(NULL);
+ return;
+ }
+
detach(c);
detachstack(c);
if (!destroyed) {
@@ -1782,9 +1870,12 @@ unmanage(Client *c, int destroyed)
XUngrabServer(dpy);
}
free(c);
- focus(NULL);
- updateclientlist();
- arrange(m);
+
+ if (!s) {
+ arrange(m);
+ focus(NULL);
+ updateclientlist();
+ }
}
void
@@ -2047,6 +2138,136 @@ view(const Arg *arg)
arrange(selmon);
}
+pid_t
+winpid(Window w)
+{
+
+ pid_t result = 0;
+
+#ifdef __linux__
+ xcb_res_client_id_spec_t spec = {0};
+ spec.client = w;
+ spec.mask = XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID;
+
+ xcb_generic_error_t *e = NULL;
+ xcb_res_query_client_ids_cookie_t c = xcb_res_query_client_ids(xcon, 1, &spec);
+ xcb_res_query_client_ids_reply_t *r = xcb_res_query_client_ids_reply(xcon, c, &e);
+
+ if (!r)
+ return (pid_t)0;
+
+ xcb_res_client_id_value_iterator_t i = xcb_res_query_client_ids_ids_iterator(r);
+ for (; i.rem; xcb_res_client_id_value_next(&i)) {
+ spec = i.data->spec;
+ if (spec.mask & XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID) {
+ uint32_t *t = xcb_res_client_id_value_value(i.data);
+ result = *t;
+ break;
+ }
+ }
+
+ free(r);
+
+ if (result == (pid_t)-1)
+ result = 0;
+
+#endif /* __linux__ */
+
+#ifdef __OpenBSD__
+ Atom type;
+ int format;
+ unsigned long len, bytes;
+ unsigned char *prop;
+ pid_t ret;
+
+ if (XGetWindowProperty(dpy, w, XInternAtom(dpy, "_NET_WM_PID", 0), 0, 1, False, AnyPropertyType, &type, &format, &len, &bytes, &prop) != Success || !prop)
+ return 0;
+
+ ret = *(pid_t*)prop;
+ XFree(prop);
+ result = ret;
+
+#endif /* __OpenBSD__ */
+ return result;
+}
+
+pid_t
+getparentprocess(pid_t p)
+{
+ unsigned int v = 0;
+
+#ifdef __linux__
+ FILE *f;
+ char buf[256];
+ snprintf(buf, sizeof(buf) - 1, "/proc/%u/stat", (unsigned)p);
+
+ if (!(f = fopen(buf, "r")))
+ return 0;
+
+ fscanf(f, "%*u %*s %*c %u", &v);
+ fclose(f);
+#endif /* __linux__*/
+
+#ifdef __OpenBSD__
+ int n;
+ kvm_t *kd;
+ struct kinfo_proc *kp;
+
+ kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, NULL);
+ if (!kd)
+ return 0;
+
+ kp = kvm_getprocs(kd, KERN_PROC_PID, p, sizeof(*kp), &n);
+ v = kp->p_ppid;
+#endif /* __OpenBSD__ */
+
+ return (pid_t)v;
+}
+
+int
+isdescprocess(pid_t p, pid_t c)
+{
+ while (p != c && c != 0)
+ c = getparentprocess(c);
+
+ return (int)c;
+}
+
+Client *
+termforwin(const Client *w)
+{
+ Client *c;
+ Monitor *m;
+
+ if (!w->pid || w->isterminal)
+ return NULL;
+
+ for (m = mons; m; m = m->next) {
+ for (c = m->clients; c; c = c->next) {
+ if (c->isterminal && !c->swallowing && c->pid && isdescprocess(c->pid, w->pid))
+ return c;
+ }
+ }
+
+ return NULL;
+}
+
+Client *
+swallowingclient(Window w)
+{
+ Client *c;
+ Monitor *m;
+
+ for (m = mons; m; m = m->next) {
+ for (c = m->clients; c; c = c->next) {
+ if (c->swallowing && c->swallowing->win == w)
+ return c;
+ }
+ }
+
+ return NULL;
+}
+
Client *
wintoclient(Window w)
{
@@ -2138,10 +2359,12 @@ main(int argc, char *argv[])
fputs("warning: no locale support\n", stderr);
if (!(dpy = XOpenDisplay(NULL)))
die("dwm: cannot open display");
+ if (!(xcon = XGetXCBConnection(dpy)))
+ die("dwm: cannot get xcb connection\n");
checkotherwm();
setup();
#ifdef __OpenBSD__
- if (pledge("stdio rpath proc exec", NULL) == -1)
+ if (pledge("stdio rpath proc exec ps", NULL) == -1)
die("pledge");
#endif /* __OpenBSD__ */
scan();
--
2.28.0

View File

@ -0,0 +1,240 @@
From f30583c6e2ab5e7de6ef4ebf156076ac0f6e69fc Mon Sep 17 00:00:00 2001
From: Jack Bird <jack.bird@durham.ac.uk>
Date: Fri, 27 Aug 2021 00:53:14 +0100
Subject: [PATCH] xresources updated for 138b405
---
config.def.h | 61 ++++++++++++++++++++++++++++++--------------
drw.c | 2 +-
drw.h | 2 +-
dwm.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 116 insertions(+), 21 deletions(-)
diff --git a/config.def.h b/config.def.h
index a2ac963..87ac198 100644
--- a/config.def.h
+++ b/config.def.h
@@ -1,21 +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 int showbar = 1; /* 0 means no bar */
-static const int topbar = 1; /* 0 means bottom bar */
-static const char *fonts[] = { "monospace:size=10" };
-static const char dmenufont[] = "monospace:size=10";
-static const char col_gray1[] = "#222222";
-static const char col_gray2[] = "#444444";
-static const char col_gray3[] = "#bbbbbb";
-static const char col_gray4[] = "#eeeeee";
-static const char col_cyan[] = "#005577";
-static const char *colors[][3] = {
- /* fg bg border */
- [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
- [SchemeSel] = { col_gray4, col_cyan, col_cyan },
+static unsigned int borderpx = 1; /* border pixel of windows */
+static unsigned int snap = 32; /* snap pixel */
+static int showbar = 1; /* 0 means no bar */
+static int topbar = 1; /* 0 means bottom bar */
+static char font[] = "monospace:size=10";
+static char dmenufont[] = "monospace:size=10";
+static const char *fonts[] = { font };
+static char normbgcolor[] = "#222222";
+static char normbordercolor[] = "#444444";
+static char normfgcolor[] = "#bbbbbb";
+static char selfgcolor[] = "#eeeeee";
+static char selbordercolor[] = "#005577";
+static char selbgcolor[] = "#005577";
+static char *colors[][3] = {
+ /* fg bg border */
+ [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor },
+ [SchemeSel] = { selfgcolor, selbgcolor, selbordercolor },
};
/* tagging */
@@ -32,9 +34,9 @@ static const Rule rules[] = {
};
/* layout(s) */
-static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
-static const int nmaster = 1; /* number of clients in master area */
-static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
+static float mfact = 0.55; /* factor of master area size [0.05..0.95] */
+static int nmaster = 1; /* number of clients in master area */
+static int resizehints = 1; /* 1 means respect size hints in tiled resizals */
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
static const Layout layouts[] = {
@@ -57,9 +59,30 @@ static const Layout layouts[] = {
/* commands */
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
-static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
+static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbordercolor, "-sf", selfgcolor, NULL };
static const char *termcmd[] = { "st", NULL };
+/*
+ * Xresources preferences to load at startup
+ */
+ResourcePref resources[] = {
+ { "font", STRING, &font },
+ { "dmenufont", STRING, &dmenufont },
+ { "normbgcolor", STRING, &normbgcolor },
+ { "normbordercolor", STRING, &normbordercolor },
+ { "normfgcolor", STRING, &normfgcolor },
+ { "selbgcolor", STRING, &selbgcolor },
+ { "selbordercolor", STRING, &selbordercolor },
+ { "selfgcolor", STRING, &selfgcolor },
+ { "borderpx", INTEGER, &borderpx },
+ { "snap", INTEGER, &snap },
+ { "showbar", INTEGER, &showbar },
+ { "topbar", INTEGER, &topbar },
+ { "nmaster", INTEGER, &nmaster },
+ { "resizehints", INTEGER, &resizehints },
+ { "mfact", FLOAT, &mfact },
+};
+
static Key keys[] = {
/* modifier key function argument */
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
diff --git a/drw.c b/drw.c
index 4cdbcbe..8f1059e 100644
--- a/drw.c
+++ b/drw.c
@@ -208,7 +208,7 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
/* Wrapper to create color schemes. The caller has to call free(3) on the
* returned color scheme when done using it. */
Clr *
-drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
+drw_scm_create(Drw *drw, char *clrnames[], size_t clrcount)
{
size_t i;
Clr *ret;
diff --git a/drw.h b/drw.h
index 4bcd5ad..42b04ce 100644
--- a/drw.h
+++ b/drw.h
@@ -39,7 +39,7 @@ void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned in
/* Colorscheme abstraction */
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
-Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
+Clr *drw_scm_create(Drw *drw, char *clrnames[], size_t clrcount);
/* Cursor abstraction */
Cur *drw_cur_create(Drw *drw, int shape);
diff --git a/dwm.c b/dwm.c
index 5e4d494..2214b19 100644
--- a/dwm.c
+++ b/dwm.c
@@ -36,6 +36,7 @@
#include <X11/Xlib.h>
#include <X11/Xproto.h>
#include <X11/Xutil.h>
+#include <X11/Xresource.h>
#ifdef XINERAMA
#include <X11/extensions/Xinerama.h>
#endif /* XINERAMA */
@@ -141,6 +142,19 @@ typedef struct {
int monitor;
} Rule;
+/* Xresources preferences */
+enum resource_type {
+ STRING = 0,
+ INTEGER = 1,
+ FLOAT = 2
+};
+
+typedef struct {
+ char *name;
+ enum resource_type type;
+ void *dst;
+} ResourcePref;
+
/* function declarations */
static void applyrules(Client *c);
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
@@ -234,6 +248,8 @@ static int xerror(Display *dpy, XErrorEvent *ee);
static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void zoom(const Arg *arg);
+static void load_xresources(void);
+static void resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst);
/* variables */
static const char broken[] = "broken";
@@ -2127,6 +2143,60 @@ zoom(const Arg *arg)
pop(c);
}
+void
+resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst)
+{
+ char *sdst = NULL;
+ int *idst = NULL;
+ float *fdst = NULL;
+
+ sdst = dst;
+ idst = dst;
+ fdst = dst;
+
+ char fullname[256];
+ char *type;
+ XrmValue ret;
+
+ snprintf(fullname, sizeof(fullname), "%s.%s", "dwm", name);
+ fullname[sizeof(fullname) - 1] = '\0';
+
+ XrmGetResource(db, fullname, "*", &type, &ret);
+ if (!(ret.addr == NULL || strncmp("String", type, 64)))
+ {
+ switch (rtype) {
+ case STRING:
+ strcpy(sdst, ret.addr);
+ break;
+ case INTEGER:
+ *idst = strtoul(ret.addr, NULL, 10);
+ break;
+ case FLOAT:
+ *fdst = strtof(ret.addr, NULL);
+ break;
+ }
+ }
+}
+
+void
+load_xresources(void)
+{
+ Display *display;
+ char *resm;
+ XrmDatabase db;
+ ResourcePref *p;
+
+ display = XOpenDisplay(NULL);
+ resm = XResourceManagerString(display);
+ if (!resm)
+ return;
+
+ db = XrmGetStringDatabase(resm);
+ for (p = resources; p < resources + LENGTH(resources); p++)
+ resource_load(db, p->name, p->type, p->dst);
+ XCloseDisplay(display);
+}
+
int
main(int argc, char *argv[])
{
@@ -2139,6 +2209,8 @@ main(int argc, char *argv[])
if (!(dpy = XOpenDisplay(NULL)))
die("dwm: cannot open display");
checkotherwm();
+ XrmInitialize();
+ load_xresources();
setup();
#ifdef __OpenBSD__
if (pledge("stdio rpath proc exec", NULL) == -1)
--
2.33.0

View File

@ -0,0 +1,354 @@
From 0ea912d5a5808003b572d4d9bc08f985bf1ab7ae Mon Sep 17 00:00:00 2001
From: David JULIEN <swytch@mailo.com>
Date: Sat, 23 Apr 2022 15:57:35 +0200
Subject: [PATCH] feat: personnal config
---
Makefile | 2 +-
config.def.h | 96 +++++++++++++++++++++++++++-------------------------
dwm.1 | 78 +++++++++++++++++++++---------------------
3 files changed, 89 insertions(+), 87 deletions(-)
diff --git a/Makefile b/Makefile
index 77bcbc0..c05dbdd 100644
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,7 @@ dwm: ${OBJ}
${CC} -o $@ ${OBJ} ${LDFLAGS}
clean:
- rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz
+ rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz config.h
dist: clean
mkdir -p dwm-${VERSION}
diff --git a/config.def.h b/config.def.h
index 5b00ea3..7aaece5 100644
--- a/config.def.h
+++ b/config.def.h
@@ -1,14 +1,15 @@
/* See LICENSE file for copyright and license details. */
/* appearance */
-static unsigned int borderpx = 1; /* border pixel of windows */
-static unsigned int gappx = 5; /* gaps between windows */
-static unsigned int snap = 32; /* snap pixel */
-static int swallowfloating = 0; /* 1 means swallow floating windows by default */
-static int showbar = 1; /* 0 means no bar */
-static int topbar = 1; /* 0 means bottom bar */
-static char font[] = "monospace:size=10";
-static char dmenufont[] = "monospace:size=10";
+static unsigned int borderpx = 1; /* border pixel of windows */
+static unsigned int gappx = 5; /* gaps between windows */
+static unsigned int snap = 32; /* snap pixel */
+static int swallowfloating = 0; /* 1 means swallow floating windows by default */
+static int showbar = 1; /* 0 means no bar */
+static int topbar = 1; /* 0 means bottom bar */
+static char font[] = "monospace:size=10";
+static char symbols[] = "monospace:size=10";
+static char dmenufont[] = "monospace:size=10";
static const char *fonts[] = { font };
static char normbgcolor[] = "#222222";
static char normbordercolor[] = "#444444";
@@ -31,10 +32,11 @@ static const Rule rules[] = {
* WM_NAME(STRING) = title
*/
/* class instance title tags mask iscentered isfloating isterminal noswallow monitor */
- { "Gimp", NULL, NULL, 0, 0, 1, 0, 0, -1 },
- { "Firefox", NULL, NULL, 1 << 8, 0, 0, 0, -1, -1 },
- { "St", NULL, NULL, 0, 0, 0, 1, 0, -1 },
- { NULL, NULL, "Event Tester", 0, 0, 0, 0, 1, -1 }, /* xev */
+// { "Gimp", NULL, NULL, 0, 0, 1, 0, 0, -1 },
+// { "Firefox", NULL, NULL, 1 << 8, 0, 0, 0, -1, -1 },
+ { "St", NULL, NULL, 0, 0, 0, 1, -1, -1 },
+ { "floating",NULL, NULL, 0, 1, 1, 1, -1, -1 },
+ { NULL, NULL, "Event Tester", 0, 0, 1, 0, 1, -1 }, /* xev */
};
/* layout(s) */
@@ -51,7 +53,7 @@ static const Layout layouts[] = {
};
/* key definitions */
-#define MODKEY Mod1Mask
+#define MODKEY Mod4Mask
#define TAGKEYS(KEY,TAG) \
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
@@ -63,7 +65,7 @@ static const Layout layouts[] = {
/* commands */
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
-static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbordercolor, "-sf", selfgcolor, NULL };
+static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-p", "run:", NULL };
static const char *termcmd[] = { "st", NULL };
/*
@@ -71,59 +73,61 @@ static const char *termcmd[] = { "st", NULL };
*/
ResourcePref resources[] = {
{ "font", STRING, &font },
+ { "symbols", STRING, &symbols },
{ "dmenufont", STRING, &dmenufont },
- { "normbgcolor", STRING, &normbgcolor },
- { "normbordercolor", STRING, &normbordercolor },
- { "normfgcolor", STRING, &normfgcolor },
- { "selbgcolor", STRING, &selbgcolor },
- { "selbordercolor", STRING, &selbordercolor },
- { "selfgcolor", STRING, &selfgcolor },
+ { "background", STRING, &normbgcolor },
+ { "background", STRING, &normbordercolor },
+ { "normforeground", STRING, &normfgcolor },
+ { "selbackground", STRING, &selbgcolor },
+ { "color2", STRING, &selbordercolor },
+ { "selforeground", STRING, &selfgcolor },
{ "borderpx", INTEGER, &borderpx },
- { "snap", INTEGER, &snap },
- { "showbar", INTEGER, &showbar },
- { "topbar", INTEGER, &topbar },
- { "nmaster", INTEGER, &nmaster },
- { "resizehints", INTEGER, &resizehints },
- { "mfact", FLOAT, &mfact },
+ { "gappx", INTEGER, &gappx },
+ { "snap", INTEGER, &snap },
+ { "showbar", INTEGER, &showbar },
+ { "topbar", INTEGER, &topbar },
+ { "nmaster", INTEGER, &nmaster },
+ { "resizehints", INTEGER, &resizehints },
+ { "mfact", FLOAT, &mfact },
};
static Key keys[] = {
/* modifier key function argument */
- { MODKEY, XK_p, spawn, {.v = dmenucmd } },
- { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
+ // { MODKEY, XK_p, spawn, {.v = dmenucmd } },
+ // { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
{ MODKEY, XK_b, togglebar, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
- { MODKEY, XK_i, incnmaster, {.i = +1 } },
- { MODKEY, XK_d, incnmaster, {.i = -1 } },
+ { MODKEY, XK_o, incnmaster, {.i = +1 } },
+ { MODKEY, XK_i, incnmaster, {.i = -1 } },
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
- { MODKEY, XK_Return, zoom, {0} },
+ { MODKEY, XK_space, zoom, {0} },
{ MODKEY, XK_Tab, view, {0} },
- { MODKEY|ShiftMask, XK_c, killclient, {0} },
+ { MODKEY, XK_q, killclient, {0} },
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
- { MODKEY, XK_space, setlayout, {0} },
+ // { MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
- { MODKEY, XK_0, view, {.ui = ~0 } },
- { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
+ { MODKEY, XK_agrave, view, {.ui = ~0 } },
+ { MODKEY|ShiftMask, XK_agrave, tag, {.ui = ~0 } },
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
{ MODKEY, XK_period, focusmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
- { MODKEY, XK_minus, setgaps, {.i = -1 } },
- { MODKEY, XK_equal, setgaps, {.i = +1 } },
+ { MODKEY, XK_less, setgaps, {.i = -1 } },
+ { MODKEY|ShiftMask, XK_less, setgaps, {.i = +1 } },
{ MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
- TAGKEYS( XK_1, 0)
- TAGKEYS( XK_2, 1)
- TAGKEYS( XK_3, 2)
- TAGKEYS( XK_4, 3)
- TAGKEYS( XK_5, 4)
- TAGKEYS( XK_6, 5)
- TAGKEYS( XK_7, 6)
- TAGKEYS( XK_8, 7)
- TAGKEYS( XK_9, 8)
+ TAGKEYS( XK_ampersand, 0)
+ TAGKEYS( XK_eacute, 1)
+ TAGKEYS( XK_quotedbl, 2)
+ TAGKEYS( XK_apostrophe, 3)
+ TAGKEYS( XK_parenleft, 4)
+ TAGKEYS( XK_minus, 5)
+ TAGKEYS( XK_egrave, 6)
+ TAGKEYS( XK_underscore, 7)
+ TAGKEYS( XK_ccedilla, 8)
{ MODKEY|ShiftMask, XK_q, quit, {0} },
};
diff --git a/dwm.1 b/dwm.1
index 85b3438..230bf30 100644
--- a/dwm.1
+++ b/dwm.1
@@ -25,9 +25,7 @@ layout, the title of the focused window, and the text read from the root window
name property, if the screen is focused. A floating window is indicated with an
empty square and a maximised floating window is indicated with a filled square
before the windows title. The selected tags are indicated with a different
-color. The tags of the focused window are indicated with a filled square in the
-top left corner. The tags which are applied to one or more windows are
-indicated with an empty square in the top left corner.
+color.
.P
dwm draws a small border around windows to indicate the focus state.
.SH OPTIONS
@@ -49,118 +47,118 @@ label toggles between tiled and floating layout.
.B Button3
click on a tag label adds/removes all windows with that tag to/from the view.
.TP
-.B Mod1\-Button1
+.B Mod4\-Button1
click on a tag label applies that tag to the focused window.
.TP
-.B Mod1\-Button3
+.B Mod4\-Button3
click on a tag label adds/removes that tag to/from the focused window.
.SS Keyboard commands
.TP
-.B Mod1\-Shift\-Return
+.B Mod4\-Shift\-Return
Start
.BR st(1).
.TP
-.B Mod1\-p
+.B Mod4\-d
Spawn
.BR dmenu(1)
for launching other programs.
.TP
-.B Mod1\-,
+.B Mod4\-,
Focus previous screen, if any.
.TP
-.B Mod1\-.
+.B Mod4\-.
Focus next screen, if any.
.TP
-.B Mod1\-Shift\-,
+.B Mod4\-Shift\-,
Send focused window to previous screen, if any.
.TP
-.B Mod1\-Shift\-.
+.B Mod4\-Shift\-.
Send focused window to next screen, if any.
.TP
-.B Mod1\-b
+.B Mod4\-b
Toggles bar on and off.
.TP
-.B Mod1\-t
+.B Mod4\-t
Sets tiled layout.
.TP
-.B Mod1\-f
+.B Mod4\-f
Sets floating layout.
.TP
-.B Mod1\-m
+.B Mod4\-m
Sets monocle layout.
.TP
-.B Mod1\-space
-Toggles between current and previous layout.
+.\" .B Mod4\-space
+.\" Toggles between current and previous layout.
.TP
-.B Mod1\-j
+.B Mod4\-j
Focus next window.
.TP
-.B Mod1\-k
+.B Mod4\-k
Focus previous window.
.TP
-.B Mod1\-i
+.B Mod4\-o
Increase number of windows in master area.
.TP
-.B Mod1\-d
+.B Mod4\-i
Decrease number of windows in master area.
.TP
-.B Mod1\-l
+.B Mod4\-l
Increase master area size.
.TP
-.B Mod1\-h
+.B Mod4\-h
Decrease master area size.
.TP
-.B Mod1\-Return
+.B Mod4\-space
Zooms/cycles focused window to/from master area (tiled layouts only).
.TP
-.B Mod1\-Shift\-c
+.B Mod4\-q
Close focused window.
.TP
-.B Mod1\-Shift\-space
+.B Mod4\-Shift\-space
Toggle focused window between tiled and floating state.
.TP
-.B Mod1\-Tab
+.B Mod4\-Tab
Toggles to the previously selected tags.
.TP
-.B Mod1\-Shift\-[1..n]
+.B Mod4\-Shift\-[1..n]
Apply nth tag to focused window.
.TP
-.B Mod1\-Shift\-0
+.B Mod4\-Shift\-0
Apply all tags to focused window.
.TP
-.B Mod1\-Control\-Shift\-[1..n]
+.B Mod4\-Control\-Shift\-[1..n]
Add/remove nth tag to/from focused window.
.TP
-.B Mod1\-[1..n]
+.B Mod4\-[1..n]
View all windows with nth tag.
.TP
-.B Mod1\-0
+.B Mod4\-0
View all windows with any tag.
.TP
-.B Mod1\-Control\-[1..n]
+.B Mod4\-Control\-[1..n]
Add/remove all windows with nth tag to/from the view.
.TP
-.B Mod1\--
+.B Mod4\-<
Decrease the gaps around windows.
.TP
-.B Mod1\-=
+.B Mod4\->
Increase the gaps around windows.
.TP
-.B Mod1\-Shift-=
+.B Mod4\-Shift-=
Reset the gaps around windows to
.BR 0 .
.TP
-.B Mod1\-Shift\-q
+.B Mod4\-Shift\-q
Quit dwm.
.SS Mouse commands
.TP
-.B Mod1\-Button1
+.B Mod4\-Button1
Move focused window while dragging. Tiled windows will be toggled to the floating state.
.TP
-.B Mod1\-Button2
+.B Mod4\-Button2
Toggles focused window between floating and tiled state.
.TP
-.B Mod1\-Button3
+.B Mod4\-Button3
Resize focused window while dragging. Tiled windows will be toggled to the floating state.
.SH CUSTOMIZATION
dwm is customized by creating a custom config.h and (re)compiling the source
--
2.35.1

23
util.c
View File

@ -6,18 +6,9 @@
#include "util.h"
void *
ecalloc(size_t nmemb, size_t size)
{
void *p;
if (!(p = calloc(nmemb, size)))
die("calloc:");
return p;
}
void
die(const char *fmt, ...) {
die(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
@ -33,3 +24,13 @@ die(const char *fmt, ...) {
exit(1);
}
void *
ecalloc(size_t nmemb, size_t size)
{
void *p;
if (!(p = calloc(nmemb, size)))
die("calloc:");
return p;
}