Respect the default system double-click interval

This commit is contained in:
Luflosi
2018-10-26 11:57:33 +02:00
parent facb2df3f6
commit 09183772d3
13 changed files with 73 additions and 9 deletions

View File

@@ -261,12 +261,6 @@ cocoa_get_lang(PyObject UNUSED *self) {
return Py_BuildValue("s", [locale UTF8String]);
}
static PyObject*
cocoa_get_double_click_interval(PyObject UNUSED *self) {
double interval = [NSEvent doubleClickInterval];
return Py_BuildValue("f", interval);
}
void
cocoa_set_hide_from_tasks(void) {
[NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory];
@@ -300,7 +294,6 @@ cocoa_set_titlebar_color(void *w, color_type titlebar_color)
static PyMethodDef module_methods[] = {
{"cocoa_get_lang", (PyCFunction)cocoa_get_lang, METH_NOARGS, ""},
{"cocoa_get_double_click_interval", (PyCFunction)cocoa_get_double_click_interval, METH_NOARGS, ""},
{"cocoa_set_new_window_trigger", (PyCFunction)cocoa_set_new_window_trigger, METH_VARARGS, ""},
{NULL, NULL, 0, NULL} /* Sentinel */
};

View File

@@ -402,8 +402,7 @@ database will be matched.'''))
def click_interval(x):
if x == 'system':
from .fast_data_types import cocoa_get_double_click_interval
return cocoa_get_double_click_interval()
return -1.0
return positive_float(x)

3
kitty/glfw-wrapper.c generated
View File

@@ -131,6 +131,9 @@ load_glfw(const char* path) {
*(void **) (&glfwGetWindowContentScale_impl) = dlsym(handle, "glfwGetWindowContentScale");
if (glfwGetWindowContentScale_impl == NULL) fail("Failed to load glfw function glfwGetWindowContentScale with error: %s", dlerror());
*(void **) (&glfwGetDoubleClickInterval_impl) = dlsym(handle, "glfwGetDoubleClickInterval");
if (glfwGetDoubleClickInterval_impl == NULL) fail("Failed to load glfw function glfwGetDoubleClickInterval with error: %s", dlerror());
*(void **) (&glfwGetWindowOpacity_impl) = dlsym(handle, "glfwGetWindowOpacity");
if (glfwGetWindowOpacity_impl == NULL) fail("Failed to load glfw function glfwGetWindowOpacity with error: %s", dlerror());

4
kitty/glfw-wrapper.h generated
View File

@@ -1544,6 +1544,10 @@ typedef void (*glfwGetWindowContentScale_func)(GLFWwindow*, float*, float*);
glfwGetWindowContentScale_func glfwGetWindowContentScale_impl;
#define glfwGetWindowContentScale glfwGetWindowContentScale_impl
typedef double (*glfwGetDoubleClickInterval_func)(GLFWwindow*);
glfwGetDoubleClickInterval_func glfwGetDoubleClickInterval_impl;
#define glfwGetDoubleClickInterval glfwGetDoubleClickInterval_impl
typedef float (*glfwGetWindowOpacity_func)(GLFWwindow*);
glfwGetWindowOpacity_func glfwGetWindowOpacity_impl;
#define glfwGetWindowOpacity glfwGetWindowOpacity_impl

View File

@@ -529,6 +529,10 @@ create_os_window(PyObject UNUSED *self, PyObject *args) {
}
glfwMakeContextCurrent(glfw_window);
if (is_first_window) {
if (OPT(click_interval) < 0) {
OPT(click_interval) = glfwGetDoubleClickInterval(glfw_window);
}
gl_init();
PyObject *ret = PyObject_CallFunction(load_programs, "i", glfwGetWindowAttrib(glfw_window, GLFW_TRANSPARENT_FRAMEBUFFER));
if (ret == NULL) return NULL;