1 | /* |
1 | /* |
2 | * Copyright 2001 by Marco d'Itri <md@linux.it> |
2 | * Copyright 2001 by Marco d'Itri <md@linux.it> |
3 | * |
3 | * Copyright 2000,2001,2002,2003,2004 |
4 | * Original version by Mike Baker, then maintained by pcg@goof.com. |
4 | * Marc Lehmann <pcg@goof.com>, |
|
|
5 | * and many others, see README |
|
|
6 | * |
|
|
7 | * Original version by Mike Baker. |
5 | * |
8 | * |
6 | * This program is free software; you can redistribute it and/or modify |
9 | * 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 |
10 | * 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 |
11 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. |
12 | * (at your option) any later version. |
… | |
… | |
377 | /* Just redraw everything without clearing (i.e. after an EXPOSE event) */ |
380 | /* Just redraw everything without clearing (i.e. after an EXPOSE event) */ |
378 | void |
381 | void |
379 | refresh (int miny, int maxy, int clear, int refresh_all) |
382 | refresh (int miny, int maxy, int clear, int refresh_all) |
380 | { |
383 | { |
381 | int lin; |
384 | int lin; |
382 | int offset = (listlen + 1) * font_height; |
385 | int offset = listlen * font_height + font_ascent + effect_y_offset; |
383 | unsigned long black_color = GetColor ("black"); |
386 | unsigned long black_color = GetColor ("black"); |
384 | |
387 | |
385 | miny -= win_y + font_height; |
388 | miny -= win_y + font_height; |
386 | maxy -= win_y - font_height; |
389 | maxy -= win_y - font_height; |
387 | |
390 | |
… | |
… | |
396 | offset -= font_height; |
399 | offset -= font_height; |
397 | |
400 | |
398 | if (offset < miny || offset > maxy) |
401 | if (offset < miny || offset > maxy) |
399 | continue; |
402 | continue; |
400 | |
403 | |
401 | if (opt_noflicker) |
|
|
402 | { |
|
|
403 | /* if this line is a different than it was, then it |
404 | /* if this line is a different than it was, then it |
404 | * needs displaying */ |
405 | * needs displaying */ |
405 | if (refresh_all || |
406 | if (refresh_all |
406 | display_line->len != line->len || |
407 | || display_line->len != line->len |
407 | strcmp(display_line->line, line->line)) |
408 | || memcmp (display_line->line, line->line, line->len)) |
408 | { |
409 | { |
409 | /* update the record of what has been displayed; |
410 | /* update the record of what has been displayed; |
410 | * first make sure the buffer is big enough */ |
411 | * first make sure the buffer is big enough */ |
411 | if (display_line->buffer_size <= line->len) |
412 | if (display_line->buffer_size <= line->len) |
412 | { |
413 | { |
413 | display_line->buffer_size = line->len + 1; |
414 | display_line->buffer_size = line->len + 1; |
414 | display_line->line = xrealloc(display_line->line, display_line->buffer_size); |
415 | display_line->line = xrealloc (display_line->line, display_line->buffer_size); |
415 | } |
416 | } |
416 | strcpy(display_line->line, line->line); |
417 | |
417 | display_line->len = line->len; |
418 | display_line->len = line->len; |
|
|
419 | memcpy (display_line->line, line->line, line->len); |
418 | |
420 | |
419 | if (clear) |
421 | if (clear) |
420 | XClearArea (disp, root, win_x, win_y + offset - font_height, |
422 | XClearArea (disp, root, win_x, win_y + offset - font_ascent, |
421 | width + effect_x_space, font_height + effect_y_space, False); |
423 | width + effect_x_space, font_height + effect_y_space, False); |
422 | |
424 | |
423 | if (opt_outline) |
425 | if (opt_outline) |
424 | { |
426 | { |
425 | int x, y; |
427 | int x, y; |
426 | XSetForeground (disp, WinGC, black_color); |
428 | XSetForeground (disp, WinGC, black_color); |
427 | |
429 | |
428 | for (x = -1; x < 2; x += 2) |
430 | for (x = -1; x < 2; x += 2) |
429 | for (y = -1; y < 2; y += 2) |
431 | for (y = -1; y < 2; y += 2) |
430 | XmbDrawString (disp, root, fontset, WinGC, |
432 | XmbDrawString (disp, root, fontset, WinGC, |
431 | win_x + effect_x_offset + x, |
433 | win_x + effect_x_offset + x, |
432 | win_y + effect_y_offset + y + offset - font_height + font_ascent, |
434 | win_y + y + offset, |
433 | line->line, line->len); |
435 | line->line, line->len); |
434 | } |
436 | } |
435 | else if (opt_shade) |
437 | else if (opt_shade) |
436 | { |
438 | { |
437 | XSetForeground (disp, WinGC, black_color); |
439 | XSetForeground (disp, WinGC, black_color); |
438 | XmbDrawString (disp, root, fontset, WinGC, |
440 | XmbDrawString (disp, root, fontset, WinGC, |
439 | win_x + effect_x_offset + SHADE_X, |
441 | win_x + effect_x_offset + SHADE_X, |
440 | win_y + effect_y_offset + offset + SHADE_Y - font_height + font_ascent, |
442 | win_y + offset + SHADE_Y, |
441 | line->line, line->len); |
443 | line->line, line->len); |
442 | } |
444 | } |
443 | |
445 | |
444 | XSetForeground (disp, WinGC, line->color); |
446 | XSetForeground (disp, WinGC, line->color); |
445 | XmbDrawString (disp, root, fontset, WinGC, |
447 | XmbDrawString (disp, root, fontset, WinGC, |
446 | win_x + effect_x_offset, |
448 | win_x + effect_x_offset, |
447 | win_y + effect_y_offset + offset - font_height + font_ascent, |
449 | win_y + offset, |
448 | line->line, line->len); |
450 | line->line, line->len); |
449 | } |
|
|
450 | } |
|
|
451 | else |
|
|
452 | { |
|
|
453 | XSetForeground (disp, WinGC, line->color); |
|
|
454 | XmbDrawString (disp, root, fontset, WinGC, |
|
|
455 | win_x + effect_x_offset, |
|
|
456 | win_y + effect_y_offset + offset - font_height + font_ascent, |
|
|
457 | line->line, line->len); |
|
|
458 | } |
451 | } |
459 | } |
452 | } |
460 | |
453 | |
461 | if (opt_frame) |
454 | if (opt_frame) |
462 | { |
455 | { |
… | |
… | |
1299 | case -1: |
1292 | case -1: |
1300 | return -1; |
1293 | return -1; |
1301 | case 0: |
1294 | case 0: |
1302 | break; |
1295 | break; |
1303 | default: |
1296 | default: |
1304 | printf("%d\n", pid); |
1297 | /*printf("%d\n", pid);*/ |
1305 | exit (0); |
1298 | exit (0); |
1306 | } |
1299 | } |
1307 | |
1300 | |
1308 | if (setsid () == -1) |
1301 | if (setsid () == -1) |
1309 | return -1; |
1302 | return -1; |