diff --git a/src/window.c b/src/window.c index a74f18a..6ebb3bc 100644 --- a/src/window.c +++ b/src/window.c @@ -156,19 +156,6 @@ void twin_window_set_name(twin_window_t *window, const char *name) strcpy(window->name, name); twin_window_draw(window); } -static void twin_window_active_paint(twin_window_t *window) -{ - twin_fixed_t bw = twin_int_to_fixed(TWIN_TITLE_BW); - twin_path_t *path = twin_path_create(); - twin_fixed_t bw_2 = bw / 2; - if (window->active) { - twin_paint_path(window->pixmap, TWIN_ACTIVE_BG, path); - twin_paint_stroke(window->pixmap, TWIN_ACTIVE_BORDER, path, bw_2 * 2); - } else { - twin_paint_path(window->pixmap, TWIN_INACTIVE_BG, path); - twin_paint_stroke(window->pixmap, TWIN_INACTIVE_BORDER, path, bw_2 * 2); - } -} static void twin_window_frame(twin_window_t *window) { @@ -241,7 +228,13 @@ static void twin_window_frame(twin_window_t *window) c_left, c_top); twin_path_close(path); - twin_window_active_paint(window); + if (window->active) { + twin_paint_path(window->pixmap, TWIN_ACTIVE_BG, path); + twin_paint_stroke(window->pixmap, TWIN_ACTIVE_BORDER, path, bw_2 * 2); + } else { + twin_paint_path(window->pixmap, TWIN_INACTIVE_BG, path); + twin_paint_stroke(window->pixmap, TWIN_INACTIVE_BORDER, path, bw_2 * 2); + } twin_path_empty(path); @@ -394,6 +387,15 @@ bool twin_window_dispatch(twin_window_t *window, twin_event_t *event) switch (ev.kind) { case TwinEventButtonDown: + /* Set window active. */ + if (window->pixmap != window->screen->top) { + window->active = true; + twin_window_frame(window); + if (window->screen->top) { + window->screen->top->window->active = false; + twin_window_frame(window->screen->top->window); + } + } if (window->client.left <= ev.u.pointer.x && ev.u.pointer.x < window->client.right && window->client.top <= ev.u.pointer.y && @@ -439,15 +441,6 @@ bool twin_window_dispatch(twin_window_t *window, twin_event_t *event) */ switch (event->kind) { case TwinEventButtonDown: - /* Set window active. */ - if (window->pixmap != window->screen->top) { - window->active = true; - twin_window_active_paint(window); - if (window->screen->top) { - window->screen->top->window->active = false; - twin_window_active_paint(window->screen->top->window); - } - } twin_window_show(window); window->screen->button_x = event->u.pointer.x; window->screen->button_y = event->u.pointer.y;