Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfb38bf0

Browse files
authored
Merge pull request#546 from yshui/window-state-update
win: rework how events for unmapped windows are handled
2 parentsbf5a9ca +0f97561 commitfb38bf0

File tree

7 files changed

+282
-180
lines changed

7 files changed

+282
-180
lines changed

‎src/event.c

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -201,58 +201,55 @@ static void configure_win(session_t *ps, xcb_configure_notify_event_t *ce) {
201201

202202
automw= (structmanaged_win*)w;
203203

204-
if (mw->state==WSTATE_UNMAPPED||mw->state==WSTATE_UNMAPPING||
205-
mw->state==WSTATE_DESTROYING) {
206-
// Only restack the window to make sure we can handle future restack
207-
// notification correctly
208-
restack_above(ps,w,ce->above_sibling);
209-
}else {
210-
restack_above(ps,w,ce->above_sibling);
211-
212-
// If window geometry change, free old extents
213-
if (mw->g.x!=ce->x||mw->g.y!=ce->y||mw->g.width!=ce->width||
214-
mw->g.height!=ce->height||mw->g.border_width!=ce->border_width) {
215-
// We don't mark the old region as damaged if we have stale
216-
// shape/size/position information. The old region should have
217-
// already been add to damage when the information became stale.
218-
if (!win_check_flags_any(
219-
mw,WIN_FLAGS_SIZE_STALE |WIN_FLAGS_POSITION_STALE)) {
220-
// Mark the old extents as damaged.
221-
// The new extents will be marked damaged when processing
222-
// window flags.
204+
restack_above(ps,w,ce->above_sibling);
205+
206+
// If window geometry change, free old extents
207+
if (mw->g.x!=ce->x||mw->g.y!=ce->y||mw->g.width!=ce->width||
208+
mw->g.height!=ce->height||mw->g.border_width!=ce->border_width) {
209+
// We don't mark the old region as damaged if we have stale
210+
// shape/size/position information. The old region should have
211+
// already been add to damage when the information became stale.
212+
if (!win_check_flags_any(mw,WIN_FLAGS_SIZE_STALE |WIN_FLAGS_POSITION_STALE)) {
213+
if (mw->state!=WSTATE_UNMAPPED&&mw->state!=WSTATE_UNMAPPING&&
214+
mw->state!=WSTATE_DESTROYING) {
215+
// Mark the old extents as damaged. The new extents will
216+
// be marked damaged when processing window flags.
217+
// If the window is not mapped, we don't care
223218
region_tdamage;
224219
pixman_region32_init(&damage);
225220
win_extents(mw,&damage);
226221
add_damage(ps,&damage);
227222
pixman_region32_fini(&damage);
228223
}
224+
}
229225

230-
// Queue pending updates
231-
win_set_flags(mw,WIN_FLAGS_FACTOR_CHANGED);
232-
ps->pending_updates= true;
233-
234-
// At least one of the following if's is true
235-
if (mw->g.x!=ce->x||mw->g.y!=ce->y) {
236-
log_trace("Window position changed, %dx%d -> %dx%d",
237-
mw->g.x,mw->g.y,ce->x,ce->y);
238-
mw->g.x=ce->x;
239-
mw->g.y=ce->y;
240-
win_set_flags(mw,WIN_FLAGS_POSITION_STALE);
241-
}
226+
// Queue pending updates
227+
win_set_flags(mw,WIN_FLAGS_FACTOR_CHANGED);
228+
// TODO(yshui) don't set pending_updates if the window is not
229+
// visible/mapped
230+
ps->pending_updates= true;
242231

243-
if (mw->g.width!=ce->width||mw->g.height!=ce->height||
244-
mw->g.border_width!=ce->border_width) {
245-
log_trace("Window size changed, %dx%d -> %dx%d",
246-
mw->g.width,mw->g.height,ce->width,ce->height);
247-
mw->g.width=ce->width;
248-
mw->g.height=ce->height;
249-
mw->g.border_width=ce->border_width;
250-
win_set_flags(mw,WIN_FLAGS_SIZE_STALE);
251-
}
232+
// At least one of the following if's is true
233+
if (mw->g.x!=ce->x||mw->g.y!=ce->y) {
234+
log_trace("Window position changed, %dx%d -> %dx%d",mw->g.x,
235+
mw->g.y,ce->x,ce->y);
236+
mw->g.x=ce->x;
237+
mw->g.y=ce->y;
238+
win_set_flags(mw,WIN_FLAGS_POSITION_STALE);
239+
}
252240

253-
// Recalculate which screen this window is on
254-
win_update_screen(ps->xinerama_nscrs,ps->xinerama_scr_regs,mw);
241+
if (mw->g.width!=ce->width||mw->g.height!=ce->height||
242+
mw->g.border_width!=ce->border_width) {
243+
log_trace("Window size changed, %dx%d -> %dx%d",mw->g.width,
244+
mw->g.height,ce->width,ce->height);
245+
mw->g.width=ce->width;
246+
mw->g.height=ce->height;
247+
mw->g.border_width=ce->border_width;
248+
win_set_flags(mw,WIN_FLAGS_SIZE_STALE);
255249
}
250+
251+
// Recalculate which screen this window is on
252+
win_update_screen(ps->xinerama_nscrs,ps->xinerama_scr_regs,mw);
256253
}
257254

258255
// override_redirect flag cannot be changed after window creation, as far

‎src/picom.c

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,20 @@ static void destroy_backend(session_t *ps) {
402402
}
403403

404404
if (ps->backend_data) {
405-
if (w->state==WSTATE_MAPPED) {
406-
win_release_images(ps->backend_data,w);
407-
}else {
408-
assert(!w->win_image);
409-
assert(!w->shadow_image);
405+
// Unmapped windows could still have shadow images, but not pixmap
406+
// images
407+
assert(!w->win_image||w->state!=WSTATE_UNMAPPED);
408+
if (win_check_flags_any(w,WIN_FLAGS_IMAGES_STALE)&&
409+
w->state==WSTATE_MAPPED) {
410+
log_warn("Stale flags set for mapped window %#010x "
411+
"during backend destruction",
412+
w->base.id);
413+
assert(false);
410414
}
415+
// Unmapped windows can still have stale flags set, because their
416+
// stale flags aren't handled until they are mapped.
417+
win_clear_flags(w,WIN_FLAGS_IMAGES_STALE);
418+
win_release_images(ps->backend_data,w);
411419
}
412420
free_paint(ps,&w->paint);
413421
}
@@ -495,25 +503,12 @@ static bool initialize_backend(session_t *ps) {
495503
}
496504
autow= (structmanaged_win*)_w;
497505
assert(w->state==WSTATE_MAPPED||w->state==WSTATE_UNMAPPED);
498-
if (w->state==WSTATE_MAPPED) {
499-
// We need to reacquire image
500-
log_debug("Marking window %#010x (%s) for update after "
501-
"redirection",
502-
w->base.id,w->name);
503-
if (w->shadow) {
504-
structcolorc= {
505-
.red=ps->o.shadow_red,
506-
.green=ps->o.shadow_green,
507-
.blue=ps->o.shadow_blue,
508-
.alpha=ps->o.shadow_opacity,
509-
};
510-
win_bind_shadow(ps->backend_data,w,c,
511-
ps->gaussian_map);
512-
}
513-
514-
w->flags |=WIN_FLAGS_PIXMAP_STALE;
515-
ps->pending_updates= true;
516-
}
506+
// We need to reacquire image
507+
log_debug("Marking window %#010x (%s) for update after "
508+
"redirection",
509+
w->base.id,w->name);
510+
win_set_flags(w,WIN_FLAGS_IMAGES_STALE);
511+
ps->pending_updates= true;
517512
}
518513
}
519514

@@ -1354,10 +1349,7 @@ static void handle_new_windows(session_t *ps) {
13541349
}
13551350
automw= (structmanaged_win*)new_w;
13561351
if (mw->a.map_state==XCB_MAP_STATE_VIEWABLE) {
1357-
// Have to map immediately instead of queue window update
1358-
// because we need the window's extent right now.
1359-
// We can do this because we are in the critical section.
1360-
map_win_start(ps,mw);
1352+
win_set_flags(mw,WIN_FLAGS_MAPPED);
13611353

13621354
// This window might be damaged before we called fill_win
13631355
// and created the damage handle. And there is no way for

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp