Skip to content

Commit 9adb7c7

Browse files
authored
Merge pull request #87764 from Riteo/wayland-native-handle
Wayland: Implement `window_get_native_handle`
2 parents f23fda3 + d8658df commit 9adb7c7

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
@@ -576,6 +576,37 @@ Vector<DisplayServer::WindowID> DisplayServerWayland::get_window_list() const {
576576
return ret;
577577
}
578578

579+
int64_t DisplayServerWayland::window_get_native_handle(HandleType p_handle_type, WindowID p_window) const {
580+
MutexLock mutex_lock(wayland_thread.mutex);
581+
582+
switch (p_handle_type) {
583+
case DISPLAY_HANDLE: {
584+
return (int64_t)wayland_thread.get_wl_display();
585+
} break;
586+
587+
case WINDOW_HANDLE: {
588+
return (int64_t)wayland_thread.window_get_wl_surface(p_window);
589+
} break;
590+
591+
case WINDOW_VIEW: {
592+
return 0; // Not supported.
593+
} break;
594+
595+
#ifdef GLES3_ENABLED
596+
case OPENGL_CONTEXT: {
597+
if (egl_manager) {
598+
return (int64_t)egl_manager->get_context(p_window);
599+
}
600+
return 0;
601+
} break;
602+
#endif // GLES3_ENABLED
603+
604+
default: {
605+
return 0;
606+
} break;
607+
}
608+
}
609+
579610
DisplayServer::WindowID DisplayServerWayland::get_window_at_screen_position(const Point2i &p_position) const {
580611
// Standard Wayland APIs don't support this.
581612
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
@@ -203,6 +203,8 @@ class DisplayServerWayland : public DisplayServer {
203203

204204
virtual Vector<DisplayServer::WindowID> get_window_list() const override;
205205

206+
virtual int64_t window_get_native_handle(HandleType p_handle_type, WindowID p_window = MAIN_WINDOW_ID) const override;
207+
206208
virtual WindowID get_window_at_screen_position(const Point2i &p_position) const override;
207209

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

0 commit comments

Comments
 (0)