#include "i3.h"
#include "xinerama.h"
-static bool focus_window_in_container(xcb_connection_t *conn, Container *container,
- direction_t direction) {
+bool focus_window_in_container(xcb_connection_t *conn, Container *container, direction_t direction) {
/* If this container is empty, we’re done */
if (container->currently_focused == NULL)
return false;
return false;
/* Set focus */
- set_focus(conn, candidate);
+ set_focus(conn, candidate, true);
return true;
}
new_row = (t_ws->rows - 1);
if (t_ws->table[new_col][new_row]->currently_focused != NULL)
- set_focus(conn, t_ws->table[new_col][new_row]->currently_focused);
+ set_focus(conn, t_ws->table[new_col][new_row]->currently_focused, true);
}
/*
/* Remove it from the old container and put it into the new one */
remove_client_from_container(conn, current_client, container);
CIRCLEQ_INSERT_TAIL(&(new->clients), current_client, clients);
+ SLIST_INSERT_HEAD(&(new->workspace->focus_stack), current_client, focus_clients);
/* Update data structures */
current_client->container = new;
render_layout(conn);
- set_focus(conn, current_client);
+ set_focus(conn, current_client, true);
}
static void move_current_container(xcb_connection_t *conn, direction_t direction) {
assert(to_container != NULL);
- CIRCLEQ_REMOVE(&(container->clients), current_client, clients);
- SLIST_REMOVE(&(container->workspace->focus_stack), current_client, Client, focus_clients);
+ remove_client_from_container(conn, current_client, container);
CIRCLEQ_INSERT_TAIL(&(to_container->clients), current_client, clients);
SLIST_INSERT_HEAD(&(to_container->workspace->focus_stack), current_client, focus_clients);
render_layout(conn);
}
-static void show_workspace(xcb_connection_t *conn, int workspace) {
+/*
+ * Switches to the given workspace
+ *
+ */
+void show_workspace(xcb_connection_t *conn, int workspace) {
Client *client;
xcb_window_t root = xcb_setup_roots_iterator(xcb_get_setup(conn)).data->root;
/* t_ws (to workspace) is just a convenience pointer to the workspace we’re switching to */
if (c_ws->screen != t_ws->screen) {
/* We need to switch to the other screen first */
LOG("moving over to other screen.\n");
+
+ /* Store the old client */
+ Client *old_client = CUR_CELL->currently_focused;
+
c_ws = &(workspaces[t_ws->screen->current_workspace]);
current_col = c_ws->current_col;
current_row = c_ws->current_row;
xcb_warp_pointer(conn, XCB_NONE, root, 0, 0, 0, 0,
dims->x + (dims->width / 2), dims->y + (dims->height / 2));
}
+
+ /* Re-decorate the old client, it’s not focused anymore */
+ if ((old_client != NULL) && !old_client->dock)
+ redecorate_window(conn, old_client);
+ else xcb_flush(conn);
}
/* Check if we need to change something or if we’re already there */
/* Restore focus on the new workspace */
if (CUR_CELL->currently_focused != NULL)
- set_focus(conn, CUR_CELL->currently_focused);
+ set_focus(conn, CUR_CELL->currently_focused, true);
else xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, root, XCB_CURRENT_TIME);
//xcb_ungrab_server(conn);
if (command[0] == '\0')
return;
- /* Is it an <exec>? */
- if (strncmp(command, "exec ", strlen("exec ")) == 0) {
+ /* Is it an <exec>? Then execute the given command. */
+ if (STARTS_WITH(command, "exec ")) {
LOG("starting \"%s\"\n", command + strlen("exec "));
start_application(command+strlen("exec "));
return;
}
- /* Is it <restart>? */
- if (strncmp(command, "restart", strlen("restart")) == 0) {
+ /* Is it an <exit>? */
+ if (STARTS_WITH(command, "exit")) {
+ LOG("User issued exit-command, exiting without error.\n");
+ exit(EXIT_SUCCESS);
+ }
+
+ /* Is it <restart>? Then restart in place. */
+ if (STARTS_WITH(command, "restart")) {
LOG("restarting \"%s\"...\n", application_path);
execl(application_path, application_path, NULL);
/* not reached */
}
+ if (STARTS_WITH(command, "kill")) {
+ if (CUR_CELL->currently_focused == NULL) {
+ LOG("There is no window to kill\n");
+ return;
+ }
+
+ LOG("Killing current window\n");
+ kill_window(conn, CUR_CELL->currently_focused);
+ return;
+ }
+
/* Is it 'f' for fullscreen? */
if (command[0] == 'f') {
if (CUR_CELL->currently_focused == NULL)