Replace duplicate "__" workspace prefix checks with a single function.
This commit is contained in:
parent
2a7359e449
commit
a080794e59
|
@ -66,6 +66,12 @@ Con *con_parent_with_orientation(Con *con, orientation_t orientation);
|
|||
*/
|
||||
Con *con_get_fullscreen_con(Con *con, int fullscreen_mode);
|
||||
|
||||
/**
|
||||
* Returns true if the container is internal, such as __i3_scratch
|
||||
*
|
||||
*/
|
||||
bool con_is_internal(Con *con);
|
||||
|
||||
/**
|
||||
* Returns true if the node is floating.
|
||||
*
|
||||
|
|
13
src/con.c
13
src/con.c
|
@ -359,6 +359,14 @@ Con *con_get_fullscreen_con(Con *con, int fullscreen_mode) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the container is internal, such as __i3_scratch
|
||||
*
|
||||
*/
|
||||
bool con_is_internal(Con *con) {
|
||||
return (con->name[0] == '_' && con->name[1] == '_');
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns true if the node is floating.
|
||||
*
|
||||
|
@ -692,7 +700,7 @@ void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool
|
|||
* calling tree_render(), so for the "real" focus this is a no-op).
|
||||
* We don’t focus the con for i3 pseudo workspaces like __i3_scratch and
|
||||
* we don’t focus when there is a fullscreen con on that workspace. */
|
||||
if ((workspace->name[0] != '_' || workspace->name[1] != '_') &&
|
||||
if (!con_is_internal(workspace) &&
|
||||
con_get_fullscreen_con(workspace, CF_OUTPUT) == NULL)
|
||||
con_focus(con_descend_focused(con));
|
||||
|
||||
|
@ -701,8 +709,7 @@ void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool
|
|||
* don’t want to focus invisible workspaces */
|
||||
if (source_output != dest_output &&
|
||||
workspace_is_visible(workspace) &&
|
||||
workspace->name[0] != '_' &&
|
||||
workspace->name[1] != '_') {
|
||||
!con_is_internal(workspace)) {
|
||||
DLOG("Moved to a different output, focusing target\n");
|
||||
} else {
|
||||
/* Descend focus stack in case focus_next is a workspace which can
|
||||
|
|
|
@ -405,7 +405,7 @@ IPC_HANDLER(get_workspaces) {
|
|||
|
||||
Con *output;
|
||||
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
|
||||
if (output->name[0] == '_' && output->name[1] == '_')
|
||||
if (con_is_internal(output))
|
||||
continue;
|
||||
Con *ws;
|
||||
TAILQ_FOREACH(ws, &(output_get_content(output)->nodes_head), nodes) {
|
||||
|
|
|
@ -225,7 +225,7 @@ void render_con(Con *con, bool render_fullscreen) {
|
|||
|
||||
if (con->layout == L_OUTPUT) {
|
||||
/* Skip i3-internal outputs */
|
||||
if (con->name[0] == '_' && con->name[1] == '_')
|
||||
if (con_is_internal(con))
|
||||
return;
|
||||
render_l_output(con);
|
||||
} else if (con->type == CT_ROOT) {
|
||||
|
@ -240,7 +240,7 @@ void render_con(Con *con, bool render_fullscreen) {
|
|||
* windows/containers so that they overlap on another output. */
|
||||
DLOG("Rendering floating windows:\n");
|
||||
TAILQ_FOREACH(output, &(con->nodes_head), nodes) {
|
||||
if (output->name[0] == '_' && output->name[1] == '_')
|
||||
if (con_is_internal(output))
|
||||
continue;
|
||||
/* Get the active workspace of that output */
|
||||
Con *content = output_get_content(output);
|
||||
|
|
|
@ -333,7 +333,7 @@ static void _workspace_show(Con *workspace) {
|
|||
Con *current, *old = NULL;
|
||||
|
||||
/* safe-guard against showing i3-internal workspaces like __i3_scratch */
|
||||
if (workspace->name[0] == '_' && workspace->name[1] == '_')
|
||||
if (con_is_internal(workspace))
|
||||
return;
|
||||
|
||||
/* disable fullscreen for the other workspaces and get the workspace we are
|
||||
|
@ -462,7 +462,7 @@ Con* workspace_next(void) {
|
|||
/* If currently a numbered workspace, find next numbered workspace. */
|
||||
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
|
||||
/* Skip outputs starting with __, they are internal. */
|
||||
if (output->name[0] == '_' && output->name[1] == '_')
|
||||
if (con_is_internal(output))
|
||||
continue;
|
||||
NODES_FOREACH(output_get_content(output)) {
|
||||
if (child->type != CT_WORKSPACE)
|
||||
|
@ -483,7 +483,7 @@ Con* workspace_next(void) {
|
|||
bool found_current = false;
|
||||
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
|
||||
/* Skip outputs starting with __, they are internal. */
|
||||
if (output->name[0] == '_' && output->name[1] == '_')
|
||||
if (con_is_internal(output))
|
||||
continue;
|
||||
NODES_FOREACH(output_get_content(output)) {
|
||||
if (child->type != CT_WORKSPACE)
|
||||
|
@ -502,7 +502,7 @@ Con* workspace_next(void) {
|
|||
if (!next) {
|
||||
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
|
||||
/* Skip outputs starting with __, they are internal. */
|
||||
if (output->name[0] == '_' && output->name[1] == '_')
|
||||
if (con_is_internal(output))
|
||||
continue;
|
||||
NODES_FOREACH(output_get_content(output)) {
|
||||
if (child->type != CT_WORKSPACE)
|
||||
|
@ -534,7 +534,7 @@ Con* workspace_prev(void) {
|
|||
/* If numbered workspace, find previous numbered workspace. */
|
||||
TAILQ_FOREACH_REVERSE(output, &(croot->nodes_head), nodes_head, nodes) {
|
||||
/* Skip outputs starting with __, they are internal. */
|
||||
if (output->name[0] == '_' && output->name[1] == '_')
|
||||
if (con_is_internal(output))
|
||||
continue;
|
||||
NODES_FOREACH_REVERSE(output_get_content(output)) {
|
||||
if (child->type != CT_WORKSPACE || child->num == -1)
|
||||
|
@ -553,7 +553,7 @@ Con* workspace_prev(void) {
|
|||
bool found_current = false;
|
||||
TAILQ_FOREACH_REVERSE(output, &(croot->nodes_head), nodes_head, nodes) {
|
||||
/* Skip outputs starting with __, they are internal. */
|
||||
if (output->name[0] == '_' && output->name[1] == '_')
|
||||
if (con_is_internal(output))
|
||||
continue;
|
||||
NODES_FOREACH_REVERSE(output_get_content(output)) {
|
||||
if (child->type != CT_WORKSPACE)
|
||||
|
@ -572,7 +572,7 @@ Con* workspace_prev(void) {
|
|||
if (!prev) {
|
||||
TAILQ_FOREACH_REVERSE(output, &(croot->nodes_head), nodes_head, nodes) {
|
||||
/* Skip outputs starting with __, they are internal. */
|
||||
if (output->name[0] == '_' && output->name[1] == '_')
|
||||
if (con_is_internal(output))
|
||||
continue;
|
||||
NODES_FOREACH_REVERSE(output_get_content(output)) {
|
||||
if (child->type != CT_WORKSPACE)
|
||||
|
|
Loading…
Reference in New Issue