aboutsummaryrefslogtreecommitdiffstats
path: root/Samples/CommonSrc/Platform/Linux_Platform.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Samples/CommonSrc/Platform/Linux_Platform.cpp')
-rw-r--r--Samples/CommonSrc/Platform/Linux_Platform.cpp53
1 files changed, 24 insertions, 29 deletions
diff --git a/Samples/CommonSrc/Platform/Linux_Platform.cpp b/Samples/CommonSrc/Platform/Linux_Platform.cpp
index c9d3e40..e94b37f 100644
--- a/Samples/CommonSrc/Platform/Linux_Platform.cpp
+++ b/Samples/CommonSrc/Platform/Linux_Platform.cpp
@@ -24,7 +24,7 @@ otherwise accompanies this software in either electronic or hard copy form.
// Renderers
#include "../Render/Render_GL_Device.h"
-#include <X11/extensions/Xinerama.h>
+#include <X11/extensions/Xrandr.h>
namespace OVR { namespace Platform { namespace Linux {
@@ -156,7 +156,7 @@ void PlatformCore::SetWindowTitle(const char* title)
{
XStoreName(Disp, Win, title);
}
-
+
void PlatformCore::ShowWindow(bool show)
{
if (show)
@@ -227,12 +227,12 @@ static KeyCode MapXKToKeyCode(unsigned vk)
{
key = vk - XK_F1 + Key_F1;
}
- else
+ else
{
for (unsigned i = 0; i< (sizeof(KeyMap) / sizeof(KeyMap[1])); i++)
{
if (vk == KeyMap[i][0])
- {
+ {
key = KeyMap[i][1];
break;
}
@@ -311,7 +311,7 @@ void PlatformCore::processEvent(XEvent& event)
case MapNotify:
if (MMode == Mouse_Relative)
- {
+ {
XWarpPointer(Disp, Win, Win, 0,0,Width,Height, Width/2, Height/2);
showCursor(false);
}
@@ -323,7 +323,7 @@ void PlatformCore::processEvent(XEvent& event)
//grab
if (MMode == Mouse_RelativeEscaped)
- {
+ {
XWarpPointer(Disp, Win, Win, 0,0,Width,Height, Width/2, Height/2);
showCursor(false);
MMode = Mouse_Relative;
@@ -333,7 +333,7 @@ void PlatformCore::processEvent(XEvent& event)
case FocusOut:
if (MMode == Mouse_Relative)
- {
+ {
MMode = Mouse_RelativeEscaped;
showCursor(true);
}
@@ -370,28 +370,23 @@ int PlatformCore::Run()
bool PlatformCore::determineScreenOffset(int screenId, int* screenOffsetX, int* screenOffsetY)
{
- Display* display = XOpenDisplay(NULL);
-
- bool foundScreen = false;
-
- if (display)
- {
- int numberOfScreens;
- XineramaScreenInfo* screens = XineramaQueryScreens(display, &numberOfScreens);
-
- if (screenId < numberOfScreens)
- {
- XineramaScreenInfo screenInfo = screens[screenId];
- *screenOffsetX = screenInfo.x_org;
- *screenOffsetY = screenInfo.y_org;
-
- foundScreen = true;
+ bool result = false;
+ if (screenId) {
+ Display* display = XOpenDisplay(NULL);
+ XRRScreenResources *screen = XRRGetScreenResources(display, DefaultRootWindow(display));
+ XRROutputInfo * info = XRRGetOutputInfo (display, screen, screenId);
+ if (info->crtc) {
+ XRRCrtcInfo * crtc_info = XRRGetCrtcInfo (display, screen, info->crtc);
+ *screenOffsetX = crtc_info->x;
+ *screenOffsetY = crtc_info->y;
+ XRRFreeCrtcInfo(crtc_info);
+ result = true;
}
-
- XFree(screens);
+ XRRFreeOutputInfo (info);
+ XRRFreeScreenResources(screen);
}
- return foundScreen;
+ return result;
}
void PlatformCore::showWindowDecorations(bool show)
@@ -476,11 +471,11 @@ RenderDevice* PlatformCore::SetupGraphics(const SetupGraphicsDeviceSet& setupGra
{
const SetupGraphicsDeviceSet* setupDesc = setupGraphicsDesc.PickSetupDevice(type);
OVR_ASSERT(setupDesc);
-
+
pRender = *setupDesc->pCreateDevice(rp, this);
if (pRender)
pRender->SetWindowSize(Width, Height);
-
+
return pRender.GetPtr();
}
@@ -540,7 +535,7 @@ void RenderDevice::Shutdown()
}}}}
-int main(int argc, const char* argv[])
+int main(int argc, char** argv)
{
using namespace OVR;
using namespace OVR::Platform;