From b4e3dfd76b303f654fa8b6007138ad7657146670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Tarl=C3=A1=20Cardoso=20Lemos?= Date: Sun, 13 Mar 2011 20:56:04 -0300 Subject: [PATCH] Add the "created" parameter to workspace_get. If created is not NULL, *created is set to whether or not the workspace has been just created. --- include/workspace.h | 5 ++++- src/cmdparse.y | 2 +- src/manage.c | 2 +- src/workspace.c | 11 ++++++++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/workspace.h b/include/workspace.h index d903ea82..ae43e2f1 100644 --- a/include/workspace.h +++ b/include/workspace.h @@ -22,8 +22,11 @@ * creating the workspace if necessary (by allocating the necessary amount of * memory and initializing the data structures correctly). * + * If created is not NULL, *created will be set to whether or not the + * workspace has just been created. + * */ -Con *workspace_get(const char *num); +Con *workspace_get(const char *num, bool *created); #if 0 /** diff --git a/src/cmdparse.y b/src/cmdparse.y index 0abcab08..f86d51ec 100644 --- a/src/cmdparse.y +++ b/src/cmdparse.y @@ -537,7 +537,7 @@ move: printf("should move window to workspace %s\n", $5); /* get the workspace */ - Con *ws = workspace_get($5); + Con *ws = workspace_get($5, NULL); free($5); /* check if the match is empty, not if the result is empty */ diff --git a/src/manage.c b/src/manage.c index 1465457e..c4d6172b 100644 --- a/src/manage.c +++ b/src/manage.c @@ -458,7 +458,7 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child, } DLOG("Changing container/workspace and unmapping the client\n"); - Workspace *t_ws = workspace_get(assign->workspace-1); + Workspace *t_ws = workspace_get(assign->workspace-1, NULL); workspace_initialize(t_ws, c_ws->output, false); new->container = t_ws->table[t_ws->current_col][t_ws->current_row]; diff --git a/src/workspace.c b/src/workspace.c index fa84e204..4d3c5218 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -17,7 +17,7 @@ * memory and initializing the data structures correctly). * */ -Con *workspace_get(const char *num) { +Con *workspace_get(const char *num, bool *created) { Con *output, *workspace = NULL, *child; /* TODO: could that look like this in the future? @@ -63,6 +63,11 @@ Con *workspace_get(const char *num) { con_attach(workspace, content, false); ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"init\"}"); + if (created != NULL) + *created = true; + } + else if (created != NULL) { + *created = false; } //ewmh_update_workarea(); @@ -201,7 +206,7 @@ static void workspace_reassign_sticky(Con *con) { void workspace_show(const char *num) { Con *workspace, *current, *old = NULL; - workspace = workspace_get(num); + workspace = workspace_get(num, NULL); /* disable fullscreen for the other workspaces and get the workspace we are * currently on. */ @@ -454,7 +459,7 @@ Workspace *get_first_workspace_for_output(Output *output) { int last_ws = 0; TAILQ_FOREACH(ws, workspaces, workspaces) last_ws = ws->num; - result = workspace_get(last_ws + 1); + result = workspace_get(last_ws + 1, NULL); } workspace_initialize(result, output, false);