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

Experimental backends: fade/hide blur-texture for transparent windows #364

Merged
merged 5 commits into from
Apr 8, 2020
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ doxygen/
/src/backtrace-symbols.[ch]
/compton*.trace
*.orig
/tests/log
/tests/testcases/__pycache__/
24 changes: 21 additions & 3 deletions src/backend/backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,34 @@ void paint_all_new(session_t *ps, struct managed_win *t, bool ignore_damage) {
// itself is not opaque, only the frame is.

double blur_opacity = 1;
if (w->state == WSTATE_MAPPING) {
if (w->opacity < (1.0 / MAX_ALPHA)) {
// Hide blur for fully transparent windows.
blur_opacity = 0;
} else if (w->state == WSTATE_MAPPING) {
// Gradually increase the blur intensity during
// fading in.
assert(w->opacity <= w->opacity_target);
blur_opacity = w->opacity / w->opacity_target;
} else if (w->state == WSTATE_UNMAPPING ||
w->state == WSTATE_DESTROYING) {
// Gradually decrease the blur intensity during
// fading out.
blur_opacity =
w->opacity / win_calc_opacity_target(ps, w, true);
assert(w->opacity <= w->opacity_target_old);
blur_opacity = w->opacity / w->opacity_target_old;
} else if (w->state == WSTATE_FADING) {
if (w->opacity < w->opacity_target &&
w->opacity_target_old < (1.0 / MAX_ALPHA)) {
// Gradually increase the blur intensity during
// fading in.
assert(w->opacity <= w->opacity_target);
blur_opacity = w->opacity / w->opacity_target;
} else if (w->opacity > w->opacity_target &&
w->opacity_target < (1.0 / MAX_ALPHA)) {
// Gradually decrease the blur intensity during
// fading out.
assert(w->opacity <= w->opacity_target_old);
blur_opacity = w->opacity / w->opacity_target_old;
}
}
assert(blur_opacity >= 0 && blur_opacity <= 1);

Expand Down
11 changes: 2 additions & 9 deletions src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ static inline void ev_map_notify(session_t *ps, xcb_map_notify_event_t *ev) {
return;
}

win_queue_update(w, WIN_UPDATE_MAP);
win_set_flags(w, WIN_FLAGS_MAPPED);

// FocusIn/Out may be ignored when the window is unmapped, so we must
// recheck focus here
Expand Down Expand Up @@ -482,14 +482,7 @@ static inline void ev_property_notify(session_t *ps, xcb_property_notify_event_t
win_update_opacity_prop(ps, w);
// we cannot receive OPACITY change when window is destroyed
assert(w->state != WSTATE_DESTROYING);
w->opacity_target = win_calc_opacity_target(ps, w, false);
if (w->state == WSTATE_MAPPED) {
// See the winstate_t transition table
w->state = WSTATE_FADING;
}
if (!ps->redirected) {
CHECK(!win_skip_fading(ps, w));
}
win_update_opacity_target(ps, w);
}
}

Expand Down
23 changes: 7 additions & 16 deletions src/picom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1309,12 +1309,6 @@ static void handle_new_windows(session_t *ps) {
}

static void refresh_windows(session_t *ps) {
win_stack_foreach_managed_safe(w, &ps->window_stack) {
win_process_updates(ps, w);
}
}

static void refresh_stale_images(session_t *ps) {
win_stack_foreach_managed(w, &ps->window_stack) {
win_process_flags(ps, w);
}
Expand Down Expand Up @@ -1351,7 +1345,13 @@ static void handle_pending_updates(EV_P_ struct session *ps) {
// Call fill_win on new windows
handle_new_windows(ps);

// Process window updates
// Handle screen changes
// This HAS TO be called before refresh_windows, as handle_root_flags
// could call configure_root, which will release images and mark them
// stale.
handle_root_flags(ps);

// Process window flags
refresh_windows(ps);

{
Expand All @@ -1363,15 +1363,6 @@ static void handle_pending_updates(EV_P_ struct session *ps) {
free(r);
}

// Handle screen changes
// This HAS TO be called before refresh_stale_images, as handle_root_flags
// could call configure_root, which will release images and mark them
// stale.
handle_root_flags(ps);

// Refresh pixmaps and shadows
refresh_stale_images(ps);

e = xcb_request_check(ps->c, xcb_ungrab_server_checked(ps->c));
if (e) {
log_fatal_x_error(e, "failed to ungrab x server");
Expand Down
Loading