i3
workspace.h File Reference
#include <config.h>
#include "data.h"
#include "tree.h"
#include "randr.h"
Include dependency graph for workspace.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define NET_WM_DESKTOP_NONE   0xFFFFFFF0
 
#define NET_WM_DESKTOP_ALL   0xFFFFFFFF
 

Functions

Conget_existing_workspace_by_name (const char *name)
 Returns the workspace with the given name or NULL if such a workspace does not exist.
 
Conget_existing_workspace_by_num (int num)
 Returns the workspace with the given number or NULL if such a workspace does not exist.
 
Conget_assigned_output (const char *name, long parsed_num)
 Returns the first output that is assigned to a workspace specified by the given name or number.
 
bool output_triggers_assignment (Output *output, struct Workspace_Assignment *assignment)
 Returns true if the first output assigned to a workspace with the given workspace assignment is the same as the given output.
 
Conworkspace_get (const char *num)
 Returns a pointer to the workspace with the given number (starting at 0), creating the workspace if necessary (by allocating the necessary amount of memory and initializing the data structures correctly).
 
void extract_workspace_names_from_bindings (void)
 Extracts workspace names from keybindings (e.g.
 
Concreate_workspace_on_output (Output *output, Con *content)
 Returns a pointer to a new workspace in the given output.
 
bool workspace_is_visible (Con *ws)
 Returns true if the workspace is currently visible.
 
void workspace_show (Con *ws)
 Switches to the given workspace.
 
void workspace_show_by_name (const char *num)
 Looks up the workspace by name and switches to it.
 
Conworkspace_next (void)
 Returns the next workspace.
 
Conworkspace_prev (void)
 Returns the previous workspace.
 
Conworkspace_next_on_output (void)
 Returns the next workspace on the same output.
 
Conworkspace_prev_on_output (void)
 Returns the previous workspace on the same output.
 
void workspace_back_and_forth (void)
 Focuses the previously focused workspace.
 
Conworkspace_back_and_forth_get (void)
 Returns the previously focused workspace con, or NULL if unavailable.
 
void workspace_update_urgent_flag (Con *ws)
 Goes through all clients on the given workspace and updates the workspace’s urgent flag accordingly.
 
void ws_force_orientation (Con *ws, orientation_t orientation)
 'Forces' workspace orientation by moving all cons into a new split-con with the same orientation as the workspace and then changing the workspace orientation.
 
Conworkspace_attach_to (Con *ws)
 Called when a new con (with a window, not an empty or split con) should be attached to the workspace (for example when managing a new window or when moving an existing window to the workspace level).
 
Conworkspace_encapsulate (Con *ws)
 Creates a new container and re-parents all of children from the given workspace into it.
 
void workspace_move_to_output (Con *ws, Output *output)
 Move the given workspace to the specified output.
 

Variables

char * previous_workspace_name
 Stores a copy of the name of the last used workspace for the workspace back-and-forth switching.
 

Macro Definition Documentation

◆ NET_WM_DESKTOP_ALL

#define NET_WM_DESKTOP_ALL   0xFFFFFFFF

◆ NET_WM_DESKTOP_NONE

#define NET_WM_DESKTOP_NONE   0xFFFFFFF0

Function Documentation

◆ create_workspace_on_output()

Con * create_workspace_on_output ( Output * output,
Con * content )

◆ extract_workspace_names_from_bindings()

void extract_workspace_names_from_bindings ( void )

Extracts workspace names from keybindings (e.g.

“web” from “bindsym $mod+1 workspace web”), so that when an output needs a workspace, i3 can start with the first configured one. Needs to be called before reorder_bindings() so that the config-file order is used, not the i3-internal order.

Definition at line 181 of file workspace.c.

References binding_workspace_names, bindings, Binding::command, DLOG, FREE, LOG, parse_string(), srealloc(), and TAILQ_FOREACH.

Referenced by load_configuration().

Here is the call graph for this function:

◆ get_assigned_output()

Con * get_assigned_output ( const char * name,
long parsed_num )

Returns the first output that is assigned to a workspace specified by the given name or number.

Returns NULL if no such output exists.

If an assignment matches by number but there is an assignment later that matches by name, the second one is preferred. The order of the 'ws_assignments' queue is respected: if multiple assignments match the criteria, the first one is returned. 'name' is ignored when NULL, 'parsed_num' is ignored when it is -1.

Definition at line 84 of file workspace.c.

References xoutput::con, DLOG, get_output_by_name(), Workspace_Assignment::name, Workspace_Assignment::output, TAILQ_FOREACH, ws_assignments, and ws_name_to_number().

Referenced by cmd_rename_workspace(), create_workspace_on_output(), init_ws_for_output(), output_triggers_assignment(), and workspace_get().

Here is the call graph for this function:

◆ get_existing_workspace_by_name()

Con * get_existing_workspace_by_name ( const char * name)

Returns the workspace with the given name or NULL if such a workspace does not exist.

Definition at line 30 of file workspace.c.

References croot, GREP_FIRST, output_get_content(), and TAILQ_FOREACH.

Referenced by cmd_rename_workspace(), create_workspace_on_output(), json_end_map(), workspace_get(), and workspace_move_to_output().

Here is the call graph for this function:

◆ get_existing_workspace_by_num()

Con * get_existing_workspace_by_num ( int num)

Returns the workspace with the given number or NULL if such a workspace does not exist.

Definition at line 44 of file workspace.c.

References croot, GREP_FIRST, Con::num, output_get_content(), and TAILQ_FOREACH.

Referenced by cmd_move_con_to_workspace_number(), cmd_workspace_number(), create_workspace_on_output(), manage_window(), and workspace_move_to_output().

Here is the call graph for this function:

◆ output_triggers_assignment()

bool output_triggers_assignment ( Output * output,
struct Workspace_Assignment * assignment )

Returns true if the first output assigned to a workspace with the given workspace assignment is the same as the given output.

Definition at line 120 of file workspace.c.

References get_assigned_output(), Workspace_Assignment::name, and Workspace_Assignment::output.

Referenced by init_ws_for_output(), and workspace_move_to_output().

Here is the call graph for this function:

◆ workspace_attach_to()

Con * workspace_attach_to ( Con * ws)

Called when a new con (with a window, not an empty or split con) should be attached to the workspace (for example when managing a new window or when moving an existing window to the workspace level).

Depending on the workspace_layout setting, this function either returns the workspace itself (default layout) or creates a new stacked/tabbed con and returns that.

Definition at line 996 of file workspace.c.

References con_attach(), con_fix_percent(), con_new(), DLOG, L_DEFAULT, Con::layout, Con::name, and Con::workspace_layout.

Referenced by _con_attach(), and insert_con_into().

Here is the call graph for this function:

◆ workspace_back_and_forth()

void workspace_back_and_forth ( void )

Focuses the previously focused workspace.

Definition at line 894 of file workspace.c.

References DLOG, previous_workspace_name, and workspace_show_by_name().

Referenced by cmd_workspace_back_and_forth(), and maybe_back_and_forth().

Here is the call graph for this function:

◆ workspace_back_and_forth_get()

Con * workspace_back_and_forth_get ( void )

Returns the previously focused workspace con, or NULL if unavailable.

Definition at line 907 of file workspace.c.

References DLOG, previous_workspace_name, and workspace_get().

Referenced by cmd_move_con_to_workspace_back_and_forth(), and maybe_auto_back_and_forth_workspace().

Here is the call graph for this function:

◆ workspace_encapsulate()

Con * workspace_encapsulate ( Con * ws)

Creates a new container and re-parents all of children from the given workspace into it.

The container inherits the layout from the workspace.

Definition at line 1028 of file workspace.c.

References con_attach(), con_detach(), con_new(), DLOG, ELOG, get_focus_order(), Con::layout, Con::name, set_focus_order(), TAILQ_EMPTY, and TAILQ_FIRST.

Referenced by _con_move_to_con(), and tree_split().

Here is the call graph for this function:

◆ workspace_get()

◆ workspace_is_visible()

bool workspace_is_visible ( Con * ws)

Returns true if the workspace is currently visible.

Especially important for multi-monitor environments, as they can have multiple currently active workspaces.

Definition at line 320 of file workspace.c.

References CF_OUTPUT, con_get_fullscreen_con(), con_get_output(), and Workspace_Assignment::output.

Referenced by cmd_focus_output(), con_move_to_output(), con_on_remove_child(), get_tree_next_workspace(), handle_client_message(), handle_configure_request(), has_drop_targets(), IPC_HANDLER(), is_tiling_drop_target(), manage_window(), move_to_output_directed(), output_push_sticky_windows(), workspace_move_to_output(), and workspace_show().

Here is the call graph for this function:

◆ workspace_move_to_output()

◆ workspace_next()

Con * workspace_next ( void )

Returns the next workspace.

Definition at line 581 of file workspace.c.

References con_get_workspace(), con_is_internal(), croot, focused, NODES_FOREACH, Con::num, Workspace_Assignment::output, output_get_content(), TAILQ_FOREACH, and TAILQ_NEXT.

Referenced by cmd_move_con_to_workspace(), and cmd_workspace().

Here is the call graph for this function:

◆ workspace_next_on_output()

Con * workspace_next_on_output ( void )

Returns the next workspace on the same output.

Definition at line 752 of file workspace.c.

References con_get_output(), con_get_workspace(), focused, NODES_FOREACH, Con::num, Workspace_Assignment::output, output_get_content(), and TAILQ_NEXT.

Referenced by cmd_move_con_to_workspace(), and cmd_workspace().

Here is the call graph for this function:

◆ workspace_prev()

Con * workspace_prev ( void )

Returns the previous workspace.

Definition at line 665 of file workspace.c.

References con_get_workspace(), con_is_internal(), croot, focused, NODES_FOREACH_REVERSE, Con::num, Workspace_Assignment::output, output_get_content(), TAILQ_FOREACH_REVERSE, and TAILQ_PREV.

Referenced by cmd_move_con_to_workspace(), and cmd_workspace().

Here is the call graph for this function:

◆ workspace_prev_on_output()

Con * workspace_prev_on_output ( void )

Returns the previous workspace on the same output.

Definition at line 822 of file workspace.c.

References con_get_output(), con_get_workspace(), DLOG, focused, NODES_FOREACH_REVERSE, Con::num, Workspace_Assignment::output, output_get_content(), and TAILQ_PREV.

Referenced by cmd_move_con_to_workspace(), and cmd_workspace().

Here is the call graph for this function:

◆ workspace_show()

◆ workspace_show_by_name()

void workspace_show_by_name ( const char * num)

Looks up the workspace by name and switches to it.

Definition at line 573 of file workspace.c.

References workspace_get(), and workspace_show().

Referenced by cmd_workspace_name(), cmd_workspace_number(), init_ws_for_output(), and workspace_back_and_forth().

Here is the call graph for this function:

◆ workspace_update_urgent_flag()

void workspace_update_urgent_flag ( Con * ws)

Goes through all clients on the given workspace and updates the workspace’s urgent flag accordingly.

Definition at line 938 of file workspace.c.

References DLOG, get_urgency_flag(), ipc_send_workspace_event(), and Con::urgent.

Referenced by _con_move_to_con(), con_focus(), con_set_urgency(), tree_close_internal(), and workspace_defer_update_urgent_hint_cb().

Here is the call graph for this function:

◆ ws_force_orientation()

void ws_force_orientation ( Con * ws,
orientation_t orientation )

'Forces' workspace orientation by moving all cons into a new split-con with the same orientation as the workspace and then changing the workspace orientation.

Definition at line 953 of file workspace.c.

References con_attach(), con_detach(), con_fix_percent(), con_new(), DLOG, get_focus_order(), HORIZ, L_SPLITH, L_SPLITV, Con::layout, Con::parent, set_focus_order(), TAILQ_EMPTY, and TAILQ_FIRST.

Referenced by tree_move().

Here is the call graph for this function:

Variable Documentation

◆ previous_workspace_name

char* previous_workspace_name
extern

Stores a copy of the name of the last used workspace for the workspace back-and-forth switching.

Definition at line 19 of file workspace.c.

Referenced by cmd_rename_workspace(), dump_node(), json_string(), workspace_back_and_forth(), workspace_back_and_forth_get(), and workspace_show().