summaryrefslogtreecommitdiff
path: root/xcompmgr.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2003-11-10 05:48:23 +0000
committerKeith Packard <keithp@keithp.com>2003-11-10 05:48:23 +0000
commit9e767b89cfa434e762f65f23c3be872cd5d99087 (patch)
treea65691fc22a2b23cf8b8866ed6a7a927d15e0d78 /xcompmgr.c
parent37280d7888001a613640b7d005f4482e7d886c47 (diff)
Add a bit of scheduling to updates; update every 30 ms instead of waiting
for more events. Smooths out window moving. Interval needs to be configurable probably.
Diffstat (limited to 'xcompmgr.c')
-rw-r--r--xcompmgr.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/xcompmgr.c b/xcompmgr.c
index 7b55eae..0662b82 100644
--- a/xcompmgr.c
+++ b/xcompmgr.c
@@ -732,6 +732,17 @@ expose_root (Display *dpy, Window root, XRectangle *rects, int nrects)
add_damage (dpy, region);
}
+int
+time_in_millis ()
+{
+ struct timeval tp;
+
+ gettimeofday (&tp, 0);
+ return(tp.tv_sec * 1000) + (tp.tv_usec / 1000);
+}
+
+#define INTERVAL 30
+
main ()
{
XEvent ev;
@@ -751,6 +762,9 @@ main ()
int n_expose = 0;
struct pollfd ufd;
int n;
+ int last_update;
+ int now;
+ int timeout;
dpy = XOpenDisplay (0);
if (!dpy)
@@ -808,6 +822,7 @@ main ()
add_win (dpy, children[i], i ? children[i-1] : None);
XFree (children);
XUngrabServer (dpy);
+ last_update = time_in_millis ();
for (;;)
{
/* dump_wins (); */
@@ -873,11 +888,17 @@ main ()
break;
}
} while (XEventsQueued (dpy, QueuedAfterReading));
- ufd.fd = ConnectionNumber (dpy);
- ufd.events = POLLIN;
- n = poll (&ufd, 1, 30);
- if (n > 0 && (ufd.revents & POLLIN) && XEventsQueued (dpy, QueuedAfterReading))
- continue;
+ now = time_in_millis ();
+ timeout = INTERVAL - (now - last_update);
+ if (timeout > 0)
+ {
+ ufd.fd = ConnectionNumber (dpy);
+ ufd.events = POLLIN;
+ n = poll (&ufd, 1, timeout);
+ if (n > 0 && (ufd.revents & POLLIN) && XEventsQueued (dpy, QueuedAfterReading))
+ continue;
+ }
+ last_update = time_in_millis();
if (allDamage)
{
paint_all (dpy, allDamage);