mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-23 00:38:10 +02:00
Use the new glfw API to set WM_CLASS if available
This commit is contained in:
16
kitty/glfw.c
16
kitty/glfw.c
@@ -208,6 +208,18 @@ glfw_get_key_name(PyObject UNUSED *self, PyObject *args) {
|
|||||||
return Py_BuildValue("s", glfwGetKeyName(key, scancode));
|
return Py_BuildValue("s", glfwGetKeyName(key, scancode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PyObject*
|
||||||
|
glfw_init_hint_string(PyObject UNUSED *self, PyObject *args) {
|
||||||
|
int hint_id;
|
||||||
|
char *hint;
|
||||||
|
if (!PyArg_ParseTuple(args, "is", &hint_id, &hint)) return NULL;
|
||||||
|
#ifdef glfwInitHintString
|
||||||
|
glfwInitHintString(hint_id, hint);
|
||||||
|
#endif
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -448,6 +460,10 @@ init_glfw(PyObject *m) {
|
|||||||
PyEval_InitThreads();
|
PyEval_InitThreads();
|
||||||
glfwSetErrorCallback(cb_error_callback);
|
glfwSetErrorCallback(cb_error_callback);
|
||||||
#define ADDC(n) if(PyModule_AddIntConstant(m, #n, n) != 0) return false;
|
#define ADDC(n) if(PyModule_AddIntConstant(m, #n, n) != 0) return false;
|
||||||
|
#ifdef GLFW_X11_WM_CLASS_NAME
|
||||||
|
ADDC(GLFW_X11_WM_CLASS_NAME)
|
||||||
|
ADDC(GLFW_X11_WM_CLASS_CLASS)
|
||||||
|
#endif
|
||||||
ADDC(GLFW_RELEASE);
|
ADDC(GLFW_RELEASE);
|
||||||
ADDC(GLFW_PRESS);
|
ADDC(GLFW_PRESS);
|
||||||
ADDC(GLFW_REPEAT);
|
ADDC(GLFW_REPEAT);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ PyObject* glfw_wait_events(PyObject UNUSED *self, PyObject*);
|
|||||||
PyObject* glfw_post_empty_event(PyObject UNUSED *self);
|
PyObject* glfw_post_empty_event(PyObject UNUSED *self);
|
||||||
PyObject* glfw_get_physical_dpi(PyObject UNUSED *self);
|
PyObject* glfw_get_physical_dpi(PyObject UNUSED *self);
|
||||||
PyObject* glfw_get_key_name(PyObject UNUSED *self, PyObject *args);
|
PyObject* glfw_get_key_name(PyObject UNUSED *self, PyObject *args);
|
||||||
|
PyObject* glfw_init_hint_string(PyObject UNUSED *self, PyObject *args);
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
PyObject* cocoa_hide_titlebar(PyObject UNUSED *self, PyObject *window_id);
|
PyObject* cocoa_hide_titlebar(PyObject UNUSED *self, PyObject *window_id);
|
||||||
@@ -38,6 +39,7 @@ PyObject* cocoa_get_lang(PyObject UNUSED *self);
|
|||||||
{"glfw_post_empty_event", (PyCFunction)glfw_post_empty_event, METH_NOARGS, ""}, \
|
{"glfw_post_empty_event", (PyCFunction)glfw_post_empty_event, METH_NOARGS, ""}, \
|
||||||
{"glfw_get_physical_dpi", (PyCFunction)glfw_get_physical_dpi, METH_NOARGS, ""}, \
|
{"glfw_get_physical_dpi", (PyCFunction)glfw_get_physical_dpi, METH_NOARGS, ""}, \
|
||||||
{"glfw_get_key_name", (PyCFunction)glfw_get_key_name, METH_VARARGS, ""}, \
|
{"glfw_get_key_name", (PyCFunction)glfw_get_key_name, METH_VARARGS, ""}, \
|
||||||
|
{"glfw_init_hint_string", (PyCFunction)glfw_init_hint_string, METH_VARARGS, ""}, \
|
||||||
COCOA_HIDE_TITLEBAR \
|
COCOA_HIDE_TITLEBAR \
|
||||||
COCOA_GET_LANG
|
COCOA_GET_LANG
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,12 @@ from .fast_data_types import (
|
|||||||
GLFW_STENCIL_BITS, Window, change_wcwidth,
|
GLFW_STENCIL_BITS, Window, change_wcwidth,
|
||||||
enable_automatic_opengl_error_checking, glClear, glClearColor, glewInit,
|
enable_automatic_opengl_error_checking, glClear, glClearColor, glewInit,
|
||||||
glfw_init, glfw_set_error_callback, glfw_swap_interval, glfw_terminate,
|
glfw_init, glfw_set_error_callback, glfw_swap_interval, glfw_terminate,
|
||||||
glfw_wait_events, glfw_window_hint
|
glfw_wait_events, glfw_window_hint, glfw_init_hint_string
|
||||||
)
|
)
|
||||||
|
try:
|
||||||
|
from .fast_data_types import GLFW_X11_WM_CLASS_NAME, GLFW_X11_WM_CLASS_CLASS
|
||||||
|
except ImportError:
|
||||||
|
GLFW_X11_WM_CLASS_NAME = GLFW_X11_WM_CLASS_CLASS = None
|
||||||
from .layout import all_layouts
|
from .layout import all_layouts
|
||||||
from .shaders import GL_VERSION
|
from .shaders import GL_VERSION
|
||||||
from .utils import safe_print
|
from .utils import safe_print
|
||||||
@@ -269,6 +273,8 @@ def main():
|
|||||||
change_wcwidth(not opts.use_system_wcwidth)
|
change_wcwidth(not opts.use_system_wcwidth)
|
||||||
glfw_set_error_callback(on_glfw_error)
|
glfw_set_error_callback(on_glfw_error)
|
||||||
enable_automatic_opengl_error_checking(args.debug_gl)
|
enable_automatic_opengl_error_checking(args.debug_gl)
|
||||||
|
if GLFW_X11_WM_CLASS_CLASS is not None:
|
||||||
|
glfw_init_hint_string(GLFW_X11_WM_CLASS_CLASS, opts.cls)
|
||||||
if not glfw_init():
|
if not glfw_init():
|
||||||
raise SystemExit('GLFW initialization failed')
|
raise SystemExit('GLFW initialization failed')
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user