VirtualBox

Changeset 83200 in vbox for trunk/src/VBox/Additions/x11


Ignore:
Timestamp:
Mar 4, 2020 3:13:17 PM (5 years ago)
Author:
vboxsync
Message:

bugref:9637. Call vmw_ctrl extension to connect outputs to crtcs

File:
1 edited

Legend:

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

    r83173 r83200  
    5454#include <X11/extensions/shape.h>
    5555#include <X11/extensions/Xrandr.h>
     56#include <X11/extensions/panoramiXproto.h>
     57
     58#ifndef sz_XineramaScreenInfo
     59#define sz_XineramaScreenInfo 8
     60#endif
    5661
    5762/** Maximum number of supported screens.  DRM and X11 both limit this to 32. */
     
    6873#define OLD_JUNK
    6974
    70 struct X11VMWRECT /* xXineramaScreenInfo in Xlib headers. */
     75typedef struct {
     76   CARD8  reqType;           /* always X_VMwareCtrlReqCode */
     77   CARD8  VMwareCtrlReqType; /* always X_VMwareCtrlSetTopology */
     78   CARD16 length B16;
     79   CARD32 screen B32;
     80   CARD32 number B32;
     81   CARD32 pad1   B32;
     82} xVMwareCtrlSetTopologyReq;
     83#define sz_xVMwareCtrlSetTopologyReq 16
     84
     85#define X_VMwareCtrlSetTopology 2
     86
     87typedef struct {
     88   BYTE   type; /* X_Reply */
     89   BYTE   pad1;
     90   CARD16 sequenceNumber B16;
     91   CARD32 length B32;
     92   CARD32 screen B32;
     93   CARD32 pad2   B32;
     94   CARD32 pad3   B32;
     95   CARD32 pad4   B32;
     96   CARD32 pad5   B32;
     97   CARD32 pad6   B32;
     98} xVMwareCtrlSetTopologyReply;
     99#define sz_xVMwareCtrlSetTopologyReply 32
     100
     101struct X11VMWRECT
    71102{
    72103    int16_t x;
     
    81112    Display *pDisplay;
    82113    int hRandRMajor;
    83     int hVMWMajor;
     114    int hVMWCtrlMajorOpCode;
    84115    int hRandRMinor;
    85116    int hRandREventBase;
     
    101132static const char *pcszCvt = "cvt";
    102133
    103 struct DRMCONTEXT
    104 {
    105     RTFILE hDevice;
    106 };
    107 
    108134struct RANDROUTPUT
    109135{
     
    121147
    122148#ifndef OLD_JUNK
     149
     150bool VMwareCtrlSetTopology(Display *dpy, int hExtensionMajorOpcode,
     151                            int screen, xXineramaScreenInfo extents[], int number)
     152{
     153   xVMwareCtrlSetTopologyReply rep;
     154   xVMwareCtrlSetTopologyReq *req;
     155
     156   long len;
     157
     158   LockDisplay(dpy);
     159
     160   GetReq(VMwareCtrlSetTopology, req);
     161   req->reqType = hExtensionMajorOpcode;
     162   req->VMwareCtrlReqType = X_VMwareCtrlSetTopology;
     163   req->screen = screen;
     164   req->number = number;
     165
     166   len = ((long) number) << 1;
     167   SetReqLen(req, len, len);
     168   len <<= 2;
     169   _XSend(dpy, (char *)extents, len);
     170
     171   if (!_XReply(dpy, (xReply *)&rep,
     172                (SIZEOF(xVMwareCtrlSetTopologyReply) - SIZEOF(xReply)) >> 2,
     173                xFalse))
     174   {
     175       UnlockDisplay(dpy);
     176       SyncHandle();
     177       return false;
     178   }
     179   UnlockDisplay(dpy);
     180   SyncHandle();
     181   return true;
     182}
     183
    123184/** This function assumes monitors are named as from Virtual1 to VirtualX. */
    124185static int getMonitorIdFromName(const char *sMonitorName)
     
    270331}
    271332
     333static bool callVMWCTRL()
     334{
     335#ifndef OLD_JUNK
     336    const int hHeight = 600;
     337    const int hWidth = 800;
     338
     339    xXineramaScreenInfo *extents = (xXineramaScreenInfo *)malloc(x11Context.hOutputCount * sizeof(xXineramaScreenInfo));
     340    if (!extents)
     341        return false;
     342    int hRunningOffset = 0;
     343    for (int i = 0; i < x11Context.hOutputCount; ++i)
     344    {
     345        extents[i].x_org = hRunningOffset;
     346        extents[i].y_org = 0;
     347        extents[i].width = hWidth;
     348        extents[i].height = hHeight;
     349        hRunningOffset += hWidth;
     350    }
     351    return VMwareCtrlSetTopology(x11Context.pDisplay, x11Context.hVMWCtrlMajorOpCode,
     352                                 DefaultScreen(x11Context.pDisplay),
     353                                 extents, x11Context.hOutputCount);
     354#else
     355    return true;
     356#endif
     357}
     358
    272359static bool init()
    273360{
     
    275362    if (x11Context.pDisplay == NULL)
    276363        return false;
     364    callVMWCTRL();
    277365    if (RT_FAILURE(startX11MonitorThread()))
    278366        return false;
     
    302390        return;
    303391    if (!XQueryExtension(x11Context.pDisplay, "VMWARE_CTRL",
    304                          &x11Context.hVMWMajor, &dummy, &dummy))
     392                         &x11Context.hVMWCtrlMajorOpCode, &dummy, &dummy))
    305393    {
    306394        XCloseDisplay(x11Context.pDisplay);
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