Cleanup
This commit is contained in:
@@ -41,22 +41,21 @@ void LinuxVulkanPlatform::CreateSurface(Window* window, GPUDeviceVulkan* device,
|
|||||||
VALIDATE_VULKAN_RESULT(vkCreateXlibSurfaceKHR(instance, &surfaceCreateInfo, nullptr, surface));
|
VALIDATE_VULKAN_RESULT(vkCreateXlibSurfaceKHR(instance, &surfaceCreateInfo, nullptr, surface));
|
||||||
#else
|
#else
|
||||||
SDLWindow* sdlWindow = static_cast<Window*>(window);
|
SDLWindow* sdlWindow = static_cast<Window*>(window);
|
||||||
X11::Window x11Window = (X11::Window)sdlWindow->GetX11WindowHandle();
|
void* windowHandle = window->GetNativePtr();
|
||||||
wl_surface* waylandSurface = (wl_surface*)sdlWindow->GetWaylandSurfacePtr();
|
if (SDLPlatform::UsesWayland())
|
||||||
if (waylandSurface != nullptr)
|
|
||||||
{
|
{
|
||||||
VkWaylandSurfaceCreateInfoKHR surfaceCreateInfo;
|
VkWaylandSurfaceCreateInfoKHR surfaceCreateInfo;
|
||||||
RenderToolsVulkan::ZeroStruct(surfaceCreateInfo, VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR);
|
RenderToolsVulkan::ZeroStruct(surfaceCreateInfo, VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR);
|
||||||
surfaceCreateInfo.display = (wl_display*)sdlWindow->GetWaylandDisplay();
|
surfaceCreateInfo.display = (wl_display*)sdlWindow->GetWaylandDisplay();
|
||||||
surfaceCreateInfo.surface = waylandSurface;
|
surfaceCreateInfo.surface = (wl_surface*)windowHandle;
|
||||||
VALIDATE_VULKAN_RESULT(vkCreateWaylandSurfaceKHR(instance, &surfaceCreateInfo, nullptr, surface));
|
VALIDATE_VULKAN_RESULT(vkCreateWaylandSurfaceKHR(instance, &surfaceCreateInfo, nullptr, surface));
|
||||||
}
|
}
|
||||||
else if (x11Window != 0)
|
else if (SDLPlatform::UsesX11())
|
||||||
{
|
{
|
||||||
VkXlibSurfaceCreateInfoKHR surfaceCreateInfo;
|
VkXlibSurfaceCreateInfoKHR surfaceCreateInfo;
|
||||||
RenderToolsVulkan::ZeroStruct(surfaceCreateInfo, VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR);
|
RenderToolsVulkan::ZeroStruct(surfaceCreateInfo, VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR);
|
||||||
surfaceCreateInfo.dpy = (X11::Display*)sdlWindow->GetX11Display();
|
surfaceCreateInfo.dpy = (X11::Display*)sdlWindow->GetX11Display();
|
||||||
surfaceCreateInfo.window = x11Window;
|
surfaceCreateInfo.window = (X11::Window)windowHandle;
|
||||||
VALIDATE_VULKAN_RESULT(vkCreateXlibSurfaceKHR(instance, &surfaceCreateInfo, nullptr, surface));
|
VALIDATE_VULKAN_RESULT(vkCreateXlibSurfaceKHR(instance, &surfaceCreateInfo, nullptr, surface));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -656,7 +656,7 @@ DragDropEffect Window::DoDragDropX11(const StringView& data)
|
|||||||
#if !PLATFORM_SDL
|
#if !PLATFORM_SDL
|
||||||
X11::Window mainWindow = _window;
|
X11::Window mainWindow = _window;
|
||||||
#else
|
#else
|
||||||
X11::Window mainWindow = static_cast<X11::Window>(GetX11WindowHandle());
|
X11::Window mainWindow = reinterpret_cast<X11::Window>(GetNativePtr());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Make sure SDL hasn't grabbed the pointer, and force ungrab it
|
// Make sure SDL hasn't grabbed the pointer, and force ungrab it
|
||||||
@@ -1105,7 +1105,7 @@ void SDLClipboard::SetText(const StringView& text)
|
|||||||
|
|
||||||
if (X11Impl::xDisplay)
|
if (X11Impl::xDisplay)
|
||||||
{
|
{
|
||||||
X11::Window window = (X11::Window)(mainWindow->GetX11WindowHandle());
|
X11::Window window = (X11::Window)(mainWindow->GetNativePtr());
|
||||||
X11Impl::ClipboardText.Set(text.Get(), text.Length());
|
X11Impl::ClipboardText.Set(text.Get(), text.Length());
|
||||||
X11::XSetSelectionOwner(X11Impl::xDisplay, X11Impl::xAtomClipboard, window, CurrentTime); // CLIPBOARD
|
X11::XSetSelectionOwner(X11Impl::xDisplay, X11Impl::xAtomClipboard, window, CurrentTime); // CLIPBOARD
|
||||||
//X11::XSetSelectionOwner(xDisplay, xAtomPrimary, window, CurrentTime); // XA_PRIMARY
|
//X11::XSetSelectionOwner(xDisplay, xAtomPrimary, window, CurrentTime); // XA_PRIMARY
|
||||||
@@ -1135,7 +1135,7 @@ String SDLClipboard::GetText()
|
|||||||
return result;
|
return result;
|
||||||
if (X11Impl::xDisplay)
|
if (X11Impl::xDisplay)
|
||||||
{
|
{
|
||||||
X11::Window window = static_cast<X11::Window>(mainWindow->GetX11WindowHandle());
|
X11::Window window = reinterpret_cast<X11::Window>(mainWindow->GetNativePtr());
|
||||||
|
|
||||||
X11Impl::ClipboardGetText(result, X11Impl::xAtomClipboard, X11Impl::xAtomUTF8String, window);
|
X11Impl::ClipboardGetText(result, X11Impl::xAtomClipboard, X11Impl::xAtomUTF8String, window);
|
||||||
if (result.HasChars())
|
if (result.HasChars())
|
||||||
|
|||||||
@@ -221,21 +221,11 @@ SDL_Window* SDLWindow::GetSDLWindow() const
|
|||||||
|
|
||||||
#if PLATFORM_LINUX
|
#if PLATFORM_LINUX
|
||||||
|
|
||||||
void* SDLWindow::GetWaylandSurfacePtr() const
|
|
||||||
{
|
|
||||||
return SDL_GetPointerProperty(SDL_GetWindowProperties(_window), SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void* SDLWindow::GetWaylandDisplay() const
|
void* SDLWindow::GetWaylandDisplay() const
|
||||||
{
|
{
|
||||||
return SDL_GetPointerProperty(SDL_GetWindowProperties(_window), SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER, nullptr);
|
return SDL_GetPointerProperty(SDL_GetWindowProperties(_window), SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
uintptr SDLWindow::GetX11WindowHandle() const
|
|
||||||
{
|
|
||||||
return (uintptr)SDL_GetNumberProperty(SDL_GetWindowProperties(_window), SDL_PROP_WINDOW_X11_WINDOW_NUMBER, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void* SDLWindow::GetX11Display() const
|
void* SDLWindow::GetX11Display() const
|
||||||
{
|
{
|
||||||
return SDL_GetPointerProperty(SDL_GetWindowProperties(_window), SDL_PROP_WINDOW_X11_DISPLAY_POINTER, nullptr);
|
return SDL_GetPointerProperty(SDL_GetWindowProperties(_window), SDL_PROP_WINDOW_X11_DISPLAY_POINTER, nullptr);
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ public:
|
|||||||
~SDLWindow();
|
~SDLWindow();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static SDLWindow* GetWindowFromEvent(const SDL_Event& event);
|
static SDLWindow* GetWindowFromEvent(const SDL_Event& event);
|
||||||
static SDLWindow* GetWindowWithSDLWindow(SDL_Window* window);
|
static SDLWindow* GetWindowWithSDLWindow(SDL_Window* window);
|
||||||
void HandleEvent(SDL_Event& event);
|
void HandleEvent(SDL_Event& event);
|
||||||
@@ -64,18 +63,10 @@ private:
|
|||||||
void CheckForWindowResize();
|
void CheckForWindowResize();
|
||||||
void UpdateCursor();
|
void UpdateCursor();
|
||||||
|
|
||||||
#if PLATFORM_LINUX
|
|
||||||
DragDropEffect DoDragDropWayland(const StringView& data, Window* dragSourceWindow = nullptr, Float2 dragOffset = Float2::Zero);
|
|
||||||
DragDropEffect DoDragDropX11(const StringView& data);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SDL_Window* GetSDLWindow() const;
|
SDL_Window* GetSDLWindow() const;
|
||||||
#if PLATFORM_LINUX
|
#if PLATFORM_LINUX
|
||||||
void* GetWaylandSurfacePtr() const;
|
|
||||||
void* GetWaylandDisplay() const;
|
void* GetWaylandDisplay() const;
|
||||||
uintptr GetX11WindowHandle() const;
|
|
||||||
void* GetX11Display() const;
|
void* GetX11Display() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -128,6 +119,10 @@ public:
|
|||||||
Windows::HRESULT __stdcall DragLeave() override;
|
Windows::HRESULT __stdcall DragLeave() override;
|
||||||
Windows::HRESULT __stdcall Drop(Windows::IDataObject* pDataObj, Windows::DWORD grfKeyState, Windows::POINTL pt, Windows::DWORD* pdwEffect) override;
|
Windows::HRESULT __stdcall Drop(Windows::IDataObject* pDataObj, Windows::DWORD grfKeyState, Windows::POINTL pt, Windows::DWORD* pdwEffect) override;
|
||||||
#endif
|
#endif
|
||||||
|
#if PLATFORM_LINUX
|
||||||
|
DragDropEffect DoDragDropWayland(const StringView& data, Window* dragSourceWindow = nullptr, Float2 dragOffset = Float2::Zero);
|
||||||
|
DragDropEffect DoDragDropX11(const StringView& data);
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user