Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 105555 | Differences between
and this patch

Collapse All | Expand All

(-)xscreensaver-4.22/driver/lock.c (-413 / +672 lines)
Lines 25-30 Link Here
25
#include "xscreensaver.h"
25
#include "xscreensaver.h"
26
#include "resources.h"
26
#include "resources.h"
27
27
28
#include "theme.h"
29
#include "theme_logo.xpm"
30
#include "theme_frame_t.xpm"
31
#include "theme_frame_b.xpm"
32
#include "theme_frame_l.xpm"
33
#include "theme_frame_r.xpm"
34
#include "theme_frame_tl.xpm"
35
#include "theme_frame_tr.xpm"
36
#include "theme_frame_bl.xpm"
37
#include "theme_frame_br.xpm"
38
39
#ifndef THEME_FONT_LOGIN
40
#define THEME_FONT_LOGIN THEME_FONT_LABEL
41
#endif
42
#ifndef THEME_FG_LOGIN
43
#define THEME_FG_LOGIN THEME_FG_LABEL
44
#endif
45
#ifndef THEME_BG_LOGIN
46
#define THEME_BG_LOGIN THEME_BG
47
#endif
48
49
28
#ifndef NO_LOCKING              /* (mostly) whole file */
50
#ifndef NO_LOCKING              /* (mostly) whole file */
29
51
30
#ifdef HAVE_SYSLOG
52
#ifdef HAVE_SYSLOG
Lines 79-85 Link Here
79
#undef MAX
101
#undef MAX
80
#define MAX(a,b) ((a)>(b)?(a):(b))
102
#define MAX(a,b) ((a)>(b)?(a):(b))
81
103
82
enum passwd_state { pw_read, pw_ok, pw_null, pw_fail, pw_cancel, pw_time };
104
#undef MAX3
105
#define MAX3(a,b,c) MAX(a,MAX(b,c))
106
107
enum passwd_state { pw_read, pw_check, pw_ok, pw_null, pw_fail, pw_cancel, pw_time };
108
109
struct xpm_data {
110
  Pixmap pixmap;
111
  Dimension width;
112
  Dimension height;
113
  int npixels;
114
  unsigned long *pixels;
115
};
83
116
84
struct passwd_dialog_data {
117
struct passwd_dialog_data {
85
118
Lines 100-137 Link Here
100
  Bool show_stars_p; /* "I regret that I have but one asterisk for my country."
133
  Bool show_stars_p; /* "I regret that I have but one asterisk for my country."
101
                        -- Nathan Hale, 1776. */
134
                        -- Nathan Hale, 1776. */
102
135
103
  char *heading_label;
104
  char *body_label;
105
  char *user_label;
136
  char *user_label;
106
  char *passwd_label;
137
  char *passwd_label;
107
  char *date_label;
138
  char *date_label;
139
  char *login_label;
108
  char *user_string;
140
  char *user_string;
109
  char *passwd_string;
141
  char *passwd_string;
110
  char *login_label;
142
  char *status_string;
111
143
112
  XFontStruct *heading_font;
113
  XFontStruct *body_font;
114
  XFontStruct *label_font;
144
  XFontStruct *label_font;
115
  XFontStruct *passwd_font;
145
  XFontStruct *passwd_font;
116
  XFontStruct *date_font;
146
  XFontStruct *date_font;
117
  XFontStruct *button_font;
147
  XFontStruct *login_font;
148
  XFontStruct *status_font;
118
149
119
  Pixel foreground;
150
  Pixel foreground;
120
  Pixel background;
151
  Pixel background;
152
153
  Pixel label_foreground;
154
  Pixel label_background;
121
  Pixel passwd_foreground;
155
  Pixel passwd_foreground;
122
  Pixel passwd_background;
156
  Pixel passwd_background;
157
  Pixel date_foreground;
158
  Pixel date_background;
123
  Pixel thermo_foreground;
159
  Pixel thermo_foreground;
124
  Pixel thermo_background;
160
  Pixel thermo_background;
125
  Pixel shadow_top;
161
  Pixel login_foreground;
126
  Pixel shadow_bottom;
162
  Pixel login_background;
127
  Pixel button_foreground;
163
  Pixel denied_foreground;
128
  Pixel button_background;
129
164
130
  Dimension logo_width;
131
  Dimension logo_height;
132
  Dimension thermo_width;
165
  Dimension thermo_width;
133
  Dimension internal_border;
166
  Dimension internal_border;
134
  Dimension shadow_width;
167
  Dimension internal_spacer;
135
168
136
  Dimension passwd_field_x, passwd_field_y;
169
  Dimension passwd_field_x, passwd_field_y;
137
  Dimension passwd_field_width, passwd_field_height;
170
  Dimension passwd_field_width, passwd_field_height;
Lines 142-150 Link Here
142
  Dimension thermo_field_x, thermo_field_y;
175
  Dimension thermo_field_x, thermo_field_y;
143
  Dimension thermo_field_height;
176
  Dimension thermo_field_height;
144
177
145
  Pixmap logo_pixmap;
178
  struct xpm_data logo;
146
  int logo_npixels;
179
  struct xpm_data frame_t;
147
  unsigned long *logo_pixels;
180
  struct xpm_data frame_b;
181
  struct xpm_data frame_l;
182
  struct xpm_data frame_r;
183
  struct xpm_data frame_tl;
184
  struct xpm_data frame_tr;
185
  struct xpm_data frame_bl;
186
  struct xpm_data frame_br;
187
188
  Dimension frame_max_t;
189
  Dimension frame_max_b;
190
  Dimension frame_max_l;
191
  Dimension frame_max_r;
148
192
149
  Cursor passwd_cursor;
193
  Cursor passwd_cursor;
150
  Bool login_button_down_p;
194
  Bool login_button_down_p;
Lines 196-205 Link Here
196
240
197
  pw->show_stars_p = get_boolean_resource("passwd.asterisks", "Boolean");
241
  pw->show_stars_p = get_boolean_resource("passwd.asterisks", "Boolean");
198
  
242
  
199
  pw->heading_label = get_string_resource ("passwd.heading.label",
200
					   "Dialog.Label.Label");
201
  pw->body_label = get_string_resource ("passwd.body.label",
202
					"Dialog.Label.Label");
203
  pw->user_label = get_string_resource ("passwd.user.label",
243
  pw->user_label = get_string_resource ("passwd.user.label",
204
					"Dialog.Label.Label");
244
					"Dialog.Label.Label");
205
  pw->passwd_label = get_string_resource ("passwd.passwd.label",
245
  pw->passwd_label = get_string_resource ("passwd.passwd.label",
Lines 207-270 Link Here
207
  pw->login_label = get_string_resource ("passwd.login.label",
247
  pw->login_label = get_string_resource ("passwd.login.label",
208
                                         "Dialog.Button.Label");
248
                                         "Dialog.Button.Label");
209
249
210
  pw->date_label = get_string_resource ("dateFormat", "DateFormat");
211
212
  if (!pw->heading_label)
213
    pw->heading_label = strdup("ERROR: RESOURCES NOT INSTALLED CORRECTLY");
214
  if (!pw->body_label)
215
    pw->body_label = strdup("ERROR: RESOURCES NOT INSTALLED CORRECTLY");
216
  if (!pw->user_label) pw->user_label = strdup("ERROR");
250
  if (!pw->user_label) pw->user_label = strdup("ERROR");
217
  if (!pw->passwd_label) pw->passwd_label = strdup("ERROR");
251
  if (!pw->passwd_label) pw->passwd_label = strdup("ERROR");
218
  if (!pw->date_label) pw->date_label = strdup("ERROR");
252
  if (!pw->login_label) pw->login_label = strdup ("ERROR") ;
219
  if (!pw->login_label) pw->login_label = strdup ("ERROR (LOGIN)") ;
220
221
  /* Put the version number in the label. */
222
  {
223
    char *s = (char *) malloc (strlen(pw->heading_label) + 20);
224
    sprintf(s, pw->heading_label, si->version);
225
    free (pw->heading_label);
226
    pw->heading_label = s;
227
  }
228
253
229
  pw->user_string = strdup (p && p->pw_name ? p->pw_name : "???");
254
  pw->user_string = strdup (p && p->pw_name ? p->pw_name : "???");
230
  pw->passwd_string = strdup("");
255
  pw->passwd_string = strdup("");
256
  pw->date_label = strdup("%H:%M");
257
258
  pw->label_font = XLoadQueryFont (si->dpy, THEME_FONT_LABEL);
259
  if (!pw->label_font) {
260
    f = get_string_resource("passwd.labelFont", "Dialog.Font");
261
    pw->label_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
262
    if (!pw->label_font) pw->label_font = XLoadQueryFont (si->dpy, "fixed");
263
    if (f) free (f);
264
  }
231
265
232
  f = get_string_resource ("passwd.headingFont", "Dialog.Font");
266
  pw->passwd_font = XLoadQueryFont (si->dpy, THEME_FONT_PASSWD);
233
  pw->heading_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
267
  if (!pw->passwd_font) {
234
  if (!pw->heading_font) pw->heading_font = XLoadQueryFont (si->dpy, "fixed");
268
    f = get_string_resource("passwd.passwdFont", "Dialog.Font");
235
  if (f) free (f);
269
    pw->passwd_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
236
270
    if (!pw->passwd_font) pw->passwd_font = XLoadQueryFont (si->dpy, "fixed");
237
  f = get_string_resource ("passwd.buttonFont", "Dialog.Font");
271
    if (f) free (f);
238
  pw->button_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
272
  }
239
  if (!pw->button_font) pw->button_font = XLoadQueryFont (si->dpy, "fixed");
273
240
  if (f) free (f);
274
  pw->login_font = XLoadQueryFont (si->dpy, THEME_FONT_LOGIN);
241
275
  if (!pw->login_font) {
242
  f = get_string_resource("passwd.bodyFont", "Dialog.Font");
276
    f = get_string_resource("passwd.loginFont", "Dialog.Font");
243
  pw->body_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
277
    pw->login_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
244
  if (!pw->body_font) pw->body_font = XLoadQueryFont (si->dpy, "fixed");
278
    if (!pw->login_font) pw->login_font = XLoadQueryFont (si->dpy, "fixed");
245
  if (f) free (f);
279
    if (f) free (f);
246
280
  }
247
  f = get_string_resource("passwd.labelFont", "Dialog.Font");
281
248
  pw->label_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
282
  pw->date_font = XLoadQueryFont (si->dpy, THEME_FONT_DATE);
249
  if (!pw->label_font) pw->label_font = XLoadQueryFont (si->dpy, "fixed");
283
  if (!pw->date_font) {
250
  if (f) free (f);
284
    f = get_string_resource("passwd.dateFont", "Dialog.Font");
251
285
    pw->date_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
252
  f = get_string_resource("passwd.passwdFont", "Dialog.Font");
286
    if (!pw->date_font) pw->date_font = XLoadQueryFont (si->dpy, "fixed");
253
  pw->passwd_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
287
    if (f) free (f);
254
  if (!pw->passwd_font) pw->passwd_font = XLoadQueryFont (si->dpy, "fixed");
288
  }
255
  if (f) free (f);
289
256
290
  pw->status_font = XLoadQueryFont (si->dpy, THEME_FONT_STATUS);
257
  f = get_string_resource("passwd.dateFont", "Dialog.Font");
291
  if (!pw->status_font) {
258
  pw->date_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
292
    pw->status_font = XLoadQueryFont (si->dpy, ("fixed"));
259
  if (!pw->date_font) pw->date_font = XLoadQueryFont (si->dpy, "fixed");
293
  }
260
  if (f) free (f);
294
261
295
  pw->foreground = parse_pixel_resource (THEME_FG, si->dpy, cmap);
262
  pw->foreground = get_pixel_resource ("passwd.foreground",
296
  pw->background = parse_pixel_resource (THEME_BG, si->dpy, cmap);
263
				       "Dialog.Foreground",
264
				       si->dpy, cmap);
265
  pw->background = get_pixel_resource ("passwd.background",
266
				       "Dialog.Background",
267
				       si->dpy, cmap);
268
297
269
  if (pw->foreground == pw->background)
298
  if (pw->foreground == pw->background)
270
    {
299
    {
Lines 273-319 Link Here
273
      pw->background = WhitePixelOfScreen (screen);
302
      pw->background = WhitePixelOfScreen (screen);
274
    }
303
    }
275
304
276
  pw->passwd_foreground = get_pixel_resource ("passwd.text.foreground",
305
  pw->label_foreground = parse_pixel_resource (THEME_FG_LABEL, si->dpy, cmap);
277
					      "Dialog.Text.Foreground",
306
  pw->label_background = parse_pixel_resource (THEME_BG_LABEL, si->dpy, cmap);
278
					      si->dpy, cmap);
307
279
  pw->passwd_background = get_pixel_resource ("passwd.text.background",
308
  pw->passwd_foreground = parse_pixel_resource (THEME_FG_PASSWD, si->dpy, cmap);
280
					      "Dialog.Text.Background",
309
  pw->passwd_background = parse_pixel_resource (THEME_BG_PASSWD, si->dpy, cmap);
281
					      si->dpy, cmap);
310
282
  pw->button_foreground = get_pixel_resource ("splash.Button.foreground",
311
  pw->date_foreground = parse_pixel_resource (THEME_FG_DATE, si->dpy, cmap);
283
                                              "Dialog.Button.Foreground",
312
  pw->date_background = parse_pixel_resource (THEME_BG_DATE, si->dpy, cmap);
284
                                              si->dpy, cmap);
313
285
  pw->button_background = get_pixel_resource ("splash.Button.background",
314
  pw->login_foreground = parse_pixel_resource (THEME_FG_LOGIN, si->dpy, cmap);
286
                                              "Dialog.Button.Background",
315
  pw->login_background = parse_pixel_resource (THEME_BG_LOGIN, si->dpy, cmap);
287
                                              si->dpy, cmap);
316
288
  pw->thermo_foreground = get_pixel_resource ("passwd.thermometer.foreground",
317
  pw->thermo_foreground = parse_pixel_resource (THEME_FG_THERMO, si->dpy, cmap);
289
					      "Dialog.Thermometer.Foreground",
318
  pw->thermo_background = parse_pixel_resource (THEME_BG_THERMO, si->dpy, cmap);
290
					      si->dpy, cmap);
319
291
  pw->thermo_background = get_pixel_resource ("passwd.thermometer.background",
320
  pw->denied_foreground = parse_pixel_resource (THEME_FG_DENIED, si->dpy, cmap);
292
					      "Dialog.Thermometer.Background",
321
293
					      si->dpy, cmap);
322
  pw->thermo_width = THEME_THERMO_WIDTH;
294
  pw->shadow_top = get_pixel_resource ("passwd.topShadowColor",
323
  pw->internal_border = THEME_INTERNAL_BORDER;
295
				       "Dialog.Foreground",
324
  pw->internal_spacer = THEME_INTERNAL_SPACER;
296
				       si->dpy, cmap);
325
297
  pw->shadow_bottom = get_pixel_resource ("passwd.bottomShadowColor",
326
  {
298
					  "Dialog.Background",
327
    int w, h, tmp;
299
					  si->dpy, cmap);
328
300
329
    /* THEME HACK: A macro or array would tidy the following. */
301
  pw->logo_width = get_integer_resource ("passwd.logo.width",
330
    if (sscanf(*theme_logo_xpm, "%d %d %d %d", &w, &h, &tmp, &tmp) == 4) {
302
					 "Dialog.Logo.Width");
331
      pw->logo.width = (int) w;
303
  pw->logo_height = get_integer_resource ("passwd.logo.height",
332
      pw->logo.height = (int) h;
304
					  "Dialog.Logo.Height");
333
    }
305
  pw->thermo_width = get_integer_resource ("passwd.thermometer.width",
334
306
					   "Dialog.Thermometer.Width");
335
    if (sscanf(*theme_frame_t_xpm, "%d %d %d %d", &w, &h, &tmp, &tmp) == 4) {
307
  pw->internal_border = get_integer_resource ("passwd.internalBorderWidth",
336
      pw->frame_t.width = (int) w;
308
					      "Dialog.InternalBorderWidth");
337
      pw->frame_t.height = (int) h;
309
  pw->shadow_width = get_integer_resource ("passwd.shadowThickness",
338
    }
310
					   "Dialog.ShadowThickness");
339
    if (sscanf(*theme_frame_b_xpm, "%d %d %d %d", &w, &h, &tmp, &tmp) == 4) {
311
340
      pw->frame_b.width = (int) w;
312
  if (pw->logo_width == 0)  pw->logo_width = 150;
341
      pw->frame_b.height = (int) h;
313
  if (pw->logo_height == 0) pw->logo_height = 150;
342
    }
314
  if (pw->internal_border == 0) pw->internal_border = 15;
343
    if (sscanf(*theme_frame_l_xpm, "%d %d %d %d", &w, &h, &tmp, &tmp) == 4) {
315
  if (pw->shadow_width == 0) pw->shadow_width = 4;
344
      pw->frame_l.width = (int) w;
316
  if (pw->thermo_width == 0) pw->thermo_width = pw->shadow_width;
345
      pw->frame_l.height = (int) h;
346
    }
347
    if (sscanf(*theme_frame_r_xpm, "%d %d %d %d", &w, &h, &tmp, &tmp) == 4) {
348
      pw->frame_r.width = (int) w;
349
      pw->frame_r.height = (int) h;
350
    }
351
    if (sscanf(*theme_frame_tl_xpm, "%d %d %d %d", &w, &h, &tmp, &tmp) == 4) {
352
      pw->frame_tl.width = (int) w;
353
      pw->frame_tl.height = (int) h;
354
    }
355
    if (sscanf(*theme_frame_tr_xpm, "%d %d %d %d", &w, &h, &tmp, &tmp) == 4) {
356
      pw->frame_tr.width = (int) w;
357
      pw->frame_tr.height = (int) h;
358
    }
359
    if (sscanf(*theme_frame_bl_xpm, "%d %d %d %d", &w, &h, &tmp, &tmp) == 4) {
360
      pw->frame_bl.width = (int) w;
361
      pw->frame_bl.height = (int) h;
362
    }
363
    if (sscanf(*theme_frame_br_xpm, "%d %d %d %d", &w, &h, &tmp, &tmp) == 4) {
364
      pw->frame_br.width = (int) w;
365
      pw->frame_br.height = (int) h;
366
    }
367
368
    /* THEME HACK: As the pixmaps may not have same dimensions and are aligned
369
       along outside edges find the maximums. */
370
    pw->frame_max_t = MAX3(pw->frame_t.height, pw->frame_tl.height, pw->frame_tr.height);
371
    pw->frame_max_b = MAX3(pw->frame_b.height, pw->frame_bl.height, pw->frame_br.height);
372
    pw->frame_max_l = MAX3(pw->frame_l.width, pw->frame_tl.width, pw->frame_bl.width);
373
    pw->frame_max_r = MAX3(pw->frame_r.width, pw->frame_tr.width, pw->frame_br.width);
374
  }
317
375
318
  {
376
  {
319
    int direction, ascent, descent;
377
    int direction, ascent, descent;
Lines 322-345 Link Here
322
    pw->width = 0;
380
    pw->width = 0;
323
    pw->height = 0;
381
    pw->height = 0;
324
382
325
    /* Measure the heading_label. */
383
    {
326
    XTextExtents (pw->heading_font,
384
      Dimension w2 = 0, w3 = 0, w4 = 0;
327
		  pw->heading_label, strlen(pw->heading_label),
385
      Dimension h2 = 0, h3 = 0, h4 = 0;
328
		  &direction, &ascent, &descent, &overall);
386
      /* THEME HACK: This used to be 12 M's to allow for result strings but on
329
    if (overall.width > pw->width) pw->width = overall.width;
387
         fonts like Neuropol it is just too wide. Result strings now get
330
    pw->height += ascent + descent;
388
         overwritten by theme so it doesn't matter. */
331
389
      const char *passwd_string = "************";
332
    /* Measure the body_label. */
390
      const char *date_string = "88:88";
333
    XTextExtents (pw->body_font,
334
		  pw->body_label, strlen(pw->body_label),
335
		  &direction, &ascent, &descent, &overall);
336
    if (overall.width > pw->width) pw->width = overall.width;
337
    pw->height += ascent + descent;
338
339
    {
340
      Dimension w2 = 0, w3 = 0, button_w = 0;
341
      Dimension h2 = 0, h3 = 0, button_h = 0;
342
      const char *passwd_string = "MMMMMMMMMMMM";
343
391
344
      /* Measure the user_label. */
392
      /* Measure the user_label. */
345
      XTextExtents (pw->label_font,
393
      XTextExtents (pw->label_font,
Lines 359-366 Link Here
359
      XTextExtents (pw->passwd_font,
407
      XTextExtents (pw->passwd_font,
360
		    pw->user_string, strlen(pw->user_string),
408
		    pw->user_string, strlen(pw->user_string),
361
		    &direction, &ascent, &descent, &overall);
409
		    &direction, &ascent, &descent, &overall);
362
      overall.width += (pw->shadow_width * 4);
363
      ascent += (pw->shadow_width * 4);
364
      if (overall.width > w3)  w3 = overall.width;
410
      if (overall.width > w3)  w3 = overall.width;
365
      h3 += ascent + descent;
411
      h3 += ascent + descent;
366
412
Lines 368-425 Link Here
368
      XTextExtents (pw->passwd_font,
414
      XTextExtents (pw->passwd_font,
369
		    passwd_string, strlen(passwd_string),
415
		    passwd_string, strlen(passwd_string),
370
		    &direction, &ascent, &descent, &overall);
416
		    &direction, &ascent, &descent, &overall);
371
      overall.width += (pw->shadow_width * 4);
372
      ascent += (pw->shadow_width * 4);
373
      if (overall.width > w3)  w3 = overall.width;
417
      if (overall.width > w3)  w3 = overall.width;
374
      h3 += ascent + descent;
418
      h3 += ascent + descent;
375
419
376
      w2 = w2 + w3 + (pw->shadow_width * 2);
420
      /* Measure the date_label. */
377
      h2 = MAX (h2, h3);
421
      XTextExtents (pw->date_font,
378
422
		    date_string, strlen(date_string),
379
      pw->login_button_width = 0;
423
		    &direction, &ascent, &descent, &overall);
380
      pw->login_button_height = 0;
424
      if (overall.width > w4)  w4 = overall.width;
425
      h4 += ascent + descent;
381
426
427
      /* Measure the login_label if enabled. */
382
      if (pw->login_button_p)
428
      if (pw->login_button_p)
383
        {
429
      {
384
          pw->login_button_enabled_p = True;
430
        XTextExtents (pw->login_font,
385
431
		      pw->login_label, strlen(pw->login_label),
386
          /* Measure the "New Login" button */
432
		      &direction, &ascent, &descent, &overall);
387
          XTextExtents (pw->button_font, pw->login_label,
433
        w4 += overall.width + 4;
388
                        strlen (pw->login_label),
434
        if (ascent + descent > h4) h4 = ascent + descent + 4;
389
                        &direction, &ascent, &descent, &overall);
435
      }
390
          button_w = overall.width;
391
          button_h = ascent + descent;
392
393
          /* Add some horizontal padding inside the buttons. */
394
          button_w += ascent;
395
396
          button_w += ((ascent + descent) / 2) + (pw->shadow_width * 2);
397
          button_h += ((ascent + descent) / 2) + (pw->shadow_width * 2);
398
399
          pw->login_button_width = button_w;
400
          pw->login_button_height = button_h;
401
402
          w2 = MAX (w2, button_w);
403
          h2 += button_h * 1.5;
404
        }
405
436
406
      if (w2 > pw->width)  pw->width  = w2;
437
      pw->width = MAX (w2 + w3, w4);
407
      pw->height += h2;
438
      pw->height = MAX (h2, h3);
439
      pw->height += h4;
408
    }
440
    }
409
441
410
    pw->width  += (pw->internal_border * 2);
442
    if (pw->logo.height > pw->height)
411
    pw->height += (pw->internal_border * 4);
443
      pw->height = pw->logo.height;
412
444
413
    pw->width += pw->thermo_width + (pw->shadow_width * 3);
445
    pw->width += 2 * pw->internal_border + pw->logo.width +
446
                 3 * pw->internal_spacer + pw->thermo_width;
447
    pw->height+= 2 * pw->internal_border;
414
448
415
    if (pw->logo_height > pw->height)
416
      pw->height = pw->logo_height;
417
    else if (pw->height > pw->logo_height)
418
      pw->logo_height = pw->height;
419
449
420
    pw->logo_width = pw->logo_height;
450
    /* THEME HACK: By default, increase size so as to draw complete pixmaps.
451
       Can only do for one (opposing) side - top and left. */
452
#if defined THEME_TOP_CENTRED || defined THEME_TOP_FIT
453
    if (pw->width % pw->frame_t.width)
454
      pw->width += pw->frame_t.width - pw->width % pw->frame_t.width;
455
#endif
456
#if defined THEME_LEFT_CENTRED || defined THEME_LEFT_FIT
457
    if (pw->height % pw->frame_l.height)
458
      pw->height += pw->frame_l.height - pw->height % pw->frame_l.height;
459
#endif
460
#ifdef THEME_BOTTOM_FIT
461
    if (pw->width % pw->frame_b.width)
462
      pw->width += pw->frame_b.width - pw->width % pw->frame_b.width;
463
#endif
464
#ifdef THEME_RIGHT_FIT
465
    if (pw->height % pw->frame_r.height)
466
      pw->height += pw->frame_r.height - pw->height % pw->frame_r.height;
467
#endif
468
#ifdef THEME_BOTTOM_CENTRED
469
    if (pw->width % pw->frame_b.width)
470
      pw->width += pw->frame_b.width - pw->width % pw->frame_b.width;
471
#endif
472
#ifdef THEME_RIGHT_CENTRED
473
    if (pw->height % pw->frame_r.height)
474
      pw->height += pw->frame_r.height - pw->height % pw->frame_r.height;
475
#endif
421
476
422
    pw->width += pw->logo_width;
477
    pw->width += pw->frame_max_l + pw->frame_max_r;
478
    pw->height+= pw->frame_max_t + pw->frame_max_b;
423
  }
479
  }
424
480
425
  attrmask |= CWOverrideRedirect; attrs.override_redirect = True;
481
  attrmask |= CWOverrideRedirect; attrs.override_redirect = True;
Lines 483-495 Link Here
483
539
484
  /* We use the default visual, not ssi->visual, so that the logo pixmap's
540
  /* We use the default visual, not ssi->visual, so that the logo pixmap's
485
     visual matches that of the si->passwd_dialog window. */
541
     visual matches that of the si->passwd_dialog window. */
486
  pw->logo_pixmap = xscreensaver_logo (ssi->screen,
542
  pw->logo.pixmap = xscreensaver_xpm (ssi->screen,
487
                                       /* ssi->current_visual, */
543
                                       /* ssi->current_visual, */
488
                                       DefaultVisualOfScreen(screen),
544
                                       DefaultVisualOfScreen(screen),
489
                                       si->passwd_dialog, cmap,
545
                                       si->passwd_dialog, cmap,
490
                                       pw->background, 
546
                                       pw->background, 
491
                                       &pw->logo_pixels, &pw->logo_npixels,
547
                                       &pw->logo.pixels, &pw->logo.npixels,
492
                                       0, True);
548
                                       0, theme_logo_xpm);
549
550
  /* THEME HACK: A macro or array would tidy the following. */
551
  pw->frame_t.pixmap = xscreensaver_xpm (ssi->screen,
552
                                       DefaultVisualOfScreen(screen),
553
                                       si->passwd_dialog, cmap,
554
                                       pw->background, 
555
                                       &pw->frame_t.pixels, &pw->frame_t.npixels,
556
                                       0, theme_frame_t_xpm);
557
  pw->frame_b.pixmap = xscreensaver_xpm (ssi->screen,
558
                                       DefaultVisualOfScreen(screen),
559
                                       si->passwd_dialog, cmap,
560
                                       pw->background, 
561
                                       &pw->frame_b.pixels, &pw->frame_b.npixels,
562
                                       0, theme_frame_b_xpm);
563
  pw->frame_l.pixmap = xscreensaver_xpm (ssi->screen,
564
                                       DefaultVisualOfScreen(screen),
565
                                       si->passwd_dialog, cmap,
566
                                       pw->background, 
567
                                       &pw->frame_l.pixels, &pw->frame_l.npixels,
568
                                       0, theme_frame_l_xpm);
569
  pw->frame_r.pixmap = xscreensaver_xpm (ssi->screen,
570
                                       DefaultVisualOfScreen(screen),
571
                                       si->passwd_dialog, cmap,
572
                                       pw->background, 
573
                                       &pw->frame_r.pixels, &pw->frame_r.npixels,
574
                                       0, theme_frame_r_xpm);
575
  pw->frame_tl.pixmap = xscreensaver_xpm (ssi->screen,
576
                                       DefaultVisualOfScreen(screen),
577
                                       si->passwd_dialog, cmap,
578
                                       pw->background, 
579
                                       &pw->frame_tl.pixels, &pw->frame_tl.npixels,
580
                                       0, theme_frame_tl_xpm);
581
  pw->frame_tr.pixmap = xscreensaver_xpm (ssi->screen,
582
                                       DefaultVisualOfScreen(screen),
583
                                       si->passwd_dialog, cmap,
584
                                       pw->background, 
585
                                       &pw->frame_tr.pixels, &pw->frame_tr.npixels,
586
                                       0, theme_frame_tr_xpm);
587
  pw->frame_bl.pixmap = xscreensaver_xpm (ssi->screen,
588
                                       DefaultVisualOfScreen(screen),
589
                                       si->passwd_dialog, cmap,
590
                                       pw->background, 
591
                                       &pw->frame_bl.pixels, &pw->frame_bl.npixels,
592
                                       0, theme_frame_bl_xpm);
593
  pw->frame_br.pixmap = xscreensaver_xpm (ssi->screen,
594
                                       DefaultVisualOfScreen(screen),
595
                                       si->passwd_dialog, cmap,
596
                                       pw->background, 
597
                                       &pw->frame_br.pixels, &pw->frame_br.npixels,
598
                                       0, theme_frame_br_xpm);
493
599
494
  /* Before mapping the window, save the bits that are underneath the
600
  /* Before mapping the window, save the bits that are underneath the
495
     rectangle the window will occlude.  When we lower the window, we
601
     rectangle the window will occlude.  When we lower the window, we
Lines 533-538 Link Here
533
  XSync (si->dpy, False);
639
  XSync (si->dpy, False);
534
}
640
}
535
641
642
static void
643
xpm_passwd_window (saver_info *si, GC gc, Pixmap pixmap, int dx, int dy)
644
{
645
  passwd_dialog_data *pw = si->pw_data;
646
647
  if (pixmap) {
648
    Window root;
649
    int x, y;
650
    unsigned int w, h, bw, d;
651
652
    XGetGeometry (si->dpy, pixmap, &root, &x, &y, &w, &h, &bw, &d);
653
    XSetForeground (si->dpy, gc, pw->foreground);
654
    XSetBackground (si->dpy, gc, pw->background);
655
    if (d == 1)
656
      XCopyPlane (si->dpy, pixmap, si->passwd_dialog, gc,
657
                  0, 0, w, h, dx, dy, 1);
658
    else
659
      XCopyArea (si->dpy, pixmap, si->passwd_dialog, gc,
660
                 0, 0, w, h, dx, dy);
661
  }
662
}
536
663
537
static void
664
static void
538
draw_passwd_window (saver_info *si)
665
draw_passwd_window (saver_info *si)
Lines 542-607 Link Here
542
  GC gc1, gc2;
669
  GC gc1, gc2;
543
  int spacing, height;
670
  int spacing, height;
544
  int x1, x2, x3, y1, y2;
671
  int x1, x2, x3, y1, y2;
545
  int sw;
672
  int i;
546
  int tb_height;
673
  int tb_height;
547
674
548
  height = (pw->heading_font->ascent + pw->heading_font->descent +
675
  height = 2 * MAX ((pw->label_font->ascent + pw->label_font->descent),
549
            pw->body_font->ascent + pw->body_font->descent +
676
		    (pw->passwd_font->ascent + pw->passwd_font->descent)) +
550
            (2 * MAX ((pw->label_font->ascent + pw->label_font->descent),
677
           pw->date_font->ascent + pw->date_font->descent;
551
                      (pw->passwd_font->ascent + pw->passwd_font->descent +
678
  /* THEME HACK: The "spacing" is automatic padding to allow for logo size.
552
                       (pw->shadow_width * 4)))) +
679
     Frame->Border->Spacer->User->Spacer->Password->Spacer->Date->Border->Frame
553
            pw->date_font->ascent + pw->date_font->descent);
680
  */
554
681
  spacing = ((pw->height - pw->frame_max_t - 2 * pw->internal_border -
555
  if (pw->login_button_p)
682
              pw->frame_max_b - height)) / 3;
556
    height += ((pw->button_font->ascent + pw->button_font->descent) * 2 +
557
               2 * pw->shadow_width);
558
559
  spacing = (((pw->height
560
               - ((pw->login_button_p ? 4 : 2) * pw->shadow_width)
561
               - pw->internal_border - height))
562
             / 8);
563
564
  if (spacing < 0) spacing = 0;
683
  if (spacing < 0) spacing = 0;
565
684
566
  gcv.foreground = pw->foreground;
685
  gcv.foreground = pw->foreground;
567
  gc1 = XCreateGC (si->dpy, si->passwd_dialog, GCForeground, &gcv);
686
  gc1 = XCreateGC (si->dpy, si->passwd_dialog, GCForeground, &gcv);
568
  gc2 = XCreateGC (si->dpy, si->passwd_dialog, GCForeground, &gcv);
687
  gc2 = XCreateGC (si->dpy, si->passwd_dialog, GCForeground, &gcv);
569
  x1 = pw->logo_width + pw->thermo_width + (pw->shadow_width * 3);
688
  /* THEME HACK: Changed from original logo-thermometer-test order to
570
  x3 = pw->width - (pw->shadow_width * 2);
689
     logo-text-thermometer. */
571
  y1 = (pw->shadow_width * 2) + spacing + spacing;
690
  x1 = pw->frame_max_l + pw->internal_border + pw->logo.width + pw->internal_spacer;
572
691
  y1 = pw->frame_max_t + pw->internal_border;
573
  /* top heading
692
  x3 = pw->width - pw->internal_spacer - pw->internal_border - pw->frame_max_r;
574
   */
575
  XSetFont (si->dpy, gc1, pw->heading_font->fid);
576
  sw = string_width (pw->heading_font, pw->heading_label);
577
  x2 = (x1 + ((x3 - x1 - sw) / 2));
578
  y1 += spacing + pw->heading_font->ascent + pw->heading_font->descent;
579
  XDrawString (si->dpy, si->passwd_dialog, gc1, x2, y1,
580
	       pw->heading_label, strlen(pw->heading_label));
581
582
  /* text below top heading
583
   */
584
  XSetFont (si->dpy, gc1, pw->body_font->fid);
585
  y1 += spacing + pw->body_font->ascent + pw->body_font->descent;
586
  sw = string_width (pw->body_font, pw->body_label);
587
  x2 = (x1 + ((x3 - x1 - sw) / 2));
588
  XDrawString (si->dpy, si->passwd_dialog, gc1, x2, y1,
589
	       pw->body_label, strlen(pw->body_label));
590
693
591
694
  tb_height = pw->passwd_font->ascent + pw->passwd_font->descent;
592
  tb_height = (pw->passwd_font->ascent + pw->passwd_font->descent +
593
	       (pw->shadow_width * 4));
594
695
595
  /* the "User:" prompt
696
  /* the "User:" prompt
596
   */
697
   */
597
  y1 += spacing;
698
  y1 += spacing + tb_height;
598
  y2 = y1;
699
  y2 = y1;
599
  XSetForeground (si->dpy, gc1, pw->foreground);
700
  x2 = x1 + MAX(string_width (pw->label_font, pw->user_label),
701
                string_width (pw->label_font, pw->passwd_label));
702
600
  XSetFont (si->dpy, gc1, pw->label_font->fid);
703
  XSetFont (si->dpy, gc1, pw->label_font->fid);
601
  y1 += (spacing + tb_height);
704
  XSetForeground (si->dpy, gc1, pw->label_background);
602
  x2 = (x1 + pw->internal_border +
705
  XFillRectangle (si->dpy, si->passwd_dialog, gc1,
603
	MAX(string_width (pw->label_font, pw->user_label),
706
		  x2 - string_width (pw->label_font, pw->user_label),
604
	    string_width (pw->label_font, pw->passwd_label)));
707
		  y1 - (pw->label_font->ascent + pw->label_font->descent),
708
		  string_width (pw->label_font, pw->user_label),
709
                  pw->label_font->ascent + pw->label_font->descent);
710
  XSetForeground (si->dpy, gc1, pw->label_foreground);
605
  XDrawString (si->dpy, si->passwd_dialog, gc1,
711
  XDrawString (si->dpy, si->passwd_dialog, gc1,
606
	       x2 - string_width (pw->label_font, pw->user_label),
712
	       x2 - string_width (pw->label_font, pw->user_label),
607
	       y1 - pw->passwd_font->descent,
713
	       y1 - pw->passwd_font->descent,
Lines 609-615 Link Here
609
715
610
  /* the "Password:" prompt
716
  /* the "Password:" prompt
611
   */
717
   */
612
  y1 += (spacing + tb_height);
718
  y1 += spacing + tb_height;
719
  XSetForeground (si->dpy, gc1, pw->label_background);
720
  XFillRectangle (si->dpy, si->passwd_dialog, gc1,
721
		  x2 - string_width (pw->label_font, pw->passwd_label),
722
		  y1 - (pw->label_font->ascent + pw->label_font->descent),
723
		  string_width (pw->label_font, pw->passwd_label),
724
                  pw->label_font->ascent + pw->label_font->descent);
725
726
  XSetForeground (si->dpy, gc1, pw->label_foreground);
613
  XDrawString (si->dpy, si->passwd_dialog, gc1,
727
  XDrawString (si->dpy, si->passwd_dialog, gc1,
614
	       x2 - string_width (pw->label_font, pw->passwd_label),
728
	       x2 - string_width (pw->label_font, pw->passwd_label),
615
	       y1 - pw->passwd_font->descent,
729
	       y1 - pw->passwd_font->descent,
Lines 623-638 Link Here
623
  y1 = y2;
737
  y1 = y2;
624
  XSetForeground (si->dpy, gc1, pw->passwd_foreground);
738
  XSetForeground (si->dpy, gc1, pw->passwd_foreground);
625
  XSetFont (si->dpy, gc1, pw->passwd_font->fid);
739
  XSetFont (si->dpy, gc1, pw->passwd_font->fid);
626
  y1 += (spacing + tb_height);
740
  x2 += pw->internal_spacer;
627
  x2 += (pw->shadow_width * 4);
628
741
629
  pw->passwd_field_width = x3 - x2 - pw->internal_border;
742
  pw->passwd_field_width = x3 - x2 - pw->internal_border;
630
  pw->passwd_field_height = (pw->passwd_font->ascent +
743
  pw->passwd_field_height = pw->passwd_font->ascent + pw->passwd_font->descent;
631
			     pw->passwd_font->descent +
632
			     pw->shadow_width);
633
744
634
  XFillRectangle (si->dpy, si->passwd_dialog, gc2,
745
  XFillRectangle (si->dpy, si->passwd_dialog, gc2,
635
		  x2 - pw->shadow_width,
746
		  x2,
636
		  y1 - (pw->passwd_font->ascent + pw->passwd_font->descent),
747
		  y1 - (pw->passwd_font->ascent + pw->passwd_font->descent),
637
		  pw->passwd_field_width, pw->passwd_field_height);
748
		  pw->passwd_field_width, pw->passwd_field_height);
638
  XDrawString (si->dpy, si->passwd_dialog, gc1,
749
  XDrawString (si->dpy, si->passwd_dialog, gc1,
Lines 642-673 Link Here
642
753
643
  /* the "password" text field
754
  /* the "password" text field
644
   */
755
   */
645
  y1 += (spacing + tb_height);
756
  y1 += spacing + tb_height;
646
757
647
  pw->passwd_field_x = x2 - pw->shadow_width;
758
  pw->passwd_field_x = x2;
648
  pw->passwd_field_y = y1 - (pw->passwd_font->ascent +
759
  pw->passwd_field_y = y1 - pw->passwd_field_height;
649
			     pw->passwd_font->descent);
650
760
651
  /* The shadow around the text fields
761
  /* The "New Login" button
652
   */
762
   */
653
  y1 = y2;
763
  if (pw->login_button_p)
654
  y1 += (spacing + (pw->shadow_width * 3));
764
    {
655
  x1 = x2 - (pw->shadow_width * 2);
765
      pw->login_button_width = string_width(pw->login_font, pw->login_label) + 4;
656
  x2 = pw->passwd_field_width + (pw->shadow_width * 2);
766
      pw->login_button_height = pw->login_font->ascent + pw->login_font->descent + 4;
657
  y2 = pw->passwd_field_height + (pw->shadow_width * 2);
658
659
  draw_shaded_rectangle (si->dpy, si->passwd_dialog,
660
			 x1, y1, x2, y2,
661
			 pw->shadow_width,
662
			 pw->shadow_bottom, pw->shadow_top);
663
664
  y1 += (spacing + pw->passwd_font->ascent + pw->passwd_font->descent +
665
	 (pw->shadow_width * 4));
666
  draw_shaded_rectangle (si->dpy, si->passwd_dialog,
667
			 x1, y1, x2, y2,
668
			 pw->shadow_width,
669
			 pw->shadow_bottom, pw->shadow_top);
670
767
768
      pw->login_button_x = pw->width - pw->login_button_width -
769
                           pw->internal_spacer - pw->thermo_width -
770
                           pw->internal_border - pw->frame_max_r;
771
      pw->login_button_y = pw->height - pw->internal_border -
772
                           pw->frame_max_b - pw->login_button_height;
773
    }
671
774
672
  /* The date, below the text fields
775
  /* The date, below the text fields
673
   */
776
   */
Lines 679-800 Link Here
679
    strftime (buf, sizeof(buf)-1, pw->date_label, tm);
782
    strftime (buf, sizeof(buf)-1, pw->date_label, tm);
680
783
681
    XSetFont (si->dpy, gc1, pw->date_font->fid);
784
    XSetFont (si->dpy, gc1, pw->date_font->fid);
682
    y1 += pw->shadow_width;
785
    /* THEME HACK: Place date centred between logo and thermometer
683
    y1 += (spacing + tb_height);
786
       (or login button if enabled). */
684
    y1 += spacing/2;
787
    x1 += (pw->width - pw->frame_max_l - 2 * pw->internal_border -
685
    sw = string_width (pw->date_font, buf);
788
           pw->logo.width - pw->login_button_width - pw->thermo_width -
686
    x2 = x1 + x2 - sw;
789
           pw->frame_max_r) / 2 -
687
    XDrawString (si->dpy, si->passwd_dialog, gc1, x2, y1, buf, strlen(buf));
790
          string_width(pw->date_font, buf) / 2;
791
    y1 = pw->height - pw->internal_border - pw->frame_max_b;
792
793
    XSetForeground (si->dpy, gc1, pw->date_background);
794
    XFillRectangle (si->dpy, si->passwd_dialog, gc1,
795
		    x1,
796
		    y1 - (pw->date_font->ascent + pw->date_font->descent),
797
		    string_width (pw->date_font, buf),
798
                    pw->date_font->ascent + pw->date_font->descent);
799
    XSetForeground (si->dpy, gc1, pw->date_foreground);
800
    XDrawString (si->dpy, si->passwd_dialog, gc1,
801
                 x1,
802
                 y1  - pw->date_font->descent,
803
                 buf, strlen(buf));
688
  }
804
  }
689
805
690
  /* The "New Login" button
691
   */
692
  if (pw->login_button_p)
693
    {
694
      XSetForeground (si->dpy, gc1, pw->button_foreground);
695
      XSetForeground (si->dpy, gc2, pw->button_background);
696
      XSetFont (si->dpy, gc1, pw->button_font->fid);
697
698
      sw = string_width (pw->button_font, pw->login_label);
699
700
      x2 = pw->width - pw->internal_border - (pw->shadow_width * 2);
701
702
      /* right aligned button */
703
      /* x1 = x2 - pw->login_button_width;  */
704
705
      /* centered button */
706
      x1 = (pw->logo_width + pw->thermo_width + (pw->shadow_width * 3) +
707
            pw->internal_border);
708
      x1 = x1 + (x2 - x1 - pw->login_button_width) / 2;
709
710
      y1 = (pw->height - pw->internal_border - pw->login_button_height +
711
            spacing);
712
      y2 = (y1 +
713
            ((pw->login_button_height -
714
              (pw->button_font->ascent + pw->button_font->descent))
715
             / 2) +
716
            pw->button_font->ascent);
717
718
      pw->login_button_x = x1;
719
      pw->login_button_y = y1;
720
    }
721
722
  /* The logo
806
  /* The logo
723
   */
807
   */
724
  x1 = pw->shadow_width * 6;
808
  x1 = pw->frame_max_l + pw->internal_border;
725
  y1 = pw->shadow_width * 6;
809
  y1 = pw->frame_max_t + (pw->height - pw->frame_max_t - pw->frame_max_b) / 2 -
726
  x2 = pw->logo_width - (pw->shadow_width * 12);
810
       pw->logo.height / 2;
727
  y2 = pw->logo_height - (pw->shadow_width * 12);
811
  x2 = pw->logo.width;
728
812
  y2 = pw->logo.height;
729
  if (pw->logo_pixmap)
813
730
    {
814
  if (pw->logo.pixmap) {
731
      Window root;
815
    xpm_passwd_window (si, gc1, pw->logo.pixmap,
732
      int x, y;
816
                       x1 + ((x2 - pw->logo.width) / 2),
733
      unsigned int w, h, bw, d;
817
                       y1 + ((y2 - pw->logo.height) / 2));
734
      XGetGeometry (si->dpy, pw->logo_pixmap, &root, &x, &y, &w, &h, &bw, &d);
818
  }
735
      XSetForeground (si->dpy, gc1, pw->foreground);
736
      XSetBackground (si->dpy, gc1, pw->background);
737
      if (d == 1)
738
        XCopyPlane (si->dpy, pw->logo_pixmap, si->passwd_dialog, gc1,
739
                    0, 0, w, h,
740
                    x1 + ((x2 - (int)w) / 2),
741
                    y1 + ((y2 - (int)h) / 2),
742
                    1);
743
      else
744
        XCopyArea (si->dpy, pw->logo_pixmap, si->passwd_dialog, gc1,
745
                   0, 0, w, h,
746
                   x1 + ((x2 - (int)w) / 2),
747
                   y1 + ((y2 - (int)h) / 2));
748
    }
749
819
750
  /* The thermometer
820
  /* The frame
751
   */
821
   */
752
  XSetForeground (si->dpy, gc1, pw->thermo_foreground);
822
  /* THEME HACK: The side pixmaps are either drawn centred or repeated along
753
  XSetForeground (si->dpy, gc2, pw->thermo_background);
823
     outside side of the frame. */
754
824
  if (pw->frame_t.pixmap) {
755
  pw->thermo_field_x = pw->logo_width + pw->shadow_width;
825
#ifdef THEME_TOP_CENTRED
756
  pw->thermo_field_y = pw->shadow_width * 5;
826
    xpm_passwd_window (si, gc1, pw->frame_t.pixmap,
757
  pw->thermo_field_height = pw->height - (pw->shadow_width * 10);
827
                       pw->frame_max_l +
758
828
                       (pw->width - pw->frame_max_l - pw->frame_max_r) / 2 -
759
#if 0
829
                       pw->frame_t.width / 2,
760
  /* Solid border inside the logo box. */
830
                       0);
761
  XSetForeground (si->dpy, gc1, pw->foreground);
831
#else
762
  XDrawRectangle (si->dpy, si->passwd_dialog, gc1, x1, y1, x2-1, y2-1);
832
    for (i = pw->frame_max_l; i < (pw->width - pw->frame_max_r) ; i += pw->frame_t.width) {
833
      xpm_passwd_window (si, gc1, pw->frame_t.pixmap, i, 0);
834
    }
763
#endif
835
#endif
836
  }
837
  if (pw->frame_b.pixmap) {
838
#ifdef THEME_BOTTOM_CENTRED
839
    xpm_passwd_window (si, gc1, pw->frame_b.pixmap,
840
                       pw->frame_max_l +
841
                       (pw->width - pw->frame_max_l - pw->frame_max_r) / 2 -
842
                       pw->frame_b.width / 2,
843
                       pw->height - pw->frame_b.height);
844
#else
845
    for (i = pw->frame_max_l; i < (pw->width - pw->frame_max_r) ; i += pw->frame_b.width) {
846
      xpm_passwd_window (si, gc1, pw->frame_b.pixmap,
847
                             i, pw->height - pw->frame_b.height);
848
    }
849
#endif
850
  }
851
  if (pw->frame_l.pixmap) {
852
#ifdef THEME_LEFT_CENTRED
853
    xpm_passwd_window (si, gc1, pw->frame_l.pixmap,
854
                       0,
855
                       pw->frame_max_t +
856
                       (pw->height - pw->frame_max_t - pw->frame_max_b) / 2 -
857
                       pw->frame_l.height / 2 );
858
#else
859
    for (i = pw->frame_max_t; i < (pw->height - pw->frame_max_b) ; i += pw->frame_l.height) {
860
      xpm_passwd_window (si, gc1, pw->frame_l.pixmap, 0, i);
861
    }
862
#endif
863
  }
864
  if (pw->frame_r.pixmap) {
865
#ifdef THEME_RIGHT_CENTRED
866
    xpm_passwd_window (si, gc1, pw->frame_r.pixmap,
867
                       pw->width - pw->frame_r.width,
868
                       pw->frame_max_t +
869
                       (pw->height - pw->frame_max_t - pw->frame_max_b) / 2 -
870
                       pw->frame_r.height / 2 );
871
#else
872
    for (i = pw->frame_max_t; i < (pw->height - pw->frame_max_b) ; i += pw->frame_r.height) {
873
      xpm_passwd_window (si, gc1, pw->frame_r.pixmap,
874
                         pw->width - pw->frame_r.width, i);
875
    }
876
#endif
877
  }
878
  /* THEME HACK: Black out corners. If corner pixmap is smaller than side
879
     pixmaps we need to clear side pixmap overwrite. Additionally if background
880
     is not black, then undrawn parts would have that colour. */
881
  XSetForeground (si->dpy, gc1, BlackPixelOfScreen (pw->prompt_screen->screen));
882
  XFillRectangle (si->dpy, si->passwd_dialog, gc1,
883
                  0, 0,
884
                  pw->frame_max_l, pw->frame_max_t);
885
  XFillRectangle (si->dpy, si->passwd_dialog, gc1,
886
                  pw->width - pw->frame_max_r, 0,
887
                  pw->frame_max_l, pw->frame_max_t);
888
  XFillRectangle (si->dpy, si->passwd_dialog, gc1,
889
                  0, pw->height - pw->frame_max_b,
890
                  pw->frame_max_l, pw->frame_max_t);
891
  XFillRectangle (si->dpy, si->passwd_dialog, gc1,
892
                  pw->width - pw->frame_max_r, pw->height - pw->frame_max_b,
893
                  pw->frame_max_l, pw->frame_max_t);
894
  /* THEME HACK: The corner pixmaps are drawn to the inside corner of the
895
     frame. */
896
  if (pw->frame_tl.pixmap) {
897
    xpm_passwd_window (si, gc1, pw->frame_tl.pixmap,
898
                       pw->frame_max_l - pw->frame_tl.width,
899
                       pw->frame_max_t - pw->frame_tl.height);
900
  }
901
  if (pw->frame_tr.pixmap) {
902
    xpm_passwd_window (si, gc1, pw->frame_tr.pixmap,
903
                       pw->width - pw->frame_max_l,
904
                       pw->frame_max_t - pw->frame_tl.height);
905
  }
906
  if (pw->frame_bl.pixmap) {
907
    xpm_passwd_window (si, gc1, pw->frame_bl.pixmap,
908
                       pw->frame_max_l - pw->frame_bl.width,
909
                       pw->height - pw->frame_max_b);
910
  }
911
  if (pw->frame_br.pixmap) {
912
    xpm_passwd_window (si, gc1, pw->frame_br.pixmap,
913
                       pw->width - pw->frame_max_r,
914
                       pw->height - pw->frame_max_b);
915
  }
764
916
765
  /* The shadow around the logo
917
  /* the thermometer
766
   */
767
  draw_shaded_rectangle (si->dpy, si->passwd_dialog,
768
			 pw->shadow_width * 4,
769
			 pw->shadow_width * 4,
770
			 pw->logo_width - (pw->shadow_width * 8),
771
			 pw->logo_height - (pw->shadow_width * 8),
772
			 pw->shadow_width,
773
			 pw->shadow_bottom, pw->shadow_top);
774
775
  /* The shadow around the thermometer
776
   */
918
   */
777
  draw_shaded_rectangle (si->dpy, si->passwd_dialog,
919
  pw->thermo_field_x = pw->width - pw->thermo_width - pw->internal_border -
778
			 pw->logo_width,
920
                       pw->frame_max_r;
779
			 pw->shadow_width * 4,
921
  pw->thermo_field_y = pw->frame_max_t + pw->internal_border;
780
			 pw->thermo_width + (pw->shadow_width * 2),
922
  pw->thermo_field_height = pw->height - pw->frame_max_t - 2 * pw->internal_border -
781
			 pw->height - (pw->shadow_width * 8),
923
                            pw->frame_max_b;
782
			 pw->shadow_width,
783
			 pw->shadow_bottom, pw->shadow_top);
784
924
785
#if 1
786
  /* Solid border inside the thermometer. */
925
  /* Solid border inside the thermometer. */
787
  XSetForeground (si->dpy, gc1, pw->foreground);
926
  XSetForeground (si->dpy, gc1, pw->thermo_background);
788
  XDrawRectangle (si->dpy, si->passwd_dialog, gc1, 
927
  XDrawRectangle (si->dpy, si->passwd_dialog, gc1, 
789
		  pw->thermo_field_x, pw->thermo_field_y,
928
		  pw->thermo_field_x, pw->thermo_field_y,
790
                  pw->thermo_width - 1, pw->thermo_field_height - 1);
929
                  pw->thermo_width - 1, pw->thermo_field_height - 1);
791
#endif
792
793
  /* The shadow around the whole window
794
   */
795
  draw_shaded_rectangle (si->dpy, si->passwd_dialog,
796
			 0, 0, pw->width, pw->height, pw->shadow_width,
797
			 pw->shadow_top, pw->shadow_bottom);
798
930
799
  XFreeGC (si->dpy, gc1);
931
  XFreeGC (si->dpy, gc1);
800
  XFreeGC (si->dpy, gc2);
932
  XFreeGC (si->dpy, gc2);
Lines 839-845 Link Here
839
  XSetClipRectangles (si->dpy, gc1, 0, 0, rects, 1, Unsorted);
971
  XSetClipRectangles (si->dpy, gc1, 0, 0, rects, 1, Unsorted);
840
972
841
  XDrawString (si->dpy, si->passwd_dialog, gc1,
973
  XDrawString (si->dpy, si->passwd_dialog, gc1,
842
               rects[0].x + pw->shadow_width,
974
               rects[0].x,
843
               rects[0].y + pw->passwd_font->ascent,
975
               rects[0].y + pw->passwd_font->ascent,
844
               pw->passwd_string, strlen(pw->passwd_string));
976
               pw->passwd_string, strlen(pw->passwd_string));
845
977
Lines 849-873 Link Here
849
   */
981
   */
850
  if (pw->i_beam != 0)
982
  if (pw->i_beam != 0)
851
    {
983
    {
852
      x = (rects[0].x + pw->shadow_width +
984
      x = rects[0].x + string_width (pw->passwd_font, pw->passwd_string);
853
	   string_width (pw->passwd_font, pw->passwd_string));
985
      y = rects[0].y;
854
      y = rects[0].y + pw->shadow_width;
855
986
856
      if (x > rects[0].x + rects[0].width - 1)
987
      if (x > rects[0].x + rects[0].width - 1)
857
        x = rects[0].x + rects[0].width - 1;
988
        x = rects[0].x + rects[0].width - 1;
858
      XDrawLine (si->dpy, si->passwd_dialog, gc1, 
989
      XDrawLine (si->dpy, si->passwd_dialog, gc1, 
859
		 x, y,
990
		 x, y, x, y + pw->passwd_field_height - 1);
860
                 x, y + pw->passwd_font->ascent + pw->passwd_font->descent-1);
861
    }
991
    }
862
992
863
  pw->i_beam = (pw->i_beam + 1) % 4;
993
  pw->i_beam = (pw->i_beam + 1) % 4;
864
994
865
995
866
  /* the thermometer
996
  /* The thermometer
867
   */
997
   */
868
  y = (pw->thermo_field_height - 2) * (1.0 - pw->ratio);
998
  y = (pw->thermo_field_height - 2) * (1.0 - pw->ratio);
869
  if (y > 0)
999
  if (y > 0)
870
    {
1000
    {
1001
      XSetForeground (si->dpy, gc2, pw->background);
871
      XFillRectangle (si->dpy, si->passwd_dialog, gc2,
1002
      XFillRectangle (si->dpy, si->passwd_dialog, gc2,
872
		      pw->thermo_field_x + 1,
1003
		      pw->thermo_field_x + 1,
873
		      pw->thermo_field_y + 1,
1004
		      pw->thermo_field_y + 1,
Lines 885-925 Link Here
885
   */
1016
   */
886
  if (pw->login_button_p)
1017
  if (pw->login_button_p)
887
    {
1018
    {
888
      int x2, y2, sw;
889
      XSetFont (si->dpy, gc1, pw->button_font->fid);
890
      XSetForeground (si->dpy, gc1,
1019
      XSetForeground (si->dpy, gc1,
891
                      (pw->login_button_enabled_p
1020
                      (pw->login_button_enabled_p
892
                       ? pw->passwd_foreground
1021
                       ? pw->login_background
893
                       : pw->shadow_bottom));
1022
                       : pw->login_foreground));
894
      XSetForeground (si->dpy, gc2, pw->button_background);
895
1023
896
      XFillRectangle (si->dpy, si->passwd_dialog, gc2,
1024
      XDrawRectangle (si->dpy, si->passwd_dialog, gc1,
897
                      pw->login_button_x, pw->login_button_y,
1025
                      pw->login_button_x, pw->login_button_y,
898
		      pw->login_button_width, pw->login_button_height);
1026
                      pw->login_button_width - 1, pw->login_button_height - 1);
1027
      XSetFont (si->dpy, gc1, pw->login_font->fid);
1028
      XDrawString (si->dpy, si->passwd_dialog, gc1,
1029
                   pw->login_button_x + 1,
1030
                   pw->login_button_y + pw->login_font->ascent + 2,
1031
                   pw->login_label, strlen(pw->login_label));
899
1032
900
      sw = string_width (pw->button_font, pw->login_label);
901
      x2 = pw->login_button_x + ((pw->login_button_width - sw) / 2);
902
      y2 = (pw->login_button_y +
903
            ((pw->login_button_height -
904
              (pw->button_font->ascent + pw->button_font->descent))
905
             / 2) +
906
            pw->button_font->ascent);
907
908
      XDrawString (si->dpy, si->passwd_dialog, gc1, x2, y2,
909
	           pw->login_label, strlen(pw->login_label));
910
911
      draw_shaded_rectangle (si->dpy, si->passwd_dialog,
912
                             pw->login_button_x, pw->login_button_y, 
913
                             pw->login_button_width, pw->login_button_height,
914
                             pw->shadow_width,
915
                             (pw->login_button_down_p
916
                              ? pw->shadow_bottom
917
                              : pw->shadow_top), 
918
                             (pw->login_button_down_p
919
                              ? pw->shadow_top
920
                              : pw->shadow_bottom));
921
    }
1033
    }
922
1034
1035
  /* the status mapping
1036
   */
1037
  /* THEME HACK: Text is cheaper than pixmaps even though they'd look
1038
     nicer being anti-aliased. */
1039
  if (pw->state) {
1040
    XSetForeground (si->dpy, gc1, pw->foreground);
1041
    switch (pw->state)
1042
      {
1043
        case pw_check:
1044
          pw->status_string = strdup("VERIFYING");
1045
          break;
1046
        case pw_ok:
1047
          pw->status_string = strdup("APPROVED");
1048
          break;
1049
        case pw_fail:
1050
          XSetForeground (si->dpy, gc1, pw->denied_foreground);
1051
          pw->status_string = strdup("DENIED");
1052
          break;
1053
        case pw_null:
1054
        case pw_cancel:
1055
          pw->status_string = strdup("CANCELLED");
1056
          break;
1057
        case pw_time:
1058
          pw->status_string = strdup("TIMED OUT");
1059
          break;
1060
        default:
1061
          break;
1062
      }
1063
    if (pw->status_string) {
1064
      XSetForeground (si->dpy, gc2, pw->background);
1065
      XSetFont (si->dpy, gc1, pw->status_font->fid);
1066
      XFillRectangle (si->dpy, si->passwd_dialog, gc2,
1067
  		      pw->frame_max_l + pw->internal_border,
1068
		      pw->frame_max_t + pw->internal_border,
1069
		      pw->width - pw->frame_max_l - 2 * pw->internal_border -
1070
                      pw->frame_max_r,
1071
		      pw->height - pw->frame_max_t - 2 * pw->internal_border -
1072
                      pw->frame_max_b);
1073
1074
      /* THEME HACK: Clip status message to not overdraw frame. */
1075
      rects[0].x = pw->frame_max_l;
1076
      rects[0].y =  pw->frame_max_t;
1077
      rects[0].width = pw->width - pw->frame_max_l - pw->frame_max_r;
1078
      rects[0].height = pw->height - pw->frame_max_t - pw->frame_max_b;
1079
      XSetClipRectangles (si->dpy, gc1, 0, 0, rects, 1, Unsorted);
1080
1081
      x = (pw->width - pw->frame_max_l - pw->frame_max_r) / 2 + pw->frame_max_l -
1082
          string_width (pw->status_font, pw->status_string) / 2;
1083
      y = (pw->height - pw->frame_max_t - pw->frame_max_b) / 2 + pw->frame_max_t +
1084
          (pw->status_font->ascent) / 2;
1085
      XDrawString (si->dpy, si->passwd_dialog, gc1,
1086
                      x, y,
1087
                      pw->status_string, strlen(pw->status_string));
1088
1089
      XSetClipMask (si->dpy, gc1, None);
1090
      free (pw->status_string);
1091
    }
1092
  }
1093
923
  XFreeGC (si->dpy, gc1);
1094
  XFreeGC (si->dpy, gc1);
924
  XFreeGC (si->dpy, gc2);
1095
  XFreeGC (si->dpy, gc2);
925
  XSync (si->dpy, False);
1096
  XSync (si->dpy, False);
Lines 986-993 Link Here
986
      XFreeGC (si->dpy, gc);
1157
      XFreeGC (si->dpy, gc);
987
    }
1158
    }
988
1159
989
  if (pw->heading_label) free (pw->heading_label);
990
  if (pw->body_label)    free (pw->body_label);
991
  if (pw->user_label)    free (pw->user_label);
1160
  if (pw->user_label)    free (pw->user_label);
992
  if (pw->passwd_label)  free (pw->passwd_label);
1161
  if (pw->passwd_label)  free (pw->passwd_label);
993
  if (pw->date_label)    free (pw->date_label);
1162
  if (pw->date_label)    free (pw->date_label);
Lines 995-1037 Link Here
995
  if (pw->user_string)   free (pw->user_string);
1164
  if (pw->user_string)   free (pw->user_string);
996
  if (pw->passwd_string) free (pw->passwd_string);
1165
  if (pw->passwd_string) free (pw->passwd_string);
997
1166
998
  if (pw->heading_font) XFreeFont (si->dpy, pw->heading_font);
999
  if (pw->body_font)    XFreeFont (si->dpy, pw->body_font);
1000
  if (pw->label_font)   XFreeFont (si->dpy, pw->label_font);
1167
  if (pw->label_font)   XFreeFont (si->dpy, pw->label_font);
1001
  if (pw->passwd_font)  XFreeFont (si->dpy, pw->passwd_font);
1168
  if (pw->passwd_font)  XFreeFont (si->dpy, pw->passwd_font);
1002
  if (pw->date_font)    XFreeFont (si->dpy, pw->date_font);
1169
  if (pw->date_font)    XFreeFont (si->dpy, pw->date_font);
1003
  if (pw->button_font)  XFreeFont (si->dpy, pw->button_font);
1170
  if (pw->login_font)   XFreeFont (si->dpy, pw->login_font);
1171
  if (pw->status_font)  XFreeFont (si->dpy, pw->status_font);
1004
1172
1005
  if (pw->foreground != black && pw->foreground != white)
1173
  if (pw->foreground != black && pw->foreground != white)
1006
    XFreeColors (si->dpy, cmap, &pw->foreground, 1, 0L);
1174
    XFreeColors (si->dpy, cmap, &pw->foreground, 1, 0L);
1007
  if (pw->background != black && pw->background != white)
1175
  if (pw->background != black && pw->background != white)
1008
    XFreeColors (si->dpy, cmap, &pw->background, 1, 0L);
1176
    XFreeColors (si->dpy, cmap, &pw->background, 1, 0L);
1009
  if (!(pw->button_foreground == black || pw->button_foreground == white))
1177
1010
    XFreeColors (si->dpy, cmap, &pw->button_foreground, 1, 0L);
1178
  if (pw->label_foreground != black && pw->label_foreground != white)
1011
  if (!(pw->button_background == black || pw->button_background == white))
1179
    XFreeColors (si->dpy, cmap, &pw->label_foreground, 1, 0L);
1012
    XFreeColors (si->dpy, cmap, &pw->button_background, 1, 0L);
1180
  if (pw->label_background != black && pw->label_background != white)
1181
    XFreeColors (si->dpy, cmap, &pw->label_background, 1, 0L);
1182
1013
  if (pw->passwd_foreground != black && pw->passwd_foreground != white)
1183
  if (pw->passwd_foreground != black && pw->passwd_foreground != white)
1014
    XFreeColors (si->dpy, cmap, &pw->passwd_foreground, 1, 0L);
1184
    XFreeColors (si->dpy, cmap, &pw->passwd_foreground, 1, 0L);
1015
  if (pw->passwd_background != black && pw->passwd_background != white)
1185
  if (pw->passwd_background != black && pw->passwd_background != white)
1016
    XFreeColors (si->dpy, cmap, &pw->passwd_background, 1, 0L);
1186
    XFreeColors (si->dpy, cmap, &pw->passwd_background, 1, 0L);
1187
1188
  if (pw->date_foreground != black && pw->date_foreground != white)
1189
    XFreeColors (si->dpy, cmap, &pw->date_foreground, 1, 0L);
1190
  if (pw->date_background != black && pw->date_background != white)
1191
    XFreeColors (si->dpy, cmap, &pw->date_background, 1, 0L);
1192
1193
  if (!(pw->login_foreground == black || pw->login_foreground == white))
1194
    XFreeColors (si->dpy, cmap, &pw->login_foreground, 1, 0L);
1195
  if (!(pw->login_background == black || pw->login_background == white))
1196
    XFreeColors (si->dpy, cmap, &pw->login_background, 1, 0L);
1197
1017
  if (pw->thermo_foreground != black && pw->thermo_foreground != white)
1198
  if (pw->thermo_foreground != black && pw->thermo_foreground != white)
1018
    XFreeColors (si->dpy, cmap, &pw->thermo_foreground, 1, 0L);
1199
    XFreeColors (si->dpy, cmap, &pw->thermo_foreground, 1, 0L);
1019
  if (pw->thermo_background != black && pw->thermo_background != white)
1200
  if (pw->thermo_background != black && pw->thermo_background != white)
1020
    XFreeColors (si->dpy, cmap, &pw->thermo_background, 1, 0L);
1201
    XFreeColors (si->dpy, cmap, &pw->thermo_background, 1, 0L);
1021
  if (pw->shadow_top != black && pw->shadow_top != white)
1202
1022
    XFreeColors (si->dpy, cmap, &pw->shadow_top, 1, 0L);
1203
  /* THEME HACK: A macro or array would tidy the following. */
1023
  if (pw->shadow_bottom != black && pw->shadow_bottom != white)
1204
  if (pw->logo.pixmap)
1024
    XFreeColors (si->dpy, cmap, &pw->shadow_bottom, 1, 0L);
1205
    XFreePixmap (si->dpy, pw->logo.pixmap);
1025
1206
  if (pw->logo.pixels)
1026
  if (pw->logo_pixmap)
1207
    {
1027
    XFreePixmap (si->dpy, pw->logo_pixmap);
1208
      if (pw->logo.npixels)
1028
  if (pw->logo_pixels)
1209
        XFreeColors (si->dpy, cmap, pw->logo.pixels, pw->logo.npixels, 0L);
1029
    {
1210
      free (pw->logo.pixels);
1030
      if (pw->logo_npixels)
1211
      pw->logo.pixels = 0;
1031
        XFreeColors (si->dpy, cmap, pw->logo_pixels, pw->logo_npixels, 0L);
1212
      pw->logo.npixels = 0;
1032
      free (pw->logo_pixels);
1213
    }
1033
      pw->logo_pixels = 0;
1214
  if (pw->frame_t.pixmap)
1034
      pw->logo_npixels = 0;
1215
    XFreePixmap (si->dpy, pw->frame_t.pixmap);
1216
  if (pw->frame_t.pixels)
1217
    {
1218
      if (pw->frame_t.npixels)
1219
        XFreeColors (si->dpy, cmap, pw->frame_t.pixels, pw->frame_t.npixels, 0L);
1220
      free (pw->frame_t.pixels);
1221
      pw->frame_t.pixels = 0;
1222
      pw->frame_t.npixels = 0;
1223
    }
1224
  if (pw->frame_b.pixmap)
1225
    XFreePixmap (si->dpy, pw->frame_b.pixmap);
1226
  if (pw->frame_b.pixels)
1227
    {
1228
      if (pw->frame_b.npixels)
1229
        XFreeColors (si->dpy, cmap, pw->frame_b.pixels, pw->frame_b.npixels, 0L);
1230
      free (pw->frame_b.pixels);
1231
      pw->frame_b.pixels = 0;
1232
      pw->frame_b.npixels = 0;
1233
    }
1234
  if (pw->frame_l.pixmap)
1235
    XFreePixmap (si->dpy, pw->frame_l.pixmap);
1236
  if (pw->frame_l.pixels)
1237
    {
1238
      if (pw->frame_l.npixels)
1239
        XFreeColors (si->dpy, cmap, pw->frame_l.pixels, pw->frame_l.npixels, 0L);
1240
      free (pw->frame_l.pixels);
1241
      pw->frame_l.pixels = 0;
1242
      pw->frame_l.npixels = 0;
1243
    }
1244
  if (pw->frame_r.pixmap)
1245
    XFreePixmap (si->dpy, pw->frame_r.pixmap);
1246
  if (pw->frame_r.pixels)
1247
    {
1248
      if (pw->frame_r.npixels)
1249
        XFreeColors (si->dpy, cmap, pw->frame_r.pixels, pw->frame_r.npixels, 0L);
1250
      free (pw->frame_r.pixels);
1251
      pw->frame_r.pixels = 0;
1252
      pw->frame_r.npixels = 0;
1253
    }
1254
  if (pw->frame_tl.pixmap)
1255
    XFreePixmap (si->dpy, pw->frame_tl.pixmap);
1256
  if (pw->frame_tl.pixels)
1257
    {
1258
      if (pw->frame_tl.npixels)
1259
        XFreeColors (si->dpy, cmap, pw->frame_tl.pixels, pw->frame_tl.npixels, 0L);
1260
      free (pw->frame_tl.pixels);
1261
      pw->frame_tl.pixels = 0;
1262
      pw->frame_tl.npixels = 0;
1263
    }
1264
  if (pw->frame_tr.pixmap)
1265
    XFreePixmap (si->dpy, pw->frame_tr.pixmap);
1266
  if (pw->frame_tr.pixels)
1267
    {
1268
      if (pw->frame_tr.npixels)
1269
        XFreeColors (si->dpy, cmap, pw->frame_tr.pixels, pw->frame_tr.npixels, 0L);
1270
      free (pw->frame_tr.pixels);
1271
      pw->frame_tr.pixels = 0;
1272
      pw->frame_tr.npixels = 0;
1273
    }
1274
  if (pw->frame_bl.pixmap)
1275
    XFreePixmap (si->dpy, pw->frame_bl.pixmap);
1276
  if (pw->frame_bl.pixels)
1277
    {
1278
      if (pw->frame_bl.npixels)
1279
        XFreeColors (si->dpy, cmap, pw->frame_bl.pixels, pw->frame_bl.npixels, 0L);
1280
      free (pw->frame_bl.pixels);
1281
      pw->frame_bl.pixels = 0;
1282
      pw->frame_bl.npixels = 0;
1283
    }
1284
  if (pw->frame_br.pixmap)
1285
    XFreePixmap (si->dpy, pw->frame_br.pixmap);
1286
  if (pw->frame_br.pixels)
1287
    {
1288
      if (pw->frame_br.npixels)
1289
        XFreeColors (si->dpy, cmap, pw->frame_br.pixels, pw->frame_br.npixels, 0L);
1290
      free (pw->frame_br.pixels);
1291
      pw->frame_br.pixels = 0;
1292
      pw->frame_br.npixels = 0;
1035
    }
1293
    }
1036
1294
1037
  if (pw->save_under)
1295
  if (pw->save_under)
Lines 1413-1418 Link Here
1413
	pw->state = pw_null;
1671
	pw->state = pw_null;
1414
      else
1672
      else
1415
        {
1673
        {
1674
          pw->state = pw_check;
1416
          update_passwd_window (si, "Checking...", pw->ratio);
1675
          update_passwd_window (si, "Checking...", pw->ratio);
1417
          XSync (si->dpy, False);
1676
          XSync (si->dpy, False);
1418
          if (passwd_valid_p (typed_passwd, p->verbose_p))
1677
          if (passwd_valid_p (typed_passwd, p->verbose_p))
(-)xscreensaver-4.22/utils/logo.c (+52 lines)
Lines 27-32 Link Here
27
   you didn't write; please don't alter its logo either.
27
   you didn't write; please don't alter its logo either.
28
 */
28
 */
29
29
30
/* THEME HACK: Reasonable enough, but the lock window is bloody ugly and
31
   I cannot stand to look at it anymore. Replacing the lock window does not
32
   prevent people knowing that it is xscreensaver running.
33
 */
34
30
#include "utils.h"
35
#include "utils.h"
31
#include "resources.h"
36
#include "resources.h"
32
#include "visual.h"
37
#include "visual.h"
Lines 242-244 Link Here
242
    }
247
    }
243
  return p;
248
  return p;
244
}
249
}
250
251
252
253
/* Returns a pixmap of the XPM data passed.
254
 */
255
Pixmap
256
xscreensaver_xpm  (Screen *screen, Visual *visual,
257
                   Drawable drawable, Colormap cmap,
258
                   unsigned long background_color,
259
                   unsigned long **pixels_ret, int *npixels_ret,
260
                   Pixmap *mask_ret,
261
                   const char * const *xpm_data)
262
{
263
  Display *dpy = DisplayOfScreen (screen);
264
  int depth = visual_depth (screen, visual);
265
  int iw, ih;
266
  XImage *image;
267
  Pixmap p = 0;
268
  unsigned char *mask = 0;
269
270
  image = parse_xpm_data (dpy, visual, cmap, depth, background_color,
271
                          xpm_data,
272
                          &iw, &ih, pixels_ret, npixels_ret,
273
                          (mask_ret ? &mask : 0));
274
275
  if (image)
276
    {
277
      XGCValues gcv;
278
      GC gc;
279
      p = XCreatePixmap (dpy, drawable, iw, ih, depth);
280
      gc = XCreateGC (dpy, p, 0, &gcv);
281
      XPutImage (dpy, p, gc, image, 0, 0, 0, 0, iw, ih);
282
      free (image->data);
283
      image->data = 0;
284
      XDestroyImage (image);
285
      XFreeGC (dpy, gc);
286
287
      if (mask_ret && mask)
288
        {
289
          *mask_ret = (Pixmap)
290
            XCreatePixmapFromBitmapData (dpy, drawable, (char *) mask,
291
                                         iw, ih, 1L, 0L, 1);
292
          free (mask);
293
        }
294
    }
295
  return p;
296
}
(-)xscreensaver-4.22/utils/resources.c (+46 lines)
Lines 129-134 Link Here
129
  return 0.0;
129
  return 0.0;
130
}
130
}
131
131
132
unsigned int
133
parse_pixel_resource (char *s, Display *dpy, Colormap cmap)
134
{
135
  XColor color;
136
  char *s2;
137
  Bool ok = True;
138
  if (!s) goto DEFAULT;
139
140
  for (s2 = s + strlen(s) - 1; s2 > s; s2--)
141
    if (*s2 == ' ' || *s2 == '\t')
142
      *s2 = 0;
143
    else
144
      break;
145
146
  if (! XParseColor (dpy, cmap, s, &color))
147
    {
148
      fprintf (stderr, "%s: can't parse color %s", progname, s);
149
      ok = False;
150
      goto DEFAULT;
151
    }
152
  if (! XAllocColor (dpy, cmap, &color))
153
    {
154
      fprintf (stderr, "%s: couldn't allocate color %s", progname, s);
155
      ok = False;
156
      goto DEFAULT;
157
    }
158
  return color.pixel;
159
 DEFAULT:
160
  {
161
    if (!ok)
162
      fprintf (stderr, ": using black.\n");
163
    color.flags = DoRed|DoGreen|DoBlue;
164
    color.red = color.green = color.blue = 0;
165
    if (XAllocColor (dpy, cmap, &color))
166
      return color.pixel;
167
    else
168
      {
169
        fprintf (stderr, "%s: couldn't allocate black either!\n", progname);
170
        /* We can't use BlackPixel/WhitePixel here, because we don't know
171
           what screen we're allocating on (only an issue when running inside
172
           the xscreensaver daemon: for hacks, DefaultScreen is fine.)
173
         */
174
        return 0;
175
      }
176
  }
177
}
132
178
133
unsigned int
179
unsigned int
134
get_pixel_resource (char *res_name, char *res_class,
180
get_pixel_resource (char *res_name, char *res_class,
(-)xscreensaver-4.22/utils/resources.h (+8 lines)
Lines 17-22 Link Here
17
extern Bool get_boolean_resource (char*,char*);
17
extern Bool get_boolean_resource (char*,char*);
18
extern int get_integer_resource (char*,char*);
18
extern int get_integer_resource (char*,char*);
19
extern double get_float_resource (char*,char*);
19
extern double get_float_resource (char*,char*);
20
extern unsigned int parse_pixel_resource (char*,Display*,Colormap);
20
extern unsigned int get_pixel_resource (char*,char*,Display*,Colormap);
21
extern unsigned int get_pixel_resource (char*,char*,Display*,Colormap);
21
extern unsigned int get_minutes_resource (char*,char*);
22
extern unsigned int get_minutes_resource (char*,char*);
22
extern unsigned int get_seconds_resource (char*,char*);
23
extern unsigned int get_seconds_resource (char*,char*);
Lines 29-33 Link Here
29
                   unsigned long **pixels_ret, int *npixels_ret,
30
                   unsigned long **pixels_ret, int *npixels_ret,
30
                   Pixmap *mask_ret,
31
                   Pixmap *mask_ret,
31
                   Bool big_p);
32
                   Bool big_p);
33
extern Pixmap
34
xscreensaver_xpm  (Screen *screen, Visual *visual,
35
                   Drawable drawable, Colormap cmap,
36
                   unsigned long background_color,
37
                   unsigned long **pixels_ret, int *npixels_ret,
38
                   Pixmap *mask_ret,
39
                   const char * const *xpm_data);
32
40
33
#endif /* __XSCREENSAVER_RESOURCES_H__ */
41
#endif /* __XSCREENSAVER_RESOURCES_H__ */

Return to bug 105555