From 86b29c539dfc3f87490e0b506402b3ff407e6684 Mon Sep 17 00:00:00 2001
From: James Cowgill <james410@cowgill.org.uk>
Date: Mon, 21 Apr 2014 14:42:07 +0100
Subject: [PATCH] Fixed various linux compile errors in EglContext

---
 src/SFML/Window/EglContext.cpp | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/SFML/Window/EglContext.cpp b/src/SFML/Window/EglContext.cpp
index 671a64db..aa751ba8 100644
--- a/src/SFML/Window/EglContext.cpp
+++ b/src/SFML/Window/EglContext.cpp
@@ -27,6 +27,7 @@
 // Headers
 ////////////////////////////////////////////////////////////
 #include <SFML/Window/EglContext.hpp>
+#include <SFML/Window/WindowImpl.hpp>
 #include <SFML/OpenGL.hpp>
 #include <SFML/System/Err.hpp>
 #include <SFML/System/Sleep.hpp>
@@ -35,6 +36,9 @@
 #ifdef SFML_SYSTEM_ANDROID
     #include <SFML/System/Android/Activity.hpp>
 #endif
+#ifdef SFML_SYSTEM_LINUX
+    #include <X11/Xlib.h>
+#endif
 
 namespace
 {
@@ -46,7 +50,7 @@ namespace
         
         if (display == EGL_NO_DISPLAY)
         {
-            eglCheck(eglGetDisplay(EGL_DEFAULT_DISPLAY));
+            display = eglCheck(eglGetDisplay(EGL_DEFAULT_DISPLAY));
             eglCheck(eglInitialize(display, NULL, NULL));
         }
         
@@ -260,12 +264,11 @@ XVisualInfo EglContext::selectBestVisual(::Display* XDisplay, unsigned int bitsP
     EGLConfig config = getBestConfig(display, bitsPerPixel, settings);
     
     // Retrieve the visual id associated with this EGL config
-    EGLint nativeVisualId, nativeVisualType;
+    EGLint nativeVisualId;
     
     eglCheck(eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &nativeVisualId));
-    eglCheck(eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_TYPE, &nativeVisualType));
     
-    if (nativeVisualId = 0 && nativeVisualType == EGL_NONE)
+    if (nativeVisualId == 0)
     {
         // Should never happen...
         err() << "No EGL visual found. You should check your graphics driver" << std::endl;
@@ -273,13 +276,14 @@ XVisualInfo EglContext::selectBestVisual(::Display* XDisplay, unsigned int bitsP
         return XVisualInfo();
     }
     
-    VisualID visualId = static_cast<VisualID>(nativeVisualId);
+    XVisualInfo vTemplate;
+    vTemplate.visualid = static_cast<VisualID>(nativeVisualId);
 
     // Get X11 visuals compatible with this EGL config
     XVisualInfo *availableVisuals, bestVisual;
     int visualCount = 0;
     
-    availableVisuals = XGetVisualInfo(XDisplayy, VisualIDMask, &visualId, &visualCount);
+    availableVisuals = XGetVisualInfo(XDisplay, VisualIDMask, &vTemplate, &visualCount);
     
     if (visualCount == 0)
     {
@@ -290,8 +294,8 @@ XVisualInfo EglContext::selectBestVisual(::Display* XDisplay, unsigned int bitsP
     }
     
     // Pick up the best one
-    bestVisual = availableVisuals[0]
-    XFree(chosenVisualInfo);
+    bestVisual = availableVisuals[0];
+    XFree(availableVisuals);
     
     return bestVisual;
 }