|
|
@ -1,4 +1,9 @@ |
|
|
|
+++ include/atoms_rest.xmacro
|
|
|
|
# Obtained from: https://github.com/i3/i3/compare/4.13...mickael9:window-icons.diff |
|
|
|
|
|
|
|
diff --git a/include/atoms_rest.xmacro b/include/atoms_rest.xmacro
|
|
|
|
index d461dc0..f32a7e1 100644
|
|
|
|
--- a/include/atoms_rest.xmacro
|
|
|
|
+++ b/include/atoms_rest.xmacro
|
|
|
|
@@ -1,6 +1,7 @@
|
|
|
|
xmacro(_NET_WM_USER_TIME) |
|
|
|
xmacro(_NET_STARTUP_ID) |
|
|
@ -7,21 +12,27 @@ |
|
|
|
xmacro(WM_PROTOCOLS) |
|
|
|
xmacro(WM_DELETE_WINDOW) |
|
|
|
xmacro(UTF8_STRING) |
|
|
|
+++ include/data.h
|
|
|
|
@@ -440,6 +440,11 @@
|
|
|
|
diff --git a/include/data.h b/include/data.h
|
|
|
|
index a729b21..faed55e 100644
|
|
|
|
--- a/include/data.h
|
|
|
|
+++ b/include/data.h
|
|
|
|
@@ -440,6 +440,11 @@ struct Window {
|
|
|
|
|
|
|
|
/* aspect ratio from WM_NORMAL_HINTS (MPlayer uses this for example) */ |
|
|
|
double aspect_ratio; |
|
|
|
+
|
|
|
|
+ /** Window icon, as array of ARGB pixels */
|
|
|
|
+ unsigned char *icon;
|
|
|
|
+ uint32_t* icon;
|
|
|
|
+ int icon_width;
|
|
|
|
+ int icon_height;
|
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
+++ include/libi3.h
|
|
|
|
@@ -586,6 +586,11 @@
|
|
|
|
diff --git a/include/libi3.h b/include/libi3.h
|
|
|
|
index 11ca312..35174f2 100644
|
|
|
|
--- a/include/libi3.h
|
|
|
|
+++ b/include/libi3.h
|
|
|
|
@@ -586,6 +586,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); |
|
|
|
|
|
|
|
/** |
|
|
@ -33,8 +44,11 @@ |
|
|
|
* Draws a filled rectangle. |
|
|
|
* This function is a convenience wrapper and takes care of flushing the |
|
|
|
* surface as well as restoring the cairo state. |
|
|
|
+++ include/window.h
|
|
|
|
@@ -89,3 +89,9 @@
|
|
|
|
diff --git a/include/window.h b/include/window.h
|
|
|
|
index 77e3f48..894ee9f 100644
|
|
|
|
--- a/include/window.h
|
|
|
|
+++ b/include/window.h
|
|
|
|
@@ -89,3 +89,9 @@ void window_update_hints(i3Window *win, xcb_get_property_reply_t *prop, bool *ur
|
|
|
|
* |
|
|
|
*/ |
|
|
|
void window_update_motif_hints(i3Window *win, xcb_get_property_reply_t *prop, border_style_t *motif_border_style); |
|
|
@ -44,8 +58,11 @@ |
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+void window_update_icon(i3Window *win, xcb_get_property_reply_t *prop);
|
|
|
|
+++ libi3/draw_util.c
|
|
|
|
@@ -135,6 +135,41 @@
|
|
|
|
diff --git a/libi3/draw_util.c b/libi3/draw_util.c
|
|
|
|
index e471405..329b685 100644
|
|
|
|
--- a/libi3/draw_util.c
|
|
|
|
+++ b/libi3/draw_util.c
|
|
|
|
@@ -135,6 +135,42 @@ void draw_util_text(i3String *text, surface_t *surface, color_t fg_color, color_
|
|
|
|
cairo_surface_mark_dirty(surface->surface); |
|
|
|
} |
|
|
|
|
|
|
@ -59,11 +76,12 @@ |
|
|
|
+void draw_util_image(unsigned char *src, int src_width, int src_height, surface_t *surface, int x, int y, int width, int height) {
|
|
|
|
+ RETURN_UNLESS_SURFACE_INITIALIZED(surface);
|
|
|
|
+
|
|
|
|
+ cairo_surface_t *image;
|
|
|
|
+ double scale;
|
|
|
|
+
|
|
|
|
+ cairo_save(surface->cr);
|
|
|
|
+
|
|
|
|
+ cairo_surface_t *image;
|
|
|
|
+
|
|
|
|
+ image = cairo_image_surface_create_for_data(
|
|
|
|
+ src,
|
|
|
|
+ CAIRO_FORMAT_ARGB32,
|
|
|
@ -87,8 +105,11 @@ |
|
|
|
/** |
|
|
|
* Draws a filled rectangle. |
|
|
|
* This function is a convenience wrapper and takes care of flushing the |
|
|
|
+++ src/handlers.c
|
|
|
|
@@ -1287,6 +1287,20 @@
|
|
|
|
diff --git a/src/handlers.c b/src/handlers.c
|
|
|
|
index 7dfacef..37bd70c 100644
|
|
|
|
--- a/src/handlers.c
|
|
|
|
+++ b/src/handlers.c
|
|
|
|
@@ -1287,6 +1287,19 @@ static bool handle_strut_partial_change(void *data, xcb_connection_t *conn, uint
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
@ -104,12 +125,11 @@ |
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
/* Returns false if the event could not be processed (e.g. the window could not |
|
|
|
* be found), true otherwise */ |
|
|
|
typedef bool (*cb_property_handler_t)(void *data, xcb_connection_t *c, uint8_t state, xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *property); |
|
|
|
@@ -1308,7 +1322,8 @@
|
|
|
|
@@ -1308,7 +1321,8 @@ static struct property_handler_t property_handlers[] = {
|
|
|
|
{0, 128, handle_class_change}, |
|
|
|
{0, UINT_MAX, handle_strut_partial_change}, |
|
|
|
{0, UINT_MAX, handle_window_type}, |
|
|
@ -119,7 +139,7 @@ |
|
|
|
#define NUM_HANDLERS (sizeof(property_handlers) / sizeof(struct property_handler_t)) |
|
|
|
|
|
|
|
/* |
|
|
|
@@ -1330,6 +1345,7 @@
|
|
|
|
@@ -1330,6 +1344,7 @@ void property_handlers_init(void) {
|
|
|
|
property_handlers[8].atom = A__NET_WM_STRUT_PARTIAL; |
|
|
|
property_handlers[9].atom = A__NET_WM_WINDOW_TYPE; |
|
|
|
property_handlers[10].atom = A__MOTIF_WM_HINTS; |
|
|
@ -127,8 +147,11 @@ |
|
|
|
} |
|
|
|
|
|
|
|
static void property_notify(uint8_t state, xcb_window_t window, xcb_atom_t atom) { |
|
|
|
+++ src/manage.c
|
|
|
|
@@ -91,6 +91,8 @@
|
|
|
|
diff --git a/src/manage.c b/src/manage.c
|
|
|
|
index 81ee16f..233333b 100644
|
|
|
|
--- a/src/manage.c
|
|
|
|
+++ b/src/manage.c
|
|
|
|
@@ -91,6 +91,8 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
|
|
|
|
role_cookie, startup_id_cookie, wm_hints_cookie, |
|
|
|
wm_normal_hints_cookie, motif_wm_hints_cookie, wm_user_time_cookie, wm_desktop_cookie; |
|
|
|
|
|
|
@ -137,7 +160,7 @@ |
|
|
|
geomc = xcb_get_geometry(conn, d); |
|
|
|
|
|
|
|
/* Check if the window is mapped (it could be not mapped when intializing and |
|
|
|
@@ -162,6 +164,7 @@
|
|
|
|
@@ -162,6 +164,7 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
|
|
|
|
motif_wm_hints_cookie = GET_PROPERTY(A__MOTIF_WM_HINTS, 5 * sizeof(uint64_t)); |
|
|
|
wm_user_time_cookie = GET_PROPERTY(A__NET_WM_USER_TIME, UINT32_MAX); |
|
|
|
wm_desktop_cookie = GET_PROPERTY(A__NET_WM_DESKTOP, UINT32_MAX); |
|
|
@ -145,7 +168,7 @@ |
|
|
|
|
|
|
|
DLOG("Managing window 0x%08x\n", window); |
|
|
|
|
|
|
|
@@ -177,6 +180,7 @@
|
|
|
|
@@ -177,6 +180,7 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
|
|
|
|
window_update_class(cwindow, xcb_get_property_reply(conn, class_cookie, NULL), true); |
|
|
|
window_update_name_legacy(cwindow, xcb_get_property_reply(conn, title_cookie, NULL), true); |
|
|
|
window_update_name(cwindow, xcb_get_property_reply(conn, utf8_title_cookie, NULL), true); |
|
|
@ -153,7 +176,7 @@ |
|
|
|
window_update_leader(cwindow, xcb_get_property_reply(conn, leader_cookie, NULL)); |
|
|
|
window_update_transient_for(cwindow, xcb_get_property_reply(conn, transient_cookie, NULL)); |
|
|
|
window_update_strut_partial(cwindow, xcb_get_property_reply(conn, strut_cookie, NULL)); |
|
|
|
@@ -185,6 +189,8 @@
|
|
|
|
@@ -185,6 +189,8 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
|
|
|
|
window_update_hints(cwindow, xcb_get_property_reply(conn, wm_hints_cookie, NULL), &urgency_hint); |
|
|
|
border_style_t motif_border_style = BS_NORMAL; |
|
|
|
window_update_motif_hints(cwindow, xcb_get_property_reply(conn, motif_wm_hints_cookie, NULL), &motif_border_style); |
|
|
@ -162,8 +185,11 @@ |
|
|
|
xcb_size_hints_t wm_size_hints; |
|
|
|
if (!xcb_icccm_get_wm_size_hints_reply(conn, wm_normal_hints_cookie, &wm_size_hints, NULL)) |
|
|
|
memset(&wm_size_hints, '\0', sizeof(xcb_size_hints_t)); |
|
|
|
+++ src/render.c
|
|
|
|
@@ -125,6 +125,10 @@
|
|
|
|
diff --git a/src/render.c b/src/render.c
|
|
|
|
index 85548f2..6380f51 100644
|
|
|
|
--- a/src/render.c
|
|
|
|
+++ b/src/render.c
|
|
|
|
@@ -125,6 +125,10 @@ void render_con(Con *con, bool render_fullscreen) {
|
|
|
|
/* find the height for the decorations */ |
|
|
|
params.deco_height = render_deco_height(); |
|
|
|
|
|
|
@ -174,8 +200,11 @@ |
|
|
|
/* precalculate the sizes to be able to correct rounding errors */ |
|
|
|
params.sizes = precalculate_sizes(con, ¶ms); |
|
|
|
|
|
|
|
+++ src/window.c
|
|
|
|
@@ -17,6 +17,7 @@
|
|
|
|
diff --git a/src/window.c b/src/window.c
|
|
|
|
index db6215d..5b69459 100644
|
|
|
|
--- a/src/window.c
|
|
|
|
+++ b/src/window.c
|
|
|
|
@@ -17,6 +17,7 @@ void window_free(i3Window *win) {
|
|
|
|
FREE(win->class_class); |
|
|
|
FREE(win->class_instance); |
|
|
|
i3string_free(win->name); |
|
|
@ -183,7 +212,7 @@ |
|
|
|
FREE(win->ran_assignments); |
|
|
|
FREE(win); |
|
|
|
} |
|
|
|
@@ -365,3 +366,62 @@
|
|
|
|
@@ -365,3 +366,75 @@ void window_update_motif_hints(i3Window *win, xcb_get_property_reply_t *prop, bo
|
|
|
|
#undef MWM_DECOR_BORDER |
|
|
|
#undef MWM_DECOR_TITLE |
|
|
|
} |
|
|
@ -221,7 +250,7 @@ |
|
|
|
+ data = prop_value;
|
|
|
|
+ }
|
|
|
|
+ if (len == 16*16) {
|
|
|
|
+ break; // found 16 pixels icon
|
|
|
|
+ break; /* found 16 pixels icon */
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* Find pointer to next icon in the reply. */
|
|
|
@ -236,18 +265,34 @@ |
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ LOG("Got _NET_WM_ICON of size: (%d,%d)\n", data[0], data[1]);
|
|
|
|
+ win->name_x_changed = true; // trigger a redraw
|
|
|
|
+ win->name_x_changed = true; /* trigger a redraw */
|
|
|
|
+
|
|
|
|
+ win->icon_width = data[0];
|
|
|
|
+ win->icon_height = data[1];
|
|
|
|
+ win->icon = srealloc(win->icon, len * 4);
|
|
|
|
+
|
|
|
|
+ win->icon = malloc(len * 4);
|
|
|
|
+ memcpy(win->icon, &data[2], len * 4);
|
|
|
|
+ for (uint64_t i = 0; i < len; i++) {
|
|
|
|
+ uint8_t r, g, b, a;
|
|
|
|
+ a = (data[2 + i] >> 24) & 0xff;
|
|
|
|
+ r = (data[2 + i] >> 16) & 0xff;
|
|
|
|
+ g = (data[2 + i] >> 8) & 0xff;
|
|
|
|
+ b = (data[2 + i] >> 0) & 0xff;
|
|
|
|
+
|
|
|
|
+ /* Cairo uses premultiplied alpha */
|
|
|
|
+ r = (r * a) / 0xff;
|
|
|
|
+ g = (g * a) / 0xff;
|
|
|
|
+ b = (b * a) / 0xff;
|
|
|
|
+
|
|
|
|
+ win->icon[i] = (a << 24) | (r << 16) | (g << 8) | b;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ FREE(prop);
|
|
|
|
+}
|
|
|
|
+++ src/x.c
|
|
|
|
@@ -538,6 +538,7 @@
|
|
|
|
diff --git a/src/x.c b/src/x.c
|
|
|
|
index 8d7d3dd..4dcd2c6 100644
|
|
|
|
--- a/src/x.c
|
|
|
|
+++ b/src/x.c
|
|
|
|
@@ -538,6 +538,7 @@ void x_draw_decoration(Con *con) {
|
|
|
|
|
|
|
|
/* 6: draw the title */ |
|
|
|
int text_offset_y = (con->deco_rect.height - config.font.height) / 2; |
|
|
@ -255,7 +300,7 @@ |
|
|
|
|
|
|
|
struct Window *win = con->window; |
|
|
|
if (win == NULL) { |
|
|
|
@@ -567,6 +568,9 @@
|
|
|
|
@@ -567,6 +568,9 @@ void x_draw_decoration(Con *con) {
|
|
|
|
if (win->name == NULL) |
|
|
|
goto copy_pixmaps; |
|
|
|
|
|
|
@ -265,7 +310,7 @@ |
|
|
|
int mark_width = 0; |
|
|
|
if (config.show_marks && !TAILQ_EMPTY(&(con->marks_head))) { |
|
|
|
char *formatted_mark = sstrdup(""); |
|
|
|
@@ -602,12 +606,30 @@
|
|
|
|
@@ -602,12 +606,30 @@ void x_draw_decoration(Con *con) {
|
|
|
|
i3String *title = con->title_format == NULL ? win->name : con_parse_title_format(con); |
|
|
|
draw_util_text(title, &(parent->frame_buffer), |
|
|
|
p->color->text, p->color->background, |
|
|
@ -285,11 +330,11 @@ |
|
|
|
+ int icon_offset_y = (con->deco_rect.height - height) / 2;
|
|
|
|
+
|
|
|
|
+ draw_util_image(
|
|
|
|
+ win->icon,
|
|
|
|
+ (unsigned char *)win->icon,
|
|
|
|
+ win->icon_width,
|
|
|
|
+ win->icon_height,
|
|
|
|
+ &(parent->frame_buffer),
|
|
|
|
+ con->deco_rect.x + text_offset_x - width,
|
|
|
|
+ con->deco_rect.x + logical_px(2),
|
|
|
|
+ con->deco_rect.y + icon_offset_y,
|
|
|
|
+ width,
|
|
|
|
+ height);
|