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
));
56 memset(pix
, 0, sizeof(WPixmap
));
58 RConvertImageMask(scr
->rcontext
, image
, &pix
->image
, &pix
->mask
, 128);
60 pix
->width
= image
->width
;
61 pix
->height
= image
->height
;
62 pix
->depth
= scr
->w_depth
;
70 *----------------------------------------------------------------------
71 * wPixmapCreateFromXBMData--
72 * Creates a WPixmap structure and initializes it with the supplied
73 * XBM structure data, size and mask.
76 * A WPixmap structure or NULL on failure.
78 *----------------------------------------------------------------------
80 WPixmap
*wPixmapCreateFromXBMData(WScreen
* scr
, char *data
, char *mask
,
81 int width
, int height
, unsigned long fg
, unsigned long bg
)
85 pix
= wmalloc(sizeof(WPixmap
));
86 memset(pix
, 0, sizeof(WPixmap
));
87 pix
->image
= XCreatePixmapFromBitmapData(dpy
, scr
->w_win
, data
, width
, height
, fg
, bg
, scr
->w_depth
);
88 if (pix
->image
== None
) {
93 pix
->mask
= XCreateBitmapFromData(dpy
, scr
->w_win
, mask
, width
, height
);
99 pix
->depth
= scr
->w_depth
;
103 WPixmap
*wPixmapCreate(WScreen
* scr
, Pixmap image
, Pixmap mask
)
108 unsigned int width
, height
, depth
, baz
;
110 pix
= wmalloc(sizeof(WPixmap
));
111 memset(pix
, 0, sizeof(WPixmap
));
114 if (!XGetGeometry(dpy
, image
, &foo
, &bar
, &bar
, &width
, &height
, &baz
, &depth
)) {
115 wwarning("XGetGeometry() failed during wPixmapCreate()");
120 pix
->height
= height
;
126 *----------------------------------------------------------------------
128 * Destroys a WPixmap structure and the pixmap/mask it holds.
132 *----------------------------------------------------------------------
134 void wPixmapDestroy(WPixmap
* pix
)
137 if (pix
->mask
&& !pix
->client_owned_mask
) {
138 XFreePixmap(dpy
, pix
->mask
);
141 if (pix
->image
&& !pix
->client_owned
) {
142 XFreePixmap(dpy
, pix
->image
);