Skip to content

Commit b798888

Browse files
committed
stuff
1 parent 5ab22b3 commit b798888

5 files changed

Lines changed: 87 additions & 39 deletions

File tree

src/ruisapp/glue/linux/wayland/glue.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
5656
#include "wayland_surface.cxx" // NOLINT(bugprone-suspicious-include, "not suspicious")
5757
#include "wayland_touch.cxx" // NOLINT(bugprone-suspicious-include, "not suspicious")
5858
#include "window.cxx" // NOLINT(bugprone-suspicious-include, "not suspicious")
59+
#include "xdg_surface.cxx" // NOLINT(bugprone-suspicious-include, "not suspicious")
5960
#include "xdg_toplevel.cxx" // NOLINT(bugprone-suspicious-include, "not suspicious")
6061

6162
using namespace std::string_view_literals;
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#include "xdg_surface.hxx"
2+
3+
#include "application.hxx"
4+
5+
xdg_surface_wrapper::xdg_surface_wrapper(
6+
wayland_surface_wrapper& wayland_surface, //
7+
xdg_wm_base_wrapper& xdg_wm_base
8+
) :
9+
wayland_surface(wayland_surface),
10+
surface(xdg_wm_base_get_xdg_surface(
11+
xdg_wm_base.wm_base, //
12+
wayland_surface.surface
13+
))
14+
{
15+
if (!this->surface) {
16+
throw std::runtime_error("could not create wayland xdg surface");
17+
}
18+
19+
utki::log_debug([&](auto& o) {
20+
auto id = wl_proxy_get_id(reinterpret_cast<wl_proxy*>(this->surface));
21+
o << "xgd_surface: CREATED, id = " << id << std::endl;
22+
});
23+
24+
xdg_surface_add_listener(
25+
this->surface, //
26+
&listener,
27+
this // user data
28+
);
29+
}
30+
31+
void xdg_surface_wrapper::xdg_surface_configure(
32+
void* data, //
33+
xdg_surface* surface,
34+
uint32_t serial
35+
)
36+
{
37+
utki::assert(data, SL);
38+
auto& self = *static_cast<xdg_surface_wrapper*>(data);
39+
40+
utki::log_debug([&](auto& o) {
41+
auto id = wl_proxy_get_id(reinterpret_cast<wl_proxy*>(surface));
42+
o << "xgd_surface: CONFIGURE for surface id = " << id << std::endl;
43+
});
44+
45+
// Wayland protocol requires to acknowledge the configure event
46+
xdg_surface_ack_configure(
47+
surface, //
48+
serial
49+
);
50+
51+
auto& glue = get_glue();
52+
53+
auto window = glue.get_window(self.wayland_surface.surface);
54+
if (!window) {
55+
utki::logcat_debug(" could not find window object, perhaps called for shared gl context window", '\n');
56+
utki::assert(self.wayland_surface.surface == glue.get_shared_gl_context_window_id(), SL);
57+
return;
58+
}
59+
60+
auto& win = *window;
61+
auto& natwin = win.ruis_native_window.get();
62+
63+
// swap EGL frame buffers with the window's EGL context made current
64+
win.gui.context.get().ren().ctx().apply([&]() {
65+
natwin.swap_frame_buffers();
66+
});
67+
68+
// self.wayland_surface.commit();
69+
}

src/ruisapp/glue/linux/wayland/xdg_surface.hxx

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -28,48 +28,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2828

2929
namespace {
3030
struct xdg_surface_wrapper {
31+
wayland_surface_wrapper& wayland_surface;
32+
3133
xdg_surface* const surface;
3234

35+
static void xdg_surface_configure(
36+
void* data, //
37+
xdg_surface* surface,
38+
uint32_t serial
39+
);
40+
3341
constexpr static const xdg_surface_listener listener = {
34-
.configure =
35-
[](void* data, //
36-
xdg_surface* surface,
37-
uint32_t serial) {
38-
utki::log_debug([&](auto& o) {
39-
auto id = wl_proxy_get_id(reinterpret_cast<wl_proxy*>(surface));
40-
o << "xgd_surface: CONFIGURE for surface id = " << id << std::endl;
41-
});
42-
xdg_surface_ack_configure(
43-
surface, //
44-
serial
45-
);
46-
}, //
42+
.configure = &xdg_surface_configure //
4743
};
4844

4945
xdg_surface_wrapper(
5046
wayland_surface_wrapper& wayland_surface, //
5147
xdg_wm_base_wrapper& xdg_wm_base
52-
) :
53-
surface(xdg_wm_base_get_xdg_surface(
54-
xdg_wm_base.wm_base, //
55-
wayland_surface.surface
56-
))
57-
{
58-
if (!this->surface) {
59-
throw std::runtime_error("could not create wayland xdg surface");
60-
}
61-
62-
utki::log_debug([&](auto& o) {
63-
auto id = wl_proxy_get_id(reinterpret_cast<wl_proxy*>(this->surface));
64-
o << "xgd_surface: CREATED, id = " << id << std::endl;
65-
});
66-
67-
xdg_surface_add_listener(
68-
this->surface, //
69-
&listener,
70-
nullptr
71-
);
72-
}
48+
);
7349

7450
xdg_surface_wrapper(const xdg_surface_wrapper&) = delete;
7551
xdg_surface_wrapper& operator=(const xdg_surface_wrapper&) = delete;

src/ruisapp/glue/linux/wayland/xdg_toplevel.cxx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,17 @@ void xdg_toplevel_wrapper::xdg_toplevel_configure(
162162
// Right after creating a Wayland surface, according to the Wayland protocol, it
163163
// should do the initial configure call, after which one is supposed to do the
164164
// initial surface commit. In case of EGL we have to call eglSwapBuffers(), which will do the
165-
// surface commit for us. This makes the sirface to be mapped to the screen and become visible.
165+
// surface commit for us. This makes the surface to be mapped to the screen and become visible.
166166
// If this sequence is not honored the surface will not appear on the screen.
167167

168168
utki::logcat_debug(" initial configure call", '\n');
169169

170170
// swap EGL frame buffers with the window's EGL context made current
171-
win.gui.context.get().ren().ctx().apply([&]() {
172-
natwin.swap_frame_buffers();
173-
});
171+
// win.gui.context.get().ren().ctx().apply([&]() {
172+
// natwin.swap_frame_buffers();
173+
// });
174+
175+
// self.wayland_surface.commit();
174176
return;
175177
}
176178

src/ruisapp/glue/linux/wayland/xdg_toplevel.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct xdg_toplevel_wrapper {
4848
);
4949

5050
constexpr static const xdg_toplevel_listener listener = {
51-
.configure = xdg_toplevel_configure,
51+
.configure = &xdg_toplevel_configure,
5252
.close = &xdg_toplevel_close,
5353
};
5454

0 commit comments

Comments
 (0)