gitlab-ci: enable sanitizers for the meson builds
[mesa-waffle.git] / src / waffle / x11 / x11_display.c
blob775bf2470d4eb9eb78e60570e75b14d19aeeb463
1 // SPDX-FileCopyrightText: Copyright 2012 Intel Corporation
2 // SPDX-License-Identifier: BSD-2-Clause
4 #include <assert.h>
6 #include "wcore_error.h"
8 #include "x11_display.h"
9 #include "x11_wrappers.h"
11 bool
12 x11_display_init(struct x11_display *self, const char *name)
14 self->xlib = wrapped_XOpenDisplay(name);
15 if (!self->xlib) {
16 wcore_errorf(WAFFLE_ERROR_UNKNOWN, "XOpenDisplay failed");
17 return false;
20 self->xcb = wrapped_XGetXCBConnection(self->xlib);
21 if (!self->xcb) {
22 wcore_errorf(WAFFLE_ERROR_UNKNOWN, "XGetXCBConnection failed");
23 wrapped_XCloseDisplay(self->xlib);
24 return false;
27 self->screen = DefaultScreen(self->xlib);
29 return true;
32 bool
33 x11_display_teardown(struct x11_display *self)
35 if (!self->xlib)
36 return 1;
38 int error = wrapped_XCloseDisplay(self->xlib);
39 if (error)
40 wcore_errorf(WAFFLE_ERROR_UNKNOWN, "XCloseDisplay failed");
42 return !error;