CTWM
Loading...
Searching...
No Matches
/usr/src/RPM/BUILD/ctwm-4.1.0/workspace_config.c
Go to the documentation of this file.
1/*
2 * Routines using in setting up the config for workspace stuff.
3 */
4
5#include "ctwm.h"
6
7#include <stdio.h>
8#include <string.h>
9#include <stdlib.h>
10
11#include "image.h"
12#include "list.h"
13#include "occupation.h"
14#include "screen.h"
15#include "util.h"
16#include "workspace_config.h"
17#include "workspace_utils.h"
18
19
20// Temp; x-ref desc in workspace_utils
21extern bool useBackgroundInfo;
22
23
24/*
25 * Create a workspace. This is what gets called when parsing
26 * WorkSpaces {} config file entries.
27 *
28 * WorkSpaces {
29 * "One" { name background foreground backback backfore "backpix.jpg" }
30 * # | | | | | |
31 * # WS name | Button Text | Map/Root FG |
32 * # Button BG Map BG Map/Root BG img
33 * }
34 */
35void
36AddWorkSpace(const char *name, const char *background, const char *foreground,
37 const char *backback, const char *backfore, const char *backpix)
38{
40
41 /* XXX Shouldn't just silently return if we're already at max... */
42 if(Scr->workSpaceMgr.count == MAXWORKSPACE) {
43 return;
44 }
45
46 /* Init. Label can change over time, but starts the same as name. */
47 ws = calloc(1, sizeof(WorkSpace));
48 ws->name = strdup(name);
49 ws->label = strdup(name);
50 ws->number = Scr->workSpaceMgr.count++;
51
52 /* We're a new entry on the "everything" list */
53 fullOccupation |= (1 << ws->number);
54
55
56 /*
57 * FB/BG colors for the button state may be specified, or fallback to
58 * the icon manager's if not.
59 */
60 if(background == NULL) {
61 ws->cp.back = Scr->IconManagerC.back;
62 }
63 else {
64 GetColor(Scr->Monochrome, &(ws->cp.back), background);
65 }
66
67 if(foreground == NULL) {
68 ws->cp.fore = Scr->IconManagerC.fore;
69 }
70 else {
71 GetColor(Scr->Monochrome, &(ws->cp.fore), foreground);
72 }
73
74 /* Shadows for 3d buttons derived from that */
75#ifdef COLOR_BLIND_USER
76 ws->cp.shadc = Scr->White;
77 ws->cp.shadd = Scr->Black;
78#else
79 if(!Scr->BeNiceToColormap) {
80 GetShadeColors(&ws->cp);
81 }
82#endif
83
84
85 /*
86 * Map-state fb/bg color, as well as root win background.
87 */
88 if(backback == NULL) {
89 GetColor(Scr->Monochrome, &(ws->backcp.back), "Black");
90 }
91 else {
92 GetColor(Scr->Monochrome, &(ws->backcp.back), backback);
93 useBackgroundInfo = true;
94 }
95
96 if(backfore == NULL) {
97 GetColor(Scr->Monochrome, &(ws->backcp.fore), "White");
98 }
99 else {
100 GetColor(Scr->Monochrome, &(ws->backcp.fore), backfore);
101 useBackgroundInfo = true;
102 }
103
104
105 /* Maybe there's an image to stick on the root as well */
106 ws->image = GetImage(backpix, ws->backcp);
107 if(ws->image != NULL) {
108 useBackgroundInfo = true;
109 }
110
111
112 /* Put ourselves on the end of the workspace list */
113 if(Scr->workSpaceMgr.workSpaceList == NULL) {
114 Scr->workSpaceMgr.workSpaceList = ws;
115 }
116 else {
117 WorkSpace *wstmp = Scr->workSpaceMgr.workSpaceList;
118 while(wstmp->next != NULL) {
119 wstmp = wstmp->next;
120 }
121 wstmp->next = ws;
122 }
123
124 /* There's at least one defined WS now */
125 Scr->workSpaceManagerActive = true;
126
127 return;
128}
129
130
131
132/*
133 * MapWindowCurrentWorkSpace {} parsing
134 */
135void
137 const char *background, const char *foreground,
138 const char *pixmap)
139{
140 Image *image;
141 WorkSpaceMgr *ws = &Scr->workSpaceMgr;
142
143 ws->curBorderColor = Scr->Black;
144 ws->curColors.back = Scr->White;
145 ws->curColors.fore = Scr->Black;
146 ws->curImage = NULL;
147
148 if(border == NULL) {
149 return;
150 }
151 GetColor(Scr->Monochrome, &ws->curBorderColor, border);
152 if(background == NULL) {
153 return;
154 }
155 ws->curPaint = true;
156 GetColor(Scr->Monochrome, &ws->curColors.back, background);
157 if(foreground == NULL) {
158 return;
159 }
160 GetColor(Scr->Monochrome, &ws->curColors.fore, foreground);
161
162 if(pixmap == NULL) {
163 return;
164 }
165 if((image = GetImage(pixmap, Scr->workSpaceMgr.curColors)) == NULL) {
166 fprintf(stderr, "Can't find pixmap %s\n", pixmap);
167 return;
168 }
169 ws->curImage = image;
170}
171
172
173
174/*
175 * MapWindowDefaultWorkSpace {} parsing
176 */
177void
179 const char *background, const char *foreground,
180 const char *pixmap)
181{
182 Image *image;
183 WorkSpaceMgr *ws = &Scr->workSpaceMgr;
184
185 ws->defBorderColor = Scr->Black;
186 ws->defColors.back = Scr->White;
187 ws->defColors.fore = Scr->Black;
188 ws->defImage = NULL;
189
190 if(border == NULL) {
191 return;
192 }
193 GetColor(Scr->Monochrome, &ws->defBorderColor, border);
194 if(background == NULL) {
195 return;
196 }
197 GetColor(Scr->Monochrome, &ws->defColors.back, background);
198 if(foreground == NULL) {
199 return;
200 }
201 GetColor(Scr->Monochrome, &ws->defColors.fore, foreground);
202 if(pixmap == NULL) {
203 return;
204 }
205 if((image = GetImage(pixmap, ws->defColors)) == NULL) {
206 return;
207 }
208 ws->defImage = image;
209}
static int PlaceX
Definition add_window.c:82
#define Scr
Image * GetImage(const char *name, ColorPair cp)
Definition image.c:37
int fullOccupation
Definition occupation.c:43
Definition image.h:9
struct WorkSpace * next
void GetColor(int kind, Pixel *what, const char *name)
Get info from the server about a given color.
Definition util.c:154
void GetShadeColors(ColorPair *cp)
Try and create a 'shaded' version of a color for prettier UI.
Definition util.c:245
bool useBackgroundInfo
void WMapCreateDefaultBackGround(const char *border, const char *background, const char *foreground, const char *pixmap)
void WMapCreateCurrentBackGround(const char *border, const char *background, const char *foreground, const char *pixmap)
void AddWorkSpace(const char *name, const char *background, const char *foreground, const char *backback, const char *backfore, const char *backpix)
#define MAXWORKSPACE