69 char *ret, *colon, *p;
74 while((colon = strchr(p,
':'))) {
85 ret = malloc(
len + 1);
89 while((colon = strchr(p,
':'))) {
136 if(name[0] !=
'~' || name[1] !=
'/') {
140 asprintf(&newname,
"%s/%s",
Home, &name[1]);
157 Colormap cmap =
Scr->RootColormaps.cwins[0]->colormap->c;
167 if(!
Scr->FirstTime) {
172 if(
Scr->Monochrome != kind) {
176 if(! XParseColor(
dpy, cmap, name, &color)) {
177 fprintf(stderr,
"%s: invalid color name \"%s\"\n",
ProgramName, name);
180 if(! XAllocColor(
dpy, cmap, &color)) {
184 XStandardColormap *stdcmap = NULL;
186 if(! XParseColor(
dpy, cmap, name, &color)) {
187 fprintf(stderr,
"%s: invalid color name \"%s\"\n",
ProgramName, name);
194 if(
Scr->StdCmapInfo.mru &&
Scr->StdCmapInfo.mru->maps &&
195 (
Scr->StdCmapInfo.mru->maps[
Scr->StdCmapInfo.mruindex].colormap ==
197 stdcmap = &(
Scr->StdCmapInfo.mru->maps[
Scr->StdCmapInfo.mruindex]);
202 for(sc =
Scr->StdCmapInfo.head; sc; sc = sc->
next) {
205 for(i = 0; i < sc->
nmaps; i++) {
206 if(sc->
maps[i].colormap == cmap) {
207 Scr->StdCmapInfo.mru = sc;
208 Scr->StdCmapInfo.mruindex = i;
209 stdcmap = &(sc->
maps[i]);
218 color.pixel = (stdcmap->base_pixel +
219 ((Pixel)(((float)color.red / 65535.0) *
220 stdcmap->red_max + 0.5) *
222 ((Pixel)(((float)color.green / 65535.0) *
223 stdcmap->green_max + 0.5) *
224 stdcmap->green_mult) +
225 ((Pixel)(((float)color.blue / 65535.0) *
226 stdcmap->blue_max + 0.5) *
227 stdcmap->blue_mult));
230 fprintf(stderr,
"%s: unable to allocate color \"%s\"\n",
248 Colormap cmap =
Scr->RootColormaps.cwins[0]->colormap->c;
252 char clearcol [32], darkcol [32];
262 clearfactor = (float)
Scr->ClearShadowContrast / 100.0;
263 darkfactor = (100.0 - (float)
Scr->DarkShadowContrast) / 100.0;
264 xcol.pixel = cp->
back;
265 XQueryColor(
dpy, cmap, &xcol);
267 sprintf(clearcol,
"#%04x%04x%04x",
268 xcol.red + (
unsigned short)((65535 - xcol.red) * clearfactor),
269 xcol.green + (
unsigned short)((65535 - xcol.green) * clearfactor),
270 xcol.blue + (
unsigned short)((65535 - xcol.blue) * clearfactor));
271 sprintf(darkcol,
"#%04x%04x%04x",
272 (
unsigned short)(xcol.red * darkfactor),
273 (
unsigned short)(xcol.green * darkfactor),
274 (
unsigned short)(xcol.blue * darkfactor));
276 save =
Scr->FirstTime;
277 Scr->FirstTime =
true;
280 Scr->FirstTime = save;
316 char *deffontname =
"fixed,*";
317 char **missing_charset_list_return;
318 int missing_charset_count_return;
319 char *def_string_return;
320 XFontSetExtents *font_extents;
321 XFontStruct **xfonts;
341 asprintf(&basename2,
"%s,*", font->
basename);
342 if((font->
font_set = XCreateFontSet(
dpy, basename2,
343 &missing_charset_list_return,
344 &missing_charset_count_return,
345 &def_string_return)) == NULL) {
346 fprintf(stderr,
"Failed to get fontset %s\n", basename2);
347 if(
Scr->DefaultFont.basename) {
348 deffontname =
Scr->DefaultFont.basename;
350 if((font->
font_set = XCreateFontSet(
dpy, deffontname,
351 &missing_charset_list_return,
352 &missing_charset_count_return,
353 &def_string_return)) == NULL) {
354 fprintf(stderr,
"%s: unable to open fonts \"%s\" or \"%s\"\n",
360 font_extents = XExtentsOfFontSet(font->
font_set);
362 fnum = XFontsOfFontSet(font->
font_set, &xfonts, &font_names);
363 for(i = 0, ascent = 0, descent = 0; i < fnum; i++) {
364 ascent =
MaxSize(ascent, (*xfonts)->ascent);
365 descent =
MaxSize(descent, (*xfonts)->descent);
369 font->
height = font_extents->max_logical_extent.height;
385#define LOADFONT(fld) (GetFont(&scr->fld##Font))
406 if(
Scr->FirstWindow == t) {
420 if(
Scr->FirstWindow != NULL) {
421 Scr->FirstWindow->prev = t;
424 Scr->FirstWindow = t;
444 if(after->
next == t) {
486 int fullw = w + 2 * bw;
487 int fullh = h + 2 * bw;
488 int old_x =
x, old_y =
y;
506 if(
x != old_x ||
y != old_y) {
535 if(
x != old_x ||
y != old_y) {
536 XMoveWindow(
dpy, i->
w,
x,
y);
543 twm_win = twm_win->
next;
559 fprintf(stderr,
"stop logging events\n");
566 if(strcmp(file,
"stderr")) {
572 fprintf(stderr,
"logging events to : %s\n", file);
588 strncpy(dest, src, size - 1);
589 dest[size - 1] =
'\0';
int frame_x
X position on screen of frame.
int frame_y
Y position on screen of frame.
int frame_bw
2d border width.
unsigned int frame_width
Width of frame.
unsigned int frame_height
Height of frame.
Info and control for each X Screen we control.
bool HaveFonts
Whether fonts have been loaded yet in the startup process.
Information about some XStandardColormap we're using.
Info and control for every X Window we take over.
struct TwmWindow * next
Next TwmWindow on the Screen.
struct Icon * icon
The current icon.
struct VirtualScreen * vs
Where the window is currently mapped (may be NULL).
struct TwmWindow * prev
Previous TwmWindow on the Screen.
void safe_strncpy(char *dest, const char *src, size_t size)
void GetColor(int kind, Pixel *what, const char *name)
Get info from the server about a given color.
char * ExpandFilename(const char *name)
bool UpdateFont(MyFont *font, int height)
Try adjusting a font's height.
void GetShadeColors(ColorPair *cp)
Try and create a 'shaded' version of a color for prettier UI.
void RescueWindows(void)
Backend for f.rescuewindows.
static void GetFont(MyFont *font)
Load up fontsets from the X server.
char * ExpandFilePath(char *path)
void DebugTrace(char *file)
Backend for f.trace.
void CreateFonts(ScreenInfo *scr)
Load up our various defined fonts.
void SetupWindow(TwmWindow *tmp_win, int x, int y, int w, int h, int bw)