diff options
-rw-r--r-- | include/compiz.h | 7 | ||||
-rw-r--r-- | src/privatescreen.h | 10 | ||||
-rw-r--r-- | src/screen.cpp | 24 |
3 files changed, 21 insertions, 20 deletions
diff --git a/include/compiz.h b/include/compiz.h index b548c16..d4b3b2e 100644 --- a/include/compiz.h +++ b/include/compiz.h @@ -47,6 +47,13 @@ ((((tv1)->tv_sec - 1 - (tv2)->tv_sec) * 1000000) + \ (1000000 + (tv1)->tv_usec - (tv2)->tv_usec)) / 1000 +#define TIMESPECDIFF(ts1, ts2) \ + ((ts1)->tv_sec == (ts2)->tv_sec || (ts1)->tv_nsec >= (ts2)->tv_nsec) ? \ + ((((ts1)->tv_sec - (ts2)->tv_sec) * 1000000) + \ + ((ts1)->tv_nsec - (ts2)->tv_nsec)) / 1000000 : \ + ((((ts1)->tv_sec - 1 - (ts2)->tv_sec) * 1000000) + \ + (1000000 + (ts1)->tv_nsec - (ts2)->tv_nsec)) / 1000000 + #define MULTIPLY_USHORT(us1, us2) \ (((GLuint) (us1) * (GLuint) (us2)) / 0xffff) diff --git a/src/privatescreen.h b/src/privatescreen.h index 237fe03..34890fb 100644 --- a/src/privatescreen.h +++ b/src/privatescreen.h @@ -34,6 +34,7 @@ #include <core/point.h> #include <core/timer.h> #include <core/plugin.h> +#include <time.h> #include <glibmm/main.h> @@ -90,7 +91,7 @@ class CompTimeoutSource : private: - struct timeval mLastTimeout; + struct timespec mLastTimeout; friend class CompTimer; friend class PrivateScreen; @@ -129,13 +130,6 @@ typedef struct _CompDelayedEdgeSettings #define SCREEN_EDGE_BOTTOMRIGHT 7 #define SCREEN_EDGE_NUM 8 -#define TIMEVALDIFF(tv1, tv2) \ - ((tv1)->tv_sec == (tv2)->tv_sec || (tv1)->tv_usec >= (tv2)->tv_usec) ? \ - ((((tv1)->tv_sec - (tv2)->tv_sec) * 1000000) + \ - ((tv1)->tv_usec - (tv2)->tv_usec)) / 1000 : \ - ((((tv1)->tv_sec - 1 - (tv2)->tv_sec) * 1000000) + \ - (1000000 + (tv1)->tv_usec - (tv2)->tv_usec)) / 1000 - struct CompScreenEdge { Window id; unsigned int count; diff --git a/src/screen.cpp b/src/screen.cpp index 03b97bf..fb76b61 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -245,10 +245,11 @@ CompScreen::getFileWatches () const CompTimeoutSource::CompTimeoutSource () : Glib::Source () { - struct timeval tv; + struct timespec ts; - gettimeofday (&tv, 0); - mLastTimeout = tv; + clock_gettime (CLOCK_MONOTONIC, &ts); + + mLastTimeout = ts; set_priority (G_PRIORITY_HIGH); attach (screen->priv->ctx); @@ -276,9 +277,9 @@ CompTimeoutSource::create () bool CompTimeoutSource::prepare (int &timeout) { - struct timeval tv; + struct timespec ts; - gettimeofday (&tv, 0); + clock_gettime (CLOCK_MONOTONIC, &ts); /* Determine time to wait */ @@ -311,12 +312,12 @@ CompTimeoutSource::prepare (int &timeout) it++; } - mLastTimeout = tv; + mLastTimeout = ts; return false; } else { - mLastTimeout = tv; + mLastTimeout = ts; timeout = 0; return true; } @@ -325,11 +326,11 @@ CompTimeoutSource::prepare (int &timeout) bool CompTimeoutSource::check () { - struct timeval tv; - int timeDiff; + struct timespec ts; + int timeDiff; - gettimeofday (&tv, 0); - timeDiff = TIMEVALDIFF (&tv, &mLastTimeout); + clock_gettime (CLOCK_MONOTONIC, &ts); + timeDiff = TIMESPECDIFF (&ts, &mLastTimeout); if (timeDiff < 0) timeDiff = 0; @@ -4827,7 +4828,6 @@ PrivateScreen::PrivateScreen (CompScreen *screen) : desktopHintSize (0), initialized (false) { - memset (history, 0, sizeof (history)); gettimeofday (&lastTimeout, 0); pingTimer.setCallback ( |