aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbobo1on1 <bob-nospam-@xbmc.org>2013-10-04 00:37:45 +0200
committerbobo1on1 <bob-nospam-@xbmc.org>2013-10-04 03:54:56 +0200
commit86ca4aaa233d19ef91cee2511ab9a34a36373d64 (patch)
tree79d0d6871efdf7447b7f812701394fa8163618b3
parent171eba001c636e9c86648aafbe6100e8bf0dd893 (diff)
added: setting to disable keyboard grabbing when in fullscreen on platforms that use SDL on X11, calls SDL_WM_GrabInput(SDL_GRAB_OFF) with the SDL_FULLSCREEN temporarily zero'd, this will make SDL call XUnGrabPointer and XUnGrabKeyboard, allowing window manager keys like printscreen, volume and alt-tab to work
-rwxr-xr-xlanguage/English/strings.po12
-rw-r--r--system/settings/settings.xml8
-rw-r--r--xbmc/settings/Settings.cpp9
-rw-r--r--xbmc/windowing/X11/WinSystemX11.cpp36
-rw-r--r--xbmc/windowing/X11/WinSystemX11.h5
5 files changed, 68 insertions, 2 deletions
diff --git a/language/English/strings.po b/language/English/strings.po
index 24c40852a6..737cf967c2 100755
--- a/language/English/strings.po
+++ b/language/English/strings.po
@@ -12357,7 +12357,12 @@ msgctxt "#35102"
msgid "Disable joystick when this device is present"
msgstr ""
-#empty strings from id 35103 to 35499
+#: system/settings/settings.xml
+msgctxt "#35103"
+msgid "Enable system keys in fullscreen"
+msgstr ""
+
+#empty strings from id 35104 to 35499
#: Unknown
msgctxt "#35500"
@@ -14433,3 +14438,8 @@ msgstr ""
msgctxt "#37018"
msgid "Boost centre channel when downmixing"
msgstr ""
+
+#: system/settings/settings.xml
+msgctxt "#37019"
+msgid "Enables system keys like printscreen, alt-tab and volume keys when in fullscreen"
+msgstr ""
diff --git a/system/settings/settings.xml b/system/settings/settings.xml
index a22138c445..a646a144bf 100644
--- a/system/settings/settings.xml
+++ b/system/settings/settings.xml
@@ -2142,6 +2142,14 @@
<level>0</level>
<default>true</default>
</setting>
+ <setting id="input.enablesystemkeys" type="boolean" label="35103" help="37019">
+ <and>
+ <requirement>HAS_GL</requirement>
+ <requirement>HAVE_X11</requirement>
+ </and>
+ <level>2</level>
+ <default>false</default>
+ </setting>
</group>
</category>
<category id="network" label="798" help="36379">
diff --git a/xbmc/settings/Settings.cpp b/xbmc/settings/Settings.cpp
index da10a5dd50..27002fb00c 100644
--- a/xbmc/settings/Settings.cpp
+++ b/xbmc/settings/Settings.cpp
@@ -721,6 +721,9 @@ void CSettings::InitializeConditions()
#ifdef HAS_EVENT_SERVER
m_settingsManager->AddCondition("has_event_server");
#endif
+#ifdef HAVE_X11
+ m_settingsManager->AddCondition("have_x11");
+#endif
#ifdef HAS_GL
m_settingsManager->AddCondition("has_gl");
#endif
@@ -944,6 +947,12 @@ void CSettings::InitializeISettingCallbacks()
settingSet.insert("input.enablemouse");
m_settingsManager->RegisterCallback(&g_Mouse, settingSet);
+#if defined(HAS_GL) && defined(HAVE_X11)
+ settingSet.clear();
+ settingSet.insert("input.enablesystemkeys");
+ m_settingsManager->RegisterCallback(&g_Windowing, settingSet);
+#endif
+
settingSet.clear();
settingSet.insert("services.webserver");
settingSet.insert("services.webserverport");
diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp
index 31f5304705..7caae9dfb3 100644
--- a/xbmc/windowing/X11/WinSystemX11.cpp
+++ b/xbmc/windowing/X11/WinSystemX11.cpp
@@ -26,6 +26,7 @@
#include "WinSystemX11.h"
#include "settings/DisplaySettings.h"
#include "settings/Settings.h"
+#include "settings/Setting.h"
#include "guilib/GraphicContext.h"
#include "guilib/Texture.h"
#include "guilib/DispResource.h"
@@ -174,6 +175,7 @@ bool CWinSystemX11::ResizeWindow(int newWidth, int newHeight, int newLeft, int n
if ((m_SDLSurface = SDL_SetVideoMode(m_nWidth, m_nHeight, 0, options)))
{
+ SetGrabMode();
RefreshGlxContext();
return true;
}
@@ -216,6 +218,7 @@ bool CWinSystemX11::SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool bl
if ((m_SDLSurface->flags & SDL_OPENGL) != SDL_OPENGL)
CLog::Log(LOGERROR, "CWinSystemX11::SetFullScreen SDL_OPENGL not set, SDL_GetError:%s", SDL_GetError());
+ SetGrabMode();
RefreshGlxContext();
return true;
@@ -560,4 +563,37 @@ bool CWinSystemX11::EnableFrameLimiter()
return m_minimized;
}
+void CWinSystemX11::SetGrabMode(const CSetting *setting /*= NULL*/)
+{
+ bool enabled;
+ if (setting)
+ enabled = ((CSettingBool*)setting)->GetValue();
+ else
+ enabled = CSettings::Get().GetBool("input.enablesystemkeys");
+
+ if (m_SDLSurface && m_SDLSurface->flags & SDL_FULLSCREEN)
+ {
+ if (enabled)
+ {
+ //SDL will always call XGrabPointer and XGrabKeyboard when in fullscreen
+ //so temporarily zero the SDL_FULLSCREEN flag, then turn off SDL grab mode
+ //this will make SDL call XUnGrabPointer and XUnGrabKeyboard
+ m_SDLSurface->flags &= ~SDL_FULLSCREEN;
+ SDL_WM_GrabInput(SDL_GRAB_OFF);
+ m_SDLSurface->flags |= SDL_FULLSCREEN;
+ }
+ else
+ {
+ //turn off key grabbing, which will actually make SDL turn it on when in fullscreen
+ SDL_WM_GrabInput(SDL_GRAB_OFF);
+ }
+ }
+}
+
+void CWinSystemX11::OnSettingChanged(const CSetting *setting)
+{
+ if (setting->GetId() == "input.enablesystemkeys")
+ SetGrabMode(setting);
+}
+
#endif
diff --git a/xbmc/windowing/X11/WinSystemX11.h b/xbmc/windowing/X11/WinSystemX11.h
index 3d438c8171..2454fb1db1 100644
--- a/xbmc/windowing/X11/WinSystemX11.h
+++ b/xbmc/windowing/X11/WinSystemX11.h
@@ -30,10 +30,11 @@
#include "windowing/WinSystem.h"
#include "utils/Stopwatch.h"
#include "threads/CriticalSection.h"
+#include "settings/ISettingCallback.h"
class IDispResource;
-class CWinSystemX11 : public CWinSystemBase
+class CWinSystemX11 : public CWinSystemBase, public ISettingCallback
{
public:
CWinSystemX11();
@@ -65,6 +66,7 @@ public:
Display* GetDisplay() { return m_dpy; }
GLXWindow GetWindow() { return m_glWindow; }
GLXContext GetGlxContext() { return m_glContext; }
+ virtual void OnSettingChanged(const CSetting *setting);
protected:
bool RefreshGlxContext();
@@ -86,6 +88,7 @@ protected:
private:
bool IsSuitableVisual(XVisualInfo *vInfo);
static int XErrorHandler(Display* dpy, XErrorEvent* error);
+ void SetGrabMode(const CSetting *setting = NULL);
CStopWatch m_screensaverReset;
};