diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/linuxbsd/display_server_x11.cpp | 30 | ||||
-rw-r--r-- | platform/linuxbsd/display_server_x11.h | 6 | ||||
-rw-r--r-- | platform/linuxbsd/vulkan_context_x11.cpp | 6 | ||||
-rw-r--r-- | platform/linuxbsd/vulkan_context_x11.h | 2 |
4 files changed, 30 insertions, 14 deletions
diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index ace07a3ac6..0b4a6b19d8 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -47,8 +47,7 @@ #include "servers/visual/rasterizer_rd/rasterizer_rd.h" #endif -#include "servers/visual/visual_server_raster.h" -#include "servers/visual/visual_server_wrap_mt.h" +#include "scene/resources/texture.h" #ifdef HAVE_MNTENT #include <mntent.h> @@ -89,6 +88,8 @@ #include <X11/XKBlib.h> +#include "core/project_settings.h" + // 2.2 is the first release with multitouch #define XINPUT_CLIENT_VERSION_MAJOR 2 #define XINPUT_CLIENT_VERSION_MINOR 2 @@ -641,7 +642,7 @@ void DisplayServerX11::delete_sub_window(WindowID p_id) { #ifdef VULKAN_ENABLED if (rendering_driver == "vulkan") { - context_vulkan->window_destroy(wd.vulkan_window); + context_vulkan->window_destroy(p_id); } #endif XUnmapWindow(x11_display, wd.x11_window); @@ -665,6 +666,13 @@ void DisplayServerX11::window_set_title(const String &p_title, WindowID p_window XChangeProperty(x11_display, wd.x11_window, _net_wm_name, utf8_string, 8, PropModeReplace, (unsigned char *)p_title.utf8().get_data(), p_title.utf8().length()); } +void DisplayServerX11::window_set_resize_callback(const Callable &p_callable, WindowID p_window) { + + ERR_FAIL_COND(!windows.has(p_window)); + WindowData &wd = windows[p_window]; + wd.resize_callback = p_callable; +} + int DisplayServerX11::window_get_current_screen(WindowID p_window) const { ERR_FAIL_COND_V(!windows.has(p_window), -1); const WindowData &wd = windows[p_window]; @@ -2020,9 +2028,17 @@ void DisplayServerX11::_window_changed(XEvent *event) { #if defined(VULKAN_ENABLED) if (rendering_driver == "vulkan") { - context_vulkan->window_resize(wd.vulkan_window, wd.size.width, wd.size.height); + context_vulkan->window_resize(window_id, wd.size.width, wd.size.height); } #endif + + if (!wd.resize_callback.is_null()) { + Variant size = wd.size; + Variant *sizep = &size; + Variant ret; + Callable::CallError ce; + wd.resize_callback.call((const Variant **)&sizep, 1, ret, ce); + } } void DisplayServerX11::process_events() { @@ -2764,8 +2780,8 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, c #if defined(VULKAN_ENABLED) if (context_vulkan) { - wd.vulkan_window = context_vulkan->window_create(wd.x11_window, x11_display, p_resolution.width, p_resolution.height); - ERR_FAIL_COND_V_MSG(wd.vulkan_window == -1, INVALID_WINDOW_ID, "Can't create a Vulkan window"); + Error err = context_vulkan->window_create(window_id_counter, wd.x11_window, x11_display, p_resolution.width, p_resolution.height); + ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Can't create a Vulkan window"); } #endif @@ -3295,7 +3311,7 @@ DisplayServerX11::~DisplayServerX11() { for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) { #ifdef VULKAN_ENABLED if (rendering_driver == "vulkan") { - context_vulkan->window_destroy(E->get().vulkan_window); + context_vulkan->window_destroy(E->key()); } #endif diff --git a/platform/linuxbsd/display_server_x11.h b/platform/linuxbsd/display_server_x11.h index 6964447be2..b1ecde30d9 100644 --- a/platform/linuxbsd/display_server_x11.h +++ b/platform/linuxbsd/display_server_x11.h @@ -113,14 +113,13 @@ class DisplayServerX11 : public DisplayServer { struct WindowData { Window x11_window; ::XIC xic; -#if defined(VULKAN_ENABLED) - int vulkan_window; -#endif + Size2i min_size; Size2i max_size; Size2i size; Size2i im_position; bool im_active = false; + Callable resize_callback; //better to guess on the fly, given WM can change it //WindowMode mode; @@ -256,6 +255,7 @@ public: virtual void delete_sub_window(WindowID p_id); virtual void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID); + virtual void window_set_resize_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); virtual int window_get_current_screen(WindowID p_window = MAIN_WINDOW_ID) const; virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID); diff --git a/platform/linuxbsd/vulkan_context_x11.cpp b/platform/linuxbsd/vulkan_context_x11.cpp index 602dbc77a2..d0e1b1678c 100644 --- a/platform/linuxbsd/vulkan_context_x11.cpp +++ b/platform/linuxbsd/vulkan_context_x11.cpp @@ -35,7 +35,7 @@ const char *VulkanContextX11::_get_platform_surface_extension() const { return VK_KHR_XLIB_SURFACE_EXTENSION_NAME; } -int VulkanContextX11::window_create(::Window p_window, Display *p_display, int p_width, int p_height) { +Error VulkanContextX11::window_create(DisplayServer::WindowID p_window_id, ::Window p_window, Display *p_display, int p_width, int p_height) { VkXlibSurfaceCreateInfoKHR createInfo; createInfo.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR; @@ -46,8 +46,8 @@ int VulkanContextX11::window_create(::Window p_window, Display *p_display, int p VkSurfaceKHR surface; VkResult err = vkCreateXlibSurfaceKHR(_get_instance(), &createInfo, NULL, &surface); - ERR_FAIL_COND_V(err, -1); - return _window_create(surface, p_width, p_height); + ERR_FAIL_COND_V(err, ERR_CANT_CREATE); + return _window_create(p_window_id, surface, p_width, p_height); } VulkanContextX11::VulkanContextX11() { diff --git a/platform/linuxbsd/vulkan_context_x11.h b/platform/linuxbsd/vulkan_context_x11.h index 573f994ea6..6e144ab2d9 100644 --- a/platform/linuxbsd/vulkan_context_x11.h +++ b/platform/linuxbsd/vulkan_context_x11.h @@ -39,7 +39,7 @@ class VulkanContextX11 : public VulkanContext { virtual const char *_get_platform_surface_extension() const; public: - int window_create(::Window p_window, Display *p_display, int p_width, int p_height); + Error window_create(DisplayServer::WindowID p_window_id, ::Window p_window, Display *p_display, int p_width, int p_height); VulkanContextX11(); ~VulkanContextX11(); |