mirror of
https://github.com/yshui/picom.git
synced 2025-04-14 17:53:25 -04:00
event: use dynarr for expose_rects
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
48dd0cf72d
commit
5e16eeddd8
3 changed files with 18 additions and 28 deletions
|
@ -272,12 +272,9 @@ typedef struct session {
|
|||
|
||||
// === Expose event related ===
|
||||
/// Pointer to an array of <code>XRectangle</code>-s of exposed region.
|
||||
/// XXX why do we need this array?
|
||||
/// This is a reuse temporary buffer for handling root expose events.
|
||||
/// This is a dynarr.
|
||||
rect_t *expose_rects;
|
||||
/// Number of <code>XRectangle</code>-s in <code>expose_rects</code>.
|
||||
int size_expose;
|
||||
/// Index of the next free slot in <code>expose_rects</code>.
|
||||
int n_expose;
|
||||
|
||||
struct wm *wm;
|
||||
|
||||
|
|
33
src/event.c
33
src/event.c
|
@ -22,6 +22,7 @@
|
|||
#include "log.h"
|
||||
#include "picom.h"
|
||||
#include "region.h"
|
||||
#include "utils/dynarr.h"
|
||||
#include "utils/misc.h"
|
||||
#include "wm/defs.h"
|
||||
#include "wm/wm.h"
|
||||
|
@ -495,9 +496,9 @@ static inline void ev_circulate_notify(session_t *ps, xcb_circulate_notify_event
|
|||
}
|
||||
}
|
||||
|
||||
static inline void expose_root(session_t *ps, const rect_t *rects, int nrects) {
|
||||
static inline void expose_root(session_t *ps, const rect_t *rects, size_t nrects) {
|
||||
region_t region;
|
||||
pixman_region32_init_rects(®ion, rects, nrects);
|
||||
pixman_region32_init_rects(®ion, rects, (int)nrects);
|
||||
add_damage(ps, ®ion);
|
||||
pixman_region32_fini(®ion);
|
||||
}
|
||||
|
@ -505,27 +506,19 @@ static inline void expose_root(session_t *ps, const rect_t *rects, int nrects) {
|
|||
static inline void ev_expose(session_t *ps, xcb_expose_event_t *ev) {
|
||||
if (ev->window == ps->c.screen_info->root ||
|
||||
(ps->overlay && ev->window == ps->overlay)) {
|
||||
int more = ev->count + 1;
|
||||
if (ps->n_expose == ps->size_expose) {
|
||||
if (ps->expose_rects) {
|
||||
ps->expose_rects =
|
||||
crealloc(ps->expose_rects, ps->size_expose + more);
|
||||
ps->size_expose += more;
|
||||
} else {
|
||||
ps->expose_rects = ccalloc(more, rect_t);
|
||||
ps->size_expose = more;
|
||||
}
|
||||
}
|
||||
dynarr_reserve(ps->expose_rects, ev->count + 1);
|
||||
|
||||
ps->expose_rects[ps->n_expose].x1 = ev->x;
|
||||
ps->expose_rects[ps->n_expose].y1 = ev->y;
|
||||
ps->expose_rects[ps->n_expose].x2 = ev->x + ev->width;
|
||||
ps->expose_rects[ps->n_expose].y2 = ev->y + ev->height;
|
||||
ps->n_expose++;
|
||||
rect_t new_rect = {
|
||||
.x1 = ev->x,
|
||||
.y1 = ev->y,
|
||||
.x2 = ev->x + ev->width,
|
||||
.y2 = ev->y + ev->height,
|
||||
};
|
||||
dynarr_push(ps->expose_rects, new_rect);
|
||||
|
||||
if (ev->count == 0) {
|
||||
expose_root(ps, ps->expose_rects, ps->n_expose);
|
||||
ps->n_expose = 0;
|
||||
expose_root(ps, ps->expose_rects, dynarr_len(ps->expose_rects));
|
||||
dynarr_clear_pod(ps->expose_rects);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
#include "renderer/command_builder.h"
|
||||
#include "renderer/layout.h"
|
||||
#include "renderer/renderer.h"
|
||||
#include "utils/dynarr.h"
|
||||
#include "utils/file_watch.h"
|
||||
#include "utils/kernel.h"
|
||||
#include "utils/list.h"
|
||||
|
@ -2020,8 +2021,6 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
|
|||
.quit = false,
|
||||
|
||||
.expose_rects = NULL,
|
||||
.size_expose = 0,
|
||||
.n_expose = 0,
|
||||
|
||||
.black_picture = XCB_NONE,
|
||||
.cshadow_picture = XCB_NONE,
|
||||
|
@ -2521,6 +2520,7 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
|
|||
}
|
||||
|
||||
ps->command_builder = command_builder_new();
|
||||
ps->expose_rects = dynarr_new(rect_t, 0);
|
||||
|
||||
ps->pending_updates = true;
|
||||
|
||||
|
@ -2591,7 +2591,7 @@ static void session_destroy(session_t *ps) {
|
|||
free_paint(ps, &ps->tgt_buffer);
|
||||
|
||||
pixman_region32_fini(&ps->screen_reg);
|
||||
free(ps->expose_rects);
|
||||
dynarr_free_pod(ps->expose_rects);
|
||||
|
||||
x_free_monitor_info(&ps->monitors);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue