Rect get_unoccupied_space(Workspace *workspace);
void decorate_window(xcb_connection_t *conn, Client *client, xcb_drawable_t drawable, xcb_gcontext_t gc, int offset);
+void redecorate_window(xcb_connection_t *conn, Client *client);
void render_container(xcb_connection_t *connection, Container *container);
void render_layout(xcb_connection_t *conn);
static void focus_window(xcb_connection_t *connection, direction_t direction) {
printf("focusing direction %d\n", direction);
+
+ int new_row = current_row,
+ new_col = current_col;
+
/* TODO: for horizontal default layout, this has to be expanded to LEFT/RIGHT */
if (direction == D_UP || direction == D_DOWN) {
/* Let’s see if we can perform up/down focus in the current container */
return;
if (direction == D_DOWN && cell_exists(current_col, current_row+1))
- current_row++;
+ new_row++;
else if (direction == D_UP && cell_exists(current_col, current_row-1))
- current_row--;
+ new_row--;
} else if (direction == D_LEFT || direction == D_RIGHT) {
if (direction == D_RIGHT && cell_exists(current_col+1, current_row))
- current_col++;
+ new_col++;
else if (direction == D_LEFT && cell_exists(current_col-1, current_row))
- current_col--;
+ new_col--;
else {
printf("nah, not possible\n");
return;
return;
}
- if (CUR_CELL->currently_focused != NULL)
- set_focus(connection, CUR_CELL->currently_focused);
+ if (c_ws->table[new_col][new_row]->currently_focused != NULL)
+ set_focus(connection, c_ws->table[new_col][new_row]->currently_focused);
}
/*
#include "table.h"
#include "util.h"
#include "xinerama.h"
+#include "layout.h"
/* This macro copies the old value of the given variable, changes the variable to contain
th new one and returns true if it changed */
return unoccupied;
}
+/*
+ * Redecorates the given client correctly by checking if it’s in a stacking container and
+ * re-rendering the stack window or just calling decorate_window if it’s not in a stacking
+ * container.
+ *
+ */
+void redecorate_window(xcb_connection_t *conn, Client *client) {
+ if (client->container->mode == MODE_STACK) {
+ render_container(conn, client->container);
+ xcb_flush(conn);
+ } else decorate_window(conn, client, client->frame, client->titlegc, 0);
+}
+
+
/*
* (Re-)draws window decorations for a given Client onto the given drawable/graphic context.
* When in stacking mode, the window decorations are drawn onto an own window.
return;
if (client->container->currently_focused == client) {
- background_color = get_colorpixel(conn, client, client->frame, "#285577");
+ /* Distinguish if the window is currently focused… */
+ if (CUR_CELL->currently_focused == client)
+ background_color = get_colorpixel(conn, client, client->frame, "#285577");
+ /* …or if it is the focused window in a not focused container */
+ else background_color = get_colorpixel(conn, client, client->frame, "#555555");
+
text_color = get_colorpixel(conn, client, client->frame, "#ffffff");
border_color = get_colorpixel(conn, client, client->frame, "#4c7899");
} else {
if (client->dock)
return;
+ /* Store the old client */
+ Client *old_client = CUR_CELL->currently_focused;
+
/* TODO: check if the focus needs to be changed at all */
/* Store current_row/current_col */
c_ws->current_row = current_row;
c_ws = client->container->workspace;
/* Update container */
- Client *old_client = client->container->currently_focused;
client->container->currently_focused = client;
current_col = client->container->col;
xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, client->child, XCB_CURRENT_TIME);
//xcb_warp_pointer(conn, XCB_NONE, client->child, 0, 0, 0, 0, 10, 10);
- /* If we’re in stacking mode, we render the container to update changes in the title
+ /* If we’re in stacking mode, this renders the container to update changes in the title
bars and to raise the focused client */
- if (client->container->mode == MODE_STACK)
- render_container(conn, client->container);
- else {
- /* Update last/current client’s titlebar */
- if (old_client != NULL)
- decorate_window(conn, old_client, old_client->frame, old_client->titlegc, 0);
- decorate_window(conn, client, client->frame, client->titlegc, 0);
- }
+ if (old_client != NULL)
+ redecorate_window(conn, old_client);
- xcb_flush(conn);
+ /* redecorate_window flushes, so we don’t need to */
+ redecorate_window(conn, client);
}
/*