i3
Functions

src/workspace.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <err.h>
#include "util.h"
#include "data.h"
#include "i3.h"
#include "config.h"
#include "xcb.h"
#include "table.h"
#include "randr.h"
#include "layout.h"
#include "workspace.h"
#include "client.h"
#include "log.h"
#include "ewmh.h"
#include "ipc.h"
Include dependency graph for workspace.c:

Go to the source code of this file.

Functions

Workspaceworkspace_get (int number)
 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 workspace_set_name (Workspace *ws, const char *name)
 Sets the name (or just its number) for the given workspace.
bool workspace_is_visible (Workspace *ws)
 Returns true if the workspace is currently visible.
void workspace_show (xcb_connection_t *conn, int workspace)
 Switches to the given workspace.
void workspace_assign_to (Workspace *ws, Output *output, bool hide_it)
 Assigns the given workspace to the given screen by correctly updating its state and reconfiguring all the clients on this workspace.
void workspace_initialize (Workspace *ws, Output *output, bool recheck)
 Initializes the given workspace if it is not already initialized.
Workspaceget_first_workspace_for_output (Output *output)
 Gets the first unused workspace for the given screen, taking into account the preferred_screen setting of every workspace (workspace assignments).
void workspace_map_clients (xcb_connection_t *conn, Workspace *ws)
 Maps all clients (and stack windows) of the given workspace.
void workspace_unmap_clients (xcb_connection_t *conn, Workspace *u_ws)
 Unmaps all clients (and stack windows) of the given workspace.
void workspace_update_urgent_flag (Workspace *ws)
 Goes through all clients on the given workspace and updates the workspace’s urgent flag accordingly.
int workspace_width (Workspace *ws)
int workspace_height (Workspace *ws)

Function Documentation

Workspace* get_first_workspace_for_output ( Output output)

Gets the first unused workspace for the given screen, taking into account the preferred_screen setting of every workspace (workspace assignments).

Definition at line 300 of file workspace.c.

References DLOG, get_output_by_name(), Workspace::num, Workspace::output, Workspace::preferred_output, TAILQ_FOREACH, workspace_get(), workspace_initialize(), and workspaces.

Referenced by init_workspaces(), and initialize_xinerama().

Here is the call graph for this function:

void workspace_assign_to ( Workspace ws,
Output screen,
bool  hide_it 
)

Assigns the given workspace to the given screen by correctly updating its state and reconfiguring all the clients on this workspace.

This is called when initializing a screen and when re-assigning it to a different screen which just got available (if you configured it to be on screen 1 and you just plugged in screen 1).

Definition at line 222 of file workspace.c.

References c_ws, xoutput::current_workspace, DLOG, ewmh_update_workarea(), Client::force_reconfigure, global_conn, ipc_send_event(), Workspace::output, xoutput::rect, Workspace::rect, render_workspace(), SLIST_FOREACH, workspace_is_visible(), and workspace_unmap_clients().

Referenced by initialize_output(), randr_query_outputs(), and workspace_initialize().

Here is the call graph for this function:

Workspace* workspace_get ( int  number)

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

Definition at line 39 of file workspace.c.

References DLOG, ewmh_update_workarea(), expand_table_cols(), expand_table_rows(), ipc_send_event(), Workspace::num, scalloc(), TAILQ_FOREACH, TAILQ_INIT, TAILQ_INSERT_TAIL, TAILQ_LAST, workspace_set_name(), and workspaces.

Referenced by get_first_workspace_for_output(), move_current_window_to_workspace(), move_floating_window_to_workspace(), reparent_window(), workspace_show(), and yyparse().

Here is the call graph for this function:

int workspace_height ( Workspace ws)
void workspace_initialize ( Workspace ws,
Output screen,
bool  recheck 
)

Initializes the given workspace if it is not already initialized.

The given screen is to be understood as a fallback, if the workspace itself either was not assigned to a particular screen or cannot be placed there because the screen is not attached at the moment.

Definition at line 270 of file workspace.c.

References DLOG, get_output_by_name(), Workspace::output, Workspace::preferred_output, and workspace_assign_to().

Referenced by get_first_workspace_for_output(), move_current_window_to_workspace(), move_floating_window_to_workspace(), reparent_window(), and workspace_show().

Here is the call graph for this function:

bool workspace_is_visible ( Workspace 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 105 of file workspace.c.

References xoutput::current_workspace, and Workspace::output.

Referenced by handle_hints(), handle_normal_hints(), handle_unmap_notify_event(), handle_windowname_change(), handle_windowname_change_legacy(), move_current_window_to_workspace(), move_floating_window_to_workspace(), reparent_window(), and workspace_assign_to().

void workspace_map_clients ( xcb_connection_t *  conn,
Workspace ws 
)

Maps all clients (and stack windows) of the given workspace.

Definition at line 341 of file workspace.c.

References CIRCLEQ_FOREACH, client_map(), Stack_Window::container, Workspace::floating_hidden, FOR_TABLE, Rect::height, ignore_enter_notify_forall(), Stack_Window::rect, SLIST_FOREACH, stack_wins, Workspace::table, TAILQ_FOREACH, Stack_Window::window, and Container::workspace.

Referenced by initialize_output(), and workspace_show().

Here is the call graph for this function:

void workspace_set_name ( Workspace ws,
const char *  name 
)

Sets the name (or just its number) for the given workspace.

This has to be called for every workspace as the rendering function (render_internal_bar) relies on workspace->name and workspace->name_len being ready-to-use.

Definition at line 78 of file workspace.c.

References config, convert_utf8_to_ucs2(), Config::font, FREE, global_conn, Workspace::name, Workspace::name_len, Workspace::num, predict_text_width(), Workspace::text_width, and Workspace::utf8_name.

Referenced by init_table(), load_configuration(), workspace_get(), and yyparse().

Here is the call graph for this function:

void workspace_show ( xcb_connection_t *  conn,
int  workspace 
)
void workspace_unmap_clients ( xcb_connection_t *  conn,
Workspace u_ws 
)

Unmaps all clients (and stack windows) of the given workspace.

This needs to be called separately when temporarily rendering a workspace which is not the active workspace to force reconfiguration of all clients, like in src/xinerama.c when re-assigning a workspace to another screen.

Definition at line 374 of file workspace.c.

References c_ws, Client::child, CIRCLEQ_FOREACH, client_is_floating(), client_unmap(), Stack_Window::container, DLOG, FOR_TABLE, Client::frame, ignore_enter_notify_forall(), Workspace::output, SLIST_FOREACH, stack_wins, Workspace::table, Stack_Window::window, Container::workspace, and Client::workspace.

Referenced by workspace_assign_to(), and workspace_show().

Here is the call graph for this function:

void workspace_update_urgent_flag ( Workspace ws)

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

Definition at line 430 of file workspace.c.

References ipc_send_event(), SLIST_FOREACH, Client::urgent, and Workspace::urgent.

Referenced by handle_hints(), handle_unmap_notify_event(), and set_focus().

Here is the call graph for this function:

int workspace_width ( Workspace ws)

Definition at line 453 of file workspace.c.

References Workspace::rect, and Rect::width.