VirtualBox

Changeset 69552 in vbox


Ignore:
Timestamp:
Nov 2, 2017 2:30:06 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
118901
Message:

FE/Qt: Setting different WM_CLASS for VirtualBox Manager and Virtual Machine windows to be able to differentiate them thru window manager rules. see bugref:9027

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

Legend:

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

    r69500 r69552  
    169169# include <X11/Xlib.h>
    170170# include <X11/Xatom.h>
     171# include <X11/Xutil.h>
    171172# include <X11/extensions/Xinerama.h>
    172173# define BOOL PRBool
     
    33223323}
    33233324
     3325#ifdef VBOX_WS_X11
     3326void VBoxGlobal::setWMClass(QWidget *pWidget, const char *pStrName, const char *pStrClass)
     3327{
     3328    /* Make sure all arguments set: */
     3329    AssertReturnVoid(pWidget && pStrName && pStrClass);
     3330
     3331    /* Create duplicates to avoid casting away constness: */
     3332    char *pWindowName = strdup(pStrName);
     3333    char *pWindowClass = strdup(pStrClass);
     3334    AssertReturnVoid(pWindowName && pWindowClass);
     3335
     3336    XClassHint windowClass;
     3337    windowClass.res_name = pWindowName;
     3338    windowClass.res_class = pWindowClass;
     3339    /* Set WM_CLASS of the window to passed name and class strings: */
     3340    XSetClassHint(QX11Info::display(), pWidget->window()->winId(), &windowClass);
     3341
     3342    /* Free duplicates: */
     3343    XFree(windowClass.res_class);
     3344    XFree(windowClass.res_name);
     3345}
     3346#endif /* VBOX_WS_X11 */
     3347
    33243348// Public slots
    33253349////////////////////////////////////////////////////////////////////////////////
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r69500 r69552  
    452452      * @note  Take into account that this request may fail on X11. */
    453453    static void setTopLevelGeometry(QWidget *pWidget, const QRect &rect);
     454
     455#ifdef VBOX_WS_X11
     456    /** Assigns WM_CLASS property for passed @a pWidget. */
     457    static void setWMClass(QWidget *pWidget, const char *pStrName, const char *pStrClass);
     458#endif
    454459
    455460signals:
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r69500 r69552  
    9696void UIMachineWindow::prepare()
    9797{
     98#ifdef VBOX_WS_X11
     99    /* Compose window name: */
     100    const QString strWindowName = QString("VirtualBox Machine UUID: %1").arg(vboxGlobal().managedVMUuid());
     101
     102    /* Assign it to both WM_CLASS name & class for now: */
     103    const char *pBuffer = strWindowName.toLatin1().constData();
     104    if (pBuffer)
     105        vboxGlobal().setWMClass(this, pBuffer, pBuffer);
     106    else
     107        vboxGlobal().setWMClass(this, "VirtualBox Machine", "VirtualBox Machine");
     108#endif
     109
    98110    /* Prepare session-connections: */
    99111    prepareSessionConnections();
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r69260 r69552  
    13211321void UISelectorWindow::prepare()
    13221322{
     1323#ifdef VBOX_WS_X11
     1324    /* Assign same name to both WM_CLASS name & class for now: */
     1325    vboxGlobal().setWMClass(this, "VirtualBox Manager", "VirtualBox Manager");
     1326#endif
     1327
    13231328#ifdef VBOX_WS_MAC
    13241329    /* We have to make sure that we are getting the front most process: */
Note: See TracChangeset for help on using the changeset viewer.

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