Permalink
Browse files

X11: move handling of xrandr events

  • Loading branch information...
1 parent 9aef2c8 commit 18311d811f6dfe295ae1ee66898cb1145b2dfe4f @elupus committed Jul 15, 2012
@@ -35,6 +35,10 @@
#include "guilib/GUIWindowManager.h"
#include "input/MouseStat.h"
+#if defined(HAS_XRANDR)
+#include <X11/extensions/Xrandr.h>
+#endif
+
#ifdef HAS_SDL_JOYSTICK
#include "input/SDLJoystick.h"
#endif
@@ -234,6 +238,13 @@ bool CWinEventsX11::Init(Display *dpy, Window win)
WinEvents->m_symLookupTable[SymMappingsX11[i][0]] = SymMappingsX11[i][1];
}
+ // register for xrandr events
+#if defined(HAS_XRANDR)
+ int iReturn;
+ XRRQueryExtension(WinEvents->m_display, &WinEvents->m_RREventBase, &iReturn);
+ XRRSelectInput(WinEvents->m_display, WinEvents->m_window, RRScreenChangeNotifyMask);
+#endif
+
return true;
}
@@ -515,6 +526,15 @@ bool CWinEventsX11::MessagePump()
break;
}
}// switch event.type
+
+#if defined(HAS_XRANDR)
+ if (WinEvents && xevent.type == WinEvents->m_RREventBase + RRScreenChangeNotify)
+ {
+ XRRUpdateConfiguration(&xevent);
+ g_Windowing.NotifyXRREvent();
+ }
+#endif
+
}// while
ret |= ProcessKeyRepeat();
@@ -51,4 +51,5 @@ class CWinEventsX11 : public CWinEventsBase
XbmcThreads::EndTime m_repeatKeyTimeout;
std::map<uint32_t,uint32_t> m_symLookupTable;
int m_keymodState;
+ int m_RREventBase;
};
@@ -641,33 +641,21 @@ bool CWinSystemX11::Show(bool raise)
void CWinSystemX11::CheckDisplayEvents()
{
-#if defined(HAS_XRANDR)
- bool bGotEvent(false);
- bool bTimeout(false);
- XEvent Event;
- while (XCheckTypedEvent(m_dpy, m_RREventBase + RRScreenChangeNotify, &Event))
- {
- if (Event.type == m_RREventBase + RRScreenChangeNotify)
- {
- CLog::Log(LOGDEBUG, "%s: Received RandR event %i", __FUNCTION__, Event.type);
- bGotEvent = true;
- }
- XRRUpdateConfiguration(&Event);
- }
-
- // check fail safe timer
if (m_dpyLostTime && CurrentHostCounter() - m_dpyLostTime > (uint64_t)3 * CurrentHostFrequency())
{
CLog::Log(LOGERROR, "%s - no display event after 3 seconds", __FUNCTION__);
- bTimeout = true;
- }
-
- if (bGotEvent || bTimeout)
- {
- CLog::Log(LOGDEBUG, "%s - notify display reset event", __FUNCTION__);
OnResetDevice();
}
+}
+
+void CWinSystemX11::NotifyXRREvent()
+{
+ CLog::Log(LOGDEBUG, "%s - notify display reset event", __FUNCTION__);
+
+#if defined(HAS_XRANDR)
+ g_xrandr.Query(true);
#endif
+ OnResetDevice();
}
void CWinSystemX11::OnLostDevice()
@@ -72,6 +72,7 @@ class CWinSystemX11 : public CWinSystemBase
// Local to WinSystemX11 only
Display* GetDisplay() { return m_dpy; }
GLXWindow GetWindow() { return m_glWindow; }
+ void NotifyXRREvent();
protected:
void RefreshWindowState();
@@ -89,7 +90,6 @@ class CWinSystemX11 : public CWinSystemBase
Pixmap m_icon;
bool m_bWasFullScreenBeforeMinimize;
bool m_minimized;
- int m_RREventBase;
CCriticalSection m_resourceSection;
std::vector<IDispResource*> m_resources;
uint64_t m_dpyLostTime;

0 comments on commit 18311d8

Please sign in to comment.