The menu timeout handling is now done centrally in the main program loop

This commit is contained in:
Klaus Schmidinger 2005-09-03 11:51:54 +02:00
parent 45a29e5b16
commit 7148cf452c
4 changed files with 11 additions and 23 deletions

View File

@ -3777,3 +3777,4 @@ Video Disk Recorder Revision History
the form "@plugin" even if that plugin doesn't have a main menu entry (using the form "@plugin" even if that plugin doesn't have a main menu entry (using
part of a patch by Hardy Flor, which originally implemented calling plugins from part of a patch by Hardy Flor, which originally implemented calling plugins from
SVDRP). SVDRP).
- The menu timeout handling is now done centrally in the main program loop.

17
menu.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: menu.c 1.358 2005/09/03 10:34:46 kls Exp $ * $Id: menu.c 1.359 2005/09/03 11:42:27 kls Exp $
*/ */
#include "menu.h" #include "menu.h"
@ -29,7 +29,6 @@
#include "transfer.h" #include "transfer.h"
#include "videodir.h" #include "videodir.h"
#define MENUTIMEOUT 120 // seconds
#define MAXWAIT4EPGINFO 3 // seconds #define MAXWAIT4EPGINFO 3 // seconds
#define MODETIMEOUT 3 // seconds #define MODETIMEOUT 3 // seconds
@ -1300,7 +1299,6 @@ cMenuCam::cMenuCam(cCiMenu *CiMenu)
Add(new cOsdItem(ciMenu->BottomText())); Add(new cOsdItem(ciMenu->BottomText()));
Display(); Display();
dsyslog("CAM: Menu - %s", ciMenu->TitleText()); dsyslog("CAM: Menu - %s", ciMenu->TitleText());
lastActivity = time(NULL);
} }
cMenuCam::~cMenuCam() cMenuCam::~cMenuCam()
@ -1329,10 +1327,6 @@ eOSState cMenuCam::ProcessKey(eKeys Key)
default: break; default: break;
} }
} }
if (Key != kNone)
lastActivity = time(NULL);
else if (time(NULL) - lastActivity > MENUTIMEOUT)
state = osEnd;
return state; return state;
} }
@ -1350,7 +1344,6 @@ cMenuCamEnquiry::cMenuCamEnquiry(cCiEnquiry *CiEnquiry)
SetTitle(ciEnquiry->Text() ? ciEnquiry->Text() : "CAM"); SetTitle(ciEnquiry->Text() ? ciEnquiry->Text() : "CAM");
Add(new cMenuEditNumItem("Input", input, Length, ciEnquiry->Blind())); Add(new cMenuEditNumItem("Input", input, Length, ciEnquiry->Blind()));
Display(); Display();
lastActivity = time(NULL);
} }
cMenuCamEnquiry::~cMenuCamEnquiry() cMenuCamEnquiry::~cMenuCamEnquiry()
@ -1379,10 +1372,6 @@ eOSState cMenuCamEnquiry::ProcessKey(eKeys Key)
default: break; default: break;
} }
} }
if (Key != kNone)
lastActivity = time(NULL);
else if (time(NULL) - lastActivity > MENUTIMEOUT)
state = osEnd;
return state; return state;
} }
@ -2505,7 +2494,6 @@ void cMenuMain::Set(void)
SetHelp(!replaying ? tr("Record") : NULL, tr("Audio"), replaying ? NULL : tr("Pause"), replaying ? tr("Button$Stop") : cReplayControl::LastReplayed() ? tr("Resume") : NULL); SetHelp(!replaying ? tr("Record") : NULL, tr("Audio"), replaying ? NULL : tr("Pause"), replaying ? tr("Button$Stop") : cReplayControl::LastReplayed() ? tr("Resume") : NULL);
Display(); Display();
lastActivity = time(NULL);
} }
eOSState cMenuMain::ProcessKey(eKeys Key) eOSState cMenuMain::ProcessKey(eKeys Key)
@ -2578,15 +2566,12 @@ eOSState cMenuMain::ProcessKey(eKeys Key)
} }
} }
if (Key != kNone) { if (Key != kNone) {
lastActivity = time(NULL);
if (Setup.OSDLanguage != osdLanguage) { if (Setup.OSDLanguage != osdLanguage) {
Set(); Set();
if (!HasSubMenu()) if (!HasSubMenu())
Display(); Display();
} }
} }
else if (time(NULL) - lastActivity > MENUTIMEOUT)
state = osEnd;
return state; return state;
} }

5
menu.h
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: menu.h 1.72 2005/09/03 10:33:17 kls Exp $ * $Id: menu.h 1.73 2005/09/03 11:41:41 kls Exp $
*/ */
#ifndef __MENU_H #ifndef __MENU_H
@ -55,7 +55,6 @@ public:
class cMenuMain : public cOsdMenu { class cMenuMain : public cOsdMenu {
private: private:
time_t lastActivity;
bool replaying; bool replaying;
static cOsdObject *pluginOsdObject; static cOsdObject *pluginOsdObject;
void Set(void); void Set(void);
@ -120,7 +119,6 @@ public:
class cMenuCam : public cOsdMenu { class cMenuCam : public cOsdMenu {
private: private:
cCiMenu *ciMenu; cCiMenu *ciMenu;
time_t lastActivity;
bool selected; bool selected;
eOSState Select(void); eOSState Select(void);
public: public:
@ -132,7 +130,6 @@ public:
class cMenuCamEnquiry : public cOsdMenu { class cMenuCamEnquiry : public cOsdMenu {
private: private:
cCiEnquiry *ciEnquiry; cCiEnquiry *ciEnquiry;
time_t lastActivity;
char *input; char *input;
bool replied; bool replied;
eOSState Reply(void); eOSState Reply(void);

11
vdr.c
View File

@ -22,7 +22,7 @@
* *
* The project's page is at http://www.cadsoft.de/vdr * The project's page is at http://www.cadsoft.de/vdr
* *
* $Id: vdr.c 1.212 2005/09/03 11:26:27 kls Exp $ * $Id: vdr.c 1.213 2005/09/03 11:50:28 kls Exp $
*/ */
#include <getopt.h> #include <getopt.h>
@ -66,6 +66,7 @@
#define LASTCAMMENUTIMEOUT 3 // seconds to run the main loop 'fast' after a CAM menu has been closed #define LASTCAMMENUTIMEOUT 3 // seconds to run the main loop 'fast' after a CAM menu has been closed
// in order to react on a possible new CAM menu as soon as possible // in order to react on a possible new CAM menu as soon as possible
#define DEVICEREADYTIMEOUT 30 // seconds to wait until all devices are ready #define DEVICEREADYTIMEOUT 30 // seconds to wait until all devices are ready
#define MENUTIMEOUT 120 // seconds of user inactivity after which an OSD display is closed
#define EXIT(v) { ExitCode = (v); goto Exit; } #define EXIT(v) { ExitCode = (v); goto Exit; }
@ -806,8 +807,12 @@ int main(int argc, char *argv[])
Interact = Menu ? Menu : cControl::Control(); // might have been closed in the mean time Interact = Menu ? Menu : cControl::Control(); // might have been closed in the mean time
if (Interact) { if (Interact) {
eOSState state = Interact->ProcessKey(key); eOSState state = Interact->ProcessKey(key);
if (state == osUnknown && ISMODELESSKEY(key) && cControl::Control() && Interact != cControl::Control()) if (state == osUnknown) {
state = cControl::Control()->ProcessKey(key); if (ISMODELESSKEY(key) && cControl::Control() && Interact != cControl::Control())
state = cControl::Control()->ProcessKey(key);
else if (time(NULL) - LastActivity > MENUTIMEOUT)
state = osEnd;
}
switch (state) { switch (state) {
case osPause: DELETENULL(Menu); case osPause: DELETENULL(Menu);
cControl::Shutdown(); // just in case cControl::Shutdown(); // just in case