2 * Window Maker window manager
4 * Copyright (c) 1997-2003 Alfredo K. Kojima
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include <X11/Xutil.h>
30 #include "WindowMaker.h"
34 *----------------------------------------------------------------------
35 * wPixmapCreateFromXPMData--
36 * Creates a WPixmap structure and initializes it with the supplied
40 * A WPixmap structure or NULL on failure.
43 * DEF_XPM_CLOSENESS specifies the XpmCloseness
44 *----------------------------------------------------------------------
46 WPixmap
*wPixmapCreateFromXPMData(WScreen
* scr
, char **data
)
51 image
= RGetImageFromXPMData(scr
->rcontext
, data
);
55 pix
= wmalloc(sizeof(WPixmap
));
57 RConvertImageMask(scr
->rcontext
, image
, &pix
->image
, &pix
->mask
, 128);
59 pix
->width
= image
->width
;
60 pix
->height
= image
->height
;
61 pix
->depth
= scr
->w_depth
;
69 *----------------------------------------------------------------------
70 * wPixmapCreateFromXBMData--
71 * Creates a WPixmap structure and initializes it with the supplied
72 * XBM structure data, size and mask.
75 * A WPixmap structure or NULL on failure.
77 *----------------------------------------------------------------------
79 WPixmap
*wPixmapCreateFromXBMData(WScreen
* scr
, char *data
, char *mask
,
80 int width
, int height
, unsigned long fg
, unsigned long bg
)
84 pix
= wmalloc(sizeof(WPixmap
));
85 pix
->image
= XCreatePixmapFromBitmapData(dpy
, scr
->w_win
, data
, width
, height
, fg
, bg
, scr
->w_depth
);
86 if (pix
->image
== None
) {
91 pix
->mask
= XCreateBitmapFromData(dpy
, scr
->w_win
, mask
, width
, height
);
97 pix
->depth
= scr
->w_depth
;
101 WPixmap
*wPixmapCreate(WScreen
* scr
, Pixmap image
, Pixmap mask
)
106 unsigned int width
, height
, depth
, baz
;
108 pix
= wmalloc(sizeof(WPixmap
));
111 if (!XGetGeometry(dpy
, image
, &foo
, &bar
, &bar
, &width
, &height
, &baz
, &depth
)) {
112 wwarning("XGetGeometry() failed during wPixmapCreate()");
117 pix
->height
= height
;
123 *----------------------------------------------------------------------
125 * Destroys a WPixmap structure and the pixmap/mask it holds.
129 *----------------------------------------------------------------------
131 void wPixmapDestroy(WPixmap
* pix
)
134 if (pix
->mask
&& !pix
->client_owned_mask
) {
135 XFreePixmap(dpy
, pix
->mask
);
138 if (pix
->image
&& !pix
->client_owned
) {
139 XFreePixmap(dpy
, pix
->image
);