Implement showing window icons in titlebar (#4439)

This feature defaults to off, and can be turned on for individual windows,
or (with for_window) for all new windows. See the userguide change.

This commit is partially based on work by:

• Marius Muja
• mickael9
• Esteve Varela Colominas
• Bernardo Menicagli
This commit is contained in:
Michael Stapelberg
2021-06-13 08:35:52 +02:00
committed by GitHub
parent eaa5e636f9
commit abbf6a85d7
23 changed files with 392 additions and 27 deletions

View File

@@ -331,3 +331,9 @@ void cmd_shmlog(I3_CMD, const char *argument);
*
*/
void cmd_debuglog(I3_CMD, const char *argument);
/**
* Implementation of 'title_window_icon <yes|no>' and 'title_window_icon padding <px>'
*
*/
void cmd_title_window_icon(I3_CMD, const char *enable, int padding);

View File

@@ -15,6 +15,7 @@
#include <xcb/randr.h>
#include <pcre.h>
#include <sys/time.h>
#include <cairo/cairo.h>
#include "queue.h"
@@ -471,6 +472,9 @@ struct Window {
double min_aspect_ratio;
double max_aspect_ratio;
/** Window icon, as Cairo surface */
cairo_surface_t *icon;
/** The window has a nonrectangular shape. */
bool shaped;
/** The window has a nonrectangular input shape. */
@@ -656,6 +660,11 @@ struct Con {
/** The format with which the window's name should be displayed. */
char *title_format;
/** Whether the window icon should be displayed, and with what padding. -1
* means display no window icon (default behavior), 0 means display without
* any padding, 1 means display with 1 pixel of padding and so on. */
int window_icon_padding;
/* a sticky-group is an identifier which bundles several containers to a
* group. The contents are shared between all of them, that is they are
* displayed on whichever of the containers is currently visible */

View File

@@ -3,6 +3,7 @@
xmacro(_NET_WM_USER_TIME) \
xmacro(_NET_STARTUP_ID) \
xmacro(_NET_WORKAREA) \
xmacro(_NET_WM_ICON) \
xmacro(WM_PROTOCOLS) \
xmacro(WM_DELETE_WINDOW) \
xmacro(UTF8_STRING) \

View File

@@ -611,6 +611,11 @@ color_t draw_util_hex_to_color(const char *color);
*/
void draw_util_text(i3String *text, surface_t *surface, color_t fg_color, color_t bg_color, int x, int y, int max_width);
/**
* Draw the given image using libi3.
*/
void draw_util_image(cairo_surface_t *image, surface_t *surface, int x, int y, int width, int height);
/**
* Draws a filled rectangle.
* This function is a convenience wrapper and takes care of flushing the
@@ -668,3 +673,9 @@ void set_screenshot_as_wallpaper(xcb_connection_t *conn, xcb_screen_t *screen);
* content of the window.
*/
bool is_background_set(xcb_connection_t *conn, xcb_screen_t *screen);
/**
* Reports whether str represents the enabled state (1, yes, true, …).
*
*/
bool boolstr(const char *str);

View File

@@ -101,3 +101,9 @@ void window_update_motif_hints(i3Window *win, xcb_get_property_reply_t *prop, bo
*
*/
void window_update_machine(i3Window *win, xcb_get_property_reply_t *prop);
/**
* Updates the _NET_WM_ICON
*
*/
void window_update_icon(i3Window *win, xcb_get_property_reply_t *prop);