forked from mirror/dwl
fix various segfaults when selmon is NULL
This commit is contained in:
parent
e46238b95e
commit
c00faae263
1 changed files with 14 additions and 8 deletions
20
dwl.c
20
dwl.c
|
@ -880,7 +880,10 @@ createlayersurface(struct wl_listener *listener, void *data)
|
||||||
struct wlr_layer_surface_v1_state old_state;
|
struct wlr_layer_surface_v1_state old_state;
|
||||||
|
|
||||||
if (!wlr_layer_surface->output)
|
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 = ecalloc(1, sizeof(LayerSurface));
|
||||||
layersurface->type = LayerShell;
|
layersurface->type = LayerShell;
|
||||||
|
@ -1269,6 +1272,8 @@ fullscreennotify(struct wl_listener *listener, void *data)
|
||||||
void
|
void
|
||||||
incnmaster(const Arg *arg)
|
incnmaster(const Arg *arg)
|
||||||
{
|
{
|
||||||
|
if (!arg || !selmon)
|
||||||
|
return;
|
||||||
selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
|
selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
@ -1948,6 +1953,8 @@ setfullscreen(Client *c, int fullscreen)
|
||||||
void
|
void
|
||||||
setlayout(const Arg *arg)
|
setlayout(const Arg *arg)
|
||||||
{
|
{
|
||||||
|
if (!selmon)
|
||||||
|
return;
|
||||||
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
|
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
|
||||||
selmon->sellt ^= 1;
|
selmon->sellt ^= 1;
|
||||||
if (arg && arg->v)
|
if (arg && arg->v)
|
||||||
|
@ -1963,7 +1970,7 @@ setmfact(const Arg *arg)
|
||||||
{
|
{
|
||||||
float f;
|
float f;
|
||||||
|
|
||||||
if (!arg || !selmon->lt[selmon->sellt]->arrange)
|
if (!arg || !selmon || !selmon->lt[selmon->sellt]->arrange)
|
||||||
return;
|
return;
|
||||||
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
|
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
|
||||||
if (f < 0.1 || f > 0.9)
|
if (f < 0.1 || f > 0.9)
|
||||||
|
@ -2250,8 +2257,7 @@ void
|
||||||
tagmon(const Arg *arg)
|
tagmon(const Arg *arg)
|
||||||
{
|
{
|
||||||
Client *sel = selclient();
|
Client *sel = selclient();
|
||||||
if (!sel)
|
if (sel)
|
||||||
return;
|
|
||||||
setmon(sel, dirtomon(arg->i), 0);
|
setmon(sel, dirtomon(arg->i), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2324,7 +2330,7 @@ toggletag(const Arg *arg)
|
||||||
void
|
void
|
||||||
toggleview(const Arg *arg)
|
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) {
|
if (newtagset) {
|
||||||
selmon->tagset[selmon->seltags] = newtagset;
|
selmon->tagset[selmon->seltags] = newtagset;
|
||||||
|
@ -2445,7 +2451,7 @@ urgent(struct wl_listener *listener, void *data)
|
||||||
void
|
void
|
||||||
view(const Arg *arg)
|
view(const Arg *arg)
|
||||||
{
|
{
|
||||||
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
if (selmon && (arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
||||||
return;
|
return;
|
||||||
selmon->seltags ^= 1; /* toggle sel tagset */
|
selmon->seltags ^= 1; /* toggle sel tagset */
|
||||||
if (arg->ui & TAGMASK)
|
if (arg->ui & TAGMASK)
|
||||||
|
@ -2507,7 +2513,7 @@ zoom(const Arg *arg)
|
||||||
{
|
{
|
||||||
Client *c, *sel = selclient();
|
Client *c, *sel = selclient();
|
||||||
|
|
||||||
if (!sel || !selmon->lt[selmon->sellt]->arrange || sel->isfloating)
|
if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange || sel->isfloating)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Search for the first tiled window that is not sel, marking sel as
|
/* Search for the first tiled window that is not sel, marking sel as
|
||||||
|
|
Loading…
Reference in a new issue