Misc: Code clean-up
- Fix a memory leak in register_cm(). - Print a warning message if argument of --vsync is invalid. - Known bug: compton will probably freeze X if another compositing window manager is running and --vsync opengl is enabled, with nvidia-drivers-304.51. Probably an issue on the driver. I could see no workaround.
This commit is contained in:
parent
b59e592588
commit
72ea4b5f47
1
Makefile
1
Makefile
|
@ -38,6 +38,7 @@ ifeq "$(NO_VSYNC_OPENGL)" ""
|
||||||
LIBS += -lGL
|
LIBS += -lGL
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
CFLAGS ?= -DNDEBUG
|
||||||
CFLAGS += $(CFG)
|
CFLAGS += $(CFG)
|
||||||
|
|
||||||
LIBS += $(shell pkg-config --libs $(PACKAGES))
|
LIBS += $(shell pkg-config --libs $(PACKAGES))
|
||||||
|
|
|
@ -35,7 +35,7 @@ const char *WINTYPES[NUM_WINTYPES] = {
|
||||||
struct timeval time_start = { 0, 0 };
|
struct timeval time_start = { 0, 0 };
|
||||||
|
|
||||||
win *list;
|
win *list;
|
||||||
Display *dpy;
|
Display *dpy = NULL;
|
||||||
int scr;
|
int scr;
|
||||||
|
|
||||||
Window root;
|
Window root;
|
||||||
|
@ -3138,10 +3138,12 @@ register_cm(Bool want_glxct) {
|
||||||
#ifdef CONFIG_VSYNC_OPENGL
|
#ifdef CONFIG_VSYNC_OPENGL
|
||||||
// Create a window with the wanted GLX visual
|
// Create a window with the wanted GLX visual
|
||||||
if (want_glxct) {
|
if (want_glxct) {
|
||||||
|
XVisualInfo *pvi = NULL;
|
||||||
Bool ret = False;
|
Bool ret = False;
|
||||||
// Get visual for the window
|
// Get visual for the window
|
||||||
int attribs[] = { GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, None };
|
int attribs[] = { GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, None };
|
||||||
XVisualInfo *pvi = glXChooseVisual(dpy, scr, attribs);
|
pvi = glXChooseVisual(dpy, scr, attribs);
|
||||||
|
|
||||||
if (!pvi) {
|
if (!pvi) {
|
||||||
fprintf(stderr, "register_cm(): Failed to choose visual required "
|
fprintf(stderr, "register_cm(): Failed to choose visual required "
|
||||||
"by fake OpenGL VSync window. OpenGL VSync turned off.\n");
|
"by fake OpenGL VSync window. OpenGL VSync turned off.\n");
|
||||||
|
@ -3156,6 +3158,7 @@ register_cm(Bool want_glxct) {
|
||||||
pvi->screen = scr;
|
pvi->screen = scr;
|
||||||
reg_win = XCreateWindow(dpy, root, 0, 0, 1, 1, 0, pvi->depth,
|
reg_win = XCreateWindow(dpy, root, 0, 0, 1, 1, 0, pvi->depth,
|
||||||
InputOutput, pvi->visual, CWBorderPixel | CWColormap, &swa);
|
InputOutput, pvi->visual, CWBorderPixel | CWColormap, &swa);
|
||||||
|
|
||||||
if (!reg_win)
|
if (!reg_win)
|
||||||
fprintf(stderr, "register_cm(): Failed to create window required "
|
fprintf(stderr, "register_cm(): Failed to create window required "
|
||||||
"by fake OpenGL VSync. OpenGL VSync turned off.\n");
|
"by fake OpenGL VSync. OpenGL VSync turned off.\n");
|
||||||
|
@ -3175,6 +3178,9 @@ register_cm(Bool want_glxct) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (pvi)
|
||||||
|
XFree(pvi);
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
opts.vsync = VSYNC_NONE;
|
opts.vsync = VSYNC_NONE;
|
||||||
}
|
}
|
||||||
|
@ -3650,11 +3656,17 @@ get_cfg(int argc, char *const *argv) {
|
||||||
break;
|
break;
|
||||||
case 270:
|
case 270:
|
||||||
// --vsync
|
// --vsync
|
||||||
for (vsync_t i = 0; i < sizeof(vsync_str) / sizeof(vsync_str[0]); ++i)
|
{
|
||||||
if (!strcasecmp(optarg, vsync_str[i])) {
|
vsync_t i;
|
||||||
opts.vsync = i;
|
for (i = 0; i < (sizeof(vsync_str) / sizeof(vsync_str[0])); ++i)
|
||||||
break;
|
if (!strcasecmp(optarg, vsync_str[i])) {
|
||||||
|
opts.vsync = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ((sizeof(vsync_str) / sizeof(vsync_str[0])) == i) {
|
||||||
|
fputs("Invalid --vsync argument. Ignored.\n", stderr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
|
@ -4011,6 +4023,8 @@ vsync_wait(Display *dpy, struct pollfd *fd, int timeout) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// This place should not reached!
|
// This place should not reached!
|
||||||
|
assert(0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
// Whether to enable OpenGL VSync support
|
// Whether to enable OpenGL VSync support
|
||||||
// #define CONFIG_VSYNC_OPENGL 1
|
// #define CONFIG_VSYNC_OPENGL 1
|
||||||
|
|
||||||
#define NDEBUG 1
|
|
||||||
// === Includes ===
|
// === Includes ===
|
||||||
|
|
||||||
// For some special functions
|
// For some special functions
|
||||||
|
|
Loading…
Reference in New Issue