mirror of
https://github.com/yshui/picom.git
synced 2024-11-11 13:51:02 -05:00
common.h: cleanup, cont.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
16ea51bbc1
commit
cdb24ec99c
6 changed files with 50 additions and 72 deletions
20
src/c2.c
20
src/c2.c
|
@ -211,6 +211,26 @@ static const c2_predef_t C2_PREDEFS[] = {
|
|||
[C2_L_PROLE] = {"role", C2_L_TSTRING, 0},
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the numeric property value from a win_prop_t.
|
||||
*/
|
||||
static inline long winprop_get_int(winprop_t prop) {
|
||||
long tgt = 0;
|
||||
|
||||
if (!prop.nitems) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (prop.format) {
|
||||
case 8: tgt = *(prop.p8); break;
|
||||
case 16: tgt = *(prop.p16); break;
|
||||
case 32: tgt = *(prop.p32); break;
|
||||
default: assert(0); break;
|
||||
}
|
||||
|
||||
return tgt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare next word in a string with another string.
|
||||
*/
|
||||
|
|
67
src/common.h
67
src/common.h
|
@ -41,11 +41,6 @@
|
|||
#include "backend/gl/glx.h"
|
||||
#endif
|
||||
|
||||
// === Macros ===
|
||||
|
||||
#define MSTR_(s) #s
|
||||
#define MSTR(s) MSTR_(s)
|
||||
|
||||
// X resource checker
|
||||
#ifdef DEBUG_XRC
|
||||
#include "xrescheck.h"
|
||||
|
@ -56,13 +51,9 @@
|
|||
#include "backend/driver.h"
|
||||
#include "compiler.h"
|
||||
#include "config.h"
|
||||
#include "kernel.h"
|
||||
#include "log.h"
|
||||
#include "region.h"
|
||||
#include "render.h"
|
||||
#include "types.h"
|
||||
#include "utils.h"
|
||||
#include "win.h"
|
||||
#include "x.h"
|
||||
|
||||
// === Constants ===0
|
||||
|
@ -84,21 +75,11 @@ typedef struct glx_fbconfig glx_fbconfig_t;
|
|||
struct glx_session;
|
||||
struct atom;
|
||||
|
||||
/// Structure representing needed window updates.
|
||||
typedef struct {
|
||||
bool shadow : 1;
|
||||
bool fade : 1;
|
||||
bool focus : 1;
|
||||
bool invert_color : 1;
|
||||
} win_upd_t;
|
||||
|
||||
typedef struct _ignore {
|
||||
struct _ignore *next;
|
||||
unsigned long sequence;
|
||||
} ignore_t;
|
||||
|
||||
typedef struct _glx_texture glx_texture_t;
|
||||
|
||||
#ifdef CONFIG_OPENGL
|
||||
#ifdef DEBUG_GLX_DEBUG_CONTEXT
|
||||
typedef GLXContext (*f_glXCreateContextAttribsARB)(Display *dpy, GLXFBConfig config,
|
||||
|
@ -109,31 +90,6 @@ typedef void (*GLDEBUGPROC)(GLenum source, GLenum type, GLuint id, GLenum severi
|
|||
typedef void (*f_DebugMessageCallback)(GLDEBUGPROC, void *userParam);
|
||||
#endif
|
||||
|
||||
/// @brief Wrapper of a binded GLX texture.
|
||||
struct _glx_texture {
|
||||
GLuint texture;
|
||||
GLXPixmap glpixmap;
|
||||
xcb_pixmap_t pixmap;
|
||||
GLenum target;
|
||||
int width;
|
||||
int height;
|
||||
bool y_inverted;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_OPENGL
|
||||
typedef struct {
|
||||
/// Fragment shader for blur.
|
||||
GLuint frag_shader;
|
||||
/// GLSL program for blur.
|
||||
GLuint prog;
|
||||
/// Location of uniform "offset_x" in blur GLSL program.
|
||||
GLint unifm_offset_x;
|
||||
/// Location of uniform "offset_y" in blur GLSL program.
|
||||
GLint unifm_offset_y;
|
||||
/// Location of uniform "factor_center" in blur GLSL program.
|
||||
GLint unifm_factor_center;
|
||||
} glx_blur_pass_t;
|
||||
|
||||
typedef struct glx_prog_main {
|
||||
/// GLSL program.
|
||||
GLuint prog;
|
||||
|
@ -148,7 +104,6 @@ typedef struct glx_prog_main {
|
|||
#define GLX_PROG_MAIN_INIT \
|
||||
{ .prog = 0, .unifm_opacity = -1, .unifm_invert_color = -1, .unifm_tex = -1, }
|
||||
|
||||
#endif
|
||||
#else
|
||||
struct glx_prog_main {};
|
||||
#endif
|
||||
|
@ -162,9 +117,6 @@ typedef struct _latom {
|
|||
struct _latom *next;
|
||||
} latom_t;
|
||||
|
||||
#define REG_DATA_INIT \
|
||||
{ NULL, 0 }
|
||||
|
||||
/// Structure containing all necessary data for a compton session.
|
||||
typedef struct session {
|
||||
// === Event handlers ===
|
||||
|
@ -545,25 +497,6 @@ static inline bool wid_has_prop(const session_t *ps, xcb_window_t w, xcb_atom_t
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the numeric property value from a win_prop_t.
|
||||
*/
|
||||
static inline long winprop_get_int(winprop_t prop) {
|
||||
long tgt = 0;
|
||||
|
||||
if (!prop.nitems)
|
||||
return 0;
|
||||
|
||||
switch (prop.format) {
|
||||
case 8: tgt = *(prop.p8); break;
|
||||
case 16: tgt = *(prop.p16); break;
|
||||
case 32: tgt = *(prop.p32); break;
|
||||
default: assert(0); break;
|
||||
}
|
||||
|
||||
return tgt;
|
||||
}
|
||||
|
||||
void force_repaint(session_t *ps);
|
||||
|
||||
/** @name DBus handling
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <test.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "config.h"
|
||||
#include "compiler.h"
|
||||
#include "compton.h"
|
||||
#include "err.h"
|
||||
|
|
|
@ -752,7 +752,7 @@ static bool cdbus_process_win_get(session_t *ps, DBusMessage *msg) {
|
|||
}
|
||||
|
||||
#define cdbus_m_win_get_do(tgt, apdarg_func) \
|
||||
if (!strcmp(MSTR(tgt), target)) { \
|
||||
if (!strcmp(#tgt, target)) { \
|
||||
apdarg_func(ps, msg, w->tgt); \
|
||||
return true; \
|
||||
}
|
||||
|
@ -957,13 +957,13 @@ static bool cdbus_process_opts_get(session_t *ps, DBusMessage *msg) {
|
|||
return false;
|
||||
|
||||
#define cdbus_m_opts_get_do(tgt, apdarg_func) \
|
||||
if (!strcmp(MSTR(tgt), target)) { \
|
||||
if (!strcmp(#tgt, target)) { \
|
||||
apdarg_func(ps, msg, ps->o.tgt); \
|
||||
return true; \
|
||||
}
|
||||
|
||||
#define cdbus_m_opts_get_stub(tgt, apdarg_func, ret) \
|
||||
if (!strcmp(MSTR(tgt), target)) { \
|
||||
if (!strcmp(#tgt, target)) { \
|
||||
apdarg_func(ps, msg, ret); \
|
||||
return true; \
|
||||
}
|
||||
|
@ -1068,7 +1068,7 @@ static bool cdbus_process_opts_set(session_t *ps, DBusMessage *msg) {
|
|||
return false;
|
||||
|
||||
#define cdbus_m_opts_set_do(tgt, type, real_type) \
|
||||
if (!strcmp(MSTR(tgt), target)) { \
|
||||
if (!strcmp(#tgt, target)) { \
|
||||
real_type val; \
|
||||
if (!cdbus_msg_get_arg(msg, 1, type, &val)) \
|
||||
return false; \
|
||||
|
|
24
src/opengl.h
24
src/opengl.h
|
@ -26,6 +26,19 @@
|
|||
#include <xcb/render.h>
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
typedef struct {
|
||||
/// Fragment shader for blur.
|
||||
GLuint frag_shader;
|
||||
/// GLSL program for blur.
|
||||
GLuint prog;
|
||||
/// Location of uniform "offset_x" in blur GLSL program.
|
||||
GLint unifm_offset_x;
|
||||
/// Location of uniform "offset_y" in blur GLSL program.
|
||||
GLint unifm_offset_y;
|
||||
/// Location of uniform "factor_center" in blur GLSL program.
|
||||
GLint unifm_factor_center;
|
||||
} glx_blur_pass_t;
|
||||
|
||||
/// Structure containing GLX-dependent data for a compton session.
|
||||
typedef struct glx_session {
|
||||
// === OpenGL related ===
|
||||
|
@ -38,6 +51,17 @@ typedef struct glx_session {
|
|||
glx_blur_pass_t blur_passes[MAX_BLUR_PASS];
|
||||
} glx_session_t;
|
||||
|
||||
/// @brief Wrapper of a binded GLX texture.
|
||||
typedef struct _glx_texture {
|
||||
GLuint texture;
|
||||
GLXPixmap glpixmap;
|
||||
xcb_pixmap_t pixmap;
|
||||
GLenum target;
|
||||
int width;
|
||||
int height;
|
||||
bool y_inverted;
|
||||
} glx_texture_t;
|
||||
|
||||
#define CGLX_SESSION_INIT \
|
||||
{ .context = NULL }
|
||||
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
#include <xcb/xcb_renderutil.h>
|
||||
#include <xcb/xinerama.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "atom.h"
|
||||
#include "backend/backend.h"
|
||||
#include "c2.h"
|
||||
#include "common.h"
|
||||
#include "compiler.h"
|
||||
#include "compton.h"
|
||||
#include "config.h"
|
||||
|
|
Loading…
Reference in a new issue