libdockapp: Add DAMakeShapeFromData() and DAMakeShapeFromFile() functions.

libdockapp supports shaped dockapps with the DASetShape() function, but this
function requires as input a bitmap.  Previously, there was no support for
creating such a bitmap from XBM data without using Xlib directly.

We add two functions, DAMakeShapeFromData(), which is a wrapper around
XCreateBitmapFromData and allows developers to #include XBM data, and
DAMakeShapeFromFile(), which is a wrapper around XReadBitmapfile and
lets developers specify the path to an XBM file.
This commit is contained in:
Doug Torrance 2017-08-31 01:03:31 -04:00 committed by Carlos R. Mafra
parent 3281a28c2f
commit 1891366919
2 changed files with 47 additions and 0 deletions

View file

@ -88,6 +88,41 @@ DAMakeShape(void)
1));
}
Pixmap
DAMakeShapeFromData(char *data, unsigned int width, unsigned int height)
{
return (XCreateBitmapFromData(DADisplay, DAWindow, data,
width, height));
}
Pixmap
DAMakeShapeFromFile(char *filename)
{
Pixmap shape;
unsigned int width, height;
int result, x_hot, y_hot;
result = XReadBitmapFile(DADisplay, DAWindow, filename, &width, &height,
&shape, &x_hot, &y_hot);
switch (result) {
case BitmapOpenFailed:
DAWarning("bitmap file %s cannot be opened.", filename);
break;
case BitmapFileInvalid:
DAWarning("bitmap file %s not valid.", filename);
break;
case BitmapNoMemory:
DAWarning("insufficient memory to open bitmap file %s.",
filename);
break;
}
return shape;
}
Bool
DAMakePixmapFromData(char **data, Pixmap *pixmap, Pixmap *mask,
unsigned short *width, unsigned short *height)

View file

@ -264,6 +264,18 @@ Pixmap DAMakePixmap(void);
*/
Pixmap DAMakeShape(void);
/*
* DAMakeShapeFromData-
* Creates a shape pixmap suitable for use with DASetShape() from XBM data.
*/
Pixmap DAMakeShapeFromData(char *data, unsigned int width, unsigned int height);
/*
* DAMakeShapeFromFile-
* Creates a shape pixmap suitable for use with DASetShape() from an
* XBM file.
*/
Pixmap DAMakeShapeFromFile(char *filename);
/*
* DAMakePixmapFromData-