workspace_get: Remove useless argument
Also reworks the structure a bit
This commit is contained in:
parent
9b295fbb57
commit
9d2c855fcd
@ -57,11 +57,8 @@ bool output_triggers_assignment(Output *output, struct Workspace_Assignment *ass
|
||||
* 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, bool *created);
|
||||
Con *workspace_get(const char *num);
|
||||
|
||||
/**
|
||||
* Extracts workspace names from keybindings (e.g. “web” from “bindsym $mod+1
|
||||
|
@ -359,7 +359,7 @@ void cmd_move_con_to_workspace_name(I3_CMD, const char *name, const char *no_aut
|
||||
|
||||
LOG("should move window to workspace %s\n", name);
|
||||
/* get the workspace */
|
||||
Con *ws = workspace_get(name, NULL);
|
||||
Con *ws = workspace_get(name);
|
||||
|
||||
if (no_auto_back_and_forth == NULL) {
|
||||
ws = maybe_auto_back_and_forth_workspace(ws);
|
||||
@ -390,7 +390,7 @@ void cmd_move_con_to_workspace_number(I3_CMD, const char *which, const char *no_
|
||||
|
||||
Con *ws = get_existing_workspace_by_num(parsed_num);
|
||||
if (!ws) {
|
||||
ws = workspace_get(which, NULL);
|
||||
ws = workspace_get(which);
|
||||
}
|
||||
|
||||
if (no_auto_back_and_forth == NULL) {
|
||||
@ -1399,7 +1399,7 @@ void cmd_focus(I3_CMD) {
|
||||
|
||||
CMD_FOCUS_WARN_CHILDREN;
|
||||
|
||||
Con *__i3_scratch = workspace_get("__i3_scratch", NULL);
|
||||
Con *__i3_scratch = workspace_get("__i3_scratch");
|
||||
owindow *current;
|
||||
TAILQ_FOREACH (current, &owindows, owindows) {
|
||||
Con *ws = con_get_workspace(current->con);
|
||||
|
@ -1370,7 +1370,7 @@ bool con_move_to_mark(Con *con, const char *mark) {
|
||||
}
|
||||
|
||||
/* For target containers in the scratchpad, we just send the window to the scratchpad. */
|
||||
if (con_get_workspace(target) == workspace_get("__i3_scratch", NULL)) {
|
||||
if (con_get_workspace(target) == workspace_get("__i3_scratch")) {
|
||||
DLOG("target container is in the scratchpad, moving container to scratchpad.\n");
|
||||
scratchpad_move(con);
|
||||
return true;
|
||||
|
@ -727,7 +727,7 @@ static void handle_client_message(xcb_client_message_event_t *event) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (con_is_internal(ws) && ws != workspace_get("__i3_scratch", NULL)) {
|
||||
if (con_is_internal(ws) && ws != workspace_get("__i3_scratch")) {
|
||||
DLOG("Workspace is internal but not scratchpad, ignoring _NET_ACTIVE_WINDOW\n");
|
||||
return;
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
|
||||
/* A_TO_WORKSPACE type assignment or fallback from A_TO_WORKSPACE_NUMBER
|
||||
* when the target workspace number does not exist yet. */
|
||||
if (!assigned_ws) {
|
||||
assigned_ws = workspace_get(assignment->dest.workspace, NULL);
|
||||
assigned_ws = workspace_get(assignment->dest.workspace);
|
||||
}
|
||||
|
||||
nc = con_descend_tiling_focused(assigned_ws);
|
||||
@ -322,7 +322,7 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
|
||||
} else if (startup_ws) {
|
||||
/* If it was started on a specific workspace, we want to open it there. */
|
||||
DLOG("Using workspace on which this application was started (%s)\n", startup_ws);
|
||||
nc = con_descend_tiling_focused(workspace_get(startup_ws, NULL));
|
||||
nc = con_descend_tiling_focused(workspace_get(startup_ws));
|
||||
DLOG("focused on ws %s: %p / %s\n", startup_ws, nc, nc->name);
|
||||
if (nc->type == CT_WORKSPACE)
|
||||
nc = tree_open_con(nc, cwindow);
|
||||
|
@ -32,7 +32,7 @@ void scratchpad_move(Con *con) {
|
||||
}
|
||||
DLOG("should move con %p to __i3_scratch\n", con);
|
||||
|
||||
Con *__i3_scratch = workspace_get("__i3_scratch", NULL);
|
||||
Con *__i3_scratch = workspace_get("__i3_scratch");
|
||||
if (con_get_workspace(con) == __i3_scratch) {
|
||||
DLOG("This window is already on __i3_scratch.\n");
|
||||
return;
|
||||
@ -84,7 +84,7 @@ void scratchpad_move(Con *con) {
|
||||
*/
|
||||
bool scratchpad_show(Con *con) {
|
||||
DLOG("should show scratchpad window %p\n", con);
|
||||
Con *__i3_scratch = workspace_get("__i3_scratch", NULL);
|
||||
Con *__i3_scratch = workspace_get("__i3_scratch");
|
||||
Con *floating;
|
||||
|
||||
/* If this was 'scratchpad show' without criteria, we check if the
|
||||
@ -245,7 +245,7 @@ static int _lcm(const int m, const int n) {
|
||||
*
|
||||
*/
|
||||
void scratchpad_fix_resolution(void) {
|
||||
Con *__i3_scratch = workspace_get("__i3_scratch", NULL);
|
||||
Con *__i3_scratch = workspace_get("__i3_scratch");
|
||||
Con *__i3_output = con_get_output(__i3_scratch);
|
||||
DLOG("Current resolution: (%d, %d) %d x %d\n",
|
||||
__i3_output->rect.x, __i3_output->rect.y,
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user