common.h: more clean up

Remove more unused stuff.

Also removed session::xinerama_scrs, since all the information we need
is covered by xinerama_scr_regs. Convert uses of xinerama_scrs to use
xinerama_scr_regs.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-05-06 02:03:07 +01:00
parent a409913c5f
commit 16ea51bbc1
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
5 changed files with 39 additions and 91 deletions

View File

@ -29,24 +29,12 @@
// For some special functions // For some special functions
#include <assert.h> #include <assert.h>
#include <ctype.h>
#include <inttypes.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h> #include <sys/time.h>
#include <time.h> #include <time.h>
#include <ev.h> #include <ev.h>
#include <pixman.h> #include <pixman.h>
#include <xcb/composite.h>
#include <xcb/damage.h>
#include <xcb/randr.h>
#include <xcb/render.h>
#include <xcb/shape.h>
#include <xcb/sync.h>
#include <xcb/xinerama.h>
#include "uthash_extra.h" #include "uthash_extra.h"
#ifdef CONFIG_OPENGL #ifdef CONFIG_OPENGL
@ -77,12 +65,7 @@
#include "win.h" #include "win.h"
#include "x.h" #include "x.h"
// === Constants === // === Constants ===0
#define ROUNDED_PERCENT 0.05
#define ROUNDED_PIXELS 10
#define SWOPTI_TOLERANCE 3000
#define NS_PER_SEC 1000000000L #define NS_PER_SEC 1000000000L
#define US_PER_SEC 1000000L #define US_PER_SEC 1000000L
@ -98,6 +81,7 @@
// === Types === // === Types ===
typedef struct glx_fbconfig glx_fbconfig_t; typedef struct glx_fbconfig glx_fbconfig_t;
struct glx_session;
struct atom; struct atom;
/// Structure representing needed window updates. /// Structure representing needed window updates.
@ -113,30 +97,6 @@ typedef struct _ignore {
unsigned long sequence; unsigned long sequence;
} ignore_t; } ignore_t;
enum wincond_target {
CONDTGT_NAME,
CONDTGT_CLASSI,
CONDTGT_CLASSG,
CONDTGT_ROLE,
};
enum wincond_type {
CONDTP_EXACT,
CONDTP_ANYWHERE,
CONDTP_FROMSTART,
CONDTP_WILDCARD,
CONDTP_REGEX_PCRE,
};
#define CONDF_IGNORECASE 0x0001
/// @brief Possible swap methods.
enum { SWAPM_BUFFER_AGE = -1,
SWAPM_UNDEFINED = 0,
SWAPM_COPY = 1,
SWAPM_EXCHANGE = 2,
};
typedef struct _glx_texture glx_texture_t; typedef struct _glx_texture glx_texture_t;
#ifdef CONFIG_OPENGL #ifdef CONFIG_OPENGL
@ -205,24 +165,6 @@ typedef struct _latom {
#define REG_DATA_INIT \ #define REG_DATA_INIT \
{ NULL, 0 } { NULL, 0 }
#ifdef CONFIG_OPENGL
/// Structure containing GLX-dependent data for a compton session.
typedef struct {
// === OpenGL related ===
/// GLX context.
GLXContext context;
/// Whether we have GL_ARB_texture_non_power_of_two.
bool has_texture_non_power_of_two;
/// Current GLX Z value.
int z;
glx_blur_pass_t blur_passes[MAX_BLUR_PASS];
} glx_session_t;
#define CGLX_SESSION_INIT \
{ .context = NULL }
#endif // CONFIG_OPENGL
/// Structure containing all necessary data for a compton session. /// Structure containing all necessary data for a compton session.
typedef struct session { typedef struct session {
// === Event handlers === // === Event handlers ===
@ -292,9 +234,9 @@ typedef struct session {
xcb_window_t reg_win; xcb_window_t reg_win;
#ifdef CONFIG_OPENGL #ifdef CONFIG_OPENGL
/// Pointer to GLX data. /// Pointer to GLX data.
glx_session_t *psglx; struct glx_session *psglx;
/// Custom GLX program used for painting window. /// Custom GLX program used for painting window.
// XXX should be in glx_session_t // XXX should be in struct glx_session
glx_prog_main_t glx_prog_win; glx_prog_main_t glx_prog_win;
#endif #endif
/// Sync fence to sync draw operations /// Sync fence to sync draw operations
@ -431,8 +373,6 @@ typedef struct session {
#endif #endif
/// Whether X Xinerama extension exists. /// Whether X Xinerama extension exists.
bool xinerama_exists; bool xinerama_exists;
/// Xinerama screen info.
xcb_xinerama_query_screens_reply_t *xinerama_scrs;
/// Xinerama screen regions. /// Xinerama screen regions.
region_t *xinerama_scr_regs; region_t *xinerama_scr_regs;
/// Number of Xinerama screens. /// Number of Xinerama screens.
@ -461,14 +401,6 @@ typedef struct session {
int (*vsync_wait)(session_t *); int (*vsync_wait)(session_t *);
} session_t; } session_t;
/// Temporary structure used for communication between
/// <code>get_cfg()</code> and <code>parse_config()</code>.
struct options_tmp {
bool no_dock_shadow;
bool no_dnd_shadow;
double menu_opacity;
};
/// Enumeration for window event hints. /// Enumeration for window event hints.
typedef enum { WIN_EVMODE_UNKNOWN, WIN_EVMODE_FRAME, WIN_EVMODE_CLIENT } win_evmode_t; typedef enum { WIN_EVMODE_UNKNOWN, WIN_EVMODE_FRAME, WIN_EVMODE_CLIENT } win_evmode_t;

View File

@ -23,6 +23,7 @@
#include <xcb/render.h> #include <xcb/render.h>
#include <xcb/sync.h> #include <xcb/sync.h>
#include <xcb/xfixes.h> #include <xcb/xfixes.h>
#include <xcb/xinerama.h>
#include <ev.h> #include <ev.h>
#include <test.h> #include <test.h>
@ -62,6 +63,8 @@
(session_t *)((char *)__mptr - offsetof(session_t, member)); \ (session_t *)((char *)__mptr - offsetof(session_t, member)); \
}) })
static const long SWOPTI_TOLERANCE = 3000;
static bool must_use redir_start(session_t *ps); static bool must_use redir_start(session_t *ps);
static void redir_stop(session_t *ps); static void redir_stop(session_t *ps);
@ -108,8 +111,6 @@ static inline void free_xinerama_info(session_t *ps) {
pixman_region32_fini(&ps->xinerama_scr_regs[i]); pixman_region32_fini(&ps->xinerama_scr_regs[i]);
free(ps->xinerama_scr_regs); free(ps->xinerama_scr_regs);
} }
free(ps->xinerama_scrs);
ps->xinerama_scrs = NULL;
ps->xinerama_nscrs = 0; ps->xinerama_nscrs = 0;
} }
@ -138,14 +139,15 @@ void cxinerama_upd_scrs(session_t *ps) {
} }
free(active); free(active);
ps->xinerama_scrs = auto xinerama_scrs =
xcb_xinerama_query_screens_reply(ps->c, xcb_xinerama_query_screens(ps->c), NULL); xcb_xinerama_query_screens_reply(ps->c, xcb_xinerama_query_screens(ps->c), NULL);
if (!ps->xinerama_scrs) if (!xinerama_scrs) {
return; return;
}
xcb_xinerama_screen_info_t *scrs = xcb_xinerama_screen_info_t *scrs =
xcb_xinerama_query_screens_screen_info(ps->xinerama_scrs); xcb_xinerama_query_screens_screen_info(xinerama_scrs);
ps->xinerama_nscrs = xcb_xinerama_query_screens_screen_info_length(ps->xinerama_scrs); ps->xinerama_nscrs = xcb_xinerama_query_screens_screen_info_length(xinerama_scrs);
ps->xinerama_scr_regs = ccalloc(ps->xinerama_nscrs, region_t); ps->xinerama_scr_regs = ccalloc(ps->xinerama_nscrs, region_t);
for (int i = 0; i < ps->xinerama_nscrs; ++i) { for (int i = 0; i < ps->xinerama_nscrs; ++i) {
@ -153,6 +155,7 @@ void cxinerama_upd_scrs(session_t *ps) {
pixman_region32_init_rect(&ps->xinerama_scr_regs[i], s->x_org, s->y_org, pixman_region32_init_rect(&ps->xinerama_scr_regs[i], s->x_org, s->y_org,
s->width, s->height); s->width, s->height);
} }
free(xinerama_scrs);
} }
/** /**

View File

@ -3,6 +3,7 @@
#include <X11/Xlibint.h> #include <X11/Xlibint.h>
#include <X11/extensions/sync.h> #include <X11/extensions/sync.h>
#include <xcb/randr.h>
#include "atom.h" #include "atom.h"
#include "common.h" #include "common.h"

View File

@ -26,6 +26,21 @@
#include <xcb/render.h> #include <xcb/render.h>
#include <xcb/xcb.h> #include <xcb/xcb.h>
/// Structure containing GLX-dependent data for a compton session.
typedef struct glx_session {
// === OpenGL related ===
/// GLX context.
GLXContext context;
/// Whether we have GL_ARB_texture_non_power_of_two.
bool has_texture_non_power_of_two;
/// Current GLX Z value.
int z;
glx_blur_pass_t blur_passes[MAX_BLUR_PASS];
} glx_session_t;
#define CGLX_SESSION_INIT \
{ .context = NULL }
bool glx_dim_dst(session_t *ps, int dx, int dy, int width, int height, int z, bool glx_dim_dst(session_t *ps, int dx, int dy, int width, int height, int z,
GLfloat factor, const region_t *reg_tgt); GLfloat factor, const region_t *reg_tgt);

View File

@ -13,6 +13,7 @@
#include <xcb/render.h> #include <xcb/render.h>
#include <xcb/xcb.h> #include <xcb/xcb.h>
#include <xcb/xcb_renderutil.h> #include <xcb/xcb_renderutil.h>
#include <xcb/xinerama.h>
#include "atom.h" #include "atom.h"
#include "backend/backend.h" #include "backend/backend.h"
@ -42,8 +43,10 @@
#include "win.h" #include "win.h"
#define OPAQUE 0xffffffff static const opacity_t OPAQUE = 0xffffffff;
#define WIN_GET_LEADER_MAX_RECURSION 20 static const int WIN_GET_LEADER_MAX_RECURSION = 20;
static const int ROUNDED_PIXELS = 1;
static const double ROUNDED_PERCENT = 0.05;
/// Generate a "return by value" function, from a function that returns the /// Generate a "return by value" function, from a function that returns the
/// region via a region_t pointer argument. /// region via a region_t pointer argument.
@ -1839,17 +1842,11 @@ void win_skip_fading(session_t *ps, struct managed_win **_w) {
void win_update_screen(session_t *ps, struct managed_win *w) { void win_update_screen(session_t *ps, struct managed_win *w) {
w->xinerama_scr = -1; w->xinerama_scr = -1;
if (!ps->xinerama_scrs) for (int i = 0; i < ps->xinerama_nscrs; i++) {
return; auto e = pixman_region32_extents(&ps->xinerama_scr_regs[i]);
if (e->x1 <= w->g.x && e->y1 <= w->g.y &&
xcb_xinerama_screen_info_t *scrs = e->x2 >= w->g.x + w->widthb &&
xcb_xinerama_query_screens_screen_info(ps->xinerama_scrs); e->y2 >= w->g.y + w->heightb) {
int length = xcb_xinerama_query_screens_screen_info_length(ps->xinerama_scrs);
for (int i = 0; i < length; i++) {
xcb_xinerama_screen_info_t *s = &scrs[i];
if (s->x_org <= w->g.x && s->y_org <= w->g.y &&
s->x_org + s->width >= w->g.x + w->widthb &&
s->y_org + s->height >= w->g.y + w->heightb) {
w->xinerama_scr = i; w->xinerama_scr = i;
return; return;
} }