Window state tracking refactor
Window state tracking is basically the back bond of window fading. We add a new enum field to the win struct to track the state of the window, instead of using a set of boolean variables. We also remove the fading callbacks, since it is only used for fading, so the potential of code reuse is lost. And it makes the code slightly harder to understand. Also fixed a problem that --no-fading-openclose is not behaving as advertised (from my observation, enabling this flag disables fading entirely, instead of just diabling it for open/close). Also uses double for opacity everywhere internally. Use opacity_t only when setting X opacity prop. TODO: Remove win::*_last Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
@ -3,11 +3,11 @@
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
#include "backend.h"
|
||||
#include "config.h"
|
||||
#include "win.h"
|
||||
#include "region.h"
|
||||
#include "common.h"
|
||||
#include "compiler.h"
|
||||
#include "config.h"
|
||||
#include "region.h"
|
||||
#include "win.h"
|
||||
|
||||
backend_info_t *backend_list[NUM_BKEND] = {
|
||||
[BKEND_XRENDER] = &xrender_backend,
|
||||
@ -107,8 +107,7 @@ void paint_all_new(session_t *ps, win *const t, bool ignore_damage) {
|
||||
®_noframe);
|
||||
pixman_region32_fini(®_noframe);
|
||||
}
|
||||
bi->blur(ps->backend_data, ps,
|
||||
(double)w->opacity / OPAQUE, ®_blur);
|
||||
bi->blur(ps->backend_data, ps, w->opacity, ®_blur);
|
||||
pixman_region32_fini(®_blur);
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ static void compose(void *backend_data, session_t *ps, win *w, void *win_data, i
|
||||
bool blend = default_is_frame_transparent(NULL, w, win_data) ||
|
||||
default_is_win_transparent(NULL, w, win_data);
|
||||
int op = (blend ? XCB_RENDER_PICT_OP_OVER : XCB_RENDER_PICT_OP_SRC);
|
||||
auto alpha_pict = xd->alpha_pict[(int)(((double)w->opacity / OPAQUE) * 255.0)];
|
||||
auto alpha_pict = xd->alpha_pict[(int)(w->opacity * 255.0)];
|
||||
|
||||
// XXX Move shadow drawing into a separate function,
|
||||
// also do shadow excluding outside of backend
|
||||
@ -290,7 +290,6 @@ render_win(void *backend_data, session_t *ps, win *w, void *win_data, const regi
|
||||
0, 0, 0, 0, w->widthb, w->heightb);
|
||||
}
|
||||
|
||||
const double dopacity = get_opacity_percent(w);
|
||||
if (w->frame_opacity != 1) {
|
||||
// Handle transparent frame
|
||||
// Step 1: clip paint area to frame
|
||||
@ -303,7 +302,7 @@ render_win(void *backend_data, session_t *ps, win *w, void *win_data, const regi
|
||||
|
||||
// Draw the frame with frame opacity
|
||||
xcb_render_picture_t alpha_pict =
|
||||
xd->alpha_pict[(int)(w->frame_opacity * dopacity * 255)];
|
||||
xd->alpha_pict[(int)(w->frame_opacity * w->opacity * 255)];
|
||||
x_set_picture_clip_region(ps->c, wd->rendered_pict, 0, 0, &frame_reg);
|
||||
|
||||
// Step 2: multiply alpha value
|
||||
@ -317,7 +316,7 @@ render_win(void *backend_data, session_t *ps, win *w, void *win_data, const regi
|
||||
|
||||
double dim_opacity = ps->o.inactive_dim;
|
||||
if (!ps->o.inactive_dim_fixed)
|
||||
dim_opacity *= get_opacity_percent(w);
|
||||
dim_opacity *= w->opacity;
|
||||
|
||||
xcb_render_color_t color = {
|
||||
.red = 0, .green = 0, .blue = 0, .alpha = 0xffff * dim_opacity};
|
||||
|
Reference in New Issue
Block a user