From 4206db2839bd98df4f0c13e72efebfd3fde216d9 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 13 Apr 2010 16:43:08 +0200 Subject: [PATCH] workspace.c: update header, reformat --- src/workspace.c | 75 +++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 40 deletions(-) diff --git a/src/workspace.c b/src/workspace.c index 63e079f9..4d7922a8 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -1,11 +1,8 @@ /* - * vim:ts=8:expandtab + * vim:ts=4:sw=4:expandtab * * i3 - an improved dynamic tiling window manager - * - * © 2009-2010 Michael Stapelberg and contributors - * - * See file LICENSE for license information. + * © 2009-2010 Michael Stapelberg and contributors (see also: LICENSE) * * workspace.c: Functions for modifying workspaces * @@ -14,8 +11,6 @@ #include "all.h" -extern Con *focused; - /* * Returns a pointer to the workspace with the given number (starting at 0), * creating the workspace if necessary (by allocating the necessary amount of @@ -23,35 +18,35 @@ extern Con *focused; * */ Con *workspace_get(const char *num) { - Con *output, *workspace = NULL, *current; + Con *output, *workspace = NULL, *current; - /* TODO: could that look like this in the future? - GET_MATCHING_NODE(workspace, croot, strcasecmp(current->name, num) != 0); - */ - TAILQ_FOREACH(output, &(croot->nodes_head), nodes) { - TAILQ_FOREACH(current, &(output->nodes_head), nodes) { - if (strcasecmp(current->name, num) != 0) - continue; + /* TODO: could that look like this in the future? + GET_MATCHING_NODE(workspace, croot, strcasecmp(current->name, num) != 0); + */ + TAILQ_FOREACH(output, &(croot->nodes_head), nodes) { + TAILQ_FOREACH(current, &(output->nodes_head), nodes) { + if (strcasecmp(current->name, num) != 0) + continue; - workspace = current; - break; - } + workspace = current; + break; } + } - LOG("should switch to ws %s\n", num); - if (workspace == NULL) { - LOG("need to create this one\n"); - output = con_get_output(focused); - LOG("got output %p\n", output); - workspace = con_new(output); - workspace->name = strdup(num); + LOG("should switch to ws %s\n", num); + if (workspace == NULL) { + LOG("need to create this one\n"); + output = con_get_output(focused); + LOG("got output %p\n", output); + workspace = con_new(output); + workspace->name = strdup(num); - ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"init\"}"); - } + ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"init\"}"); + } - //ewmh_update_workarea(); + //ewmh_update_workarea(); - return workspace; + return workspace; } #if 0 @@ -101,23 +96,23 @@ bool workspace_is_visible(Workspace *ws) { * */ void workspace_show(const char *num) { - Con *workspace, *current; + Con *workspace, *current; - workspace = workspace_get(num); - workspace->fullscreen_mode = CF_OUTPUT; - /* disable fullscreen */ - TAILQ_FOREACH(current, &(workspace->parent->nodes_head), nodes) - current->fullscreen_mode = CF_NONE; + workspace = workspace_get(num); + workspace->fullscreen_mode = CF_OUTPUT; + /* disable fullscreen */ + TAILQ_FOREACH(current, &(workspace->parent->nodes_head), nodes) + current->fullscreen_mode = CF_NONE; - LOG("switching to %p\n", workspace); - Con *next = workspace; + LOG("switching to %p\n", workspace); + Con *next = workspace; while (!TAILQ_EMPTY(&(next->focus_head))) next = TAILQ_FIRST(&(next->focus_head)); - con_focus(next); - workspace->fullscreen_mode = CF_OUTPUT; - LOG("focused now = %p / %s\n", focused, focused->name); + con_focus(next); + workspace->fullscreen_mode = CF_OUTPUT; + LOG("focused now = %p / %s\n", focused, focused->name); #if 0 /* Check if the workspace has not been used yet */