gbm: factor out gbm_window_{init,teardown}
[mesa-waffle.git] / src / waffle / wayland / wayland_display.h
blob722e379ad7507fe2ec2a3ed022f8c644b0114d45
1 // Copyright 2012 Intel Corporation
2 //
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // - Redistributions of source code must retain the above copyright notice, this
9 // list of conditions and the following disclaimer.
11 // - Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #pragma once
28 #include <stdbool.h>
29 #include <stdint.h>
31 #include "wcore_display.h"
32 #include "wcore_util.h"
34 #include "wegl_display.h"
36 #include "waffle_wayland.h"
38 struct wcore_platform;
39 struct wl_display;
40 struct wl_compositor;
41 struct wl_shell;
43 struct wayland_display {
44 struct wl_display *wl_display;
45 struct wl_registry *wl_registry;
46 struct wl_compositor *wl_compositor;
47 struct wl_shell *wl_shell;
49 struct wegl_display wegl;
52 static inline struct wayland_display*
53 wayland_display(struct wcore_display *wc_self)
55 if (wc_self) {
56 struct wegl_display *wegl_self = container_of(wc_self, struct wegl_display, wcore);
57 return container_of(wegl_self, struct wayland_display, wegl);
59 else {
60 return NULL;
64 struct wcore_display*
65 wayland_display_connect(struct wcore_platform *wc_plat,
66 const char *name);
68 bool
69 wayland_display_destroy(struct wcore_display *wc_self);
71 void
72 wayland_display_fill_native(struct wayland_display *self,
73 struct waffle_wayland_display *n_dpy);
75 union waffle_native_display*
76 wayland_display_get_native(struct wcore_display *wc_self);
78 /// @brief Synchronize with server.
79 ///
80 /// Wayland has flushing requirements that differ from X, largely due to
81 /// Wayland being agressively asyncrhonous. For example, according to
82 /// wl_display(3), in event loops "the client should always call
83 /// wl_display_dispatch_pending() and then wl_display_flush() prior to going
84 /// back to sleep". Otherwise, all pending requests may not be dispatched to
85 /// the server.
86 ///
87 /// Waffle can't expect the client to be aware of Wayland's flushing
88 /// requirements and to make the needed native Wayland calls before blocking.
89 /// Instead, the only sensible solution (for now, at least) is to make the
90 /// public entry points synchronous.
91 bool
92 wayland_display_sync(struct wayland_display *dpy);