]> git.sur5r.net Git - i3/i3/blob - include/workspace.h
Introduce get_existing_workspace_by_name
[i3/i3] / include / workspace.h
1 /*
2  * vim:ts=4:sw=4:expandtab
3  *
4  * i3 - an improved dynamic tiling window manager
5  * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
6  *
7  * workspace.c: Modifying workspaces, accessing them, moving containers to
8  *              workspaces.
9  *
10  */
11 #pragma once
12
13 #include <config.h>
14
15 #include "data.h"
16 #include "tree.h"
17 #include "randr.h"
18
19 /* We use NET_WM_DESKTOP_NONE for cases where we cannot determine the EWMH
20  * desktop index for a window. We cannot use a negative value like -1 since we
21  * need to use uint32_t as we actually need the full range of it. This is
22  * technically dangerous, but it's safe to assume that we will never have more
23  * than 4294967279 workspaces open at a time. */
24 #define NET_WM_DESKTOP_NONE 0xFFFFFFF0
25 #define NET_WM_DESKTOP_ALL 0xFFFFFFFF
26
27 /**
28  * Returns the workspace with the given name or NULL if such a workspace does
29  * not exist.
30  *
31  */
32 Con *get_existing_workspace_by_name(const char *name);
33
34 /**
35  * Returns a pointer to the workspace with the given number (starting at 0),
36  * creating the workspace if necessary (by allocating the necessary amount of
37  * memory and initializing the data structures correctly).
38  *
39  * If created is not NULL, *created will be set to whether or not the
40  * workspace has just been created.
41  *
42  */
43 Con *workspace_get(const char *num, bool *created);
44
45 /**
46  * Extracts workspace names from keybindings (e.g. “web” from “bindsym $mod+1
47  * workspace web”), so that when an output needs a workspace, i3 can start with
48  * the first configured one. Needs to be called before reorder_bindings() so
49  * that the config-file order is used, not the i3-internal order.
50  *
51  */
52 void extract_workspace_names_from_bindings(void);
53
54 /**
55  * Returns a pointer to a new workspace in the given output. The workspace
56  * is created attached to the tree hierarchy through the given content
57  * container.
58  *
59  */
60 Con *create_workspace_on_output(Output *output, Con *content);
61
62 /**
63  * Returns true if the workspace is currently visible. Especially important for
64  * multi-monitor environments, as they can have multiple currenlty active
65  * workspaces.
66  *
67  */
68 bool workspace_is_visible(Con *ws);
69
70 /**
71  * Switches to the given workspace
72  *
73  */
74 void workspace_show(Con *ws);
75
76 /**
77  * Looks up the workspace by name and switches to it.
78  *
79  */
80 void workspace_show_by_name(const char *num);
81
82 /**
83  * Returns the next workspace.
84  *
85  */
86 Con *workspace_next(void);
87
88 /**
89  * Returns the previous workspace.
90  *
91  */
92 Con *workspace_prev(void);
93
94 /**
95  * Returns the next workspace on the same output
96  *
97  */
98 Con *workspace_next_on_output(void);
99
100 /**
101  * Returns the previous workspace on the same output
102  *
103  */
104 Con *workspace_prev_on_output(void);
105
106 /**
107  * Focuses the previously focused workspace.
108  *
109  */
110 void workspace_back_and_forth(void);
111
112 /**
113  * Returns the previously focused workspace con, or NULL if unavailable.
114  *
115  */
116 Con *workspace_back_and_forth_get(void);
117
118 #if 0
119 /**
120  * Assigns the given workspace to the given screen by correctly updating its
121  * state and reconfiguring all the clients on this workspace.
122  *
123  * This is called when initializing a screen and when re-assigning it to a
124  * different screen which just got available (if you configured it to be on
125  * screen 1 and you just plugged in screen 1).
126  *
127  */
128 void workspace_assign_to(Workspace *ws, Output *screen, bool hide_it);
129
130 /**
131  * Initializes the given workspace if it is not already initialized. The given
132  * screen is to be understood as a fallback, if the workspace itself either
133  * was not assigned to a particular screen or cannot be placed there because
134  * the screen is not attached at the moment.
135  *
136  */
137 void workspace_initialize(Workspace *ws, Output *screen, bool recheck);
138
139 /**
140  * Gets the first unused workspace for the given screen, taking into account
141  * the preferred_screen setting of every workspace (workspace assignments).
142  *
143  */
144 Workspace *get_first_workspace_for_output(Output *screen);
145
146 /**
147  * Unmaps all clients (and stack windows) of the given workspace.
148  *
149  * This needs to be called separately when temporarily rendering a workspace
150  * which is not the active workspace to force reconfiguration of all clients,
151  * like in src/xinerama.c when re-assigning a workspace to another screen.
152  *
153  */
154 void workspace_unmap_clients(xcb_connection_t *conn, Workspace *u_ws);
155
156 /**
157  * Maps all clients (and stack windows) of the given workspace.
158  *
159  */
160 void workspace_map_clients(xcb_connection_t *conn, Workspace *ws);
161 #endif
162
163 /**
164  * Goes through all clients on the given workspace and updates the workspace’s
165  * urgent flag accordingly.
166  *
167  */
168 void workspace_update_urgent_flag(Con *ws);
169
170 /**
171  * 'Forces' workspace orientation by moving all cons into a new split-con with
172  * the same orientation as the workspace and then changing the workspace
173  * orientation.
174  *
175  */
176 void ws_force_orientation(Con *ws, orientation_t orientation);
177
178 /**
179  * Called when a new con (with a window, not an empty or split con) should be
180  * attached to the workspace (for example when managing a new window or when
181  * moving an existing window to the workspace level).
182  *
183  * Depending on the workspace_layout setting, this function either returns the
184  * workspace itself (default layout) or creates a new stacked/tabbed con and
185  * returns that.
186  *
187  */
188 Con *workspace_attach_to(Con *ws);
189
190 /**
191  * Creates a new container and re-parents all of children from the given
192  * workspace into it.
193  *
194  * The container inherits the layout from the workspace.
195  */
196 Con *workspace_encapsulate(Con *ws);
197
198 /**
199  * Move the given workspace to the specified output.
200  * This returns true if and only if moving the workspace was successful.
201  *
202  */
203 bool workspace_move_to_output(Con *ws, const char *output);