Skip to content

Commit

Permalink
FvwmForm: change Timeout resolution to 100ms, instead of 1s
Browse files Browse the repository at this point in the history
  • Loading branch information
phileimer authored and ThomasAdam committed Aug 17, 2020
1 parent 873f5c9 commit d48ca18
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 4 additions & 4 deletions modules/FvwmForm/FvwmForm.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -582,13 +582,13 @@ used while the pointer is over a text field.
See DEFAULTS.

.TP 4
.B *FvwmForm: Timeout \fIseconds\fP \fIcommand\fP \fI"text"\fP
Set up FvwmForm to time out after the amount of \fIseconds\fP
.B *FvwmForm: Timeout \fItenth_of_seconds\fP \fIcommand\fP \fI"text"\fP
Set up FvwmForm to time out after the amount of \fItenth of seconds\fP
specified. When the timer hits zero, \fIcommand\fP executes. The
\fItext\fP field is displayed much like a \fIText\fP
field, except that a '%%' in the line is replaced automatically by
the amount of time left on the timer. The value gets updated every
second as the timer counts down.
tenth of second as the timer counts down.
There can only be one timeout field per form.

.SH EXAMPLES
Expand Down Expand Up @@ -623,7 +623,7 @@ DestroyModuleConfig FvwmForm-QuitVerify: *
*FvwmForm-QuitVerify: Command Restart
*FvwmForm-QuitVerify: Button quit "Cancel" ^[
*FvwmForm-QuitVerify: Command Nop
*FvwmForm-QuitVerify: Timeout 20 Quit "Automatic logout will occur in %% seconds."
*FvwmForm-QuitVerify: Timeout 200 Quit "Automatic logout will occur in %% tenth of seconds."
.EE

.SH EXAMPLE 2 - Remote Login
Expand Down
9 changes: 6 additions & 3 deletions modules/FvwmForm/FvwmForm.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ Bool Swallowed = False;
int colorset = -1;
int itemcolorset = 0;

/* global not exported */
const struct itimerval itv_100ms = { {0L, 100000L}, {0L, 100000L} };

/* prototypes */
static void RedrawSeparator(Item *item);
static void AssignDrawTable(Item *);
Expand Down Expand Up @@ -135,7 +138,7 @@ static void SetupTimer(void)
#endif
#endif

alarm(1);
setitimer(ITIMER_REAL, &itv_100ms, NULL);
}

/* copy a string until '"', or '\n', or '\0' */
Expand Down Expand Up @@ -878,7 +881,7 @@ static void ct_Title(char *cp)
}
static void ct_Timeout(char *cp)
{
/* syntax: *FFTimeout seconds <Command> "Text" */
/* syntax: *FFTimeout tenth_of_seconds <Command> "Text" */
char *tmpcp, *tmpbuf;

if (timer != NULL) {
Expand Down Expand Up @@ -2674,7 +2677,7 @@ TimerHandler(int sig)
}
else {
RedrawTimeout(timer);
alarm(1);
setitimer(ITIMER_REAL, &itv_100ms, NULL);
}

SIGNAL_RETURN;
Expand Down

0 comments on commit d48ca18

Please sign in to comment.