Wait for EWMH WM to add _NET_SUPPORTING_WM_CHECK property, addresses #54
This commit is contained in:
2
render.c
2
render.c
@@ -681,6 +681,8 @@ static struct gl_bind_src* lookup_bind_src(const char* str) {
|
||||
|
||||
struct renderer* rd_new(const char** paths, const char* entry,
|
||||
const char* force_mod, const char* force_backend) {
|
||||
|
||||
xwin_wait_for_wm();
|
||||
|
||||
renderer* r = malloc(sizeof(struct renderer));
|
||||
*r = (struct renderer) {
|
||||
|
||||
29
xwin.c
29
xwin.c
@@ -8,6 +8,8 @@
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
|
||||
@@ -53,6 +55,33 @@ static Window find_desktop(struct renderer* r) {
|
||||
return desktop;
|
||||
}
|
||||
|
||||
void xwin_wait_for_wm(void) {
|
||||
Display* d = XOpenDisplay(0);
|
||||
|
||||
Atom check = None;
|
||||
bool exists = false;
|
||||
struct timespec tv = { .tv_sec = 0, .tv_nsec = 50 * 1000000 };
|
||||
|
||||
do {
|
||||
if (check == None) {
|
||||
check = XInternAtom(d, "_NET_SUPPORTING_WM_CHECK", true);
|
||||
}
|
||||
if (check) {
|
||||
int num_prop, idx;
|
||||
Atom* props = XListProperties(d, DefaultRootWindow(d), &num_prop);
|
||||
for (idx = 0; idx < num_prop; ++idx) {
|
||||
if (props[idx] == check) {
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!exists) nanosleep(&tv, NULL);
|
||||
} while (!exists);
|
||||
|
||||
XCloseDisplay(d);
|
||||
}
|
||||
|
||||
bool xwin_should_render(struct renderer* rd) {
|
||||
bool ret = true, should_close = false;
|
||||
Display* d = rd_get_wcb(rd)->get_x11_display();
|
||||
|
||||
1
xwin.h
1
xwin.h
@@ -2,6 +2,7 @@
|
||||
#define XWIN_ALL_DESKTOPS 0xFFFFFFFF
|
||||
|
||||
bool xwin_should_render(struct renderer* rd);
|
||||
void xwin_wait_for_wm(void);
|
||||
bool xwin_settype(struct gl_wcb* wcb, void* impl, const char* type);
|
||||
void xwin_setdesktop(struct gl_wcb* wcb, void* impl, unsigned long desktop);
|
||||
void xwin_addstate(struct gl_wcb* wcb, void* impl, const char* state);
|
||||
|
||||
Reference in New Issue
Block a user