From efee05461adf85f9d2730a008c757387364deb54 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 11 Jan 2024 21:25:59 +0100 Subject: 2ms leway --- src/compositor.c | 2 +- src/main.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/compositor.c b/src/compositor.c index 92a7029..ee6c986 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -129,7 +129,7 @@ void ngxc_compositor_render(ngxc_compositor *self) { glFinish(); const double time_limit = 1.0f / 60.0f; // TODO: Get from randr - const double delayed_update = time_limit - frame_duration - 0.001; + const double delayed_update = time_limit - frame_duration - 0.002; //fprintf(stderr, "delayed update: %f\n", delayed_update); if(delayed_update > 0.0) usleep(delayed_update * 1000000.0); diff --git a/src/main.c b/src/main.c index bd552b2..7763a4b 100644 --- a/src/main.c +++ b/src/main.c @@ -108,7 +108,8 @@ int main(int argc, char **argv) { fatal_if(is_compositor_running(dpy), "another compositor is already running"); const Window root_window = DefaultRootWindow(dpy); - XSelectInput(dpy, root_window, SubstructureNotifyMask); + //XCompositeRedirectSubwindows(dpy, root_window, CompositeRedirectManual); + XSelectInput(dpy, root_window, ExposureMask | StructureNotifyMask | SubstructureNotifyMask | PropertyChangeMask); GLXFBConfig *fb_config; XVisualInfo *xvisual_info; @@ -168,6 +169,8 @@ int main(int argc, char **argv) { for(;;) { while(XPending(dpy)) { XNextEvent(dpy, &xev); + //if(xev.type != 22) + // fprintf(stderr, "event: %d\n", xev.type); switch(xev.type) { case CreateNotify: { // TODO: @@ -187,11 +190,22 @@ int main(int argc, char **argv) { ngxc_compositor_remove_window(&compositor, xev.xunmap.window); break; } + case ReparentNotify: { + if(xev.xreparent.parent == root_window) + ngxc_compositor_add_window(&compositor, xev.xreparent.window); + else + ngxc_compositor_remove_window(&compositor, xev.xreparent.window); + break; + } case ConfigureNotify: { /* TODO: Instead of doing this potentially multiple times at once, only do this for the last configure notify event for each window */ ngxc_compositor_on_configure(&compositor, &xev.xconfigure); break; } + case CirculateNotify: { + fprintf(stderr, "circulate!\n"); + break; + } default: break; } -- cgit v1.2.3