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, add the twin_window_frame() to update the
color when box is triggered by TwinEventButtonDown.
  • Loading branch information
weihsinyeh committed Jan 29, 2025
1 parent 0b0cc1f commit 512a891
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 24 deletions.
2 changes: 2 additions & 0 deletions include/twin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
41 changes: 17 additions & 24 deletions src/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,21 +156,8 @@ 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)
void twin_window_frame(twin_window_t *window)
{
twin_fixed_t bw = twin_int_to_fixed(TWIN_TITLE_BW);
twin_path_t *path;
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 512a891

Please sign in to comment.