Skip to content

Commit

Permalink
Fix the box trigger causing change order of pixmap
Browse files Browse the repository at this point in the history
When the box is trigger by TwinEventButtonDown, its window's title bar
needs to change color and be put onto the toppest layer. However, after
removing the implementation of changing the color of window's title bar
from the function twin_screen_update(), it will only be putted onto the
toppest layer. Therefore, change the location where twin_window_frame()
is called to ensure that the color is updated whenever the box or window
is triggered by TwinEventButtonDown.

Signed-off-by: Wei-Hsin Yeh <[email protected]>
  • Loading branch information
weihsinyeh committed Jan 31, 2025
1 parent 0b0cc1f commit 9c7e0d9
Showing 1 changed file with 16 additions and 23 deletions.
39 changes: 16 additions & 23 deletions src/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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 &&
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9c7e0d9

Please sign in to comment.