i3
Macros | Functions | Variables
workspace.c File Reference
#include "all.h"
Include dependency graph for workspace.c:

Go to the source code of this file.

Macros

#define I3__FILE__   "workspace.c"
 

Functions

static void _workspace_apply_default_orientation (Con *ws)
 
Conworkspace_get (const char *num, bool *created)
 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). More...
 
Concreate_workspace_on_output (Output *output, Con *content)
 
bool workspace_is_visible (Con *ws)
 Returns true if the workspace is currently visible. More...
 
Con_get_sticky (Con *con, const char *sticky_group, Con *exclude)
 
static void workspace_reassign_sticky (Con *con)
 
static void workspace_defer_update_urgent_hint_cb (EV_P_ ev_timer *w, int revents)
 
static void _workspace_show (Con *workspace)
 
void workspace_show (Con *workspace)
 Switches to the given workspace. More...
 
void workspace_show_by_name (const char *num)
 Looks up the workspace by name and switches to it. More...
 
Conworkspace_next (void)
 Returns the next workspace. More...
 
Conworkspace_prev (void)
 Returns the previous workspace. More...
 
Conworkspace_next_on_output (void)
 Returns the next workspace on the same output. More...
 
Conworkspace_prev_on_output (void)
 Returns the previous workspace on the same output. More...
 
void workspace_back_and_forth (void)
 Focuses the previously focused workspace. More...
 
Conworkspace_back_and_forth_get (void)
 Returns the previously focused workspace con, or NULL if unavailable. More...
 
static bool get_urgency_flag (Con *con)
 
void workspace_update_urgent_flag (Con *ws)
 Goes through all clients on the given workspace and updates the workspace’s urgent flag accordingly. More...
 
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. More...
 
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). More...
 
Conworkspace_encapsulate (Con *ws)
 Creates a new container and re-parents all of children from the given workspace into it. More...
 

Variables

static char * previous_workspace_name = NULL
 

Macro Definition Documentation

#define I3__FILE__   "workspace.c"

Definition at line 2 of file workspace.c.

Function Documentation

Con* _get_sticky ( Con con,
const char *  sticky_group,
Con exclude 
)

Definition at line 242 of file workspace.c.

References Con::sticky_group, TAILQ_FOREACH, and Con::window.

Referenced by workspace_reassign_sticky().

static void _workspace_apply_default_orientation ( Con ws)
static

Definition at line 25 of file workspace.c.

References con_get_output(), config, Config::default_orientation, DLOG, Rect::height, HORIZ, L_SPLITH, L_SPLITV, Con::layout, NO_ORIENTATION, Con::rect, and Rect::width.

Referenced by create_workspace_on_output(), and workspace_get().

Here is the call graph for this function:

static void _workspace_show ( Con workspace)
static
Con* create_workspace_on_output ( Output output,
Con content 
)
static bool get_urgency_flag ( Con con)
static

Definition at line 741 of file workspace.c.

References TAILQ_FOREACH, and Con::urgent.

Referenced by workspace_update_urgent_flag().

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 816 of file workspace.c.

References con_attach(), 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:

void workspace_back_and_forth ( void  )

Focuses the previously focused workspace.

Definition at line 716 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:

Con* workspace_back_and_forth_get ( void  )

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

Definition at line 729 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:

static void workspace_defer_update_urgent_hint_cb ( EV_P_ ev_timer *  w,
int  revents 
)
static

Definition at line 322 of file workspace.c.

References con_get_workspace(), con_update_parents_urgency(), DLOG, FREE, main_loop, tree_render(), Con::urgency_timer, Con::urgent, and workspace_update_urgent_flag().

Referenced by _workspace_show().

Here is the call graph for this function:

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 845 of file workspace.c.

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

Referenced by con_move_to_workspace(), and tree_split().

Here is the call graph for this function:

Con* workspace_get ( const char *  num,
bool *  created 
)

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).

If created is not NULL, *created will be set to whether or not the workspace has just been created.

Definition at line 44 of file workspace.c.

References _workspace_apply_default_orientation(), con_attach(), con_get_output(), con_new(), config, croot, Config::default_layout, focused, FREE, GREP_FIRST, ipc_send_event(), LOG, Workspace_Assignment::name, Con::name, Con::num, Workspace_Assignment::output, output_get_content(), Con::parent, sasprintf(), sstrdup(), TAILQ_FOREACH, Con::type, Con::workspace_layout, ws_assignments, and x_set_name().

Referenced by cmd_focus(), cmd_move_con_to_workspace_name(), cmd_move_con_to_workspace_number(), cmd_move_workspace_to_output(), manage_window(), scratchpad_fix_resolution(), scratchpad_move(), scratchpad_show(), workspace_back_and_forth_get(), and workspace_show_by_name().

Here is the call graph for this function:

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 currenlty active workspaces.

Definition at line 229 of file workspace.c.

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

Referenced by _tree_next(), _workspace_show(), cmd_focus_output(), cmd_move_con_to_output(), cmd_move_workspace_to_output(), con_move_to_workspace(), con_on_remove_child(), handle_client_message(), init_ws_for_output(), IPC_HANDLER(), manage_window(), and move_to_output_directed().

Here is the call graph for this function:

Con* workspace_next ( void  )

Returns the next workspace.

Definition at line 462 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:

Con* workspace_next_on_output ( void  )

Returns the next workspace on the same output.

Definition at line 604 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:

Con* workspace_prev ( void  )

Returns the previous workspace.

Definition at line 532 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:

Con* workspace_prev_on_output ( void  )

Returns the previous workspace on the same output.

Definition at line 659 of file workspace.c.

References con_get_output(), con_get_workspace(), DLOG, focused, Con::name, 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:

static void workspace_reassign_sticky ( Con con)
static

Definition at line 279 of file workspace.c.

References _get_sticky(), con_get_output(), LOG, Con::mapped, Con::name, Workspace_Assignment::output, Con::sticky_group, TAILQ_FOREACH, Con::window, x_move_win(), and x_reparent_child().

Referenced by _workspace_show().

Here is the call graph for this function:

void workspace_show ( Con ws)
void workspace_show_by_name ( const char *  num)

Looks up the workspace by name and switches to it.

Definition at line 452 of file workspace.c.

References _workspace_show(), and workspace_get().

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:

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 759 of file workspace.c.

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

Referenced by con_focus(), con_set_urgency(), tree_close(), and workspace_defer_update_urgent_hint_cb().

Here is the call graph for this function:

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 773 of file workspace.c.

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

Referenced by tree_move().

Here is the call graph for this function:

Variable Documentation

char* previous_workspace_name = NULL
static