Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp	(revision 59376)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp	(revision 59377)
@@ -813,8 +813,10 @@
 bool UIKeyboardHandler::x11EventFilter(XEvent *pEvent, ulong uScreenId)
 {
-    /* Check if some system event should be filtered-out.
-     * Returning 'true' means filtering-out,
-     * Returning 'false' means passing event to Qt. */
-    bool fResult = false; /* Pass to Qt by default: */
+    /* Check if some system event should be filtered out.
+     * Returning @c true means filtering-out,
+     * Returning @c false means passing event to Qt. */
+    bool fResult = false; /* Pass to Qt by default. */
+
+    /* Depending on event type: */
     switch (pEvent->type)
     {
@@ -850,12 +852,13 @@
             break;
         }
+        /* Watch for key-events: */
         case XKeyPress:
         case XKeyRelease:
         {
-            /* Translate the keycode to a PC scan code. */
-            unsigned scan = handleXKeyEvent(pEvent->xkey.display, pEvent->xkey.keycode);
-
-            /* Scancodes 0x00 (no valid translation) and 0x80 are ignored: */
-            if (!(scan & 0x7F))
+            /* Translate the keycode to a PC scan code: */
+            unsigned uScan = handleXKeyEvent(pEvent->xkey.display, pEvent->xkey.keycode);
+
+            /* Scan codes 0x00 (no valid translation) and 0x80 (extended flag) are ignored: */
+            if (!(uScan & 0x7F))
             {
                 fResult = true;
@@ -874,32 +877,35 @@
             }
 
-            KeySym ks = ::wrapXkbKeycodeToKeysym(pEvent->xkey.display, pEvent->xkey.keycode, 0, 0);
-
-            int flags = 0;
-            if (scan >> 8)
-                flags |= KeyExtended;
+            /* Calculate flags: */
+            int iFlags = 0;
+            if (uScan >> 8)
+                iFlags |= KeyExtended;
             if (pEvent->type == XKeyPress)
-                flags |= KeyPressed;
+                iFlags |= KeyPressed;
 
             /* Remove the extended flag: */
-            scan &= 0x7F;
-
-            /* Special Korean keys must send scancode 0xF1/0xF2 when pressed and nothing
-             * when released.
-             */
-            if (scan == 0x71 || scan == 0x72)
-            {
-                if (pEvent->type == XKeyRelease)  /* Ignore. */
+            uScan &= 0x7F;
+
+            /* Special Korean keys must send scan code 0xF1/0xF2
+             * when pressed and nothing when released. */
+            if (uScan == 0x71 || uScan == 0x72)
+            {
+                if (pEvent->type == XKeyRelease)
                 {
                     fResult = true;
                     break;
                 }
-                scan |= 0x80;   /* Re-create the bizarre scancode. */
-            }
-
+                /* Re-create the bizarre scan code: */
+                uScan |= 0x80;
+            }
+
+            /* Translate the keycode to a keysym: */
+            KeySym ks = ::wrapXkbKeycodeToKeysym(pEvent->xkey.display, pEvent->xkey.keycode, 0, 0);
+
+            /* Update special flags: */
             switch (ks)
             {
                 case XK_Print:
-                    flags |= KeyPrint;
+                    iFlags |= KeyPrint;
                     break;
                 case XK_Pause:
@@ -907,17 +913,21 @@
                     {
                         ks = XK_Break;
-                        flags |= KeyExtended;
-                        scan = 0x46;
+                        iFlags |= KeyExtended;
+                        uScan = 0x46;
                     }
                     else
-                        flags |= KeyPause;
+                        iFlags |= KeyPause;
                     break;
             }
 
-            fResult = keyEvent(ks, scan, flags, uScreenId);
+            /* Finally, handle parsed key-event: */
+            fResult = keyEvent(ks, uScan, iFlags, uScreenId);
+
+            break;
         }
         default:
             break;
     }
+
     /* Return result: */
     return fResult;
@@ -1513,5 +1523,5 @@
 
     /* If some key was pressed or some previously pressed key was released =>
-     * we are updating the list of pressed keys and preparing scancodes: */
+     * we are updating the list of pressed keys and preparing scan codes: */
     if ((fFlags & KeyPressed) || (m_pressedKeys[uScan] & uWhatPressed))
     {
@@ -1522,5 +1532,5 @@
                 fixModifierState(pCodes, puCodesCount);
 
-        /* Prepend 'extended' scancode if needed: */
+        /* Prepend 'extended' scan code if needed: */
         if (fFlags & KeyExtended)
             pCodes[(*puCodesCount)++] = 0xE0;
@@ -1529,5 +1539,5 @@
         if (fFlags & KeyPressed)
         {
-            /* Append scancode: */
+            /* Append scan code: */
             pCodes[(*puCodesCount)++] = uScan;
             m_pressedKeys[uScan] |= uWhatPressed;
@@ -1536,5 +1546,5 @@
         else if (m_pressedKeys[uScan] & uWhatPressed)
         {
-            /* Append scancode: */
+            /* Append scan code: */
             pCodes[(*puCodesCount)++] = uScan | 0x80;
             m_pressedKeys[uScan] &= ~uWhatPressed;
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp	(revision 59376)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp	(revision 59377)
@@ -1779,4 +1779,5 @@
 bool UIMachineView::x11Event(XEvent *pEvent)
 {
+    /* Make sure arguments valid: */
     AssertPtrReturn(pEvent, false);
 
@@ -1787,6 +1788,8 @@
     switch (pEvent->type)
     {
+        /* Watch for focus-events: */
         case XFocusIn:
         case XFocusOut:
+        /* Watch for key-events: */
         case XKeyPress:
         case XKeyRelease:
@@ -1806,4 +1809,5 @@
     }
 
+    /* Return result: */
     return fResult;
 }
