struct Con {
bool mapped;
- enum { CT_ROOT = 0, CT_OUTPUT = 1, CT_CON = 2, CT_FLOATING_CON = 3 } type;
+ enum { CT_ROOT = 0, CT_OUTPUT = 1, CT_CON = 2, CT_FLOATING_CON = 3, CT_WORKSPACE = 4 } type;
orientation_t orientation;
struct Con *parent;
/* parent before setting it to floating */
*/
bool con_accepts_window(Con *con) {
/* 1: workspaces never accept direct windows */
- if (con->parent->type == CT_OUTPUT)
+ if (con->type == CT_WORKSPACE)
return false;
/* TODO: if this is a swallowing container, we need to check its max_clients */
*/
Con *con_get_workspace(Con *con) {
Con *result = con;
- while (result != NULL && result->parent->type != CT_OUTPUT)
+ while (result != NULL && result->type != CT_WORKSPACE)
result = result->parent;
assert(result != NULL);
return result;
/* add a workspace to this output */
ws = con_new(oc);
+ ws->type = CT_WORKSPACE;
ws->name = strdup("1");
ws->fullscreen_mode = CF_OUTPUT;
}
void tree_close_con() {
assert(focused != NULL);
- if (focused->parent->type == CT_OUTPUT) {
+ if (focused->type == CT_WORKSPACE) {
LOG("Cannot close workspace\n");
return;
}
*/
void tree_split(Con *con, orientation_t orientation) {
/* for a workspace, we just need to change orientation */
- if (con->parent->type == CT_OUTPUT) {
+ if (con->type == CT_WORKSPACE) {
con->orientation = orientation;
return;
}
void level_up() {
/* We can focus up to the workspace, but not any higher in the tree */
- if (focused->parent->type != CT_CON) {
+ if (focused->parent->type != CT_CON &&
+ focused->parent->type != CT_WORKSPACE) {
printf("cannot go up\n");
return;
}
LOG("need to go one level further up\n");
/* if the current parent is an output, we are at a workspace
* and the orientation still does not match */
- if (parent->parent->type == CT_OUTPUT)
+ if (parent->type == CT_WORKSPACE)
return;
parent = parent->parent;
}
void tree_move(char way, orientation_t orientation) {
/* 1: get the first parent with the same orientation */
Con *parent = focused->parent;
- if (parent->type == CT_OUTPUT)
+ if (focused->type == CT_WORKSPACE)
return;
bool level_changed = false;
while (parent->orientation != orientation) {
LOG("need to go one level further up\n");
/* if the current parent is an output, we are at a workspace
* and the orientation still does not match */
- if (parent->parent->type == CT_OUTPUT)
+ if (parent->type == CT_WORKSPACE)
return;
parent = parent->parent;
level_changed = true;
output = con_get_output(focused);
LOG("got output %p\n", output);
workspace = con_new(output);
+ workspace->type = CT_WORKSPACE;
workspace->name = strdup(num);
ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"init\"}");