~ruther/dwl

c00faae26370682c307cfb107b12123d10d49053 — Leonardo Hernández Hernández 2 years ago e46238b
fix various segfaults when selmon is NULL
1 files changed, 14 insertions(+), 8 deletions(-)

M dwl.c
M dwl.c => dwl.c +14 -8
@@ 880,7 880,10 @@ createlayersurface(struct wl_listener *listener, void *data)
	struct wlr_layer_surface_v1_state old_state;

	if (!wlr_layer_surface->output)
		wlr_layer_surface->output = selmon->wlr_output;
		wlr_layer_surface->output = selmon ? selmon->wlr_output : NULL;

	if (!wlr_layer_surface->output)
		wlr_layer_surface_v1_destroy(wlr_layer_surface);

	layersurface = ecalloc(1, sizeof(LayerSurface));
	layersurface->type = LayerShell;


@@ 1269,6 1272,8 @@ fullscreennotify(struct wl_listener *listener, void *data)
void
incnmaster(const Arg *arg)
{
	if (!arg || !selmon)
		return;
	selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
	arrange(selmon);
}


@@ 1948,6 1953,8 @@ setfullscreen(Client *c, int fullscreen)
void
setlayout(const Arg *arg)
{
	if (!selmon)
		return;
	if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
		selmon->sellt ^= 1;
	if (arg && arg->v)


@@ 1963,7 1970,7 @@ setmfact(const Arg *arg)
{
	float f;

	if (!arg || !selmon->lt[selmon->sellt]->arrange)
	if (!arg || !selmon || !selmon->lt[selmon->sellt]->arrange)
		return;
	f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
	if (f < 0.1 || f > 0.9)


@@ 2250,9 2257,8 @@ void
tagmon(const Arg *arg)
{
	Client *sel = selclient();
	if (!sel)
		return;
	setmon(sel, dirtomon(arg->i), 0);
	if (sel)
		setmon(sel, dirtomon(arg->i), 0);
}

void


@@ 2324,7 2330,7 @@ toggletag(const Arg *arg)
void
toggleview(const Arg *arg)
{
	unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
	unsigned int newtagset = selmon ? selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK) : 0;

	if (newtagset) {
		selmon->tagset[selmon->seltags] = newtagset;


@@ 2445,7 2451,7 @@ urgent(struct wl_listener *listener, void *data)
void
view(const Arg *arg)
{
	if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
	if (selmon && (arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
		return;
	selmon->seltags ^= 1; /* toggle sel tagset */
	if (arg->ui & TAGMASK)


@@ 2507,7 2513,7 @@ zoom(const Arg *arg)
{
	Client *c, *sel = selclient();

	if (!sel || !selmon->lt[selmon->sellt]->arrange || sel->isfloating)
	if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange || sel->isfloating)
		return;

	/* Search for the first tiled window that is not sel, marking sel as

Do not follow this link