Initial dockapps git repo
[dockapps.git] / wmweather+-2.12 / wmgeneral / wmgeneral.c
blob808ae0d93bfac9bc6ca3b0a628a6457fdd5737d1
1 #include "../config.h"
3 /*
4 Best viewed with vim5, using ts=4
6 wmgeneral was taken from wmppp.
8 It has a lot of routines which most of the wm* programs use.
10 ------------------------------------------------------------
12 Author: Martijn Pieterse (pieterse@xs4all.nl)
14 ---
15 CHANGES:
16 ---
17 15/08/2002 (Brad Jorsch, anomie@users.sourceforge.net)
18 * Updated createXBMfromXPM to handle the case where the XBM is to be
19 wider than the XPM, or the XBM width is not a multiple of 8.
20 * Pulled createXBMfromXPM into its own file, because it's the same in
21 both -gtk and -x11.
23 11/08/2002 (Brad Jorsch, anomie@users.sourceforge.net)
24 * Removed the rc-file and mouse region stuff to their own files.
25 * Renamed this file to "wmgeneral-x11.c"
26 * Renamed a few of the functions
28 28/08/2001 (Brad Jorsch, anomie@users.sourceforge.net)
29 * Added EnableMouseRegion and DisableMouseRegion
30 * Got annoyed with the 81-character lines. Fixed it. If you don't like
31 it, find a different copy of wmgeneral.c ;)
32 * GraphicsExpose events are enabled here.
33 * GetXPM is exported. It optionally takes an XpmColorSymbol array.
34 * GetColor is exported.
36 30/09/2000 (Brad Jorsch, anomie@users.sourceforge.net)
37 * You know, wmgen.mask sounds like a much nicer place to store the
38 mask... why don't we do that?
40 21/09/1999 (Brad Jorsch, anomie@users.sourceforge.net)
41 * Changed openXwindow to use only the filename, sans path,
42 as the name and class properties of the app.
44 14/09/1998 (Dave Clark, clarkd@skyia.com)
45 * Updated createXBMfromXPM routine
46 * Now supports >256 colors
47 11/09/1998 (Martijn Pieterse, pieterse@xs4all.nl)
48 * Removed a bug from parse_rcfile. You could
49 not use "start" in a command if a label was
50 also start.
51 * Changed the needed geometry string.
52 We don't use window size, and don't support
53 negative positions.
54 03/09/1998 (Martijn Pieterse, pieterse@xs4all.nl)
55 * Added parse_rcfile2
56 02/09/1998 (Martijn Pieterse, pieterse@xs4all.nl)
57 * Added -geometry support (untested)
58 28/08/1998 (Martijn Pieterse, pieterse@xs4all.nl)
59 * Added createXBMfromXPM routine
60 * Saves a lot of work with changing xpm's.
61 02/05/1998 (Martijn Pieterse, pieterse@xs4all.nl)
62 * changed the read_rc_file to parse_rcfile, as suggested by Marcelo E. Magallon
63 * debugged the parse_rc file.
64 30/04/1998 (Martijn Pieterse, pieterse@xs4all.nl)
65 * Ripped similar code from all the wm* programs,
66 and put them in a single file.
70 #include <stdio.h>
72 /******************************************************************************\
73 |* createXBMfromXPM *|
74 \******************************************************************************/
75 void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) {
77 int i,j,k;
78 int width, height, numcol, depth;
79 int zero=0;
80 unsigned char bwrite;
81 int bcount;
82 int curpixel;
84 while(sx&7){ sx++; }
86 sscanf(*xpm, "%d %d %d %d", &width, &height, &numcol, &depth);
87 width*=depth;
89 for (k=0; k!=depth; k++)
91 zero <<=8;
92 zero |= xpm[1][k];
95 for (i=numcol+1; i < numcol+sy+1; i++) {
96 bcount = 0;
97 bwrite = 0;
98 for (j=0; j<sx*depth; j+=depth) {
99 bwrite >>= 1;
101 if(j<width){
102 curpixel=0;
103 for (k=0; k!=depth; k++)
105 curpixel <<=8;
106 curpixel |= xpm[i][j+k];
108 } else {
109 curpixel=zero;
112 if ( curpixel != zero ) {
113 bwrite += 128;
115 bcount++;
116 if (bcount == 8) {
117 *xbm = bwrite;
118 xbm++;
119 bcount = 0;
120 bwrite = 0;