Merge remote-tracking branch 'upstream/main' into wlroots-next

This commit is contained in:
Leonardo Hernández Hernández 2023-10-09 11:45:51 -06:00
commit b299e01e44
Failed to generate hash of commit
5 changed files with 44 additions and 16 deletions

View file

@ -43,7 +43,7 @@ clean:
dist: clean dist: clean
mkdir -p dwl-$(VERSION) mkdir -p dwl-$(VERSION)
cp -R LICENSE* Makefile README.md client.h config.def.h\ cp -R LICENSE* Makefile README.md client.h config.def.h\
config.mk protocols dwl.1 dwl.c util.c util.h\ config.mk protocols dwl.1 dwl.c util.c util.h dwl.desktop\
dwl-$(VERSION) dwl-$(VERSION)
tar -caf dwl-$(VERSION).tar.gz dwl-$(VERSION) tar -caf dwl-$(VERSION).tar.gz dwl-$(VERSION)
rm -rf dwl-$(VERSION) rm -rf dwl-$(VERSION)

View file

@ -311,6 +311,14 @@ client_send_close(Client *c)
wlr_xdg_toplevel_send_close(c->surface.xdg->toplevel); 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 static inline void
client_set_fullscreen(Client *c, int fullscreen) client_set_fullscreen(Client *c, int fullscreen)
{ {

View file

@ -1,15 +1,23 @@
/* 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 */ /* appearance */
static const int sloppyfocus = 1; /* focus follows mouse */ 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 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 unsigned int borderpx = 1; /* border pixel of windows */
static const float bordercolor[] = {0.5, 0.5, 0.5, 1.0}; static const float bordercolor[] = COLOR(0x444444ff);
static const float focuscolor[] = {1.0, 0.0, 0.0, 1.0}; static const float focuscolor[] = COLOR(0x005577ff);
static const float urgentcolor[] = COLOR(0xff0000ff);
/* To conform the xdg-protocol, set the alpha to zero to restore the old behavior */ /* 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 float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0}; /* 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)
static const int tagcount = TAGCOUNT;
/* logging */
static int log_level = WLR_ERROR;
static const Rule rules[] = { static const Rule rules[] = {
/* app_id title tags mask isfloating monitor */ /* app_id title tags mask isfloating monitor */

7
dwl.1
View file

@ -7,6 +7,7 @@
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl v .Op Fl v
.Op Fl d
.Op Fl s Ar startup command .Op Fl s Ar startup command
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm .Nm
@ -22,6 +23,12 @@ option,
writes its name and version to standard error and exits unsuccessfully. writes its name and version to standard error and exits unsuccessfully.
.Pp .Pp
When given the When given the
.Fl d
option,
.Nm
enables full wlroots logging, including debug information.
.Pp
When given the
.Fl s .Fl s
option, option,
.Nm .Nm

25
dwl.c
View file

@ -69,7 +69,7 @@
#define VISIBLEON(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags])) #define VISIBLEON(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]))
#define LENGTH(X) (sizeof X / sizeof X[0]) #define LENGTH(X) (sizeof X / sizeof X[0])
#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 { static struct wl_listener _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)
@ -1186,7 +1186,7 @@ void
focusclient(Client *c, int lift) focusclient(Client *c, int lift)
{ {
struct wlr_surface *old = seat->keyboard_state.focused_surface; struct wlr_surface *old = seat->keyboard_state.focused_surface;
int i, unused_lx, unused_ly, old_client_type; int unused_lx, unused_ly, old_client_type;
Client *old_c = NULL; Client *old_c = NULL;
LayerSurface *old_l = NULL; LayerSurface *old_l = NULL;
@ -1217,8 +1217,7 @@ focusclient(Client *c, int lift)
/* 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 */
if (!exclusive_focus && !seat->drag) if (!exclusive_focus && !seat->drag)
for (i = 0; i < 4; i++) client_set_border_color(c, focuscolor);
wlr_scene_rect_set_color(c->border[i], focuscolor);
} }
/* Deactivate old client if focus is changing */ /* Deactivate old client if focus is changing */
@ -1235,8 +1234,7 @@ focusclient(Client *c, int lift)
/* Don't deactivate old client if the new one wants focus, as this causes issues with winecfg /* Don't deactivate old client if the new one wants focus, as this causes issues with winecfg
* and probably other clients */ * and probably other clients */
} else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) { } else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) {
for (i = 0; i < 4; i++) client_set_border_color(old_c, bordercolor);
wlr_scene_rect_set_color(old_c->border[i], bordercolor);
client_activate_surface(old, 0); client_activate_surface(old, 0);
} }
@ -2028,7 +2026,8 @@ setfloating(Client *c, int floating)
c->isfloating = floating; c->isfloating = floating;
if (!c->mon) if (!c->mon)
return; return;
wlr_scene_node_reparent(&c->scene->node, layers[c->isfloating ? LyrFloat : LyrTile]); wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen
? LyrFS : c->isfloating ? LyrFloat : LyrTile]);
arrange(c->mon); arrange(c->mon);
printstatus(); printstatus();
} }
@ -2041,7 +2040,7 @@ setfullscreen(Client *c, int fullscreen)
return; return;
c->bw = fullscreen ? 0 : borderpx; c->bw = fullscreen ? 0 : borderpx;
client_set_fullscreen(c, fullscreen); client_set_fullscreen(c, fullscreen);
wlr_scene_node_reparent(&c->scene->node, layers[fullscreen wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen
? LyrFS : c->isfloating ? LyrFloat : LyrTile]); ? LyrFS : c->isfloating ? LyrFloat : LyrTile]);
if (fullscreen) { if (fullscreen) {
@ -2161,6 +2160,8 @@ setup(void)
for (i = 0; i < LENGTH(sig); i++) for (i = 0; i < LENGTH(sig); i++)
sigaction(sig[i], &sa, NULL); sigaction(sig[i], &sa, NULL);
wlr_log_init(log_level, NULL);
/* The Wayland display is managed by libwayland. It handles accepting /* The Wayland display is managed by libwayland. It handles accepting
* clients from the Unix socket, manging Wayland globals, and so on. */ * clients from the Unix socket, manging Wayland globals, and so on. */
dpy = wl_display_create(); dpy = wl_display_create();
@ -2627,6 +2628,7 @@ urgent(struct wl_listener *listener, void *data)
if (!c || c == focustop(selmon)) if (!c || c == focustop(selmon))
return; return;
client_set_border_color(c, urgentcolor);
c->isurgent = 1; c->isurgent = 1;
printstatus(); printstatus();
} }
@ -2808,6 +2810,7 @@ sethints(struct wl_listener *listener, void *data)
if (c == focustop(selmon)) if (c == focustop(selmon))
return; return;
client_set_border_color(c, urgentcolor);
c->isurgent = xcb_icccm_wm_hints_get_urgency(c->surface.xwayland->hints); c->isurgent = xcb_icccm_wm_hints_get_urgency(c->surface.xwayland->hints);
printstatus(); printstatus();
} }
@ -2850,9 +2853,11 @@ main(int argc, char *argv[])
char *startup_cmd = NULL; char *startup_cmd = NULL;
int c; int c;
while ((c = getopt(argc, argv, "s:hv")) != -1) { while ((c = getopt(argc, argv, "s:hdv")) != -1) {
if (c == 's') if (c == 's')
startup_cmd = optarg; startup_cmd = optarg;
else if (c == 'd')
log_level = WLR_DEBUG;
else if (c == 'v') else if (c == 'v')
die("dwl " VERSION); die("dwl " VERSION);
else else
@ -2870,5 +2875,5 @@ main(int argc, char *argv[])
return EXIT_SUCCESS; return EXIT_SUCCESS;
usage: usage:
die("Usage: %s [-v] [-s startup command]", argv[0]); die("Usage: %s [-v] [-d] [-s startup command]", argv[0]);
} }