Skip to content

Commit 2d1c1a4

Browse files
committed
Fix iconified pixmap check condition
Add twin_pixmap_is_iconified() function to determine whether a pixmap is iconified. This function provides a way to access the corresponding window's iconify state, after verifying that the pixmap belongs to a window. Signed-off-by: Wei-Hsin Yeh <[email protected]>
1 parent 5eb41fa commit 2d1c1a4

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
lines changed

include/twin.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,8 @@ bool twin_pixmap_transparent(twin_pixmap_t *pixmap,
10361036
twin_coord_t x,
10371037
twin_coord_t y);
10381038

1039+
bool twin_pixmap_is_iconified(twin_pixmap_t *pixmap, twin_coord_t y);
1040+
10391041
bool twin_pixmap_dispatch(twin_pixmap_t *pixmap, twin_event_t *event);
10401042

10411043
/*

src/pixmap.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
#include "twin_private.h"
1111

12+
#define TWIN_BW 0
13+
#define TWIN_TITLE_HEIGHT 20
14+
1215
#define IS_ALIGNED(p, alignment) ((p % alignment) == 0)
1316
#define ALIGN_UP(sz, alignment) \
1417
(((alignment) & ((alignment) - 1)) == 0 \
@@ -318,6 +321,19 @@ bool twin_pixmap_transparent(twin_pixmap_t *pixmap,
318321
return (_twin_pixmap_fetch(pixmap, x, y) >> 24) == 0;
319322
}
320323

324+
bool twin_pixmap_is_iconified(twin_pixmap_t *pixmap, twin_coord_t y)
325+
{
326+
/*
327+
* Check whether the specified area within the pixmap corresponds to an
328+
* iconified window.
329+
*/
330+
if (pixmap->window &&
331+
(pixmap->window->iconify &&
332+
y >= pixmap->y + TWIN_BW + TWIN_TITLE_HEIGHT + TWIN_BW))
333+
return true;
334+
return false;
335+
}
336+
321337
void twin_pixmap_move(twin_pixmap_t *pixmap, twin_coord_t x, twin_coord_t y)
322338
{
323339
twin_pixmap_damage(pixmap, 0, 0, pixmap->width, pixmap->height);

src/screen.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99

1010
#include "twin_private.h"
1111

12-
#define TWIN_BW 0
13-
#define TWIN_TITLE_HEIGHT 20
14-
1512
twin_screen_t *twin_screen_create(twin_coord_t width,
1613
twin_coord_t height,
1714
twin_put_begin_t put_begin,
@@ -139,10 +136,6 @@ static void twin_screen_span_pixmap(twin_screen_t maybe_unused *screen,
139136
if (p->y + p->height <= y)
140137
return;
141138

142-
/* Skip drawing the window's client area if the window is iconified. */
143-
if (p->window->iconify && y >= p->y + TWIN_BW + TWIN_TITLE_HEIGHT + TWIN_BW)
144-
return;
145-
146139
/* bounds check in x */
147140
p_left = left;
148141
if (p_left < p->x)
@@ -215,14 +208,20 @@ void twin_screen_update(twin_screen_t *screen)
215208
} else
216209
memset(span, 0xff, width * sizeof(twin_argb32_t));
217210

218-
for (p = screen->bottom; p; p = p->up)
219-
twin_screen_span_pixmap(screen, span, p, y, left, right, pop16,
220-
pop32);
211+
for (p = screen->bottom; p; p = p->up) {
212+
/* Skip drawing the region of the iconified pixmap. */
213+
if (!twin_pixmap_is_iconified(p, y))
214+
twin_screen_span_pixmap(screen, span, p, y, left, right,
215+
pop16, pop32);
216+
}
221217

222218
#if defined(CONFIG_CURSOR)
223-
if (screen->cursor)
224-
twin_screen_span_pixmap(screen, span, screen->cursor, y, left,
225-
right, pop16, pop32);
219+
if (screen->cursor) {
220+
/* Skip drawing the region of the iconified pixmap. */
221+
if (!twin_pixmap_is_iconified(p, y))
222+
twin_screen_span_pixmap(screen, span, screen->cursor, y,
223+
left, right, pop16, pop32);
224+
}
226225
#endif
227226

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

0 commit comments

Comments
 (0)