Merge branch 'unstable'

This commit is contained in:
Jarcode
2018-03-18 12:26:31 -07:00
7 changed files with 36 additions and 19 deletions

View File

@@ -199,7 +199,7 @@ int main(int argc, char** argv) {
bool verbose = false; bool verbose = false;
bool copy_mode = false; bool copy_mode = false;
int c, idx, n = 0; int c, idx;
while ((c = getopt_long(argc, argv, opt_str, p_opts, &idx)) != -1) { while ((c = getopt_long(argc, argv, opt_str, p_opts, &idx)) != -1) {
switch (c) { switch (c) {
case 'v': verbose = true; break; case 'v': verbose = true; break;
@@ -259,7 +259,7 @@ int main(int argc, char** argv) {
} }
pthread_t thread; pthread_t thread;
int thread_id = pthread_create(&thread, NULL, input_pulse, (void*) &audio); pthread_create(&thread, NULL, input_pulse, (void*) &audio);
float lb[r->bufsize_request], rb[r->bufsize_request]; float lb[r->bufsize_request], rb[r->bufsize_request];
while (r->alive) { while (r->alive) {

View File

@@ -119,7 +119,7 @@ static void set_visible(GLFWwindow* w, bool visible) {
else glfwHideWindow(w); else glfwHideWindow(w);
} }
static bool swap_buffers(GLFWwindow* w) { static void swap_buffers(GLFWwindow* w) {
glfwSwapBuffers(w); glfwSwapBuffers(w);
glfwPollEvents(); glfwPollEvents();
} }

View File

@@ -15,6 +15,7 @@
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/extensions/Xrender.h> #include <X11/extensions/Xrender.h>
#include <X11/extensions/shape.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <glad/glad.h> #include <glad/glad.h>
@@ -126,7 +127,7 @@ static void* create_and_bind(const char* name, const char* class,
if (!fmt || (transparent ? fmt->direct.alphaMask == 0 : fmt->direct.alphaMask != 0)) if (!fmt || (transparent ? fmt->direct.alphaMask == 0 : fmt->direct.alphaMask != 0))
continue; continue;
if (best < 0 || samp_buf && samples > samp) { if (best < 0 || (samp_buf && samples > samp)) {
best = t; best = t;
samp = samples; samp = samples;
} }
@@ -157,9 +158,11 @@ static void* create_and_bind(const char* name, const char* class,
fprintf(stderr, "XCreateWindow(): failed\n"); fprintf(stderr, "XCreateWindow(): failed\n");
abort(); abort();
} }
bool desktop = false;
if (type) if (type)
xwin_settype(&wcb_glx, w, type); desktop = xwin_settype(&wcb_glx, w, type);
for (size_t t = 0; t < states_sz; ++t) for (size_t t = 0; t < states_sz; ++t)
xwin_addstate(&wcb_glx, w, states[t]); xwin_addstate(&wcb_glx, w, states[t]);
@@ -180,6 +183,20 @@ static void* create_and_bind(const char* name, const char* class,
Atom dwin = XInternAtom(display, "WM_DELETE_WINDOW", false); Atom dwin = XInternAtom(display, "WM_DELETE_WINDOW", false);
XSetWMProtocols(display, w->w, &dwin, 1); XSetWMProtocols(display, w->w, &dwin, 1);
// XReparentWindow(display, w->w, DefaultRootWindow(display), 0, 0);
/* Eliminate the window's effective region */
if (desktop){
int ignored;
if (XShapeQueryExtension(display, &ignored, &ignored)) {
Region region;
if ((region = XCreateRegion())) {
XShapeCombineRegion(display, w->w, ShapeInput, 0, 0, region, ShapeSet);
XDestroyRegion(region);
}
}
}
glXCreateContextAttribsARBProc glXCreateContextAttribsARB = NULL; glXCreateContextAttribsARBProc glXCreateContextAttribsARB = NULL;
glXSwapIntervalEXTProc glXSwapIntervalEXT = NULL; glXSwapIntervalEXTProc glXSwapIntervalEXT = NULL;
@@ -255,7 +272,6 @@ static void get_fbsize(struct glxwin* w, int* d, int* h) {
} }
static void get_pos(struct glxwin* w, int* x, int* y) { static void get_pos(struct glxwin* w, int* x, int* y) {
XWindowAttributes a;
Window _ignored; Window _ignored;
XTranslateCoordinates(display, w->w, DefaultRootWindow(display), 0, 0, x, y, &_ignored); XTranslateCoordinates(display, w->w, DefaultRootWindow(display), 0, 0, x, y, &_ignored);
} }

View File

@@ -506,7 +506,6 @@ void transform_smooth(struct gl_data* d, void** udaa, void* data) {
for (int t = 0; t < asz; ++t) { for (int t = 0; t < asz; ++t) {
float float
db = log(t), /* buffer index on log scale */ db = log(t), /* buffer index on log scale */
v = b[t], /* value at this position */
avg = 0; /* adj value averages (weighted) */ avg = 0; /* adj value averages (weighted) */
/* Calculate real indexes for sampling at this position, since the /* Calculate real indexes for sampling at this position, since the
distance is specified in scalar values */ distance is specified in scalar values */
@@ -592,7 +591,7 @@ void transform_wrange(struct gl_data* d, void** _, void* data) {
void transform_window(struct gl_data* d, void** _, void* data) { void transform_window(struct gl_data* d, void** _, void* data) {
struct gl_sampler_data* s = (struct gl_sampler_data*) data; struct gl_sampler_data* s = (struct gl_sampler_data*) data;
float* b = s->buf, w; float* b = s->buf;
size_t sz = s->sz, t; size_t sz = s->sz, t;
for (t = 0; t < sz; ++t) { for (t = 0; t < sz; ++t) {
@@ -765,7 +764,7 @@ struct renderer* rd_new(const char** paths, const char* entry,
}; };
if (!gl->wcb) { if (!gl->wcb) {
fprintf(stderr, "Invalid window creation backend selected: '%s'\n", gl->wcb); fprintf(stderr, "Invalid window creation backend selected: '%s'\n", backend);
abort(); abort();
} }

View File

@@ -31,7 +31,7 @@ struct gl_wcb {
int x, int y, int x, int y,
int version_major, int version_minor); int version_major, int version_minor);
bool (*should_close) (void* ptr); bool (*should_close) (void* ptr);
bool (*swap_buffers) (void* ptr); void (*swap_buffers) (void* ptr);
void (*get_pos) (void* ptr, int* x, int* y); void (*get_pos) (void* ptr, int* x, int* y);
void (*get_fbsize) (void* ptr, int* w, int* h); void (*get_fbsize) (void* ptr, int* w, int* h);
void (*set_geometry) (void* ptr, int x, int y, int w, int h); void (*set_geometry) (void* ptr, int x, int y, int w, int h);

18
xwin.c
View File

@@ -100,9 +100,7 @@ bool xwin_should_render(struct renderer* rd) {
return ret; return ret;
} }
/* Set window types defined by the EWMH standard, possible values: static bool xwin_changeatom(struct gl_wcb* wcb, void* impl, const char* type,
-> "desktop", "dock", "toolbar", "menu", "utility", "splash", "dialog", "normal" */
static void xwin_changeatom(struct gl_wcb* wcb, void* impl, const char* type,
const char* atom, const char* fmt, int mode) { const char* atom, const char* fmt, int mode) {
Window w = wcb->get_x11_window(impl); Window w = wcb->get_x11_window(impl);
Display* d = wcb->get_x11_display(); Display* d = wcb->get_x11_display();
@@ -116,14 +114,19 @@ static void xwin_changeatom(struct gl_wcb* wcb, void* impl, const char* type,
default: formatted[t] = c; default: formatted[t] = c;
} }
} }
bool ret = !strcmp(type, "DESKTOP");
char buf[256]; char buf[256];
snprintf(buf, sizeof(buf), fmt, formatted); snprintf(buf, sizeof(buf), fmt, formatted);
Atom desk = XInternAtom(d, buf, false); Atom desk = XInternAtom(d, buf, false);
XChangeProperty(d, w, wtype, XA_ATOM, 32, mode, (unsigned char*) &desk, 1); XChangeProperty(d, w, wtype, XA_ATOM, 32, mode, (unsigned char*) &desk, 1);
return ret;
} }
void xwin_settype(struct gl_wcb* wcb, void* impl, const char* type) { /* Set window types defined by the EWMH standard, possible values:
xwin_changeatom(wcb, impl, type, "_NET_WM_WINDOW_TYPE", "_NET_WM_WINDOW_TYPE_%s", PropModeReplace); -> "desktop", "dock", "toolbar", "menu", "utility", "splash", "dialog", "normal" */
bool xwin_settype(struct gl_wcb* wcb, void* impl, const char* type) {
return xwin_changeatom(wcb, impl, type, "_NET_WM_WINDOW_TYPE",
"_NET_WM_WINDOW_TYPE_%s", PropModeReplace);
} }
void xwin_addstate(struct gl_wcb* wcb, void* impl, const char* state) { void xwin_addstate(struct gl_wcb* wcb, void* impl, const char* state) {
@@ -160,14 +163,13 @@ unsigned int xwin_copyglbg(struct renderer* rd, unsigned int tex) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
bool use_shm = true;
int x, y, w, h; int x, y, w, h;
rd_get_wcb(rd)->get_fbsize(rd_get_impl_window(rd), &w, &h); rd_get_wcb(rd)->get_fbsize(rd_get_impl_window(rd), &w, &h);
rd_get_wcb(rd)->get_pos(rd_get_impl_window(rd), &x, &y); rd_get_wcb(rd)->get_pos(rd_get_impl_window(rd), &x, &y);
XColor c; XColor c;
Display* d = rd_get_wcb(rd)->get_x11_display(); Display* d = rd_get_wcb(rd)->get_x11_display();
Drawable src = get_drawable(d, find_desktop(rd)); Drawable src = get_drawable(d, find_desktop(rd));
bool use_shm = XShmQueryExtension(d);
/* Obtain section of root pixmap */ /* Obtain section of root pixmap */
@@ -191,7 +193,7 @@ unsigned int xwin_copyglbg(struct renderer* rd, unsigned int tex) {
XShmGetImage(d, src, image, x, y, AllPlanes); XShmGetImage(d, src, image, x, y, AllPlanes);
} else { } else {
image = XGetImage(d, src, x, y, (unsigned int) w, (unsigned int) h, image = XGetImage(d, src, x, y, (unsigned int) w, (unsigned int) h,
ZPixmap, AllPlanes); AllPlanes, ZPixmap);
} }
/* Try to convert pixel bit depth to OpenGL storage format. The following formats\ /* Try to convert pixel bit depth to OpenGL storage format. The following formats\

2
xwin.h
View File

@@ -1,5 +1,5 @@
bool xwin_should_render(struct renderer* rd); bool xwin_should_render(struct renderer* rd);
void xwin_settype(struct gl_wcb* wcb, void* impl, const char* type); bool xwin_settype(struct gl_wcb* wcb, void* impl, const char* type);
void xwin_addstate(struct gl_wcb* wcb, void* impl, const char* state); void xwin_addstate(struct gl_wcb* wcb, void* impl, const char* state);
unsigned int xwin_copyglbg(struct renderer* rd, unsigned int texture); unsigned int xwin_copyglbg(struct renderer* rd, unsigned int texture);