VirtualBox

Changeset 99407 in vbox


Ignore:
Timestamp:
Apr 14, 2023 6:15:43 PM (18 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10407. Safe guarding more X11 call code.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDesktopWidgetWatchdog.cpp

    r99002 r99407  
    790790#ifdef VBOX_WS_X11
    791791# define QWINDOWSIZE_MAX ((1<<24)-1)
    792     if (pWidget->isWindow() && pWidget->isVisible())
     792    if (pWidget->isWindow() && pWidget->isVisible() && uiCommon().X11XServerAvailable())
    793793    {
    794794        // WORKAROUND:
     
    861861
    862862#elif defined(VBOX_WS_X11)
    863 
    864     fResult &= NativeWindowSubsystem::X11ActivateWindow(wId, fSwitchDesktop);
     863    if (uiCommon().X11XServerAvailable())
     864        fResult &= NativeWindowSubsystem::X11ActivateWindow(wId, fSwitchDesktop);
    865865
    866866#else
     
    11421142# include "UIDesktopWidgetWatchdog.moc"
    11431143#endif /* VBOX_WS_X11 && !VBOX_GUI_WITH_CUSTOMIZATIONS1 */
    1144 
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp

    r98848 r99407  
    11461146
    11471147#ifdef VBOX_WS_X11
    1148     /* Resync Qt and X11 Server (see xTracker #7547). */
    1149     XSync(NativeWindowSubsystem::X11GetDisplay(), false);
     1148    if (uiCommon().X11XServerAvailable())
     1149        /* Resync Qt and X11 Server (see xTracker #7547). */
     1150        XSync(NativeWindowSubsystem::X11GetDisplay(), false);
    11501151#endif
    11511152
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp

    r99071 r99407  
    10351035    /* Global settings: */
    10361036#ifdef VBOX_WS_X11
    1037     /* Initialize the X keyboard subsystem: */
    1038     initMappedX11Keyboard(NativeWindowSubsystem::X11GetDisplay(), gEDataManager->remappedScanCodes());
    1039     /* Fix for http://www.virtualbox.org/ticket/1296:
    1040      * when X11 sends events for repeated keys, it always inserts an XKeyRelease
    1041      * before the XKeyPress. */
    1042     /* Disable key release events during key auto-repeat: */
    1043     XkbSetDetectableAutoRepeat(NativeWindowSubsystem::X11GetDisplay(), True, NULL);
     1037    if (uiCommon().X11XServerAvailable())
     1038    {
     1039        /* Initialize the X keyboard subsystem: */
     1040        initMappedX11Keyboard(NativeWindowSubsystem::X11GetDisplay(), gEDataManager->remappedScanCodes());
     1041        /* Fix for http://www.virtualbox.org/ticket/1296:
     1042        * when X11 sends events for repeated keys, it always inserts an XKeyRelease
     1043        * before the XKeyPress. */
     1044        /* Disable key release events during key auto-repeat: */
     1045        XkbSetDetectableAutoRepeat(NativeWindowSubsystem::X11GetDisplay(), True, NULL);
     1046    }
    10441047#endif /* VBOX_WS_X11 */
    10451048
     
    17831786
    17841787#elif defined(VBOX_WS_X11)
    1785 
    1786     Q_UNUSED(pHotKey);
    1787     Display *pDisplay = NativeWindowSubsystem::X11GetDisplay();
    1788     KeyCode keyCode = XKeysymToKeycode(pDisplay, iHotKey);
    1789     for (int i = 0; i < 4 && !fWasProcessed; ++i) /* Up to four groups. */
    1790     {
    1791         KeySym ks = wrapXkbKeycodeToKeysym(pDisplay, keyCode, i, 0);
    1792         char symbol = 0;
    1793         if (XkbTranslateKeySym(pDisplay, &ks, 0, &symbol, 1, NULL) == 0)
    1794             symbol = 0;
    1795         if (symbol)
    1796         {
    1797             QChar qtSymbol = QString::fromLocal8Bit(&symbol, 1)[0];
    1798             fWasProcessed = actionPool()->processHotKey(QKeySequence(qtSymbol.toUpper().unicode()));
     1788    if (uiCommon().X11XServerAvailable())
     1789    {
     1790        Q_UNUSED(pHotKey);
     1791        Display *pDisplay = NativeWindowSubsystem::X11GetDisplay();
     1792        KeyCode keyCode = XKeysymToKeycode(pDisplay, iHotKey);
     1793        for (int i = 0; i < 4 && !fWasProcessed; ++i) /* Up to four groups. */
     1794        {
     1795            KeySym ks = wrapXkbKeycodeToKeysym(pDisplay, keyCode, i, 0);
     1796            char symbol = 0;
     1797            if (XkbTranslateKeySym(pDisplay, &ks, 0, &symbol, 1, NULL) == 0)
     1798                symbol = 0;
     1799            if (symbol)
     1800            {
     1801                QChar qtSymbol = QString::fromLocal8Bit(&symbol, 1)[0];
     1802                fWasProcessed = actionPool()->processHotKey(QKeySequence(qtSymbol.toUpper().unicode()));
     1803            }
    17991804        }
    18001805    }
     
    18581863
    18591864#elif defined(VBOX_WS_X11)
    1860 
    1861     Window   wDummy1, wDummy2;
    1862     int      iDummy3, iDummy4, iDummy5, iDummy6;
    1863     unsigned uMask;
    1864     unsigned uKeyMaskNum = 0, uKeyMaskCaps = 0;
    1865     Display * const pDisplay = NativeWindowSubsystem::X11GetDisplay();
    1866 
    1867     uKeyMaskCaps          = LockMask;
    1868     XModifierKeymap* map  = XGetModifierMapping(pDisplay);
    1869     KeyCode keyCodeNum    = XKeysymToKeycode(pDisplay, XK_Num_Lock);
    1870 
    1871     for (int i = 0; i < 8; ++ i)
    1872         if (keyCodeNum != NoSymbol && map->modifiermap[map->max_keypermod * i] == keyCodeNum)
    1873             uKeyMaskNum = 1 << i;
    1874     XQueryPointer(pDisplay, DefaultRootWindow(pDisplay), &wDummy1, &wDummy2,
    1875                   &iDummy3, &iDummy4, &iDummy5, &iDummy6, &uMask);
    1876     XFreeModifiermap(map);
    1877 
    1878     if (uimachine()->numLockAdaptionCnt() && (uimachine()->isNumLock() ^ !!(uMask & uKeyMaskNum)))
    1879     {
    1880         uimachine()->setNumLockAdaptionCnt(uimachine()->numLockAdaptionCnt() - 1);
    1881         piCodes[(*puCount)++] = 0x45;
    1882         piCodes[(*puCount)++] = 0x45 | 0x80;
    1883     }
    1884     if (uimachine()->capsLockAdaptionCnt() && (uimachine()->isCapsLock() ^ !!(uMask & uKeyMaskCaps)))
    1885     {
    1886         uimachine()->setCapsLockAdaptionCnt(uimachine()->capsLockAdaptionCnt() - 1);
    1887         piCodes[(*puCount)++] = 0x3a;
    1888         piCodes[(*puCount)++] = 0x3a | 0x80;
    1889         /* Some keyboard layouts require shift to be pressed to break
    1890          * capslock.  For simplicity, only do this if shift is not
    1891          * already held down. */
    1892         if (uimachine()->isCapsLock() && !(m_pressedKeys[0x2a] & IsKeyPressed))
    1893         {
    1894             piCodes[(*puCount)++] = 0x2a;
    1895             piCodes[(*puCount)++] = 0x2a | 0x80;
    1896         }
    1897     }
    1898 
     1865    if (uiCommon().X11XServerAvailable())
     1866    {
     1867        Window   wDummy1, wDummy2;
     1868        int      iDummy3, iDummy4, iDummy5, iDummy6;
     1869        unsigned uMask;
     1870        unsigned uKeyMaskNum = 0, uKeyMaskCaps = 0;
     1871        Display * const pDisplay = NativeWindowSubsystem::X11GetDisplay();
     1872
     1873        uKeyMaskCaps          = LockMask;
     1874        XModifierKeymap* map  = XGetModifierMapping(pDisplay);
     1875        KeyCode keyCodeNum    = XKeysymToKeycode(pDisplay, XK_Num_Lock);
     1876
     1877        for (int i = 0; i < 8; ++ i)
     1878            if (keyCodeNum != NoSymbol && map->modifiermap[map->max_keypermod * i] == keyCodeNum)
     1879                uKeyMaskNum = 1 << i;
     1880        XQueryPointer(pDisplay, DefaultRootWindow(pDisplay), &wDummy1, &wDummy2,
     1881                    &iDummy3, &iDummy4, &iDummy5, &iDummy6, &uMask);
     1882        XFreeModifiermap(map);
     1883
     1884        if (uimachine()->numLockAdaptionCnt() && (uimachine()->isNumLock() ^ !!(uMask & uKeyMaskNum)))
     1885        {
     1886            uimachine()->setNumLockAdaptionCnt(uimachine()->numLockAdaptionCnt() - 1);
     1887            piCodes[(*puCount)++] = 0x45;
     1888            piCodes[(*puCount)++] = 0x45 | 0x80;
     1889        }
     1890        if (uimachine()->capsLockAdaptionCnt() && (uimachine()->isCapsLock() ^ !!(uMask & uKeyMaskCaps)))
     1891        {
     1892            uimachine()->setCapsLockAdaptionCnt(uimachine()->capsLockAdaptionCnt() - 1);
     1893            piCodes[(*puCount)++] = 0x3a;
     1894            piCodes[(*puCount)++] = 0x3a | 0x80;
     1895            /* Some keyboard layouts require shift to be pressed to break
     1896            * capslock.  For simplicity, only do this if shift is not
     1897            * already held down. */
     1898            if (uimachine()->isCapsLock() && !(m_pressedKeys[0x2a] & IsKeyPressed))
     1899            {
     1900                piCodes[(*puCount)++] = 0x2a;
     1901                piCodes[(*puCount)++] = 0x2a | 0x80;
     1902            }
     1903        }
     1904    }
    18991905#else
    19001906
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r99098 r99407  
    149149    if (gEDataManager->distinguishMachineWindowGroups(uiCommon().managedVMUuid()))
    150150        strWindowName = QString("VirtualBox Machine UUID: %1").arg(uiCommon().managedVMUuid().toString());
    151     /* Assign WM_CLASS property: */
    152     NativeWindowSubsystem::X11SetWMClass(this, strWindowName, strWindowClass);
    153     /* Tell the WM we are well behaved wrt Xwayland keyboard-grabs: */
    154     NativeWindowSubsystem::X11SetXwaylandMayGrabKeyboardFlag(this);
     151    if (uiCommon().X11XServerAvailable())
     152    {
     153        /* Assign WM_CLASS property: */
     154        NativeWindowSubsystem::X11SetWMClass(this, strWindowName, strWindowClass);
     155        /* Tell the WM we are well behaved wrt Xwayland keyboard-grabs: */
     156        NativeWindowSubsystem::X11SetXwaylandMayGrabKeyboardFlag(this);
     157    }
    155158#endif
    156159}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette