aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-01-11 20:39:41 +0100
committerdec05eba <dec05eba@protonmail.com>2024-01-11 20:43:49 +0100
commit3a1fb0dfc8bb255ee2d46fb12ba850a6f41c50ea (patch)
tree1429bfde7463c771a861956d5bd9a51d3b21e95d
parent2b9389ae016c8048a16ba033f27ca5c256985e4d (diff)
Add/remove window
-rw-r--r--README.md2
-rw-r--r--src/compositor.c3
-rw-r--r--src/main.c18
3 files changed, 21 insertions, 2 deletions
diff --git a/README.md b/README.md
index a98c136..33730cc 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,2 @@
# Next Generation X Compositor
-Low latency stutter free compositor
+Low latency stutter-free X compositor
diff --git a/src/compositor.c b/src/compositor.c
index 4b622c0..92a7029 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -69,6 +69,7 @@ void ngxc_compositor_remove_window(ngxc_compositor *self, Window window) {
for(int j = i + 1; j < self->num_windows; ++j) {
self->windows[j - 1] = self->windows[j];
}
+ self->num_windows--;
break;
}
}
@@ -128,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.002;
+ const double delayed_update = time_limit - frame_duration - 0.001;
//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 d660e1d..bd552b2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -169,6 +169,24 @@ int main(int argc, char **argv) {
while(XPending(dpy)) {
XNextEvent(dpy, &xev);
switch(xev.type) {
+ case CreateNotify: {
+ // TODO:
+ //ngxc_compositor_add_window(&compositor, xev.xcreatewindow.window);
+ break;
+ }
+ case DestroyNotify: {
+ // TODO:
+ //ngxc_compositor_remove_window(&compositor, xev.xdestroywindow.window);
+ break;
+ }
+ case MapNotify: {
+ ngxc_compositor_add_window(&compositor, xev.xmap.window);
+ break;
+ }
+ case UnmapNotify: {
+ ngxc_compositor_remove_window(&compositor, xev.xunmap.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);