Replace newwin by mvwin & wresize and remove nanosleep (halfdelay() do all)

reverse-branch
Martin Duquesnoy 17 years ago
parent feaaec0f1a
commit abcff61de7
  1. 24
      ttyclock.c
  2. 2
      ttyclock.h

@ -239,24 +239,20 @@ clock_move(int x, int y, int w, int h)
wborder(ttyclock->framewin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); wborder(ttyclock->framewin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
wbkgdset(ttyclock->datewin, COLOR_PAIR(0)); wbkgdset(ttyclock->datewin, COLOR_PAIR(0));
wborder(ttyclock->datewin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); wborder(ttyclock->datewin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
/* Clean windows */
werase(ttyclock->framewin); werase(ttyclock->framewin);
werase(ttyclock->datewin); werase(ttyclock->datewin);
wrefresh(ttyclock->framewin); wrefresh(ttyclock->framewin);
wrefresh(ttyclock->datewin); wrefresh(ttyclock->datewin);
/* Frame win move */
mvwin(ttyclock->framewin, (ttyclock->geo.x = x), (ttyclock->geo.y = y));
wresize(ttyclock->framewin, (ttyclock->geo.h = h), (ttyclock->geo.w = w));
/* Make new property */ /* Date win move */
ttyclock->framewin = newwin((ttyclock->geo.h = h), mvwin(ttyclock->datewin,
(ttyclock->geo.w = w), ttyclock->geo.x + ttyclock->geo.h - 1,
(ttyclock->geo.x = x), ttyclock->geo.y + (ttyclock->geo.w / 2) - (strlen(ttyclock->date.datestr) / 2) - 1);
(ttyclock->geo.y = y)); wresize(ttyclock->datewin, DATEWINH, strlen(ttyclock->date.datestr) + 2);
ttyclock->datewin = newwin(DATEWINH,
strlen(ttyclock->date.datestr) + 2,
ttyclock->geo.x + ttyclock->geo.h - 1,
ttyclock->geo.y + (ttyclock->geo.w / 2) - (strlen(ttyclock->date.datestr) / 2) - 1);
box(ttyclock->framewin, 0, 0); box(ttyclock->framewin, 0, 0);
box(ttyclock->datewin, 0, 0); box(ttyclock->datewin, 0, 0);
@ -264,7 +260,6 @@ clock_move(int x, int y, int w, int h)
wrefresh(ttyclock->datewin); wrefresh(ttyclock->datewin);
wrefresh(ttyclock->framewin); wrefresh(ttyclock->framewin);
return; return;
} }
@ -301,6 +296,7 @@ set_second(void)
(ttyclock->geo.w = ((ttyclock->option.second = !ttyclock->option.second)) ? SECFRAMEW : NORMFRAMEW), (ttyclock->geo.w = ((ttyclock->option.second = !ttyclock->option.second)) ? SECFRAMEW : NORMFRAMEW),
ttyclock->geo.h); ttyclock->geo.h);
set_center(ttyclock->option.center); set_center(ttyclock->option.center);
return; return;
@ -400,7 +396,6 @@ int
main(int argc, char **argv) main(int argc, char **argv)
{ {
int c; int c;
struct timespec sleeptime = {0, UPDATETIME};
struct option long_options[] = struct option long_options[] =
{ {
@ -461,7 +456,6 @@ main(int argc, char **argv)
update_hour(); update_hour();
draw_clock(); draw_clock();
key_event(); key_event();
nanosleep(&sleeptime, NULL);
} }
free(ttyclock); free(ttyclock);

@ -44,7 +44,7 @@
/* Macro */ /* Macro */
#define NORMFRAMEW 35 #define NORMFRAMEW 35
#define SECFRAMEW 54 #define SECFRAMEW 54
#define UPDATETIME 10000000 #define UPDATETIME 25000000
#define DATEWINH 3 #define DATEWINH 3
#define AMSIGN " [AM]" #define AMSIGN " [AM]"
#define PMSIGN " [PM]" #define PMSIGN " [PM]"

Loading…
Cancel
Save