Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix active window not working on the framebuffer #94

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comments.


void twin_window_queue_paint(twin_window_t *window);

bool twin_window_dispatch(twin_window_t *window, twin_event_t *event);
Expand Down
39 changes: 1 addition & 38 deletions src/screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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;
Expand Down
19 changes: 14 additions & 5 deletions src/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you change this function from static to non-static?

{
twin_fixed_t bw = twin_int_to_fixed(TWIN_TITLE_BW);
twin_path_t *path;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 &&
Expand Down