#include "client.h"
#include "log.h"
#include "ewmh.h"
+#include "ipc.h"
/*
* Returns a pointer to the workspace with the given number (starting at 0),
workspace_set_name(ws, NULL);
TAILQ_INSERT_TAIL(workspaces, ws, workspaces);
+
+ ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"init\"}");
}
DLOG("done\n");
errx(1, "asprintf() failed");
FREE(ws->name);
+ FREE(ws->utf8_name);
ws->name = convert_utf8_to_ucs2(label, &(ws->name_len));
if (config.font != NULL)
ws->text_width = predict_text_width(global_conn, config.font, ws->name, ws->name_len);
else ws->text_width = 0;
-
- free(label);
+ ws->utf8_name = label;
}
/*
if ((old_client != NULL) && !old_client->dock)
redecorate_window(conn, old_client);
else xcb_flush(conn);
+
+ /* We need to check if a global fullscreen-client is blocking
+ * the t_ws and if necessary switch that to local fullscreen */
+ Client* client = c_ws->fullscreen_client;
+ if (client != NULL && client->workspace != c_ws) {
+ if (c_ws->fullscreen_client->workspace != c_ws)
+ c_ws->fullscreen_client = NULL;
+ client_enter_fullscreen(conn, client, false);
+ }
}
/* Check if we need to change something or if we’re already there */
xcb_flush(conn);
}
+ ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"focus\"}");
+
return;
}
current_col = c_ws->current_col;
DLOG("new current row = %d, current col = %d\n", current_row, current_col);
+ ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"focus\"}");
+
workspace_map_clients(conn, c_ws);
/* POTENTIAL TO IMPROVE HERE: due to the call to _map_clients first and
}
}
-
-/*
- * Parses the preferred_screen property of a workspace. You can either specify
- * the screen number (it is not given that the screen numbering always stays
- * the same) or the screen coordinates (exact coordinates, e.g. 1280 will match
- * the screen starting at x=1280, but 1281 will not). For coordinates, you can
- * either specify an x coordinate ("1280") or an y coordinate ("x800") or both
- * ("1280x800").
- *
- */
-static Output *get_screen_from_preference(char *preference) {
- Output *screen;
- char *rest;
- int preferred_screen = strtol(preference, &rest, 10);
-
- DLOG("Getting screen for preference \"%s\" (%d)\n", preference, preferred_screen);
-
- if ((rest == preference) || (preferred_screen >= num_screens)) {
- int x = INT_MAX, y = INT_MAX;
- if (strchr(preference, 'x') != NULL) {
- /* Check if only the y coordinate was specified */
- if (*preference == 'x')
- y = atoi(preference+1);
- else {
- x = atoi(preference);
- y = atoi(strchr(preference, 'x') + 1);
- }
- } else {
- x = atoi(preference);
- }
-
- DLOG("Looking for screen at %d x %d\n", x, y);
-
- TAILQ_FOREACH(screen, &outputs, outputs)
- if ((x == INT_MAX || screen->rect.x == x) &&
- (y == INT_MAX || screen->rect.y == y)) {
- DLOG("found %p\n", screen);
- return screen;
- }
-
- DLOG("none found\n");
- return NULL;
- } else {
- int c = 0;
- TAILQ_FOREACH(screen, &outputs, outputs)
- if (c++ == preferred_screen)
- return screen;
- }
-
- return NULL;
-}
-
/*
* Assigns the given workspace to the given output by correctly updating its
* state and reconfiguring all the clients on this workspace.
* output 1 and you just plugged in output 1).
*
*/
-void workspace_assign_to(Workspace *ws, Output *output) {
+void workspace_assign_to(Workspace *ws, Output *output, bool hide_it) {
Client *client;
bool empty = true;
+ bool visible = workspace_is_visible(ws);
ws->output = output;
render_workspace(global_conn, output, ws);
/* …unless we want to see them at the moment, we should hide that workspace */
- if (workspace_is_visible(ws))
+ if (visible && !hide_it)
return;
workspace_unmap_clients(global_conn, ws);
if (c_ws == ws) {
- DLOG("Need to adjust c_ws...\n");
- c_ws = output->current_workspace;
+ DLOG("Need to adjust output->current_workspace...\n");
+ output->current_workspace = c_ws;
}
}
/* If this workspace has no preferred output or if the output it wants
* to be on is not available at the moment, we initialize it with
* the output which was given */
- if (ws->preferred_screen == NULL ||
- (ws->output = get_screen_from_preference(ws->preferred_screen)) == NULL)
+ if (ws->preferred_output == NULL ||
+ (ws->output = get_output_by_name(ws->preferred_output)) == NULL)
ws->output = output;
DLOG("old_output = %p, ws->output = %p\n", old_output, ws->output);
if (old_output != NULL && ws->output == old_output)
return;
- workspace_assign_to(ws, ws->output);
+ workspace_assign_to(ws, ws->output, false);
}
/*
* Gets the first unused workspace for the given screen, taking into account
- * the preferred_screen setting of every workspace (workspace assignments).
+ * the preferred_output setting of every workspace (workspace assignments).
*
*/
-Workspace *get_first_workspace_for_screen(Output *output) {
+Workspace *get_first_workspace_for_output(Output *output) {
Workspace *result = NULL;
Workspace *ws;
TAILQ_FOREACH(ws, workspaces, workspaces) {
- if (ws->preferred_screen == NULL ||
- !screens_are_equal(get_screen_from_preference(ws->preferred_screen), output))
+ if (ws->preferred_output == NULL ||
+ get_output_by_name(ws->preferred_output) != output)
continue;
result = ws;
if (result == NULL) {
/* No assignment found, returning first unused workspace */
- Workspace *ws;
TAILQ_FOREACH(ws, workspaces, workspaces) {
if (ws->output != NULL)
continue;
if (result == NULL) {
DLOG("No existing free workspace found to assign, creating a new one\n");
- Workspace *ws;
int last_ws = 0;
TAILQ_FOREACH(ws, workspaces, workspaces)
last_ws = ws->num;
/* Map all stack windows, if any */
struct Stack_Window *stack_win;
SLIST_FOREACH(stack_win, &stack_wins, stack_windows)
- if (stack_win->container->workspace == ws)
+ if (stack_win->container->workspace == ws && stack_win->rect.height > 0)
xcb_map_window(conn, stack_win->window);
ignore_enter_notify_forall(conn, ws, false);
height -= client->desired_height;
/* Space for the internal bar */
- height -= (font->height + 6);
+ if (!config.disable_workspace_bar)
+ height -= (font->height + 6);
return height;
}