Use a different color for focused windows in not focused containers, includes bugfixes for re-decoration
This commit is contained in:
parent
1d9dc05b91
commit
16a514b9c1
@ -15,6 +15,7 @@
|
||||
|
||||
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);
|
||||
|
||||
|
@ -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) {
|
||||
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 */
|
||||
@ -60,14 +64,14 @@ static void focus_window(xcb_connection_t *connection, direction_t direction) {
|
||||
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;
|
||||
@ -77,8 +81,8 @@ static void focus_window(xcb_connection_t *connection, direction_t direction) {
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
22
src/layout.c
22
src/layout.c
@ -23,6 +23,7 @@
|
||||
#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 */
|
||||
@ -77,6 +78,20 @@ int get_unoccupied_y(Workspace *workspace, int col) {
|
||||
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.
|
||||
@ -93,7 +108,12 @@ void decorate_window(xcb_connection_t *conn, Client *client, xcb_drawable_t draw
|
||||
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 {
|
||||
|
19
src/util.c
19
src/util.c
@ -127,6 +127,9 @@ void set_focus(xcb_connection_t *conn, Client *client) {
|
||||
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;
|
||||
@ -134,7 +137,6 @@ void set_focus(xcb_connection_t *conn, Client *client) {
|
||||
c_ws = client->container->workspace;
|
||||
|
||||
/* Update container */
|
||||
Client *old_client = client->container->currently_focused;
|
||||
client->container->currently_focused = client;
|
||||
|
||||
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_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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user