Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp	(revision 37347)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp	(revision 37348)
@@ -485,5 +485,5 @@
         case XFocusIn:
         {
-            if (uisession()->isRunning())
+            if (isSessionRunning())
             {
                 if (VBoxGlobal::qtRTVersion() < ((4 << 16) | (5 << 8) | 0))
@@ -494,6 +494,6 @@
                         captureKeyboard(uScreenId);
                         /* Reset the single-time disable capture flag: */
-                        if (uisession()->isAutoCaptureDisabled())
-                            uisession()->setAutoCaptureDisabled(false);
+                        if (isAutoCaptureDisabled())
+                            setAutoCaptureDisabled(false);
                     }
                     else
@@ -608,17 +608,17 @@
             for (int i = 0; i < theListOfViewIds.size(); ++i)
             {
-                if (m_views[theListOfViewIds[i]]->hasFocus())
+                if (viewHasFocus(theListOfViewIds[i]))
                 {
                     /* Capture keyboard: */
 #ifdef Q_WS_WIN
-                    if (!uisession()->isAutoCaptureDisabled() && m_globalSettings.autoCapture() &&
+                    if (!isAutoCaptureDisabled() && autoCaptureSetGlobally() &&
                         GetAncestor(m_views[theListOfViewIds[i]]->winId(), GA_ROOT) == GetForegroundWindow())
 #else /* Q_WS_WIN */
-                    if (!uisession()->isAutoCaptureDisabled() && m_globalSettings.autoCapture())
+                    if (!isAutoCaptureDisabled() && autoCaptureSetGlobally())
 #endif /* !Q_WS_WIN */
                         captureKeyboard(theListOfViewIds[i]);
                     /* Reset the single-time disable capture flag: */
-                    if (uisession()->isAutoCaptureDisabled())
-                        uisession()->setAutoCaptureDisabled(false);
+                    if (isAutoCaptureDisabled())
+                        setAutoCaptureDisabled(false);
                     break;
                 }
@@ -827,22 +827,22 @@
         {
             case QEvent::FocusIn:
-                if (uisession()->isRunning())
+                if (isSessionRunning())
                 {
                     /* Capture keyboard: */
 #ifdef Q_WS_WIN
-                    if (!uisession()->isAutoCaptureDisabled() && m_globalSettings.autoCapture() &&
+                    if (!isAutoCaptureDisabled() && autoCaptureSetGlobally() &&
                         GetAncestor(pWatchedView->winId(), GA_ROOT) == GetForegroundWindow())
 #else /* Q_WS_WIN */
-                    if (!uisession()->isAutoCaptureDisabled() && m_globalSettings.autoCapture())
+                    if (!isAutoCaptureDisabled() && autoCaptureSetGlobally())
 #endif /* !Q_WS_WIN */
                         captureKeyboard(uScreenId);
                     /* Reset the single-time disable capture flag: */
-                    if (uisession()->isAutoCaptureDisabled())
-                        uisession()->setAutoCaptureDisabled(false);
+                    if (isAutoCaptureDisabled())
+                        setAutoCaptureDisabled(false);
                 }
                 break;
             case QEvent::FocusOut:
                 /* Release keyboard: */
-                if (uisession()->isRunning())
+                if (isSessionRunning())
                     releaseKeyboard();
                 /* And all pressed keys: */
@@ -1128,5 +1128,5 @@
          * to the host when the user forgets the Host Key. Note that it's always possible
          * to send C-A-D to the guest using the Host+Del combination: */
-        if (uisession()->isRunning() && m_fIsKeyboardCaptured)
+        if (isSessionRunning() && m_fIsKeyboardCaptured)
         {
             releaseKeyboard();
@@ -1207,5 +1207,5 @@
             m_bIsHostComboAlone = true;
             m_bIsHostComboProcessed = false;
-            if (uisession()->isRunning())
+            if (isSessionRunning())
                 saveKeyStates();
         }
@@ -1241,5 +1241,5 @@
         if (m_bIsHostComboAlone && !m_bIsHostComboProcessed)
         {
-            if (uisession()->isRunning())
+            if (isSessionRunning())
             {
                 bool ok = true;
@@ -1249,9 +1249,9 @@
                      * this dialog is dismissed because the capture state is to be
                      * defined by the dialog result itself: */
-                    uisession()->setAutoCaptureDisabled(true);
+                    setAutoCaptureDisabled(true);
                     bool fIsAutoConfirmed = false;
                     ok = vboxProblem().confirmInputCapture(&fIsAutoConfirmed);
                     if (fIsAutoConfirmed)
-                        uisession()->setAutoCaptureDisabled(false);
+                        setAutoCaptureDisabled(false);
                     /* Otherwise, the disable flag will be reset in the next
                      * machine-view's focus-in event (since may happen asynchronously
@@ -1280,5 +1280,5 @@
             }
         }
-        if (uisession()->isRunning())
+        if (isSessionRunning())
             sendChangedKeyStates();
     }
@@ -1613,4 +1613,29 @@
 }
 
+bool UIKeyboardHandler::isAutoCaptureDisabled()
+{
+    return uisession()->isAutoCaptureDisabled();
+}
+
+void UIKeyboardHandler::setAutoCaptureDisabled(bool fIsAutoCaptureDisabled)
+{
+    uisession()->setAutoCaptureDisabled(fIsAutoCaptureDisabled);
+}
+
+bool UIKeyboardHandler::autoCaptureSetGlobally()
+{
+    return m_globalSettings.autoCapture();
+}
+
+bool UIKeyboardHandler::viewHasFocus(ulong uScreenId)
+{
+    return m_views[uScreenId]->hasFocus();
+}
+
+bool UIKeyboardHandler::isSessionRunning()
+{
+    return uisession()->isRunning();
+}
+
 UIMachineWindow* UIKeyboardHandler::isItListenedWindow(QObject *pWatchedObject) const
 {
@@ -1646,3 +1671,2 @@
     return pResultView;
 }
-
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.h	(revision 37347)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.h	(revision 37348)
@@ -137,4 +137,9 @@
     void saveKeyStates();
     void sendChangedKeyStates();
+    bool isAutoCaptureDisabled();
+    void setAutoCaptureDisabled(bool fIsAutoCaptureDisabled);
+    bool autoCaptureSetGlobally();
+    bool viewHasFocus(ulong uScreenId);
+    bool isSessionRunning();
 
     UIMachineWindow* isItListenedWindow(QObject *pWatchedObject) const;
