mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-20 15:35:03 +02:00
API for registering MIME types for drag enter
This commit is contained in:
@@ -3876,6 +3876,17 @@ glfwCocoaCycleThroughOSWindows(bool backwards) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GLFWAPI void
|
||||||
|
glfwCocoaRegisterMIMETypes(GLFWwindow *window, const char **mimes, size_t count) {
|
||||||
|
_GLFWwindow *w = (_GLFWwindow*)window;
|
||||||
|
NSArray *currentTypes = [w->ns.view registeredDraggedTypes];
|
||||||
|
NSMutableArray *updatedTypes = [NSMutableArray arrayWithArray:currentTypes];
|
||||||
|
for (size_t i = 0; i < count; i++) {
|
||||||
|
NSString *uti = mime_to_uti(mimes[i]);
|
||||||
|
if (![updatedTypes containsObject:uti]) [updatedTypes addObject:uti];
|
||||||
|
}
|
||||||
|
[w->ns.view registerForDraggedTypes:updatedTypes];
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW internal API //////
|
////// GLFW internal API //////
|
||||||
|
|||||||
@@ -316,6 +316,7 @@ def generate_wrappers(glfw_header: str) -> None:
|
|||||||
void glfwCocoaCycleThroughOSWindows(bool backwards)
|
void glfwCocoaCycleThroughOSWindows(bool backwards)
|
||||||
void glfwCocoaSetWindowChrome(GLFWwindow* window, unsigned int color, bool use_system_color, unsigned int system_color,\
|
void glfwCocoaSetWindowChrome(GLFWwindow* window, unsigned int color, bool use_system_color, unsigned int system_color,\
|
||||||
int background_blur, unsigned int hide_window_decorations, bool show_text_in_titlebar, int color_space, float background_opacity, bool resizable)
|
int background_blur, unsigned int hide_window_decorations, bool show_text_in_titlebar, int color_space, float background_opacity, bool resizable)
|
||||||
|
void glfwCocoaRegisterMIMETypes(GLFWwindow *window, const char **mimes, size_t count)
|
||||||
const char* glfwGetPrimarySelectionString(GLFWwindow* window, void)
|
const char* glfwGetPrimarySelectionString(GLFWwindow* window, void)
|
||||||
int glfwGetNativeKeyForName(const char* key_name, int case_sensitive)
|
int glfwGetNativeKeyForName(const char* key_name, int case_sensitive)
|
||||||
void glfwRequestWaylandFrameEvent(GLFWwindow *handle, unsigned long long id, GLFWwaylandframecallbackfunc callback)
|
void glfwRequestWaylandFrameEvent(GLFWwindow *handle, unsigned long long id, GLFWwaylandframecallbackfunc callback)
|
||||||
|
|||||||
3
kitty/glfw-wrapper.c
generated
3
kitty/glfw-wrapper.c
generated
@@ -491,6 +491,9 @@ load_glfw(const char* path) {
|
|||||||
*(void **) (&glfwCocoaSetWindowChrome_impl) = dlsym(handle, "glfwCocoaSetWindowChrome");
|
*(void **) (&glfwCocoaSetWindowChrome_impl) = dlsym(handle, "glfwCocoaSetWindowChrome");
|
||||||
if (glfwCocoaSetWindowChrome_impl == NULL) dlerror(); // clear error indicator
|
if (glfwCocoaSetWindowChrome_impl == NULL) dlerror(); // clear error indicator
|
||||||
|
|
||||||
|
*(void **) (&glfwCocoaRegisterMIMETypes_impl) = dlsym(handle, "glfwCocoaRegisterMIMETypes");
|
||||||
|
if (glfwCocoaRegisterMIMETypes_impl == NULL) dlerror(); // clear error indicator
|
||||||
|
|
||||||
*(void **) (&glfwGetPrimarySelectionString_impl) = dlsym(handle, "glfwGetPrimarySelectionString");
|
*(void **) (&glfwGetPrimarySelectionString_impl) = dlsym(handle, "glfwGetPrimarySelectionString");
|
||||||
if (glfwGetPrimarySelectionString_impl == NULL) dlerror(); // clear error indicator
|
if (glfwGetPrimarySelectionString_impl == NULL) dlerror(); // clear error indicator
|
||||||
|
|
||||||
|
|||||||
14
kitty/glfw-wrapper.h
generated
14
kitty/glfw-wrapper.h
generated
@@ -1540,7 +1540,7 @@ typedef void (* GLFWscrollfun)(GLFWwindow*,const GLFWScrollEvent*);
|
|||||||
typedef void (* GLFWkeyboardfun)(GLFWwindow*, GLFWkeyevent*);
|
typedef void (* GLFWkeyboardfun)(GLFWwindow*, GLFWkeyevent*);
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
GLFW_DRAG_DATA_REQUEST,
|
GLFW_DRAG_DATA_REQUEST, // request data for specified mime type
|
||||||
GLFW_DRAG_CANCELLED,
|
GLFW_DRAG_CANCELLED,
|
||||||
GLFW_DRAG_FINSHED,
|
GLFW_DRAG_FINSHED,
|
||||||
GLFW_DRAG_ACCEPTED, // mimetype was accepted or NULL if drag was accepted but no mime type specified
|
GLFW_DRAG_ACCEPTED, // mimetype was accepted or NULL if drag was accepted but no mime type specified
|
||||||
@@ -1557,8 +1557,14 @@ typedef struct GLFWDragSourceItem {
|
|||||||
|
|
||||||
typedef struct GLFWDragEvent {
|
typedef struct GLFWDragEvent {
|
||||||
GLFWDragEventType type;
|
GLFWDragEventType type;
|
||||||
|
// When the drag event callback is called with a mimetype and no data, the
|
||||||
|
// application should set the data ans data_sz and err_num fields.
|
||||||
|
// Once glfw is done reading the data the drag event callback will be
|
||||||
|
// called with the data pointer unchanged. The application is now free
|
||||||
|
// to delete the data, as needed.
|
||||||
const char *mime_type;
|
const char *mime_type;
|
||||||
const char *data; size_t data_sz; int err_num;
|
const char *data; size_t data_sz;
|
||||||
|
int err_num; // POSIX error code indicating failure fetching data
|
||||||
GLFWDragOperationType action; // can be 0 indicating no action
|
GLFWDragOperationType action; // can be 0 indicating no action
|
||||||
} GLFWDragEvent;
|
} GLFWDragEvent;
|
||||||
|
|
||||||
@@ -2459,6 +2465,10 @@ typedef void (*glfwCocoaSetWindowChrome_func)(GLFWwindow*, unsigned int, bool, u
|
|||||||
GFW_EXTERN glfwCocoaSetWindowChrome_func glfwCocoaSetWindowChrome_impl;
|
GFW_EXTERN glfwCocoaSetWindowChrome_func glfwCocoaSetWindowChrome_impl;
|
||||||
#define glfwCocoaSetWindowChrome glfwCocoaSetWindowChrome_impl
|
#define glfwCocoaSetWindowChrome glfwCocoaSetWindowChrome_impl
|
||||||
|
|
||||||
|
typedef void (*glfwCocoaRegisterMIMETypes_func)(GLFWwindow*, const char**, size_t);
|
||||||
|
GFW_EXTERN glfwCocoaRegisterMIMETypes_func glfwCocoaRegisterMIMETypes_impl;
|
||||||
|
#define glfwCocoaRegisterMIMETypes glfwCocoaRegisterMIMETypes_impl
|
||||||
|
|
||||||
typedef const char* (*glfwGetPrimarySelectionString_func)(GLFWwindow*);
|
typedef const char* (*glfwGetPrimarySelectionString_func)(GLFWwindow*);
|
||||||
GFW_EXTERN glfwGetPrimarySelectionString_func glfwGetPrimarySelectionString_impl;
|
GFW_EXTERN glfwGetPrimarySelectionString_func glfwGetPrimarySelectionString_impl;
|
||||||
#define glfwGetPrimarySelectionString glfwGetPrimarySelectionString_impl
|
#define glfwGetPrimarySelectionString glfwGetPrimarySelectionString_impl
|
||||||
|
|||||||
Reference in New Issue
Block a user