mirror of
				https://codeberg.org/dwl/dwl.git
				synced 2025-11-03 09:01:45 -05:00 
			
		
		
		
	Merge branch 'main' into wlroots-next
This commit is contained in:
		
						commit
						cd3d0a102f
					
				
					 1 changed files with 59 additions and 39 deletions
				
			
		
							
								
								
									
										94
									
								
								dwl.c
									
										
									
									
									
								
							
							
						
						
									
										94
									
								
								dwl.c
									
										
									
									
									
								
							| 
						 | 
					@ -175,7 +175,6 @@ struct Monitor {
 | 
				
			||||||
	unsigned int tagset[2];
 | 
						unsigned int tagset[2];
 | 
				
			||||||
	double mfact;
 | 
						double mfact;
 | 
				
			||||||
	int nmaster;
 | 
						int nmaster;
 | 
				
			||||||
	Client *fullscreenclient;
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
| 
						 | 
					@ -249,7 +248,6 @@ static void keypressmod(struct wl_listener *listener, void *data);
 | 
				
			||||||
static void killclient(const Arg *arg);
 | 
					static void killclient(const Arg *arg);
 | 
				
			||||||
static void maplayersurfacenotify(struct wl_listener *listener, void *data);
 | 
					static void maplayersurfacenotify(struct wl_listener *listener, void *data);
 | 
				
			||||||
static void mapnotify(struct wl_listener *listener, void *data);
 | 
					static void mapnotify(struct wl_listener *listener, void *data);
 | 
				
			||||||
static void maximizeclient(Client *c);
 | 
					 | 
				
			||||||
static void monocle(Monitor *m);
 | 
					static void monocle(Monitor *m);
 | 
				
			||||||
static void motionabsolute(struct wl_listener *listener, void *data);
 | 
					static void motionabsolute(struct wl_listener *listener, void *data);
 | 
				
			||||||
static void motionnotify(uint32_t time);
 | 
					static void motionnotify(uint32_t time);
 | 
				
			||||||
| 
						 | 
					@ -260,6 +258,7 @@ static void outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int
 | 
				
			||||||
static void outputmgrtest(struct wl_listener *listener, void *data);
 | 
					static void outputmgrtest(struct wl_listener *listener, void *data);
 | 
				
			||||||
static void pointerfocus(Client *c, struct wlr_surface *surface,
 | 
					static void pointerfocus(Client *c, struct wlr_surface *surface,
 | 
				
			||||||
		double sx, double sy, uint32_t time);
 | 
							double sx, double sy, uint32_t time);
 | 
				
			||||||
 | 
					static void printstatus(void);
 | 
				
			||||||
static void quit(const Arg *arg);
 | 
					static void quit(const Arg *arg);
 | 
				
			||||||
static void render(struct wlr_surface *surface, int sx, int sy, void *data);
 | 
					static void render(struct wlr_surface *surface, int sx, int sy, void *data);
 | 
				
			||||||
static void renderclients(Monitor *m, struct timespec *now);
 | 
					static void renderclients(Monitor *m, struct timespec *now);
 | 
				
			||||||
| 
						 | 
					@ -278,6 +277,7 @@ static void setlayout(const Arg *arg);
 | 
				
			||||||
static void setmfact(const Arg *arg);
 | 
					static void setmfact(const Arg *arg);
 | 
				
			||||||
static void setmon(Client *c, Monitor *m, unsigned int newtags);
 | 
					static void setmon(Client *c, Monitor *m, unsigned int newtags);
 | 
				
			||||||
static void setup(void);
 | 
					static void setup(void);
 | 
				
			||||||
 | 
					static void sigchld(int unused);
 | 
				
			||||||
static void spawn(const Arg *arg);
 | 
					static void spawn(const Arg *arg);
 | 
				
			||||||
static void tag(const Arg *arg);
 | 
					static void tag(const Arg *arg);
 | 
				
			||||||
static void tagmon(const Arg *arg);
 | 
					static void tagmon(const Arg *arg);
 | 
				
			||||||
| 
						 | 
					@ -483,8 +483,6 @@ arrange(Monitor *m)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (m->lt[m->sellt]->arrange)
 | 
						if (m->lt[m->sellt]->arrange)
 | 
				
			||||||
		m->lt[m->sellt]->arrange(m);
 | 
							m->lt[m->sellt]->arrange(m);
 | 
				
			||||||
	else if (m->fullscreenclient)
 | 
					 | 
				
			||||||
		maximizeclient(m->fullscreenclient);
 | 
					 | 
				
			||||||
	/* TODO recheck pointer focus here... or in resize()? */
 | 
						/* TODO recheck pointer focus here... or in resize()? */
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -883,9 +881,6 @@ createnotify(struct wl_listener *listener, void *data)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (xdg_surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL)
 | 
						if (xdg_surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	wl_list_for_each(c, &clients, link)
 | 
					 | 
				
			||||||
		if (c->isfullscreen && VISIBLEON(c, c->mon))
 | 
					 | 
				
			||||||
			setfullscreen(c, 0);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Allocate a Client for this surface */
 | 
						/* Allocate a Client for this surface */
 | 
				
			||||||
	c = xdg_surface->data = calloc(1, sizeof(*c));
 | 
						c = xdg_surface->data = calloc(1, sizeof(*c));
 | 
				
			||||||
| 
						 | 
					@ -1040,16 +1035,10 @@ void
 | 
				
			||||||
togglefullscreen(const Arg *arg)
 | 
					togglefullscreen(const Arg *arg)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	Client *sel = selclient();
 | 
						Client *sel = selclient();
 | 
				
			||||||
 | 
						if (sel)
 | 
				
			||||||
		setfullscreen(sel, !sel->isfullscreen);
 | 
							setfullscreen(sel, !sel->isfullscreen);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					 | 
				
			||||||
maximizeclient(Client *c)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	resize(c, c->mon->m.x, c->mon->m.y, c->mon->m.width, c->mon->m.height, 0);
 | 
					 | 
				
			||||||
	/* used for fullscreen clients */
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
setfullscreen(Client *c, int fullscreen)
 | 
					setfullscreen(Client *c, int fullscreen)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -1062,13 +1051,11 @@ setfullscreen(Client *c, int fullscreen)
 | 
				
			||||||
		c->prevy = c->geom.y;
 | 
							c->prevy = c->geom.y;
 | 
				
			||||||
		c->prevheight = c->geom.height;
 | 
							c->prevheight = c->geom.height;
 | 
				
			||||||
		c->prevwidth = c->geom.width;
 | 
							c->prevwidth = c->geom.width;
 | 
				
			||||||
		c->mon->fullscreenclient = c;
 | 
							resize(c, c->mon->m.x, c->mon->m.y, c->mon->m.width, c->mon->m.height, 0);
 | 
				
			||||||
		maximizeclient(c);
 | 
					 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		/* restore previous size instead of arrange for floating windows since
 | 
							/* restore previous size instead of arrange for floating windows since
 | 
				
			||||||
		 * client positions are set by the user and cannot be recalculated */
 | 
							 * client positions are set by the user and cannot be recalculated */
 | 
				
			||||||
		resize(c, c->prevx, c->prevy, c->prevwidth, c->prevheight, 0);
 | 
							resize(c, c->prevx, c->prevy, c->prevwidth, c->prevheight, 0);
 | 
				
			||||||
		c->mon->fullscreenclient = NULL;
 | 
					 | 
				
			||||||
		arrange(c->mon);
 | 
							arrange(c->mon);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1115,6 +1102,7 @@ focusclient(Client *c, int lift)
 | 
				
			||||||
		wl_list_insert(&fstack, &c->flink);
 | 
							wl_list_insert(&fstack, &c->flink);
 | 
				
			||||||
		selmon = c->mon;
 | 
							selmon = c->mon;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						printstatus();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Deactivate old client if focus is changing */
 | 
						/* Deactivate old client if focus is changing */
 | 
				
			||||||
	if (old && (!c || client_surface(c) != old)) {
 | 
						if (old && (!c || client_surface(c) != old)) {
 | 
				
			||||||
| 
						 | 
					@ -1334,7 +1322,7 @@ void
 | 
				
			||||||
mapnotify(struct wl_listener *listener, void *data)
 | 
					mapnotify(struct wl_listener *listener, void *data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	/* Called when the surface is mapped, or ready to display on-screen. */
 | 
						/* Called when the surface is mapped, or ready to display on-screen. */
 | 
				
			||||||
	Client *c = wl_container_of(listener, c, map), *oldfocus = selclient();
 | 
						Client *c = wl_container_of(listener, c, map);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (client_is_unmanaged(c)) {
 | 
						if (client_is_unmanaged(c)) {
 | 
				
			||||||
		/* Insert this independent into independents lists. */
 | 
							/* Insert this independent into independents lists. */
 | 
				
			||||||
| 
						 | 
					@ -1353,14 +1341,6 @@ mapnotify(struct wl_listener *listener, void *data)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Set initial monitor, tags, floating status, and focus */
 | 
						/* Set initial monitor, tags, floating status, and focus */
 | 
				
			||||||
	applyrules(c);
 | 
						applyrules(c);
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (c->mon->fullscreenclient && c->mon->fullscreenclient == oldfocus
 | 
					 | 
				
			||||||
			&& !c->isfloating && c->mon->lt[c->mon->sellt]->arrange) {
 | 
					 | 
				
			||||||
		maximizeclient(c->mon->fullscreenclient);
 | 
					 | 
				
			||||||
		focusclient(c->mon->fullscreenclient, 1);
 | 
					 | 
				
			||||||
		/* give the focus back the fullscreen client on that monitor if exists,
 | 
					 | 
				
			||||||
		 * is focused and the new client isn't floating */
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
| 
						 | 
					@ -1369,11 +1349,8 @@ monocle(Monitor *m)
 | 
				
			||||||
	Client *c;
 | 
						Client *c;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wl_list_for_each(c, &clients, link) {
 | 
						wl_list_for_each(c, &clients, link) {
 | 
				
			||||||
		if (!VISIBLEON(c, m) || c->isfloating)
 | 
							if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
		if (c->isfullscreen)
 | 
					 | 
				
			||||||
			maximizeclient(c);
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
		resize(c, m->w.x, m->w.y, m->w.width, m->w.height, 0);
 | 
							resize(c, m->w.x, m->w.y, m->w.width, m->w.height, 0);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1601,6 +1578,31 @@ pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy,
 | 
				
			||||||
		focusclient(c, 0);
 | 
							focusclient(c, 0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					printstatus(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						Monitor *m = NULL;
 | 
				
			||||||
 | 
						Client *c = NULL;
 | 
				
			||||||
 | 
						unsigned int activetags;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						wl_list_for_each(m, &mons, link) {
 | 
				
			||||||
 | 
							activetags=0;
 | 
				
			||||||
 | 
							wl_list_for_each(c, &clients, link) {
 | 
				
			||||||
 | 
								if (c->mon == m)
 | 
				
			||||||
 | 
									activetags |= c->tags;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (focustop(m))
 | 
				
			||||||
 | 
								printf("%s title %s\n", m->wlr_output->name, client_get_title(focustop(m)));
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
								printf("%s title \n", m->wlr_output->name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							printf("%s selmon %u\n", m->wlr_output->name, m == selmon);
 | 
				
			||||||
 | 
							printf("%s tags %u %u\n", m->wlr_output->name, activetags, m->tagset[m->seltags]);
 | 
				
			||||||
 | 
							printf("%s layout %s\n", m->wlr_output->name, m->lt[m->sellt]->symbol);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						fflush(stdout);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
quit(const Arg *arg)
 | 
					quit(const Arg *arg)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -1843,6 +1845,7 @@ run(char *startup_cmd)
 | 
				
			||||||
		if (startup_pid < 0)
 | 
							if (startup_pid < 0)
 | 
				
			||||||
			EBARF("startup: fork");
 | 
								EBARF("startup: fork");
 | 
				
			||||||
		if (startup_pid == 0) {
 | 
							if (startup_pid == 0) {
 | 
				
			||||||
 | 
								dup2(STDERR_FILENO, STDOUT_FILENO);
 | 
				
			||||||
			execl("/bin/sh", "/bin/sh", "-c", startup_cmd, NULL);
 | 
								execl("/bin/sh", "/bin/sh", "-c", startup_cmd, NULL);
 | 
				
			||||||
			EBARF("startup: execl");
 | 
								EBARF("startup: execl");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -1913,6 +1916,7 @@ setlayout(const Arg *arg)
 | 
				
			||||||
		selmon->lt[selmon->sellt] = (Layout *)arg->v;
 | 
							selmon->lt[selmon->sellt] = (Layout *)arg->v;
 | 
				
			||||||
	/* TODO change layout symbol? */
 | 
						/* TODO change layout symbol? */
 | 
				
			||||||
	arrange(selmon);
 | 
						arrange(selmon);
 | 
				
			||||||
 | 
						printstatus();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* arg > 1.0 will set mfact absolutely */
 | 
					/* arg > 1.0 will set mfact absolutely */
 | 
				
			||||||
| 
						 | 
					@ -1983,9 +1987,8 @@ setup(void)
 | 
				
			||||||
	 * clients from the Unix socket, manging Wayland globals, and so on. */
 | 
						 * clients from the Unix socket, manging Wayland globals, and so on. */
 | 
				
			||||||
	dpy = wl_display_create();
 | 
						dpy = wl_display_create();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Indicate explicitly to the OS that we are not interested in info
 | 
						/* clean up child processes immediately */
 | 
				
			||||||
	 * about child processes (per POSIX.1-2001) */
 | 
						sigchld(0);
 | 
				
			||||||
	signal(SIGCHLD, SIG_IGN);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* The backend is a wlroots feature which abstracts the underlying input and
 | 
						/* The backend is a wlroots feature which abstracts the underlying input and
 | 
				
			||||||
	 * output hardware. The autocreate option will choose the most suitable
 | 
						 * output hardware. The autocreate option will choose the most suitable
 | 
				
			||||||
| 
						 | 
					@ -2136,10 +2139,25 @@ setup(void)
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					sigchld(int unused)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						/* We should be able to remove this function in favor of a simple
 | 
				
			||||||
 | 
						 *     signal(SIGCHLD, SIG_IGN);
 | 
				
			||||||
 | 
						 * but the Xwayland implementation in wlroots currently prevents us from
 | 
				
			||||||
 | 
						 * setting our own disposition for SIGCHLD.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						if (signal(SIGCHLD, sigchld) == SIG_ERR)
 | 
				
			||||||
 | 
							EBARF("can't install SIGCHLD handler");
 | 
				
			||||||
 | 
						while (0 < waitpid(-1, NULL, WNOHANG))
 | 
				
			||||||
 | 
							;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
spawn(const Arg *arg)
 | 
					spawn(const Arg *arg)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (fork() == 0) {
 | 
						if (fork() == 0) {
 | 
				
			||||||
 | 
							dup2(STDERR_FILENO, STDOUT_FILENO);
 | 
				
			||||||
		setsid();
 | 
							setsid();
 | 
				
			||||||
		execvp(((char **)arg->v)[0], (char **)arg->v);
 | 
							execvp(((char **)arg->v)[0], (char **)arg->v);
 | 
				
			||||||
		EBARF("dwl: execvp %s failed", ((char **)arg->v)[0]);
 | 
							EBARF("dwl: execvp %s failed", ((char **)arg->v)[0]);
 | 
				
			||||||
| 
						 | 
					@ -2155,6 +2173,7 @@ tag(const Arg *arg)
 | 
				
			||||||
		focusclient(focustop(selmon), 1);
 | 
							focusclient(focustop(selmon), 1);
 | 
				
			||||||
		arrange(selmon);
 | 
							arrange(selmon);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						printstatus();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
| 
						 | 
					@ -2184,11 +2203,9 @@ tile(Monitor *m)
 | 
				
			||||||
		mw = m->w.width;
 | 
							mw = m->w.width;
 | 
				
			||||||
	i = my = ty = 0;
 | 
						i = my = ty = 0;
 | 
				
			||||||
	wl_list_for_each(c, &clients, link) {
 | 
						wl_list_for_each(c, &clients, link) {
 | 
				
			||||||
		if (!VISIBLEON(c, m) || c->isfloating)
 | 
							if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
		if (c->isfullscreen)
 | 
							if (i < m->nmaster) {
 | 
				
			||||||
			maximizeclient(c);
 | 
					 | 
				
			||||||
		else if (i < m->nmaster) {
 | 
					 | 
				
			||||||
			h = (m->w.height - my) / (MIN(n, m->nmaster) - i);
 | 
								h = (m->w.height - my) / (MIN(n, m->nmaster) - i);
 | 
				
			||||||
			resize(c, m->w.x, m->w.y + my, mw, h, 0);
 | 
								resize(c, m->w.x, m->w.y + my, mw, h, 0);
 | 
				
			||||||
			my += c->geom.height;
 | 
								my += c->geom.height;
 | 
				
			||||||
| 
						 | 
					@ -2224,6 +2241,7 @@ toggletag(const Arg *arg)
 | 
				
			||||||
		focusclient(focustop(selmon), 1);
 | 
							focusclient(focustop(selmon), 1);
 | 
				
			||||||
		arrange(selmon);
 | 
							arrange(selmon);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						printstatus();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
| 
						 | 
					@ -2236,6 +2254,7 @@ toggleview(const Arg *arg)
 | 
				
			||||||
		focusclient(focustop(selmon), 1);
 | 
							focusclient(focustop(selmon), 1);
 | 
				
			||||||
		arrange(selmon);
 | 
							arrange(selmon);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						printstatus();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
| 
						 | 
					@ -2316,6 +2335,7 @@ view(const Arg *arg)
 | 
				
			||||||
		selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
 | 
							selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
 | 
				
			||||||
	focusclient(focustop(selmon), 1);
 | 
						focusclient(focustop(selmon), 1);
 | 
				
			||||||
	arrange(selmon);
 | 
						arrange(selmon);
 | 
				
			||||||
 | 
						printstatus();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue