diff --git a/docs/changelog.rst b/docs/changelog.rst index 2484c6172..c5f0777c1 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -43,6 +43,8 @@ Detailed list of changes - kitten @ ls: Add user variables set on windows to the output (:iss:`6502`) +- X11: Print an error to STDERR instead of refusing to start when the user sets a custom window icon larger than 128128 (:iss:`6507`) + 0.29.2 [2023-07-27] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/glfw.c b/kitty/glfw.c index db73487dd..e0dea6b42 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -703,6 +703,11 @@ set_default_window_icon(PyObject UNUSED *self, PyObject *args) { uint8_t *data; if(!PyArg_ParseTuple(args, "s", &path)) return NULL; if (png_path_to_bitmap(path, &data, &width, &height, &sz)) { +#ifndef __APPLE__ + if (!global_state.is_wayland && (width > 128 || height > 128)) { + return PyErr_Format(PyExc_ValueError, "The window icon is too large (%dx%d). On X11 max window icon size is: 128x128. Create a file called ~/.config/kitty.app-128.png containing a 128x128 image to use as the window icon on X11.", width, height); + } +#endif logo.width = width; logo.height = height; logo.pixels = data; } diff --git a/kitty/main.py b/kitty/main.py index 87258c01d..08b63ac6f 100644 --- a/kitty/main.py +++ b/kitty/main.py @@ -201,14 +201,17 @@ def get_icon128_path(base_path: str) -> str: def set_x11_window_icon() -> None: custom_icon_path = get_custom_window_icon()[1] - if custom_icon_path is not None: - custom_icon128_path = get_icon128_path(custom_icon_path) - if safe_mtime(custom_icon128_path) is None: - set_default_window_icon(custom_icon_path) + try: + if custom_icon_path is not None: + custom_icon128_path = get_icon128_path(custom_icon_path) + if safe_mtime(custom_icon128_path) is None: + set_default_window_icon(custom_icon_path) + else: + set_default_window_icon(custom_icon128_path) else: - set_default_window_icon(custom_icon128_path) - else: - set_default_window_icon(get_icon128_path(logo_png_file)) + set_default_window_icon(get_icon128_path(logo_png_file)) + except ValueError as err: + log_error(err) def _run_app(opts: Options, args: CLIOptions, bad_lines: Sequence[BadLine] = ()) -> None: