sync wochap patches with latest dwl

This commit is contained in:
wochap
2024-07-09 10:56:43 -05:00
parent 14928cda03
commit ff57f0b2e7
4 changed files with 96 additions and 110 deletions
+16 -40
View File
@@ -1,36 +1,18 @@
From d224594e8f077ac49a1369670f6ff6a5d27ec75a Mon Sep 17 00:00:00 2001
From 285470897406b653e77d732a77356aaf9a70b799 Mon Sep 17 00:00:00 2001
From: wochap <gean.marroquin@gmail.com>
Date: Tue, 5 Mar 2024 23:50:01 -0500
Subject: [PATCH] implement swap and focus direction functions
Date: Fri, 5 Jul 2024 12:37:39 -0500
Subject: [PATCH] implement swapandfocusdir
you should expect the same behavior as in river wm,
swap only works on tiling windows
focus works on tiling and floating windows
---
Makefile | 2 +-
config.def.h | 8 +++
dwl.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 172 insertions(+), 1 deletion(-)
dwl.c | 164 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 172 insertions(+)
diff --git a/Makefile b/Makefile
index 6cde460..22f4372 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@ DWLDEVCFLAGS = -g -pedantic -Wall -Wextra -Wdeclaration-after-statement -Wno-unu
# CFLAGS / LDFLAGS
PKGS = wlroots wayland-server xkbcommon libinput $(XLIBS)
DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
-LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(LIBS)
+LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` -lm $(LIBS)
all: dwl
dwl: dwl.o util.o
diff --git a/config.def.h b/config.def.h
index db0babc..b584f3e 100644
index 22d2171..724e15e 100644
--- a/config.def.h
+++ b/config.def.h
@@ -122,6 +122,14 @@ static const Key keys[] = {
@@ -129,6 +129,14 @@ static const Key keys[] = {
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
@@ -44,20 +26,12 @@ index db0babc..b584f3e 100644
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Down, swapdir, {.ui = 3} },
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05} },
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },
diff --git a/dwl.c b/dwl.c
index ef27a1d..8d3540e 100644
index dc0437e..844c1f5 100644
--- a/dwl.c
+++ b/dwl.c
@@ -4,6 +4,7 @@
#include <getopt.h>
#include <libinput.h>
#include <linux/input-event-codes.h>
+#include <math.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
@@ -226,6 +227,11 @@ typedef struct {
@@ -241,6 +241,11 @@ typedef struct {
struct wl_listener destroy;
} SessionLock;
@@ -69,7 +43,7 @@ index ef27a1d..8d3540e 100644
/* function declarations */
static void applybounds(Client *c, struct wlr_box *bbox);
static void applyrules(Client *c);
@@ -264,6 +270,8 @@ static Monitor *dirtomon(enum wlr_direction dir);
@@ -285,6 +290,8 @@ static Monitor *dirtomon(enum wlr_direction dir);
static void focusclient(Client *c, int lift);
static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg);
@@ -78,7 +52,7 @@ index ef27a1d..8d3540e 100644
static Client *focustop(Monitor *m);
static void fullscreennotify(struct wl_listener *listener, void *data);
static void handlesig(int signo);
@@ -1282,6 +1290,161 @@ focusstack(const Arg *arg)
@@ -1425,6 +1432,163 @@ focusstack(const Arg *arg)
focusclient(c, 1);
}
@@ -126,7 +100,7 @@ index ef27a1d..8d3540e 100644
+client_in_direction(const char *direction, const int *skipfloat)
+{
+ Client *cfocused = focustop(selmon);
+ Vector cfocusedposition = position_of_box(&cfocused->geom);
+ Vector cfocusedposition;
+ Client *ctarget = NULL;
+ double targetdistance = INFINITY;
+ Client *c;
@@ -134,6 +108,8 @@ index ef27a1d..8d3540e 100644
+ if (!cfocused || cfocused->isfullscreen || (skipfloat && cfocused->isfloating))
+ return NULL;
+
+ cfocusedposition = position_of_box(&cfocused->geom);
+
+ wl_list_for_each(c, &clients, link) {
+ Vector cposition;
+ Vector positiondiff;
@@ -241,5 +217,5 @@ index ef27a1d..8d3540e 100644
* will focus the topmost client of this mon, when actually will
* only return that client */
--
2.42.0
2.45.1