show shutdown menu on long power button press
[enigma2.git] / lib / base / ebase.cpp
index e53aa74525e800b2745944ff7e63d9efed398753..08c15610d4cb38dce3a0e2fbbe98fd5578f59217 100644 (file)
@@ -197,12 +197,17 @@ int eMainloop::processOneEvent(unsigned int twisted_timeout, PyObject **res, ePy
                }
        }
 
+       m_is_idle = 1;
+
        if (this == eApp)
+       {
                Py_BEGIN_ALLOW_THREADS
                ret = ::poll(pfd, fdcount, poll_timeout);
                Py_END_ALLOW_THREADS
-       else
+       else
                ret = ::poll(pfd, fdcount, poll_timeout);
+       
+       m_is_idle = 0;
 
                        /* ret > 0 means that there are some active poll entries. */
        if (ret > 0)
@@ -289,11 +294,13 @@ int eMainloop::iterate(unsigned int twisted_timeout, PyObject **res, ePyObject d
                {
                        timeval now, timeout;
                        gettimeofday(&now, 0);
-                       m_twisted_timer -= time_offset;
+                       m_twisted_timer += time_offset;  // apply pending offset
                        if (m_twisted_timer<=now) // timeout
                                return 0;
                        timeout = m_twisted_timer - now;
                        to = timeout.tv_sec * 1000 + timeout.tv_usec / 1000;
+                       // remove pending offset .. it is re-applied in next call of processOneEvent.. applyTimeOffset
+                       m_twisted_timer -= time_offset;  
                }
                ret = processOneEvent(to, res, dict);
        } while ( !ret && !(res && *res) );