Use a different color for focused windows in not focused containers, includes bugfixes for re-decoration

This commit is contained in:
Michael Stapelberg 2009-03-03 02:28:26 +01:00
parent 1d9dc05b91
commit 16a514b9c1
4 changed files with 40 additions and 18 deletions

View File

@ -15,6 +15,7 @@
Rect get_unoccupied_space(Workspace *workspace); 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 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_container(xcb_connection_t *connection, Container *container);
void render_layout(xcb_connection_t *conn); void render_layout(xcb_connection_t *conn);

View File

@ -48,6 +48,10 @@ static bool focus_window_in_container(xcb_connection_t *connection, Container *c
static void focus_window(xcb_connection_t *connection, direction_t direction) { static void focus_window(xcb_connection_t *connection, direction_t direction) {
printf("focusing direction %d\n", 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 */ /* TODO: for horizontal default layout, this has to be expanded to LEFT/RIGHT */
if (direction == D_UP || direction == D_DOWN) { if (direction == D_UP || direction == D_DOWN) {
/* Lets see if we can perform up/down focus in the current container */ /* Lets see if we can perform up/down focus in the current container */
@ -60,14 +64,14 @@ static void focus_window(xcb_connection_t *connection, direction_t direction) {
return; return;
if (direction == D_DOWN && cell_exists(current_col, current_row+1)) 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)) else if (direction == D_UP && cell_exists(current_col, current_row-1))
current_row--; new_row--;
} else if (direction == D_LEFT || direction == D_RIGHT) { } else if (direction == D_LEFT || direction == D_RIGHT) {
if (direction == D_RIGHT && cell_exists(current_col+1, current_row)) 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)) else if (direction == D_LEFT && cell_exists(current_col-1, current_row))
current_col--; new_col--;
else { else {
printf("nah, not possible\n"); printf("nah, not possible\n");
return; return;
@ -77,8 +81,8 @@ static void focus_window(xcb_connection_t *connection, direction_t direction) {
return; return;
} }
if (CUR_CELL->currently_focused != NULL) if (c_ws->table[new_col][new_row]->currently_focused != NULL)
set_focus(connection, CUR_CELL->currently_focused); set_focus(connection, c_ws->table[new_col][new_row]->currently_focused);
} }
/* /*

View File

@ -23,6 +23,7 @@
#include "table.h" #include "table.h"
#include "util.h" #include "util.h"
#include "xinerama.h" #include "xinerama.h"
#include "layout.h"
/* This macro copies the old value of the given variable, changes the variable to contain /* This macro copies the old value of the given variable, changes the variable to contain
th new one and returns true if it changed */ th new one and returns true if it changed */
@ -77,6 +78,20 @@ int get_unoccupied_y(Workspace *workspace, int col) {
return unoccupied; return unoccupied;
} }
/*
* Redecorates the given client correctly by checking if its in a stacking container and
* re-rendering the stack window or just calling decorate_window if its 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. * (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. * When in stacking mode, the window decorations are drawn onto an own window.
@ -93,7 +108,12 @@ void decorate_window(xcb_connection_t *conn, Client *client, xcb_drawable_t draw
return; return;
if (client->container->currently_focused == client) { if (client->container->currently_focused == client) {
/* Distinguish if the window is currently focused… */
if (CUR_CELL->currently_focused == client)
background_color = get_colorpixel(conn, client, client->frame, "#285577"); 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"); text_color = get_colorpixel(conn, client, client->frame, "#ffffff");
border_color = get_colorpixel(conn, client, client->frame, "#4c7899"); border_color = get_colorpixel(conn, client, client->frame, "#4c7899");
} else { } else {

View File

@ -127,6 +127,9 @@ void set_focus(xcb_connection_t *conn, Client *client) {
if (client->dock) if (client->dock)
return; return;
/* Store the old client */
Client *old_client = CUR_CELL->currently_focused;
/* TODO: check if the focus needs to be changed at all */ /* TODO: check if the focus needs to be changed at all */
/* Store current_row/current_col */ /* Store current_row/current_col */
c_ws->current_row = current_row; c_ws->current_row = current_row;
@ -134,7 +137,6 @@ void set_focus(xcb_connection_t *conn, Client *client) {
c_ws = client->container->workspace; c_ws = client->container->workspace;
/* Update container */ /* Update container */
Client *old_client = client->container->currently_focused;
client->container->currently_focused = client; client->container->currently_focused = client;
current_col = client->container->col; current_col = client->container->col;
@ -145,18 +147,13 @@ void set_focus(xcb_connection_t *conn, Client *client) {
xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, client->child, XCB_CURRENT_TIME); 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); //xcb_warp_pointer(conn, XCB_NONE, client->child, 0, 0, 0, 0, 10, 10);
/* If were in stacking mode, we render the container to update changes in the title /* If were in stacking mode, this renders the container to update changes in the title
bars and to raise the focused client */ bars and to raise the focused client */
if (client->container->mode == MODE_STACK)
render_container(conn, client->container);
else {
/* Update last/current clients titlebar */
if (old_client != NULL) if (old_client != NULL)
decorate_window(conn, old_client, old_client->frame, old_client->titlegc, 0); redecorate_window(conn, old_client);
decorate_window(conn, client, client->frame, client->titlegc, 0);
}
xcb_flush(conn); /* redecorate_window flushes, so we dont need to */
redecorate_window(conn, client);
} }
/* /*