Skip to content

Commit

Permalink
feat: update dwl to v0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Frewacom committed Aug 5, 2021
2 parents 9fc015a + 3a72cd9 commit 3c1870e
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Bug report
about: Something in dwl isn't working correctly
title: ''
labels: 'Type: bug'
labels: 'A: bug'
assignees: ''

---
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/enhancement-idea.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Enhancement idea
about: Suggest a feature or improvement
title: ''
labels: 'Type: enhancement'
labels: 'A: enhancement'
assignees: ''

---
Expand Down
90 changes: 50 additions & 40 deletions dwl.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ struct Monitor {
unsigned int tagset[2];
double mfact;
int nmaster;
Client *fullscreenclient;
};

typedef struct {
Expand Down Expand Up @@ -247,7 +246,6 @@ static void keypressmod(struct wl_listener *listener, void *data);
static void killclient(const Arg *arg);
static void maplayersurfacenotify(struct wl_listener *listener, void *data);
static void mapnotify(struct wl_listener *listener, void *data);
static void maximizeclient(Client *c);
static void monocle(Monitor *m);
static void motionabsolute(struct wl_listener *listener, void *data);
static void motionnotify(uint32_t time);
Expand All @@ -258,6 +256,7 @@ static void outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int
static void outputmgrtest(struct wl_listener *listener, void *data);
static void pointerfocus(Client *c, struct wlr_surface *surface,
double sx, double sy, uint32_t time);
static void printstatus(void);
static void quit(const Arg *arg);
static void render(struct wlr_surface *surface, int sx, int sy, void *data);
static void renderclients(Monitor *m, struct timespec *now);
Expand Down Expand Up @@ -485,8 +484,6 @@ arrange(Monitor *m)
{
if (m->lt[m->sellt]->arrange)
dscm_safe_call(DSCM_CALL_ARRANGE, m->lt[m->sellt]->arrange, m);
else if (m->fullscreenclient)
maximizeclient(m->fullscreenclient);
/* TODO recheck pointer focus here... or in resize()? */
}

Expand Down Expand Up @@ -887,9 +884,6 @@ createnotify(struct wl_listener *listener, void *data)

if (xdg_surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL)
return;
wl_list_for_each(c, &clients, link)
if (c->isfullscreen && VISIBLEON(c, c->mon))
setfullscreen(c, 0);

/* Allocate a Client for this surface */
c = xdg_surface->data = calloc(1, sizeof(*c));
Expand Down Expand Up @@ -1044,14 +1038,8 @@ void
togglefullscreen(const Arg *arg)
{
Client *sel = selclient();
setfullscreen(sel, !sel->isfullscreen);
}

void
maximizeclient(Client *c)
{
resize(c, c->mon->m.x, c->mon->m.y, c->mon->m.width, c->mon->m.height, 0);
/* used for fullscreen clients */
if (sel)
setfullscreen(sel, !sel->isfullscreen);
}

void
Expand All @@ -1066,13 +1054,11 @@ setfullscreen(Client *c, int fullscreen)
c->prevy = c->geom.y;
c->prevheight = c->geom.height;
c->prevwidth = c->geom.width;
c->mon->fullscreenclient = c;
maximizeclient(c);
resize(c, c->mon->m.x, c->mon->m.y, c->mon->m.width, c->mon->m.height, 0);
} else {
/* restore previous size instead of arrange for floating windows since
* client positions are set by the user and cannot be recalculated */
resize(c, c->prevx, c->prevy, c->prevwidth, c->prevheight, 0);
c->mon->fullscreenclient = NULL;
arrange(c->mon);
}
}
Expand Down Expand Up @@ -1119,6 +1105,7 @@ focusclient(Client *c, int lift)
wl_list_insert(&fstack, &c->flink);
selmon = c->mon;
}
printstatus();

/* Deactivate old client if focus is changing */
if (old && (!c || client_surface(c) != old)) {
Expand Down Expand Up @@ -1282,7 +1269,7 @@ keypress(struct wl_listener *listener, void *data)
wlr_idle_notify_activity(idle, seat);

/* On _press_, attempt to process a compositor keybinding. */
if (event->state == WLR_KEY_PRESSED)
if (event->state == WL_KEYBOARD_KEY_STATE_PRESSED)
handled = keybinding(mods, keycode) || handled;

if (!handled) {
Expand Down Expand Up @@ -1332,7 +1319,7 @@ void
mapnotify(struct wl_listener *listener, void *data)
{
/* Called when the surface is mapped, or ready to display on-screen. */
Client *c = wl_container_of(listener, c, map), *oldfocus = selclient();
Client *c = wl_container_of(listener, c, map);

if (client_is_unmanaged(c)) {
/* Insert this independent into independents lists. */
Expand All @@ -1351,14 +1338,6 @@ mapnotify(struct wl_listener *listener, void *data)

/* Set initial monitor, tags, floating status, and focus */
applyrules(c);

if (c->mon->fullscreenclient && c->mon->fullscreenclient == oldfocus
&& !c->isfloating && c->mon->lt[c->mon->sellt]->arrange) {
maximizeclient(c->mon->fullscreenclient);
focusclient(c->mon->fullscreenclient, 1);
/* give the focus back the fullscreen client on that monitor if exists,
* is focused and the new client isn't floating */
}
}

void
Expand All @@ -1367,12 +1346,9 @@ monocle(Monitor *m)
Client *c;

wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || c->isfloating)
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
continue;
if (c->isfullscreen)
maximizeclient(c);
else
resize(c, m->w.x, m->w.y, m->w.width, m->w.height, 0);
resize(c, m->w.x, m->w.y, m->w.width, m->w.height, 0);
}
}

Expand Down Expand Up @@ -1475,8 +1451,7 @@ motionrelative(struct wl_listener *listener, void *data)
void
moveresize(const Arg *arg)
{
grabc = xytoclient(cursor->x, cursor->y);
if (!grabc)
if (cursor_mode != CurNormal || !(grabc = xytoclient(cursor->x, cursor->y)))
return;

/* Float the window and tell motionnotify to grab it */
Expand Down Expand Up @@ -1599,6 +1574,31 @@ pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy,
focusclient(c, 0);
}

void
printstatus(void)
{
Monitor *m = NULL;
Client *c = NULL;
unsigned int activetags;

wl_list_for_each(m, &mons, link) {
activetags=0;
wl_list_for_each(c, &clients, link) {
if (c->mon == m)
activetags |= c->tags;
}
if (focustop(m))
printf("%s title %s\n", m->wlr_output->name, client_get_title(focustop(m)));
else
printf("%s title \n", m->wlr_output->name);

printf("%s selmon %u\n", m->wlr_output->name, m == selmon);
printf("%s tags %u %u\n", m->wlr_output->name, activetags, m->tagset[m->seltags]);
printf("%s layout %s\n", m->wlr_output->name, m->lt[m->sellt]->symbol);
}
fflush(stdout);
}

void
quit(const Arg *arg)
{
Expand Down Expand Up @@ -1841,6 +1841,7 @@ run(char *startup_cmd)
if (startup_pid < 0)
EBARF("startup: fork");
if (startup_pid == 0) {
dup2(STDERR_FILENO, STDOUT_FILENO);
execl("/bin/sh", "/bin/sh", "-c", startup_cmd, NULL);
EBARF("startup: execl");
}
Expand Down Expand Up @@ -1911,6 +1912,7 @@ setlayout(const Arg *arg)
selmon->lt[selmon->sellt] = (Layout *)arg->v;
/* TODO change layout symbol? */
arrange(selmon);
printstatus();
}

/* arg > 1.0 will set mfact absolutely */
Expand Down Expand Up @@ -1992,7 +1994,7 @@ setup(void)
* backend uses the renderer, for example, to fall back to software cursors
* if the backend does not support hardware cursors (some older GPUs
* don't). */
if (!(backend = wlr_backend_autocreate(dpy, NULL)))
if (!(backend = wlr_backend_autocreate(dpy)))
BARF("couldn't create backend");

/* If we don't provide a renderer, autocreate makes a GLES2 renderer for us.
Expand Down Expand Up @@ -2136,6 +2138,11 @@ setup(void)
void
sigchld(int unused)
{
/* We should be able to remove this function in favor of a simple
* signal(SIGCHLD, SIG_IGN);
* but the Xwayland implementation in wlroots currently prevents us from
* setting our own disposition for SIGCHLD.
*/
if (signal(SIGCHLD, sigchld) == SIG_ERR)
EBARF("can't install SIGCHLD handler");
while (0 < waitpid(-1, NULL, WNOHANG))
Expand All @@ -2146,6 +2153,7 @@ void
spawn(const Arg *arg)
{
if (fork() == 0) {
dup2(STDERR_FILENO, STDOUT_FILENO);
setsid();
execvp(((char **)arg->v)[0], (char **)arg->v);
EBARF("dwl: execvp %s failed", ((char **)arg->v)[0]);
Expand All @@ -2161,6 +2169,7 @@ tag(const Arg *arg)
focusclient(focustop(selmon), 1);
arrange(selmon);
}
printstatus();
}

void
Expand Down Expand Up @@ -2190,11 +2199,9 @@ tile(Monitor *m)
mw = m->w.width;
i = my = ty = 0;
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || c->isfloating)
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
continue;
if (c->isfullscreen)
maximizeclient(c);
else if (i < m->nmaster) {
if (i < m->nmaster) {
h = (m->w.height - my) / (MIN(n, m->nmaster) - i);
resize(c, m->w.x, m->w.y + my, mw, h, 0);
my += c->geom.height;
Expand Down Expand Up @@ -2230,6 +2237,7 @@ toggletag(const Arg *arg)
focusclient(focustop(selmon), 1);
arrange(selmon);
}
printstatus();
}

void
Expand All @@ -2242,6 +2250,7 @@ toggleview(const Arg *arg)
focusclient(focustop(selmon), 1);
arrange(selmon);
}
printstatus();
}

void
Expand Down Expand Up @@ -2322,6 +2331,7 @@ view(const Arg *arg)
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
focusclient(focustop(selmon), 1);
arrange(selmon);
printstatus();
}

void
Expand Down
38 changes: 38 additions & 0 deletions guix.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
(use-modules (dwl-guile packages)
(guix gexp)
(guix utils)
(guix packages)
(guix git-download)
(gnu packages wm)
(gnu packages guile))

(define this-directory
(dirname (current-filename)))

(define source
(local-file this-directory
#:recursive? #t
#:select? (git-predicate this-directory)))

(package
(inherit dwl)
(source source)
(name "dwl-guile-devel")
(inputs
`(("guile-3.0" ,guile-3.0)
("wlroots-0.13.0" ,wlroots-0.13.0)))
(arguments
(substitute-keyword-arguments
(package-arguments dwl)
((#:phases phases)
`(modify-phases
,phases
(replace
'install
(lambda*
(#:key inputs outputs #:allow-other-keys)
(let ((bin (string-append (assoc-ref outputs "out") "/bin")))
(install-file "dwl" bin)
(rename-file (string-append bin "/dwl")
(string-append bin "/dwl-guile-devel"))
#t))))))))
2 changes: 0 additions & 2 deletions scripts/guix-install.sh

This file was deleted.

0 comments on commit 3c1870e

Please sign in to comment.