1
0
Fork 0
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:
Yuxuan Shui 2019-05-06 02:23:15 +01:00
parent 16ea51bbc1
commit cdb24ec99c
No known key found for this signature in database
GPG key ID: 37C999F617EA1A47
6 changed files with 50 additions and 72 deletions

View file

@ -211,6 +211,26 @@ static const c2_predef_t C2_PREDEFS[] = {
[C2_L_PROLE] = {"role", C2_L_TSTRING, 0}, [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. * Compare next word in a string with another string.
*/ */

View file

@ -41,11 +41,6 @@
#include "backend/gl/glx.h" #include "backend/gl/glx.h"
#endif #endif
// === Macros ===
#define MSTR_(s) #s
#define MSTR(s) MSTR_(s)
// X resource checker // X resource checker
#ifdef DEBUG_XRC #ifdef DEBUG_XRC
#include "xrescheck.h" #include "xrescheck.h"
@ -56,13 +51,9 @@
#include "backend/driver.h" #include "backend/driver.h"
#include "compiler.h" #include "compiler.h"
#include "config.h" #include "config.h"
#include "kernel.h"
#include "log.h"
#include "region.h" #include "region.h"
#include "render.h"
#include "types.h" #include "types.h"
#include "utils.h" #include "utils.h"
#include "win.h"
#include "x.h" #include "x.h"
// === Constants ===0 // === Constants ===0
@ -84,21 +75,11 @@ typedef struct glx_fbconfig glx_fbconfig_t;
struct glx_session; struct glx_session;
struct atom; 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 { typedef struct _ignore {
struct _ignore *next; struct _ignore *next;
unsigned long sequence; unsigned long sequence;
} ignore_t; } ignore_t;
typedef struct _glx_texture glx_texture_t;
#ifdef CONFIG_OPENGL #ifdef CONFIG_OPENGL
#ifdef DEBUG_GLX_DEBUG_CONTEXT #ifdef DEBUG_GLX_DEBUG_CONTEXT
typedef GLXContext (*f_glXCreateContextAttribsARB)(Display *dpy, GLXFBConfig config, 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); typedef void (*f_DebugMessageCallback)(GLDEBUGPROC, void *userParam);
#endif #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 { typedef struct glx_prog_main {
/// GLSL program. /// GLSL program.
GLuint prog; GLuint prog;
@ -148,7 +104,6 @@ typedef struct glx_prog_main {
#define GLX_PROG_MAIN_INIT \ #define GLX_PROG_MAIN_INIT \
{ .prog = 0, .unifm_opacity = -1, .unifm_invert_color = -1, .unifm_tex = -1, } { .prog = 0, .unifm_opacity = -1, .unifm_invert_color = -1, .unifm_tex = -1, }
#endif
#else #else
struct glx_prog_main {}; struct glx_prog_main {};
#endif #endif
@ -162,9 +117,6 @@ typedef struct _latom {
struct _latom *next; struct _latom *next;
} latom_t; } latom_t;
#define REG_DATA_INIT \
{ NULL, 0 }
/// 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 ===
@ -545,25 +497,6 @@ static inline bool wid_has_prop(const session_t *ps, xcb_window_t w, xcb_atom_t
return false; 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); void force_repaint(session_t *ps);
/** @name DBus handling /** @name DBus handling

View file

@ -29,6 +29,7 @@
#include <test.h> #include <test.h>
#include "common.h" #include "common.h"
#include "config.h"
#include "compiler.h" #include "compiler.h"
#include "compton.h" #include "compton.h"
#include "err.h" #include "err.h"

View file

@ -752,7 +752,7 @@ static bool cdbus_process_win_get(session_t *ps, DBusMessage *msg) {
} }
#define cdbus_m_win_get_do(tgt, apdarg_func) \ #define cdbus_m_win_get_do(tgt, apdarg_func) \
if (!strcmp(MSTR(tgt), target)) { \ if (!strcmp(#tgt, target)) { \
apdarg_func(ps, msg, w->tgt); \ apdarg_func(ps, msg, w->tgt); \
return true; \ return true; \
} }
@ -957,13 +957,13 @@ static bool cdbus_process_opts_get(session_t *ps, DBusMessage *msg) {
return false; return false;
#define cdbus_m_opts_get_do(tgt, apdarg_func) \ #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); \ apdarg_func(ps, msg, ps->o.tgt); \
return true; \ return true; \
} }
#define cdbus_m_opts_get_stub(tgt, apdarg_func, ret) \ #define cdbus_m_opts_get_stub(tgt, apdarg_func, ret) \
if (!strcmp(MSTR(tgt), target)) { \ if (!strcmp(#tgt, target)) { \
apdarg_func(ps, msg, ret); \ apdarg_func(ps, msg, ret); \
return true; \ return true; \
} }
@ -1068,7 +1068,7 @@ static bool cdbus_process_opts_set(session_t *ps, DBusMessage *msg) {
return false; return false;
#define cdbus_m_opts_set_do(tgt, type, real_type) \ #define cdbus_m_opts_set_do(tgt, type, real_type) \
if (!strcmp(MSTR(tgt), target)) { \ if (!strcmp(#tgt, target)) { \
real_type val; \ real_type val; \
if (!cdbus_msg_get_arg(msg, 1, type, &val)) \ if (!cdbus_msg_get_arg(msg, 1, type, &val)) \
return false; \ return false; \

View file

@ -26,6 +26,19 @@
#include <xcb/render.h> #include <xcb/render.h>
#include <xcb/xcb.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. /// Structure containing GLX-dependent data for a compton session.
typedef struct glx_session { typedef struct glx_session {
// === OpenGL related === // === OpenGL related ===
@ -38,6 +51,17 @@ typedef struct glx_session {
glx_blur_pass_t blur_passes[MAX_BLUR_PASS]; glx_blur_pass_t blur_passes[MAX_BLUR_PASS];
} glx_session_t; } 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 \ #define CGLX_SESSION_INIT \
{ .context = NULL } { .context = NULL }

View file

@ -15,10 +15,10 @@
#include <xcb/xcb_renderutil.h> #include <xcb/xcb_renderutil.h>
#include <xcb/xinerama.h> #include <xcb/xinerama.h>
#include "common.h"
#include "atom.h" #include "atom.h"
#include "backend/backend.h" #include "backend/backend.h"
#include "c2.h" #include "c2.h"
#include "common.h"
#include "compiler.h" #include "compiler.h"
#include "compton.h" #include "compton.h"
#include "config.h" #include "config.h"