Commit Graph

25 Commits

Author SHA1 Message Date
Emmanuel Lepage Vallée c0b8388f9b
Merge pull request #2207 from psychon/alpha_borders
Make alpha work on window borders
2018-04-22 02:02:10 -04:00
Uli Schlachter 154a76198e Remove a weird comment (#2217)
No idea what this is meant to tell us, but color_init_unchecked()
pointing at itself with "use this instead" makes no sense.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-03-12 22:54:12 -04:00
Uli Schlachter 8a44d59716 Correctly convert colors with alpha to a Lua string
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-03-03 10:57:48 +01:00
Uli Schlachter 1acae2aa6c Make alpha work on window borders
Up to now, we always asked the X11 server for color allocation ("which
pixel value corresponds to (r,g,b)?", an AllocCollor request).

This commit adds direct support for TrueColor and DirectColor visuals.
In such a visual, the X11 server gives tells us where the red, green,
and blue color components are in a pixel value and we can then just
directly compute the pixel value.

Additionally, this commit adds code that assumes that in a depth=32
visual, the remaining values (after handling red, green, blue) is the
alpha channel for colors. Thus, this adds support for transparent client
borders.

This commit also touches code for the systray. However, the systray must
always use the X11 server's default visual and that one always(?) has
depth=24, i.e. does not support an alpha channel. Thus, the systray
background still cannot be transparent.

Also, in theory this commit should support visuals where some color
component does not have 8 bits, for example RGB565. However, this is
just theoretic and I have no idea how to actually test this (without
jumping through too many hoops).

Fixes: https://github.com/awesomeWM/awesome/issues/162
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-03-03 10:57:48 +01:00
Uli Schlachter d2b1e92f9e Clean up header includes
Every .c file has to include the corresponding .h file first to make sure the
headers are self-contained. Additionally, this moves some unneeded includes
around.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-03-30 20:07:48 +02:00
Uli Schlachter 00059d2d73 C color code: Ignore alpha component (FS#966)
The only place where we silently have to ignore alpha components are window
borders and systray background. However, because these color strings could be
coming from the beautiful theme, we shouldn't error out when an alpha component
is present.

With this commit, we silently ignore this alpha component.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-04-07 22:03:38 +02:00
Majic f3f9834aef Refine RGB_ macros, use RGB_16TO8() in luaA_push_color()
Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-11-23 17:39:11 +01:00
Gregor Best c2ea920ca0 remove encoding=utf-8 from modelines
This option is no longer valid in modelines, so it has been removed from
all modelines using the following shellscript:

    #!/bin/ksh

    git ls-tree -r HEAD | cut -f2 | while read f; do
        egrep -e '^(//|--) vim: .*encoding=' $f >/dev/null || continue
        sed -E -e '/^(\/\/|--) vim:/s/:encoding=utf-8//' $f > /tmp/foo
        mv /tmp/foo $f
    done

Signed-off-by: Gregor Best <gbe@ring0.de>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-09-11 17:34:09 +02:00
Uli Schlachter ae8567bef3 Color: Remove alpha, it is unused
Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-10-06 20:18:24 +02:00
Uli Schlachter 0e819f2328 xcolor: Rename to color
Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-10-06 20:14:19 +02:00
Uli Schlachter 2c52bc7001 Color: Remove, we are only using xcolor now
Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-10-06 20:12:57 +02:00
Uli Schlachter dfd95f1f72 Use the new defaults from globalconf
This makes all the code use the default colormap, depth and visual from
globalconf.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-09-30 14:43:58 +02:00
Uli Schlachter cf679c2db3 Remove named colors
The only string format for colors that we now support are #rrggbb and #rrggbbaa.
All other strings will cause errors.

Thanks to this, color_init_cookie_t can be removed. There won't be a request to
the X server for transforming named colors any more and so there won't be a
cookie. This means that color_init_reply() has to be removed, too.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-09-10 11:27:40 +02:00
Uli Schlachter 5d35771673 Save the screen in globalconf.
There can only be on xcb_screen_t now, so we can save it in globalconf.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-08-16 14:10:58 +02:00
Julien Danjou 5b718cdacb structs: rename to globalconf
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-09-07 17:23:01 +02:00
Brian Gianforcaro 3145e3145e Grammar/spelling corrections in comments and docs.
Signed-off-by: Brian Gianforcaro <b.gianfo@gmail.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-08-31 10:39:36 +02:00
Julien Danjou ada6056c89 color: do not take pointer to push
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-08-17 17:46:35 +02:00
Julien Danjou df20e95f82 color: move push color function to color.c
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-06-19 17:01:01 +02:00
Julien Danjou 9b35ad7983 color: simplify includes
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-04-18 14:02:21 +02:00
Uli Schlachter 7beda0321a Add some comments to make things clearer
Signed-off-by: Uli Schlachter <psychon@znc.in>
2009-04-18 14:02:21 +02:00
Uli Schlachter 293f2a312d Add an API for converting a xcolor_t to a color_t
Signed-off-by: Uli Schlachter <psychon@znc.in>
2009-04-18 14:02:21 +02:00
Uli Schlachter 19e30e56d0 Add new color management api
This api is intended for uses where you don't need a color's pixel value but
only the color components.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2009-04-18 14:02:20 +02:00
Uli Schlachter b38881b123 Fix a integer overflow issue
Alpha of 0xff resulted in RGB_8TO16(0xff) == 0x10000. This was cast to uint8_t
which resulted in alpha being set to 0.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2009-04-18 14:01:22 +02:00
Uli Schlachter 388ef61158 Move some code into a helper function
Signed-off-by: Uli Schlachter <psychon@znc.in>
2009-04-18 14:01:21 +02:00
Uli Schlachter 5dadaa59a9 Move xcolor into its own source files
Signed-off-by: Uli Schlachter <psychon@znc.in>
2009-04-18 13:55:38 +02:00