@@ -151,6 +151,25 @@ static void twin_screen_span_pixmap(twin_screen_t maybe_unused *screen,
151
151
op32 (dst , src , p_right - p_left );
152
152
}
153
153
154
+ static twin_pixmap_t * twin_active_pixmap (twin_screen_t * screen ,
155
+ twin_pixmap_t * * active_pix )
156
+ {
157
+ twin_pixmap_t * p = NULL , * prev_active_pix = NULL ;
158
+ /*
159
+ * Identify the previously active pixel map and the currently active pixel
160
+ * map, which is on the topmost layer.
161
+ */
162
+ for (p = screen -> bottom ; p ; p = p -> up ) {
163
+ if (p -> window -> active == true) {
164
+ prev_active_pix = p ;
165
+ prev_active_pix -> window -> active = false;
166
+ }
167
+ (* active_pix ) = p ;
168
+ }
169
+ (* active_pix )-> window -> active = true;
170
+ return prev_active_pix ;
171
+ }
172
+
154
173
void twin_screen_update (twin_screen_t * screen )
155
174
{
156
175
twin_coord_t left = screen -> damage .left ;
@@ -170,7 +189,7 @@ void twin_screen_update(twin_screen_t *screen)
170
189
171
190
if (!screen -> disable && left < right && top < bottom ) {
172
191
twin_argb32_t * span ;
173
- twin_pixmap_t * p ;
192
+ twin_pixmap_t * p , * active_pix = NULL , * prev_active_pix = NULL ;
174
193
twin_coord_t y ;
175
194
twin_coord_t width = right - left ;
176
195
@@ -183,6 +202,24 @@ void twin_screen_update(twin_screen_t *screen)
183
202
184
203
if (screen -> put_begin )
185
204
(* screen -> put_begin )(left , top , right , bottom , screen -> closure );
205
+
206
+ prev_active_pix = twin_active_pixmap (screen , & active_pix );
207
+
208
+ /*
209
+ * Mark the previously active pixel map as damaged to update its
210
+ * changes.
211
+ */
212
+ if (prev_active_pix && active_pix != prev_active_pix ) {
213
+ twin_pixmap_damage (prev_active_pix , 0 , 0 , prev_active_pix -> width ,
214
+ prev_active_pix -> height );
215
+ twin_window_draw (prev_active_pix -> window );
216
+ }
217
+
218
+ /* Mark the active pixel map as damaged to update its changes. */
219
+ twin_pixmap_damage (active_pix , 0 , 0 , active_pix -> width ,
220
+ active_pix -> height );
221
+ twin_window_draw (active_pix -> window );
222
+
186
223
for (y = top ; y < bottom ; y ++ ) {
187
224
if (screen -> background ) {
188
225
twin_pointer_t dst ;
0 commit comments