mirror of
				https://codeberg.org/dwl/dwl-patches.git
				synced 2025-10-31 03:54:19 +00:00 
			
		
		
		
	Reintroduce cfacts patch
This commit is contained in:
		
							parent
							
								
									9bbae57be5
								
							
						
					
					
						commit
						8a3709bf3a
					
				
							
								
								
									
										121
									
								
								cfact/cfact.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										121
									
								
								cfact/cfact.patch
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,121 @@ | |||||||
|  | From 1c22458b124148f48808edfbfed13af3f0e7973c Mon Sep 17 00:00:00 2001 | ||||||
|  | From: Palanix <palanixyt@gmail.com> | ||||||
|  | Date: Fri, 24 Nov 2023 21:16:56 +0100 | ||||||
|  | Subject: [PATCH] cweights to allow different size clients in normal layouts | ||||||
|  | 
 | ||||||
|  | ---
 | ||||||
|  |  config.def.h |  3 +++ | ||||||
|  |  dwl.c        | 32 ++++++++++++++++++++++++++++++-- | ||||||
|  |  2 files changed, 33 insertions(+), 2 deletions(-) | ||||||
|  | 
 | ||||||
|  | diff --git a/config.def.h b/config.def.h
 | ||||||
|  | index 9009517..4690567 100644
 | ||||||
|  | --- a/config.def.h
 | ||||||
|  | +++ b/config.def.h
 | ||||||
|  | @@ -128,6 +128,9 @@ static const Key keys[] = {
 | ||||||
|  |  	{ MODKEY,                    XKB_KEY_d,          incnmaster,     {.i = -1} }, | ||||||
|  |  	{ MODKEY,                    XKB_KEY_h,          setmfact,       {.f = -0.05f} }, | ||||||
|  |  	{ MODKEY,                    XKB_KEY_l,          setmfact,       {.f = +0.05f} }, | ||||||
|  | +	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_H,          setcfact,       {.f = +0.25f} },
 | ||||||
|  | +	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_L,          setcfact,       {.f = -0.25f} },
 | ||||||
|  | +	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_K,          setcfact,       {.f = 0f} },
 | ||||||
|  |  	{ MODKEY,                    XKB_KEY_Return,     zoom,           {0} }, | ||||||
|  |  	{ MODKEY,                    XKB_KEY_Tab,        view,           {0} }, | ||||||
|  |  	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C,          killclient,     {0} }, | ||||||
|  | diff --git a/dwl.c b/dwl.c
 | ||||||
|  | index c8283b7..b548a42 100644
 | ||||||
|  | --- a/dwl.c
 | ||||||
|  | +++ b/dwl.c
 | ||||||
|  | @@ -136,6 +136,7 @@ typedef struct {
 | ||||||
|  |  	uint32_t tags; | ||||||
|  |  	int isfloating, isurgent, isfullscreen; | ||||||
|  |  	uint32_t resize; /* configure serial of a pending resize */ | ||||||
|  | +	float cweight;
 | ||||||
|  |  } Client; | ||||||
|  |   | ||||||
|  |  typedef struct { | ||||||
|  | @@ -301,6 +302,7 @@ static void requeststartdrag(struct wl_listener *listener, void *data);
 | ||||||
|  |  static void requestmonstate(struct wl_listener *listener, void *data); | ||||||
|  |  static void resize(Client *c, struct wlr_box geo, int interact); | ||||||
|  |  static void run(char *startup_cmd); | ||||||
|  | +static void setcfact(const Arg *arg);
 | ||||||
|  |  static void setcursor(struct wl_listener *listener, void *data); | ||||||
|  |  static void setcursorshape(struct wl_listener *listener, void *data); | ||||||
|  |  static void setfloating(Client *c, int floating); | ||||||
|  | @@ -956,6 +958,7 @@ createnotify(struct wl_listener *listener, void *data)
 | ||||||
|  |  	c = xdg_surface->data = ecalloc(1, sizeof(*c)); | ||||||
|  |  	c->surface.xdg = xdg_surface; | ||||||
|  |  	c->bw = borderpx; | ||||||
|  | +	c->cweight = 1.0;
 | ||||||
|  |   | ||||||
|  |  	wlr_xdg_toplevel_set_wm_capabilities(xdg_surface->toplevel, | ||||||
|  |  			WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN); | ||||||
|  | @@ -2007,6 +2010,19 @@ run(char *startup_cmd)
 | ||||||
|  |  	wl_display_run(dpy); | ||||||
|  |  } | ||||||
|  |   | ||||||
|  | +void
 | ||||||
|  | +setcfact(const Arg *arg)
 | ||||||
|  | +{
 | ||||||
|  | +	Client *sel = focustop(selmon);
 | ||||||
|  | +
 | ||||||
|  | +	if(!arg || !sel || !selmon->lt[selmon->sellt]->arrange)
 | ||||||
|  | +		return;
 | ||||||
|  | +	sel->cweight = arg->f ? sel->cweight + arg->f : 1.0;
 | ||||||
|  | +	if (sel->cweight < 0)
 | ||||||
|  | +		sel->cweight = 0;
 | ||||||
|  | +	arrange(selmon);
 | ||||||
|  | +}
 | ||||||
|  | +
 | ||||||
|  |  void | ||||||
|  |  setcursor(struct wl_listener *listener, void *data) | ||||||
|  |  { | ||||||
|  | @@ -2464,6 +2480,7 @@ tile(Monitor *m)
 | ||||||
|  |  { | ||||||
|  |  	unsigned int mw, my, ty; | ||||||
|  |  	int i, n = 0; | ||||||
|  | +	float mweight = 0, tweight = 0;
 | ||||||
|  |  	Client *c; | ||||||
|  |   | ||||||
|  |  	wl_list_for_each(c, &clients, link) | ||||||
|  | @@ -2476,17 +2493,27 @@ tile(Monitor *m)
 | ||||||
|  |  		mw = m->nmaster ? ROUND(m->w.width * m->mfact) : 0; | ||||||
|  |  	else | ||||||
|  |  		mw = m->w.width; | ||||||
|  | +	i = 0;
 | ||||||
|  | +	wl_list_for_each(c, &clients, link){
 | ||||||
|  | +		if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
 | ||||||
|  | +			continue;
 | ||||||
|  | +		if (i < m->nmaster)
 | ||||||
|  | +			mweight += c->cweight;
 | ||||||
|  | +		else
 | ||||||
|  | +			tweight += c->cweight;
 | ||||||
|  | +		i++;
 | ||||||
|  | +	}
 | ||||||
|  |  	i = my = ty = 0; | ||||||
|  |  	wl_list_for_each(c, &clients, link) { | ||||||
|  |  		if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen) | ||||||
|  |  			continue; | ||||||
|  |  		if (i < m->nmaster) { | ||||||
|  |  			resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw, | ||||||
|  | -				.height = (m->w.height - my) / (MIN(n, m->nmaster) - i)}, 0);
 | ||||||
|  | +				.height = ((c->cweight / mweight) * m->w.height)}, 0);
 | ||||||
|  |  			my += c->geom.height; | ||||||
|  |  		} else { | ||||||
|  |  			resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y + ty, | ||||||
|  | -				.width = m->w.width - mw, .height = (m->w.height - ty) / (n - i)}, 0);
 | ||||||
|  | +				.width = m->w.width - mw, .height = ((c->cweight / tweight) * m->w.height) }, 0);
 | ||||||
|  |  			ty += c->geom.height; | ||||||
|  |  		} | ||||||
|  |  		i++; | ||||||
|  | @@ -2868,6 +2895,7 @@ createnotifyx11(struct wl_listener *listener, void *data)
 | ||||||
|  |  	c->surface.xwayland = xsurface; | ||||||
|  |  	c->type = X11; | ||||||
|  |  	c->bw = borderpx; | ||||||
|  | +	c->cweight = 1.0;
 | ||||||
|  |   | ||||||
|  |  	/* Listen to the various events it can emit */ | ||||||
|  |  	LISTEN(&xsurface->events.associate, &c->associate, associatex11); | ||||||
|  | -- 
 | ||||||
|  | 2.43.0 | ||||||
|  | 
 | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Palanix
						Palanix