mirror of
				https://codeberg.org/dwl/dwl.git
				synced 2025-11-04 05:54:14 +00:00 
			
		
		
		
	Function to cycle through available layouts.
This commit is contained in:
		
							parent
							
								
									9433f353b3
								
							
						
					
					
						commit
						58234d4e0b
					
				@ -26,6 +26,7 @@ static const Layout layouts[] = {
 | 
				
			|||||||
	{ "[]=",      tile },
 | 
						{ "[]=",      tile },
 | 
				
			||||||
	{ "><>",      NULL },    /* no layout function means floating behavior */
 | 
						{ "><>",      NULL },    /* no layout function means floating behavior */
 | 
				
			||||||
	{ "[M]",      monocle },
 | 
						{ "[M]",      monocle },
 | 
				
			||||||
 | 
						{ NULL,       NULL },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* monitors
 | 
					/* monitors
 | 
				
			||||||
@ -131,6 +132,8 @@ static const Key keys[] = {
 | 
				
			|||||||
	{ MODKEY,                    XKB_KEY_t,          setlayout,      {.v = &layouts[0]} },
 | 
						{ MODKEY,                    XKB_KEY_t,          setlayout,      {.v = &layouts[0]} },
 | 
				
			||||||
	{ MODKEY,                    XKB_KEY_f,          setlayout,      {.v = &layouts[1]} },
 | 
						{ MODKEY,                    XKB_KEY_f,          setlayout,      {.v = &layouts[1]} },
 | 
				
			||||||
	{ MODKEY,                    XKB_KEY_m,          setlayout,      {.v = &layouts[2]} },
 | 
						{ MODKEY,                    XKB_KEY_m,          setlayout,      {.v = &layouts[2]} },
 | 
				
			||||||
 | 
						{ MODKEY|WLR_MODIFIER_CTRL,  XKB_KEY_comma,      cyclelayout,    {.i = -1 } },
 | 
				
			||||||
 | 
						{ MODKEY|WLR_MODIFIER_CTRL,  XKB_KEY_period,     cyclelayout,    {.i = +1 } },
 | 
				
			||||||
	{ MODKEY,                    XKB_KEY_space,      setlayout,      {0} },
 | 
						{ MODKEY,                    XKB_KEY_space,      setlayout,      {0} },
 | 
				
			||||||
	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space,      togglefloating, {0} },
 | 
						{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space,      togglefloating, {0} },
 | 
				
			||||||
	{ MODKEY,                    XKB_KEY_e,         togglefullscreen, {0} },
 | 
						{ MODKEY,                    XKB_KEY_e,         togglefullscreen, {0} },
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										19
									
								
								dwl.c
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								dwl.c
									
									
									
									
									
								
							@ -256,6 +256,7 @@ static void createpointerconstraint(struct wl_listener *listener, void *data);
 | 
				
			|||||||
static void cursorconstrain(struct wlr_pointer_constraint_v1 *constraint);
 | 
					static void cursorconstrain(struct wlr_pointer_constraint_v1 *constraint);
 | 
				
			||||||
static void cursorframe(struct wl_listener *listener, void *data);
 | 
					static void cursorframe(struct wl_listener *listener, void *data);
 | 
				
			||||||
static void cursorwarptoconstrainthint(void);
 | 
					static void cursorwarptoconstrainthint(void);
 | 
				
			||||||
 | 
					static void cyclelayout(const Arg *arg);
 | 
				
			||||||
static void destroydragicon(struct wl_listener *listener, void *data);
 | 
					static void destroydragicon(struct wl_listener *listener, void *data);
 | 
				
			||||||
static void destroyidleinhibitor(struct wl_listener *listener, void *data);
 | 
					static void destroyidleinhibitor(struct wl_listener *listener, void *data);
 | 
				
			||||||
static void destroylayersurfacenotify(struct wl_listener *listener, void *data);
 | 
					static void destroylayersurfacenotify(struct wl_listener *listener, void *data);
 | 
				
			||||||
@ -1368,6 +1369,24 @@ cursorwarptoconstrainthint(void)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					cyclelayout(const Arg *arg)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						Layout *l;
 | 
				
			||||||
 | 
						for (l = (Layout *)layouts; l != selmon->lt[selmon->sellt]; l++);
 | 
				
			||||||
 | 
						if (arg->i > 0) {
 | 
				
			||||||
 | 
							if (l->symbol && (l + 1)->symbol)
 | 
				
			||||||
 | 
								setlayout(&((Arg) { .v = (l + 1) }));
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
								setlayout(&((Arg) { .v = layouts }));
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							if (l != layouts && (l - 1)->symbol)
 | 
				
			||||||
 | 
								setlayout(&((Arg) { .v = (l - 1) }));
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
								setlayout(&((Arg) { .v = &layouts[LENGTH(layouts) - 2] }));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
destroydragicon(struct wl_listener *listener, void *data)
 | 
					destroydragicon(struct wl_listener *listener, void *data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user