mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-25 17:52:02 +02:00
X11: Print an error to STDERR instead of refusing to start when the user sets a custom window icon larger than 128128
Fixes #6507
This commit is contained in:
@@ -43,6 +43,8 @@ Detailed list of changes
|
|||||||
|
|
||||||
- kitten @ ls: Add user variables set on windows to the output (:iss:`6502`)
|
- 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]
|
0.29.2 [2023-07-27]
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|||||||
@@ -703,6 +703,11 @@ set_default_window_icon(PyObject UNUSED *self, PyObject *args) {
|
|||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
if(!PyArg_ParseTuple(args, "s", &path)) return NULL;
|
if(!PyArg_ParseTuple(args, "s", &path)) return NULL;
|
||||||
if (png_path_to_bitmap(path, &data, &width, &height, &sz)) {
|
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.width = width; logo.height = height;
|
||||||
logo.pixels = data;
|
logo.pixels = data;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,14 +201,17 @@ def get_icon128_path(base_path: str) -> str:
|
|||||||
|
|
||||||
def set_x11_window_icon() -> None:
|
def set_x11_window_icon() -> None:
|
||||||
custom_icon_path = get_custom_window_icon()[1]
|
custom_icon_path = get_custom_window_icon()[1]
|
||||||
if custom_icon_path is not None:
|
try:
|
||||||
custom_icon128_path = get_icon128_path(custom_icon_path)
|
if custom_icon_path is not None:
|
||||||
if safe_mtime(custom_icon128_path) is None:
|
custom_icon128_path = get_icon128_path(custom_icon_path)
|
||||||
set_default_window_icon(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:
|
else:
|
||||||
set_default_window_icon(custom_icon128_path)
|
set_default_window_icon(get_icon128_path(logo_png_file))
|
||||||
else:
|
except ValueError as err:
|
||||||
set_default_window_icon(get_icon128_path(logo_png_file))
|
log_error(err)
|
||||||
|
|
||||||
|
|
||||||
def _run_app(opts: Options, args: CLIOptions, bad_lines: Sequence[BadLine] = ()) -> None:
|
def _run_app(opts: Options, args: CLIOptions, bad_lines: Sequence[BadLine] = ()) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user