contrib
debian
docs
i3-config-wizard
i3-dump-log
i3-input
i3-msg
i3-nagbar
i3bar
include
libi3
Makefile
README
fake_configure_notify.c
font.c
get_colorpixel.c
get_mod_mask.c
get_visualtype.c
ipc_connect.c
ipc_recv_message.c
ipc_send_message.c
is_debug_build.c
libi3.mk
root_atom_contents.c
safewrappers.c
string.c
strndup.c
ucs2_conversion.c
man
parser-specs
src
testcases
tests
yajl-fallback
.gitignore
DEPENDS
LICENSE
Makefile
PACKAGE-MAINTAINER
RELEASE-NOTES-4.2
RELEASE-NOTES-4.3
common.mk
generate-command-parser.pl
i3-migrate-config-to-v4
i3-sensible-editor
i3-sensible-pager
i3-sensible-terminal
i3.applications.desktop
i3.config
i3.config.keycodes
i3.xsession.desktop
logo.svg
pseudo-doc.doxygen
You need to specify the --enable-32bit-visual flag when starting i3. This is done because everything feels sluggish on my system when using a 32 bit visual instead of a 24 bit visual. Fast > fancy.
39 lines
1.2 KiB
C
39 lines
1.2 KiB
C
/*
|
|
* vim:ts=4:sw=4:expandtab
|
|
*
|
|
* i3 - an improved dynamic tiling window manager
|
|
* © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE)
|
|
*
|
|
*/
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
|
|
#include "libi3.h"
|
|
|
|
/*
|
|
* Returns the colorpixel to use for the given hex color (think of HTML). Only
|
|
* works for true-color (vast majority of cases) at the moment, avoiding a
|
|
* roundtrip to X11.
|
|
*
|
|
* The hex_color has to start with #, for example #FF00FF.
|
|
*
|
|
* NOTE that get_colorpixel() does _NOT_ check the given color code for validity.
|
|
* This has to be done by the caller.
|
|
*
|
|
* NOTE that this function may in the future rely on a global xcb_connection_t
|
|
* variable called 'conn' to be present.
|
|
*
|
|
*/
|
|
uint32_t get_colorpixel(const char *hex) {
|
|
char strgroups[3][3] = {{hex[1], hex[2], '\0'},
|
|
{hex[3], hex[4], '\0'},
|
|
{hex[5], hex[6], '\0'}};
|
|
uint8_t r = strtol(strgroups[0], NULL, 16);
|
|
uint8_t g = strtol(strgroups[1], NULL, 16);
|
|
uint8_t b = strtol(strgroups[2], NULL, 16);
|
|
|
|
/* We set the first 8 bits high to have 100% opacity in case of a 32 bit
|
|
* color depth visual. */
|
|
return (0xFF << 24) | (r << 16 | g << 8 | b);
|
|
}
|