mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
Also allow using other image formats for window_logo_path
This commit is contained in:
@@ -84,6 +84,8 @@ Detailed list of changes
|
|||||||
|
|
||||||
- Sessions: A new command ``focus_matching_window`` to shift focus to a specific window, useful when creating complex layouts with splits (:disc:`7635`)
|
- Sessions: A new command ``focus_matching_window`` to shift focus to a specific window, useful when creating complex layouts with splits (:disc:`7635`)
|
||||||
|
|
||||||
|
- Speed up loading of large background images by caching the decoded image data. Also allow using images in JPEG/WEBP/TIFF/GIF/BMP formats in addition to PNG
|
||||||
|
|
||||||
- Wayland: Allow fractional scales less than one (:pull:`7549`)
|
- Wayland: Allow fractional scales less than one (:pull:`7549`)
|
||||||
|
|
||||||
- Wayland: Fix specifying the output name for the panel kitten not working (:iss:`7573`)
|
- Wayland: Fix specifying the output name for the panel kitten not working (:iss:`7573`)
|
||||||
|
|||||||
@@ -1134,7 +1134,7 @@ corners from clipping text. Or use :code:`titlebar-and-corners`.
|
|||||||
opt('window_logo_path', 'none',
|
opt('window_logo_path', 'none',
|
||||||
option_type='config_or_absolute_path', ctype='!window_logo_path',
|
option_type='config_or_absolute_path', ctype='!window_logo_path',
|
||||||
long_text='''
|
long_text='''
|
||||||
Path to a logo image. Must be in PNG format. Relative paths are interpreted
|
Path to a logo image. Must be in PNG/JPEG/WEBP/GIF/TIFF/BMP format. Relative paths are interpreted
|
||||||
relative to the kitty config directory. The logo is displayed in a corner of
|
relative to the kitty config directory. The logo is displayed in a corner of
|
||||||
every kitty window. The position is controlled by :opt:`window_logo_position`.
|
every kitty window. The position is controlled by :opt:`window_logo_position`.
|
||||||
Individual windows can be configured to have different logos either using the
|
Individual windows can be configured to have different logos either using the
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "window_logo.h"
|
#include "window_logo.h"
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
typedef struct WindowLogoItem {
|
typedef struct WindowLogoItem {
|
||||||
WindowLogo wl;
|
WindowLogo wl;
|
||||||
@@ -33,19 +34,29 @@ struct WindowLogoTable {
|
|||||||
hash_by_path by_path;
|
hash_by_path by_path;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
free_window_logo_bitmap(WindowLogo *wl) {
|
||||||
|
if (!wl->bitmap) return;
|
||||||
|
if (wl->mmap_size) {
|
||||||
|
if (munmap(wl->bitmap, wl->mmap_size) != 0) log_error("Failed to unmap window logo bitmap with error: %s", strerror(errno));
|
||||||
|
} else free(wl->bitmap);
|
||||||
|
wl->bitmap = NULL; wl->mmap_size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
free_window_logo(WindowLogoItem **itemref) {
|
free_window_logo(WindowLogoItem **itemref) {
|
||||||
WindowLogoItem *item = *itemref;
|
WindowLogoItem *item = *itemref;
|
||||||
free(item->path);
|
free(item->path);
|
||||||
free(item->wl.bitmap);
|
free_window_logo_bitmap(&item->wl);
|
||||||
if (item->wl.texture_id) free_texture(&item->wl.texture_id);
|
if (item->wl.texture_id) free_texture(&item->wl.texture_id);
|
||||||
free(item); itemref = NULL;
|
free(item); itemref = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
send_logo_to_gpu(WindowLogo *s) {
|
send_logo_to_gpu(WindowLogo *s) {
|
||||||
send_image_to_gpu(&s->texture_id, s->bitmap, s->width, s->height, false, true, true, REPEAT_CLAMP);
|
size_t off = s->mmap_size ? 8 : 0;
|
||||||
free(s->bitmap); s->bitmap = NULL;
|
send_image_to_gpu(&s->texture_id, s->bitmap + off, s->width, s->height, false, true, true, REPEAT_CLAMP);
|
||||||
|
free_window_logo_bitmap(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -68,7 +79,7 @@ find_or_create_window_logo(WindowLogoTable *head, const char *path, void *png_da
|
|||||||
size_t size;
|
size_t size;
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
if (png_data == NULL || !png_data_size) {
|
if (png_data == NULL || !png_data_size) {
|
||||||
ok = png_path_to_bitmap(path, &s->wl.bitmap, &s->wl.width, &s->wl.height, &size);
|
ok = image_path_to_bitmap(path, &s->wl.bitmap, &s->wl.width, &s->wl.height, &s->wl.mmap_size);
|
||||||
} else {
|
} else {
|
||||||
ok = png_from_data(png_data, png_data_size, path, &s->wl.bitmap, &s->wl.width, &s->wl.height, &size);
|
ok = png_from_data(png_data, png_data_size, path, &s->wl.bitmap, &s->wl.width, &s->wl.height, &size);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
typedef unsigned int window_logo_id_t;
|
typedef unsigned int window_logo_id_t;
|
||||||
|
|
||||||
typedef struct WindowLogo {
|
typedef struct WindowLogo {
|
||||||
@@ -13,6 +17,7 @@ typedef struct WindowLogo {
|
|||||||
bool load_from_disk_ok;
|
bool load_from_disk_ok;
|
||||||
uint32_t texture_id;
|
uint32_t texture_id;
|
||||||
uint8_t* bitmap;
|
uint8_t* bitmap;
|
||||||
|
size_t mmap_size;
|
||||||
} WindowLogo;
|
} WindowLogo;
|
||||||
|
|
||||||
typedef struct WindowLogoTable WindowLogoTable;
|
typedef struct WindowLogoTable WindowLogoTable;
|
||||||
|
|||||||
Reference in New Issue
Block a user