This commit is contained in:
YgorVasilenko 2024-01-22 23:37:40 +01:00 committed by GitHub
commit 0389c447a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 30 additions and 0 deletions

View File

@ -5833,6 +5833,9 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state);
*/ */
GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string); GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
// hacky way for a screenshot
GLFWAPI void glfwSetClipboardBitmap(unsigned char * data, int width, int height);
/*! @brief Returns the contents of the clipboard as a string. /*! @brief Returns the contents of the clipboard as a string.
* *
* This function returns the contents of the system clipboard, if it contains * This function returns the contents of the system clipboard, if it contains

View File

@ -1464,6 +1464,12 @@ GLFWAPI void glfwSetClipboardString(GLFWwindow* handle, const char* string)
_glfw.platform.setClipboardString(string); _glfw.platform.setClipboardString(string);
} }
GLFWAPI void glfwSetClipboardBitmap(unsigned char * data, int width, int height)
{
_GLFW_REQUIRE_INIT();
_glfw.platform.setClipboardBitmap();
}
GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle) GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL);

View File

@ -750,6 +750,7 @@ struct _GLFWplatform
void (*getRequiredInstanceExtensions)(char**); void (*getRequiredInstanceExtensions)(char**);
GLFWbool (*getPhysicalDevicePresentationSupport)(VkInstance,VkPhysicalDevice,uint32_t); GLFWbool (*getPhysicalDevicePresentationSupport)(VkInstance,VkPhysicalDevice,uint32_t);
VkResult (*createWindowSurface)(VkInstance,_GLFWwindow*,const VkAllocationCallbacks*,VkSurfaceKHR*); VkResult (*createWindowSurface)(VkInstance,_GLFWwindow*,const VkAllocationCallbacks*,VkSurfaceKHR*);
void (*setClipboardBitmap)();
}; };
// Library global data // Library global data

View File

@ -675,6 +675,7 @@ GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform)
_glfwGetRequiredInstanceExtensionsWin32, _glfwGetRequiredInstanceExtensionsWin32,
_glfwGetPhysicalDevicePresentationSupportWin32, _glfwGetPhysicalDevicePresentationSupportWin32,
_glfwCreateWindowSurfaceWin32, _glfwCreateWindowSurfaceWin32,
_glfwSetClipboardBitmapWin32
}; };
*platform = win32; *platform = win32;

View File

@ -591,6 +591,7 @@ GLFWbool _glfwCreateStandardCursorWin32(_GLFWcursor* cursor, int shape);
void _glfwDestroyCursorWin32(_GLFWcursor* cursor); void _glfwDestroyCursorWin32(_GLFWcursor* cursor);
void _glfwSetCursorWin32(_GLFWwindow* window, _GLFWcursor* cursor); void _glfwSetCursorWin32(_GLFWwindow* window, _GLFWcursor* cursor);
void _glfwSetClipboardStringWin32(const char* string); void _glfwSetClipboardStringWin32(const char* string);
void _glfwSetClipboardBitmapWin32();
const char* _glfwGetClipboardStringWin32(void); const char* _glfwGetClipboardStringWin32(void);
EGLenum _glfwGetEGLPlatformWin32(EGLint** attribs); EGLenum _glfwGetEGLPlatformWin32(EGLint** attribs);

View File

@ -2289,6 +2289,24 @@ void _glfwSetCursorWin32(_GLFWwindow* window, _GLFWcursor* cursor)
updateCursorImage(window); updateCursorImage(window);
} }
void _glfwSetClipboardBitmapWin32(unsigned char * data, int width, int height) {
HBITMAP fillBm = NULL;
fillBm = CreateBitmap(width, height, 1, 32, data);
if (!OpenClipboard(_glfw.win32.helperWindowHandle)) {
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR, "Win32: Failed to open clipboard");
return;
}
EmptyClipboard();
// place handle to clipboard
SetClipboardData(CF_BITMAP, fillBm);
// Close the clipboard.
CloseClipboard();
DeleteObject(fillBm);
}
void _glfwSetClipboardStringWin32(const char* string) void _glfwSetClipboardStringWin32(const char* string)
{ {
int characterCount, tries = 0; int characterCount, tries = 0;