Index: Configuration/Sections/General.cs =================================================================== --- Configuration/Sections/General.cs (revision 27028) +++ Configuration/Sections/General.cs (working copy) @@ -86,34 +86,36 @@ // 1 Use screenselector to choose on which screen MP should start new string[] {"general", "alwaysontop", "false"}, // 2 Keep MediaPortal always on top + new string[] {"general", "keepfocused", "true"}, + // 3 Keep MediaPortal focused in 'Keep MediaPortal always on top' mode new string[] {"general", "hidetaskbar", "false"}, - // 3 Hide taskbar in fullscreen mode + // 4 Hide taskbar in fullscreen mode new string[] {"general", "autostart", "false"}, - // 4 Autostart MediaPortal on Windows startup + // 5 Autostart MediaPortal on Windows startup new string[] {"general", "minimizeonstartup", "false"}, - // 5 Minimize to tray on start up + // 6 Minimize to tray on start up new string[] {"general", "minimizeonexit", "false"}, - // 6 Minimize to tray on GUI exit + // 7 Minimize to tray on GUI exit new string[] {"general", "mousesupport", "false"}, - // 7 Show special mouse controls (scrollbars, etc) + // 8 Show special mouse controls (scrollbars, etc) new string[] {"general", "hideextensions", "true"}, - // 8 Hide file extensions like .mp3, .avi, .mpg,... + // 9 Hide file extensions like .mp3, .avi, .mpg,... new string[] {"general", "turnoffmonitor", "false"}, - // 9 Turn off monitor when blanking screen + // 10 Turn off monitor when blanking screen new string[] {"general", "turnmonitoronafterresume", "true"}, - // 10 Turn monitor/tv on when resuming from standby + // 11 Turn monitor/tv on when resuming from standby new string[] {"general", "enables3trick", "true"}, - // 11 Allow S3 standby although wake up devices are present + // 12 Allow S3 standby although wake up devices are present new string[] {"debug", "useS3Hack", "false"}, - // 12 Apply workaround to fix MP freezing on resume on some systems + // 13 Apply workaround to fix MP freezing on resume on some systems new string[] {"general", "restartonresume", "false"}, - // 13 Restart MediaPortal on resume (avoids stuttering playback with nvidia) + // 14 Restart MediaPortal on resume (avoids stuttering playback with nvidia) new string[] {"general", "showlastactivemodule", "false"}, - // 14 Show last active module when starting / resuming from standby + // 15 Show last active module when starting / resuming from standby new string[] {"comskip", "automaticskip", "false"}, - // 15 Automatically skip commercials for videos with ComSkip data available + // 16 Automatically skip commercials for videos with ComSkip data available new string[] {"screenselector", "usescreenselector", "false"}, - // 16 Allow remember last focused item on supported window/skin + // 17 Allow remember last focused item on supported window/skin new string[] {"general", "allowRememberLastFocusedItem", "true"}, // 17 Allow remember last focused item on supported window/skin new string[] {"general", "fileexistscache", "false"}, @@ -183,6 +185,15 @@ } } + private int _findSectionIndex(string[][] sections, string arg1, string arg2) + { + for (int i = 0; i < sections.Length; i++) + if ((sections[i][0] == arg1) && (sections[i][1] == arg2)) + return i; + + return -1; + } + public override void SaveSettings() { using (Settings xmlwriter = new MPSettings()) @@ -201,19 +212,24 @@ try { - if (settingsCheckedListBox.GetItemChecked(4)) // autostart on boot + int index; + index = _findSectionIndex(sectionEntries, "general", "autostart"); + if (index >= 0) { - string fileName = Config.GetFile(Config.Dir.Base, "MediaPortal.exe"); - using (RegistryKey subkey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true)) + if (settingsCheckedListBox.GetItemChecked(index)) // autostart on boot { - subkey.SetValue("MediaPortal", fileName); + string fileName = Config.GetFile(Config.Dir.Base, "MediaPortal.exe"); + using (RegistryKey subkey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true)) + { + subkey.SetValue("MediaPortal", fileName); + } } - } - else - { - using (RegistryKey subkey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true)) + else { - subkey.DeleteValue("MediaPortal", false); + using (RegistryKey subkey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true)) + { + subkey.DeleteValue("MediaPortal", false); + } } } @@ -227,11 +243,15 @@ // subkey.SetValue("EnableBalloonTips", iValue); //} - if (settingsCheckedListBox.GetItemChecked(2)) // always on top + index = _findSectionIndex(sectionEntries, "general", "alwaysontop"); + if (index >= 0) { - using (RegistryKey subkey = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true)) + if (settingsCheckedListBox.GetItemChecked(index)) // always on top { - subkey.SetValue("ForegroundLockTimeout", 0); + using (RegistryKey subkey = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true)) + { + subkey.SetValue("ForegroundLockTimeout", 0); + } } } Index: Configuration/Sections/General.Designer.cs =================================================================== --- Configuration/Sections/General.Designer.cs (revision 27028) +++ Configuration/Sections/General.Designer.cs (working copy) @@ -162,6 +162,7 @@ "Start MediaPortal in fullscreen mode", "Use alternative fullscreen Splashscreen (only if started in fullscreen mode)", "Keep MediaPortal always on top", + "Keep MediaPortal focused in \'Keep MediaPortal always on top\' mode", "Hide taskbar in fullscreen mode", "Autostart MediaPortal on Windows startup", "Minimize to tray on start up", Index: MediaPortal.Application/d3dapp.cs =================================================================== --- MediaPortal.Application/d3dapp.cs (revision 27028) +++ MediaPortal.Application/d3dapp.cs (working copy) @@ -258,6 +258,7 @@ protected bool autoHideTaskbar = true; private bool alwaysOnTop = false; private bool alwaysOnTopConfig = false; + private bool keepFocused = true; protected bool useExclusiveDirectXMode; protected bool useEnhancedVideoRenderer; private bool _disableMouseEvents = false; @@ -321,6 +322,7 @@ } autoHideTaskbar = xmlreader.GetValueAsBool("general", "hidetaskbar", true); alwaysOnTopConfig = alwaysOnTop = xmlreader.GetValueAsBool("general", "alwaysontop", false); + keepFocused = xmlreader.GetValueAsBool("general", "keepfocused", true); debugChangeDeviceHack = xmlreader.GetValueAsBool("debug", "changedevicehack", false); _disableMouseEvents = xmlreader.GetValueAsBool("remote", "CentareaJoystickMap", false); } @@ -1420,7 +1422,7 @@ HandleCursor(); // In minitv mode allow to loose focus - if ((ActiveForm != this) && (alwaysOnTop) && !miniTvMode && (GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.RUNNING)) + if ((ActiveForm != this) && (alwaysOnTop) && !miniTvMode && (GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.RUNNING) && keepFocused) { this.Activate(); } @@ -1437,7 +1439,7 @@ try { #endif - if ((GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.LOST) || (ActiveForm != this) || (GUIGraphicsContext.SaveRenderCycles)) + if ((GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.LOST) || (ActiveForm != this && !alwaysOnTop) || (GUIGraphicsContext.SaveRenderCycles)) { // Yield some CPU time to other processes DoSleep(100); // 100 milliseconds @@ -1473,7 +1475,7 @@ { #if !PROFILING // if we dont got the focus, then dont use all the CPU - if (ActiveForm != this || (GUIGraphicsContext.SaveRenderCycles)) + if ((ActiveForm != this && !alwaysOnTop) || (GUIGraphicsContext.SaveRenderCycles)) { Thread.Sleep(100); }