mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-21 05:18:06 +01:00
Change to the linux kernel coding style
for arq in `git ls-files *.c`; do
echo $arq;
indent -linux -l115 $arq;
done
The different line break at 115 columns is because
I use a widescreen monitor :-)
This commit is contained in:
283
src/pixmap.c
283
src/pixmap.c
@@ -31,8 +31,6 @@
|
||||
#include "WindowMaker.h"
|
||||
#include "wcore.h"
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
* wPixmapCreateFromXPMData--
|
||||
@@ -46,31 +44,29 @@
|
||||
* DEF_XPM_CLOSENESS specifies the XpmCloseness
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
WPixmap*
|
||||
wPixmapCreateFromXPMData(WScreen *scr, char **data)
|
||||
WPixmap *wPixmapCreateFromXPMData(WScreen * scr, char **data)
|
||||
{
|
||||
RImage *image;
|
||||
WPixmap *pix;
|
||||
RImage *image;
|
||||
WPixmap *pix;
|
||||
|
||||
image = RGetImageFromXPMData(scr->rcontext, data);
|
||||
if (!image)
|
||||
return NULL;
|
||||
image = RGetImageFromXPMData(scr->rcontext, data);
|
||||
if (!image)
|
||||
return NULL;
|
||||
|
||||
pix = wmalloc(sizeof(WPixmap));
|
||||
memset(pix, 0, sizeof(WPixmap));
|
||||
pix = wmalloc(sizeof(WPixmap));
|
||||
memset(pix, 0, sizeof(WPixmap));
|
||||
|
||||
RConvertImageMask(scr->rcontext, image, &pix->image, &pix->mask, 128);
|
||||
RConvertImageMask(scr->rcontext, image, &pix->image, &pix->mask, 128);
|
||||
|
||||
pix->width = image->width;
|
||||
pix->height = image->height;
|
||||
pix->depth = scr->w_depth;
|
||||
pix->width = image->width;
|
||||
pix->height = image->height;
|
||||
pix->depth = scr->w_depth;
|
||||
|
||||
RReleaseImage(image);
|
||||
RReleaseImage(image);
|
||||
|
||||
return pix;
|
||||
return pix;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
* wPixmapCreateFromXBMData--
|
||||
@@ -82,117 +78,106 @@ wPixmapCreateFromXPMData(WScreen *scr, char **data)
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
WPixmap*
|
||||
wPixmapCreateFromXBMData(WScreen *scr, char *data, char *mask,
|
||||
int width, int height, unsigned long fg,
|
||||
unsigned long bg)
|
||||
WPixmap *wPixmapCreateFromXBMData(WScreen * scr, char *data, char *mask,
|
||||
int width, int height, unsigned long fg, unsigned long bg)
|
||||
{
|
||||
WPixmap *pix;
|
||||
WPixmap *pix;
|
||||
|
||||
pix = wmalloc(sizeof(WPixmap));
|
||||
memset(pix, 0, sizeof(WPixmap));
|
||||
pix->image = XCreatePixmapFromBitmapData(dpy, scr->w_win, data, width,
|
||||
height, fg, bg, scr->w_depth);
|
||||
if (pix->image==None) {
|
||||
wfree(pix);
|
||||
return NULL;
|
||||
}
|
||||
if (mask) {
|
||||
pix->mask = XCreateBitmapFromData(dpy, scr->w_win, mask, width,
|
||||
height);
|
||||
} else {
|
||||
pix->mask = None;
|
||||
}
|
||||
pix->width = width;
|
||||
pix->height = height;
|
||||
pix->depth = scr->w_depth;
|
||||
return pix;
|
||||
pix = wmalloc(sizeof(WPixmap));
|
||||
memset(pix, 0, sizeof(WPixmap));
|
||||
pix->image = XCreatePixmapFromBitmapData(dpy, scr->w_win, data, width, height, fg, bg, scr->w_depth);
|
||||
if (pix->image == None) {
|
||||
wfree(pix);
|
||||
return NULL;
|
||||
}
|
||||
if (mask) {
|
||||
pix->mask = XCreateBitmapFromData(dpy, scr->w_win, mask, width, height);
|
||||
} else {
|
||||
pix->mask = None;
|
||||
}
|
||||
pix->width = width;
|
||||
pix->height = height;
|
||||
pix->depth = scr->w_depth;
|
||||
return pix;
|
||||
}
|
||||
|
||||
|
||||
#ifdef unused
|
||||
WPixmap*
|
||||
wPixmapCreateFromBitmap(WScreen *scr, Pixmap bitmap, Pixmap mask,
|
||||
unsigned long fg, unsigned long bg)
|
||||
WPixmap *wPixmapCreateFromBitmap(WScreen * scr, Pixmap bitmap, Pixmap mask, unsigned long fg, unsigned long bg)
|
||||
{
|
||||
WPixmap *pix;
|
||||
XImage *img, *img2;
|
||||
Window foo;
|
||||
int bar, x, y;
|
||||
Pixmap pixmap;
|
||||
unsigned int width, height, baz, d;
|
||||
WPixmap *pix;
|
||||
XImage *img, *img2;
|
||||
Window foo;
|
||||
int bar, x, y;
|
||||
Pixmap pixmap;
|
||||
unsigned int width, height, baz, d;
|
||||
|
||||
if (!XGetGeometry(dpy, bitmap, &foo, &bar, &bar, &width, &height, &baz,
|
||||
&d) || d!=1) {
|
||||
return NULL;
|
||||
}
|
||||
img = XGetImage(dpy, bitmap, 0, 0, width, height, AllPlanes, XYPixmap);
|
||||
if (!img)
|
||||
return NULL;
|
||||
if (!XGetGeometry(dpy, bitmap, &foo, &bar, &bar, &width, &height, &baz, &d) || d != 1) {
|
||||
return NULL;
|
||||
}
|
||||
img = XGetImage(dpy, bitmap, 0, 0, width, height, AllPlanes, XYPixmap);
|
||||
if (!img)
|
||||
return NULL;
|
||||
|
||||
img2=XCreateImage(dpy, scr->w_visual, scr->w_depth, ZPixmap,
|
||||
0, NULL, width, height, 8, 0);
|
||||
if (!img2) {
|
||||
XDestroyImage(img);
|
||||
return NULL;
|
||||
}
|
||||
img2 = XCreateImage(dpy, scr->w_visual, scr->w_depth, ZPixmap, 0, NULL, width, height, 8, 0);
|
||||
if (!img2) {
|
||||
XDestroyImage(img);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pixmap = XCreatePixmap(dpy, scr->w_win, width, height, scr->w_depth);
|
||||
if (pixmap==None) {
|
||||
XDestroyImage(img);
|
||||
XDestroyImage(img2);
|
||||
return NULL;
|
||||
}
|
||||
pixmap = XCreatePixmap(dpy, scr->w_win, width, height, scr->w_depth);
|
||||
if (pixmap == None) {
|
||||
XDestroyImage(img);
|
||||
XDestroyImage(img2);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
img2->data = wmalloc(height * img2->bytes_per_line);
|
||||
img2->data = wmalloc(height * img2->bytes_per_line);
|
||||
|
||||
for (y=0; y<height; y++) {
|
||||
for (x=0; x<width; x++) {
|
||||
if (XGetPixel(img, x, y)==0) {
|
||||
XPutPixel(img2, x, y, bg);
|
||||
} else {
|
||||
XPutPixel(img2, x, y, fg);
|
||||
}
|
||||
}
|
||||
}
|
||||
XSetClipMask(dpy, scr->copy_gc, None);
|
||||
XPutImage(dpy, pixmap, scr->copy_gc, img2, 0, 0, 0, 0, width, height);
|
||||
XDestroyImage(img);
|
||||
XDestroyImage(img2);
|
||||
for (y = 0; y < height; y++) {
|
||||
for (x = 0; x < width; x++) {
|
||||
if (XGetPixel(img, x, y) == 0) {
|
||||
XPutPixel(img2, x, y, bg);
|
||||
} else {
|
||||
XPutPixel(img2, x, y, fg);
|
||||
}
|
||||
}
|
||||
}
|
||||
XSetClipMask(dpy, scr->copy_gc, None);
|
||||
XPutImage(dpy, pixmap, scr->copy_gc, img2, 0, 0, 0, 0, width, height);
|
||||
XDestroyImage(img);
|
||||
XDestroyImage(img2);
|
||||
|
||||
pix = wmalloc(sizeof(WPixmap));
|
||||
memset(pix, 0, sizeof(WPixmap));
|
||||
pix->image = pixmap;
|
||||
pix->mask = mask;
|
||||
pix->width = width;
|
||||
pix->height = height;
|
||||
pix->depth = scr->w_depth;
|
||||
return pix;
|
||||
pix = wmalloc(sizeof(WPixmap));
|
||||
memset(pix, 0, sizeof(WPixmap));
|
||||
pix->image = pixmap;
|
||||
pix->mask = mask;
|
||||
pix->width = width;
|
||||
pix->height = height;
|
||||
pix->depth = scr->w_depth;
|
||||
return pix;
|
||||
}
|
||||
#endif /* unused */
|
||||
#endif /* unused */
|
||||
|
||||
WPixmap*
|
||||
wPixmapCreate(WScreen *scr, Pixmap image, Pixmap mask)
|
||||
WPixmap *wPixmapCreate(WScreen * scr, Pixmap image, Pixmap mask)
|
||||
{
|
||||
WPixmap *pix;
|
||||
Window foo;
|
||||
int bar;
|
||||
unsigned int width, height, depth, baz;
|
||||
WPixmap *pix;
|
||||
Window foo;
|
||||
int bar;
|
||||
unsigned int width, height, depth, baz;
|
||||
|
||||
pix = wmalloc(sizeof(WPixmap));
|
||||
memset(pix, 0, sizeof(WPixmap));
|
||||
pix->image = image;
|
||||
pix->mask = mask;
|
||||
if (!XGetGeometry(dpy, image, &foo, &bar, &bar, &width, &height, &baz,
|
||||
&depth)) {
|
||||
wwarning("XGetGeometry() failed during wPixmapCreate()");
|
||||
wfree(pix);
|
||||
return NULL;
|
||||
}
|
||||
pix->width = width;
|
||||
pix->height = height;
|
||||
pix->depth = depth;
|
||||
return pix;
|
||||
pix = wmalloc(sizeof(WPixmap));
|
||||
memset(pix, 0, sizeof(WPixmap));
|
||||
pix->image = image;
|
||||
pix->mask = mask;
|
||||
if (!XGetGeometry(dpy, image, &foo, &bar, &bar, &width, &height, &baz, &depth)) {
|
||||
wwarning("XGetGeometry() failed during wPixmapCreate()");
|
||||
wfree(pix);
|
||||
return NULL;
|
||||
}
|
||||
pix->width = width;
|
||||
pix->height = height;
|
||||
pix->depth = depth;
|
||||
return pix;
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -211,36 +196,33 @@ wPixmapCreate(WScreen *scr, Pixmap image, Pixmap mask)
|
||||
* continues as no mask was supplied.
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
WPixmap*
|
||||
wPixmapLoadXBMFile(WScreen *scr, char *path, char *mask_path)
|
||||
WPixmap *wPixmapLoadXBMFile(WScreen * scr, char *path, char *mask_path)
|
||||
{
|
||||
WPixmap *pix;
|
||||
int junk;
|
||||
WPixmap *pix;
|
||||
int junk;
|
||||
|
||||
if (!path) return NULL;
|
||||
if (!path)
|
||||
return NULL;
|
||||
|
||||
pix = wmalloc(sizeof(WPixmap));
|
||||
memset(pix, 0, sizeof(WPixmap));
|
||||
pix = wmalloc(sizeof(WPixmap));
|
||||
memset(pix, 0, sizeof(WPixmap));
|
||||
|
||||
if (XReadBitmapFile(dpy, scr->w_win, path, (unsigned *)&(pix->width),
|
||||
(unsigned *)&(pix->height),
|
||||
&(pix->image), &junk, &junk)!=BitmapSuccess) {
|
||||
wfree(pix);
|
||||
return NULL;
|
||||
}
|
||||
if (mask_path!=NULL) {
|
||||
if (XReadBitmapFile(dpy, scr->w_win, path, (unsigned *)&junk,
|
||||
(unsigned *)&junk, &(pix->mask),
|
||||
&junk, &junk) !=BitmapSuccess) {
|
||||
wwarning(_("could not load mask bitmap file \"%s\". Won't use mask"),
|
||||
mask_path);
|
||||
pix->mask = None;
|
||||
}
|
||||
} else {
|
||||
pix->mask = None;
|
||||
}
|
||||
pix->depth = 1;
|
||||
return pix;
|
||||
if (XReadBitmapFile(dpy, scr->w_win, path, (unsigned *)&(pix->width),
|
||||
(unsigned *)&(pix->height), &(pix->image), &junk, &junk) != BitmapSuccess) {
|
||||
wfree(pix);
|
||||
return NULL;
|
||||
}
|
||||
if (mask_path != NULL) {
|
||||
if (XReadBitmapFile(dpy, scr->w_win, path, (unsigned *)&junk,
|
||||
(unsigned *)&junk, &(pix->mask), &junk, &junk) != BitmapSuccess) {
|
||||
wwarning(_("could not load mask bitmap file \"%s\". Won't use mask"), mask_path);
|
||||
pix->mask = None;
|
||||
}
|
||||
} else {
|
||||
pix->mask = None;
|
||||
}
|
||||
pix->depth = 1;
|
||||
return pix;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -254,19 +236,16 @@ wPixmapLoadXBMFile(WScreen *scr, char *path, char *mask_path)
|
||||
* None
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
wPixmapDestroy(WPixmap *pix)
|
||||
void wPixmapDestroy(WPixmap * pix)
|
||||
{
|
||||
if (!pix->shared) {
|
||||
if (pix->mask && !pix->client_owned_mask) {
|
||||
XFreePixmap(dpy, pix->mask);
|
||||
}
|
||||
if (!pix->shared) {
|
||||
if (pix->mask && !pix->client_owned_mask) {
|
||||
XFreePixmap(dpy, pix->mask);
|
||||
}
|
||||
|
||||
if (pix->image && !pix->client_owned) {
|
||||
XFreePixmap(dpy, pix->image);
|
||||
}
|
||||
}
|
||||
wfree(pix);
|
||||
if (pix->image && !pix->client_owned) {
|
||||
XFreePixmap(dpy, pix->image);
|
||||
}
|
||||
}
|
||||
wfree(pix);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user