st/egl: Follow the portability guide.
[mesa.git] / src / gallium / state_trackers / egl / x11 / native_x11.c
index 8eb542bd82780cd1d59f04e0a452ac309026e79d..b6d51bbf9fbe3063b1881fcc116b1e57fb02830d 100644 (file)
  * The above copyright notice and this permission notice shall be included
  * in all copies or substantial portions of the Software.
  *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
  */
 
-#include <stdio.h>
 #include <string.h>
 #include "util/u_debug.h"
 #include "util/u_memory.h"
+#include "util/u_string.h"
 #include "state_tracker/drm_api.h"
 #include "egllog.h"
 
@@ -40,8 +41,8 @@ static void
 x11_probe_destroy(struct native_probe *nprobe)
 {
    if (nprobe->data)
-      free(nprobe->data);
-   free(nprobe);
+      FREE(nprobe->data);
+   FREE(nprobe);
 }
 
 struct native_probe *
@@ -61,7 +62,7 @@ native_create_probe(EGLNativeDisplayType dpy)
    if (!xdpy) {
       xdpy = XOpenDisplay(NULL);
       if (!xdpy) {
-         free(nprobe);
+         FREE(nprobe);
          return NULL;
       }
    }
@@ -70,7 +71,7 @@ native_create_probe(EGLNativeDisplayType dpy)
    xscr = x11_screen_create(xdpy, scr);
    if (xscr) {
       if (x11_screen_support(xscr, X11_SCREEN_EXTENSION_DRI2)) {
-         driver_name = x11_screen_probe_dri2(xscr);
+         driver_name = x11_screen_probe_dri2(xscr, NULL, NULL);
          if (driver_name)
             nprobe->data = strdup(driver_name);
       }
@@ -118,15 +119,16 @@ native_get_name(void)
       api = drm_api_create();
 
    if (api)
-      snprintf(x11_name, sizeof(x11_name), "X11/%s", api->name);
+      util_snprintf(x11_name, sizeof(x11_name), "X11/%s", api->name);
    else
-      snprintf(x11_name, sizeof(x11_name), "X11");
+      util_snprintf(x11_name, sizeof(x11_name), "X11");
 
    return x11_name;
 }
 
 struct native_display *
-native_create_display(EGLNativeDisplayType dpy)
+native_create_display(EGLNativeDisplayType dpy,
+                      struct native_event_handler *event_handler)
 {
    struct native_display *ndpy = NULL;
    boolean force_sw;
@@ -136,14 +138,14 @@ native_create_display(EGLNativeDisplayType dpy)
 
    force_sw = debug_get_bool_option("EGL_SOFTWARE", FALSE);
    if (api && !force_sw) {
-      ndpy = x11_create_dri2_display(dpy, api);
+      ndpy = x11_create_dri2_display(dpy, event_handler, api);
    }
 
    if (!ndpy) {
       EGLint level = (force_sw) ? _EGL_INFO : _EGL_WARNING;
 
       _eglLog(level, "use software fallback");
-      ndpy = x11_create_ximage_display(dpy, TRUE);
+      ndpy = x11_create_ximage_display(dpy, event_handler);
    }
 
    return ndpy;