Skip to content

Commit d8658df

Browse files
committed
Wayland: implement window_get_native_handle
This will be the most useful for stuff like OpenXR, although we'd need a way to eventually also expose the EGL handles.
1 parent 313f623 commit d8658df

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

platform/linuxbsd/wayland/display_server_wayland.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,37 @@ Vector<DisplayServer::WindowID> DisplayServerWayland::get_window_list() const {
557557
return ret;
558558
}
559559

560+
int64_t DisplayServerWayland::window_get_native_handle(HandleType p_handle_type, WindowID p_window) const {
561+
MutexLock mutex_lock(wayland_thread.mutex);
562+
563+
switch (p_handle_type) {
564+
case DISPLAY_HANDLE: {
565+
return (int64_t)wayland_thread.get_wl_display();
566+
} break;
567+
568+
case WINDOW_HANDLE: {
569+
return (int64_t)wayland_thread.window_get_wl_surface(p_window);
570+
} break;
571+
572+
case WINDOW_VIEW: {
573+
return 0; // Not supported.
574+
} break;
575+
576+
#ifdef GLES3_ENABLED
577+
case OPENGL_CONTEXT: {
578+
if (egl_manager) {
579+
return (int64_t)egl_manager->get_context(p_window);
580+
}
581+
return 0;
582+
} break;
583+
#endif // GLES3_ENABLED
584+
585+
default: {
586+
return 0;
587+
} break;
588+
}
589+
}
590+
560591
DisplayServer::WindowID DisplayServerWayland::get_window_at_screen_position(const Point2i &p_position) const {
561592
// Standard Wayland APIs don't support this.
562593
return MAIN_WINDOW_ID;

platform/linuxbsd/wayland/display_server_wayland.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ class DisplayServerWayland : public DisplayServer {
200200

201201
virtual Vector<DisplayServer::WindowID> get_window_list() const override;
202202

203+
virtual int64_t window_get_native_handle(HandleType p_handle_type, WindowID p_window = MAIN_WINDOW_ID) const override;
204+
203205
virtual WindowID get_window_at_screen_position(const Point2i &p_position) const override;
204206

205207
virtual void window_attach_instance_id(ObjectID p_instance, WindowID p_window_id = MAIN_WINDOW_ID) override;

0 commit comments

Comments
 (0)