...
 
Commits (2)
......@@ -70,7 +70,6 @@ static void setws(struct monitor *, int, int);
static void sigchld(int);
static size_t unifyscreens(XineramaScreenInfo **, size_t);
static void unmapnotify(XEvent *);
static void updateclient(struct client *);
static void updategeom(void);
static void updatetransient(struct client *);
static void updatewsm(void);
......@@ -583,7 +582,6 @@ maprequest(XEvent *e)
workspace_attach_client(ws, c);
monitor_restack(seat->selmon);
monitor_arrange(seat->selmon);
updateclient(c); /* TODO: move away */
updatetransient(c); /* TODO: move away */
}
......@@ -745,7 +743,11 @@ propertynotify(XEvent *e)
client_query_name(c);
}
if (ev->atom == x11.netatom[NetWMWindowType]) {
updateclient(c);
client_query_window_type(c);
if (c->dialog) {
debug("\033[32mwindow %lu is a dialog!\033[0m", c->win);
setfloating(c, true);
}
}
}
......@@ -1033,13 +1035,6 @@ sendfollowclient(union arg arg)
void
setfloating(struct client *c, bool floating)
{
if (c->ws == state->scratchpad)
return;
if (c->floating == floating)
/* nothing to do */
return;
workspace_set_floating(c->ws, c, floating);
if (c->ws->mon) {
......@@ -1560,6 +1555,11 @@ togglefloat(union arg arg)
struct client *c;
(void) arg;
if (seat->selmon->scratchpad) {
debug("Scratchpad active, not toggling floating state");
return;
}
c = seat->selmon->selws->selcli;
if (!c) {
warn("No client focused for toggling floating");
......@@ -1700,23 +1700,6 @@ unmapnotify(XEvent *e)
client_destroy(c);
}
/* TODO: split this up */
void
updateclient(struct client *c)
{
client_query_window_state(c);
if (c->fullscreen) {
debug("\033[32mwindow %lu has fullscreen state\033[0m", c->win);
setfullscreen(c, true);
}
client_query_window_type(c);
if (c->dialog) {
debug("\033[32mwindow %lu is a dialog!\033[0m", c->win);
setfloating(c, true);
}
}
void
updategeom(void)
{
......
......@@ -28,6 +28,7 @@ state_create(void)
s->workspaces = list_create();
s->wsmap = NULL;
s->scratchpad = workspace_create(0, 0);
s->scratchpad->nofloat = true;
return s;
}
......
......@@ -5,6 +5,7 @@
#include "log.h"
#include "utils.h"
#include "wsmbox.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
......@@ -14,6 +15,11 @@ workspace_attach_client(struct workspace *ws, struct client *c)
int unsigned i, pos;
struct list *list;
if (ws->nofloat && c->floating) {
debug("Attaching floating client to non-floating window; tiling");
c->floating = false;
}
list = c->floating ? ws->floating : ws->tiled;
/* insert after focused client */
......@@ -56,6 +62,7 @@ workspace_create(int x, int y)
workspace_rename(ws, NULL);
ws->wsmbox = NULL;
ws->focused = false;
ws->nofloat = false;
return ws;
}
......@@ -83,12 +90,13 @@ workspace_detach_client(struct workspace *ws, struct client *c)
return;
}
if (ws->nofloat)
assert(!c->floating);
clients = c->floating ? ws->floating : ws->tiled;
otherclients = c->floating ? ws->tiled : ws->floating;
if (!list_contains(clients, c, NULL))
die("Client %lu (%s) is not attached to this workspace",
c->win, c->name);
assert(list_contains(clients, c, NULL));
/* focus next client */
i = list_find_index(clients, c, NULL);
......@@ -106,10 +114,10 @@ workspace_detach_client(struct workspace *ws, struct client *c)
void
workspace_focus(struct workspace *ws, bool focus)
{
assert(!focus || ws->mon);
if (ws->focused == focus)
return;
if (focus && !ws->mon)
die("Attempt to focus invisible workspace");
ws->focused = focus;
......@@ -147,8 +155,8 @@ workspace_isempty(struct workspace *ws)
void
workspace_raise_floating(struct workspace *ws, struct client *c)
{
if (!c->floating)
die("Attempt to raise non-floating client");
assert(c->floating);
assert(!ws->nofloat);
list_push(ws->floating, c);
}
......@@ -175,6 +183,11 @@ workspace_set_floating(struct workspace *ws, struct client *c, bool floating)
if (c->floating == floating)
return;
if (ws->nofloat) {
assert(!c->floating);
return;
}
src = c->floating ? ws->floating : ws->tiled;
dst = c->floating ? ws->tiled : ws->floating;
......
......@@ -14,6 +14,7 @@ struct workspace {
struct layout *layout;
struct state *state;
bool focused;
bool nofloat;
};
#include "client.h"
......