Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug fix #48: Premultiply icon image
 - Premultiply icon images from _NET_WM_ICON. _NET_WM_ICON (supposedly)
   provides non-premultiplied image data while X probably requires
   premultiplied ones. Absence of the conversation causes issues with
   transparent icons (for example, transparent parts become white).
   Thanks to Arkq and revast for reporting. (#48)

 - Use ARGB visual for XCreateImage() when depth is 32 when converting
   image data to pictures, instead of using the default (usually 24-bit)
   visual. In practice seemingly there's no effect, though. Presently
   it uses the result of find_argb_visual() from mainwin.c but maybe the
   initialization should be moved to skippy.c in the future.
  • Loading branch information
richardgv committed Oct 19, 2014
1 parent 2f71a2d commit ecb7835
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/img-xlib.c
Expand Up @@ -56,6 +56,7 @@ simg_load_icon(session_t *ps, Window wid, int desired_size) {
{
unsigned char *converted_data = simg_data32_from_long(
(const long *) best_data, best_width * best_height);
simg_data32_premultiply(converted_data, best_width * best_height);
pictw = simg_data_to_pictw(ps, best_width, best_height, 32, converted_data, 0);
if (converted_data != best_data)
free(converted_data);
Expand Down
7 changes: 6 additions & 1 deletion src/img.h
Expand Up @@ -325,7 +325,12 @@ simg_data_to_pictw(session_t *ps, int width, int height, int depth,
* (bytes_per_line ? bytes_per_line: depth_to_len(depth) * width));
pictw_t *pictw = NULL;
GC gc = None;
XImage *img = XCreateImage(ps->dpy, DefaultVisual(ps->dpy, ps->screen),

// Use ARGB visual if needed
Visual *visual = DefaultVisual(ps->dpy, ps->screen);
if (32 == depth && ps->argb_visual)
visual = ps->argb_visual;
XImage *img = XCreateImage(ps->dpy, visual,
depth, ZPixmap, 0, (char *) data, width, height,
8, bytes_per_line);
if (!img) {
Expand Down
11 changes: 8 additions & 3 deletions src/mainwin.c
Expand Up @@ -57,14 +57,19 @@ mainwin_create(session_t *ps) {
XWindowAttributes rootattr;
XRenderPictureAttributes pa;
XRenderColor clear;


// Get ARGB visual.
// FIXME: Move this to skippy.c?
if (!ps->argb_visual)
ps->argb_visual = find_argb_visual(dpy, ps->screen);

// calloc() makes sure it's filled with zero
MainWin *mw = allocchk(calloc(1, sizeof(MainWin)));

mw->ps = ps;
if (ps->o.lazyTrans) {
mw->depth = 32;
mw->visual = find_argb_visual(dpy, DefaultScreen(dpy));
mw->visual = ps->argb_visual;
if (!mw->visual) {
printfef("(): Couldn't find ARGB visual, lazy transparency can't work.");
goto mainwin_create_err;
Expand Down
2 changes: 2 additions & 0 deletions src/skippy.h
Expand Up @@ -348,6 +348,8 @@ typedef struct {
wmpsn_t wmpsn;
/// @brief Whether we have EWMH fullscreen support.
bool has_ewmh_fullscreen;
/// @brief ARGB visual of the current screen.
Visual *argb_visual;
/// @brief File descriptor of command pipe, in daemon mode.
int fd_pipe;
/// @brief Main window.
Expand Down

0 comments on commit ecb7835

Please sign in to comment.