Skip to content

Commit

Permalink
Merge pull request #87764 from Riteo/wayland-native-handle
Browse files Browse the repository at this point in the history
Wayland: Implement `window_get_native_handle`
  • Loading branch information
akien-mga authored Jan 31, 2024
2 parents f23fda3 + d8658df commit 9adb7c7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
31 changes: 31 additions & 0 deletions platform/linuxbsd/wayland/display_server_wayland.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,37 @@ Vector<DisplayServer::WindowID> DisplayServerWayland::get_window_list() const {
return ret;
}

int64_t DisplayServerWayland::window_get_native_handle(HandleType p_handle_type, WindowID p_window) const {
MutexLock mutex_lock(wayland_thread.mutex);

switch (p_handle_type) {
case DISPLAY_HANDLE: {
return (int64_t)wayland_thread.get_wl_display();
} break;

case WINDOW_HANDLE: {
return (int64_t)wayland_thread.window_get_wl_surface(p_window);
} break;

case WINDOW_VIEW: {
return 0; // Not supported.
} break;

#ifdef GLES3_ENABLED
case OPENGL_CONTEXT: {
if (egl_manager) {
return (int64_t)egl_manager->get_context(p_window);
}
return 0;
} break;
#endif // GLES3_ENABLED

default: {
return 0;
} break;
}
}

DisplayServer::WindowID DisplayServerWayland::get_window_at_screen_position(const Point2i &p_position) const {
// Standard Wayland APIs don't support this.
return MAIN_WINDOW_ID;
Expand Down
2 changes: 2 additions & 0 deletions platform/linuxbsd/wayland/display_server_wayland.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ class DisplayServerWayland : public DisplayServer {

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

virtual int64_t window_get_native_handle(HandleType p_handle_type, WindowID p_window = MAIN_WINDOW_ID) const override;

virtual WindowID get_window_at_screen_position(const Point2i &p_position) const override;

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

0 comments on commit 9adb7c7

Please sign in to comment.