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:
parent
5c0fe23aa5
commit
02c9205061
3 changed files with 17 additions and 7 deletions
|
|
@ -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]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue