mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-20 04:48:06 +01:00
---------------
- Added retain/release mechanism to RImage by adding RRetainImage() and
RReleaseImage(). RDestroyImage() is an alias to RReleaseImage() now, but
will be removed in a future release because it no longer fits with the
semantics. Will be kept for a while to allow a smoother transition.
More about in wrlib/NEWS
For WINGs:
----------
- Small API change:
1. Renamed WMSetApplicationIconImage(), WMGetApplicationIconImage() and
WMSetWindowMiniwindowImage() to respectively WMSetApplicationIconPixmap(),
WMGetApplicationIconPixmap() and WMSetWindowMiniwindowPixmap()
They operate on a WMPixmap which is practically an X Pixmap with no alpha
channel information and the new name is more suggestive and also leaves
room for the new functions added for operating on images with alpha info.
2. Added WMSetApplicationIconImage() and WMGetApplicationIconImage() which
operate on an RImage and store alpha information too.
3. Added WMGetApplicationIconBlendedPixmap() which will take the image with
alpha set by WMSetApplicationIconImage() and will blend it with a color.
If color is NULL it will blend using the default panel color (#aeaaae)
All these changes will allow WINGs to handle images with alpha blending
correctly in panels and wherever else needed. More about in WINGs/NEWS.
- updated panels to use the newly available RImages if present and fallback
to old WMPixmaps if not, to properly show alpha blended images.
- replaced some still left malloc's with wmalloc's.
For Window Maker:
-----------------
- Fixed wrong mapping position of the "Docked Applications Panel" for some
icons.
- Smoother animation for the smiley =)
- Made images with alpha blending be shown correctly in the panels and the
icon chooser.
- The icon image set to be shown in panels ("Logo.WMPanel") will be
automatically updated if its entry in WMWindowAttributes changes (without
a need to restart as until now).
*** Note!!! ***
If you are developing applications with one of libwraster or libWINGs
then you should look to wrlib/NEWS and WINGs/NEWS to see what changed
and how should you update your code.
267 lines
5.0 KiB
C
267 lines
5.0 KiB
C
|
|
#include "WINGsP.h"
|
|
|
|
#include <wraster.h>
|
|
|
|
|
|
WMPixmap*
|
|
WMRetainPixmap(WMPixmap *pixmap)
|
|
{
|
|
if (pixmap)
|
|
pixmap->refCount++;
|
|
|
|
return pixmap;
|
|
}
|
|
|
|
|
|
void
|
|
WMReleasePixmap(WMPixmap *pixmap)
|
|
{
|
|
wassertr(pixmap!=NULL);
|
|
|
|
pixmap->refCount--;
|
|
|
|
if (pixmap->refCount<1) {
|
|
if (pixmap->pixmap)
|
|
XFreePixmap(pixmap->screen->display, pixmap->pixmap);
|
|
if (pixmap->mask)
|
|
XFreePixmap(pixmap->screen->display, pixmap->mask);
|
|
wfree(pixmap);
|
|
}
|
|
}
|
|
|
|
|
|
WMPixmap*
|
|
WMCreatePixmap(WMScreen *scrPtr, int width, int height, int depth, Bool masked)
|
|
{
|
|
WMPixmap *pixPtr;
|
|
|
|
pixPtr = wmalloc(sizeof(WMPixmap));
|
|
pixPtr->screen = scrPtr;
|
|
pixPtr->width = width;
|
|
pixPtr->height = height;
|
|
pixPtr->depth = depth;
|
|
pixPtr->refCount = 1;
|
|
|
|
pixPtr->pixmap = XCreatePixmap(scrPtr->display, W_DRAWABLE(scrPtr),
|
|
width, height, depth);
|
|
if (masked) {
|
|
pixPtr->mask = XCreatePixmap(scrPtr->display, W_DRAWABLE(scrPtr),
|
|
width, height, 1);
|
|
} else {
|
|
pixPtr->mask = None;
|
|
}
|
|
|
|
return pixPtr;
|
|
}
|
|
|
|
|
|
WMPixmap*
|
|
WMCreatePixmapFromXPixmaps(WMScreen *scrPtr, Pixmap pixmap, Pixmap mask,
|
|
int width, int height, int depth)
|
|
{
|
|
WMPixmap *pixPtr;
|
|
|
|
pixPtr = wmalloc(sizeof(WMPixmap));
|
|
pixPtr->screen = scrPtr;
|
|
pixPtr->pixmap = pixmap;
|
|
pixPtr->mask = mask;
|
|
pixPtr->width = width;
|
|
pixPtr->height = height;
|
|
pixPtr->depth = depth;
|
|
pixPtr->refCount = 1;
|
|
|
|
return pixPtr;
|
|
}
|
|
|
|
|
|
WMPixmap*
|
|
WMCreatePixmapFromFile(WMScreen *scrPtr, char *fileName)
|
|
{
|
|
WMPixmap *pixPtr;
|
|
RImage *image;
|
|
|
|
image = RLoadImage(scrPtr->rcontext, fileName, 0);
|
|
if (!image)
|
|
return NULL;
|
|
|
|
pixPtr = WMCreatePixmapFromRImage(scrPtr, image, 127);
|
|
|
|
RReleaseImage(image);
|
|
|
|
return pixPtr;
|
|
}
|
|
|
|
|
|
WMPixmap*
|
|
WMCreatePixmapFromRImage(WMScreen *scrPtr, RImage *image, int threshold)
|
|
{
|
|
WMPixmap *pixPtr;
|
|
Pixmap pixmap, mask;
|
|
|
|
if (!RConvertImageMask(scrPtr->rcontext, image, &pixmap, &mask,
|
|
threshold)) {
|
|
return NULL;
|
|
}
|
|
|
|
pixPtr = wmalloc(sizeof(WMPixmap));
|
|
pixPtr->screen = scrPtr;
|
|
pixPtr->pixmap = pixmap;
|
|
pixPtr->mask = mask;
|
|
pixPtr->width = image->width;
|
|
pixPtr->height = image->height;
|
|
pixPtr->depth = scrPtr->depth;
|
|
pixPtr->refCount = 1;
|
|
|
|
return pixPtr;
|
|
}
|
|
|
|
|
|
WMPixmap*
|
|
WMCreateBlendedPixmapFromRImage(WMScreen *scrPtr, RImage *image, RColor *color)
|
|
{
|
|
WMPixmap *pixPtr;
|
|
RImage *copy;
|
|
|
|
copy = RCloneImage(image);
|
|
if (!copy)
|
|
return NULL;
|
|
|
|
RCombineImageWithColor(copy, color);
|
|
pixPtr = WMCreatePixmapFromRImage(scrPtr, copy, 0);
|
|
RReleaseImage(copy);
|
|
|
|
return pixPtr;
|
|
}
|
|
|
|
|
|
WMPixmap*
|
|
WMCreateBlendedPixmapFromFile(WMScreen *scrPtr, char *fileName, RColor *color)
|
|
{
|
|
WMPixmap *pixPtr;
|
|
RImage *image;
|
|
|
|
|
|
image = RLoadImage(scrPtr->rcontext, fileName, 0);
|
|
if (!image)
|
|
return NULL;
|
|
|
|
RCombineImageWithColor(image, color);
|
|
|
|
pixPtr = WMCreatePixmapFromRImage(scrPtr, image, 0);
|
|
|
|
RReleaseImage(image);
|
|
|
|
return pixPtr;
|
|
}
|
|
|
|
|
|
WMPixmap*
|
|
WMCreatePixmapFromXPMData(WMScreen *scrPtr, char **data)
|
|
{
|
|
WMPixmap *pixPtr;
|
|
RImage *image;
|
|
|
|
image = RGetImageFromXPMData(scrPtr->rcontext, data);
|
|
if (!image)
|
|
return NULL;
|
|
|
|
pixPtr = WMCreatePixmapFromRImage(scrPtr, image, 127);
|
|
|
|
RReleaseImage(image);
|
|
|
|
return pixPtr;
|
|
}
|
|
|
|
|
|
Pixmap
|
|
WMGetPixmapXID(WMPixmap *pixmap)
|
|
{
|
|
wassertrv(pixmap != NULL, None);
|
|
|
|
return pixmap->pixmap;
|
|
}
|
|
|
|
|
|
Pixmap
|
|
WMGetPixmapMaskXID(WMPixmap *pixmap)
|
|
{
|
|
wassertrv(pixmap != NULL, None);
|
|
|
|
return pixmap->mask;
|
|
}
|
|
|
|
|
|
WMSize
|
|
WMGetPixmapSize(WMPixmap *pixmap)
|
|
{
|
|
WMSize size = {0,0};
|
|
|
|
wassertrv(pixmap != NULL, size);
|
|
|
|
size.width = pixmap->width;
|
|
size.height = pixmap->height;
|
|
|
|
return size;
|
|
}
|
|
|
|
|
|
WMPixmap*
|
|
WMGetSystemPixmap(WMScreen *scr, int image)
|
|
{
|
|
switch (image) {
|
|
case WSIReturnArrow:
|
|
return WMRetainPixmap(scr->buttonArrow);
|
|
|
|
case WSIHighlightedReturnArrow:
|
|
return WMRetainPixmap(scr->pushedButtonArrow);
|
|
|
|
case WSIScrollerDimple:
|
|
return WMRetainPixmap(scr->scrollerDimple);
|
|
|
|
case WSIArrowLeft:
|
|
return WMRetainPixmap(scr->leftArrow);
|
|
|
|
case WSIHighlightedArrowLeft:
|
|
return WMRetainPixmap(scr->hiLeftArrow);
|
|
|
|
case WSIArrowRight:
|
|
return WMRetainPixmap(scr->rightArrow);
|
|
|
|
case WSIHighlightedArrowRight:
|
|
return WMRetainPixmap(scr->hiRightArrow);
|
|
|
|
case WSIArrowUp:
|
|
return WMRetainPixmap(scr->upArrow);
|
|
|
|
case WSIHighlightedArrowUp:
|
|
return WMRetainPixmap(scr->hiUpArrow);
|
|
|
|
case WSIArrowDown:
|
|
return WMRetainPixmap(scr->downArrow);
|
|
|
|
case WSIHighlightedArrowDown:
|
|
return WMRetainPixmap(scr->hiDownArrow);
|
|
|
|
case WSICheckMark:
|
|
return WMRetainPixmap(scr->checkMark);
|
|
|
|
default:
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void
|
|
WMDrawPixmap(WMPixmap *pixmap, Drawable d, int x, int y)
|
|
{
|
|
WMScreen *scr = pixmap->screen;
|
|
|
|
XSetClipMask(scr->display, scr->clipGC, pixmap->mask);
|
|
XSetClipOrigin(scr->display, scr->clipGC, x, y);
|
|
|
|
XCopyArea(scr->display, pixmap->pixmap, d, scr->clipGC, 0, 0,
|
|
pixmap->width, pixmap->height, x, y);
|
|
}
|