ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rclock.C
(Generate patch)

Comparing rxvt-unicode/src/rclock.C (file contents):
Revision 1.1 by root, Mon May 10 00:36:04 2021 UTC vs.
Revision 1.2 by root, Mon May 10 00:36:58 2021 UTC

310#ifdef MAIL_SPOOL 310#ifdef MAIL_SPOOL
311 if (val == NULL) /* csh doesn't set $MAIL */ 311 if (val == NULL) /* csh doesn't set $MAIL */
312 { 312 {
313 const char * spool = MAIL_SPOOL; 313 const char * spool = MAIL_SPOOL;
314 char * user = getenv ("USER"); /* assume this works */ 314 char * user = getenv ("USER"); /* assume this works */
315 if (user != NULL) {
315 val = malloc (strlen (spool) + strlen (user) + 1); 316 val = malloc (strlen (spool) + strlen (user) + 1);
316 if (val == NULL) 317 if (val == NULL)
317 goto Malloc_Error; 318 goto Malloc_Error;
318 strcpy (val, spool); 319 strcpy (val, spool);
319 strcat (val, user); 320 strcat (val, user);
321 }
320 } 322 }
321#endif 323#endif
322 mail_file = val; 324 mail_file = val;
323 if( mail_file ) 325 if( mail_file )
324 CheckMaildir(); 326 CheckMaildir();
325#endif 327#endif
326
327 if ((display_name = getenv ("DISPLAY")) == NULL)
328 display_name = ":0";
329 328
330 /* parse the command line */ 329 /* parse the command line */
331 for (i = 1; i < argc; i += 2) 330 for (i = 1; i < argc; i += 2)
332 { 331 {
333 opt = argv [i]; 332 opt = argv [i];
422 421
423 /* open display */ 422 /* open display */
424 Xdisplay = XOpenDisplay (display_name); 423 Xdisplay = XOpenDisplay (display_name);
425 if (!Xdisplay) 424 if (!Xdisplay)
426 { 425 {
427 print_error ("can't open display %s", display_name); 426 print_error ("can't open display %s", display_name?display_name:
427 getenv("DISPLAY")?getenv("DISPLAY"):
428 "as no -d given and DISPLAY not set");
428 goto Abort; 429 goto Abort;
429 } 430 }
430 431
431 /* get display info */ 432 /* get display info */
432 Xfd = XConnectionNumber (Xdisplay); 433 Xfd = XConnectionNumber (Xdisplay);
703 *----------------------------------------------------------------------*/ 704 *----------------------------------------------------------------------*/
704static void 705static void
705Draw_Window (mywindow_t * W, int full_redraw) 706Draw_Window (mywindow_t * W, int full_redraw)
706{ 707{
707 /* pre-computed values for sin() x1000, to avoid using floats */ 708 /* pre-computed values for sin() x1000, to avoid using floats */
708 static const short Sin [60] = { 709 static const short Sin [720] = {
709 0, 710 0,
710 105, 208, 309, 407, 500, 588, 669, 711 9, 17, 26, 35, 44, 52, 61, 70, 78, 87, 96, 105,
711 743, 809, 866, 914, 951, 978, 995, 712 113, 122, 131, 139, 148, 156, 165, 174, 182, 191, 199, 208,
712 1000, 713 216, 225, 233, 242, 250, 259, 267, 276, 284, 292, 301, 309,
713 995, 978, 951, 914, 866, 809, 743, 714 317, 326, 334, 342, 350, 358, 367, 375, 383, 391, 399, 407,
714 669, 588, 500, 407, 309, 208, 105, 715 415, 423, 431, 438, 446, 454, 462, 469, 477, 485, 492, 500,
715 0, 716 508, 515, 522, 530, 537, 545, 552, 559, 566, 574, 581, 588,
716 -105, -208, -309, -407, -500, -588, -669, 717 595, 602, 609, 616, 623, 629, 636, 643, 649, 656, 663, 669,
717 -743, -809, -866, -914, -951, -978, -995, 718 676, 682, 688, 695, 701, 707, 713, 719, 725, 731, 737, 743,
718 -1000, 719 749, 755, 760, 766, 772, 777, 783, 788, 793, 799, 804, 809,
719 -995, -978, -951, -914, -866, -809, -743, 720 814, 819, 824, 829, 834, 839, 843, 848, 853, 857, 862, 866,
720 -669, -588, -500, -407, -309, -208, -105 721 870, 875, 879, 883, 887, 891, 895, 899, 903, 906, 910, 914,
722 917, 921, 924, 927, 930, 934, 937, 940, 943, 946, 948, 951,
723 954, 956, 959, 961, 964, 966, 968, 970, 972, 974, 976, 978,
724 980, 982, 983, 985, 986, 988, 989, 990, 991, 993, 994, 995,
725 995, 996, 997, 998, 998, 999, 999, 999, 1000, 1000, 1000, 1000,
726 1000, 1000, 1000, 999, 999, 999, 998, 998, 997, 996, 995, 995,
727 994, 993, 991, 990, 989, 988, 986, 985, 983, 982, 980, 978,
728 976, 974, 972, 970, 968, 966, 964, 961, 959, 956, 954, 951,
729 948, 946, 943, 940, 937, 934, 930, 927, 924, 921, 917, 914,
730 910, 906, 903, 899, 895, 891, 887, 883, 879, 875, 870, 866,
731 862, 857, 853, 848, 843, 839, 834, 829, 824, 819, 814, 809,
732 804, 799, 793, 788, 783, 777, 772, 766, 760, 755, 749, 743,
733 737, 731, 725, 719, 713, 707, 701, 695, 688, 682, 676, 669,
734 663, 656, 649, 643, 636, 629, 623, 616, 609, 602, 595, 588,
735 581, 574, 566, 559, 552, 545, 537, 530, 523, 515, 508, 500,
736 492, 485, 477, 469, 462, 454, 446, 438, 431, 423, 415, 407,
737 399, 391, 383, 375, 367, 358, 350, 342, 334, 326, 317, 309,
738 301, 292, 284, 276, 267, 259, 250, 242, 233, 225, 216, 208,
739 199, 191, 182, 174, 165, 156, 148, 139, 131, 122, 113, 105,
740 96, 87, 78, 70, 61, 52, 44, 35, 26, 17, 9, 0,
741 -9, -17, -26, -35, -44, -52, -61, -70, -78, -87, -96, -105,
742 -113, -122, -131, -139, -148, -156, -165, -174, -182, -191, -199, -208,
743 -216, -225, -233, -242, -250, -259, -267, -276, -284, -292, -301, -309,
744 -317, -326, -334, -342, -350, -358, -366, -375, -383, -391, -399, -407,
745 -415, -423, -431, -438, -446, -454, -462, -469, -477, -485, -492, -500,
746 -508, -515, -522, -530, -537, -545, -552, -559, -566, -574, -581, -588,
747 -595, -602, -609, -616, -623, -629, -636, -643, -649, -656, -663, -669,
748 -676, -682, -688, -695, -701, -707, -713, -719, -725, -731, -737, -743,
749 -749, -755, -760, -766, -772, -777, -783, -788, -793, -799, -804, -809,
750 -814, -819, -824, -829, -834, -839, -843, -848, -853, -857, -862, -866,
751 -870, -875, -879, -883, -887, -891, -895, -899, -903, -906, -910, -914,
752 -917, -921, -924, -927, -930, -934, -937, -940, -943, -946, -948, -951,
753 -954, -956, -959, -961, -964, -966, -968, -970, -972, -974, -976, -978,
754 -980, -982, -983, -985, -986, -988, -989, -990, -991, -993, -994, -995,
755 -995, -996, -997, -998, -998, -999, -999, -999, -1000, -1000, -1000, -1000,
756 -1000, -1000, -1000, -999, -999, -999, -998, -998, -997, -996, -995, -995,
757 -994, -993, -991, -990, -989, -988, -986, -985, -983, -982, -980, -978,
758 -976, -974, -972, -970, -968, -966, -964, -961, -959, -956, -954, -951,
759 -948, -946, -943, -940, -937, -934, -930, -927, -924, -921, -917, -914,
760 -910, -906, -903, -899, -895, -891, -887, -883, -879, -875, -870, -866,
761 -862, -857, -853, -848, -843, -839, -834, -829, -824, -819, -814, -809,
762 -804, -799, -793, -788, -783, -777, -772, -766, -760, -755, -749, -743,
763 -737, -731, -725, -719, -713, -707, -701, -695, -688, -682, -676, -669,
764 -663, -656, -649, -643, -636, -629, -623, -616, -609, -602, -595, -588,
765 -581, -574, -566, -559, -552, -545, -537, -530, -523, -515, -508, -500,
766 -492, -485, -477, -469, -462, -454, -446, -438, -431, -423, -415, -407,
767 -399, -391, -383, -375, -367, -358, -350, -342, -334, -326, -317, -309,
768 -301, -292, -284, -276, -267, -259, -250, -242, -233, -225, -216, -208,
769 -199, -191, -182, -174, -165, -156, -148, -139, -131, -122, -113, -105,
770 -96, -87, -78, -70, -61, -52, -44, -35, -26, -17, -9,
721 }; 771 };
722 772
723 static int savedDay = -1; 773 static int savedDay = -1;
724 774
725 time_t currentTime; 775 time_t currentTime;
903 */ 953 */
904 954
905 ctr_x = (W->width / 2); 955 ctr_x = (W->width / 2);
906 ctr_y = (W->height / 2); 956 ctr_y = (W->height / 2);
907 957
908#define XPOS(i,val) (ctr_x + (W->width * Sin[i%60] * (val) + 100000) / 200000) 958#define XPOS(i,val) (ctr_x + (W->width * Sin[i%720] * (val) + 100000) / 200000)
909#define YPOS(i,val) (ctr_y - (W->height * Sin[(i+15)%60] * (val) + 100000) / 200000) 959#define YPOS(i,val) (ctr_y - (W->height * Sin[(i+180)%720] * (val) + 100000) / 200000)
910 /* 960 /*
911 * how to draw the clock face 961 * how to draw the clock face
912 */ 962 */
913 963
914 /* calculate the positions of the hands */ 964 /* calculate the positions of the hands */
915 { 965 {
916 int angle = (tmval->tm_hour % 12) * 5 + (tmval->tm_min / 12); 966 int angle = (tmval->tm_hour % 12) * 60 + tmval->tm_min;
917 HandsNow.h_x = XPOS (angle, 60); 967 HandsNow.h_x = XPOS (angle, 60);
918 HandsNow.h_y = YPOS (angle, 60); 968 HandsNow.h_y = YPOS (angle, 60);
919 } 969 }
920 { 970 {
921 int angle = tmval->tm_min; 971 int angle = (tmval->tm_min * 12);
922 HandsNow.m_x = XPOS (angle, 80); 972 HandsNow.m_x = XPOS (angle, 80);
923 HandsNow.m_y = YPOS (angle, 80); 973 HandsNow.m_y = YPOS (angle, 80);
924 } 974 }
925 if (clockUpdate == 1) 975 if (clockUpdate == 1)
926 { 976 {
927 int angle = tmval->tm_sec; 977 int angle = (tmval->tm_sec * 12);
928 HandsNow.s_x = XPOS (angle, 85); 978 HandsNow.s_x = XPOS (angle, 85);
929 HandsNow.s_y = YPOS (angle, 85); 979 HandsNow.s_y = YPOS (angle, 85);
930 } 980 }
931 981
932 pHandsOld = ( 982 pHandsOld = (
953 * The code is enclosed in REMINDERS because it uses the same 1003 * The code is enclosed in REMINDERS because it uses the same
954 * font as the reminders code. 1004 * font as the reminders code.
955 * I believe this should be drawn always so it does not get 1005 * I believe this should be drawn always so it does not get
956 * "swept away" by the minute hand. 1006 * "swept away" by the minute hand.
957 */ 1007 */
958#ifdef REMINDERS && DATE_ON_CLOCK_FACE 1008#if defined(REMINDERS) && defined(DATE_ON_CLOCK_FACE)
959 if( show_date) 1009 if( show_date)
960 { 1010 {
961 char date[10]; 1011 char date[10];
962 currentTime = time (NULL) + adjustTime; /* get the current time */ 1012 currentTime = time (NULL) + adjustTime; /* get the current time */
963 tmval = localtime (&currentTime); 1013 tmval = localtime (&currentTime);
969 } 1019 }
970#endif 1020#endif
971 1021
972 if (full_redraw) 1022 if (full_redraw)
973 { 1023 {
974 int angle; 1024 int mintick;
975 /* 1025 /*
976 * draw clock face 1026 * draw clock face
977 */ 1027 */
978#ifdef SUBTICKS 1028#ifdef SUBTICKS
979 for (angle = 0; angle < 60; angle++) 1029 for (mintick = 0; mintick < 60; mintick++)
980 XDrawPoint (Xdisplay, W->win, X_gc, 1030 XDrawPoint (Xdisplay, W->win, X_gc,
981 XPOS (angle, 95), 1031 XPOS ((mintick * 12), 95),
982 YPOS (angle, 95)); 1032 YPOS ((mintick * 12), 95));
983#endif 1033#endif
984 for (angle = 0; angle < 60; angle += 5) 1034 for (mintick = 0; mintick < 60; mintick += 5)
985 XDrawLine (Xdisplay, W->win, X_gc, 1035 XDrawLine (Xdisplay, W->win, X_gc,
986 XPOS (angle, 90), 1036 XPOS ((mintick * 12), 90),
987 YPOS (angle, 90), 1037 YPOS ((mintick * 12), 90),
988 XPOS (angle, 100), 1038 XPOS ((mintick * 12), 100),
989 YPOS (angle, 100)); 1039 YPOS ((mintick * 12), 100));
990 } 1040 }
991 else if (memcmp (pHandsOld, &HandsNow, sizeof(hands_t))) 1041 else if (memcmp (pHandsOld, &HandsNow, sizeof(hands_t)))
992 { 1042 {
993 int i, j; 1043 int i, j;
994 /* 1044 /*
1256 if (prgm != NULL) 1306 if (prgm != NULL)
1257 { 1307 {
1258 int n = (sizeof(execPrgm) - strlen (execPrgm) - 2); 1308 int n = (sizeof(execPrgm) - strlen (execPrgm) - 2);
1259 if ((n > 0) && (n >= strlen (prgm))) 1309 if ((n > 0) && (n >= strlen (prgm)))
1260 { 1310 {
1261 /* for co-occurring programs */ 1311 /* for co-occurring programs */
1312 switch (execPrgm[strlen (execPrgm)-1])
1313 {
1314 case '&':
1315 case ';':
1316 break;
1317 default:
1262 strcat (execPrgm, ";"); 1318 strcat (execPrgm, ";");
1319 break;
1320 }
1263 strncat (execPrgm, prgm, n); 1321 strncat (execPrgm, prgm, n);
1264 } 1322 }
1265 } 1323 }
1266#endif /* NO_REMINDER_EXEC */ 1324#endif /* NO_REMINDER_EXEC */
1267 } 1325 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines