Skip to content

Fix iconified pixmap check condition #105

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

Merged
merged 1 commit into from
Jun 21, 2025
Merged
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 @@ -1036,6 +1036,8 @@ bool twin_pixmap_transparent(twin_pixmap_t *pixmap,
twin_coord_t x,
twin_coord_t y);

bool twin_pixmap_is_iconified(twin_pixmap_t *pixmap, twin_coord_t y);

bool twin_pixmap_dispatch(twin_pixmap_t *pixmap, twin_event_t *event);

/*
Expand Down
16 changes: 16 additions & 0 deletions src/pixmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

#include "twin_private.h"

#define TWIN_BW 0
#define TWIN_TITLE_HEIGHT 20

#define IS_ALIGNED(p, alignment) ((p % alignment) == 0)
#define ALIGN_UP(sz, alignment) \
(((alignment) & ((alignment) - 1)) == 0 \
Expand Down Expand Up @@ -318,6 +321,19 @@ bool twin_pixmap_transparent(twin_pixmap_t *pixmap,
return (_twin_pixmap_fetch(pixmap, x, y) >> 24) == 0;
}

bool twin_pixmap_is_iconified(twin_pixmap_t *pixmap, twin_coord_t y)
{
/*
* Check whether the specified area within the pixmap corresponds to an
* iconified window.
*/
if (pixmap->window &&
(pixmap->window->iconify &&
y >= pixmap->y + TWIN_BW + TWIN_TITLE_HEIGHT + TWIN_BW))
return true;
return false;
}

void twin_pixmap_move(twin_pixmap_t *pixmap, twin_coord_t x, twin_coord_t y)
{
twin_pixmap_damage(pixmap, 0, 0, pixmap->width, pixmap->height);
Expand Down
25 changes: 12 additions & 13 deletions src/screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

#include "twin_private.h"

#define TWIN_BW 0
#define TWIN_TITLE_HEIGHT 20

twin_screen_t *twin_screen_create(twin_coord_t width,
twin_coord_t height,
twin_put_begin_t put_begin,
Expand Down Expand Up @@ -139,10 +136,6 @@ static void twin_screen_span_pixmap(twin_screen_t maybe_unused *screen,
if (p->y + p->height <= y)
return;

/* Skip drawing the window's client area if the window is iconified. */
if (p->window->iconify && y >= p->y + TWIN_BW + TWIN_TITLE_HEIGHT + TWIN_BW)
return;

/* bounds check in x */
p_left = left;
if (p_left < p->x)
Expand Down Expand Up @@ -215,14 +208,20 @@ void twin_screen_update(twin_screen_t *screen)
} else
memset(span, 0xff, width * sizeof(twin_argb32_t));

for (p = screen->bottom; p; p = p->up)
twin_screen_span_pixmap(screen, span, p, y, left, right, pop16,
pop32);
for (p = screen->bottom; p; p = p->up) {
/* Skip drawing the region of the iconified pixmap. */
if (!twin_pixmap_is_iconified(p, y))
twin_screen_span_pixmap(screen, span, p, y, left, right,
pop16, pop32);
}

#if defined(CONFIG_CURSOR)
if (screen->cursor)
twin_screen_span_pixmap(screen, span, screen->cursor, y, left,
right, pop16, pop32);
if (screen->cursor) {
/* Skip drawing the region of the iconified pixmap. */
if (!twin_pixmap_is_iconified(p, y))
twin_screen_span_pixmap(screen, span, screen->cursor, y,
left, right, pop16, pop32);
}
#endif

(*screen->put_span)(left, y, right, span, screen->closure);
Expand Down