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.6 by root, Sat Jul 17 00:10:15 2021 UTC vs.
Revision 1.12 by root, Sun Nov 14 18:46:50 2021 UTC

39#include <X11/Xlib.h> 39#include <X11/Xlib.h>
40#include <X11/Xutil.h> 40#include <X11/Xutil.h>
41 41
42#include "ecb.h" 42#include "ecb.h"
43 43
44#include "version.h"
45
44#define APL_CLASS "Clock" 46#define APL_CLASS "Clock"
45#define APL_NAME "rclock" 47#define APL_NAME "rclock"
46#define MSG_CLASS "Appointment" 48#define MSG_CLASS "Appointment"
47#define MSG_NAME "Appointment" 49#define MSG_NAME "Appointment"
48#define CONFIG_FILE ".rclock" 50#define CONFIG_FILE ".rclock"
49 51
50#ifndef EXIT_SUCCESS /* missed from <stdlib.h> ? */ 52#ifndef EXIT_SUCCESS /* missed from <stdlib.h> ? */
51# define EXIT_SUCCESS 0 53# define EXIT_SUCCESS 0
52# define EXIT_FAILURE 1 54# define EXIT_FAILURE 1
53#endif 55#endif
54
55#define VERSION "TODO: fetch from urxvt somehow"
56 56
57/*--------------------------------*-C-*---------------------------------* 57/*--------------------------------*-C-*---------------------------------*
58 * Compile-time configuration. 58 * Compile-time configuration.
59 *----------------------------------------------------------------------* 59 *----------------------------------------------------------------------*
60 * Copyright (C) 1997 1998 mj olesen <olesen@me.QueensU.CA> 60 * Copyright (C) 1997 1998 mj olesen <olesen@me.QueensU.CA>
184static int32_t 184static int32_t
185Sin (int32_t arg) 185Sin (int32_t arg)
186{ 186{
187 int32_t x = (arg - 360) * 16384 / 360; 187 int32_t x = (arg - 360) * 16384 / 360;
188 188
189 int c, x2, y; 189 int c, y;
190 static const int qN = 13, qA = 12, B = 19900, C = 3516; 190 static const int qN = 13, qA = 12, B = 19900, C = 3516;
191 191
192 c = x << (30 - qN); // Semi-circle info into carry. 192 c = x << (30 - qN); // Semi-circle info into carry.
193 x -= 1 << qN; // sine -> cosine calc 193 x -= 1 << qN; // sine -> cosine calc
194 194
304 0, 0, /* base size */ 304 0, 0, /* base size */
305 NorthWestGravity /* gravity */ 305 NorthWestGravity /* gravity */
306}; 306};
307 307
308/* subroutine declarations */ 308/* subroutine declarations */
309static void geometry2sizehint (mywindow_t * /* win */ , 309static void geometry2sizehint (mywindow_t *win, const char *geom);
310 const char * /* geom */ );
311static void Create_Windows (int /* argc */ , 310static void Create_Windows (int argc, char *argv[]);
312 char * /* argv */ []);
313static void getXevent (); 311static void getXevent ();
314static void print_error (const char * /* fmt */ , ...); 312static void print_error (const char *fmt, ...);
315 313
316static void Draw_Window (mywindow_t * /* this_win */ , 314static void Draw_Window (mywindow_t *this_win, int full_redraw);
317 int /* full_redraw */ );
318static void Reminder (); 315static void Reminder ();
319static void Next_Reminder (int /* update_only */ ); 316static void Next_Reminder (int update_only);
320 317
321/* Arguments for Next_Reminder() */ 318/* Arguments for Next_Reminder() */
322#define REPLACE 0 319#define REPLACE 0
323#define UPDATE 1 320#define UPDATE 1
324 321
359# endif 356# endif
360#endif 357#endif
361 {"#geom", "icon window geometry"} 358 {"#geom", "icon window geometry"}
362 }; 359 };
363 360
364 fprintf (stderr, "\nUsage v" VERSION ":\n " APL_NAME " [options]\n\n" "where options include:\n"); 361 fprintf (stderr, "\nUsage for urclock version " VERSION "\n\n urclock [options]\n\n" "where options include:\n");
365 362
366 for (i = 0; i < (int)optList_size (); i++) 363 for (i = 0; i < (int)optList_size (); i++)
367 fprintf (stderr, " %-29s%s\n", optList[i].opt, optList[i].desc); 364 fprintf (stderr, " %-29s%s\n", optList[i].opt, optList[i].desc);
368} 365}
369 366
636 633
637/* 634/*
638 * translate geometry string to appropriate sizehint 635 * translate geometry string to appropriate sizehint
639 */ 636 */
640static void 637static void
641geometry2sizehint (mywindow_t * win, const char *geom) 638geometry2sizehint (mywindow_t *win, const char *geom)
642{ 639{
643 int x, y, flags; 640 int x, y, flags;
644 unsigned int width, height; 641 unsigned int width, height;
645 642
646 /* copy in values */ 643 /* copy in values */
770} 767}
771 768
772static time_t 769static time_t
773mk_time (struct tm *tmval) 770mk_time (struct tm *tmval)
774{ 771{
775 return (tmval->tm_min + 60 * (tmval->tm_hour + 24 * (tmval->tm_mday + 31 * ((tmval->tm_mon + 1) + 12 * tmval->tm_year)))); 772 return (tmval->tm_min
773 + 60 * (tmval->tm_hour
774 + 24 * (tmval->tm_mday
775 + 31 * ((tmval->tm_mon + 1)
776 + 12 * tmval->tm_year))));
776} 777}
777 778
778#ifdef MAIL 779#ifdef MAIL
779static int 780static int
780MailAvailable () 781MailAvailable ()
811 * Redraw the whole window after an exposure or size change. 812 * Redraw the whole window after an exposure or size change.
812 * After a timeout, only redraw the hands. 813 * After a timeout, only redraw the hands.
813 * Provide reminder if needed. 814 * Provide reminder if needed.
814 *----------------------------------------------------------------------*/ 815 *----------------------------------------------------------------------*/
815static void 816static void
816Draw_Window (mywindow_t * W, int full_redraw) 817Draw_Window (mywindow_t *W, int full_redraw)
817{ 818{
818 static int savedDay = -1; 819 static int savedDay = -1;
819 820
820 time_t currentTime; 821 time_t currentTime;
821 struct tm *tmval; 822 struct tm *tmval;
836#ifdef ICONWIN 837#ifdef ICONWIN
837 static hands_t HandsOld_icon = { -1 }; 838 static hands_t HandsOld_icon = { -1 };
838#endif 839#endif
839#ifdef REMINDERS 840#ifdef REMINDERS
840 static int lastUpdateTime = -10; 841 static int lastUpdateTime = -10;
842#endif
843#ifdef DATE_ON_CLOCK_FACE
844 static char clockdate[10];
841#endif 845#endif
842 846
843#ifdef MAIL 847#ifdef MAIL
844 static time_t mailTime = 0; 848 static time_t mailTime = 0;
845 static int MailUp = 0, MailUp_rvideo = 0; 849 static int MailUp = 0, MailUp_rvideo = 0;
907 911
908 savedDay = tmval->tm_yday; 912 savedDay = tmval->tm_yday;
909 strftime (str, sizeof (str), "%a %h %d", tmval); 913 strftime (str, sizeof (str), "%a %h %d", tmval);
910 XStoreName (Xdisplay, Clock.win, str); 914 XStoreName (Xdisplay, Clock.win, str);
911 XSetIconName (Xdisplay, Clock.win, str); 915 XSetIconName (Xdisplay, Clock.win, str);
912 }
913 916
917#if defined(REMINDERS) && defined(DATE_ON_CLOCK_FACE)
918 if (show_date)
919 {
920 strftime (clockdate, sizeof (clockdate), "%d", tmval);
921 full_redraw = 1;
922 }
923 }
924
925#endif
914 if (full_redraw) 926 if (full_redraw)
915 XClearWindow (Xdisplay, W->win); 927 XClearWindow (Xdisplay, W->win);
916 928
917#ifdef REMINDERS 929#ifdef REMINDERS
918 /* for a message window, just re-draw the message */ 930 /* for a message window, just re-draw the message */
939 Xgc, 951 Xgc,
940 (Msg.width - 952 (Msg.width -
941 XTextWidth (Xfont, beg, (end - beg))) / 2, 10 + Xfont->ascent + FontHeight () * lines, beg, (end - beg)); 953 XTextWidth (Xfont, beg, (end - beg))) / 2, 10 + Xfont->ascent + FontHeight () * lines, beg, (end - beg));
942 } 954 }
943 955
944 XDrawString (Xdisplay, msgButton.Dismiss, Xrvgc, (msgButton.width - XTextWidth (Xfont, "Done", 4)) / 2, Xfont->ascent + 2, "Done", 4); 956 XDrawString (Xdisplay, msgButton.Dismiss, Xrvgc, (msgButton.width - XTextWidth (Xfont, "Done" , 4)) / 2, Xfont->ascent + 2, "Done" , 4);
945 957
946 XDrawString (Xdisplay, msgButton.Defer, Xrvgc, (msgButton.width - XTextWidth (Xfont, "Defer", 5)) / 2, Xfont->ascent + 2, "Defer", 5); 958 XDrawString (Xdisplay, msgButton.Defer , Xrvgc, (msgButton.width - XTextWidth (Xfont, "Defer", 5)) / 2, Xfont->ascent + 2, "Defer", 5);
947 959
948# ifndef NO_REMINDER_EXEC 960# ifndef NO_REMINDER_EXEC
949 XDrawString (Xdisplay, msgButton.Start, Xrvgc, (msgButton.width - XTextWidth (Xfont, "Start", 5)) / 2, Xfont->ascent + 2, "Start", 5); 961 XDrawString (Xdisplay, msgButton.Start , Xrvgc, (msgButton.width - XTextWidth (Xfont, "Start", 5)) / 2, Xfont->ascent + 2, "Start", 5);
950 962
951 if (strlen (execPrgm) > 1) 963 if (strlen (execPrgm) > 1)
952 XMapWindow (Xdisplay, msgButton.Start); 964 XMapWindow (Xdisplay, msgButton.Start);
953 else 965 else
954 XUnmapWindow (Xdisplay, msgButton.Start); 966 XUnmapWindow (Xdisplay, msgButton.Start);
1030 1042
1031 /* 1043 /*
1032 * Draw the date in the lower half of the clock window. 1044 * Draw the date in the lower half of the clock window.
1033 * The code is enclosed in REMINDERS because it uses the same 1045 * The code is enclosed in REMINDERS because it uses the same
1034 * font as the reminders code. 1046 * font as the reminders code.
1035 * I believe this should be drawn always so it does not get
1036 * "swept away" by the minute hand.
1037 */ 1047 */
1038#if defined(REMINDERS) && defined(DATE_ON_CLOCK_FACE) 1048#if defined(REMINDERS) && defined(DATE_ON_CLOCK_FACE)
1039 if (show_date) 1049 if (show_date)
1040 {
1041 char date[10];
1042
1043 currentTime = time (NULL) + adjustTime; /* get the current time */
1044 tmval = localtime (&currentTime);
1045 strftime (date, sizeof (date), "%d", tmval);
1046 XDrawString (Xdisplay, W->win, X_gc, 1050 XDrawString (Xdisplay, W->win, X_gc,
1047 ctr_x - XTextWidth (Xfont, date, strlen (date)) / 2, 1051 ctr_x - XTextWidth (Xfont, clockdate, strlen (clockdate)) / 2,
1048 ctr_y + FontHeight () + (ctr_y - FontHeight ()) / 2, date, strlen (date)); 1052 ctr_y + FontHeight () + (ctr_y - FontHeight ()) / 2, clockdate, strlen (clockdate));
1049 }
1050#endif 1053#endif
1051 1054
1052 if (full_redraw) 1055 if (full_redraw)
1053 { 1056 {
1054 int mintick; 1057 int mintick;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines