diff --git a/include/twin.h b/include/twin.h index 834e57a..52a3c96 100644 --- a/include/twin.h +++ b/include/twin.h @@ -1173,6 +1173,8 @@ void twin_window_damage(twin_window_t *window, twin_coord_t right, twin_coord_t bottom); +void twin_window_frame(twin_window_t *window); + void twin_window_queue_paint(twin_window_t *window); bool twin_window_dispatch(twin_window_t *window, twin_event_t *event); diff --git a/src/screen.c b/src/screen.c index c3dfb2d..76bcfe2 100644 --- a/src/screen.c +++ b/src/screen.c @@ -151,25 +151,6 @@ static void twin_screen_span_pixmap(twin_screen_t maybe_unused *screen, op32(dst, src, p_right - p_left); } -static twin_pixmap_t *twin_active_pixmap(twin_screen_t *screen, - twin_pixmap_t **active_pix) -{ - twin_pixmap_t *p = NULL, *prev_active_pix = NULL; - /* - * Identify the previously active pixel map and the currently active pixel - * map, which is on the topmost layer. - */ - for (p = screen->bottom; p; p = p->up) { - if (p->window->active == true) { - prev_active_pix = p; - prev_active_pix->window->active = false; - } - (*active_pix) = p; - } - (*active_pix)->window->active = true; - return prev_active_pix; -} - void twin_screen_update(twin_screen_t *screen) { twin_coord_t left = screen->damage.left; @@ -189,7 +170,7 @@ void twin_screen_update(twin_screen_t *screen) if (!screen->disable && left < right && top < bottom) { twin_argb32_t *span; - twin_pixmap_t *p, *active_pix = NULL, *prev_active_pix = NULL; + twin_pixmap_t *p; twin_coord_t y; twin_coord_t width = right - left; @@ -202,24 +183,6 @@ void twin_screen_update(twin_screen_t *screen) if (screen->put_begin) (*screen->put_begin)(left, top, right, bottom, screen->closure); - - prev_active_pix = twin_active_pixmap(screen, &active_pix); - - /* - * Mark the previously active pixel map as damaged to update its - * changes. - */ - if (prev_active_pix && active_pix != prev_active_pix) { - twin_pixmap_damage(prev_active_pix, 0, 0, prev_active_pix->width, - prev_active_pix->height); - twin_window_draw(prev_active_pix->window); - } - - /* Mark the active pixel map as damaged to update its changes. */ - twin_pixmap_damage(active_pix, 0, 0, active_pix->width, - active_pix->height); - twin_window_draw(active_pix->window); - for (y = top; y < bottom; y++) { if (screen->background) { twin_pointer_t dst; diff --git a/src/window.c b/src/window.c index 59696fd..2756a4e 100644 --- a/src/window.c +++ b/src/window.c @@ -157,7 +157,7 @@ void twin_window_set_name(twin_window_t *window, const char *name) twin_window_draw(window); } -static void twin_window_frame(twin_window_t *window) +void twin_window_frame(twin_window_t *window) { twin_fixed_t bw = twin_int_to_fixed(TWIN_TITLE_BW); twin_path_t *path; @@ -229,11 +229,11 @@ static void twin_window_frame(twin_window_t *window) twin_path_close(path); if (window->active) { - twin_paint_path(pixmap, TWIN_ACTIVE_BG, path); - twin_paint_stroke(pixmap, TWIN_ACTIVE_BORDER, path, bw_2 * 2); + 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(pixmap, TWIN_INACTIVE_BG, path); - twin_paint_stroke(pixmap, TWIN_INACTIVE_BORDER, path, bw_2 * 2); + 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); @@ -387,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 &&