VirtualBox

Changeset 60190 in vbox for trunk


Ignore:
Timestamp:
Mar 24, 2016 8:06:24 PM (9 years ago)
Author:
vboxsync
Message:

bugref:8087:8087: Additions/x11: support non-root X server: revert r106142: we still need to keep old, buggy versions of gnome-settings-daemon from seeing ACPI events when possible to prevent them from doing bad things.

Location:
trunk/src/VBox/Additions/x11/vboxvideo
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/vboxvideo/getmode.c

    r60133 r60190  
    228228
    229229#undef COMPARE_AND_MAYBE_SET
     230
     231#ifdef VBOXVIDEO_13
     232# ifdef RT_OS_LINUX
     233/** We have this for two purposes: one is to ensure that the X server is woken
     234 * up when we get a video ACPI event.  Two is to grab ACPI video events to
     235 * prevent gnome-settings-daemon from seeing them, as older versions ignored
     236 * the time stamp and handled them at the wrong time. */
     237static void acpiEventHandler(int fd, void *pvData)
     238{
     239    ScreenPtr pScreen = (ScreenPtr)pvData;
     240    VBOXPtr pVBox = VBOXGetRec(xf86Screens[pScreen->myNum]);
     241    struct input_event event;
     242    ssize_t rc;
     243
     244    do
     245        rc = read(fd, &event, sizeof(event));
     246    while (rc > 0 || (rc == -1 && errno == EINTR));
     247    /* Why do they return EAGAIN instead of zero bytes read like everyone else does? */
     248    VBVXASSERT(rc != -1 || errno == EAGAIN, ("Reading ACPI input event failed.\n"));
     249}
     250
     251void vbvxSetUpLinuxACPI(ScreenPtr pScreen)
     252{
     253    VBOXPtr pVBox = VBOXGetRec(xf86Screens[pScreen->myNum]);
     254    struct dirent *pDirent;
     255    DIR *pDir;
     256    int fd = -1;
     257
     258    if (pVBox->fdACPIDevices != -1 || pVBox->hACPIEventHandler != NULL)
     259        FatalError("ACPI input file descriptor not initialised correctly.\n");
     260    pDir = opendir("/dev/input");
     261    if (pDir == NULL)
     262        return;
     263    for (pDirent = readdir(pDir); pDirent != NULL; pDirent = readdir(pDir))
     264    {
     265        if (strncmp(pDirent->d_name, "event", sizeof("event") - 1) == 0)
     266        {
     267#define BITS_PER_BLOCK (sizeof(unsigned long) * 8)
     268            char szFile[64] = "/dev/input/";
     269            char szDevice[64] = "";
     270            unsigned long afKeys[KEY_MAX / BITS_PER_BLOCK];
     271
     272            strncat(szFile, pDirent->d_name, sizeof(szFile) - sizeof("/dev/input/"));
     273            if (fd != -1)
     274                close(fd);
     275            fd = open(szFile, O_RDONLY | O_NONBLOCK);
     276            if (   fd == -1
     277                || ioctl(fd, EVIOCGNAME(sizeof(szDevice)), szDevice) == -1
     278                || strcmp(szDevice, "Video Bus") != 0)
     279                continue;
     280            if (   ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(afKeys)), afKeys) == -1
     281                || ((   afKeys[KEY_SWITCHVIDEOMODE / BITS_PER_BLOCK]
     282                     >> KEY_SWITCHVIDEOMODE % BITS_PER_BLOCK) & 1) == 0)
     283                break;
     284            if (ioctl(fd, EVIOCGRAB, (void *)1) != 0)
     285                break;
     286            pVBox->hACPIEventHandler
     287                = xf86AddGeneralHandler(fd, acpiEventHandler, pScreen);
     288            if (pVBox->hACPIEventHandler == NULL)
     289                break;
     290            pVBox->fdACPIDevices = fd;
     291            fd = -1;
     292            break;
     293#undef BITS_PER_BLOCK
     294        }
     295    }
     296    if (fd != -1)
     297        close(fd);
     298    closedir(pDir);
     299}
     300
     301void vbvxCleanUpLinuxACPI(ScreenPtr pScreen)
     302{
     303    VBOXPtr pVBox = VBOXGetRec(xf86Screens[pScreen->myNum]);
     304    if (pVBox->fdACPIDevices != -1)
     305        close(pVBox->fdACPIDevices);
     306    pVBox->fdACPIDevices = -1;
     307    xf86RemoveGeneralHandler(pVBox->hACPIEventHandler);
     308    pVBox->hACPIEventHandler = NULL;
     309}
     310# endif /* RT_OS_LINUX */
     311#endif /* VBOXVIDEO_13 */
  • trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo.c

    r60180 r60190  
    141141        VBOXPtr pVBox = (VBOXPtr)xnfcalloc(sizeof(VBOXRec), 1);
    142142        pScrn->driverPrivate = pVBox;
     143#if defined(VBOXVIDEO_13) && defined(RT_OS_LINUX)
     144        pVBox->fdACPIDevices = -1;
     145#endif
    143146    }
    144147}
     
    10941097    TRACE_ENTRY();
    10951098
     1099    /* Initialise our guest library if possible: ignore failure. */
     1100    VbglR3Init();
    10961101    if (!VBOXMapVidMem(pScrn))
    10971102        return (FALSE);
     
    11341139    pScrn->vtSema = TRUE;
    11351140
     1141#if defined(VBOXVIDEO_13) && defined(RT_OS_LINUX)
     1142    vbvxSetUpLinuxACPI(pScreen);
     1143#endif
     1144
    11361145    if (!VBoxHGSMIIsSupported())
    11371146    {
     
    13331342
    13341343    pScreen->CloseScreen = pVBox->CloseScreen;
     1344#if defined(VBOXVIDEO_13) && defined(RT_OS_LINUX)
     1345    vbvxCleanUpLinuxACPI(pScreen);
     1346#endif
    13351347#ifndef XF86_SCRN_INTERFACE
    13361348    ret = pScreen->CloseScreen(pScreen->myNum, pScreen);
     
    13381350    ret = pScreen->CloseScreen(pScreen);
    13391351#endif
     1352    VbglR3Term();
    13401353    return ret;
    13411354}
  • trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo.h

    r60180 r60190  
    194194    /** Array of structures for receiving mode hints. */
    195195    VBVAMODEHINT *paVBVAModeHints;
    196 #ifndef VBOXVIDEO_13
     196#ifdef VBOXVIDEO_13
     197# ifdef RT_OS_LINUX
     198    /** Input device file descriptor for getting ACPI hot-plug events. */
     199    int fdACPIDevices;
     200    /** Input handler handle for ACPI hot-plug listener. */
     201    void *hACPIEventHandler;
     202# endif
     203#else
    197204    /** Has VBoxClient registered with us for setting video modes? */
    198205    bool fHaveVBoxClient;
     
    251258extern void vbvxReadSizesAndCursorIntegrationFromProperties(ScrnInfoPtr pScrn, bool *pfNeedUpdate);
    252259extern void vbvxReadSizesAndCursorIntegrationFromHGSMI(ScrnInfoPtr pScrn, bool *pfNeedUpdate);
     260extern void vbvxSetUpLinuxACPI(ScreenPtr pScreen);
     261extern void vbvxCleanUpLinuxACPI(ScreenPtr pScreen);
    253262
    254263/* EDID generation */
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