workspace_get: Remove useless argument
Also reworks the structure a bit
This commit is contained in:
@ -122,52 +122,45 @@ bool output_triggers_assignment(Output *output, struct Workspace_Assignment *ass
|
||||
* memory and initializing the data structures correctly).
|
||||
*
|
||||
*/
|
||||
Con *workspace_get(const char *num, bool *created) {
|
||||
Con *workspace_get(const char *num) {
|
||||
Con *workspace = get_existing_workspace_by_name(num);
|
||||
|
||||
if (workspace == NULL) {
|
||||
LOG("Creating new workspace \"%s\"\n", num);
|
||||
|
||||
/* We set workspace->num to the number if this workspace’s name begins
|
||||
* with a positive number. Otherwise it’s a named ws and num will be
|
||||
* -1. */
|
||||
long parsed_num = ws_name_to_number(num);
|
||||
|
||||
Con *output = get_assigned_output(num, parsed_num);
|
||||
/* if an assignment is not found, we create this workspace on the current output */
|
||||
if (!output) {
|
||||
output = con_get_output(focused);
|
||||
}
|
||||
|
||||
Con *content = output_get_content(output);
|
||||
LOG("got output %p with content %p\n", output, content);
|
||||
/* We need to attach this container after setting its type. con_attach
|
||||
* will handle CT_WORKSPACEs differently */
|
||||
workspace = con_new(NULL, NULL);
|
||||
char *name;
|
||||
sasprintf(&name, "[i3 con] workspace %s", num);
|
||||
x_set_name(workspace, name);
|
||||
free(name);
|
||||
workspace->type = CT_WORKSPACE;
|
||||
FREE(workspace->name);
|
||||
workspace->name = sstrdup(num);
|
||||
workspace->workspace_layout = config.default_layout;
|
||||
workspace->num = parsed_num;
|
||||
LOG("num = %d\n", workspace->num);
|
||||
|
||||
workspace->parent = content;
|
||||
_workspace_apply_default_orientation(workspace);
|
||||
|
||||
con_attach(workspace, content, false);
|
||||
|
||||
ipc_send_workspace_event("init", workspace, NULL);
|
||||
ewmh_update_desktop_properties();
|
||||
if (created != NULL)
|
||||
*created = true;
|
||||
} else if (created != NULL) {
|
||||
*created = false;
|
||||
if (workspace) {
|
||||
return workspace;
|
||||
}
|
||||
|
||||
LOG("Creating new workspace \"%s\"\n", num);
|
||||
|
||||
/* We set workspace->num to the number if this workspace’s name begins with
|
||||
* a positive number. Otherwise it’s a named ws and num will be 1. */
|
||||
const long parsed_num = ws_name_to_number(num);
|
||||
|
||||
Con *output = get_assigned_output(num, parsed_num);
|
||||
/* if an assignment is not found, we create this workspace on the current output */
|
||||
if (!output) {
|
||||
output = con_get_output(focused);
|
||||
}
|
||||
|
||||
/* No parent because we need to attach this container after setting its
|
||||
* type. con_attach will handle CT_WORKSPACEs differently. */
|
||||
workspace = con_new(NULL, NULL);
|
||||
|
||||
char *name;
|
||||
sasprintf(&name, "[i3 con] workspace %s", num);
|
||||
x_set_name(workspace, name);
|
||||
free(name);
|
||||
|
||||
FREE(workspace->name);
|
||||
workspace->name = sstrdup(num);
|
||||
workspace->workspace_layout = config.default_layout;
|
||||
workspace->num = parsed_num;
|
||||
workspace->type = CT_WORKSPACE;
|
||||
|
||||
con_attach(workspace, output_get_content(output), false);
|
||||
_workspace_apply_default_orientation(workspace);
|
||||
|
||||
ipc_send_workspace_event("init", workspace, NULL);
|
||||
ewmh_update_desktop_properties();
|
||||
|
||||
return workspace;
|
||||
}
|
||||
|
||||
@ -552,9 +545,7 @@ void workspace_show(Con *workspace) {
|
||||
*
|
||||
*/
|
||||
void workspace_show_by_name(const char *num) {
|
||||
Con *workspace;
|
||||
workspace = workspace_get(num, NULL);
|
||||
workspace_show(workspace);
|
||||
workspace_show(workspace_get(num));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -821,10 +812,7 @@ Con *workspace_back_and_forth_get(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Con *workspace;
|
||||
workspace = workspace_get(previous_workspace_name, NULL);
|
||||
|
||||
return workspace;
|
||||
return workspace_get(previous_workspace_name);
|
||||
}
|
||||
|
||||
static bool get_urgency_flag(Con *con) {
|
||||
@ -1011,7 +999,7 @@ void workspace_move_to_output(Con *ws, Output *output) {
|
||||
|
||||
/* so create the workspace referenced to by this assignment */
|
||||
DLOG("Creating workspace from assignment %s.\n", assignment->name);
|
||||
workspace_get(assignment->name, NULL);
|
||||
workspace_get(assignment->name);
|
||||
used_assignment = true;
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user