patch: Consistent menu behaviour

Message ID 200510232009.24296.rollercoaster@reel-multimedia.com
State New
Headers

Commit Message

rollercoaster@reel-multimedia.com Oct. 23, 2005, 6:09 p.m. UTC
  as said a few days ago, i modified the posted patch to apply and work cleanly 
on vanilla-vdr.

this patch does two things: (sorry Klaus ;) )

1. makes the "menu" button close a plugin if it is open (instead of opening 
the main menu)
2. makes the channelinfo remain visible forever if the user requested it (with 
the OK button). this option can (now) be turned off via Setup->OSD->Timeout 
requested channel info


have fun,
Thiemo
  

Comments

Luca Olivetti Oct. 23, 2005, 8:36 p.m. UTC | #1
En/na rollercoaster@reel-multimedia.com ha escrit:
> as said a few days ago, i modified the posted patch to apply and work cleanly 
> on vanilla-vdr.
> 
> this patch does two things: (sorry Klaus ;) )
> 
> 1. makes the "menu" button close a plugin if it is open (instead of opening 
> the main menu)

Wouldn't it be simpler to just set isMenu for cOsdObject created as the
plugin main menu entry?
This would also address the "back" key (it seems that your patch doesn't
modify that, so in a plugin it'd still work differently depending if it
uses cOsdObject or cOsdMenu).

Bye
  

Patch

diff -Nur vdr-1.3.34-vanilla/config.c vdr-1.3.34/config.c
--- vdr-1.3.34-vanilla/config.c	2005-09-09 17:08:59.000000000 +0200
+++ vdr-1.3.34/config.c	2005-10-23 13:35:07.000000000 +0200
@@ -250,6 +250,7 @@ 
   strcpy(OSDTheme, "default");
   PrimaryDVB = 1;
   ShowInfoOnChSwitch = 1;
+  TimeoutRequestedChInfo = 0;
   MenuScrollPage = 1;
   MenuScrollWrap = 0;
   MarkInstantRecord = 1;
@@ -408,6 +409,7 @@ 
   else if (!strcasecmp(Name, "OSDTheme"))            strn0cpy(OSDTheme, Value, MaxThemeName);
   else if (!strcasecmp(Name, "PrimaryDVB"))          PrimaryDVB         = atoi(Value);
   else if (!strcasecmp(Name, "ShowInfoOnChSwitch"))  ShowInfoOnChSwitch = atoi(Value);
+  else if (!strcasecmp(Name, "TimeoutRequestedChInfo"))  TimeoutRequestedChInfo = atoi(Value);
   else if (!strcasecmp(Name, "MenuScrollPage"))      MenuScrollPage     = atoi(Value);
   else if (!strcasecmp(Name, "MenuScrollWrap"))      MenuScrollWrap     = atoi(Value);
   else if (!strcasecmp(Name, "MarkInstantRecord"))   MarkInstantRecord  = atoi(Value);
@@ -473,6 +475,7 @@ 
   Store("OSDTheme",           OSDTheme);
   Store("PrimaryDVB",         PrimaryDVB);
   Store("ShowInfoOnChSwitch", ShowInfoOnChSwitch);
+  Store("TimeoutRequestedChInfo", TimeoutRequestedChInfo);
   Store("MenuScrollPage",     MenuScrollPage);
   Store("MenuScrollWrap",     MenuScrollWrap);
   Store("MarkInstantRecord",  MarkInstantRecord);
diff -Nur vdr-1.3.34-vanilla/config.h vdr-1.3.34/config.h
--- vdr-1.3.34-vanilla/config.h	2005-10-01 12:41:33.000000000 +0200
+++ vdr-1.3.34/config.h	2005-10-23 13:35:07.000000000 +0200
@@ -209,6 +209,7 @@ 
   char OSDTheme[MaxThemeName];
   int PrimaryDVB;
   int ShowInfoOnChSwitch;
+  int TimeoutRequestedChInfo;
   int MenuScrollPage;
   int MenuScrollWrap;
   int MarkInstantRecord;
diff -Nur vdr-1.3.34-vanilla/i18n.c vdr-1.3.34/i18n.c
--- vdr-1.3.34-vanilla/i18n.c	2005-10-03 14:27:15.000000000 +0200
+++ vdr-1.3.34/i18n.c	2005-10-23 13:35:07.000000000 +0200
@@ -2989,6 +2989,27 @@ 
     "Lehekülje kerimine",
     "Scroll sidevis",
   },
+  { "Setup.OSD$Timeout requested channel info",
+    "Angeforderte Kanalinfo schließen",
+    "", // TODO
+    "", // TODO
+    "", // TODO
+    "", // TODO
+    "", // TODO
+    "", // TODO
+    "", // TODO
+    "", // TODO
+    "", // TODO
+    "", // TODO
+    "", // TODO
+    "", // TODO
+    "", // TODO
+    "", // TODO
+    "", // TODO
+    "", // TODO
+    "", // TODO
+    "", // TODO
+  },
   { "Setup.OSD$Scroll wraps",
     "Rundum scrollen",
     "Iz konca skoèi na zaèetek",
diff -Nur vdr-1.3.34-vanilla/menu.c vdr-1.3.34/menu.c
--- vdr-1.3.34-vanilla/menu.c	2005-10-03 14:53:51.000000000 +0200
+++ vdr-1.3.34/menu.c	2005-10-23 13:35:07.000000000 +0200
@@ -1877,6 +1877,7 @@ 
   Add(new cMenuEditBoolItem(tr("Setup.OSD$Channel info position"),  &data.ChannelInfoPos, tr("bottom"), tr("top")));
   Add(new cMenuEditIntItem( tr("Setup.OSD$Channel info time (s)"),  &data.ChannelInfoTime, 1, 60));
   Add(new cMenuEditBoolItem(tr("Setup.OSD$Info on channel switch"), &data.ShowInfoOnChSwitch));
+  Add(new cMenuEditBoolItem(tr("Setup.OSD$Timeout requested channel info"), &data.TimeoutRequestedChInfo));
   Add(new cMenuEditBoolItem(tr("Setup.OSD$Scroll pages"),           &data.MenuScrollPage));
   Add(new cMenuEditBoolItem(tr("Setup.OSD$Scroll wraps"),           &data.MenuScrollWrap));
   Add(new cMenuEditBoolItem(tr("Setup.OSD$Sort timers"),            &data.SortTimers));
@@ -2704,13 +2705,14 @@ 
 
 #define DIRECTCHANNELTIMEOUT 1000 //ms
 
-cDisplayChannel::cDisplayChannel(int Number, bool Switched)
+cDisplayChannel::cDisplayChannel(int Number, bool Switched, bool Timeout )
 :cOsdObject(true)
 {
   group = -1;
   withInfo = !Switched || Setup.ShowInfoOnChSwitch;
   displayChannel = Skins.Current()->DisplayChannel(withInfo);
   number = 0;
+  timeout = Timeout;
   channel = Channels.GetByNumber(Number);
   lastPresent = lastFollowing = NULL;
   if (channel) {
@@ -2721,11 +2723,12 @@ 
   lastTime.Set();
 }
 
-cDisplayChannel::cDisplayChannel(eKeys FirstKey)
+cDisplayChannel::cDisplayChannel(eKeys FirstKey, bool Timeout)
 :cOsdObject(true)
 {
   group = -1;
   number = 0;
+  timeout = Timeout;
   lastPresent = lastFollowing = NULL;
   lastTime.Set();
   withInfo = Setup.ShowInfoOnChSwitch;
@@ -2861,7 +2864,7 @@ 
          Refresh();
          break;
     case kNone:
-         if (number && lastTime.Elapsed() > DIRECTCHANNELTIMEOUT) {
+         if (number && lastTime.Elapsed() > DIRECTCHANNELTIMEOUT && timeout) {
             if (Channels.GetByNumber(number))
                Channels.SwitchTo(number);
             else {
@@ -2894,7 +2897,7 @@ 
                      return osEnd;
                      }
     };
-  if (lastTime.Elapsed() < (uint64)(Setup.ChannelInfoTime * 1000)) {
+  if (lastTime.Elapsed() < (uint64)(Setup.ChannelInfoTime * 1000) || !timeout) {
      if (!number && group < 0 && channel && channel->Number() != cDevice::CurrentChannel())
         Refresh(); // makes sure a channel switch through the SVDRP CHAN command is displayed
      DisplayInfo();
diff -Nur vdr-1.3.34-vanilla/menu.h vdr-1.3.34/menu.h
--- vdr-1.3.34-vanilla/menu.h	2005-10-03 12:39:08.000000000 +0200
+++ vdr-1.3.34/menu.h	2005-10-23 13:35:07.000000000 +0200
@@ -71,6 +71,7 @@ 
   bool withInfo;
   cTimeMs lastTime;
   int number;
+  bool timeout;
   cChannel *channel;
   const cEvent *lastPresent;
   const cEvent *lastFollowing;
@@ -78,8 +79,8 @@ 
   void DisplayInfo(void);
   void Refresh(void);
 public:
-  cDisplayChannel(int Number, bool Switched);
-  cDisplayChannel(eKeys FirstKey);
+  cDisplayChannel(int Number, bool Switched, bool Timeout = true );
+  cDisplayChannel(eKeys FirstKey, bool Timeout = true );
   virtual ~cDisplayChannel();
   virtual eOSState ProcessKey(eKeys Key);
   };
diff -Nur vdr-1.3.34-vanilla/vdr.c vdr-1.3.34/vdr.c
--- vdr-1.3.34-vanilla/vdr.c	2005-09-24 15:27:26.000000000 +0200
+++ vdr-1.3.34/vdr.c	2005-10-23 13:35:07.000000000 +0200
@@ -407,6 +407,10 @@ 
   bool ForceShutdown = false;
   bool UserShutdown = false;
   bool TimerInVpsMargin = false;
+  eOSState active_function = osUnknown;
+  eOSState active_function_cp = osUnknown;
+  eOSState last_active_function = osUnknown; 
+  bool channelinfo_requested = false;
 
   // Load plugins:
 
@@ -632,7 +636,8 @@ 
         // Channel display:
         if (!EITScanner.Active() && cDevice::CurrentChannel() != LastChannel) {
            if (!Menu)
-              Menu = Temp = new cDisplayChannel(cDevice::CurrentChannel(), LastChannel > 0);
+              Menu = Temp = new cDisplayChannel(cDevice::CurrentChannel(), LastChannel > 0, !channelinfo_requested);
+           channelinfo_requested = false; 
            LastChannel = cDevice::CurrentChannel();
            LastChannelChanged = time(NULL);
            }
@@ -697,7 +702,8 @@ 
                key = kNone; // nobody else needs to see this key
                if (Menu) {
                   DELETENULL(Menu);
-                  if (!Temp)
+                  active_function = osUnknown;
+                  //if (!Temp)
                      break;
                   }
                if (cControl::Control())
@@ -705,19 +711,27 @@ 
                Menu = new cMenuMain(cControl::Control());
                Temp = NULL;
                break;
-          #define DirectMainFunction(function)\
+          #define DirectMainFunction(function, startKey)\
             DELETENULL(Menu);\
-            if (cControl::Control())\
-               cControl::Control()->Hide();\
-            Menu = new cMenuMain(cControl::Control(), function);\
-            Temp = NULL;\
-            key = kNone; // nobody else needs to see this key
-          case kSchedule:   DirectMainFunction(osSchedule); break;
-          case kChannels:   DirectMainFunction(osChannels); break;
-          case kTimers:     DirectMainFunction(osTimers); break;
-          case kRecordings: DirectMainFunction(osRecordings); break;
-          case kSetup:      DirectMainFunction(osSetup); break;
-          case kCommands:   DirectMainFunction(osCommands); break;
+            active_function_cp = active_function;\
+            if (function == osChannels && last_active_function == osPlugin);\
+              else if (function != active_function) {\
+                        if (cControl::Control())\
+                            cControl::Control()->Hide();\
+                        Menu = new cMenuMain(cControl::Control(), function);\
+                        Temp = NULL;\
+                   }\
+                   else {\
+                           active_function = osUnknown;\
+                        }\
+            last_active_function = active_function_cp;\
+            key = startKey; // normaly this is kNone
+          case kSchedule:   DirectMainFunction(osSchedule, kNone); break;
+          case kChannels:   DirectMainFunction(osChannels, kNone); break;
+          case kTimers:     DirectMainFunction(osTimers, kNone); break;
+          case kRecordings: DirectMainFunction(osRecordings, kNone); break;
+          case kSetup:      DirectMainFunction(osSetup, kNone); break;
+          case kCommands:   DirectMainFunction(osCommands, kNone); break;
           case kUser1 ... kUser9: cRemote::PutMacro(key); key = kNone; break;
           case k_Plugin: {
                DELETENULL(Menu);
@@ -770,6 +784,7 @@ 
                   cControl::Control()->Hide();
                if (Temp && !cDisplayTracks::IsOpen()) {
                   DELETENULL(Menu);
+                  active_function = osUnknown;
                   Temp = NULL;
                   }
                if (!Menu && !cOsd::IsOpen())
@@ -782,6 +797,7 @@ 
           case kPause:
                if (!cControl::Control()) {
                   DELETENULL(Menu);
+                  active_function = osUnknown;
                   Temp = NULL;
                   if (!cRecordControls::PauseLiveVideo())
                      Skins.Message(mtError, tr("No free DVB device to record!"));
@@ -801,6 +817,7 @@ 
           // Power off:
           case kPower: isyslog("Power button pressed");
                        DELETENULL(Menu);
+                       active_function = osUnknown;
                        Temp = NULL;
                        if (!Shutdown) {
                           Skins.Message(mtError, tr("Can't shutdown - option '-s' not given!"));
@@ -826,12 +843,14 @@ 
               }
            switch (state) {
              case osPause:  DELETENULL(Menu);
+                            active_function = osUnknown;
                             cControl::Shutdown(); // just in case
                             Temp = NULL;
                             if (!cRecordControls::PauseLiveVideo())
                                Skins.Message(mtError, tr("No free DVB device to record!"));
                             break;
              case osRecord: DELETENULL(Menu);
+                            active_function = osUnknown;
                             Temp = NULL;
                             if (cRecordControls::Start())
                                ;//XXX Skins.Message(mtInfo, tr("Recording"));
@@ -840,22 +859,26 @@ 
                             break;
              case osRecordings:
                             DELETENULL(Menu);
+                            active_function = osUnknown;
                             cControl::Shutdown();
                             Temp = NULL;
                             Menu = new cMenuMain(false, osRecordings);
                             break;
              case osReplay: DELETENULL(Menu);
+                            active_function = osUnknown;
                             cControl::Shutdown();
                             Temp = NULL;
                             cControl::Launch(new cReplayControl);
                             break;
              case osStopReplay:
                             DELETENULL(Menu);
+                            active_function = osUnknown;
                             cControl::Shutdown();
                             Temp = NULL;
                             break;
              case osSwitchDvb:
                             DELETENULL(Menu);
+                            active_function = osUnknown;
                             cControl::Shutdown();
                             Temp = NULL;
                             Skins.Message(mtInfo, tr("Switching primary DVB..."));
@@ -868,7 +891,10 @@ 
                             break;
              case osBack:
              case osEnd:    if (Interact == Menu)
+                            {
                                DELETENULL(Menu);
+                               active_function = osUnknown;
+                            }
                             else
                                cControl::Shutdown();
                             Temp = NULL;
@@ -905,7 +931,8 @@ 
                   cDevice::SwitchChannel(NORMALKEY(key) == kUp ? 1 : -1);
                   break;
              // Viewing Control:
-             case kOk:   LastChannel = -1; break; // forces channel display
+             case kOk:   LastChannel = -1; channelinfo_requested = (Setup.TimeoutRequestedChInfo == 0) ; 
+                         break; // forces channel display
              // Instant resume of the last viewed recording:
              case kPlay:
                   if (cReplayControl::LastReplayed()) {