Wire up clipboard lost events
This commit is contained in:
parent
08b4e3f2e0
commit
b34a88065b
10 changed files with 40 additions and 0 deletions
3
glfw/glfw3.h
vendored
3
glfw/glfw3.h
vendored
|
|
@ -1432,6 +1432,7 @@ typedef void (* GLFWwindowclosefun)(GLFWwindow*);
|
||||||
*/
|
*/
|
||||||
typedef void (* GLFWapplicationclosefun)(int);
|
typedef void (* GLFWapplicationclosefun)(int);
|
||||||
|
|
||||||
|
|
||||||
/*! @brief The function pointer type for system color theme change callbacks.
|
/*! @brief The function pointer type for system color theme change callbacks.
|
||||||
*
|
*
|
||||||
* This is the function pointer type for system color theme changes.
|
* This is the function pointer type for system color theme changes.
|
||||||
|
|
@ -1814,6 +1815,7 @@ typedef enum {
|
||||||
typedef GLFWDataChunk (* GLFWclipboarditerfun)(const char *mime_type, void *iter, GLFWClipboardType ctype);
|
typedef GLFWDataChunk (* GLFWclipboarditerfun)(const char *mime_type, void *iter, GLFWClipboardType ctype);
|
||||||
typedef bool (* GLFWclipboardwritedatafun)(void *object, const char *data, size_t sz);
|
typedef bool (* GLFWclipboardwritedatafun)(void *object, const char *data, size_t sz);
|
||||||
typedef bool (* GLFWimecursorpositionfun)(GLFWwindow *window, GLFWIMEUpdateEvent *ev);
|
typedef bool (* GLFWimecursorpositionfun)(GLFWwindow *window, GLFWIMEUpdateEvent *ev);
|
||||||
|
typedef void (* GLFWclipboardlostfun )(GLFWClipboardType);
|
||||||
|
|
||||||
/*! @brief Video mode type.
|
/*! @brief Video mode type.
|
||||||
*
|
*
|
||||||
|
|
@ -3985,6 +3987,7 @@ GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwind
|
||||||
GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun callback);
|
GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun callback);
|
||||||
GLFWAPI GLFWapplicationclosefun glfwSetApplicationCloseCallback(GLFWapplicationclosefun callback);
|
GLFWAPI GLFWapplicationclosefun glfwSetApplicationCloseCallback(GLFWapplicationclosefun callback);
|
||||||
GLFWAPI GLFWsystemcolorthemechangefun glfwSetSystemColorThemeChangeCallback(GLFWsystemcolorthemechangefun callback);
|
GLFWAPI GLFWsystemcolorthemechangefun glfwSetSystemColorThemeChangeCallback(GLFWsystemcolorthemechangefun callback);
|
||||||
|
GLFWAPI GLFWclipboardlostfun glfwSetClipboardLostCallback(GLFWclipboardlostfun callback);
|
||||||
GLFWAPI GLFWColorScheme glfwGetCurrentSystemColorTheme(bool query_if_unintialized);
|
GLFWAPI GLFWColorScheme glfwGetCurrentSystemColorTheme(bool query_if_unintialized);
|
||||||
|
|
||||||
/*! @brief Sets the refresh callback for the specified window.
|
/*! @brief Sets the refresh callback for the specified window.
|
||||||
|
|
|
||||||
7
glfw/init.c
vendored
7
glfw/init.c
vendored
|
|
@ -395,6 +395,13 @@ GLFWAPI GLFWsystemcolorthemechangefun glfwSetSystemColorThemeChangeCallback(GLFW
|
||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWAPI GLFWclipboardlostfun glfwSetClipboardLostCallback(GLFWclipboardlostfun cbfun)
|
||||||
|
{
|
||||||
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
_GLFW_SWAP_POINTERS(_glfw.callbacks.clipboard_lost, cbfun);
|
||||||
|
return cbfun;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GLFWAPI GLFWdrawtextfun glfwSetDrawTextFunction(GLFWdrawtextfun cbfun)
|
GLFWAPI GLFWdrawtextfun glfwSetDrawTextFunction(GLFWdrawtextfun cbfun)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
5
glfw/input.c
vendored
5
glfw/input.c
vendored
|
|
@ -453,6 +453,11 @@ void _glfwInputColorScheme(GLFWColorScheme value, bool is_initial_value) {
|
||||||
if (_glfw.callbacks.system_color_theme_change) _glfw.callbacks.system_color_theme_change(value, is_initial_value);
|
if (_glfw.callbacks.system_color_theme_change) _glfw.callbacks.system_color_theme_change(value, is_initial_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _glfwInputClipboardLost(GLFWClipboardType which) {
|
||||||
|
if (_glfw.callbacks.clipboard_lost) _glfw.callbacks.clipboard_lost(which);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW internal API //////
|
////// GLFW internal API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
||||||
2
glfw/internal.h
vendored
2
glfw/internal.h
vendored
|
|
@ -644,6 +644,7 @@ struct _GLFWlibrary
|
||||||
GLFWmonitorfun monitor;
|
GLFWmonitorfun monitor;
|
||||||
GLFWjoystickfun joystick;
|
GLFWjoystickfun joystick;
|
||||||
GLFWapplicationclosefun application_close;
|
GLFWapplicationclosefun application_close;
|
||||||
|
GLFWclipboardlostfun clipboard_lost;
|
||||||
GLFWsystemcolorthemechangefun system_color_theme_change;
|
GLFWsystemcolorthemechangefun system_color_theme_change;
|
||||||
GLFWdrawtextfun draw_text;
|
GLFWdrawtextfun draw_text;
|
||||||
GLFWcurrentselectionfun get_current_selection;
|
GLFWcurrentselectionfun get_current_selection;
|
||||||
|
|
@ -809,6 +810,7 @@ void _glfwInputWindowCloseRequest(_GLFWwindow* window);
|
||||||
void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor);
|
void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor);
|
||||||
|
|
||||||
void _glfwInputKeyboard(_GLFWwindow *window, GLFWkeyevent *ev);
|
void _glfwInputKeyboard(_GLFWwindow *window, GLFWkeyevent *ev);
|
||||||
|
void _glfwInputClipboardLost(GLFWClipboardType which);
|
||||||
void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset, int flags, int mods);
|
void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset, int flags, int mods);
|
||||||
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods);
|
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods);
|
||||||
void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos);
|
void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos);
|
||||||
|
|
|
||||||
2
glfw/wl_window.c
vendored
2
glfw/wl_window.c
vendored
|
|
@ -2204,6 +2204,7 @@ static void data_source_canceled(void *data UNUSED, struct wl_data_source *wl_da
|
||||||
if (_glfw.wl.dataSourceForClipboard == wl_data_source) {
|
if (_glfw.wl.dataSourceForClipboard == wl_data_source) {
|
||||||
_glfw.wl.dataSourceForClipboard = NULL;
|
_glfw.wl.dataSourceForClipboard = NULL;
|
||||||
_glfw_free_clipboard_data(&_glfw.clipboard);
|
_glfw_free_clipboard_data(&_glfw.clipboard);
|
||||||
|
_glfwInputClipboardLost(GLFW_CLIPBOARD);
|
||||||
}
|
}
|
||||||
wl_data_source_destroy(wl_data_source);
|
wl_data_source_destroy(wl_data_source);
|
||||||
}
|
}
|
||||||
|
|
@ -2212,6 +2213,7 @@ static void primary_selection_source_canceled(void *data UNUSED, struct zwp_prim
|
||||||
if (_glfw.wl.dataSourceForPrimarySelection == primary_selection_source) {
|
if (_glfw.wl.dataSourceForPrimarySelection == primary_selection_source) {
|
||||||
_glfw.wl.dataSourceForPrimarySelection = NULL;
|
_glfw.wl.dataSourceForPrimarySelection = NULL;
|
||||||
_glfw_free_clipboard_data(&_glfw.primary);
|
_glfw_free_clipboard_data(&_glfw.primary);
|
||||||
|
_glfwInputClipboardLost(GLFW_PRIMARY_SELECTION);
|
||||||
}
|
}
|
||||||
zwp_primary_selection_source_v1_destroy(primary_selection_source);
|
zwp_primary_selection_source_v1_destroy(primary_selection_source);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
glfw/x11_window.c
vendored
2
glfw/x11_window.c
vendored
|
|
@ -902,10 +902,12 @@ static void handleSelectionClear(XEvent* event)
|
||||||
if (event->xselectionclear.selection == _glfw.x11.PRIMARY)
|
if (event->xselectionclear.selection == _glfw.x11.PRIMARY)
|
||||||
{
|
{
|
||||||
_glfw_free_clipboard_data(&_glfw.primary);
|
_glfw_free_clipboard_data(&_glfw.primary);
|
||||||
|
_glfwInputClipboardLost(GLFW_PRIMARY_SELECTION);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_glfw_free_clipboard_data(&_glfw.clipboard);
|
_glfw_free_clipboard_data(&_glfw.clipboard);
|
||||||
|
_glfwInputClipboardLost(GLFW_CLIPBOARD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
from typing import (
|
from typing import (
|
||||||
TYPE_CHECKING,
|
TYPE_CHECKING,
|
||||||
Any,
|
Any,
|
||||||
|
Literal,
|
||||||
Optional,
|
Optional,
|
||||||
Union,
|
Union,
|
||||||
)
|
)
|
||||||
|
|
@ -3109,3 +3110,6 @@ def update_progress_in_dock(self) -> None:
|
||||||
cocoa_show_progress_bar_on_dock_icon(101)
|
cocoa_show_progress_bar_on_dock_icon(101)
|
||||||
else:
|
else:
|
||||||
cocoa_show_progress_bar_on_dock_icon()
|
cocoa_show_progress_bar_on_dock_icon()
|
||||||
|
|
||||||
|
def on_clipboard_lost(self, which: Literal['clipboard', 'primary']) -> None:
|
||||||
|
pass
|
||||||
|
|
|
||||||
3
kitty/glfw-wrapper.c
generated
3
kitty/glfw-wrapper.c
generated
|
|
@ -245,6 +245,9 @@ load_glfw(const char* path) {
|
||||||
*(void **) (&glfwSetSystemColorThemeChangeCallback_impl) = dlsym(handle, "glfwSetSystemColorThemeChangeCallback");
|
*(void **) (&glfwSetSystemColorThemeChangeCallback_impl) = dlsym(handle, "glfwSetSystemColorThemeChangeCallback");
|
||||||
if (glfwSetSystemColorThemeChangeCallback_impl == NULL) fail("Failed to load glfw function glfwSetSystemColorThemeChangeCallback with error: %s", dlerror());
|
if (glfwSetSystemColorThemeChangeCallback_impl == NULL) fail("Failed to load glfw function glfwSetSystemColorThemeChangeCallback with error: %s", dlerror());
|
||||||
|
|
||||||
|
*(void **) (&glfwSetClipboardLostCallback_impl) = dlsym(handle, "glfwSetClipboardLostCallback");
|
||||||
|
if (glfwSetClipboardLostCallback_impl == NULL) fail("Failed to load glfw function glfwSetClipboardLostCallback with error: %s", dlerror());
|
||||||
|
|
||||||
*(void **) (&glfwGetCurrentSystemColorTheme_impl) = dlsym(handle, "glfwGetCurrentSystemColorTheme");
|
*(void **) (&glfwGetCurrentSystemColorTheme_impl) = dlsym(handle, "glfwGetCurrentSystemColorTheme");
|
||||||
if (glfwGetCurrentSystemColorTheme_impl == NULL) fail("Failed to load glfw function glfwGetCurrentSystemColorTheme with error: %s", dlerror());
|
if (glfwGetCurrentSystemColorTheme_impl == NULL) fail("Failed to load glfw function glfwGetCurrentSystemColorTheme with error: %s", dlerror());
|
||||||
|
|
||||||
|
|
|
||||||
6
kitty/glfw-wrapper.h
generated
6
kitty/glfw-wrapper.h
generated
|
|
@ -1170,6 +1170,7 @@ typedef void (* GLFWwindowclosefun)(GLFWwindow*);
|
||||||
*/
|
*/
|
||||||
typedef void (* GLFWapplicationclosefun)(int);
|
typedef void (* GLFWapplicationclosefun)(int);
|
||||||
|
|
||||||
|
|
||||||
/*! @brief The function pointer type for system color theme change callbacks.
|
/*! @brief The function pointer type for system color theme change callbacks.
|
||||||
*
|
*
|
||||||
* This is the function pointer type for system color theme changes.
|
* This is the function pointer type for system color theme changes.
|
||||||
|
|
@ -1552,6 +1553,7 @@ typedef enum {
|
||||||
typedef GLFWDataChunk (* GLFWclipboarditerfun)(const char *mime_type, void *iter, GLFWClipboardType ctype);
|
typedef GLFWDataChunk (* GLFWclipboarditerfun)(const char *mime_type, void *iter, GLFWClipboardType ctype);
|
||||||
typedef bool (* GLFWclipboardwritedatafun)(void *object, const char *data, size_t sz);
|
typedef bool (* GLFWclipboardwritedatafun)(void *object, const char *data, size_t sz);
|
||||||
typedef bool (* GLFWimecursorpositionfun)(GLFWwindow *window, GLFWIMEUpdateEvent *ev);
|
typedef bool (* GLFWimecursorpositionfun)(GLFWwindow *window, GLFWIMEUpdateEvent *ev);
|
||||||
|
typedef void (* GLFWclipboardlostfun )(GLFWClipboardType);
|
||||||
|
|
||||||
/*! @brief Video mode type.
|
/*! @brief Video mode type.
|
||||||
*
|
*
|
||||||
|
|
@ -2017,6 +2019,10 @@ typedef GLFWsystemcolorthemechangefun (*glfwSetSystemColorThemeChangeCallback_fu
|
||||||
GFW_EXTERN glfwSetSystemColorThemeChangeCallback_func glfwSetSystemColorThemeChangeCallback_impl;
|
GFW_EXTERN glfwSetSystemColorThemeChangeCallback_func glfwSetSystemColorThemeChangeCallback_impl;
|
||||||
#define glfwSetSystemColorThemeChangeCallback glfwSetSystemColorThemeChangeCallback_impl
|
#define glfwSetSystemColorThemeChangeCallback glfwSetSystemColorThemeChangeCallback_impl
|
||||||
|
|
||||||
|
typedef GLFWclipboardlostfun (*glfwSetClipboardLostCallback_func)(GLFWclipboardlostfun);
|
||||||
|
GFW_EXTERN glfwSetClipboardLostCallback_func glfwSetClipboardLostCallback_impl;
|
||||||
|
#define glfwSetClipboardLostCallback glfwSetClipboardLostCallback_impl
|
||||||
|
|
||||||
typedef GLFWColorScheme (*glfwGetCurrentSystemColorTheme_func)(bool);
|
typedef GLFWColorScheme (*glfwGetCurrentSystemColorTheme_func)(bool);
|
||||||
GFW_EXTERN glfwGetCurrentSystemColorTheme_func glfwGetCurrentSystemColorTheme_impl;
|
GFW_EXTERN glfwGetCurrentSystemColorTheme_func glfwGetCurrentSystemColorTheme_impl;
|
||||||
#define glfwGetCurrentSystemColorTheme glfwGetCurrentSystemColorTheme_impl
|
#define glfwGetCurrentSystemColorTheme glfwGetCurrentSystemColorTheme_impl
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,11 @@ on_system_color_scheme_change(GLFWColorScheme appearance, bool is_initial_value)
|
||||||
call_boss(on_system_color_scheme_change, "sO", which, is_initial_value ? Py_True : Py_False);
|
call_boss(on_system_color_scheme_change, "sO", which, is_initial_value ? Py_True : Py_False);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_clipboard_lost(GLFWClipboardType which) {
|
||||||
|
call_boss(on_clipboard_lost, "s", which == GLFW_CLIPBOARD ? "clipboard" : "primary");
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
strip_csi_(const char *title, char *buf, size_t bufsz) {
|
strip_csi_(const char *title, char *buf, size_t bufsz) {
|
||||||
enum { NORMAL, IN_ESC, IN_CSI} state = NORMAL;
|
enum { NORMAL, IN_ESC, IN_CSI} state = NORMAL;
|
||||||
|
|
@ -1195,6 +1200,7 @@ create_os_window(PyObject UNUSED *self, PyObject *args, PyObject *kw) {
|
||||||
glfwSetHasCurrentSelectionCallback(has_current_selection);
|
glfwSetHasCurrentSelectionCallback(has_current_selection);
|
||||||
glfwSetIMECursorPositionCallback(get_ime_cursor_position);
|
glfwSetIMECursorPositionCallback(get_ime_cursor_position);
|
||||||
glfwSetSystemColorThemeChangeCallback(on_system_color_scheme_change);
|
glfwSetSystemColorThemeChangeCallback(on_system_color_scheme_change);
|
||||||
|
glfwSetClipboardLostCallback(on_clipboard_lost);
|
||||||
// Request SRGB output buffer
|
// Request SRGB output buffer
|
||||||
// Prevents kitty from starting on Wayland + NVIDIA, sigh: https://github.com/kovidgoyal/kitty/issues/7021
|
// Prevents kitty from starting on Wayland + NVIDIA, sigh: https://github.com/kovidgoyal/kitty/issues/7021
|
||||||
// Remove after https://github.com/NVIDIA/egl-wayland/issues/85 is fixed.
|
// Remove after https://github.com/NVIDIA/egl-wayland/issues/85 is fixed.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue