1 // Copyright 2012 Intel Corporation
3 // All rights reserved.
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
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.
31 #include "wcore_display.h"
32 #include "wcore_util.h"
34 #include "wegl_display.h"
36 #include "waffle_wayland.h"
38 struct wcore_platform
;
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
)
56 struct wegl_display
*wegl_self
= container_of(wc_self
, struct wegl_display
, wcore
);
57 return container_of(wegl_self
, struct wayland_display
, wegl
);
65 wayland_display_connect(struct wcore_platform
*wc_plat
,
69 wayland_display_destroy(struct wcore_display
*wc_self
);
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.
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
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.
92 wayland_display_sync(struct wayland_display
*dpy
);