workspace.c: Make small consistency changes

This commit is contained in:
Orestis Floros 2020-11-11 09:47:25 +01:00
parent 68258785ac
commit 13757ac1ca
No known key found for this signature in database
GPG Key ID: A09DBD7D3222C1C3

View File

@ -134,7 +134,7 @@ Con *workspace_get(const char *num) {
/* We set workspace->num to the number if this workspaces name begins with
* a positive number. Otherwise its a named ws and num will be 1. */
const long parsed_num = ws_name_to_number(num);
const int 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 */
@ -238,7 +238,6 @@ void extract_workspace_names_from_bindings(void) {
*/
Con *create_workspace_on_output(Output *output, Con *content) {
/* add a workspace to this output */
char *name;
bool exists = true;
Con *ws = con_new(NULL, NULL);
ws->type = CT_WORKSPACE;
@ -263,7 +262,7 @@ Con *create_workspace_on_output(Output *output, Con *content) {
/* Set ->num to the number of the workspace, if the name actually
* is a number or starts with a number */
ws->num = num;
LOG("Used number %d for workspace with name %s\n", ws->num, ws->name);
DLOG("Used number %d for workspace with name %s\n", ws->num, ws->name);
break;
}
@ -284,6 +283,7 @@ Con *create_workspace_on_output(Output *output, Con *content) {
}
con_attach(ws, content, false);
char *name;
sasprintf(&name, "[i3 con] workspace %s", ws->name);
x_set_name(ws, name);
free(name);
@ -990,14 +990,14 @@ void workspace_move_to_output(Con *ws, Output *output) {
bool used_assignment = false;
struct Workspace_Assignment *assignment;
TAILQ_FOREACH (assignment, &ws_assignments, ws_assignments) {
bool attached;
int num;
if (!output_triggers_assignment(current_output, assignment)) {
continue;
}
/* check if this workspace's name or num is already attached to the tree */
num = ws_name_to_number(assignment->name);
attached = ((num == -1) ? get_existing_workspace_by_name(assignment->name) : get_existing_workspace_by_num(num)) != NULL;
const int num = ws_name_to_number(assignment->name);
const bool attached = (num == -1)
? get_existing_workspace_by_name(assignment->name)
: get_existing_workspace_by_num(num);
if (attached) {
continue;
}