2003-11-09 Keith Packard <keithp@keithp.com>
+ * xcompmgr.c: (time_in_millis), (main):
+ 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.
+
+2003-11-09 Keith Packard <keithp@keithp.com>
+
* xcompmgr.c: (root_tile):
Make sure _XROOTPMAP_ID property is right type, format and length
before attempting to use the resulting value.
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;
int n_expose = 0;
struct pollfd ufd;
int n;
+ int last_update;
+ int now;
+ int timeout;
dpy = XOpenDisplay (0);
if (!dpy)
add_win (dpy, children[i], i ? children[i-1] : None);
XFree (children);
XUngrabServer (dpy);
+ last_update = time_in_millis ();
for (;;)
{
/* dump_wins (); */
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);