- /* Inform clients waiting for a new _NET_SYSTEM_TRAY that we are here */
- void *event = scalloc(32);
- xcb_client_message_event_t *ev = event;
- ev->response_type = XCB_CLIENT_MESSAGE;
- ev->window = xcb_root;
- ev->type = atoms[MANAGER];
- ev->format = 32;
- ev->data.data32[0] = XCB_CURRENT_TIME;
- ev->data.data32[1] = tray_reply->atom;
- ev->data.data32[2] = selwin;
- xcb_send_event(xcb_connection,
- 0,
- xcb_root,
- XCB_EVENT_MASK_STRUCTURE_NOTIFY,
- (char*)ev);
- free(event);
- free(tray_reply);
+ send_tray_clientmessage();
+}
+
+/*
+ * We need to set the _NET_SYSTEM_TRAY_COLORS atom on the tray selection window
+ * to make GTK+ 3 applets with Symbolic Icons visible. If the colors are unset,
+ * they assume a light background.
+ * See also https://bugzilla.gnome.org/show_bug.cgi?id=679591
+ *
+ */
+void init_tray_colors(void) {
+ /* Convert colors.bar_fg (#rrggbb) to 16-bit RGB */
+ const char *bar_fg = (config.colors.bar_fg ? config.colors.bar_fg : "#FFFFFF");
+
+ DLOG("Setting bar_fg = %s as _NET_SYSTEM_TRAY_COLORS\n", bar_fg);
+
+ char strgroups[3][3] = {{bar_fg[1], bar_fg[2], '\0'},
+ {bar_fg[3], bar_fg[4], '\0'},
+ {bar_fg[5], bar_fg[6], '\0'}};
+ const uint8_t r = strtol(strgroups[0], NULL, 16);
+ const uint8_t g = strtol(strgroups[1], NULL, 16);
+ const uint8_t b = strtol(strgroups[2], NULL, 16);
+
+ const uint16_t r16 = ((uint16_t)r << 8) | r;
+ const uint16_t g16 = ((uint16_t)g << 8) | g;
+ const uint16_t b16 = ((uint16_t)b << 8) | b;
+
+ const uint32_t tray_colors[12] = {
+ r16, g16, b16, /* foreground color */
+ r16, g16, b16, /* error color */
+ r16, g16, b16, /* warning color */
+ r16, g16, b16, /* success color */
+ };
+
+ xcb_change_property(xcb_connection,
+ XCB_PROP_MODE_REPLACE,
+ selwin,
+ atoms[_NET_SYSTEM_TRAY_COLORS],
+ XCB_ATOM_CARDINAL,
+ 32,
+ 12,
+ tray_colors);