VirtualBox

Changeset 82692 in vbox


Ignore:
Timestamp:
Jan 9, 2020 12:41:11 PM (5 years ago)
Author:
vboxsync
Message:

bugref:9637. Some refactoring

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/VBoxClient/display-svga.cpp

    r82680 r82692  
    8989AssertCompileSize(struct DRMVMWRECT, 16);
    9090
    91 struct DISPLAYCACHE
    92 {
    93     int fEnabled;
    94     struct DRMVMWRECT rect;
    95 };
    96 
    9791#define DRM_IOCTL_VERSION _IOWR('d', 0x00, struct DRMVERSION)
    9892
     
    10296};
    10397
    104 struct DISPLAYCACHE aRects[VMW_MAX_HEADS];
    10598
    10699static void drmConnect(struct DRMCONTEXT *pContext)
     
    190183    (void)fDaemonised;
    191184    struct DRMCONTEXT drmContext = { NIL_RTFILE };
    192 
     185    static struct VMMDevDisplayDef aMonitors[VMW_MAX_HEADS];
    193186    int rc;
    194     unsigned cHeads;
     187    unsigned cEnabledMonitors;
    195188    /* Do not acknowledge the first event we query for to pick up old events,
    196189     * e.g. from before a guest reboot. */
     
    208201        VBClLogFatalError("Failed to register resizing support, rc=%Rrc\n", rc);
    209202
    210     /* For the time being we initialize all the monitors as disabled as per VMM device initialization. */
    211     for (int i = 0; i < VMW_MAX_HEADS; ++i)
    212         aRects[i].fEnabled = 0;
    213 
    214203    for (;;)
    215204    {
     
    233222                if (idDisplay >= VMW_MAX_HEADS)
    234223                    continue;
     224                aMonitors[idDisplay].fDisplayFlags = aDisplays[i].fDisplayFlags;
    235225                if (!(aDisplays[i].fDisplayFlags & VMMDEV_DISPLAY_DISABLED))
    236226                {
    237227                    if ((idDisplay == 0) || (aDisplays[i].fDisplayFlags & VMMDEV_DISPLAY_ORIGIN))
    238228                    {
    239                         aRects[idDisplay].rect.x = aDisplays[i].xOrigin;
    240                         aRects[idDisplay].rect.y = aDisplays[i].yOrigin;
     229                        aMonitors[idDisplay].xOrigin = aDisplays[i].xOrigin;
     230                        aMonitors[idDisplay].yOrigin = aDisplays[i].yOrigin;
    241231                    } else {
    242                         aRects[idDisplay].rect.x = aRects[idDisplay - 1].rect.x + aRects[idDisplay - 1].rect.w;
    243                         aRects[idDisplay].rect.y = aRects[idDisplay - 1].rect.y;
     232                        aMonitors[idDisplay].xOrigin = aMonitors[idDisplay - 1].xOrigin + aMonitors[idDisplay - 1].cx;
     233                        aMonitors[idDisplay].yOrigin = aMonitors[idDisplay - 1].yOrigin;
    244234                    }
    245                     aRects[idDisplay].rect.w = aDisplays[i].cx;
    246                     aRects[idDisplay].rect.h = aDisplays[i].cy;
    247                     aRects[idDisplay].fEnabled = 1;
     235                    aMonitors[idDisplay].cx = aDisplays[i].cx;
     236                    aMonitors[idDisplay].cy = aDisplays[i].cy;
    248237                }
    249                 else
    250                     aRects[idDisplay].fEnabled = 0;
    251238            }
    252239            /* Create an dense (consisting of enable monitors only) array to pass to DRM. */
    253             cHeads = 0;
    254             struct DRMVMWRECT enabledMonitors[VMW_MAX_HEADS];
    255 
     240            cEnabledMonitors = 0;
     241            struct DRMVMWRECT aEnabledMonitors[VMW_MAX_HEADS];
    256242            for (int j = 0; j < VMW_MAX_HEADS; ++j)
    257243            {
    258                 if (aRects[j].fEnabled)
     244                if (!(aMonitors[j].fDisplayFlags & VMMDEV_DISPLAY_DISABLED))
    259245                {
    260                     enabledMonitors[cHeads] = aRects[j].rect;
    261                     if (cHeads > 0)
    262                         enabledMonitors[cHeads].x = enabledMonitors[cHeads - 1].x + enabledMonitors[cHeads - 1].w;
    263                     ++cHeads;
     246                    aEnabledMonitors[cEnabledMonitors].x = aMonitors[j].xOrigin;
     247                    aEnabledMonitors[cEnabledMonitors].y = aMonitors[j].yOrigin;
     248                    aEnabledMonitors[cEnabledMonitors].w = aMonitors[j].cx;
     249                    aEnabledMonitors[cEnabledMonitors].h = aMonitors[j].cy;
     250                    if (cEnabledMonitors > 0)
     251                        aEnabledMonitors[cEnabledMonitors].x = aEnabledMonitors[cEnabledMonitors - 1].x + aEnabledMonitors[cEnabledMonitors - 1].w;
     252                    ++cEnabledMonitors;
    264253                }
    265254            }
    266 
    267             for (unsigned i = 0; i < cHeads; ++i)
    268                 printf("Monitor %u: %dx%d, (%d, %d)\n", i, (int)enabledMonitors[i].w, (int)enabledMonitors[i].h,
    269                        (int)enabledMonitors[i].x, (int)enabledMonitors[i].y);
    270             drmSendHints(&drmContext, enabledMonitors, cHeads);
     255            for (unsigned i = 0; i < cEnabledMonitors; ++i)
     256                printf("Monitor %u: %dx%d, (%d, %d)\n", i, (int)aEnabledMonitors[i].w, (int)aEnabledMonitors[i].h,
     257                       (int)aEnabledMonitors[i].x, (int)aEnabledMonitors[i].y);
     258            drmSendHints(&drmContext, aEnabledMonitors, cEnabledMonitors);
    271259        }
    272260        do
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