arieboven / dwm Goto Github PK
View Code? Open in Web Editor NEWMy custom dwm build
License: MIT License
My custom dwm build
License: MIT License
Hi Arie,
I have searched on internet and find this post: https://www.reddit.com/r/suckless/comments/s2ch3f/dwm_how_to_reset_to_tiled_layout_when_all_windows/
diff --git a/dwm.c b/dwm.c
index a96f33c..787cd2a 100644
--- a/dwm.c
+++ b/dwm.c
@@ -189,6 +189,7 @@ static void pop(Client *);
static void propertynotify(XEvent *e);
static void quit(const Arg *arg);
static Monitor *recttomon(int x, int y, int w, int h);
+static void resetlayout(const Arg *arg);
static void resize(Client *c, int x, int y, int w, int h, int interact);
static void resizeclient(Client *c, int x, int y, int w, int h);
static void resizemouse(const Arg *arg);
@@ -1269,6 +1270,16 @@ recttomon(int x, int y, int w, int h)
return r;
}
+void
+resetlayout(const Arg *arg)
+{
+ Arg default_layout = {.v = &layouts[0]};
+ Arg default_mfact = {.f = mfact + 1};
+
+ setlayout(&default_layout);
+ setmfact(&default_mfact);
+}
+
void
resize(Client *c, int x, int y, int w, int h, int interact)
{
@@ -1788,6 +1799,8 @@ unmanage(Client *c, int destroyed)
focus(NULL);
updateclientlist();
arrange(m);
+ if (!(nexttiled(m->clients)))
+ resetlayout(NULL);
}
void
Thanks for your instruction! But I think it seems not a good way. Beacuse It will check all clients in a monitor instead of a specific tag. And this might be dangerous, beacuse we have focus(NULL); updateclientlist(); arrange(m);
in the above of resetlayout()
, the current focus tag might be already changed. Then it calls resetlayout()
, the setlayout()
subfunction (in resetlayout()
) calls arrange()
if the selmon->sel
is not empty. So it might cause potential duplicate arrange()
call.
So I wonder if there has a safe way to achieve the goal? Thanks ! :-)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.