16 Commits

Author SHA1 Message Date
Nikita Ivanov d5bbe6d54d Fix crash disabling monitor with locked surface
(cherry picked from commit d1880b4422)
2025-06-18 22:10:34 +02:00
Leonardo Hernández Hernández 2783d91611 remove binary before copying to destination
Since Linux 6.11 is possible overwrite a running executable, possibly making it
crash.

Thanks to: movq42rax
Fixes: https://codeberg.org/dwl/dwl/issues/709
References: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2a010c412853
References: https://lore.kernel.org/stable/CACKH++YAtEMYu2nTLUyfmxZoGO37fqogKMDkBpddmNaz5HE6ng@mail.gmail.com/T/#u

(cherry picked from commit 1d08ade132)
2025-03-13 22:00:48 +01:00
Guido Cella b2abff8b57 fix a use after free
This line makes dwl crash after closing mpv with the switchtotag patch.

(cherry picked from commit 8206cc8889)
2025-03-13 21:59:55 +01:00
DreamMaoMao 298c6e1839 fix: crash when open some x11 app
(cherry picked from commit e0f531d508)
2025-03-13 21:58:14 +01: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
10 changed files with 335 additions and 458 deletions
-2
View File
@@ -1,3 +1 @@
Lennart Jablonka <humm@ljabl.com> <hummsmith42@gmail.com> Lennart Jablonka <humm@ljabl.com> <hummsmith42@gmail.com>
Leonardo Hernández Hernández <leohdz172@proton.me> <leohdz172@outlook.com>
Leonardo Hernández Hernández <leohdz172@proton.me> <leohdz172@protonmail.com>
+7 -10
View File
@@ -8,15 +8,6 @@
## Unreleased ## Unreleased
### Added ### Added
* Support for the linux-drm-syncobj-v1 protocol ([wlroots!4715][wlroots!4715], [#685][685])
* Allow the use of non-system wlroots library ([#646][646])
[wlroots!4715]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4715
[685]: https://codeberg.org/dwl/dwl/pulls/685
[646]: https://codeberg.org/dwl/dwl/pulls/646
### Changed ### Changed
### Deprecated ### Deprecated
### Removed ### Removed
@@ -30,7 +21,7 @@
## 0.7 ## 0.7
This version is just 0.6 with wlroots 0.18 compatibility. See also [0.6](#0.6) release notes. 0.7 builds against wlroots 0.18.x.
### Added ### Added
@@ -41,9 +32,15 @@ This version is just 0.6 with wlroots 0.18 compatibility.
[601]: https://codeberg.org/dwl/dwl/issues/601 [601]: https://codeberg.org/dwl/dwl/issues/601
### Fixed
* Crash when re-mapping unmapped clients.
### Contributors ### Contributors
Guido Cella Guido Cella
Lennart Jablonka
## 0.6 ## 0.6
+4 -4
View File
@@ -6,15 +6,15 @@ include config.mk
# flags for compiling # flags for compiling
DWLCPPFLAGS = -I. -DWLR_USE_UNSTABLE -D_POSIX_C_SOURCE=200809L \ DWLCPPFLAGS = -I. -DWLR_USE_UNSTABLE -D_POSIX_C_SOURCE=200809L \
-DVERSION=\"$(VERSION)\" $(XWAYLAND) -DVERSION=\"$(VERSION)\" $(XWAYLAND)
DWLDEVCFLAGS = -g -Wpedantic -Wall -Wextra -Wdeclaration-after-statement \ DWLDEVCFLAGS = -g -pedantic -Wall -Wextra -Wdeclaration-after-statement \
-Wno-unused-parameter -Wshadow -Wunused-macros -Werror=strict-prototypes \ -Wno-unused-parameter -Wshadow -Wunused-macros -Werror=strict-prototypes \
-Werror=implicit -Werror=return-type -Werror=incompatible-pointer-types \ -Werror=implicit -Werror=return-type -Werror=incompatible-pointer-types \
-Wfloat-conversion -Wfloat-conversion
# CFLAGS / LDFLAGS # CFLAGS / LDFLAGS
PKGS = wayland-server xkbcommon libinput $(XLIBS) PKGS = wlroots-0.18 wayland-server xkbcommon libinput $(XLIBS)
DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(WLR_INCS) $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS) DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) -lm $(LIBS) LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` -lm $(LIBS)
all: dwl all: dwl
dwl: dwl.o util.o dwl: dwl.o util.o
+18 -28
View File
@@ -1,12 +1,12 @@
# dwl - dwm for Wayland # dwl - dwm for Wayland
Join us on our IRC channel: [#dwl on Libera Chat] Join us on our IRC channel: [#dwl on Libera Chat]
Or on the community-maintained [Discord server]. Or on our [Discord server].
dwl is a compact, hackable compositor for [Wayland] based on [wlroots]. It is 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, intended to fill the same space in the Wayland world that dwm does in X11,
primarily in terms of functionality, and secondarily in terms of primarily in terms of functionality, and secondarily in terms of
philosophy. Like [dwm], dwl is: philosophy. Like dwm, dwl is:
- Easy to understand, hack on, and extend with patches - Easy to understand, hack on, and extend with patches
- One C source file (or a very small number) configurable via `config.h` - One C source file (or a very small number) configurable via `config.h`
@@ -14,12 +14,13 @@ philosophy. Like [dwm], dwl is:
## Getting Started: ## Getting Started:
### **dwl branch 0.7 and releases based upon 0.7 build against [wlroots] 0.18**
### Latest semi-stable [release] ### Latest semi-stable [release]
This is probably where you want to start. This builds against the [wlroots] This is probably where you want to start. This builds against the dependent
versions currently shipping in major distributions. If your packages' versions currently shipping in major distributions. If your
distribution's `wlroots` version is older, use an earlier dwl [release]. distribution's wlroots version is older, use an earlier dwl [release] or [0.x
The `wlroots` version against which a given `dwl` release builds is specified branch].
with each release on the [release] page
### Development branch [main] ### Development branch [main]
Active development progresses on the `main` branch. The `main` branch is built Active development progresses on the `main` branch. The `main` branch is built
@@ -55,11 +56,11 @@ To enable XWayland, you should uncomment its flags in `config.mk`.
## Configuration ## Configuration
All configuration is done by editing `config.h` and recompiling, in the same All configuration is done by editing `config.h` and recompiling, in the same
manner as [dwm]. There is no way to separately restart the window manager in 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 Wayland without restarting the entire display server, so any changes will take
effect the next time dwl is executed. effect the next time dwl is executed.
As in the [dwm] community, we encourage users to share patches they have As in the dwm community, we encourage users to share patches they have
created. Check out the [dwl-patches] repository! created. Check out the [dwl-patches] repository!
## Running dwl ## Running dwl
@@ -75,7 +76,7 @@ seatd daemon.
When dwl is run with no arguments, it will launch the server and begin handling 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 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 decoration initially; these are instead clients that can be run within the
Wayland session. Do note that the default background color is grey. This can be Wayland session. Do note that the default background color is black. This can be
modified in `config.h`. modified in `config.h`.
If you would like to run a script or command automatically at startup, you can If you would like to run a script or command automatically at startup, you can
@@ -103,7 +104,7 @@ automatically, you will need to configure it prior to launching `dwl`, e.g.:
Information about selected layouts, current window title, app-id, 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 selected/occupied/urgent tags is written to the stdin of the `-s` command (see
the `STATUS INFORMATION` section in `_dwl_(1)`). This information can be used to the `printstatus()` function for details). This information can be used to
populate an external status bar with a script that parses the 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 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, do want to run a startup command that does not consume the status information,
@@ -118,26 +119,17 @@ script with the line
To get a list of status bars that work with dwl consult our [wiki]. To get a list of status bars that work with dwl consult our [wiki].
### (Known) Java nonreparenting WM issue
Certain IDEs don't display correctly unless an environmental variable for Java AWT
indicates that the WM is nonreparenting.
For some Java AWT-based IDEs, such as Xilinx Vivado and Microchip MPLAB X, the
following environment variable needs to be set before running the IDE or dwl:
export _JAVA_AWT_WM_NONREPARENTING=1
## Replacements for X applications ## Replacements for X applications
You can find a [list of useful resources on our wiki]. You can find a [list of useful resources on our wiki].
## Background ## Background
dwl is not meant to provide every feature under the sun. Instead, like [dwm], it 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 sticks to features which are necessary, simple, and straightforward to implement
given the base on which it is built. Implemented default features are: given the base on which it is built. Implemented default features are:
- Any features provided by [dwm]/Xlib: simple window borders, tags, keybindings, - Any features provided by dwm/Xlib: simple window borders, tags, keybindings,
client rules, mouse move/resize. Providing a built-in status bar is an 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 exception to this goal, to avoid dependencies on font rendering and/or drawing
libraries when an external bar could work well. libraries when an external bar could work well.
@@ -154,10 +146,10 @@ given the base on which it is built. Implemented default features are:
- Layer shell popups (used by Waybar) - Layer shell popups (used by Waybar)
- Damage tracking provided by scenegraph API - Damage tracking provided by scenegraph API
Given the Wayland architecture, dwl has to implement features from [dwm] **and** 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 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 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 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. indiscriminately. We will try to keep the code as small as possible.
Features under consideration (possibly as patches) are: Features under consideration (possibly as patches) are:
@@ -181,7 +173,7 @@ developers. This was made possible in many cases by looking at how sway
accomplished something, then trying to do the same in as suckless a way as accomplished something, then trying to do the same in as suckless a way as
possible. possible.
Many thanks to suckless.org and the [dwm] developers and community for the Many thanks to suckless.org and the dwm developers and community for the
inspiration, and to the various contributors to the project, including: inspiration, and to the various contributors to the project, including:
- **Devin J. Pohly for creating and nurturing the fledgling project** - **Devin J. Pohly for creating and nurturing the fledgling project**
@@ -191,8 +183,6 @@ inspiration, and to the various contributors to the project, including:
- Stivvo for output management and fullscreen support, and patch maintenance - Stivvo for output management and fullscreen support, and patch maintenance
[wlroots]: https://gitlab.freedesktop.org/wlroots
[dwm]: https://dwm.suckless.org/
[`systemd --user`]: https://wiki.archlinux.org/title/Systemd/User [`systemd --user`]: https://wiki.archlinux.org/title/Systemd/User
[#dwl on Libera Chat]: https://web.libera.chat/?channels=#dwl [#dwl on Libera Chat]: https://web.libera.chat/?channels=#dwl
[0.7-rc1]: https://codeberg.org/dwl/dwl/releases/tag/v0.7-rc1 [0.7-rc1]: https://codeberg.org/dwl/dwl/releases/tag/v0.7-rc1
+31 -27
View File
@@ -126,14 +126,15 @@ client_get_appid(Client *c)
{ {
#ifdef XWAYLAND #ifdef XWAYLAND
if (client_is_x11(c)) if (client_is_x11(c))
return c->surface.xwayland->class ? c->surface.xwayland->class : "broken"; return c->surface.xwayland->class;
#endif #endif
return c->surface.xdg->toplevel->app_id ? c->surface.xdg->toplevel->app_id : "broken"; return c->surface.xdg->toplevel->app_id;
} }
static inline void static inline void
client_get_clip(Client *c, struct wlr_box *clip) client_get_clip(Client *c, struct wlr_box *clip)
{ {
struct wlr_box xdg_geom = {0};
*clip = (struct wlr_box){ *clip = (struct wlr_box){
.x = 0, .x = 0,
.y = 0, .y = 0,
@@ -146,8 +147,9 @@ client_get_clip(Client *c, struct wlr_box *clip)
return; return;
#endif #endif
clip->x = c->surface.xdg->geometry.x; wlr_xdg_surface_get_geometry(c->surface.xdg, &xdg_geom);
clip->y = c->surface.xdg->geometry.y; clip->x = xdg_geom.x;
clip->y = xdg_geom.y;
} }
static inline void static inline void
@@ -162,7 +164,7 @@ client_get_geometry(Client *c, struct wlr_box *geom)
return; return;
} }
#endif #endif
*geom = c->surface.xdg->geometry; wlr_xdg_surface_get_geometry(c->surface.xdg, geom);
} }
static inline Client * static inline Client *
@@ -198,9 +200,9 @@ client_get_title(Client *c)
{ {
#ifdef XWAYLAND #ifdef XWAYLAND
if (client_is_x11(c)) if (client_is_x11(c))
return c->surface.xwayland->title ? c->surface.xwayland->title : "broken"; return c->surface.xwayland->title;
#endif #endif
return c->surface.xdg->toplevel->title ? c->surface.xdg->toplevel->title : "broken"; return c->surface.xdg->toplevel->title;
} }
static inline int static inline int
@@ -213,15 +215,16 @@ client_is_float_type(Client *c)
if (client_is_x11(c)) { if (client_is_x11(c)) {
struct wlr_xwayland_surface *surface = c->surface.xwayland; struct wlr_xwayland_surface *surface = c->surface.xwayland;
xcb_size_hints_t *size_hints = surface->size_hints; xcb_size_hints_t *size_hints = surface->size_hints;
size_t i;
if (surface->modal) if (surface->modal)
return 1; return 1;
if (wlr_xwayland_surface_has_window_type(surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_DIALOG) for (i = 0; i < surface->window_type_len; i++)
|| wlr_xwayland_surface_has_window_type(surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_SPLASH) if (surface->window_type[i] == netatom[NetWMWindowTypeDialog]
|| wlr_xwayland_surface_has_window_type(surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_TOOLBAR) || surface->window_type[i] == netatom[NetWMWindowTypeSplash]
|| wlr_xwayland_surface_has_window_type(surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_UTILITY)) { || surface->window_type[i] == netatom[NetWMWindowTypeToolbar]
|| surface->window_type[i] == netatom[NetWMWindowTypeUtility])
return 1; return 1;
}
return size_hints && size_hints->min_width > 0 && size_hints->min_height > 0 return size_hints && size_hints->min_width > 0 && size_hints->min_height > 0
&& (size_hints->max_width == size_hints->min_width && (size_hints->max_width == size_hints->min_width
@@ -264,8 +267,8 @@ client_is_stopped(Client *c)
wl_client_get_credentials(c->surface.xdg->client->client, &pid, NULL, NULL); wl_client_get_credentials(c->surface.xdg->client->client, &pid, NULL, NULL);
if (waitid(P_PID, pid, &in, WNOHANG|WCONTINUED|WSTOPPED|WNOWAIT) < 0) { if (waitid(P_PID, pid, &in, WNOHANG|WCONTINUED|WSTOPPED|WNOWAIT) < 0) {
/* This process is not our child process, while is very unlikely that /* This process is not our child process, while is very unluckely that
* it is stopped, in order to do not skip frames, assume that it is. */ * it is stopped, in order to do not skip frames assume that it is. */
if (errno == ECHILD) if (errno == ECHILD)
return 1; return 1;
} else if (in.si_pid) { } else if (in.si_pid) {
@@ -298,6 +301,17 @@ client_notify_enter(struct wlr_surface *s, struct wlr_keyboard *kb)
wlr_seat_keyboard_notify_enter(seat, s, NULL, 0, NULL); wlr_seat_keyboard_notify_enter(seat, s, NULL, 0, NULL);
} }
static inline void
client_restack_surface(Client *c)
{
#ifdef XWAYLAND
if (client_is_x11(c))
wlr_xwayland_surface_restack(c->surface.xwayland, NULL,
XCB_STACK_MODE_ABOVE);
#endif
return;
}
static inline void static inline void
client_send_close(Client *c) client_send_close(Client *c)
{ {
@@ -330,13 +344,6 @@ client_set_fullscreen(Client *c, int fullscreen)
wlr_xdg_toplevel_set_fullscreen(c->surface.xdg->toplevel, fullscreen); wlr_xdg_toplevel_set_fullscreen(c->surface.xdg->toplevel, fullscreen);
} }
static inline void
client_set_scale(struct wlr_surface *s, float scale)
{
wlr_fractional_scale_v1_notify_scale(s, scale);
wlr_surface_set_preferred_buffer_scale(s, (int32_t)ceilf(scale));
}
static inline uint32_t static inline uint32_t
client_set_size(Client *c, uint32_t width, uint32_t height) client_set_size(Client *c, uint32_t width, uint32_t height)
{ {
@@ -357,11 +364,8 @@ static inline void
client_set_tiled(Client *c, uint32_t edges) client_set_tiled(Client *c, uint32_t edges)
{ {
#ifdef XWAYLAND #ifdef XWAYLAND
if (client_is_x11(c)) { if (client_is_x11(c))
wlr_xwayland_surface_set_maximized(c->surface.xwayland,
edges != WLR_EDGE_NONE, edges != WLR_EDGE_NONE);
return; return;
}
#endif #endif
if (wl_resource_get_version(c->surface.xdg->toplevel->resource) if (wl_resource_get_version(c->surface.xdg->toplevel->resource)
>= XDG_TOPLEVEL_STATE_TILED_RIGHT_SINCE_VERSION) { >= XDG_TOPLEVEL_STATE_TILED_RIGHT_SINCE_VERSION) {
@@ -387,8 +391,8 @@ client_wants_focus(Client *c)
{ {
#ifdef XWAYLAND #ifdef XWAYLAND
return client_is_unmanaged(c) return client_is_unmanaged(c)
&& wlr_xwayland_surface_override_redirect_wants_focus(c->surface.xwayland) && wlr_xwayland_or_surface_wants_focus(c->surface.xwayland)
&& wlr_xwayland_surface_icccm_input_model(c->surface.xwayland) != WLR_ICCCM_INPUT_MODEL_NONE; && wlr_xwayland_icccm_input_model(c->surface.xwayland) != WLR_ICCCM_INPUT_MODEL_NONE;
#endif #endif
return 0; return 0;
} }
+15 -11
View File
@@ -12,7 +12,7 @@ static const float bordercolor[] = COLOR(0x444444ff);
static const float focuscolor[] = COLOR(0x005577ff); static const float focuscolor[] = COLOR(0x005577ff);
static const float urgentcolor[] = COLOR(0xff0000ff); static const float urgentcolor[] = COLOR(0xff0000ff);
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */ /* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */
/* tagging - TAGCOUNT must be no greater than 31 */ /* tagging - TAGCOUNT must be no greater than 31 */
#define TAGCOUNT (9) #define TAGCOUNT (9)
@@ -20,11 +20,12 @@ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You ca
/* logging */ /* logging */
static int log_level = WLR_ERROR; 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[] = { static const Rule rules[] = {
/* app_id title tags mask isfloating monitor */ /* app_id title tags mask isfloating monitor */
/* examples: */
{ "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */ { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
{ "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */ { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
/* default/example rule: can be changed but cannot be eliminated; at least one rule must exist */
}; };
/* layout(s) */ /* layout(s) */
@@ -37,14 +38,17 @@ static const Layout layouts[] = {
/* monitors */ /* monitors */
/* (x=-1, y=-1) is reserved as an "autoconfigure" monitor position indicator /* (x=-1, y=-1) is reserved as an "autoconfigure" monitor position indicator
* WARNING: negative values other than (-1, -1) cause problems with Xwayland clients due to * WARNING: negative values other than (-1, -1) cause problems with Xwayland clients
* https://gitlab.freedesktop.org/xorg/xserver/-/issues/899 */ * 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[] = { static const MonitorRule monrules[] = {
/* name mfact nmaster scale layout rotate/reflect x y /* name mfact nmaster scale layout rotate/reflect x y */
* example of a HiDPI laptop monitor: /* example of a HiDPI laptop monitor:
{ "eDP-1", 0.5f, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, */ { "eDP-1", 0.5f, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
*/
/* defaults */
{ NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, { NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
/* default monitor rule: can be changed but cannot be eliminated; at least one monitor rule must exist */
}; };
/* keyboard */ /* keyboard */
@@ -119,7 +123,7 @@ static const char *termcmd[] = { "foot", NULL };
static const char *menucmd[] = { "wmenu-run", NULL }; static const char *menucmd[] = { "wmenu-run", NULL };
static const Key keys[] = { static const Key keys[] = {
/* Note that Shift changes certain key codes: 2 -> at, etc. */ /* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */
/* modifier key function argument */ /* modifier key function argument */
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} }, { MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
@@ -131,7 +135,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_l, setmfact, {.f = +0.05f} }, { MODKEY, XKB_KEY_l, setmfact, {.f = +0.05f} },
{ MODKEY, XKB_KEY_Return, zoom, {0} }, { MODKEY, XKB_KEY_Return, zoom, {0} },
{ MODKEY, XKB_KEY_Tab, view, {0} }, { MODKEY, XKB_KEY_Tab, view, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_c, killclient, {0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C, killclient, {0} },
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} }, { MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} }, { MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
@@ -153,7 +157,7 @@ static const Key keys[] = {
TAGKEYS( XKB_KEY_7, XKB_KEY_ampersand, 6), TAGKEYS( XKB_KEY_7, XKB_KEY_ampersand, 6),
TAGKEYS( XKB_KEY_8, XKB_KEY_asterisk, 7), TAGKEYS( XKB_KEY_8, XKB_KEY_asterisk, 7),
TAGKEYS( XKB_KEY_9, XKB_KEY_parenleft, 8), TAGKEYS( XKB_KEY_9, XKB_KEY_parenleft, 8),
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_q, quit, {0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Q, quit, {0} },
/* Ctrl-Alt-Backspace and Ctrl-Alt-Fx used to be handled by X server */ /* 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} }, { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_Terminate_Server, quit, {0} },
+2 -21
View File
@@ -1,4 +1,4 @@
_VERSION = 0.8-dev _VERSION = 0.7
VERSION = `git describe --tags --dirty 2>/dev/null || echo $(_VERSION)` VERSION = `git describe --tags --dirty 2>/dev/null || echo $(_VERSION)`
PKG_CONFIG = pkg-config PKG_CONFIG = pkg-config
@@ -8,29 +8,10 @@ PREFIX = /usr/local
MANDIR = $(PREFIX)/share/man MANDIR = $(PREFIX)/share/man
DATADIR = $(PREFIX)/share DATADIR = $(PREFIX)/share
WLR_INCS = `$(PKG_CONFIG) --cflags wlroots-0.19`
WLR_LIBS = `$(PKG_CONFIG) --libs wlroots-0.19`
# Allow using an alternative wlroots installation
# This has to have all the includes required by wlroots, e.g:
# Assuming wlroots git repo is "${PWD}/wlroots" and you only ran "meson setup build && ninja -C build"
#WLR_INCS = -I/usr/include/pixman-1 -I/usr/include/elogind -I/usr/include/libdrm \
# -I$(PWD)/wlroots/include
# Set -rpath to avoid using the wrong library.
#WLR_LIBS = -Wl,-rpath,$(PWD)/wlroots/build -L$(PWD)/wlroots/build -lwlroots-0.19
# Assuming you ran "meson setup --prefix ${PWD}/0.19 build && ninja -C build install"
#WLR_INCS = -I/usr/include/pixman-1 -I/usr/include/elogind -I/usr/include/libdrm \
# -I$(PWD)/wlroots/0.19/include/wlroots-0.19
#WLR_LIBS = -Wl,-rpath,$(PWD)/wlroots/0.19/lib64 -L$(PWD)/wlroots/0.19/lib64 -lwlroots-0.19
XWAYLAND = XWAYLAND =
XLIBS = XLIBS =
# Uncomment to build XWayland support # Uncomment to build XWayland support
#XWAYLAND = -DXWAYLAND #XWAYLAND = -DXWAYLAND
#XLIBS = xcb xcb-icccm #XLIBS = xcb xcb-icccm
# dwl itself only uses C99 features, but wlroots' headers use anonymous unions (C11). CC = gcc
# To avoid warnings about them, we do not use -std=c99 and instead of using the
# gmake default 'CC=c99', we use cc.
CC = cc
+12 -112
View File
@@ -37,7 +37,7 @@ starts a shell process running
when starting. when starting.
When stopping, it sends When stopping, it sends
.Dv SIGTERM .Dv SIGTERM
to the child process group and waits for it to exit. to the child process and waits for it to exit.
.Pp .Pp
Users are encouraged to customize Users are encouraged to customize
.Nm .Nm
@@ -55,10 +55,10 @@ Move window to a single tag.
Toggle tag for window. Toggle tag for window.
.It Mod-p .It Mod-p
Spawn Spawn
.Xr wmenu-run 1 . .Nm wmenu-run .
.It Mod-Shift-Return .It Mod-Shift-Return
Spawn Spawn
.Xr foot 1 . .Nm foot .
.It Mod-[jk] .It Mod-[jk]
Move focus down/up the stack. Move focus down/up the stack.
.It Mod-[id] .It Mod-[id]
@@ -100,114 +100,6 @@ Quit
.Nm . .Nm .
.El .El
These might differ depending on your keyboard layout. These might differ depending on your keyboard layout.
.Ss Mouse commands
.Bl -tag -width 20n -offset indent -compact
.It Mod-Button1
Move focused window while dragging.
Tiled windows will be toggled to the floating state.
.It Mod-Button2
Toggle focused window between floating and tiled state.
.It Mod-Button3
Resize focused window while dragging.
Tiled windows will be toggled to the floating state.
.El
.Sh STATUS INFORMATION
.Nm
writes its status information to standard output.
If the
.Fl s
option is given, the status information is written to the standard input of the
child process instead.
.Pp
Said information has the following format:
.Bd -ragged -offset indent
.Ar <monitor>
.Ar <component>
.Ar <data>
.Ed
.Pp
.Bl -tag -width 11n -offset 0 -compact
.It Ar <monitor>
is the name given to the output.
.It Ar <component>
is one of (in order)
.Em title ,
.Em appid ,
.Em fullscreen ,
.Em floating ,
.Em selmon ,
.Em tags ,
.Em layout .
.It Ar <data>
changes depending on
.Ar <component> .
.Bl -tag -width 10n -compact
.It Em title
The title of the focused window on
.Ar <monitor>
or nothing if there is no focused window.
.It Em appid
The app_id of the focused window on
.Ar <monitor>
or nothing if there is no focused window.
.It Em fullscreen
Prints 1 if the focused window on
.Ar <monitor>
is in fullscreen state, otherwise prints 0. If there is no focused
window it prints nothing.
.It Em floating
Prints 1 if the focused window on
.Ar <monitor>
is in floating state, otherwise prints 0. If there is no focused
window it prints nothing.
.It Em selmon
Prints 1 if
.Ar <monitor>
is the selected monitor, otherwise prints 0.
.It Em tags
Prints four bitmasks in the following order:
.Bl -bullet -width 2n -compact
.It
Occupied tags of
.Ar <monitor> .
.It
Selected tags of
.Ar <monitor> .
.It
Tags of the focused window on
.Ar <monitor> .
.It
Tags where a window on
.Ar <monitor>
requested activation or has urgency hints.
.El
The bitmasks are 32-bit unsigned decimal integers.
.It Em layout
Prints the symbol of the current layout.
.El
.El
.Ss Examples
When there is a selected window:
.Bd -literal -offset indent
HDMI\-A\-1 title \(ti/source/repos/dwl > man \-l dwl.1
HDMI\-A\-1 appid footclient
HDMI\-A\-1 fullscreen 0
HDMI\-A\-1 floating 0
HDMI\-A\-1 selmon 1
HDMI\-A\-1 tags 271 4 4 0
HDMI\-A\-1 layout [T]
.Ed
.Pp
When there is no selected window:
.Bd -literal -offset indent
HDMI\-A\-1 title
HDMI\-A\-1 appid
HDMI\-A\-1 fullscreen
HDMI\-A\-1 floating
HDMI\-A\-1 selmon 1
HDMI\-A\-1 tags 271 512 0 0
HDMI\-A\-1 layout [T]
.Ed
.Sh ENVIRONMENT .Sh ENVIRONMENT
These environment variables are used by These environment variables are used by
.Nm : .Nm :
@@ -250,9 +142,17 @@ Start
with s6 in the background: with s6 in the background:
.Dl dwl \-s \(aqs6\-svscan <&\-\(aq .Dl dwl \-s \(aqs6\-svscan <&\-\(aq
.Sh SEE ALSO .Sh SEE ALSO
.Xr dwm 1 ,
.Xr foot 1 , .Xr foot 1 ,
.Xr wmenu 1 , .Xr wmenu 1 ,
.Xr dwm 1 ,
.Xr xkeyboard-config 7 .Xr xkeyboard-config 7
.Sh CAVEATS
The child process's standard input is connected with a pipe to
.Nm .
If the child process neither reads from the pipe nor closes its
standard input,
.Nm
will freeze after a while due to it blocking when writing to the full
pipe buffer.
.Sh BUGS .Sh BUGS
All of them. All of them.
+203 -200
View File
@@ -33,7 +33,6 @@
#include <wlr/types/wlr_keyboard_group.h> #include <wlr/types/wlr_keyboard_group.h>
#include <wlr/types/wlr_layer_shell_v1.h> #include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_linux_dmabuf_v1.h> #include <wlr/types/wlr_linux_dmabuf_v1.h>
#include <wlr/types/wlr_linux_drm_syncobj_v1.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_output_management_v1.h> #include <wlr/types/wlr_output_management_v1.h>
@@ -79,12 +78,16 @@
#define END(A) ((A) + LENGTH(A)) #define END(A) ((A) + LENGTH(A))
#define TAGMASK ((1u << TAGCOUNT) - 1) #define TAGMASK ((1u << TAGCOUNT) - 1)
#define LISTEN(E, L, H) wl_signal_add((E), ((L)->notify = (H), (L))) #define LISTEN(E, L, H) wl_signal_add((E), ((L)->notify = (H), (L)))
#define LISTEN_STATIC(E, H) do { struct wl_listener *_l = ecalloc(1, sizeof(*_l)); _l->notify = (H); wl_signal_add((E), _l); } while (0) #define LISTEN_STATIC(E, H) do { static struct wl_listener _l = {.notify = (H)}; wl_signal_add((E), &_l); } while (0)
/* enums */ /* enums */
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */ enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
enum { XDGShell, LayerShell, X11 }; /* client types */ enum { XDGShell, LayerShell, X11 }; /* client types */
enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrOverlay, LyrBlock, NUM_LAYERS }; /* scene layers */ enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrOverlay, LyrBlock, NUM_LAYERS }; /* scene layers */
#ifdef XWAYLAND
enum { NetWMWindowTypeDialog, NetWMWindowTypeSplash, NetWMWindowTypeToolbar,
NetWMWindowTypeUtility, NetLast }; /* EWMH atoms */
#endif
typedef union { typedef union {
int i; int i;
@@ -102,18 +105,15 @@ typedef struct {
typedef struct Monitor Monitor; typedef struct Monitor Monitor;
typedef struct { typedef struct {
/* Must keep this field first */ /* Must keep these three elements in this order */
unsigned int type; /* XDGShell or X11* */ unsigned int type; /* XDGShell or X11* */
struct wlr_box geom; /* layout-relative, includes border */
Monitor *mon; Monitor *mon;
struct wlr_scene_tree *scene; struct wlr_scene_tree *scene;
struct wlr_scene_rect *border[4]; /* top, bottom, left, right */ struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
struct wlr_scene_tree *scene_surface; struct wlr_scene_tree *scene_surface;
struct wl_list link; struct wl_list link;
struct wl_list flink; struct wl_list flink;
struct wlr_box geom; /* layout-relative, includes border */
struct wlr_box prev; /* layout-relative, includes border */
struct wlr_box bounds; /* only width and height are used */
union { union {
struct wlr_xdg_surface *xdg; struct wlr_xdg_surface *xdg;
struct wlr_xwayland_surface *xwayland; struct wlr_xwayland_surface *xwayland;
@@ -128,6 +128,8 @@ typedef struct {
struct wl_listener fullscreen; struct wl_listener fullscreen;
struct wl_listener set_decoration_mode; struct wl_listener set_decoration_mode;
struct wl_listener destroy_decoration; struct wl_listener destroy_decoration;
struct wlr_box prev; /* layout-relative, includes border */
struct wlr_box bounds;
#ifdef XWAYLAND #ifdef XWAYLAND
struct wl_listener activate; struct wl_listener activate;
struct wl_listener associate; struct wl_listener associate;
@@ -149,6 +151,7 @@ typedef struct {
} Key; } Key;
typedef struct { typedef struct {
struct wl_list link;
struct wlr_keyboard_group *wlr_group; struct wlr_keyboard_group *wlr_group;
int nsyms; int nsyms;
@@ -162,9 +165,9 @@ typedef struct {
} KeyboardGroup; } KeyboardGroup;
typedef struct { typedef struct {
/* Must keep this field first */ /* Must keep these three elements in this order */
unsigned int type; /* LayerShell */ unsigned int type; /* LayerShell */
struct wlr_box geom;
Monitor *mon; Monitor *mon;
struct wlr_scene_tree *scene; struct wlr_scene_tree *scene;
struct wlr_scene_tree *popups; struct wlr_scene_tree *popups;
@@ -252,7 +255,6 @@ static void chvt(const Arg *arg);
static void checkidleinhibitor(struct wlr_surface *exclude); static void checkidleinhibitor(struct wlr_surface *exclude);
static void cleanup(void); static void cleanup(void);
static void cleanupmon(struct wl_listener *listener, void *data); static void cleanupmon(struct wl_listener *listener, void *data);
static void cleanuplisteners(void);
static void closemon(Monitor *m); static void closemon(Monitor *m);
static void commitlayersurfacenotify(struct wl_listener *listener, void *data); static void commitlayersurfacenotify(struct wl_listener *listener, void *data);
static void commitnotify(struct wl_listener *listener, void *data); static void commitnotify(struct wl_listener *listener, void *data);
@@ -280,6 +282,7 @@ static void destroylocksurface(struct wl_listener *listener, void *data);
static void destroynotify(struct wl_listener *listener, void *data); static void destroynotify(struct wl_listener *listener, void *data);
static void destroypointerconstraint(struct wl_listener *listener, void *data); static void destroypointerconstraint(struct wl_listener *listener, void *data);
static void destroysessionlock(struct wl_listener *listener, void *data); static void destroysessionlock(struct wl_listener *listener, void *data);
static void destroysessionmgr(struct wl_listener *listener, void *data);
static void destroykeyboardgroup(struct wl_listener *listener, void *data); static void destroykeyboardgroup(struct wl_listener *listener, void *data);
static Monitor *dirtomon(enum wlr_direction dir); static Monitor *dirtomon(enum wlr_direction dir);
static void focusclient(Client *c, int lift); static void focusclient(Client *c, int lift);
@@ -323,6 +326,7 @@ static void setcursor(struct wl_listener *listener, void *data);
static void setcursorshape(struct wl_listener *listener, void *data); static void setcursorshape(struct wl_listener *listener, void *data);
static void setfloating(Client *c, int floating); static void setfloating(Client *c, int floating);
static void setfullscreen(Client *c, int fullscreen); static void setfullscreen(Client *c, int fullscreen);
static void setgamma(struct wl_listener *listener, void *data);
static void setlayout(const Arg *arg); static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg); static void setmfact(const Arg *arg);
static void setmon(Client *c, Monitor *m, uint32_t newtags); static void setmon(Client *c, Monitor *m, uint32_t newtags);
@@ -353,6 +357,7 @@ static void xytonode(double x, double y, struct wlr_surface **psurface,
static void zoom(const Arg *arg); static void zoom(const Arg *arg);
/* variables */ /* variables */
static const char broken[] = "broken";
static pid_t child_pid = -1; static pid_t child_pid = -1;
static int locked; static int locked;
static void *exclusive_focus; static void *exclusive_focus;
@@ -378,6 +383,7 @@ static struct wlr_idle_notifier_v1 *idle_notifier;
static struct wlr_idle_inhibit_manager_v1 *idle_inhibit_mgr; static struct wlr_idle_inhibit_manager_v1 *idle_inhibit_mgr;
static struct wlr_layer_shell_v1 *layer_shell; static struct wlr_layer_shell_v1 *layer_shell;
static struct wlr_output_manager_v1 *output_mgr; static struct wlr_output_manager_v1 *output_mgr;
static struct wlr_gamma_control_manager_v1 *gamma_control_mgr;
static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr; static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr;
static struct wlr_virtual_pointer_manager_v1 *virtual_pointer_mgr; static struct wlr_virtual_pointer_manager_v1 *virtual_pointer_mgr;
static struct wlr_cursor_shape_manager_v1 *cursor_shape_mgr; static struct wlr_cursor_shape_manager_v1 *cursor_shape_mgr;
@@ -394,6 +400,7 @@ static struct wlr_scene_rect *root_bg;
static struct wlr_session_lock_manager_v1 *session_lock_mgr; static struct wlr_session_lock_manager_v1 *session_lock_mgr;
static struct wlr_scene_rect *locked_bg; static struct wlr_scene_rect *locked_bg;
static struct wlr_session_lock_v1 *cur_lock; static struct wlr_session_lock_v1 *cur_lock;
static struct wl_listener lock_listener = {.notify = locksession};
static struct wlr_seat *seat; static struct wlr_seat *seat;
static KeyboardGroup *kb_group; static KeyboardGroup *kb_group;
@@ -406,47 +413,17 @@ static struct wlr_box sgeom;
static struct wl_list mons; static struct wl_list mons;
static Monitor *selmon; static Monitor *selmon;
/* global event handlers */
static struct wl_listener cursor_axis = {.notify = axisnotify};
static struct wl_listener cursor_button = {.notify = buttonpress};
static struct wl_listener cursor_frame = {.notify = cursorframe};
static struct wl_listener cursor_motion = {.notify = motionrelative};
static struct wl_listener cursor_motion_absolute = {.notify = motionabsolute};
static struct wl_listener gpu_reset = {.notify = gpureset};
static struct wl_listener layout_change = {.notify = updatemons};
static struct wl_listener new_idle_inhibitor = {.notify = createidleinhibitor};
static struct wl_listener new_input_device = {.notify = inputdevice};
static struct wl_listener new_virtual_keyboard = {.notify = virtualkeyboard};
static struct wl_listener new_virtual_pointer = {.notify = virtualpointer};
static struct wl_listener new_pointer_constraint = {.notify = createpointerconstraint};
static struct wl_listener new_output = {.notify = createmon};
static struct wl_listener new_xdg_toplevel = {.notify = createnotify};
static struct wl_listener new_xdg_popup = {.notify = createpopup};
static struct wl_listener new_xdg_decoration = {.notify = createdecoration};
static struct wl_listener new_layer_surface = {.notify = createlayersurface};
static struct wl_listener output_mgr_apply = {.notify = outputmgrapply};
static struct wl_listener output_mgr_test = {.notify = outputmgrtest};
static struct wl_listener output_power_mgr_set_mode = {.notify = powermgrsetmode};
static struct wl_listener request_activate = {.notify = urgent};
static struct wl_listener request_cursor = {.notify = setcursor};
static struct wl_listener request_set_psel = {.notify = setpsel};
static struct wl_listener request_set_sel = {.notify = setsel};
static struct wl_listener request_set_cursor_shape = {.notify = setcursorshape};
static struct wl_listener request_start_drag = {.notify = requeststartdrag};
static struct wl_listener start_drag = {.notify = startdrag};
static struct wl_listener new_session_lock = {.notify = locksession};
#ifdef XWAYLAND #ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data); static void activatex11(struct wl_listener *listener, void *data);
static void associatex11(struct wl_listener *listener, void *data); static void associatex11(struct wl_listener *listener, void *data);
static void configurex11(struct wl_listener *listener, void *data); static void configurex11(struct wl_listener *listener, void *data);
static void createnotifyx11(struct wl_listener *listener, void *data); static void createnotifyx11(struct wl_listener *listener, void *data);
static void dissociatex11(struct wl_listener *listener, void *data); static void dissociatex11(struct wl_listener *listener, void *data);
static xcb_atom_t getatom(xcb_connection_t *xc, const char *name);
static void sethints(struct wl_listener *listener, void *data); static void sethints(struct wl_listener *listener, void *data);
static void xwaylandready(struct wl_listener *listener, void *data); static void xwaylandready(struct wl_listener *listener, void *data);
static struct wl_listener new_xwayland_surface = {.notify = createnotifyx11};
static struct wl_listener xwayland_ready = {.notify = xwaylandready};
static struct wlr_xwayland *xwayland; static struct wlr_xwayland *xwayland;
static xcb_atom_t netatom[NetLast];
#endif #endif
/* configuration, allows nested code to access above variables */ /* configuration, allows nested code to access above variables */
@@ -483,8 +460,11 @@ applyrules(Client *c)
const Rule *r; const Rule *r;
Monitor *mon = selmon, *m; Monitor *mon = selmon, *m;
appid = client_get_appid(c); c->isfloating = client_is_float_type(c);
title = client_get_title(c); if (!(appid = client_get_appid(c)))
appid = broken;
if (!(title = client_get_title(c)))
title = broken;
for (r = rules; r < END(rules); r++) { for (r = rules; r < END(rules); r++) {
if ((!r->title || strstr(title, r->title)) if ((!r->title || strstr(title, r->title))
@@ -498,8 +478,6 @@ applyrules(Client *c)
} }
} }
} }
c->isfloating |= client_is_float_type(c);
setmon(c, mon, newtags); setmon(c, mon, newtags);
} }
@@ -552,14 +530,13 @@ arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int
wl_list_for_each(l, list, link) { wl_list_for_each(l, list, link) {
struct wlr_layer_surface_v1 *layer_surface = l->layer_surface; struct wlr_layer_surface_v1 *layer_surface = l->layer_surface;
if (!layer_surface->initialized)
continue;
if (exclusive != (layer_surface->current.exclusive_zone > 0)) if (exclusive != (layer_surface->current.exclusive_zone > 0))
continue; continue;
wlr_scene_layer_surface_v1_configure(l->scene_layer, &full_area, usable_area); wlr_scene_layer_surface_v1_configure(l->scene_layer, &full_area, usable_area);
wlr_scene_node_set_position(&l->popups->node, l->scene->node.x, l->scene->node.y); wlr_scene_node_set_position(&l->popups->node, l->scene->node.x, l->scene->node.y);
l->geom.x = l->scene->node.x;
l->geom.y = l->scene->node.y;
} }
} }
@@ -610,8 +587,8 @@ axisnotify(struct wl_listener *listener, void *data)
* for example when you move the scroll wheel. */ * for example when you move the scroll wheel. */
struct wlr_pointer_axis_event *event = data; struct wlr_pointer_axis_event *event = data;
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat); wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
/* TODO: allow usage of scroll wheel for mousebindings, it can be implemented /* TODO: allow usage of scroll whell for mousebindings, it can be implemented
* by checking the event's orientation and the delta of the event */ * checking the event's orientation and the delta of the event */
/* Notify the client with pointer focus of the axis event. */ /* Notify the client with pointer focus of the axis event. */
wlr_seat_pointer_notify_axis(seat, wlr_seat_pointer_notify_axis(seat,
event->time_msec, event->orientation, event->delta, event->time_msec, event->orientation, event->delta,
@@ -653,17 +630,17 @@ buttonpress(struct wl_listener *listener, void *data)
break; break;
case WL_POINTER_BUTTON_STATE_RELEASED: case WL_POINTER_BUTTON_STATE_RELEASED:
/* If you released any buttons, we exit interactive move/resize mode. */ /* If you released any buttons, we exit interactive move/resize mode. */
/* TODO: should reset to the pointer focus's current setcursor */ /* TODO should reset to the pointer focus's current setcursor */
if (!locked && cursor_mode != CurNormal && cursor_mode != CurPressed) { if (!locked && cursor_mode != CurNormal && cursor_mode != CurPressed) {
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default"); wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
cursor_mode = CurNormal; cursor_mode = CurNormal;
/* Drop the window off on its new monitor */ /* Drop the window off on its new monitor */
selmon = xytomon(cursor->x, cursor->y); selmon = xytomon(cursor->x, cursor->y);
setmon(grabc, selmon, 0); setmon(grabc, selmon, 0);
grabc = NULL;
return; return;
} } else {
cursor_mode = CurNormal; cursor_mode = CurNormal;
}
break; break;
} }
/* If the event wasn't handled by the compositor, notify the client with /* If the event wasn't handled by the compositor, notify the client with
@@ -699,7 +676,6 @@ checkidleinhibitor(struct wlr_surface *exclude)
void void
cleanup(void) cleanup(void)
{ {
cleanuplisteners();
#ifdef XWAYLAND #ifdef XWAYLAND
wlr_xwayland_destroy(xwayland); wlr_xwayland_destroy(xwayland);
xwayland = NULL; xwayland = NULL;
@@ -713,8 +689,8 @@ cleanup(void)
destroykeyboardgroup(&kb_group->destroy, NULL); destroykeyboardgroup(&kb_group->destroy, NULL);
/* If it's not destroyed manually, it will cause a use-after-free of wlr_seat. /* If it's not destroyed manually it will cause a use-after-free of wlr_seat.
* Destroy it until it's fixed on the wlroots side */ * Destroy it until it's fixed in the wlroots side */
wlr_backend_destroy(backend); wlr_backend_destroy(backend);
wl_display_destroy(dpy); wl_display_destroy(dpy);
@@ -751,43 +727,6 @@ cleanupmon(struct wl_listener *listener, void *data)
free(m); free(m);
} }
void
cleanuplisteners(void)
{
wl_list_remove(&cursor_axis.link);
wl_list_remove(&cursor_button.link);
wl_list_remove(&cursor_frame.link);
wl_list_remove(&cursor_motion.link);
wl_list_remove(&cursor_motion_absolute.link);
wl_list_remove(&gpu_reset.link);
wl_list_remove(&new_idle_inhibitor.link);
wl_list_remove(&layout_change.link);
wl_list_remove(&new_input_device.link);
wl_list_remove(&new_virtual_keyboard.link);
wl_list_remove(&new_virtual_pointer.link);
wl_list_remove(&new_pointer_constraint.link);
wl_list_remove(&new_output.link);
wl_list_remove(&new_xdg_toplevel.link);
wl_list_remove(&new_xdg_decoration.link);
wl_list_remove(&new_xdg_popup.link);
wl_list_remove(&new_layer_surface.link);
wl_list_remove(&output_mgr_apply.link);
wl_list_remove(&output_mgr_test.link);
wl_list_remove(&output_power_mgr_set_mode.link);
wl_list_remove(&request_activate.link);
wl_list_remove(&request_cursor.link);
wl_list_remove(&request_set_psel.link);
wl_list_remove(&request_set_sel.link);
wl_list_remove(&request_set_cursor_shape.link);
wl_list_remove(&request_start_drag.link);
wl_list_remove(&start_drag.link);
wl_list_remove(&new_session_lock.link);
#ifdef XWAYLAND
wl_list_remove(&new_xwayland_surface.link);
wl_list_remove(&xwayland_ready.link);
#endif
}
void void
closemon(Monitor *m) closemon(Monitor *m)
{ {
@@ -826,7 +765,8 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
struct wlr_layer_surface_v1_state old_state; struct wlr_layer_surface_v1_state old_state;
if (l->layer_surface->initial_commit) { if (l->layer_surface->initial_commit) {
client_set_scale(layer_surface->surface, l->mon->wlr_output->scale); wlr_fractional_scale_v1_notify_scale(layer_surface->surface, l->mon->wlr_output->scale);
wlr_surface_set_preferred_buffer_scale(layer_surface->surface, (int32_t)ceilf(l->mon->wlr_output->scale));
/* Temporarily set the layer's current state to pending /* Temporarily set the layer's current state to pending
* so that we can easily arrange it */ * so that we can easily arrange it */
@@ -861,23 +801,24 @@ commitnotify(struct wl_listener *listener, void *data)
/* /*
* Get the monitor this client will be rendered on * Get the monitor this client will be rendered on
* Note that if the user set a rule in which the client is placed on * Note that if the user set a rule in which the client is placed on
* a different monitor based on its title, this will likely select * a different monitor based on its title this will likely select
* a wrong monitor. * a wrong monitor.
*/ */
applyrules(c); applyrules(c);
if (c->mon) { if (c->mon) {
client_set_scale(client_surface(c), c->mon->wlr_output->scale); wlr_surface_set_preferred_buffer_scale(client_surface(c), (int)ceilf(c->mon->wlr_output->scale));
wlr_fractional_scale_v1_notify_scale(client_surface(c), c->mon->wlr_output->scale);
} }
setmon(c, NULL, 0); /* Make sure to reapply rules in mapnotify() */ setmon(c, NULL, 0); /* Make sure to reapply rules in mapnotify() */
wlr_xdg_toplevel_set_wm_capabilities(c->surface.xdg->toplevel, wlr_xdg_toplevel_set_wm_capabilities(c->surface.xdg->toplevel, WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN);
WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN); wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, 0, 0);
if (c->decoration) if (c->decoration)
requestdecorationmode(&c->set_decoration_mode, c->decoration); requestdecorationmode(&c->set_decoration_mode, c->decoration);
wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, 0, 0);
return; return;
} }
if (client_surface(c)->mapped && c->mon)
resize(c, c->geom, (c->isfloating && !c->isfullscreen)); resize(c, c->geom, (c->isfloating && !c->isfullscreen));
/* mark a pending resize as completed */ /* mark a pending resize as completed */
@@ -903,16 +844,13 @@ commitpopup(struct wl_listener *listener, void *data)
return; return;
popup->base->surface->data = wlr_scene_xdg_surface_create( popup->base->surface->data = wlr_scene_xdg_surface_create(
popup->parent->data, popup->base); popup->parent->data, popup->base);
if ((l && !l->mon) || (c && !c->mon)) { if ((l && !l->mon) || (c && !c->mon))
wlr_xdg_popup_destroy(popup);
return; return;
}
box = type == LayerShell ? l->mon->m : c->mon->w; box = type == LayerShell ? l->mon->m : c->mon->w;
box.x -= (type == LayerShell ? l->scene->node.x : c->geom.x); box.x -= (type == LayerShell ? l->geom.x : c->geom.x);
box.y -= (type == LayerShell ? l->scene->node.y : c->geom.y); box.y -= (type == LayerShell ? l->geom.y : c->geom.y);
wlr_xdg_popup_unconstrain_from_box(popup, &box); wlr_xdg_popup_unconstrain_from_box(popup, &box);
wl_list_remove(&listener->link); wl_list_remove(&listener->link);
free(listener);
} }
void void
@@ -1164,10 +1102,10 @@ createpointer(struct wlr_pointer *pointer)
libinput_device_config_middle_emulation_set_enabled(device, middle_button_emulation); libinput_device_config_middle_emulation_set_enabled(device, middle_button_emulation);
if (libinput_device_config_scroll_get_methods(device) != LIBINPUT_CONFIG_SCROLL_NO_SCROLL) if (libinput_device_config_scroll_get_methods(device) != LIBINPUT_CONFIG_SCROLL_NO_SCROLL)
libinput_device_config_scroll_set_method(device, scroll_method); libinput_device_config_scroll_set_method (device, scroll_method);
if (libinput_device_config_click_get_methods(device) != LIBINPUT_CONFIG_CLICK_METHOD_NONE) if (libinput_device_config_click_get_methods(device) != LIBINPUT_CONFIG_CLICK_METHOD_NONE)
libinput_device_config_click_set_method(device, click_method); libinput_device_config_click_set_method (device, click_method);
if (libinput_device_config_send_events_get_modes(device)) if (libinput_device_config_send_events_get_modes(device))
libinput_device_config_send_events_set_mode(device, send_events_mode); libinput_device_config_send_events_set_mode(device, send_events_mode);
@@ -1215,7 +1153,7 @@ cursorconstrain(struct wlr_pointer_constraint_v1 *constraint)
void void
cursorframe(struct wl_listener *listener, void *data) cursorframe(struct wl_listener *listener, void *data)
{ {
/* This event is forwarded by the cursor when a pointer emits a frame /* This event is forwarded by the cursor when a pointer emits an frame
* event. Frame events are sent after regular pointer events to group * event. Frame events are sent after regular pointer events to group
* multiple events together. For instance, two axis events may happen at the * multiple events together. For instance, two axis events may happen at the
* same time, in which case a frame event won't be sent in between. */ * same time, in which case a frame event won't be sent in between. */
@@ -1252,8 +1190,6 @@ destroydragicon(struct wl_listener *listener, void *data)
/* Focus enter isn't sent during drag, so refocus the focused node. */ /* Focus enter isn't sent during drag, so refocus the focused node. */
focusclient(focustop(selmon), 1); focusclient(focustop(selmon), 1);
motionnotify(0, NULL, 0, 0, 0, 0); motionnotify(0, NULL, 0, 0, 0, 0);
wl_list_remove(&listener->link);
free(listener);
} }
void void
@@ -1262,8 +1198,6 @@ destroyidleinhibitor(struct wl_listener *listener, void *data)
/* `data` is the wlr_surface of the idle inhibitor being destroyed, /* `data` is the wlr_surface of the idle inhibitor being destroyed,
* at this point the idle inhibitor is still in the list of the manager */ * at this point the idle inhibitor is still in the list of the manager */
checkidleinhibitor(wlr_surface_get_root_surface(data)); checkidleinhibitor(wlr_surface_get_root_surface(data));
wl_list_remove(&listener->link);
free(listener);
} }
void void
@@ -1345,7 +1279,6 @@ destroynotify(struct wl_listener *listener, void *data)
wl_list_remove(&c->commit.link); wl_list_remove(&c->commit.link);
wl_list_remove(&c->map.link); wl_list_remove(&c->map.link);
wl_list_remove(&c->unmap.link); wl_list_remove(&c->unmap.link);
wl_list_remove(&c->maximize.link);
} }
free(c); free(c);
} }
@@ -1371,15 +1304,22 @@ destroysessionlock(struct wl_listener *listener, void *data)
destroylock(lock, 0); destroylock(lock, 0);
} }
void
destroysessionmgr(struct wl_listener *listener, void *data)
{
wl_list_remove(&lock_listener.link);
wl_list_remove(&listener->link);
}
void void
destroykeyboardgroup(struct wl_listener *listener, void *data) destroykeyboardgroup(struct wl_listener *listener, void *data)
{ {
KeyboardGroup *group = wl_container_of(listener, group, destroy); KeyboardGroup *group = wl_container_of(listener, group, destroy);
wl_event_source_remove(group->key_repeat_source); wl_event_source_remove(group->key_repeat_source);
wlr_keyboard_group_destroy(group->wlr_group);
wl_list_remove(&group->key.link); wl_list_remove(&group->key.link);
wl_list_remove(&group->modifiers.link); wl_list_remove(&group->modifiers.link);
wl_list_remove(&group->destroy.link); wl_list_remove(&group->destroy.link);
wlr_keyboard_group_destroy(group->wlr_group);
free(group); free(group);
} }
@@ -1429,6 +1369,7 @@ focusclient(Client *c, int lift)
wl_list_insert(&fstack, &c->flink); wl_list_insert(&fstack, &c->flink);
selmon = c->mon; selmon = c->mon;
c->isurgent = 0; c->isurgent = 0;
client_restack_surface(c);
/* Don't change border color if there is an exclusive focus or we are /* Don't change border color if there is an exclusive focus or we are
* handling a drag operation */ * handling a drag operation */
@@ -1511,7 +1452,7 @@ focusstack(const Arg *arg)
focusclient(c, 1); focusclient(c, 1);
} }
/* We probably should change the name of this: it sounds like it /* We probably should change the name of this, it sounds like
* will focus the topmost client of this mon, when actually will * will focus the topmost client of this mon, when actually will
* only return that client */ * only return that client */
Client * Client *
@@ -1544,8 +1485,7 @@ gpureset(struct wl_listener *listener, void *data)
if (!(alloc = wlr_allocator_autocreate(backend, drw))) if (!(alloc = wlr_allocator_autocreate(backend, drw)))
die("couldn't recreate allocator"); die("couldn't recreate allocator");
wl_list_remove(&gpu_reset.link); LISTEN_STATIC(&drw->events.lost, gpureset);
wl_signal_add(&drw->events.lost, &gpu_reset);
wlr_compositor_set_renderer(compositor, drw); wlr_compositor_set_renderer(compositor, drw);
@@ -1560,10 +1500,22 @@ gpureset(struct wl_listener *listener, void *data)
void void
handlesig(int signo) handlesig(int signo)
{ {
if (signo == SIGCHLD) if (signo == SIGCHLD) {
#ifdef XWAYLAND
siginfo_t in;
/* wlroots expects to reap the XWayland process itself, so we
* use WNOWAIT to keep the child waitable until we know it's not
* XWayland.
*/
while (!waitid(P_ALL, 0, &in, WEXITED|WNOHANG|WNOWAIT) && in.si_pid
&& (!xwayland || in.si_pid != xwayland->server->pid))
waitpid(in.si_pid, NULL, 0);
#else
while (waitpid(-1, NULL, WNOHANG) > 0); while (waitpid(-1, NULL, WNOHANG) > 0);
else if (signo == SIGINT || signo == SIGTERM) #endif
} else if (signo == SIGINT || signo == SIGTERM) {
quit(NULL); quit(NULL);
}
} }
void void
@@ -1616,8 +1568,7 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
const Key *k; const Key *k;
for (k = keys; k < END(keys); k++) { for (k = keys; k < END(keys); k++) {
if (CLEANMASK(mods) == CLEANMASK(k->mod) if (CLEANMASK(mods) == CLEANMASK(k->mod)
&& xkb_keysym_to_lower(sym) == xkb_keysym_to_lower(k->keysym) && sym == k->keysym && k->func) {
&& k->func) {
k->func(&k->arg); k->func(&k->arg);
return 1; return 1;
} }
@@ -1745,8 +1696,7 @@ mapnotify(struct wl_listener *listener, void *data)
/* Create scene tree for this client and its border */ /* Create scene tree for this client and its border */
c->scene = client_surface(c)->data = wlr_scene_tree_create(layers[LyrTile]); c->scene = client_surface(c)->data = wlr_scene_tree_create(layers[LyrTile]);
/* Enabled later by a call to arrange() */ wlr_scene_node_set_enabled(&c->scene->node, c->type != XDGShell);
wlr_scene_node_set_enabled(&c->scene->node, client_is_unmanaged(c));
c->scene_surface = c->type == XDGShell c->scene_surface = c->type == XDGShell
? wlr_scene_xdg_surface_create(c->scene, c->surface.xdg) ? wlr_scene_xdg_surface_create(c->scene, c->surface.xdg)
: wlr_scene_subsurface_tree_create(c->scene, client_surface(c)); : wlr_scene_subsurface_tree_create(c->scene, client_surface(c));
@@ -1759,7 +1709,6 @@ mapnotify(struct wl_listener *listener, void *data)
/* Unmanaged clients always are floating */ /* Unmanaged clients always are floating */
wlr_scene_node_reparent(&c->scene->node, layers[LyrFloat]); wlr_scene_node_reparent(&c->scene->node, layers[LyrFloat]);
wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y); wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
client_set_size(c, c->geom.width, c->geom.height);
if (client_wants_focus(c)) { if (client_wants_focus(c)) {
focusclient(c, 1); focusclient(c, 1);
exclusive_focus = c; exclusive_focus = c;
@@ -1784,8 +1733,8 @@ mapnotify(struct wl_listener *listener, void *data)
/* Set initial monitor, tags, floating status, and focus: /* Set initial monitor, tags, floating status, and focus:
* we always consider floating, clients that have parent and thus * we always consider floating, clients that have parent and thus
* we set the same tags and monitor as its parent. * we set the same tags and monitor than its parent, if not
* If there is no parent, apply rules */ * try to apply rules for them */
if ((p = client_get_parent(c))) { if ((p = client_get_parent(c))) {
c->isfloating = 1; c->isfloating = 1;
setmon(c, p->mon, p->tags); setmon(c, p->mon, p->tags);
@@ -1845,7 +1794,8 @@ motionabsolute(struct wl_listener *listener, void *data)
* motion event, from 0..1 on each axis. This happens, for example, when * motion event, from 0..1 on each axis. This happens, for example, when
* wlroots is running under a Wayland window rather than KMS+DRM, and you * wlroots is running under a Wayland window rather than KMS+DRM, and you
* move the mouse over the window. You could enter the window from any edge, * move the mouse over the window. You could enter the window from any edge,
* so we have to warp the mouse there. Also, some hardware emits these events. */ * so we have to warp the mouse there. There is also some hardware which
* emits these events. */
struct wlr_pointer_motion_absolute_event *event = data; struct wlr_pointer_motion_absolute_event *event = data;
double lx, ly, dx, dy; double lx, ly, dx, dy;
@@ -1876,8 +1826,8 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
&& toplevel_from_wlr_surface(seat->pointer_state.focused_surface, &w, &l) >= 0) { && toplevel_from_wlr_surface(seat->pointer_state.focused_surface, &w, &l) >= 0) {
c = w; c = w;
surface = seat->pointer_state.focused_surface; surface = seat->pointer_state.focused_surface;
sx = cursor->x - (l ? l->scene->node.x : w->geom.x); sx = cursor->x - (l ? l->geom.x : w->geom.x);
sy = cursor->y - (l ? l->scene->node.y : w->geom.y); sy = cursor->y - (l ? l->geom.y : w->geom.y);
} }
/* time is 0 in internal calls meant to restore pointer focus. */ /* time is 0 in internal calls meant to restore pointer focus. */
@@ -1967,7 +1917,7 @@ moveresize(const Arg *arg)
case CurMove: case CurMove:
grabcx = (int)round(cursor->x) - grabc->geom.x; grabcx = (int)round(cursor->x) - grabc->geom.x;
grabcy = (int)round(cursor->y) - grabc->geom.y; grabcy = (int)round(cursor->y) - grabc->geom.y;
wlr_cursor_set_xcursor(cursor, cursor_mgr, "all-scroll"); wlr_cursor_set_xcursor(cursor, cursor_mgr, "fleur");
break; break;
case CurResize: case CurResize:
/* Doesn't work for X11 output - the next absolute motion event /* Doesn't work for X11 output - the next absolute motion event
@@ -2030,7 +1980,7 @@ apply_or_test:
ok &= test ? wlr_output_test_state(wlr_output, &state) ok &= test ? wlr_output_test_state(wlr_output, &state)
: wlr_output_commit_state(wlr_output, &state); : wlr_output_commit_state(wlr_output, &state);
/* Don't move monitors if position wouldn't change. This avoids /* Don't move monitors if position wouldn't change, this to avoid
* wlroots marking the output as manually configured. * wlroots marking the output as manually configured.
* wlr_output_layout_add does not like disabled outputs */ * wlr_output_layout_add does not like disabled outputs */
if (!test && wlr_output->enabled && (m->m.x != config_head->state.x || m->m.y != config_head->state.y)) if (!test && wlr_output->enabled && (m->m.x != config_head->state.x || m->m.y != config_head->state.y))
@@ -2091,6 +2041,7 @@ printstatus(void)
Monitor *m = NULL; Monitor *m = NULL;
Client *c; Client *c;
uint32_t occ, urg, sel; uint32_t occ, urg, sel;
const char *appid, *title;
wl_list_for_each(m, &mons, link) { wl_list_for_each(m, &mons, link) {
occ = urg = 0; occ = urg = 0;
@@ -2102,8 +2053,10 @@ printstatus(void)
urg |= c->tags; urg |= c->tags;
} }
if ((c = focustop(m))) { if ((c = focustop(m))) {
printf("%s title %s\n", m->wlr_output->name, client_get_title(c)); title = client_get_title(c);
printf("%s appid %s\n", m->wlr_output->name, client_get_appid(c)); appid = client_get_appid(c);
printf("%s title %s\n", m->wlr_output->name, title ? title : broken);
printf("%s appid %s\n", m->wlr_output->name, appid ? appid : broken);
printf("%s fullscreen %d\n", m->wlr_output->name, c->isfullscreen); printf("%s fullscreen %d\n", m->wlr_output->name, c->isfullscreen);
printf("%s floating %d\n", m->wlr_output->name, c->isfloating); printf("%s floating %d\n", m->wlr_output->name, c->isfloating);
sel = c->tags; sel = c->tags;
@@ -2138,7 +2091,6 @@ powermgrsetmode(struct wl_listener *listener, void *data)
wlr_output_commit_state(m->wlr_output, &state); wlr_output_commit_state(m->wlr_output, &state);
m->asleep = !event->mode; m->asleep = !event->mode;
updatemons(NULL, NULL);
} }
void void
@@ -2155,6 +2107,7 @@ rendermon(struct wl_listener *listener, void *data)
Monitor *m = wl_container_of(listener, m, frame); Monitor *m = wl_container_of(listener, m, frame);
Client *c; Client *c;
struct wlr_output_state pending = {0}; struct wlr_output_state pending = {0};
struct wlr_gamma_control_v1 *gamma_control;
struct timespec now; struct timespec now;
/* Render if no XDG clients have an outstanding resize and are visible on /* Render if no XDG clients have an outstanding resize and are visible on
@@ -2164,7 +2117,32 @@ rendermon(struct wl_listener *listener, void *data)
goto skip; goto skip;
} }
/*
* HACK: The "correct" way to set the gamma is to commit it together with
* the rest of the state in one go, but to do that we would need to rewrite
* wlr_scene_output_commit() in order to add the gamma to the pending
* state before committing, instead try to commit the gamma in one frame,
* and commit the rest of the state in the next one (or in the same frame if
* the gamma can not be committed).
*/
if (m->gamma_lut_changed) {
gamma_control
= wlr_gamma_control_manager_v1_get_control(gamma_control_mgr, m->wlr_output);
m->gamma_lut_changed = 0;
if (!wlr_gamma_control_v1_apply(gamma_control, &pending))
goto commit;
if (!wlr_output_test_state(m->wlr_output, &pending)) {
wlr_gamma_control_v1_send_failed_and_destroy(gamma_control);
goto commit;
}
wlr_output_commit_state(m->wlr_output, &pending);
wlr_output_schedule_frame(m->wlr_output);
} else {
commit:
wlr_scene_output_commit(m->scene_output, NULL); wlr_scene_output_commit(m->scene_output, NULL);
}
skip: skip:
/* Let clients know a frame has been rendered */ /* Let clients know a frame has been rendered */
@@ -2269,10 +2247,8 @@ run(char *startup_cmd)
close(piperw[0]); close(piperw[0]);
} }
/* Mark stdout as non-blocking to avoid the startup script /* Mark stdout as non-blocking to avoid people who does not close stdin
* causing dwl to freeze when a user neither closes stdin * nor consumes it in their startup script getting dwl frozen */
* nor consumes standard input in his startup script */
if (fd_set_nonblock(STDOUT_FILENO) < 0) if (fd_set_nonblock(STDOUT_FILENO) < 0)
close(STDOUT_FILENO); close(STDOUT_FILENO);
@@ -2283,7 +2259,7 @@ run(char *startup_cmd)
selmon = xytomon(cursor->x, cursor->y); selmon = xytomon(cursor->x, cursor->y);
/* TODO hack to get cursor to display in its initial location (100, 100) /* TODO hack to get cursor to display in its initial location (100, 100)
* instead of (0, 0) and then jumping. Still may not be fully * instead of (0, 0) and then jumping. still may not be fully
* initialized, as the image/coordinates are not transformed for the * initialized, as the image/coordinates are not transformed for the
* monitor when displayed here */ * monitor when displayed here */
wlr_cursor_warp_closest(cursor, NULL, cursor->x, cursor->y); wlr_cursor_warp_closest(cursor, NULL, cursor->x, cursor->y);
@@ -2306,7 +2282,7 @@ setcursor(struct wl_listener *listener, void *data)
* event, which will result in the client requesting set the cursor surface */ * event, which will result in the client requesting set the cursor surface */
if (cursor_mode != CurNormal && cursor_mode != CurPressed) if (cursor_mode != CurNormal && cursor_mode != CurPressed)
return; return;
/* This can be sent by any client, so we check to make sure this one /* This can be sent by any client, so we check to make sure this one is
* actually has pointer focus first. If so, we can tell the cursor to * actually has pointer focus first. If so, we can tell the cursor to
* use the provided surface as the cursor image. It will set the * use the provided surface as the cursor image. It will set the
* hardware cursor on the output that it's currently on and continue to * hardware cursor on the output that it's currently on and continue to
@@ -2322,7 +2298,7 @@ setcursorshape(struct wl_listener *listener, void *data)
struct wlr_cursor_shape_manager_v1_request_set_shape_event *event = data; struct wlr_cursor_shape_manager_v1_request_set_shape_event *event = data;
if (cursor_mode != CurNormal && cursor_mode != CurPressed) if (cursor_mode != CurNormal && cursor_mode != CurPressed)
return; return;
/* This can be sent by any client, so we check to make sure this one /* This can be sent by any client, so we check to make sure this one is
* actually has pointer focus first. If so, we can tell the cursor to * actually has pointer focus first. If so, we can tell the cursor to
* use the provided cursor shape. */ * use the provided cursor shape. */
if (event->seat_client == seat->pointer_state.focused_client) if (event->seat_client == seat->pointer_state.focused_client)
@@ -2368,6 +2344,17 @@ setfullscreen(Client *c, int fullscreen)
printstatus(); printstatus();
} }
void
setgamma(struct wl_listener *listener, void *data)
{
struct wlr_gamma_control_manager_v1_set_gamma_event *event = data;
Monitor *m = event->output->data;
if (!m)
return;
m->gamma_lut_changed = 1;
wlr_output_schedule_frame(m->wlr_output);
}
void void
setlayout(const Arg *arg) setlayout(const Arg *arg)
{ {
@@ -2425,7 +2412,7 @@ setpsel(struct wl_listener *listener, void *data)
{ {
/* This event is raised by the seat when a client wants to set the selection, /* This event is raised by the seat when a client wants to set the selection,
* usually when the user copies something. wlroots allows compositors to * usually when the user copies something. wlroots allows compositors to
* ignore such requests if they so choose, but in dwl we always honor them * ignore such requests if they so choose, but in dwl we always honor
*/ */
struct wlr_seat_request_set_primary_selection_event *event = data; struct wlr_seat_request_set_primary_selection_event *event = data;
wlr_seat_set_primary_selection(seat, event->source, event->serial); wlr_seat_set_primary_selection(seat, event->source, event->serial);
@@ -2436,7 +2423,7 @@ setsel(struct wl_listener *listener, void *data)
{ {
/* This event is raised by the seat when a client wants to set the selection, /* This event is raised by the seat when a client wants to set the selection,
* usually when the user copies something. wlroots allows compositors to * usually when the user copies something. wlroots allows compositors to
* ignore such requests if they so choose, but in dwl we always honor them * ignore such requests if they so choose, but in dwl we always honor
*/ */
struct wlr_seat_request_set_selection_event *event = data; struct wlr_seat_request_set_selection_event *event = data;
wlr_seat_set_selection(seat, event->source, event->serial); wlr_seat_set_selection(seat, event->source, event->serial);
@@ -2445,7 +2432,7 @@ setsel(struct wl_listener *listener, void *data)
void void
setup(void) setup(void)
{ {
int drm_fd, i, sig[] = {SIGCHLD, SIGINT, SIGTERM, SIGPIPE}; int i, sig[] = {SIGCHLD, SIGINT, SIGTERM, SIGPIPE};
struct sigaction sa = {.sa_flags = SA_RESTART, .sa_handler = handlesig}; struct sigaction sa = {.sa_flags = SA_RESTART, .sa_handler = handlesig};
sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask);
@@ -2480,12 +2467,12 @@ setup(void)
* supports for shared memory, this configures that for clients. */ * supports for shared memory, this configures that for clients. */
if (!(drw = wlr_renderer_autocreate(backend))) if (!(drw = wlr_renderer_autocreate(backend)))
die("couldn't create renderer"); die("couldn't create renderer");
wl_signal_add(&drw->events.lost, &gpu_reset); LISTEN_STATIC(&drw->events.lost, gpureset);
/* Create shm, drm and linux_dmabuf interfaces by ourselves. /* Create shm, drm and linux_dmabuf interfaces by ourselves.
* The simplest way is to call: * The simplest way is call:
* wlr_renderer_init_wl_display(drw); * wlr_renderer_init_wl_display(drw);
* but we need to create the linux_dmabuf interface manually to integrate it * but we need to create manually the linux_dmabuf interface to integrate it
* with wlr_scene. */ * with wlr_scene. */
wlr_renderer_init_wl_shm(drw, dpy); wlr_renderer_init_wl_shm(drw, dpy);
@@ -2495,10 +2482,6 @@ setup(void)
wlr_linux_dmabuf_v1_create_with_renderer(dpy, 5, drw)); wlr_linux_dmabuf_v1_create_with_renderer(dpy, 5, drw));
} }
if ((drm_fd = wlr_renderer_get_drm_fd(drw)) >= 0 && drw->features.timeline
&& backend->features.timeline)
wlr_linux_drm_syncobj_manager_v1_create(dpy, 1, drm_fd);
/* Autocreates an allocator for us. /* Autocreates an allocator for us.
* The allocator is the bridge between the renderer and the backend. It * The allocator is the bridge between the renderer and the backend. It
* handles the buffer creation, allowing wlroots to render onto the * handles the buffer creation, allowing wlroots to render onto the
@@ -2522,29 +2505,29 @@ setup(void)
wlr_viewporter_create(dpy); wlr_viewporter_create(dpy);
wlr_single_pixel_buffer_manager_v1_create(dpy); wlr_single_pixel_buffer_manager_v1_create(dpy);
wlr_fractional_scale_manager_v1_create(dpy, 1); wlr_fractional_scale_manager_v1_create(dpy, 1);
wlr_presentation_create(dpy, backend, 2); wlr_presentation_create(dpy, backend);
wlr_alpha_modifier_v1_create(dpy); wlr_alpha_modifier_v1_create(dpy);
/* Initializes the interface used to implement urgency hints */ /* Initializes the interface used to implement urgency hints */
activation = wlr_xdg_activation_v1_create(dpy); activation = wlr_xdg_activation_v1_create(dpy);
wl_signal_add(&activation->events.request_activate, &request_activate); LISTEN_STATIC(&activation->events.request_activate, urgent);
wlr_scene_set_gamma_control_manager_v1(scene, wlr_gamma_control_manager_v1_create(dpy)); gamma_control_mgr = wlr_gamma_control_manager_v1_create(dpy);
LISTEN_STATIC(&gamma_control_mgr->events.set_gamma, setgamma);
power_mgr = wlr_output_power_manager_v1_create(dpy); power_mgr = wlr_output_power_manager_v1_create(dpy);
wl_signal_add(&power_mgr->events.set_mode, &output_power_mgr_set_mode); LISTEN_STATIC(&power_mgr->events.set_mode, powermgrsetmode);
/* Creates an output layout, which is a wlroots utility for working with an /* Creates an output layout, which a wlroots utility for working with an
* arrangement of screens in a physical layout. */ * arrangement of screens in a physical layout. */
output_layout = wlr_output_layout_create(dpy); output_layout = wlr_output_layout_create(dpy);
wl_signal_add(&output_layout->events.change, &layout_change); LISTEN_STATIC(&output_layout->events.change, updatemons);
wlr_xdg_output_manager_v1_create(dpy, output_layout); wlr_xdg_output_manager_v1_create(dpy, output_layout);
/* Configure a listener to be notified when new outputs are available on the /* Configure a listener to be notified when new outputs are available on the
* backend. */ * backend. */
wl_list_init(&mons); wl_list_init(&mons);
wl_signal_add(&backend->events.new_output, &new_output); LISTEN_STATIC(&backend->events.new_output, createmon);
/* Set up our client lists, the xdg-shell and the layer-shell. The xdg-shell is a /* Set up our client lists, the xdg-shell and the layer-shell. The xdg-shell is a
* Wayland protocol which is used for application windows. For more * Wayland protocol which is used for application windows. For more
@@ -2556,19 +2539,20 @@ setup(void)
wl_list_init(&fstack); wl_list_init(&fstack);
xdg_shell = wlr_xdg_shell_create(dpy, 6); xdg_shell = wlr_xdg_shell_create(dpy, 6);
wl_signal_add(&xdg_shell->events.new_toplevel, &new_xdg_toplevel); LISTEN_STATIC(&xdg_shell->events.new_toplevel, createnotify);
wl_signal_add(&xdg_shell->events.new_popup, &new_xdg_popup); LISTEN_STATIC(&xdg_shell->events.new_popup, createpopup);
layer_shell = wlr_layer_shell_v1_create(dpy, 3); layer_shell = wlr_layer_shell_v1_create(dpy, 3);
wl_signal_add(&layer_shell->events.new_surface, &new_layer_surface); LISTEN_STATIC(&layer_shell->events.new_surface, createlayersurface);
idle_notifier = wlr_idle_notifier_v1_create(dpy); idle_notifier = wlr_idle_notifier_v1_create(dpy);
idle_inhibit_mgr = wlr_idle_inhibit_v1_create(dpy); idle_inhibit_mgr = wlr_idle_inhibit_v1_create(dpy);
wl_signal_add(&idle_inhibit_mgr->events.new_inhibitor, &new_idle_inhibitor); LISTEN_STATIC(&idle_inhibit_mgr->events.new_inhibitor, createidleinhibitor);
session_lock_mgr = wlr_session_lock_manager_v1_create(dpy); session_lock_mgr = wlr_session_lock_manager_v1_create(dpy);
wl_signal_add(&session_lock_mgr->events.new_lock, &new_session_lock); wl_signal_add(&session_lock_mgr->events.new_lock, &lock_listener);
LISTEN_STATIC(&session_lock_mgr->events.destroy, destroysessionmgr);
locked_bg = wlr_scene_rect_create(layers[LyrBlock], sgeom.width, sgeom.height, locked_bg = wlr_scene_rect_create(layers[LyrBlock], sgeom.width, sgeom.height,
(float [4]){0.1f, 0.1f, 0.1f, 1.0f}); (float [4]){0.1f, 0.1f, 0.1f, 1.0f});
wlr_scene_node_set_enabled(&locked_bg->node, 0); wlr_scene_node_set_enabled(&locked_bg->node, 0);
@@ -2578,10 +2562,10 @@ setup(void)
wlr_server_decoration_manager_create(dpy), wlr_server_decoration_manager_create(dpy),
WLR_SERVER_DECORATION_MANAGER_MODE_SERVER); WLR_SERVER_DECORATION_MANAGER_MODE_SERVER);
xdg_decoration_mgr = wlr_xdg_decoration_manager_v1_create(dpy); xdg_decoration_mgr = wlr_xdg_decoration_manager_v1_create(dpy);
wl_signal_add(&xdg_decoration_mgr->events.new_toplevel_decoration, &new_xdg_decoration); LISTEN_STATIC(&xdg_decoration_mgr->events.new_toplevel_decoration, createdecoration);
pointer_constraints = wlr_pointer_constraints_v1_create(dpy); pointer_constraints = wlr_pointer_constraints_v1_create(dpy);
wl_signal_add(&pointer_constraints->events.new_constraint, &new_pointer_constraint); LISTEN_STATIC(&pointer_constraints->events.new_constraint, createpointerconstraint);
relative_pointer_mgr = wlr_relative_pointer_manager_v1_create(dpy); relative_pointer_mgr = wlr_relative_pointer_manager_v1_create(dpy);
@@ -2609,14 +2593,14 @@ setup(void)
* *
* And more comments are sprinkled throughout the notify functions above. * And more comments are sprinkled throughout the notify functions above.
*/ */
wl_signal_add(&cursor->events.motion, &cursor_motion); LISTEN_STATIC(&cursor->events.motion, motionrelative);
wl_signal_add(&cursor->events.motion_absolute, &cursor_motion_absolute); LISTEN_STATIC(&cursor->events.motion_absolute, motionabsolute);
wl_signal_add(&cursor->events.button, &cursor_button); LISTEN_STATIC(&cursor->events.button, buttonpress);
wl_signal_add(&cursor->events.axis, &cursor_axis); LISTEN_STATIC(&cursor->events.axis, axisnotify);
wl_signal_add(&cursor->events.frame, &cursor_frame); LISTEN_STATIC(&cursor->events.frame, cursorframe);
cursor_shape_mgr = wlr_cursor_shape_manager_v1_create(dpy, 1); cursor_shape_mgr = wlr_cursor_shape_manager_v1_create(dpy, 1);
wl_signal_add(&cursor_shape_mgr->events.request_set_shape, &request_set_cursor_shape); LISTEN_STATIC(&cursor_shape_mgr->events.request_set_shape, setcursorshape);
/* /*
* Configures a seat, which is a single "seat" at which a user sits and * Configures a seat, which is a single "seat" at which a user sits and
@@ -2624,27 +2608,25 @@ setup(void)
* pointer, touch, and drawing tablet device. We also rig up a listener to * pointer, touch, and drawing tablet device. We also rig up a listener to
* let us know when new input devices are available on the backend. * let us know when new input devices are available on the backend.
*/ */
wl_signal_add(&backend->events.new_input, &new_input_device); LISTEN_STATIC(&backend->events.new_input, inputdevice);
virtual_keyboard_mgr = wlr_virtual_keyboard_manager_v1_create(dpy); virtual_keyboard_mgr = wlr_virtual_keyboard_manager_v1_create(dpy);
wl_signal_add(&virtual_keyboard_mgr->events.new_virtual_keyboard, LISTEN_STATIC(&virtual_keyboard_mgr->events.new_virtual_keyboard, virtualkeyboard);
&new_virtual_keyboard);
virtual_pointer_mgr = wlr_virtual_pointer_manager_v1_create(dpy); virtual_pointer_mgr = wlr_virtual_pointer_manager_v1_create(dpy);
wl_signal_add(&virtual_pointer_mgr->events.new_virtual_pointer, LISTEN_STATIC(&virtual_pointer_mgr->events.new_virtual_pointer, virtualpointer);
&new_virtual_pointer);
seat = wlr_seat_create(dpy, "seat0"); seat = wlr_seat_create(dpy, "seat0");
wl_signal_add(&seat->events.request_set_cursor, &request_cursor); LISTEN_STATIC(&seat->events.request_set_cursor, setcursor);
wl_signal_add(&seat->events.request_set_selection, &request_set_sel); LISTEN_STATIC(&seat->events.request_set_selection, setsel);
wl_signal_add(&seat->events.request_set_primary_selection, &request_set_psel); LISTEN_STATIC(&seat->events.request_set_primary_selection, setpsel);
wl_signal_add(&seat->events.request_start_drag, &request_start_drag); LISTEN_STATIC(&seat->events.request_start_drag, requeststartdrag);
wl_signal_add(&seat->events.start_drag, &start_drag); LISTEN_STATIC(&seat->events.start_drag, startdrag);
kb_group = createkeyboardgroup(); kb_group = createkeyboardgroup();
wl_list_init(&kb_group->destroy.link); wl_list_init(&kb_group->destroy.link);
output_mgr = wlr_output_manager_v1_create(dpy); output_mgr = wlr_output_manager_v1_create(dpy);
wl_signal_add(&output_mgr->events.apply, &output_mgr_apply); LISTEN_STATIC(&output_mgr->events.apply, outputmgrapply);
wl_signal_add(&output_mgr->events.test, &output_mgr_test); LISTEN_STATIC(&output_mgr->events.test, outputmgrtest);
/* Make sure XWayland clients don't connect to the parent X server, /* Make sure XWayland clients don't connect to the parent X server,
* e.g when running in the x11 backend or the wayland backend and the * e.g when running in the x11 backend or the wayland backend and the
@@ -2656,8 +2638,8 @@ setup(void)
* It will be started when the first X client is started. * It will be started when the first X client is started.
*/ */
if ((xwayland = wlr_xwayland_create(dpy, compositor, 1))) { if ((xwayland = wlr_xwayland_create(dpy, compositor, 1))) {
wl_signal_add(&xwayland->events.ready, &xwayland_ready); LISTEN_STATIC(&xwayland->events.ready, xwaylandready);
wl_signal_add(&xwayland->events.new_surface, &new_xwayland_surface); LISTEN_STATIC(&xwayland->events.new_surface, createnotifyx11);
setenv("DISPLAY", xwayland->display_name, 1); setenv("DISPLAY", xwayland->display_name, 1);
} else { } else {
@@ -3100,24 +3082,17 @@ configurex11(struct wl_listener *listener, void *data)
{ {
Client *c = wl_container_of(listener, c, configure); Client *c = wl_container_of(listener, c, configure);
struct wlr_xwayland_surface_configure_event *event = data; struct wlr_xwayland_surface_configure_event *event = data;
if (!client_surface(c) || !client_surface(c)->mapped) { /* TODO: figure out if there is another way to do this */
if (!c->mon) {
wlr_xwayland_surface_configure(c->surface.xwayland, wlr_xwayland_surface_configure(c->surface.xwayland,
event->x, event->y, event->width, event->height); event->x, event->y, event->width, event->height);
return; return;
} }
if (client_is_unmanaged(c)) { if (c->isfloating || client_is_unmanaged(c))
wlr_scene_node_set_position(&c->scene->node, event->x, event->y); resize(c, (struct wlr_box){.x = event->x, .y = event->y,
wlr_xwayland_surface_configure(c->surface.xwayland, .width = event->width + c->bw * 2, .height = event->height + c->bw * 2}, 0);
event->x, event->y, event->width, event->height); else
return;
}
if ((c->isfloating && c != grabc) || !c->mon->lt[c->mon->sellt]->arrange) {
resize(c, (struct wlr_box){.x = event->x - c->bw,
.y = event->y - c->bw, .width = event->width + c->bw * 2,
.height = event->height + c->bw * 2}, 0);
} else {
arrange(c->mon); arrange(c->mon);
}
} }
void void
@@ -3151,6 +3126,19 @@ dissociatex11(struct wl_listener *listener, void *data)
wl_list_remove(&c->unmap.link); wl_list_remove(&c->unmap.link);
} }
xcb_atom_t
getatom(xcb_connection_t *xc, const char *name)
{
xcb_atom_t atom = 0;
xcb_intern_atom_reply_t *reply;
xcb_intern_atom_cookie_t cookie = xcb_intern_atom(xc, 0, strlen(name), name);
if ((reply = xcb_intern_atom_reply(xc, cookie, NULL)))
atom = reply->atom;
free(reply);
return atom;
}
void void
sethints(struct wl_listener *listener, void *data) sethints(struct wl_listener *listener, void *data)
{ {
@@ -3170,6 +3158,19 @@ void
xwaylandready(struct wl_listener *listener, void *data) xwaylandready(struct wl_listener *listener, void *data)
{ {
struct wlr_xcursor *xcursor; struct wlr_xcursor *xcursor;
xcb_connection_t *xc = xcb_connect(xwayland->display_name, NULL);
int err = xcb_connection_has_error(xc);
if (err) {
fprintf(stderr, "xcb_connect to X server failed with code %d\n. Continuing with degraded functionality.\n", err);
return;
}
/* Collect atoms we are interested in. If getatom returns 0, we will
* not detect that window type. */
netatom[NetWMWindowTypeDialog] = getatom(xc, "_NET_WM_WINDOW_TYPE_DIALOG");
netatom[NetWMWindowTypeSplash] = getatom(xc, "_NET_WM_WINDOW_TYPE_SPLASH");
netatom[NetWMWindowTypeToolbar] = getatom(xc, "_NET_WM_WINDOW_TYPE_TOOLBAR");
netatom[NetWMWindowTypeUtility] = getatom(xc, "_NET_WM_WINDOW_TYPE_UTILITY");
/* assign the one and only seat */ /* assign the one and only seat */
wlr_xwayland_set_seat(xwayland, seat); wlr_xwayland_set_seat(xwayland, seat);
@@ -3180,6 +3181,8 @@ xwaylandready(struct wl_listener *listener, void *data)
xcursor->images[0]->buffer, xcursor->images[0]->width * 4, xcursor->images[0]->buffer, xcursor->images[0]->width * 4,
xcursor->images[0]->width, xcursor->images[0]->height, xcursor->images[0]->width, xcursor->images[0]->height,
xcursor->images[0]->hotspot_x, xcursor->images[0]->hotspot_y); xcursor->images[0]->hotspot_x, xcursor->images[0]->hotspot_y);
xcb_disconnect(xc);
} }
#endif #endif