mirror of
				https://codeberg.org/dwl/dwl-patches.git
				synced 2025-10-27 10:14:16 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			78 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			78 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| From ef817db56044ac28a2da5bc8a56381883a5bba7d Mon Sep 17 00:00:00 2001
 | |
| From: Guido Cella <guido@guidocella.xyz>
 | |
| Date: Tue, 16 Jan 2024 18:58:34 +0100
 | |
| Subject: [PATCH] allow switching to the configured tag when a window opens
 | |
| 
 | |
| Add a rule option to switch to the configured tag when a window opens,
 | |
| then switch back when it closes.
 | |
| ---
 | |
|  config.def.h |  6 +++---
 | |
|  dwl.c        | 11 +++++++++++
 | |
|  2 files changed, 14 insertions(+), 3 deletions(-)
 | |
| 
 | |
| diff --git a/config.def.h b/config.def.h
 | |
| index 9009517..055ec93 100644
 | |
| --- a/config.def.h
 | |
| +++ b/config.def.h
 | |
| @@ -21,11 +21,11 @@ static const float fullscreen_bg[]         = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca
 | |
|  static int log_level = WLR_ERROR;
 | |
|  
 | |
|  static const Rule rules[] = {
 | |
| -	/* app_id     title       tags mask     isfloating   monitor */
 | |
| +	/* app_id     title       tags mask     switchtotag   isfloating   monitor */
 | |
|  	/* examples:
 | |
| -	{ "Gimp",     NULL,       0,            1,           -1 },
 | |
| +	{ "Gimp",     NULL,       0,            0,            1,           -1 },
 | |
| +	{ "firefox",  NULL,       1 << 8,       1,            0,           -1 },
 | |
|  	*/
 | |
| -	{ "firefox",  NULL,       1 << 8,       0,           -1 },
 | |
|  };
 | |
|  
 | |
|  /* layout(s) */
 | |
| diff --git a/dwl.c b/dwl.c
 | |
| index d508d79..d05e815 100644
 | |
| --- a/dwl.c
 | |
| +++ b/dwl.c
 | |
| @@ -138,6 +138,7 @@ typedef struct {
 | |
|  	unsigned int bw;
 | |
|  	uint32_t tags;
 | |
|  	int isfloating, isurgent, isfullscreen;
 | |
| +	int switchtotag;
 | |
|  	uint32_t resize; /* configure serial of a pending resize */
 | |
|  } Client;
 | |
|  
 | |
| @@ -226,6 +227,7 @@ typedef struct {
 | |
|  	const char *id;
 | |
|  	const char *title;
 | |
|  	uint32_t tags;
 | |
| +	bool switchtotag;
 | |
|  	int isfloating;
 | |
|  	int monitor;
 | |
|  } Rule;
 | |
| @@ -468,6 +470,11 @@ applyrules(Client *c)
 | |
|  				if (r->monitor == i++)
 | |
|  					mon = m;
 | |
|  			}
 | |
| +			if (r->switchtotag) {
 | |
| +				c->switchtotag = selmon->tagset[selmon->seltags];
 | |
| +				mon->seltags ^= 1;
 | |
| +				mon->tagset[selmon->seltags] = r->tags & TAGMASK;
 | |
| +			}
 | |
|  		}
 | |
|  	}
 | |
|  	setmon(c, mon, newtags);
 | |
| @@ -2691,6 +2698,10 @@ unmapnotify(struct wl_listener *listener, void *data)
 | |
|  	wlr_scene_node_destroy(&c->scene->node);
 | |
|  	printstatus();
 | |
|  	motionnotify(0, NULL, 0, 0, 0, 0);
 | |
| +	if (c->switchtotag) {
 | |
| +		Arg a = { .ui = c->switchtotag };
 | |
| +		view(&a);
 | |
| +	}
 | |
|  }
 | |
|  
 | |
|  void
 | |
| -- 
 | |
| 2.44.0
 | |
| 
 | 
