Skip to content

Commit

Permalink
Rounded corners
Browse files Browse the repository at this point in the history
  • Loading branch information
resloved committed May 9, 2018
1 parent fcdf8d3 commit 83a12f7
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 29 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -3,6 +3,8 @@
[![Forks](https://img.shields.io/github/forks/Airblader/i3.svg)](https://github.com/Airblader/i3/network)
[![Stars](https://img.shields.io/github/stars/Airblader/i3.svg)](https://github.com/Airblader/i3/stargazers)

AS-IS Enter at your own risk

# i3 - Unofficial Fork

This is a fork of [i3wm](http://www.i3wm.org), a tiling window manager for Linux. It includes a few additional features which you can read up on below.
Expand Down
13 changes: 13 additions & 0 deletions build.sh
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

# compile & install
autoreconf --force --install
rm -rf build/
mkdir -p build && cd build/

# Disabling sanitizers is important for release versions!
# The prefix and sysconfdir are, obviously, dependent on the distribution.
../configure --prefix=/usr --sysconfdir=/etc --disable-sanitizers
make
sudo make install

118 changes: 89 additions & 29 deletions src/x.c
Expand Up @@ -99,23 +99,6 @@ static con_state *state_for_frame(xcb_window_t window) {
return NULL;
}

/*
* Changes the atoms on the root window and the windows themselves to properly
* reflect the current focus for ewmh compliance.
*
*/
static void change_ewmh_focus(xcb_window_t new_focus, xcb_window_t old_focus) {
ewmh_update_active_window(new_focus);

if (new_focus != XCB_WINDOW_NONE) {
ewmh_update_focused(new_focus, true);
}

if (old_focus != XCB_WINDOW_NONE) {
ewmh_update_focused(old_focus, false);
}
}

/*
* Initializes the X11 part for the given container. Called exactly once for
* every container from con_new().
Expand Down Expand Up @@ -347,11 +330,66 @@ static void x_draw_title_border(Con *con, struct deco_render_params *p) {
deco_diff_r = 0;
}

draw_util_rectangle(&(con->parent->frame_buffer), p->color->border,
dr->x, dr->y, dr->width, 1);
color_t gradient_inner = p->color->border;
gradient_inner.alpha = 170.0 / 255.0;
color_t gradient_outer = p->color->border;
gradient_outer.alpha = 102.0 / 255.0;

draw_util_rectangle(&(con->parent->frame_buffer), p->color->border,
dr->x + deco_diff_l, dr->y + dr->height - 1, dr->width - (deco_diff_l + deco_diff_r), 1);
dr->x + 3, dr->y, dr->width - 6, 1);
/* Left side */
if (con->parent->layout != L_TABBED || con == TAILQ_FIRST(&(con->parent->nodes_head))) {

/* Body */
draw_util_rectangle(&(con->parent->frame_buffer), p->color->border,
dr->x + 1, dr->y + 1, 2, 1);
draw_util_rectangle(&(con->parent->frame_buffer), p->color->border,
dr->x + 1, dr->y + 2, 1, 1);
draw_util_rectangle(&(con->parent->frame_buffer), p->color->border,
dr->x, dr->y + 3, 1, dr->height - 3);

/* AA */
draw_util_rectangle(&(con->parent->frame_buffer),
gradient_inner,
dr->x, dr->y + 2, 1, 1);
draw_util_rectangle(&(con->parent->frame_buffer),
gradient_inner,
dr->x + 2, dr->y, 1, 1);
draw_util_rectangle(&(con->parent->frame_buffer),
gradient_outer,
dr->x, dr->y + 1, 1, 1);
draw_util_rectangle(&(con->parent->frame_buffer),
gradient_outer,
dr->x + 1, dr->y, 1, 1);
}

/* Right side */
if (con->parent->layout != L_TABBED || TAILQ_NEXT(con, nodes) == NULL) {

/* Body */
draw_util_rectangle(&(con->parent->frame_buffer), p->color->border,
dr->x + dr->width - 3, dr->y + 1, 2, 1);
draw_util_rectangle(&(con->parent->frame_buffer), p->color->border,
dr->x + dr->width - 2, dr->y + 2, 1, 1);
draw_util_rectangle(&(con->parent->frame_buffer), p->color->border,
dr->x + dr->width - 1, dr->y + 3, 1, dr->height - 3);
/* AA */
draw_util_rectangle(&(con->parent->frame_buffer),
gradient_inner,
dr->x + dr->width - 1, dr->y + 2, 1, 1);
draw_util_rectangle(&(con->parent->frame_buffer),
gradient_inner,
dr->x + dr->width - 3, dr->y, 1, 1);
draw_util_rectangle(&(con->parent->frame_buffer),
gradient_outer,
dr->x + dr->width - 1, dr->y + 1, 1, 1);
draw_util_rectangle(&(con->parent->frame_buffer),
gradient_outer,
dr->x + dr->width - 2, dr->y, 1, 1);
}

/* draw_util_rectangle(&(con->parent->frame_buffer), p->color->border, */
/* dr->x + deco_diff_l, dr->y + dr->height - 1, dr->width - (deco_diff_l + deco_diff_r), 1); */
}

static void x_draw_decoration_after_title(Con *con, struct deco_render_params *p) {
Expand All @@ -377,12 +415,21 @@ static void x_draw_decoration_after_title(Con *con, struct deco_render_params *p
* be easily distinguished. */
if (con->parent->layout == L_TABBED) {
/* Left side */
draw_util_rectangle(&(con->parent->frame_buffer), p->color->border,
dr->x, dr->y, 1, dr->height);
/* draw_util_rectangle(&(con->parent->frame_buffer), p->color->border, */
/* dr->x, dr->y, 1, dr->height); */

/* Right side */
draw_util_rectangle(&(con->parent->frame_buffer), p->color->border,
dr->x + dr->width - 1, dr->y, 1, dr->height);
if (TAILQ_NEXT(con, nodes) != NULL) {
draw_util_rectangle(&(con->parent->frame_buffer), p->color->background,
dr->x + dr->width - 3, dr->y + 1, 6, dr->height - 1);
draw_util_rectangle(&(con->parent->frame_buffer), p->color->border,
dr->x + dr->width - 3, dr->y, 6, 1);
draw_util_rectangle(&(con->parent->frame_buffer), draw_util_hex_to_color("#ffffff24"),
dr->x + dr->width - 3, dr->y + 1, 8, 1);

draw_util_rectangle(&(con->parent->frame_buffer), draw_util_hex_to_color("#ffffff24"),
dr->x + dr->width, dr->y + 6, 1, 14);
}
}

/* Redraw the border. */
Expand Down Expand Up @@ -556,7 +603,21 @@ void x_draw_decoration(Con *con) {

/* 4: paint the bar */
draw_util_rectangle(&(parent->frame_buffer), p->color->background,
con->deco_rect.x, con->deco_rect.y, con->deco_rect.width, con->deco_rect.height);
con->deco_rect.x + 3, con->deco_rect.y + 1, con->deco_rect.width - 6, 1);
draw_util_rectangle(&(parent->frame_buffer), p->color->background,
con->deco_rect.x + 2, con->deco_rect.y + 2, con->deco_rect.width - 4, 1);
draw_util_rectangle(&(parent->frame_buffer), p->color->background,
con->deco_rect.x + 1, con->deco_rect.y + 3, con->deco_rect.width - 2, con->deco_rect.height - 2);
draw_util_rectangle(&(parent->frame_buffer), p->color->background,
con->deco_rect.x + 3, con->deco_rect.y + 1, con->deco_rect.width - 6, 1);
if (con->parent->layout != L_TABBED || con == TAILQ_FIRST(&(con->parent->nodes_head))) {
draw_util_rectangle(&(parent->frame_buffer), p->color->background,
con->deco_rect.x + 2, con->deco_rect.y + 2, 1, 1);
}
if (con->parent->layout != L_TABBED || TAILQ_NEXT(con, nodes) != NULL) {
draw_util_rectangle(&(parent->frame_buffer), p->color->background,
con->deco_rect.x + con->deco_rect.width - 3, con->deco_rect.y + 2, 1, 1);
}

/* 5: draw two unconnected horizontal lines in border color */
x_draw_title_border(con, p);
Expand Down Expand Up @@ -1137,7 +1198,7 @@ void x_push_changes(Con *con) {
to_focus, focused, focused->name);
send_take_focus(to_focus, last_timestamp);

change_ewmh_focus((con_has_managed_window(focused) ? focused->window->id : XCB_WINDOW_NONE), last_focused);
ewmh_update_active_window((con_has_managed_window(focused) ? focused->window->id : XCB_WINDOW_NONE));

if (to_focus != last_focused && is_con_attached(focused))
ipc_send_window_event("focus", focused);
Expand All @@ -1156,7 +1217,7 @@ void x_push_changes(Con *con) {
xcb_change_window_attributes(conn, focused->window->id, XCB_CW_EVENT_MASK, values);
}

change_ewmh_focus((con_has_managed_window(focused) ? focused->window->id : XCB_WINDOW_NONE), last_focused);
ewmh_update_active_window((con_has_managed_window(focused) ? focused->window->id : XCB_WINDOW_NONE));

if (to_focus != XCB_NONE && to_focus != last_focused && focused->window != NULL && is_con_attached(focused))
ipc_send_window_event("focus", focused);
Expand All @@ -1171,8 +1232,7 @@ void x_push_changes(Con *con) {
* root window in order to avoid an X11 fallback mechanism causing a ghosting effect (see #1378). */
DLOG("Still no window focused, better set focus to the EWMH support window (%d)\n", ewmh_window);
xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, ewmh_window, last_timestamp);
change_ewmh_focus(XCB_WINDOW_NONE, last_focused);

ewmh_update_active_window(XCB_WINDOW_NONE);
focused_id = ewmh_window;
}

Expand Down

0 comments on commit 83a12f7

Please sign in to comment.