typedef XVisualInfo* (*GetVisualInfoFunction)(Display *dpy);
+typedef enum x11WindowSystemStates
+{
+ REDRAW_STATE = 0,
+ WAKEUP_STATE = 1,
+ IDLE_STATE = 2,
+ UNKOWN_STATE
+} X11WindowSystemStates;
+
class X11WindowSystem: public BaseWindowSystem
{
public:
bool start();
void stop();
static XVisualInfo * getDefaultVisual(Display *dpy);
- void signalRedrawEvent();
-
- Display* getNativeDisplayHandle()
- {
- return x11Display;
- }
-
- Window getCompositorNativeWindowHandle()
- {
- return CompositorWindow;
- }
-
+ void signalRedrawEvent();
+ void wakeUpRendererThread();
+ void setSystemState (X11WindowSystemStates state);
+ X11WindowSystemStates getSystemState ();
+ Display* getNativeDisplayHandle();
+ Window getCompositorNativeWindowHandle();
virtual void allocatePlatformSurface(Surface *surface);
void doScreenShot(std::string fileName);
void doScreenShotOfLayer(std::string fileName, const uint id);
void doScreenShotOfSurface(std::string fileName, const uint id, const uint layer_id);
-
private:
ScreenShotType takeScreenshot;
std::string screenShotFile;
static int composite_opcode;
int composite_event, composite_error;
int composite_major, composite_minor;
- static int damage_opcode;
- int damage_event, damage_error;
- int damage_major, damage_minor;
+ static int damage_opcode;
+ int damage_event, damage_error;
+ int damage_major, damage_minor;
static const char CompositorWindowTitle[];
bool m_running;
bool m_initialized;
bool m_success;
+ X11WindowSystemStates m_systemState;
protected:
Display* x11Display;
void printDebug();
void* EventLoop();
static int error(Display *dpy, XErrorEvent *ev);
- bool redrawEvent;
+
static bool m_xerror;
#ifdef WITH_INPUT_EVENTS
void ManageXInputEvent(XEvent *pevent);
#endif
-
+
friend void * X11eventLoopCallback(void *);
};
+inline void X11WindowSystem::setSystemState (X11WindowSystemStates state)
+{
+ m_systemState = state;
+};
+inline X11WindowSystemStates X11WindowSystem::getSystemState ()
+{
+ return m_systemState;
+};
+
+inline Display* X11WindowSystem::getNativeDisplayHandle()
+{
+ return x11Display;
+}
+
+inline Window X11WindowSystem::getCompositorNativeWindowHandle()
+{
+ return CompositorWindow;
+}
+
#endif /* _X11WINDOWSYSTEM_H_ */
, m_success(false)
, windowWidth(width)
, windowHeight(height)
-, redrawEvent(false)
+, m_systemState(IDLE_STATE)
{
LOG_DEBUG("X11WindowSystem", "creating X11WindowSystem");
CheckRedrawAllLayers();
if (m_damaged)
- {
+ {
graphicSystem->clearBackground();
RedrawAllLayers();
- m_pScene->unlockScene();
+ m_pScene->unlockScene();
graphicSystem->swapBuffers();
-
if (debugMode)
{
printDebug();
#ifndef WITH_XTHREADS
}
#endif //WITH_XTHREADS
- if (this->redrawEvent)
+ if (this->m_systemState == REDRAW_STATE)
{
- this->redrawEvent = false;
+ LOG_DEBUG("X11WindowSystem", "Enter Redraw State");
+ this->m_systemState = IDLE_STATE;
// check if we are supposed to take screenshot
if (this->takeScreenshot!=ScreenShotNone)
checkRedraw = true;
}
+ }
+ else if (this->m_systemState == WAKEUP_STATE)
+ {
+ LOG_DEBUG("X11WindowSystem", "Enter Wake Up State");
}
if (checkRedraw)
#ifdef WITH_XTHREADS
static Display* displaySignal = NULL;
#endif //WITH_XTHREADS
-void X11WindowSystem::signalRedrawEvent()
+void X11WindowSystem::wakeUpRendererThread()
{
- // set flag that redraw is needed
- redrawEvent = true;
- m_damaged = true;
#ifdef WITH_XTHREADS
// send dummy expose event, to wake up blocking x11 event loop (XNextEvent)
LOG_DEBUG("X11WindowSystem", "Sending dummy event to wake up renderer thread");
#endif //WITH_XTHREADS
}
+void X11WindowSystem::signalRedrawEvent()
+{
+ // set flag that redraw is needed
+ this->m_systemState = REDRAW_STATE;
+ m_damaged = true;
+ this->wakeUpRendererThread();
+}
+
void X11WindowSystem::cleanup(){
LOG_DEBUG("X11WindowSystem", "Cleanup");
if (None != CompositorWindow)