Compare commits

...

300 commits
push ... 0.7

Author SHA1 Message Date
389d476f5b fix monitor scaling 2024-12-13 05:38:32 -08:00
94a804e3d9 libdrm 2024-12-13 05:34:06 -08:00
aad4181ca7 nix footgun fix 2024-12-13 05:15:08 -08:00
132dc5ad5c fix overrideAttrs 2024-12-13 05:04:43 -08:00
e801bcbdb6 flake overlay 2024-12-13 04:57:04 -08:00
7e2bbdbfaf add flake dependencies 2024-12-13 04:52:16 -08:00
8eb6cc467c monitor rules 2024-12-13 04:48:08 -08:00
7d25c6650d start discord on 2 2024-12-13 04:48:08 -08:00
dc6f1cab59 bar patch 2024-12-13 04:48:08 -08:00
49888cdcbb kitty term 2024-12-13 01:25:09 -08:00
70a90ac7b5 super modkey 2024-12-13 01:25:05 -08:00
8cd12ccb2d remove unused flake stuff 2024-12-12 15:46:00 -08:00
1ea7c6d404 remove flake build artifacts 2024-12-12 15:44:57 -08:00
1957bc6e55 flake 2024-12-12 15:42:46 -08:00
57b7b87596 compile_commands 2024-12-12 15:42:35 -08:00
4c6e81631c shell.fish 2024-12-12 15:42:28 -08:00
Leonardo Hernández Hernández
cfc80c8f44
fix crash when a client is created while all outputs are disabled 2024-08-27 23:07:21 -06:00
Leonardo Hernández Hernández
0e0c97db56
changelog: add new 'unreleased' section 2024-08-27 23:07:13 -06:00
Leonardo Hernández Hernández
74e45c4014
bump version to 0.7 2024-08-06 12:03:27 -06:00
Leonardo Hernández Hernández
464dddc110
fix crash when a virtual pointer is destroyed
Fixes: https://codeberg.org/dwl/dwl/issues/680
(cherry picked from commit a634e3f527)
2024-08-06 12:03:27 -06:00
Leonardo Hernández Hernández
cb01023db6
fix crash when re-mapping a client
Fixes: ab5c554d09
(cherry picked from commit b5abbc37d8)
2024-08-01 22:35:10 -06:00
Lennart Jablonka
5bbb0ab404
dwl(1): use correct special characters for - and '
The hyphen-minus <-> and apostrophe-quote <'> are interpreted by troff
as hyphen and right single quotation mark.  See groff_char(7).

Fixes: 0db6f3c5b5 ("add dwl(1)")
(cherry picked from commit f2c5023a3a)
2024-08-01 22:34:51 -06:00
Lennart Jablonka
ed74960373
add myself to .mailmap
(cherry picked from commit 4bbbb4907e)
2024-08-01 22:34:51 -06:00
A Frederick Christensen
cc622d4dd5
Specify that the 0.7 branch builds against wlroots 0.18 2024-08-01 22:31:06 -06:00
A Frederick Christensen
3256ae0679
README.md Fix links formatting issue after re-flow text to 80 columns
(cherry picked from commit ea6a450121)
2024-08-01 22:29:29 -06:00
A Frederick Christensen
e3f1aab770
Documentation restructuring
Modified documentation to make clear the change in development (main) branch versus releases.

(cherry picked from commit ad30ca910b)
2024-08-01 22:29:29 -06:00
Leonardo Hernández Hernández
57153fd557
update README.md to mention the main branch now requires wlroots-git
Closes: https://codeberg.org/dwl/dwl/issues/646
(cherry picked from commit 452a314faa)
2024-08-01 22:29:29 -06:00
Leonardo Hernández Hernández
a9bcdff683
send scale on initial commit to layer surfaces
Signed-off-by: Leonardo Hernández Hernández <leohdz172@proton.me>
(cherry picked from commit cd216908a7)
2024-07-24 07:03:57 -05:00
Leonardo Hernández Hernández
bd59573f07
bump version to 0.7-rc1 2024-07-14 21:25:37 -06:00
Leonardo Hernández Hernández
0060e1922d
prepare CHANGELOG.md for 0.7 2024-07-14 21:25:37 -06:00
Leonardo Hernández Hernández
c709b09e10
changelog: add new 'unreleased' section 2024-07-14 21:13:20 -06:00
Guido Cella
efe10ea655
use the parent scene node to determine if move clients out of LyrFloat
[sevz: commit message is mine]
2024-07-14 21:10:44 -06:00
Leonardo Hernández Hernández
9a962ce136
Reapply "place child clients above fullscreen clients"
This reverts commit 043ab3ac13.
2024-07-14 21:10:44 -06:00
Leonardo Hernández Hernández
0761fd0691
Merge branch 'wlroots-next' 2024-07-14 21:10:44 -06:00
Leonardo Hernández Hernández
12b44421c8
bump to linux-dmabuf version 5 2024-07-13 20:23:04 -06:00
Leonardo Hernández Hernández
5a4839b1c8
bump version to 0.6 2024-07-13 16:34:01 -06:00
Leonardo Hernández Hernández
bd5001b780
prepare CHANGELOG.md for 0.6 2024-07-13 16:30:51 -06:00
Leonardo Hernández Hernández
043ab3ac13
Revert "place child clients above fullscreen clients"
This does not work as intended. Lets revert it temporarily and add it back
after the release.

This reverts commit 298949bbc4.
2024-07-12 21:08:48 -06:00
Rutherther
aede3b294b
Fix applybounds
Applybounds doesn't move client when it overlays
only with border with monitor to the right.

Apparently, c->geom.width already includes the border
as well.
2024-07-03 13:39:32 -06:00
Rutherther
7d8c3ea369
feat: focus empty monitor when clicked 2024-07-03 13:35:29 -06:00
Leonardo Hernández Hernández
2db0a2e8ef
use round(3) and ceilf(3) from the math library
ΔSLOC: -1
2024-07-03 13:27:52 -06:00
Leonardo Hernández Hernández
ab5c554d09
set preferred scale after the first commit (XDGshell) 2024-07-03 13:27:51 -06:00
Leonardo Hernández Hernández
b4638fef29
drop useless maplayersurfacenotify() 2024-07-03 13:27:51 -06:00
Leonardo Hernández Hernández
71f11e6cf6
set O_NONBLOCK flag to stdout 2024-07-01 20:40:54 -06:00
Leonardo Hernández Hernández
2b4893a0ad
add a note about having at least a dummy rule for rules[]
Closes: https://codeberg.org/dwl/dwl/issues/656
2024-06-29 20:41:54 -06:00
Leonardo Hernández Hernández
1002ea04fa
add bugref about why we call updatemons in outputmgrapplyortest 2024-06-25 22:24:38 -06:00
Leonardo Hernández Hernández
5d73134e33
Merge remote-tracking branch 'upstream/main' into wlroots-next 2024-06-25 11:50:42 -06:00
Leonardo Hernández Hernández
46ae075430
set preferred scale on creation (LayerShell) 2024-06-25 11:33:49 -06:00
Leonardo Hernández Hernández
13925eb1da
correctly report position to xwayland clients
Previously we didn't take into account their borders requiring us to add
`borderpx` to override_redirect clients.

Fixes: https://codeberg.org/dwl/dwl/issues/651
2024-06-24 13:32:03 -06:00
Leonardo Hernández Hernández
4a7d1bebf5
add bugref for negative x,y monitor position and xwayland 2024-06-22 00:21:17 -06:00
Leonardo Hernández Hernández
baedf7f791
Merge remote-tracking branch 'upstream/main' into wlroots-next 2024-06-20 23:32:44 -06:00
Leonardo Hernández Hernández
845d3c47bd
Reapply gamma LUT when re-enabling an output using wlr-output-power-management 2024-06-20 23:30:46 -06:00
Leonardo Hernández Hernández
9cdce1b8ff
try to limit (79 characters) the line lenght in the Makefile 2024-06-20 23:29:26 -06:00
Leonardo Hernández Hernández
4cf1d604b8
Merge remote-tracking branch 'upstream/main' into wlroots-next 2024-06-20 22:44:50 -06:00
thanatos
650a918010
Updated power management handling to address issues raised in the PR 2024-06-20 19:11:53 -06:00
David Donahue
2902df94d6
Prevent updatemons() from removing monitors that have been put to sleep from the layout 2024-06-20 19:11:53 -06:00
Emil Miler
9b1f35e42b
Implement support for output power management
This patch is based on the original stale patch by Guido Cella @guidocella.
It has been modified to apply cleanly to the latest v5.0 tag. Since the SLOC
limit is now lifted, this core feature should be merged into dwl upstream.

Thanks to Dima Krasner @dimkr for the cherry-pick.

Closes: #559, #525
2024-06-20 19:11:52 -06:00
Leonardo Hernández Hernández
92d1c286b8
default CC to gcc
posix c99 does not accept `-pedantic`

Fixes: https://codeberg.org/dwl/dwl/issues/584
2024-06-20 18:42:00 -06:00
Rutherther
784b047b38
Check for null monitor in resize function 2024-06-20 17:49:29 -06:00
Rutherther
11baacbec0
Add output to layout after enabled state is committed 2024-06-20 17:49:29 -06:00
Rutherther
16076ec5a4
fix: make sure selmon doesn't get set to disabled mon 2024-06-20 17:49:25 -06:00
Leonardo Hernández Hernández
a8403d7b4d
handle gpu resets
Fixes: https://codeberg.org/dwl/dwl/issues/601
2024-06-20 16:58:31 -06:00
Peter Hofmann
7a46fccdba
Run startup_cmd in new session and kill the entire group
When a user's startup_cmd is a little more complex, e.g. a shell script,
and forks off several processes, then killing only the main child pid
might leave unwanted processes behind on exit. Not all children will
notice when their parent or the compositor has quit.

To fix this, put startup_cmd into its own session and process group, and
kill the entire group on exit.
2024-06-20 16:36:08 -06:00
Forrest Bushstone
c2e7350f2e
Make sure toplevel_from_wlr_surface is called with a valid surface pointer 2024-06-14 01:43:32 -06:00
Leonardo Hernández Hernández
7570dc0a41
minor adjustments in Makefile 2024-06-13 14:46:09 -06:00
Guido Cella
e5a57fb155
use tabs in client.h
Fixes 298949bbc4.
2024-06-12 14:25:58 -06:00
Leonardo Hernández Hernández
57b5e41063
use enum headers when possible 2024-06-08 20:16:16 -06:00
Leonardo Hernández Hernández
f4b6b429ec
Merge remote-tracking branch 'upstream/main' into wlroots-next 2024-06-04 14:03:37 -06:00
Leonardo Hernández Hernández
21205f2f40
make sure clients share the same layer on floating layout 2024-06-04 13:58:16 -06:00
Leonardo Hernández Hernández
8f6fca35d0
create a keyboard group for each virtual keyboard 2024-06-02 23:33:57 -06:00
A Frederick Christensen
bca077b927
Allow negative coordinates in MonitorRules
Monitor/output position (-1, -1) remains as a single indicator value for autoconfigure layout.
Additionally, one minor comment typo is corrected.
2024-06-02 18:54:11 -05:00
Forrest Bushstone
0047ff740a
Replicate dwm behavior for sloppyfocus 2024-05-30 16:24:42 -06:00
Leonardo Hernández Hernández
bf81a128ec
wlroots now allows parallel installs 2024-05-27 23:10:40 -06:00
fauxmight
9825c26cdd dwl-patches overhaul - doc changes 2024-05-10 05:08:54 +00:00
A Frederick Christensen
34b7a57211
Update wmenu-run name 2024-05-05 13:52:25 -05:00
sewn
5c19e23146 switch to wmenu
bemenu is very bloated, turning itself into a library, which makes it
7489 SLOC.

wmenu on the other hand, looks suckless by default, and is only 2000
SLOC, which i also find alot nicer to use, since bemenu does nothing
to replicate the original dmenu feel.
2024-05-05 18:40:23 +00:00
Leonardo Hernández Hernández
3b1f0a8a88
add support for alpha-modifier-v1 (wlroots!4616)
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4616
2024-04-30 12:36:10 -06:00
Leonardo Hernández Hernández
bb73481662
use wlr_renderer_get_texture_formats (wlroots!4644)
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4644
2024-04-21 15:53:59 -06:00
choc
577d8da6d1
put wlr_layer_shell top layer below fullscreen
fixes wlr_layer_shell top clients showing over fullscreen clients
2024-04-04 11:09:05 -06:00
Leonardo Hernández Hernández
72e2ce8b00
Merge remote-tracking branch 'upstream/main' into wlroots-next 2024-04-04 10:50:21 -06:00
Leonardo Hernández Hernández
dd00d994ce
do not set withdrawn state for xwayland clients
Closes: https://codeberg.org/dwl/dwl/issues/573
2024-03-31 21:41:12 -06:00
korei999
f7154d539d
properly resize on configurex11 2024-03-31 21:39:21 -06:00
A Frederick Christensen
3a95d4ed03
Fix rule examples; minimize newbie surprises
Make example rules be actual EXAMPLES.
Now newcomers should not have to ask, "When I start firefox, nothing
happens. What is going on?"

Also clarified a minor typo and a consistency in spacing.
2024-03-26 20:00:46 -05:00
Guido Cella
2b171fd501 fix virtual pointers
When motionabsolute() is called from warpd, event->time_msec is 0, so
motionnotify() doesn't call wlr_cursor_move(). Fix this by explicitly
warping the cursor in this case, like it was done before implementing
pointer constraints.

I don't know if this is a bug in warpd or time_msec is always 0 with
virtual pointers, since the only other software that uses the virtual
pointer protocol I know of is wl-kbptr, and I can't get that to work
with dwl at all.
2024-03-11 19:01:13 +01:00
Forrest Bushstone
ea33ce9ae6
Support pointer constraints and relative pointer protocols
Fixes: https://codeberg.org/dwl/dwl/issues/489
FIxes: https://codeberg.org/dwl/dwl/issues/317
2024-03-11 11:34:26 -06:00
Leonardo Hernández Hernández
a0117eea76
use enums from the wayland protocol (wlroots!4575)
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4575
2024-02-29 14:05:09 -06:00
Leonardo Hernández Hernández
7b3eb70501
misc fixes to xdg-toplevel-decoration 2024-02-06 20:37:36 -06:00
Leonardo Hernández Hernández
c215e8a3e1
send initial configure to xdg-toplevels (wlroots!4396)
We still need to fix xdg-popups

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4396
2024-02-06 20:30:40 -06:00
Leonardo Hernández Hernández
8e0b5baf8e
Merge remote-tracking branch 'upstream/main' into wlroots-next 2024-02-07 02:27:07 +00:00
Guido Cella
8006e79200
allow toggling the layout before selecting a different one 2024-02-07 02:23:33 +00:00
Leonardo Hernández Hernández
5ae245beed
fix minimum size
continuation of 4043fc3093
2024-02-07 02:21:26 +00:00
A Frederick Christensen
089480e0b6
Update and correct patches/patches-wiki links
Signed-off-by: Leonardo Hernández Hernández <leohdz172@proton.me>
2024-02-06 19:53:13 -06:00
Benjamin Chausse
3c98c4c24d Fix link to patches website
Signed-off-by: Benjamin Chausse <benjamin@chausse.xyz>
2024-02-06 00:39:01 +00:00
Guido Cella
298949bbc4
place child clients above fullscreen clients
When a child window of a fullscreen client is mapped, the fullscreen is
disabled, and if the previously fullscreen client is floating the child
window is rendered below it and cannot be seen, causing confusion,
though it is still focused and interactable.

Fix this by putting children of fullscreen clients in LyrFS instead of
LyrFloat, and by returning before the unset_fullscreen code is called
when they are mapped.

focusstack() now lets you switch focus from a fullscreen client to its
child windows, otherwise if you switch focus from the child window to
the fullscreen client you could not focus the child window again and the
fullscreen client would stay unresponsive.

Child clients are not reparented to LyrFloat after leaving fullscreen,
so you could spawn a child window, focus back the fullscreen client,
unfullscreen it, and the child window would still be drawn above other
floating clients. Avoid dealing with this edge case to keep the line
count low.

These cases can be tested by pressing Ctrl+o in applications with an
open file dialog.
2024-02-05 16:00:28 -06:00
Guido Cella
17c5cbbf7b
make XWayland clients inherit tags and monitors
Revert 3213088 because the linked bug can no longer be reproduced with
wlroots 0.17, and update client_get_parent() so it doesn't segfault with
XWayland surfaces. This also allows reusing the p variable in the next
commit.
2024-02-05 15:59:46 -06:00
Guido Cella
45e3694fc8
remove useless wlr_scene_node_reparent() calls
These don't do anything because wlr_scene_node_reparent() is immediately
called again by setfloating() through setmon(). They are also a source
of confusion because if you change the wlr_scene_node_reparent() call in
applyrules() it takes a while to understand why it doesn't work.
2024-02-05 15:59:46 -06:00
Leonardo Hernández Hernández
5c936efc42
Revert "No need to call updatemons ourselves"
Fixes: https://codeberg.org/dwl/dwl/issues/577

This reverts commit 26d7c9689f.
2024-01-30 22:54:54 -06:00
A Frederick Christensen
9830a991ff
Correct specifier-data_type mismatches 2024-01-26 23:12:35 -06:00
Guido Cella
863634a61c
configure xwayland surfaces without monitors
For wine clients often configurex11() is called before mapnotify() and
therefore c->mon is NULL. configurex11 just returns early in that case,
letting these clients stay in the wrong size. For example only the top
left part of winecfg and wine uninstaller is drawn, or confirmation
dialogs like when closing wine notepad are too big. Fix this by
configuring their surfaces like before 88d386b.
2024-01-25 19:47:34 -06:00
Leonardo Hernández Hernández
5fec98b17a
pass wl_event_loop to wlr_backend_autocreate (wlroots!4443)
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4443
2024-01-25 12:12:22 -06:00
Guido Cella
ac6074f4fd
implement the virtual pointer protocol
This is used by programs like warpd.
2024-01-25 17:13:01 +00:00
Leonardo Hernández Hernández
433385f7f1
do not arrange monitor if it's disabled (wlroots!4520)
This causes us to send negative values to xdg-configures (e.g a bug in our end)

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4520
(cherry picked from commit 4043fc3093)
2024-01-24 13:36:46 -06:00
Leonardo Hernández Hernández
4043fc3093
do not arrange monitor if it's disabled (wlroots!4520)
This causes us to send negative values to xdg-configures (e.g a bug in our end)

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4520
2024-01-24 12:12:09 -06:00
Leonardo Hernández Hernández
b3f33e9147
add support for axis_relative_direction event (wlroots!4003)
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4003
2024-01-24 12:10:54 -06:00
Leonardo Hernández Hernández
f136aa088a
Revert "drop wl_drm (wlroots!4397)"
There still a lot software that uses this protocol

This reverts commit facbe57fcb.
2024-01-24 12:09:55 -06:00
Leonardo Hernández Hernández
1c3aaa70ba
Merge remote-tracking branch 'upstream/main' into wlroots-next 2024-01-24 12:09:42 -06:00
Devin J. Pohly
26d7c9689f
No need to call updatemons ourselves
The output manager in wlroots emits an output_layout.change event when
anything changes, so updatemons will be called anyway.

ΔSLOC: -1
2024-01-20 21:51:20 -06:00
Leonardo Hernández Hernández
6c8be38ec4
drop unused variable 2024-01-15 02:19:02 +00:00
Leonardo Hernández Hernández
417e37f988
request description before logs 2024-01-15 02:15:54 +00:00
Leonardo Hernández Hernández
a1f3e25c35
turn on -Wfloat-conversion 2024-01-15 02:09:18 +00:00
Leonardo Hernández Hernández
0151bd48dd
turn on -Wsign-compare 2024-01-15 02:09:18 +00:00
A Frederick Christensen
337d6ba3fb
acknowledgements refactoring 2024-01-14 09:01:49 -06:00
Leonardo Hernández Hernández
ec557f253b
clarify the code will be kept as small as possible 2024-01-12 22:34:09 -06:00
choc
fd263041a0 check if monitor is null before setting gamma
fixes segfault on monitor disconnect when using wlsunset
2024-01-11 17:17:57 +08:00
Leonardo Hernández Hernández
a73afc66ab
drop SLOC limit 2024-01-10 20:50:34 -06:00
Leonardo Hernández Hernández
facbe57fcb
drop wl_drm (wlroots!4397)
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4397
2024-01-10 18:13:31 -06:00
Leonardo Hernández Hernández
f5b046ce9e
prefer functionality over philosophy 2024-01-10 00:20:11 -06:00
Leonardo Hernández Hernández
6340989c8e
add acknowledgment to djpohly 2024-01-10 00:17:06 -06:00
Ben Jargowsky
25e34e4d0c Destroy fullscreen node after moving clients off mon 2024-01-06 17:34:08 -08:00
Leonardo Hernández Hernández
668022bc90
don't send configure events to uninitialized xdg-toplevels 2024-01-05 11:12:34 -06:00
Leonardo Hernández Hernández
c222468887
don't send configure events to uninitialized xdg-popups 2024-01-05 11:08:50 -06:00
Leonardo Hernández Hernández
f3c4f72314
fix posible NULL-dereference in wl_surface.commit handler 2024-01-01 00:51:01 -06:00
Leonardo Hernández Hernández
05c263de45
only create wlr_presentation (wlroots!4482)
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4482
2023-12-27 11:45:36 -06:00
Leonardo Hernández Hernández
bf35e77811
Merge remote-tracking branch 'upstream/main' into wlroots-next 2023-12-27 11:22:11 -06:00
Leonardo Hernández Hernández
6cbf8e9b80
unset DISPLAY before setting up xwayland 2023-12-27 11:19:03 -06:00
Leonardo Hernández Hernández
d13015381b
only execute the first keybinding 2023-12-27 11:18:24 -06:00
Leonardo Hernández Hernández
e277d84c51
more style fixes
missed from the previous iteration
2023-12-27 11:17:52 -06:00
Leonardo Hernández Hernández
bf5a6be73c
Merge remote-tracking branch 'upstream/main' into wlroots-next 2023-12-26 16:21:28 -06:00
Leonardo Hernández Hernández
1f0afcfc28
create a wlr_keyboard_group for virtual keyboards
Fixes: https://codeberg.org/dwl/dwl/issues/554
2023-12-25 21:19:59 -06:00
Leonardo Hernández Hernández
23fd312409
fix typo
Fixes: 7afdc191fe
Thanks to: David Donahue <david.donahue2996@gmail.com>
2023-12-18 14:08:09 -06:00
Leonardo Hernández Hernández
e39d931430
tie xdg_toplevel_decorations to Client
a xdg_toplevel can only have one xdg_toplevel_decoration so there is no need to
have a new struct for decorations
2023-12-18 12:59:47 -06:00
Leonardo Hernández Hernández
396840cdf2
Revert "nuke CSDs, hopefully for good!"
The compositor must respond to the client requesting a change to the decoration
mode, it does not matter if the compositor chooses a different mode.

This reverts commit 9071ce6c84.
2023-12-18 12:56:20 -06:00
Leonardo Hernández Hernández
a71b368483
Revert "remove typedef Decoration"
This reverts commit d1ff1e6f75.
2023-12-18 12:56:19 -06:00
Leonardo Hernández Hernández
7afdc191fe
style fixes 2023-12-17 21:42:50 +00:00
David Donahue
023efce6eb
use wlr_keyboard_group to manage all keyboards 2023-12-17 21:41:39 +00:00
Leonardo Hernández Hernández
fa660fb61e
check toplevel resources
it's just a aesthetic change
2023-12-12 22:21:32 -06:00
Leonardo Hernández Hernández
126a333354
Merge remote-tracking branch 'upstream/main' into wlroots-next
Fixes: https://codeberg.org/dwl/dwl/issues/432
Fixes: https://codeberg.org/dwl/dwl/issues/547
2023-12-11 00:31:17 -06:00
Dima Krasner
9a84789ff1
restore and respect rootcolor 2023-12-11 00:30:17 -06:00
Leonardo Hernández Hernández
49bfe92703
merge X11Managed and X11Unmanaged into X11
now that client_is_unmanaged() checks the wlr struct we don't need to keep
track of it ourselves
2023-12-10 23:46:49 -06:00
Leonardo Hernández Hernández
c88960751d
check if a client is unmanaged checking the o-r flag
it may change at any moment and I don't really want to add a listener for it
2023-12-10 23:46:40 -06:00
Leonardo Hernández Hernández
9c5bdcfbe8
do not blindly try to send motion events when pointer button is pressed
we don't have to do this if the surface is the same
2023-12-10 23:27:59 -06:00
Leonardo Hernández Hernández
0de7d1aa71
Merge branch 'main' into wlroots-next 2023-12-07 22:43:13 -06:00
Leonardo Hernández Hernández
1884a07646
sort LISTEN calls in createnotify{,x11} 2023-12-07 22:40:59 -06:00
Leonardo Hernández Hernández
79c51a4584
use the same style for urgent() and sethints() 2023-12-07 22:37:35 -06:00
Leonardo Hernández Hernández
f5d839844d
remove an unneeded cast in createpointer() 2023-12-07 22:37:00 -06:00
Leonardo Hernández Hernández
e03896b4d6
avoid duplication of lines
the output state is copied when creating a output configuration head
2023-12-07 22:18:49 -06:00
Leonardo Hernández Hernández
e7e84b1083
add explanation about why we try to re-apply the gamma LUT on output changes 2023-12-07 22:17:48 -06:00
Leonardo Hernández Hernández
9694477b2f
relax a bit the line length limit 2023-12-07 22:16:13 -06:00
Leonardo Hernández Hernández
6a15167754
add a blank line to improve readability 2023-12-07 22:15:42 -06:00
Leonardo Hernández Hernández
e5e2d1c28f
use (struct wlr_box){0} to empty the Monitor areas 2023-12-07 22:04:24 -06:00
Leonardo Hernández Hernández
bdbfb45d66
copy layout symbol when matching a MonitorRule 2023-12-07 21:51:24 -06:00
Leonardo Hernández Hernández
50ea84c5f6
remove extra blank line 2023-12-07 21:49:26 -06:00
Leonardo Hernández Hernández
472a31b5a4
LayerSurface::link -> LayerSurface.link 2023-12-07 21:48:56 -06:00
Leonardo Hernández Hernández
a760757b82
set the correct border color when mapping a client 2023-12-07 21:44:53 -06:00
Leonardo Hernández Hernández
80c9ad12ba
reduce calls to client_get_geometry 2023-12-07 21:43:48 -06:00
Leonardo Hernández Hernández
7341d047da
add a note about not removing the default rule
Closes: https://codeberg.org/dwl/dwl/issues/527
2023-12-07 14:20:49 -06:00
fictitiousexistence
be2a1dea26
Update README.md 2023-12-07 14:19:42 -06:00
Leonardo Hernández Hernández
393078d80c
store the layersurface pointer in l->popups->node.data as well 2023-12-07 14:19:09 -06:00
Leonardo Hernández Hernández
28ec843aee
make sure popups of a layer surface are in the correct layer
previously it worked because we checked in every commit the layer
in a353eee2ca and
b100b446b8
we changed the way it's handled and now if the layer surface does not change
the layer we don't it either. meaning that if it was created in the bottom
layer and did not change the layer the popups would show behind xdg clients
2023-12-07 14:19:02 -06:00
Leonardo Hernández Hernández
2b3504e439
sort #includes 2023-12-01 21:35:50 -06:00
Leonardo Hernández Hernández
bab5c0185a
Merge remote-tracking branch 'upstream/main' into wlroots-next 2023-11-30 22:44:52 -06:00
Leonardo Hernández Hernández
5f7d396996
don't return early if the first output commit fails 2023-11-30 22:39:03 -06:00
Leonardo Hernández Hernández
901d2e2d9d
check failure of wlr_output_init_render 2023-11-30 22:38:52 -06:00
Leonardo Hernández Hernández
00e867d536
use detached output state in createmon()
see previous commit for motivation
2023-11-30 22:38:39 -06:00
Leonardo Hernández Hernández
2e29189b92
use a detached output state in outputmgrapplyortest()
wlr_output.pending might be removed in wlroots 0.18
2023-11-30 22:38:11 -06:00
Leonardo Hernández Hernández
43f31b8f1b
improve the bug report template
Fixes: https://codeberg.org/dwl/dwl/issues/498
2023-11-28 23:03:35 -06:00
Leonardo Hernández Hernández
ff39cac355
convert issue templates to yaml
also move the templates to .gitea to reflect the migration to Codeberg
2023-11-28 21:28:51 -06:00
Leonardo Hernández Hernández
70c5fcc23d
chase xdg-shell events update (wlroots!4345)
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4345
2023-11-27 00:06:03 -06:00
Leonardo Hernández Hernández
3fe3581a59
chase wlr_layer_shell_v1.new_surface changes (wlroots!4265)
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4265
2023-11-27 00:06:03 -06:00
Leonardo Hernández Hernández
057d50af8c
pass wl_display to wlr_output_layout_create (wlroots!4310)
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4310
2023-11-27 00:06:03 -06:00
Leonardo Hernández Hernández
2e4fdc1664
use l instead of layersurface
`layer_surface` instead of `wlr_layer_surface`
and `scene_layer` whenever a wlr_scene_tree is related to layer surfaces
2023-11-25 19:18:19 -06:00
Leonardo Hernández Hernández
b100b446b8
return early if a layersurface didn't commit something 2023-11-25 19:17:32 -06:00
Leonardo Hernández Hernández
9cb1ece6cc
do not check if a layer surface has monitor on commit
We do not allow creating them w/o monitor and they are destroyed when
destroying their monitor
2023-11-25 19:17:32 -06:00
Leonardo Hernández Hernández
01a237bd5c
send wl_surface.enter before initial commit
It's not necessary but it'll help clients to render a perfect first frame
2023-11-25 19:17:32 -06:00
Leonardo Hernández Hernández
a5e068b20a
destroy the layer-suface's scene tree for popups 2023-11-25 19:16:33 -06:00
Leonardo Hernández Hernández
39f4ee564b
use wlr_box_equal() instead of memcmp 2023-11-25 19:08:56 -06:00
Leonardo Hernández Hernández
a353eee2ca
simplify settings popups scene tree parent 2023-11-25 19:06:17 -06:00
Leonardo Hernández Hernández
66ec028b00
simplify check for wlr_layer_surface.output 2023-11-25 19:05:27 -06:00
Leonardo Hernández Hernández
1f10e69b4c
use sizeof(*pointer) instead of sizeof(struct) 2023-11-25 19:04:57 -06:00
Leonardo Hernández Hernández
922e117fc5
add new 'unreleased' section 2023-11-25 19:04:08 -06:00
Leonardo Hernández Hernández
2783e82bf8
make sure to unlink Monitor.request_state listener 2023-11-25 18:53:18 -06:00
Squibid
66ef4ecfec
Change github links to codeberg links in README.md 2023-11-25 10:54:56 -06:00
Leonardo Hernández Hernández
d08e6a3a7e
include CHANGELOG.md in the tarball
Fixes: 24576f1fdf
2023-11-25 01:22:48 -06:00
Leonardo Hernández Hernández
f579dd8668
bump version to 0.5 2023-11-25 00:28:11 -06:00
Leonardo Hernández Hernández
24576f1fdf
add CHANGELOG.md 2023-11-25 00:21:53 -06:00
Leonardo Hernández Hernández
7ac76219df
Merge branch 'wlroots-next' 2023-11-25 00:04:19 -06:00
Leonardo Hernández Hernández
6838f909bd
try to apply gamma LUT in updatemons
this in the case the output was re-enabled
2023-11-21 20:41:36 -06:00
Leonardo Hernández Hernández
d2dd2f4986
ignore wl_surface.commit for xwayland clients
This is no longer needed
2023-11-21 20:16:26 -06:00
Leonardo Hernández Hernández
a0e79d8145
Do not send repeated xdg_toplevel.configure_bounds
Fixes: 32e66f4582
2023-11-21 20:15:46 -06:00
Leonardo Hernández Hernández
32e66f4582
resize clients on commit
Fixes: https://github.com/djpohly/dwl/issues/515
This reverts commit 4567979b16.
2023-11-21 20:15:00 -06:00
link2xt
b4da97446a createkeyboard: do not segfault if xkb_keymap_new_from_names returns NULL
Passing NULL to wlr_keyboard_set_keymap results in a segfault.
Example:

  Thread 1 "dwl" received signal SIGSEGV, Segmentation fault.
  0x00007ffff7e49b64 in xkb_keymap_ref () from /usr/lib/libxkbcommon.so.0
  (gdb) bt
  #0  0x00007ffff7e49b64 in xkb_keymap_ref () at /usr/lib/libxkbcommon.so.0
  #1  0x00007ffff7f06389 in wlr_keyboard_set_keymap () at /usr/lib/libwlroots.so.11
  #2  0x000055555555bc54 in createkeyboard ()
  #3  0x000055555555c283 in inputdevice ()
  #4  0x00007ffff7e8101e in wl_signal_emit_mutable () at /usr/lib/libwayland-server.so.0
  #5  0x00007ffff7e8101e in wl_signal_emit_mutable () at /usr/lib/libwayland-server.so.0
  #6  0x00007ffff7edb52c in  () at /usr/lib/libwlroots.so.11
  #7  0x00007ffff7ee44b6 in  () at /usr/lib/libwlroots.so.11
  #8  0x000055555555fe66 in main ()
2023-11-19 01:14:35 -06:00
Leonardo Hernández Hernández
2751a6195d
do not try to enable adaptive sync 2023-11-18 11:20:56 -06:00
Leonardo Hernández Hernández
fcf324be6c
fix the position of the cursor image after turning all the monitors on 2023-11-17 19:03:23 -06:00
Leonardo Hernández Hernández
b8e933b9a9
remove unused #include 2023-11-17 11:03:33 -06:00
Leonardo Hernández Hernández
1044a21555
do not check if session is non-NULL
wlr_session_change_vt() is a no-op if session == NULL
2023-11-17 11:03:33 -06:00
Leonardo Hernández Hernández
6bcd5d8d87
do not explicitly destroy some wlroots interfaces
they are destroyed when the wayland display is destroyed
2023-11-17 11:03:32 -06:00
Leonardo Hernández Hernández
7611dc91d7
enable debug symbols by default
they does not affect performance and the size's increase is negligible
2023-11-17 11:03:32 -06:00
Leonardo Hernández Hernández
e95f14541a
fix docs
copied from tinywl
2023-11-17 11:03:32 -06:00
Leonardo Hernández Hernández
bca1b779aa
fix destroynotify() docs
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4421
2023-11-17 11:03:32 -06:00
Leonardo Hernández Hernández
7bdbab0400
check toplevel resource instead of client's xdg_shell to set bounds 2023-11-17 11:03:32 -06:00
Leonardo Hernández Hernández
dd25cdb56e
use the new wlroots function to get a toplevel from a wlr_surface
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4419
2023-11-17 11:03:32 -06:00
Leonardo Hernández Hernández
caac2d664d
explicitly return -1 in the first check in toplevel_from_wlr_surface 2023-11-17 11:03:31 -06:00
Leonardo Hernández Hernández
b1740056d5
do not use #ifdef -> #else -> #endif in client_is_x11
all other funcions use #ifdef -> #endif
2023-11-17 11:03:31 -06:00
Leonardo Hernández Hernández
0067c76cab
delete unused functions 2023-11-17 11:03:31 -06:00
Leonardo Hernández Hernández
22d21676b0
style fixes in client_is_float_type 2023-11-17 11:03:31 -06:00
Leonardo Hernández Hernández
d6c102d9db
correctly check if the scene node is enabled in client_is_rendered_on_mon 2023-11-17 11:03:31 -06:00
Leonardo Hernández Hernández
0e897608a1
do not use magical numbers to check edges
the interface is declared stable, which means we could just use 0 anyway
2023-11-17 11:03:31 -06:00
Leonardo Hernández Hernández
6d0ec595d3
simplify client_get_clip
the clips for xwayland and xdg clients are pretty similar, after all we only
need to adjust x and y for xdg clients
2023-11-17 11:03:31 -06:00
Leonardo Hernández Hernández
4f4c540bb9
prevent a use-after-free at exit 2023-11-17 11:03:30 -06:00
Leonardo Hernández Hernández
8e3f5364d3
do not compute layout box twice 2023-11-17 11:03:30 -06:00
Leonardo Hernández Hernández
2212363225
make sure fullscreen clients have the right size 2023-11-17 11:03:30 -06:00
Leonardo Hernández Hernández
6f8a3f9374
fix screen artifacts when setting gamma
the artifacts were caused because we tried to set the gamma right after
receiving the event, this resulted in two pending page-flips, which
not always play well together.

This also seems to fix a screen freeze when turning on a monitor that has
gamma.

Additionally the current method won't work once [0] is merged

[0]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4423
2023-11-17 11:01:30 -06:00
Leonardo Hernández Hernández
e1f3983bf8
use wlr_scene_subsurface_tree_set_clip
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4131
Closes: https://github.com/djpohly/dwl/issues/411
2023-11-14 19:44:43 -06:00
Leonardo Hernández Hernández
31bf1cbaf6
Revert "respect size hints"
This reverts commit 72e0a560d9.
2023-11-14 19:44:28 -06:00
Leonardo Hernández Hernández
d6fabe3a15
add a comment about chvt keybindings
Closes: https://github.com/djpohly/dwl/issues/427
2023-11-01 12:44:16 -06:00
Leonardo Hernández Hernández
a4a83e95e6
use newer cursor naming spec
References: https://www.freedesktop.org/wiki/Specifications/cursor-spec/
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4416
2023-11-01 12:28:19 -06:00
Leonardo Hernández Hernández
e45ded7eea
ignore maximize events for clients using xdg-shell v5 and newer 2023-11-01 12:16:02 -06:00
Leonardo Hernández Hernández
e5e74acfce
send maximized if tiled isn't supported (XDG shell)
wlroots doesn't do it automatically anymore

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4409
2023-11-01 12:04:59 -06:00
Leonardo Hernández Hernández
892a4d3ec7
Merge remote-tracking branch 'upstream/main' into wlroots-next 2023-10-13 17:10:25 -06:00
Leonardo Hernández Hernández
ab87410023
clarify the dependencies needed by dwl
Note that previous df131cdb78 libX11 headers
were also required for building (but not for runtime)

Also, I want to apologize to the packagers for do not list *all* the required
dependencies before.
2023-10-11 20:08:44 -06:00
Leonardo Hernández Hernández
7085057f6d
update README.md
these things were changed in the code but not in the readme
2023-10-11 19:59:58 -06:00
Ben Collerson
8c79f8dc15
check client is mapped before setting border color
For some reason brave configured for as a wayland client triggers this code on startup and segfaults.

Checking if the client is mapped fixes this, like with the previous fix for urgent border colour.

References: 887fde65a3
Fixes: 72a7d78a1a
2023-10-10 10:16:11 -06:00
Leonardo Hernández Hernández
8781f4dbf5
Merge remote-tracking branch 'upstream/main' into wlroots-next 2023-10-09 22:37:36 -06:00
Leonardo Hernández Hernández
df131cdb78
use <xcb/xcb.h> instead of <X11/Xlib.h> 2023-10-09 22:33:37 -06:00
Leonardo Hernández Hernández
887fde65a3
only set border color for urgent *and* mapped X11 clients
this fixes a segfault when the client emits .set_hints but it's not mapped

Fixes: 72a7d78a1a
2023-10-09 22:32:15 -06:00
Leonardo Hernández Hernández
b299e01e44
Merge remote-tracking branch 'upstream/main' into wlroots-next 2023-10-09 11:45:51 -06:00
Leonardo Hernández Hernández
6d9a915fb6
Revert "just add define"
I'm going to make some changes in the config file anyway

This reverts commit e5367753bb.
2023-10-09 11:12:24 -06:00
Leonardo Hernández Hernández
935b852dc5
add [-d] flag to enable debug logging 2023-10-09 11:11:33 -06:00
Leonardo Hernández Hernández
a18c528300
simplify setting the border color of clients 2023-10-09 11:05:41 -06:00
Leonardo Hernández Hernández
72a7d78a1a
make the borders red borders for urgent clients
iirc this is the same behavior of dwm
2023-10-09 11:04:03 -06:00
Leonardo Hernández Hernández
d63f4078c5
use the same border colors as dwm 2023-10-09 11:03:06 -06:00
Leonardo Hernández Hernández
f4031590cd
add missing url about the COLOR macro 2023-10-05 22:06:30 -06:00
Leonardo Hernández Hernández
0ab1ed6530
add macro to configure colors
Closes: https://github.com/djpohly/dwl/issues/466
2023-10-05 22:03:59 -06:00
Forrest Bushstone
f695674361
Check if c is fullscreen before reparenting it to LyrFloating
Closes: https://github.com/djpohly/dwl/issues/487
2023-09-29 18:01:31 -06:00
Forrest Bushstone
aec21eca1f
make sure that fullscreen clients are on the correct screen when isfloating is true
Bug: https://github.com/djpohly/dwl/issues/487
2023-09-29 18:00:32 -06:00
Leonardo Hernández Hernández
342850487a
include dwl.desktop in the tarbal 2023-09-24 14:43:30 -06:00
Leonardo Hernández Hernández
1333f8cc6e
Merge remote-tracking branch 'upstream/main' into wlroots-next 2023-09-24 11:44:29 -06:00
Leonardo Hernández Hernández
5baf195523
allow specify DATADIR (to install desktop file) 2023-09-24 11:24:39 -06:00
Weiseguy
773bd04764 Add desktop entry file 2023-09-22 19:49:18 -06:00
Angelo Antony
755fcae2af fix typo 2023-09-10 10:42:33 -06:00
Leonardo Hernández Hernández
960c32a7d8
call setfloating in setmon
since in the previous commit we may not applying floating in clients
this is to make sure we do
2023-09-06 22:23:37 -06:00
Leonardo Hernández Hernández
aea8dd6ae1
return early if the client doesn't have monitor in setfloating
there is still a bug, but for now this prevents a segfault

Bug: https://github.com/djpohly/dwl/issues/472
2023-09-06 22:22:21 -06:00
Leonardo Hernández Hernández
c1d8b77f7f
prefer IRC over Discord
I regularly check the discord server, but it is much more likely that I will be
online on IRC, and djpohly does not seem to be active on either.
2023-08-23 00:32:15 -06:00
Ben Collerson
e5367753bb just add define 2023-08-22 22:20:39 -06:00
Ben Collerson
9be85c1117 tagcount should have been a #define 2023-08-22 22:20:39 -06:00
Leonardo Hernández Hernández
4b8c1bf31e
return nothing in xytonode()
we do not use the node
2023-08-22 14:48:29 -06:00
Devin J. Pohly
d7569870b6
Style: use early-return to clarify code
Use an early return to avoid indenting the main logic instead of
wrapping the tail of a function in an if statement.

No functional change, except for a handful of places where printstatus()
was being called spuriously (tag, toggletag, toggleview).

ΔSLOC: 0
2023-08-22 01:44:31 -06:00
Devin J. Pohly
4eb54b55f3
No need to send surface.leave/enter events
The scene graph implementation sends these for us, and it does so more
accurately than our overly-simplified approach.  Layer shell surfaces
don't appear to receive these events at all, according to my
WAYLAND_DEBUG experiments with bemenu and dtao.

ΔSLOC: -4
2023-08-22 01:44:31 -06:00
Leonardo Hernández Hernández
d4f2c6bfd6
chase wlroots!4288
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4288
2023-08-21 17:53:24 -06:00
Leonardo Hernández Hernández
4567979b16
don't resize clients on commit
It creates an infinite commit-resize loop when scale != 1
2023-08-18 21:37:22 -06:00
Leonardo Hernández Hernández
25db045392 set withdrawn state for xwayland invisible clients 2023-07-31 18:19:41 -06:00
Leonardo Hernández Hernández
78cf88670f add support for xdg-shell v6 2023-07-31 18:19:41 -06:00
Leonardo Hernández Hernández
ce997c4a21
update to xdg-shell v5 2023-07-23 21:15:06 -06:00
Leonardo Hernández Hernández
0e5405610e
add support for cursor-shape-v1
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4106
2023-07-23 19:56:55 -06:00
Leonardo Hernández Hernández
0bb1a1cc5c
increase wl_compositor version
Now scene will handle sending the preferred buffer scale

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4269
2023-07-15 10:11:47 -06:00
Leonardo Hernández Hernández
aecff8cb26
Merge branch 'main' into wlroots-next 2023-07-13 22:36:48 -06:00
Leonardo Hernández Hernández
ca4a97b933 do not use wl_event_loop for signal handling
ΔSLOC: -4

Fixes: https://github.com/djpohly/dwl/issues/456
Fixes: https://github.com/djpohly/dwl/issues/459
2023-07-13 22:32:48 -06:00
Devin J. Pohly
76ba2cdab0 Remove now-unneeded call to motionnotify
This appears to have been here for the side effect of updating the drag
icon's position.
2023-07-13 22:17:03 -06:00
Devin J. Pohly
4b15bbeb33 Remove unused icon variable 2023-07-13 22:17:03 -06:00
Devin J. Pohly
831fc36bc9 Make drag_icon a persistent scene node
If there is no current drag icon, this node will be empty, but we now
have `drag_icon != NULL` as an invariant.  This allows us to eliminate a
conditional, since there's no harm in moving an empty node's coordinates
around with the pointer.

ΔSLOC: -1
2023-07-13 22:17:03 -06:00
Devin J. Pohly
1841527871 properly destroy scene
ΔSLOC: +1
2023-07-13 17:44:21 -06:00
Leonardo Hernández Hernández
ff7c0e9508
chase wlroots!4220
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4220
2023-07-10 11:23:19 -06:00
Devin J. Pohly
33bcd2e4ca Line saver: LISTEN_STATIC macro
This parallels the LISTEN macro for statically allocated listeners, and
it allows us to remove almost all of the global wl_listener
declarations.

This also fixes a bug with the axisnotify listener, which was declared
with a compound literal.  At block scope, these have automatic storage
duration [1], so the listener was no longer valid after setup()
returned.  (The option to declare it static explicitly was standardized
in C23, if that ever gains suckless traction.)

ΔSLOC: -27

[1]: https://en.cppreference.com/w/c/language/compound_literal#Explanation
2023-07-08 16:56:09 -06:00
Devin J. Pohly
fbd84aca4a Unify signal handling under wl_event_loop
Merge our signal handlers into a single function and let Wayland deal
with all the struct sigaction stuff.

ΔSLOC: -3
2023-07-03 22:28:27 -06:00
Devin J. Pohly
a01e402c5d Line saver: follow "local = wlr->data = obj" pattern
There were still a couple of places where we could use this handy
multiple assignment to save a line.

ΔSLOC = -3
2023-07-03 21:21:43 -06:00
Leonardo Hernández Hernández
9dd3f230c0
Merge remote-tracking branch 'upstream/main' into wlroots-next 2023-06-29 13:11:55 -06:00
Leonardo Hernández Hernández
733114f0ca
schedule a frame after commmiting gamma
not doing it, may freeze the output or do not actually change the gamma until
creating a client
2023-06-24 10:09:49 -06:00
Leonardo Hernández Hernández
fdb66ccfa3
use detached output states to set gamma 2023-06-23 13:42:44 -06:00
Leonardo Hernández Hernández
6095ff84d2
Revert "use wlr_scene_output_build_state() to set gamma"
This reverts commit 65f68e7643.
2023-06-23 13:30:43 -06:00
Leonardo Hernández Hernández
1e1811f953
drop KDE idle support
use ext-idle-notify-v1 instead
2023-06-15 12:32:31 -06:00
Leonardo Hernández Hernández
dfb6b97159
drop support for wlr-input-inhibitor-unstable-v1
deprecated in favor of ext-session-lock-v1

References: 4aa366e3dd
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3848
2023-06-15 12:27:34 -06:00
Leonardo Hernández Hernández
65f68e7643
use wlr_scene_output_build_state() to set gamma 2023-06-15 12:22:43 -06:00
Leonardo Hernández Hernández
96ab92cdb1
use wlr_cursor_set_xcursor()
This avoids re-upload the cursor image in each motion event

Managing the scale is done by the function itself

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4170
2023-06-15 12:12:22 -06:00
Leonardo Hernández Hernández
1eb8a82ac4
Revert "avoid setting duplicate cursor image"
This reverts commit b5776e5180.

See next commit for details
2023-06-15 12:02:30 -06:00
Leonardo Hernández Hernández
24a337e6ec
handle gamma-control-v1 set_gamma event
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4046
2023-06-08 23:35:46 -06:00
Leonardo Hernández Hernández
f3d017077a
use the new {a,di}ssociate events to handle xwayland commit listener 2023-06-02 22:08:17 -06:00
Leonardo Hernández Hernández
06bc65549f
chase wlroots map logic unification
Signed-off-by: Leonardo Hernández Hernández <leohdz172@proton.me>
2023-06-02 22:03:41 -06:00
Leonardo Hernández Hernández
a8ccbe63f3
Merge branch 'main' into wlroots-next 2023-06-02 22:01:39 -06:00
Leonardo Hernández Hernández
2d1a40caf2
pass version to wlr_compositor_create()
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3696
Signed-off-by: Leonardo Hernández Hernández <leohdz172@proton.me>
2023-04-14 12:25:05 -06:00
Leonardo Hernández Hernández
733754bb06
Merge remote-tracking branch 'upstream/main' into wlroots-next 2023-04-14 12:24:19 -06:00
Leonardo Hernández Hernández
eaf6dd2cd2
do not call dmabuf_create twice
it is called automatically by `wlr_renderer_init_wl_display()` but since we
need a pointer to wlr_linux_dmabuf_v1 to integrate it with scene API we need
to recreate that function.

Bug: https://github.com/emersion/xdg-desktop-portal-wlr/issues/216
Fixes: https://github.com/djpohly/dwl/issues/398
2023-03-07 22:04:32 -06:00
Leonardo Hernández Hernández
d1b36925c9
add support for linux-dmabuf-unstable-v1
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3726
References: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/main/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
2023-02-20 21:24:18 -06:00
Leonardo Hernández Hernández
fefcdbed4a
Merge remote-tracking branch 'upstream/main' into wlroots-next 2023-02-13 13:46:41 -06:00
Leonardo Hernández Hernández
04fdf1a295
add support for wp-fractional-scale-v1
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3511
2023-02-08 22:25:41 -06:00
Leonardo Hernández Hernández
fbe89a929f
chase wlroots!4000
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4000
2023-02-05 10:03:09 -06:00
Leonardo Hernández Hernández
e7f736ccc9
chase wlroots!3391
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3991
2023-02-02 10:30:24 -06:00
Job79
7ae5039b4f follow upstream xwayland_surface changes
wlroots removed the `wlr_surface_is_xwayland_surface` function, and renamed `wlr_xwayland_surface_from_wlr_surface` to `wlr_xwayland_surface_try_from_wlr_surface`.

related commit: fbf5982e38
2023-02-01 14:16:54 -06:00
Leonardo Hernández Hernández
cf9c5745e5
Merge remote-tracking branch 'upstream/main' into wlroots-next 2022-12-30 15:29:12 -06:00
Leonardo Hernández Hernández
b39d270b9f
Merge branch 'main' into wlroots-next 2022-12-24 18:04:41 -06:00
Leonardo Hernández Hernández
98c7adfb3d
Merge remote-tracking branch 'upstream/main' into wlroots-next 2022-12-06 14:21:44 -06:00
Leonardo Hernández Hernández
b5229636a3
Merge remote-tracking branch 'upstream/main' into wlroots-next 2022-12-05 23:43:47 -06:00
Leonardo Hernández Hernández
02c257e0b1
update for wlroots!3627
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3627
2022-12-05 20:21:38 -06:00
Leonardo Hernández Hernández
27ab9cf1b1
call updatemons() in requestmonstate()
This way we make sure that the Monitor's boxes are updated correctly
2022-12-02 23:17:05 -06:00
Leonardo Hernández Hernández
1b39bbf316
Merge remote-tracking branch 'upstream/main' into wlroots-next 2022-12-02 10:39:06 -06:00
Leonardo Hernández Hernández
ea1b2dda63
Merge branch 'main' into wlroots-next 2022-11-21 20:51:30 -06:00
Leonardo Hernández Hernández
21ef004886
listen to the output request_state event;
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/2693
2022-11-15 23:52:21 -06:00
Leonardo Hernández Hernández
dae00caadd
update for wlroots!3861
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3861
2022-11-15 23:07:45 -06:00
Leonardo Hernández Hernández
5eb3529275
use the new scene helper for drag icons 2022-11-15 23:07:21 -06:00
Leonardo Hernández Hernández
359e7edc52
update for wlroots!3814
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3814
2022-11-15 23:04:39 -06:00
Leonardo Hernández Hernández
25dfdcc433
specify layer shell version 2022-11-15 23:04:02 -06:00
23 changed files with 3790 additions and 964 deletions

View file

@ -0,0 +1,62 @@
name: Bug Report
about: Something in dwl isn't working correctly
title:
labels:
- 'Kind/Bug'
body:
- type: markdown
attributes:
value: |
- Only report bugs that can be reproduced on the main (or wlroots-next) branch without patches.
- Proprietary graphics drivers, including nvidia, are not supported. Please use the open source equivalents, such as nouveau, if you would like to use dwl.
- Report patch issues to their respective authors.
- type: input
id: dwl_version
attributes:
label: 'dwl version:'
placeholder: '`dwl -v`'
validations:
required: true
- type: input
id: wlroots_version
attributes:
label: 'wlroots version:'
validations:
required: true
- type: input
id: distro
attributes:
label: What distro (and version) are you using?
validations:
required: false
- type: textarea
attributes:
label: Description
value: |
The steps you took to reproduce the problem.
validations:
required: false
- type: textarea
id: debug_log
attributes:
label: Debug Log
value: |
Run `dwl -d 2> ~/dwl.log` from a TTY and attach the **full** (do not truncate it) file here, or upload it to a pastebin.
Please try to keep the reproduction as brief as possible and exit dwl.
validations:
required: false
- type: textarea
id: backtrace
attributes:
label: Stack Trace
value: |
- Only required if dwl crashes.
- If the lines mentioning dwl or wlroots have `??`. Please compile both dwl and wlroots from source (enabling debug symbols) and try to reproduce.
validations:
required: false

View file

@ -0,0 +1,9 @@
name: Enhancement idea
about: Suggest a feature or improvement
title:
labels:
- 'Kind/Feature'
body:
- type: textarea
attributes:
label: Description

View file

@ -1,17 +0,0 @@
---
name: Bug report
about: Something in dwl isn't working correctly
title: ''
labels: 'A: bug'
assignees: ''
---
## Info
dwl version:
wlroots version:
## Description
<!--
Only report bugs that can be reproduced on the main line
Report patch issues to their respective authors
-->

View file

@ -1,10 +0,0 @@
---
name: Enhancement idea
about: Suggest a feature or improvement
title: ''
labels: 'A: enhancement'
assignees: ''
---

1
.mailmap Normal file
View file

@ -0,0 +1 @@
Lennart Jablonka <humm@ljabl.com> <hummsmith42@gmail.com>

214
CHANGELOG.md Normal file
View file

@ -0,0 +1,214 @@
# Changelog
* [Unreleased](#unreleased)
* [0.7](#0.7)
* [0.6](#0.6)
* [0.5](#0.5)
## Unreleased
### Added
### Changed
### Deprecated
### Removed
### Fixed
* Crash when a client is created while all outputs are disabled.
### Security
### Contributors
## 0.7
See also [0.6](#0.6) release notes. 0.7 builds against wlroots 0.18.x.
### Added
* Add support for the alpha-modifier-v1 protocol ([wlroots!4616][wlroots!4616]).
* dwl now will survive GPU resets ([#601][601]).
[wlroots!4616]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4616
[601]: https://codeberg.org/dwl/dwl/issues/601
### Fixed
* Crash when re-mapping unmapped clients.
### Contributors
Guido Cella
Lennart Jablonka
## 0.6
### Added
* Add `rootcolor` to change the default background color ([#544][544]).
* Implement the wlr-virtual-pointer-unstable-v1 protocol ([#574][574]).
* Implement the pointer-constraints and relative-pointer protocols ([#317][317])
* Implement the wlr-output-power-management protocol ([#599][599])
[544]: https://codeberg.org/dwl/dwl/pulls/544
[574]: https://codeberg.org/dwl/dwl/pulls/574
[317]: https://codeberg.org/dwl/dwl/issues/317
[599]: https://codeberg.org/dwl/dwl/issues/559
### Changed
* Keyboards are now managed through keyboard groups ([#549][549]).
* Only the first matched keybinding is executed.
* Allow toggling the layout before selecting a different one ([#570][570]).
* Fullscreen clients are now rendered above wlr_layer_surfaces in the top layer
([#609][609]).
* The default menu was changed from `bemenu-run` to `wmenu-run` ([#553][553]).
* The option `sloppyfocus` now replicates the dwm behavior ([#599][599]).
* Allow configure position of monitors with negative values. (-1, -1) is
used to auto-configure them ([#635][635]).
* dwl now kills the entire process group of `startup_cmd`
* The O_NONBLOCK flag is set for stdout.
[549]: https://codeberg.org/dwl/dwl/pulls/549
[570]: https://codeberg.org/dwl/dwl/pulls/570
[609]: https://codeberg.org/dwl/dwl/pulls/609
[553]: https://codeberg.org/dwl/dwl/issues/553
[599]: https://codeberg.org/dwl/dwl/pulls/599
[635]: https://codeberg.org/dwl/dwl/pulls/635
### Removed
* The SLOC limit is now removed ([#497][497]).
[497]: https://codeberg.org/dwl/dwl/pulls/497
### Fixed
* Clients not having the correct border color when mapping.
* Compliance with the xdg-decoration-unstable-v1 ([#546][546]).
* dwl no longer sends negative values in xdg_toplevel.configure events.
* Crashes with disabled monitors ([#472][472]).
[546]: https://codeberg.org/dwl/dwl/pulls/546
[472]: https://codeberg.org/dwl/dwl/issues/472
### Contributors
Ben Jargowsky
Benjamin Chausse
David Donahue
Devin J. Pohly
Dima Krasner
Emil Miler
Forrest Bushstone
Guido Cella
Peter Hofmann
Rutherther
Squibid
choc
fictitiousexistence
korei999
sewn
thanatos
## 0.5
### Added
* Allow configure x and y position of outputs ([#301][301])
* Implement repeatable keybindings ([#368][368])
* Print app id in printstatus() output ([#381][381])
* Display client count in monocle symbol ([#387][387])
* Export XCURSOR_SIZE to fix apps using an older version of Qt ([#425][425])
* Support for wp-fractional-scale-v1 (through wlr_scene: [wlroots!3511][wlroots!3511])
* dwl now sends `wl_surface.preferred_buffer_scale` (through wlr_scene: [wlroots!4269][wlroots!4269])
* Add support for xdg-shell v6 ([#465][465])
* Add support for wp-cursor-shape-v1 ([#444][444])
* Add desktop file ([#484][484])
* Add macro to easily configure colors ([#466][466])
* Color of urgent clients are now red ([#494][494])
* New flag `-d` and option `log_level` to change the wlroots debug level
* Add CHANGELOG.md ([#501][501])
[301]: https://github.com/djpohly/dwl/pull/301
[368]: https://github.com/djpohly/dwl/pull/368
[381]: https://github.com/djpohly/dwl/pull/381
[387]: https://github.com/djpohly/dwl/issues/387
[425]: https://github.com/djpohly/dwl/pull/425
[wlroots!4269]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4269
[wlroots!3511]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3511
[465]: https://github.com/djpohly/dwl/pull/465
[444]: https://github.com/djpohly/dwl/pull/444
[484]: https://github.com/djpohly/dwl/pull/484
[466]: https://github.com/djpohly/dwl/issues/466
[494]: https://github.com/djpohly/dwl/pull/494
[501]: https://github.com/djpohly/dwl/pull/501
### Changed
* Replace `tags` with `TAGCOUNT` in config.def.h ([#403][403])
* Pop ups are now destroyed when focusing another client ([#408][408])
* dwl does not longer respect size hints, instead clip windows if they are
larger than they should be ([#455][455])
* The version of wlr-layer-shell-unstable-v1 was lowered to 3 (from 4)
* Use the same border color as dwm ([#494][494])
[403]: https://github.com/djpohly/dwl/pull/403
[408]: https://github.com/djpohly/dwl/pull/409
[455]: https://github.com/djpohly/dwl/pull/455
[494]: https://github.com/djpohly/dwl/pull/494
### Removed
* Remove unused `rootcolor` option ([#401][401])
* Remove support for wlr-input-inhibitor-unstable-v1 ([#430][430])
* Remove support for KDE idle protocol ([#431][431])
[401]: https://github.com/djpohly/dwl/pull/401
[430]: https://github.com/djpohly/dwl/pull/430
[431]: https://github.com/djpohly/dwl/pull/431
### Fixed
* Fix crash when creating a layer surface with all outputs disabled
([#421][421])
* Fix other clients being shown as focused if the focused client have pop ups
open ([#408][408])
* Resize fullscreen clients when updating monitor mode
* dwl no longer crash at exit like sometimes did
* Fullscreen background appearing above clients ([#487][487])
* Fix a segfault when user provides invalid xkb_rules ([#518][518])
[421]: https://github.com/djpohly/dwl/pull/421
[408]: https://github.com/djpohly/dwl/issues/408
[487]: https://github.com/djpohly/dwl/issues/487
[518]: https://github.com/djpohly/dwl/pull/518
### Contributors
* A Frederick Christensen
* Angelo Antony
* Ben Collerson
* Devin J. Pohly
* Forrest Bushstone
* gan-of-culture
* godalming123
* Job79
* link2xt
* Micah Gorrell
* Nikita Ivanov
* Palanix
* pino-desktop
* Weiseguy
* Yves Zoundi

View file

@ -4,19 +4,24 @@
include config.mk
# flags for compiling
DWLCPPFLAGS = -I. -DWLR_USE_UNSTABLE -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" $(XWAYLAND)
DWLDEVCFLAGS = -pedantic -Wall -Wextra -Wdeclaration-after-statement -Wno-unused-parameter -Wno-sign-compare -Wshadow -Wunused-macros\
-Werror=strict-prototypes -Werror=implicit -Werror=return-type -Werror=incompatible-pointer-types
DWLCPPFLAGS = -I. -DWLR_USE_UNSTABLE -D_POSIX_C_SOURCE=200809L \
-DVERSION=\"$(VERSION)\" $(XWAYLAND)
DWLDEVCFLAGS = -g -pedantic -Wall -Wextra -Wdeclaration-after-statement \
-Wno-unused-parameter -Wshadow -Wunused-macros -Werror=strict-prototypes \
-Werror=implicit -Werror=return-type -Werror=incompatible-pointer-types \
-Wfloat-conversion
# CFLAGS / LDFLAGS
PKGS = wlroots wayland-server xkbcommon libinput $(XLIBS)
PKGS = wlroots-0.18 wayland-server xkbcommon libinput pixman-1 fcft $(XLIBS)
DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(LIBS)
LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` -lm $(LIBS)
all: dwl
dwl: dwl.o util.o
$(CC) dwl.o util.o $(LDLIBS) $(LDFLAGS) $(DWLCFLAGS) -o $@
dwl.o: dwl.c config.mk config.h client.h xdg-shell-protocol.h wlr-layer-shell-unstable-v1-protocol.h
$(CC) dwl.o util.o $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
dwl.o: dwl.c client.h config.h config.mk cursor-shape-v1-protocol.h \
pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h \
wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h
util.o: util.c util.h
# wayland-scanner is a tool which generates C headers and rigging for Wayland
@ -25,22 +30,32 @@ util.o: util.c util.h
WAYLAND_SCANNER = `$(PKG_CONFIG) --variable=wayland_scanner wayland-scanner`
WAYLAND_PROTOCOLS = `$(PKG_CONFIG) --variable=pkgdatadir wayland-protocols`
cursor-shape-v1-protocol.h:
$(WAYLAND_SCANNER) enum-header \
$(WAYLAND_PROTOCOLS)/staging/cursor-shape/cursor-shape-v1.xml $@
pointer-constraints-unstable-v1-protocol.h:
$(WAYLAND_SCANNER) enum-header \
$(WAYLAND_PROTOCOLS)/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml $@
wlr-layer-shell-unstable-v1-protocol.h:
$(WAYLAND_SCANNER) enum-header \
protocols/wlr-layer-shell-unstable-v1.xml $@
wlr-output-power-management-unstable-v1-protocol.h:
$(WAYLAND_SCANNER) server-header \
protocols/wlr-output-power-management-unstable-v1.xml $@
xdg-shell-protocol.h:
$(WAYLAND_SCANNER) server-header \
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
wlr-layer-shell-unstable-v1-protocol.h:
$(WAYLAND_SCANNER) server-header \
protocols/wlr-layer-shell-unstable-v1.xml $@
config.h:
cp config.def.h $@
clean:
rm -f dwl *.o *-protocol.h
rm -f result result-man
dist: clean
mkdir -p dwl-$(VERSION)
cp -R LICENSE* Makefile README.md client.h config.def.h\
config.mk protocols dwl.1 dwl.c util.c util.h\
cp -R LICENSE* Makefile CHANGELOG.md README.md client.h config.def.h \
config.mk protocols dwl.1 dwl.c util.c util.h dwl.desktop \
dwl-$(VERSION)
tar -caf dwl-$(VERSION).tar.gz dwl-$(VERSION)
rm -rf dwl-$(VERSION)
@ -52,9 +67,13 @@ install: dwl
mkdir -p $(DESTDIR)$(MANDIR)/man1
cp -f dwl.1 $(DESTDIR)$(MANDIR)/man1
chmod 644 $(DESTDIR)$(MANDIR)/man1/dwl.1
mkdir -p $(DESTDIR)$(DATADIR)/wayland-sessions
cp -f dwl.desktop $(DESTDIR)$(DATADIR)/wayland-sessions/dwl.desktop
chmod 644 $(DESTDIR)$(DATADIR)/wayland-sessions/dwl.desktop
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/dwl $(DESTDIR)$(MANDIR)/man1/dwl.1
rm -f $(DESTDIR)$(PREFIX)/bin/dwl $(DESTDIR)$(MANDIR)/man1/dwl.1 \
$(DESTDIR)$(DATADIR)/wayland-sessions/dwl.desktop
.SUFFIXES: .c .o
.c.o:
$(CC) $(CPPFLAGS) $(DWLCFLAGS) -c $<
$(CC) $(CPPFLAGS) $(DWLCFLAGS) -o $@ -c $<

184
README.md
View file

@ -1,62 +1,57 @@
# dwl - dwm for Wayland
Join us on our [Discord server] or at [#dwl] on irc.libera.chat.
Join us on our IRC channel: [#dwl on Libera Chat]
Or on our [Discord server].
dwl is a compact, hackable compositor for [Wayland] based on [wlroots]. It is
intended to fill the same space in the Wayland world that dwm does in X11,
primarily in terms of philosophy, and secondarily in terms of functionality.
Like dwm, dwl is:
primarily in terms of functionality, and secondarily in terms of
philosophy. Like dwm, dwl is:
- Easy to understand, hack on, and extend with patches
- One C source file (or a very small number) configurable via `config.h`
- Limited to 2200 SLOC to promote hackability
- Tied to as few external dependencies as possible
dwl is not meant to provide every feature under the sun. Instead, like dwm, it
sticks to features which are necessary, simple, and straightforward to implement
given the base on which it is built. Implemented default features are:
## Getting Started:
- Any features provided by dwm/Xlib: simple window borders, tags, keybindings,
client rules, mouse move/resize. Providing a built-in status bar is an
exception to this goal, to avoid dependencies on font rendering and/or
drawing libraries when an external bar could work well.
- Configurable multi-monitor layout support, including position and rotation
- Configurable HiDPI/multi-DPI support
- Idle-inhibit protocol which lets applications such as mpv disable idle
monitoring
- Provide information to external status bars via stdout/stdin
- Urgency hints via xdg-activate protocol
- Support screen lockers via input-inhibitor protocol
- Various Wayland protocols
- XWayland support as provided by wlroots (can be enabled in `config.mk`)
- Zero flickering - Wayland users naturally expect that "every frame is perfect"
- Layer shell popups (used by Waybar)
- Damage tracking provided by scenegraph API
### **dwl branch 0.7 and releases based upon 0.7 build against [wlroots] 0.18**
Features under consideration (possibly as patches) are:
### Latest semi-stable [release]
This is probably where you want to start. This builds against the dependent
packages' versions currently shipping in major distributions. If your
distribution's wlroots version is older, use an earlier dwl [release] or [0.x
branch].
- Protocols made trivial by wlroots
- Implement the text-input and input-method protocols to support IME once ibus
implements input-method v2 (see https://github.com/ibus/ibus/pull/2256 and
https://github.com/djpohly/dwl/pull/235)
### Development branch [main]
Active development progresses on the `main` branch. The `main` branch is built
against a late (and often changing) git commit of wlroots. While the adventurous
are welcome to use `main`, it is a rocky road. Using `main` requires that the
user be willing to chase git commits of wlroots. Testing development pull
requests may involve merging unmerged pull requests in [wlroots]' git repository
and/or git commits of wayland.
Feature *non-goals* for the main codebase include:
### Building dwl
dwl has the following dependencies:
- libinput
- wayland
- wlroots (compiled with the libinput backend)
- xkbcommon
- wayland-protocols (compile-time only)
- pkg-config (compile-time only)
- Client-side decoration (any more than is necessary to tell the clients not to)
- Client-initiated window management, such as move, resize, and close, which can
be done through the compositor
- Animations and visual effects
dwl has the following additional dependencies if XWayland support is enabled:
- libxcb
- libxcb-wm
- wlroots (compiled with X11 support)
- Xwayland (runtime only)
## Building dwl
Install these (and their `-devel` versions if your distro has separate
development packages) and run `make`. If you wish to build against a released
version of wlroots (*you probably do*), use a [release] or a [0.x branch]. If
you want to use the unstable development `main` branch, you need to use the git
version of [wlroots].
dwl has only two dependencies: `wlroots` and `wayland-protocols`.
Simply install these (and their `-devel` versions if your distro has separate
development packages) and run `make`. If you wish to build against a Git
version of wlroots, check out the [wlroots-next branch].
To enable XWayland, you should also install xorg-xwayland and uncomment its flag
in `config.mk`.
To enable XWayland, you should uncomment its flags in `config.mk`.
## Configuration
@ -65,23 +60,24 @@ manner as dwm. There is no way to separately restart the window manager in
Wayland without restarting the entire display server, so any changes will take
effect the next time dwl is executed.
As in the dwm community, we encourage users to share patches they have created.
Check out the [patches page on our wiki]!
As in the dwm community, we encourage users to share patches they have
created. Check out the [dwl-patches] repository!
## Running dwl
dwl can be run on any of the backends supported by wlroots. This means you can
run it as a separate window inside either an X11 or Wayland session, as well
as directly from a VT console. Depending on your distro's setup, you may need
to add your user to the `video` and `input` groups before you can run dwl on
a VT. If you are using `elogind` or `systemd-logind` you need to install
polkit; otherwise you need to add yourself in the `seat` group and
enable/start the seatd daemon.
run it as a separate window inside either an X11 or Wayland session, as well as
directly from a VT console. Depending on your distro's setup, you may need to
add your user to the `video` and `input` groups before you can run dwl on a
VT. If you are using `elogind` or `systemd-logind` you need to install polkit;
otherwise you need to add yourself in the `seat` group and enable/start the
seatd daemon.
When dwl is run with no arguments, it will launch the server and begin handling
any shortcuts configured in `config.h`. There is no status bar or other
decoration initially; these are instead clients that can be run within
the Wayland session.
decoration initially; these are instead clients that can be run within the
Wayland session. Do note that the default background color is black. This can be
modified in `config.h`.
If you would like to run a script or command automatically at startup, you can
specify the command using the `-s` option. This command will be executed as a
@ -89,7 +85,8 @@ shell command using `/bin/sh -c`. It serves a similar function to `.xinitrc`,
but differs in that the display server will not shut down when this process
terminates. Instead, dwl will send this process a SIGTERM at shutdown and wait
for it to terminate (if it hasn't already). This makes it ideal for execing into
a user service manager like [s6], [anopa], [runit], or [`systemd --user`].
a user service manager like [s6], [anopa], [runit], [dinit], or [`systemd
--user`].
Note: The `-s` command is run as a *child process* of dwl, which means that it
does not have the ability to affect the environment of dwl or of any processes
@ -105,13 +102,13 @@ automatically, you will need to configure it prior to launching `dwl`, e.g.:
### Status information
Information about selected layouts, current window title, and
Information about selected layouts, current window title, app-id, and
selected/occupied/urgent tags is written to the stdin of the `-s` command (see
the `printstatus()` function for details). This information can be used to
populate an external status bar with a script that parses the information.
Failing to read this information will cause dwl to block, so if you do want to
run a startup command that does not consume the status information, you can
close standard input with the `<&-` shell redirection, for example:
populate an external status bar with a script that parses the
information. Failing to read this information will cause dwl to block, so if you
do want to run a startup command that does not consume the status information,
you can close standard input with the `<&-` shell redirection, for example:
dwl -s 'foot --server <&-'
@ -126,6 +123,49 @@ To get a list of status bars that work with dwl consult our [wiki].
You can find a [list of useful resources on our wiki].
## Background
dwl is not meant to provide every feature under the sun. Instead, like dwm, it
sticks to features which are necessary, simple, and straightforward to implement
given the base on which it is built. Implemented default features are:
- Any features provided by dwm/Xlib: simple window borders, tags, keybindings,
client rules, mouse move/resize. Providing a built-in status bar is an
exception to this goal, to avoid dependencies on font rendering and/or drawing
libraries when an external bar could work well.
- Configurable multi-monitor layout support, including position and rotation
- Configurable HiDPI/multi-DPI support
- Idle-inhibit protocol which lets applications such as mpv disable idle
monitoring
- Provide information to external status bars via stdout/stdin
- Urgency hints via xdg-activate protocol
- Support screen lockers via ext-session-lock-v1 protocol
- Various Wayland protocols
- XWayland support as provided by wlroots (can be enabled in `config.mk`)
- Zero flickering - Wayland users naturally expect that "every frame is perfect"
- Layer shell popups (used by Waybar)
- Damage tracking provided by scenegraph API
Given the Wayland architecture, dwl has to implement features from dwm **and**
the xorg-server. Because of this, it is impossible to maintain the original
project goal of 2000 SLOC and have a reasonably complete compositor with
features comparable to dwm. However, this does not mean that the code will grow
indiscriminately. We will try to keep the code as small as possible.
Features under consideration (possibly as patches) are:
- Protocols made trivial by wlroots
- Implement the text-input and input-method protocols to support IME once ibus
implements input-method v2 (see https://github.com/ibus/ibus/pull/2256 and
https://codeberg.org/dwl/dwl/pulls/235)
Feature *non-goals* for the main codebase include:
- Client-side decoration (any more than is necessary to tell the clients not to)
- Client-initiated window management, such as move, resize, and close, which can
be done through the compositor
- Animations and visual effects
## Acknowledgements
dwl began by extending the TinyWL example provided (CC0) by the sway/wlroots
@ -136,22 +176,26 @@ possible.
Many thanks to suckless.org and the dwm developers and community for the
inspiration, and to the various contributors to the project, including:
- **Devin J. Pohly for creating and nurturing the fledgling project**
- Alexander Courtis for the XWayland implementation
- Guido Cella for the layer-shell protocol implementation, patch maintenance,
and for helping to keep the project running
- Stivvo for output management and fullscreen support, and patch maintenance
[Discord server]: https://discord.gg/jJxZnrGPWN
[#dwl]: https://web.libera.chat/?channels=#dwl
[Wayland]: https://wayland.freedesktop.org/
[wlroots]: https://gitlab.freedesktop.org/wlroots/wlroots/
[wlroots-next branch]: https://github.com/djpohly/dwl/tree/wlroots-next
[patches page on our wiki]: https://github.com/djpohly/dwl/wiki/Patches
[s6]: https://skarnet.org/software/s6/
[anopa]: https://jjacky.com/anopa/
[runit]: http://smarden.org/runit/faq.html#userservices
[`systemd --user`]: https://wiki.archlinux.org/title/Systemd/User
[wiki]: https://github.com/djpohly/dwl/wiki#compatible-status-bars
[list of useful resources on our wiki]:
https://github.com/djpohly/dwl/wiki#migrating-from-x
[#dwl on Libera Chat]: https://web.libera.chat/?channels=#dwl
[0.7-rc1]: https://codeberg.org/dwl/dwl/releases/tag/v0.7-rc1
[0.x branch]: https://codeberg.org/dwl/dwl/branches
[anopa]: https://jjacky.com/anopa/
[dinit]: https://davmac.org/projects/dinit/
[dwl-patches]: https://codeberg.org/dwl/dwl-patches
[list of useful resources on our wiki]: https://codeberg.org/dwl/dwl/wiki/Home#migrating-from-x
[main]: https://codeberg.org/dwl/dwl/src/branch/main
[release]: https://codeberg.org/dwl/dwl/releases
[runit]: http://smarden.org/runit/faq.html#userservices
[s6]: https://skarnet.org/software/s6/
[wlroots]: https://gitlab.freedesktop.org/wlroots/wlroots/
[wiki]: https://codeberg.org/dwl/dwl/wiki/Home#compatible-status-bars
[Discord server]: https://discord.gg/jJxZnrGPWN
[Wayland]: https://wayland.freedesktop.org/

192
client.h
View file

@ -10,35 +10,9 @@ static inline int
client_is_x11(Client *c)
{
#ifdef XWAYLAND
return c->type == X11Managed || c->type == X11Unmanaged;
#else
return c->type == X11;
#endif
return 0;
#endif
}
static inline void
client_get_size_hints(Client *c, struct wlr_box *max, struct wlr_box *min)
{
struct wlr_xdg_toplevel *toplevel;
struct wlr_xdg_toplevel_state *state;
#ifdef XWAYLAND
if (client_is_x11(c)) {
xcb_size_hints_t *size_hints = c->surface.xwayland->size_hints;
if (size_hints) {
max->width = size_hints->max_width;
max->height = size_hints->max_height;
min->width = size_hints->min_width;
min->height = size_hints->min_height;
}
return;
}
#endif
toplevel = c->surface.xdg->toplevel;
state = &toplevel->current;
max->width = state->max_width;
max->height = state->max_height;
min->width = state->min_width;
min->height = state->min_height;
}
static inline struct wlr_surface *
@ -54,7 +28,7 @@ client_surface(Client *c)
static inline int
toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc, LayerSurface **pl)
{
struct wlr_xdg_surface *xdg_surface;
struct wlr_xdg_surface *xdg_surface, *tmp_xdg_surface;
struct wlr_surface *root_surface;
struct wlr_layer_surface_v1 *layer_surface;
Client *c = NULL;
@ -65,36 +39,37 @@ toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc, LayerSurface **pl)
#endif
if (!s)
return type;
return -1;
root_surface = wlr_surface_get_root_surface(s);
#ifdef XWAYLAND
if (wlr_surface_is_xwayland_surface(root_surface)
&& (xsurface = wlr_xwayland_surface_from_wlr_surface(root_surface))) {
if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(root_surface))) {
c = xsurface->data;
type = c->type;
goto end;
}
#endif
if (wlr_surface_is_layer_surface(root_surface)
&& (layer_surface = wlr_layer_surface_v1_from_wlr_surface(root_surface))) {
if ((layer_surface = wlr_layer_surface_v1_try_from_wlr_surface(root_surface))) {
l = layer_surface->data;
type = LayerShell;
goto end;
}
if (wlr_surface_is_xdg_surface(root_surface)
&& (xdg_surface = wlr_xdg_surface_from_wlr_surface(root_surface))) {
while (1) {
xdg_surface = wlr_xdg_surface_try_from_wlr_surface(root_surface);
while (xdg_surface) {
tmp_xdg_surface = NULL;
switch (xdg_surface->role) {
case WLR_XDG_SURFACE_ROLE_POPUP:
if (!xdg_surface->popup->parent)
if (!xdg_surface->popup || !xdg_surface->popup->parent)
return -1;
else if (!wlr_surface_is_xdg_surface(xdg_surface->popup->parent))
tmp_xdg_surface = wlr_xdg_surface_try_from_wlr_surface(xdg_surface->popup->parent);
if (!tmp_xdg_surface)
return toplevel_from_wlr_surface(xdg_surface->popup->parent, pc, pl);
xdg_surface = wlr_xdg_surface_from_wlr_surface(xdg_surface->popup->parent);
xdg_surface = tmp_xdg_surface;
break;
case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
c = xdg_surface->data;
@ -104,7 +79,6 @@ toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc, LayerSurface **pl)
return -1;
}
}
}
end:
if (pl)
@ -118,19 +92,16 @@ end:
static inline void
client_activate_surface(struct wlr_surface *s, int activated)
{
struct wlr_xdg_surface *surface;
struct wlr_xdg_toplevel *toplevel;
#ifdef XWAYLAND
struct wlr_xwayland_surface *xsurface;
if (wlr_surface_is_xwayland_surface(s)
&& (xsurface = wlr_xwayland_surface_from_wlr_surface(s))) {
if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(s))) {
wlr_xwayland_surface_activate(xsurface, activated);
return;
}
#endif
if (wlr_surface_is_xdg_surface(s)
&& (surface = wlr_xdg_surface_from_wlr_surface(s))
&& surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL)
wlr_xdg_toplevel_set_activated(surface->toplevel, activated);
if ((toplevel = wlr_xdg_toplevel_try_from_wlr_surface(s)))
wlr_xdg_toplevel_set_activated(toplevel, activated);
}
static inline uint32_t
@ -140,21 +111,14 @@ client_set_bounds(Client *c, int32_t width, int32_t height)
if (client_is_x11(c))
return 0;
#endif
if (c->surface.xdg->client->shell->version >=
XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION && width >= 0 && height >= 0)
if (wl_resource_get_version(c->surface.xdg->toplevel->resource) >=
XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION && width >= 0 && height >= 0
&& (c->bounds.width != width || c->bounds.height != height)) {
c->bounds.width = width;
c->bounds.height = height;
return wlr_xdg_toplevel_set_bounds(c->surface.xdg->toplevel, width, height);
return 0;
}
static inline void
client_for_each_surface(Client *c, wlr_surface_iterator_func_t fn, void *data)
{
wlr_surface_for_each_surface(client_surface(c), fn, data);
#ifdef XWAYLAND
if (client_is_x11(c))
return;
#endif
wlr_xdg_surface_for_each_popup_surface(c->surface.xdg, fn, data);
return 0;
}
static inline const char *
@ -167,6 +131,27 @@ client_get_appid(Client *c)
return c->surface.xdg->toplevel->app_id;
}
static inline void
client_get_clip(Client *c, struct wlr_box *clip)
{
struct wlr_box xdg_geom = {0};
*clip = (struct wlr_box){
.x = 0,
.y = 0,
.width = c->geom.width - c->bw,
.height = c->geom.height - c->bw,
};
#ifdef XWAYLAND
if (client_is_x11(c))
return;
#endif
wlr_xdg_surface_get_geometry(c->surface.xdg, &xdg_geom);
clip->x = xdg_geom.x;
clip->y = xdg_geom.y;
}
static inline void
client_get_geometry(Client *c, struct wlr_box *geom)
{
@ -187,15 +172,29 @@ client_get_parent(Client *c)
{
Client *p = NULL;
#ifdef XWAYLAND
if (client_is_x11(c) && c->surface.xwayland->parent)
if (client_is_x11(c)) {
if (c->surface.xwayland->parent)
toplevel_from_wlr_surface(c->surface.xwayland->parent->surface, &p, NULL);
return p;
}
#endif
if (c->surface.xdg->toplevel->parent)
toplevel_from_wlr_surface(c->surface.xdg->toplevel->parent->base->surface, &p, NULL);
return p;
}
static inline int
client_has_children(Client *c)
{
#ifdef XWAYLAND
if (client_is_x11(c))
return !wl_list_empty(&c->surface.xwayland->children);
#endif
/* surface.xdg->link is never empty because it always contains at least the
* surface itself. */
return wl_list_length(&c->surface.xdg->link) > 1;
}
static inline const char *
client_get_title(Client *c)
{
@ -209,35 +208,35 @@ client_get_title(Client *c)
static inline int
client_is_float_type(Client *c)
{
struct wlr_box min = {0}, max = {0};
client_get_size_hints(c, &max, &min);
struct wlr_xdg_toplevel *toplevel;
struct wlr_xdg_toplevel_state state;
#ifdef XWAYLAND
if (client_is_x11(c)) {
struct wlr_xwayland_surface *surface = c->surface.xwayland;
xcb_size_hints_t *size_hints = surface->size_hints;
size_t i;
if (surface->modal)
return 1;
for (size_t i = 0; i < surface->window_type_len; i++)
for (i = 0; i < surface->window_type_len; i++)
if (surface->window_type[i] == netatom[NetWMWindowTypeDialog]
|| surface->window_type[i] == netatom[NetWMWindowTypeSplash]
|| surface->window_type[i] == netatom[NetWMWindowTypeToolbar]
|| surface->window_type[i] == netatom[NetWMWindowTypeUtility])
return 1;
}
#endif
return ((min.width > 0 || min.height > 0 || max.width > 0 || max.height > 0)
&& (min.width == max.width || min.height == max.height));
}
static inline int
client_is_mapped(Client *c)
{
#ifdef XWAYLAND
if (client_is_x11(c))
return c->surface.xwayland->mapped;
return size_hints && size_hints->min_width > 0 && size_hints->min_height > 0
&& (size_hints->max_width == size_hints->min_width
|| size_hints->max_height == size_hints->min_height);
}
#endif
return c->surface.xdg->mapped;
toplevel = c->surface.xdg->toplevel;
state = toplevel->current;
return toplevel->parent || (state.min_width != 0 && state.min_height != 0
&& (state.min_width == state.max_width
|| state.min_height == state.max_height));
}
static inline int
@ -247,7 +246,8 @@ client_is_rendered_on_mon(Client *c, Monitor *m)
* but rather actual displaying of the pixels.
* Usually VISIBLEON suffices and is also faster. */
struct wlr_surface_output *s;
if (!c->scene->node.enabled)
int unused_lx, unused_ly;
if (!wlr_scene_node_coords(&c->scene->node, &unused_lx, &unused_ly))
return 0;
wl_list_for_each(s, &client_surface(c)->current_outputs, link)
if (s->output == m->wlr_output)
@ -285,7 +285,8 @@ static inline int
client_is_unmanaged(Client *c)
{
#ifdef XWAYLAND
return c->type == X11Unmanaged;
if (client_is_x11(c))
return c->surface.xwayland->override_redirect;
#endif
return 0;
}
@ -323,6 +324,14 @@ client_send_close(Client *c)
wlr_xdg_toplevel_send_close(c->surface.xdg->toplevel);
}
static inline void
client_set_border_color(Client *c, const float color[static 4])
{
int i;
for (i = 0; i < 4; i++)
wlr_scene_rect_set_color(c->border[i], color);
}
static inline void
client_set_fullscreen(Client *c, int fullscreen)
{
@ -341,14 +350,14 @@ client_set_size(Client *c, uint32_t width, uint32_t height)
#ifdef XWAYLAND
if (client_is_x11(c)) {
wlr_xwayland_surface_configure(c->surface.xwayland,
c->geom.x, c->geom.y, width, height);
c->geom.x + c->bw, c->geom.y + c->bw, width, height);
return 0;
}
#endif
if (width == c->surface.xdg->toplevel->current.width
&& height ==c->surface.xdg->toplevel->current.height)
if ((int32_t)width == c->surface.xdg->toplevel->current.width
&& (int32_t)height == c->surface.xdg->toplevel->current.height)
return 0;
return wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, width, height);
return wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width, (int32_t)height);
}
static inline void
@ -358,18 +367,23 @@ client_set_tiled(Client *c, uint32_t edges)
if (client_is_x11(c))
return;
#endif
if (wl_resource_get_version(c->surface.xdg->toplevel->resource)
>= XDG_TOPLEVEL_STATE_TILED_RIGHT_SINCE_VERSION) {
wlr_xdg_toplevel_set_tiled(c->surface.xdg->toplevel, edges);
} else {
wlr_xdg_toplevel_set_maximized(c->surface.xdg->toplevel, edges != WLR_EDGE_NONE);
}
}
static inline struct wlr_surface *
client_surface_at(Client *c, double cx, double cy, double *sx, double *sy)
static inline void
client_set_suspended(Client *c, int suspended)
{
#ifdef XWAYLAND
if (client_is_x11(c))
return wlr_surface_surface_at(c->surface.xwayland->surface,
cx, cy, sx, sy);
return;
#endif
return wlr_xdg_surface_surface_at(c->surface.xdg, cx, cy, sx, sy);
wlr_xdg_toplevel_set_suspended(c->surface.xdg->toplevel, suspended);
}
static inline int

1
compile_commands.json Normal file
View file

@ -0,0 +1 @@
[]

View file

@ -1,21 +1,37 @@
/* Taken from https://github.com/djpohly/dwl/issues/466 */
#define COLOR(hex) { ((hex >> 24) & 0xFF) / 255.0f, \
((hex >> 16) & 0xFF) / 255.0f, \
((hex >> 8) & 0xFF) / 255.0f, \
(hex & 0xFF) / 255.0f }
/* appearance */
static const int sloppyfocus = 1; /* focus follows mouse */
static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */
static const unsigned int borderpx = 1; /* border pixel of windows */
static const float bordercolor[] = {0.5, 0.5, 0.5, 1.0};
static const float focuscolor[] = {1.0, 0.0, 0.0, 1.0};
/* To conform the xdg-protocol, set the alpha to zero to restore the old behavior */
static const float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0};
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 float rootcolor[] = COLOR(0x000000ff);
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */
static uint32_t colors[][3] = {
/* fg bg border */
[SchemeNorm] = { 0xbbbbbbff, 0x222222ff, 0x444444ff },
[SchemeSel] = { 0xeeeeeeff, 0x005577ff, 0x005577ff },
[SchemeUrg] = { 0, 0, 0x770000ff },
};
/* tagging - tagcount must be no greater than 31 */
static const int tagcount = 9;
/* tagging - TAGCOUNT must be no greater than 31 */
static char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
/* logging */
static int log_level = WLR_ERROR;
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
static const Rule rules[] = {
/* app_id title tags mask isfloating monitor */
/* examples:
{ "Gimp", NULL, 0, 1, -1 },
*/
{ "firefox", NULL, 1 << 8, 0, -1 },
/* examples: */
{ "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
{ "discord", NULL, 1 << 1, 0, 1 }, /* Start on ONLY tag "9" */
};
/* layout(s) */
@ -27,13 +43,20 @@ static const Layout layouts[] = {
};
/* monitors */
/* (x=-1, y=-1) is reserved as an "autoconfigure" monitor position indicator
* WARNING: negative values other than (-1, -1) cause problems with Xwayland clients
* https://gitlab.freedesktop.org/xorg/xserver/-/issues/899
*/
/* NOTE: ALWAYS add a fallback rule, even if you are completely sure it won't be used */
static const MonitorRule monrules[] = {
/* name mfact nmaster scale layout rotate/reflect x y */
/* example of a HiDPI laptop monitor:
{ "eDP-1", 0.5, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
{ "eDP-1", 0.5f, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
*/
{ "HDMI-A-1", 0.5f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, 0, 0 },
{ "DP-1", 0.5f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, 1920, 0 },
/* defaults */
{ NULL, 0.55, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
{ NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
};
/* keyboard */
@ -84,6 +107,7 @@ LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE
*/
static const enum libinput_config_accel_profile accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
static const double accel_speed = 0.0;
/* You can choose between:
LIBINPUT_CONFIG_TAP_MAP_LRM -- 1/2/3 finger tap maps to left/right/middle
LIBINPUT_CONFIG_TAP_MAP_LMR -- 1/2/3 finger tap maps to left/middle/right
@ -91,7 +115,7 @@ LIBINPUT_CONFIG_TAP_MAP_LMR -- 1/2/3 finger tap maps to left/middle/right
static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TAP_MAP_LRM;
/* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */
#define MODKEY WLR_MODIFIER_ALT
#define MODKEY WLR_MODIFIER_LOGO
#define TAGKEYS(KEY,SKEY,TAG) \
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
@ -103,20 +127,21 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
/* commands */
static const char *termcmd[] = { "foot", NULL };
static const char *menucmd[] = { "bemenu-run", NULL };
static const char *termcmd[] = { "kitty", NULL };
static const char *menucmd[] = { "wmenu-run", NULL };
static const Key keys[] = {
/* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */
/* modifier key function argument */
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
{ MODKEY, XKB_KEY_b, togglebar, {0} },
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05} },
{ MODKEY, XKB_KEY_l, setmfact, {.f = +0.05} },
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },
{ MODKEY, XKB_KEY_l, setmfact, {.f = +0.05f} },
{ MODKEY, XKB_KEY_Return, zoom, {0} },
{ MODKEY, XKB_KEY_Tab, view, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C, killclient, {0} },
@ -145,13 +170,24 @@ static const Key keys[] = {
/* Ctrl-Alt-Backspace and Ctrl-Alt-Fx used to be handled by X server */
{ WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_Terminate_Server, quit, {0} },
/* Ctrl-Alt-Fx is used to switch to another VT, if you don't know what a VT is
* do not remove them.
*/
#define CHVT(n) { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_XF86Switch_VT_##n, chvt, {.ui = (n)} }
CHVT(1), CHVT(2), CHVT(3), CHVT(4), CHVT(5), CHVT(6),
CHVT(7), CHVT(8), CHVT(9), CHVT(10), CHVT(11), CHVT(12),
};
static const Button buttons[] = {
{ MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} },
{ MODKEY, BTN_MIDDLE, togglefloating, {0} },
{ MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} },
{ ClkLtSymbol, 0, BTN_LEFT, setlayout, {.v = &layouts[0]} },
{ ClkLtSymbol, 0, BTN_RIGHT, setlayout, {.v = &layouts[2]} },
{ ClkTitle, 0, BTN_MIDDLE, zoom, {0} },
{ ClkStatus, 0, BTN_MIDDLE, spawn, {.v = termcmd} },
{ ClkClient, MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} },
{ ClkClient, MODKEY, BTN_MIDDLE, togglefloating, {0} },
{ ClkClient, MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} },
{ ClkTagBar, 0, BTN_LEFT, view, {0} },
{ ClkTagBar, 0, BTN_RIGHT, toggleview, {0} },
{ ClkTagBar, MODKEY, BTN_LEFT, tag, {0} },
{ ClkTagBar, MODKEY, BTN_RIGHT, toggletag, {0} },
};

View file

@ -1,4 +1,4 @@
_VERSION = 0.4
_VERSION = 0.7
VERSION = `git describe --tags --dirty 2>/dev/null || echo $(_VERSION)`
PKG_CONFIG = pkg-config
@ -6,9 +6,12 @@ PKG_CONFIG = pkg-config
# paths
PREFIX = /usr/local
MANDIR = $(PREFIX)/share/man
DATADIR = $(PREFIX)/share
XWAYLAND =
XLIBS =
# Uncomment to build XWayland support
#XWAYLAND = -DXWAYLAND
#XLIBS = xcb xcb-icccm
CC = gcc

311
drwl.h Normal file
View file

@ -0,0 +1,311 @@
/*
* drwl - https://codeberg.org/sewn/drwl
*
* Copyright (c) 2023-2024 sewn <sewn@disroot.org>
* Copyright (c) 2024 notchoc <notchoc@disroot.org>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* The UTF-8 Decoder included is from Bjoern Hoehrmann:
* Copyright (c) 2008-2010 Bjoern Hoehrmann <bjoern@hoehrmann.de>
* See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.
*/
#pragma once
#include <stdlib.h>
#include <fcft/fcft.h>
#include <pixman-1/pixman.h>
enum { ColFg, ColBg, ColBorder }; /* colorscheme index */
typedef struct fcft_font Fnt;
typedef pixman_image_t Img;
typedef struct {
Img *image;
Fnt *font;
uint32_t *scheme;
} Drwl;
#define UTF8_ACCEPT 0
#define UTF8_REJECT 12
#define UTF8_INVALID 0xFFFD
static const uint8_t utf8d[] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8,
0,12,24,36,60,96,84,12,12,12,48,72, 12,12,12,12,12,12,12,12,12,12,12,12,
12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24,12,12,
12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24,12,12,
12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36,12,12,
12,36,12,12,12,12,12,12,12,12,12,12,
};
static inline uint32_t
utf8decode(uint32_t *state, uint32_t *codep, uint8_t byte)
{
uint32_t type = utf8d[byte];
*codep = (*state != UTF8_ACCEPT) ?
(byte & 0x3fu) | (*codep << 6) :
(0xff >> type) & (byte);
*state = utf8d[256 + *state + type];
return *state;
}
static int
drwl_init(void)
{
fcft_set_scaling_filter(FCFT_SCALING_FILTER_LANCZOS3);
return fcft_init(FCFT_LOG_COLORIZE_AUTO, 0, FCFT_LOG_CLASS_ERROR);
}
static Drwl *
drwl_create(void)
{
Drwl *drwl;
if (!(drwl = calloc(1, sizeof(Drwl))))
return NULL;
return drwl;
}
static void
drwl_setfont(Drwl *drwl, Fnt *font)
{
if (drwl)
drwl->font = font;
}
static void
drwl_setimage(Drwl *drwl, Img *image)
{
if (drwl)
drwl->image = image;
}
static Fnt *
drwl_font_create(Drwl *drwl, size_t count,
const char *names[static count], const char *attributes)
{
Fnt *font = fcft_from_name(count, names, attributes);
if (drwl)
drwl_setfont(drwl, font);
return font;
}
static void
drwl_font_destroy(Fnt *font)
{
fcft_destroy(font);
}
static inline pixman_color_t
convert_color(uint32_t clr)
{
return (pixman_color_t){
((clr >> 24) & 0xFF) * 0x101 * (clr & 0xFF) / 0xFF,
((clr >> 16) & 0xFF) * 0x101 * (clr & 0xFF) / 0xFF,
((clr >> 8) & 0xFF) * 0x101 * (clr & 0xFF) / 0xFF,
(clr & 0xFF) * 0x101
};
}
static void
drwl_setscheme(Drwl *drwl, uint32_t *scm)
{
if (drwl)
drwl->scheme = scm;
}
static Img *
drwl_image_create(Drwl *drwl, unsigned int w, unsigned int h, uint32_t *bits)
{
Img *image;
pixman_region32_t clip;
image = pixman_image_create_bits_no_clear(
PIXMAN_a8r8g8b8, w, h, bits, w * 4);
if (!image)
return NULL;
pixman_region32_init_rect(&clip, 0, 0, w, h);
pixman_image_set_clip_region32(image, &clip);
pixman_region32_fini(&clip);
if (drwl)
drwl_setimage(drwl, image);
return image;
}
static void
drwl_rect(Drwl *drwl,
int x, int y, unsigned int w, unsigned int h,
int filled, int invert)
{
pixman_color_t clr;
if (!drwl || !drwl->scheme || !drwl->image)
return;
clr = convert_color(drwl->scheme[invert ? ColBg : ColFg]);
if (filled)
pixman_image_fill_rectangles(PIXMAN_OP_SRC, drwl->image, &clr, 1,
&(pixman_rectangle16_t){x, y, w, h});
else
pixman_image_fill_rectangles(PIXMAN_OP_SRC, drwl->image, &clr, 4,
(pixman_rectangle16_t[4]){
{ x, y, w, 1 },
{ x, y + h - 1, w, 1 },
{ x, y, 1, h },
{ x + w - 1, y, 1, h }});
}
static int
drwl_text(Drwl *drwl,
int x, int y, unsigned int w, unsigned int h,
unsigned int lpad, const char *text, int invert)
{
int ty;
int render = x || y || w || h;
long x_kern;
uint32_t cp = 0, last_cp = 0, state;
pixman_color_t clr;
pixman_image_t *fg_pix = NULL;
int noellipsis = 0;
const struct fcft_glyph *glyph, *eg = NULL;
int fcft_subpixel_mode = FCFT_SUBPIXEL_DEFAULT;
if (!drwl || (render && (!drwl->scheme || !w || !drwl->image)) || !text || !drwl->font)
return 0;
if (!render) {
w = invert ? invert : ~invert;
} else {
clr = convert_color(drwl->scheme[invert ? ColBg : ColFg]);
fg_pix = pixman_image_create_solid_fill(&clr);
drwl_rect(drwl, x, y, w, h, 1, !invert);
x += lpad;
w -= lpad;
}
if (render && (drwl->scheme[ColBg] & 0xFF) != 0xFF)
fcft_subpixel_mode = FCFT_SUBPIXEL_NONE;
if (render)
eg = fcft_rasterize_char_utf32(drwl->font, 0x2026 /* … */, fcft_subpixel_mode);
for (const char *p = text, *pp; pp = p, *p; p++) {
for (state = UTF8_ACCEPT; *p &&
utf8decode(&state, &cp, *p) > UTF8_REJECT; p++)
;
if (!*p || state == UTF8_REJECT) {
cp = UTF8_INVALID;
if (p > pp)
p--;
}
glyph = fcft_rasterize_char_utf32(drwl->font, cp, fcft_subpixel_mode);
if (!glyph)
continue;
x_kern = 0;
if (last_cp)
fcft_kerning(drwl->font, last_cp, cp, &x_kern, NULL);
last_cp = cp;
ty = y + (h - drwl->font->height) / 2 + drwl->font->ascent;
if (render && !noellipsis && x_kern + glyph->advance.x + eg->advance.x > w &&
*(p + 1) != '\0') {
/* cannot fit ellipsis after current codepoint */
if (drwl_text(drwl, 0, 0, 0, 0, 0, pp, 0) + x_kern <= w) {
noellipsis = 1;
} else {
w -= eg->advance.x;
pixman_image_composite32(
PIXMAN_OP_OVER, fg_pix, eg->pix, drwl->image, 0, 0, 0, 0,
x + eg->x, ty - eg->y, eg->width, eg->height);
}
}
if ((x_kern + glyph->advance.x) > w)
break;
x += x_kern;
if (render && pixman_image_get_format(glyph->pix) == PIXMAN_a8r8g8b8)
/* pre-rendered glyphs (eg. emoji) */
pixman_image_composite32(
PIXMAN_OP_OVER, glyph->pix, NULL, drwl->image, 0, 0, 0, 0,
x + glyph->x, ty - glyph->y, glyph->width, glyph->height);
else if (render)
pixman_image_composite32(
PIXMAN_OP_OVER, fg_pix, glyph->pix, drwl->image, 0, 0, 0, 0,
x + glyph->x, ty - glyph->y, glyph->width, glyph->height);
x += glyph->advance.x;
w -= glyph->advance.x;
}
if (render)
pixman_image_unref(fg_pix);
return x + (render ? w : 0);
}
static unsigned int
drwl_font_getwidth(Drwl *drwl, const char *text)
{
if (!drwl || !drwl->font || !text)
return 0;
return drwl_text(drwl, 0, 0, 0, 0, 0, text, 0);
}
static void
drwl_image_destroy(Img *image)
{
pixman_image_unref(image);
}
static void
drwl_destroy(Drwl *drwl)
{
if (drwl->font)
drwl_font_destroy(drwl->font);
if (drwl->image)
drwl_image_destroy(drwl->image);
free(drwl);
}
static void
drwl_fini(void)
{
fcft_fini();
}

15
dwl.1
View file

@ -7,6 +7,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl v
.Op Fl d
.Op Fl s Ar startup command
.Sh DESCRIPTION
.Nm
@ -22,6 +23,12 @@ option,
writes its name and version to standard error and exits unsuccessfully.
.Pp
When given the
.Fl d
option,
.Nm
enables full wlroots logging, including debug information.
.Pp
When given the
.Fl s
option,
.Nm
@ -48,7 +55,7 @@ Move window to a single tag.
Toggle tag for window.
.It Mod-p
Spawn
.Nm bemenu-run .
.Nm wmenu-run .
.It Mod-Shift-Return
Spawn
.Nm foot .
@ -101,7 +108,7 @@ These environment variables are used by
A directory where temporary user files, such as the Wayland socket,
are stored.
.It Ev XDG_CONFIG_DIR
A directory containung configuration of various programs and
A directory containing configuration of various programs and
libraries, including libxkbcommon.
.It Ev DISPLAY , WAYLAND_DISPLAY , WAYLAND_SOCKET
Tell how to connect to an underlying X11 or Wayland server.
@ -133,10 +140,10 @@ server.
Start
.Nm
with s6 in the background:
.Dl dwl -s 's6-svscan <&-'
.Dl dwl \-s \(aqs6\-svscan <&\-\(aq
.Sh SEE ALSO
.Xr foot 1 ,
.Xr bemenu 1 ,
.Xr wmenu 1 ,
.Xr dwm 1 ,
.Xr xkeyboard-config 7
.Sh CAVEATS

2049
dwl.c

File diff suppressed because it is too large Load diff

5
dwl.desktop Normal file
View file

@ -0,0 +1,5 @@
[Desktop Entry]
Name=dwl
Comment=dwm for Wayland
Exec=dwl
Type=Application

58
flake.lock Normal file
View file

@ -0,0 +1,58 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1733312601,
"narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1733759999,
"narHash": "sha256-463SNPWmz46iLzJKRzO3Q2b0Aurff3U1n0nYItxq7jU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a73246e2eef4c6ed172979932bc80e1404ba2d56",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1733096140,
"narHash": "sha256-1qRH7uAUsyQI7R1Uwl4T+XvdNv778H0Nb5njNrqvylY=",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/5487e69da40cbd611ab2cadee0b4637225f7cfae.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/5487e69da40cbd611ab2cadee0b4637225f7cfae.tar.gz"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

28
flake.nix Normal file
View file

@ -0,0 +1,28 @@
{
description = "dwm for Wayland (requires dwl 0.7)";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
};
outputs = inputs@{ flake-parts, nixpkgs, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
flake-parts.flakeModules.easyOverlay
];
systems = nixpkgs.lib.platforms.unix;
perSystem = { config, self', inputs', pkgs, system, ... }: {
overlayAttrs = {
zdwl = config.packages.default;
};
packages.default = pkgs.dwl.overrideAttrs (old: {
buildInputs = old.buildInputs ++ (with pkgs; [
fcft
libdrm.dev
]);
src = ./.;
});
};
};
}

1245
patches/bar-0.7.patch Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="wlr_output_power_management_unstable_v1">
<copyright>
Copyright © 2019 Purism SPC
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>
<description summary="Control power management modes of outputs">
This protocol allows clients to control power management modes
of outputs that are currently part of the compositor space. The
intent is to allow special clients like desktop shells to power
down outputs when the system is idle.
To modify outputs not currently part of the compositor space see
wlr-output-management.
Warning! The protocol described in this file is experimental and
backward incompatible changes may be made. Backward compatible changes
may be added together with the corresponding interface version bump.
Backward incompatible changes are done by bumping the version number in
the protocol and interface names and resetting the interface version.
Once the protocol is to be declared stable, the 'z' prefix and the
version number in the protocol and interface names are removed and the
interface version number is reset.
</description>
<interface name="zwlr_output_power_manager_v1" version="1">
<description summary="manager to create per-output power management">
This interface is a manager that allows creating per-output power
management mode controls.
</description>
<request name="get_output_power">
<description summary="get a power management for an output">
Create a output power management mode control that can be used to
adjust the power management mode for a given output.
</description>
<arg name="id" type="new_id" interface="zwlr_output_power_v1"/>
<arg name="output" type="object" interface="wl_output"/>
</request>
<request name="destroy" type="destructor">
<description summary="destroy the manager">
All objects created by the manager will still remain valid, until their
appropriate destroy request has been called.
</description>
</request>
</interface>
<interface name="zwlr_output_power_v1" version="1">
<description summary="adjust power management mode for an output">
This object offers requests to set the power management mode of
an output.
</description>
<enum name="mode">
<entry name="off" value="0"
summary="Output is turned off."/>
<entry name="on" value="1"
summary="Output is turned on, no power saving"/>
</enum>
<enum name="error">
<entry name="invalid_mode" value="1" summary="inexistent power save mode"/>
</enum>
<request name="set_mode">
<description summary="Set an outputs power save mode">
Set an output's power save mode to the given mode. The mode change
is effective immediately. If the output does not support the given
mode a failed event is sent.
</description>
<arg name="mode" type="uint" enum="mode" summary="the power save mode to set"/>
</request>
<event name="mode">
<description summary="Report a power management mode change">
Report the power management mode change of an output.
The mode event is sent after an output changed its power
management mode. The reason can be a client using set_mode or the
compositor deciding to change an output's mode.
This event is also sent immediately when the object is created
so the client is informed about the current power management mode.
</description>
<arg name="mode" type="uint" enum="mode"
summary="the output's new power management mode"/>
</event>
<event name="failed">
<description summary="object no longer valid">
This event indicates that the output power management mode control
is no longer valid. This can happen for a number of reasons,
including:
- The output doesn't support power management
- Another client already has exclusive power management mode control
for this output
- The output disappeared
Upon receiving this event, the client should destroy this object.
</description>
</event>
<request name="destroy" type="destructor">
<description summary="destroy this power management">
Destroys the output power management mode control object.
</description>
</request>
</interface>
</protocol>

2
shell.fish Executable file
View file

@ -0,0 +1,2 @@
nix-shell -p bear --command fish
nix develop nixpkgs#dwl --command fish

16
util.c
View file

@ -3,6 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include "util.h"
@ -33,3 +34,18 @@ ecalloc(size_t nmemb, size_t size)
die("calloc:");
return p;
}
int
fd_set_nonblock(int fd) {
int flags = fcntl(fd, F_GETFL);
if (flags < 0) {
perror("fcntl(F_GETFL):");
return -1;
}
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) {
perror("fcntl(F_SETFL):");
return -1;
}
return 0;
}

1
util.h
View file

@ -2,3 +2,4 @@
void die(const char *fmt, ...);
void *ecalloc(size_t nmemb, size_t size);
int fd_set_nonblock(int fd);