VirtualBox

Changeset 93400 in vbox for trunk


Ignore:
Timestamp:
Jan 21, 2022 4:19:23 PM (3 years ago)
Author:
vboxsync
Message:

Additions: Linux: DRM: forgotten bits for display-helper-generic, bugref:10134.

Fixed code checker warning, updated logging (no need to specify log
prefix anymore), coding style.

File:
1 edited

Legend:

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

    r93380 r93400  
    4040#include <X11/Xlibint.h>
    4141
    42 /* A log prefix which is specific for this source file. */
    43 #define VBCL_HLP_LOG_PREFIX         "display-helper-generic "
    44 
    4542/** Name of Display Change Monitor thread. */
    4643#define VBCL_HLP_DCM_THREAD_NAME    "dcm-task"
    4744
    4845/** Display Change Monitor thread. */
    49 static RTTHREAD vbclHlpGenericDcmThread = NIL_RTTHREAD;
     46static RTTHREAD g_vbclHlpGenericDcmThread = NIL_RTTHREAD;
    5047
    5148/** Global flag which is triggered when service requested to shutdown. */
     
    166163static void vbcl_hlp_generic_process_display_change_event(Display *pDisplay)
    167164{
    168     int iCount, idxDisplay = 0;
     165    int iCount;
     166    uint32_t idxDisplay = 0;
    169167    XRRMonitorInfo *pMonitorsInfo = XRRGetMonitors(pDisplay, DefaultRootWindow(pDisplay), true, &iCount);
    170     if (pMonitorsInfo && iCount && iCount < VBOX_DRMIPC_MONITORS_MAX)
     168    if (pMonitorsInfo && iCount > 0 && iCount < VBOX_DRMIPC_MONITORS_MAX)
    171169    {
    172170        int rc;
     
    182180            if (RT_FAILURE(rc))
    183181            {
    184                 VBClLogError(VBCL_HLP_LOG_PREFIX "unable to fill monitors info list, rc=%Rrc\n", rc);
     182                VBClLogError("unable to fill monitors info list, rc=%Rrc\n", rc);
    185183                break;
    186184            }
     
    192190            char *pszMonitorName = XGetAtomName(pDisplay, pIter->pMonitorInfo->name);
    193191
    194             VBClLogVerbose(1, VBCL_HLP_LOG_PREFIX "reporting monitor %s offset: (%d, %d)\n",
     192            VBClLogVerbose(1, "reporting monitor %s offset: (%d, %d)\n",
    195193                        pszMonitorName, pIter->pMonitorInfo->x, pIter->pMonitorInfo->y);
    196194
     
    208206        if (g_pfnDisplayOffsetChangeCb)
    209207        {
    210             rc = g_pfnDisplayOffsetChangeCb(iCount, aDisplayOffsets);
     208            rc = g_pfnDisplayOffsetChangeCb(idxDisplay, aDisplayOffsets);
    211209            if (RT_FAILURE(rc))
    212                 VBClLogError(VBCL_HLP_LOG_PREFIX "unable to notify subscriber about monitors info change, rc=%Rrc\n", rc);
     210                VBClLogError("unable to notify subscriber about monitors info change, rc=%Rrc\n", rc);
    213211        }
    214212    }
    215213    else
    216         VBClLogError(VBCL_HLP_LOG_PREFIX "cannot get monitors info\n");
     214        VBClLogError("cannot get monitors info\n");
    217215}
    218216
     
    269267        else
    270268        {
    271             VBClLogError(VBCL_HLP_LOG_PREFIX "dcm monitor cannot find XRandr 1.3+ extension\n");
     269            VBClLogError("dcm monitor cannot find XRandr 1.3+ extension\n");
    272270            rc = VERR_NOT_AVAILABLE;
    273271        }
     
    277275    else
    278276    {
    279         VBClLogError(VBCL_HLP_LOG_PREFIX "dcm monitor cannot open X Display\n");
     277        VBClLogError("dcm monitor cannot open X Display\n");
    280278        rc = VERR_NOT_AVAILABLE;
    281279    }
     
    286284}
    287285
    288 RTDECL(int) vbcl_hlp_generic_start_display_change_monitor()
     286static void vbcl_hlp_generic_start_display_change_monitor()
    289287{
    290288    int rc;
     
    294292    {
    295293        /* Start thread which will monitor display change events. */
    296         rc = RTThreadCreate(&vbclHlpGenericDcmThread, vbcl_hlp_generic_display_change_event_monitor_worker, (void *)NULL, 0,
     294        rc = RTThreadCreate(&g_vbclHlpGenericDcmThread, vbcl_hlp_generic_display_change_event_monitor_worker, (void *)NULL, 0,
    297295                            RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, VBCL_HLP_DCM_THREAD_NAME);
    298296        if (RT_SUCCESS(rc))
    299297        {
    300             rc = RTThreadUserWait(vbclHlpGenericDcmThread, RT_MS_5SEC);
     298            rc = RTThreadUserWait(g_vbclHlpGenericDcmThread, RT_MS_5SEC);
    301299        }
    302300        else
    303             vbclHlpGenericDcmThread = NIL_RTTHREAD;
    304 
    305         VBClLogInfo(VBCL_HLP_LOG_PREFIX "attempt to start display change monitor thread, rc=%Rrc\n", rc);
     301            g_vbclHlpGenericDcmThread = NIL_RTTHREAD;
     302
     303        VBClLogInfo("attempt to start display change monitor thread, rc=%Rrc\n", rc);
    306304
    307305    }
    308306    else
    309         VBClLogInfo(VBCL_HLP_LOG_PREFIX "libXrandr not available, will not monitor display change events, rc=%Rrc\n", rc);
    310 
    311     return rc;
     307        VBClLogInfo("libXrandr not available, will not monitor display change events, rc=%Rrc\n", rc);
    312308}
    313309
     
    331327            {
    332328                XRRSetOutputPrimary(pDisplay, DefaultRootWindow(pDisplay), pScreenResources->outputs[idDisplay]);
    333                 VBClLogInfo(VBCL_HLP_LOG_PREFIX "display %u has been set as primary\n", idDisplay);
     329                VBClLogInfo("display %u has been set as primary\n", idDisplay);
    334330                rc = VINF_SUCCESS;
    335331            }
    336332            else
    337                 VBClLogError(VBCL_HLP_LOG_PREFIX "cannot set display %u as primary: index out of range\n", idDisplay);
     333                VBClLogError("cannot set display %u as primary: index out of range\n", idDisplay);
    338334
    339335            XRRFreeScreenResources(pScreenResources);
    340336        }
    341337        else
    342             VBClLogError(VBCL_HLP_LOG_PREFIX "cannot set display %u as primary: libXrandr can not get screen resources\n", idDisplay);
     338            VBClLogError("cannot set display %u as primary: libXrandr can not get screen resources\n", idDisplay);
    343339
    344340        XCloseDisplay(pDisplay);
    345341    }
    346342    else
    347         VBClLogError(VBCL_HLP_LOG_PREFIX "cannot set display %u as primary: cannot connect to X11\n", idDisplay);
     343        VBClLogError("cannot set display %u as primary: cannot connect to X11\n", idDisplay);
    348344
    349345    return rc;
     
    368364    ASMAtomicWriteBool(&g_fShutdown, false);
    369365
    370     /* Attempt to start display change events monitor. Ignore rc,
    371      * error will be printed inside function anyway. */
    372     (void)vbcl_hlp_generic_start_display_change_monitor();
     366    /* Attempt to start display change events monitor. */
     367    vbcl_hlp_generic_start_display_change_monitor();
    373368
    374369    /* Always return positive status for generic (fallback, last resort) helper. */
     
    383378    int rc = VINF_SUCCESS;
    384379
    385     if (vbclHlpGenericDcmThread != NIL_RTTHREAD)
     380    if (g_vbclHlpGenericDcmThread != NIL_RTTHREAD)
    386381    {
    387382        /* Signal thread we are going to shutdown. */
     
    389384
    390385        /* Wait for thread to terminate gracefully. */
    391         rc = RTThreadWait(vbclHlpGenericDcmThread, RT_MS_5SEC, NULL);
     386        rc = RTThreadWait(g_vbclHlpGenericDcmThread, RT_MS_5SEC, NULL);
    392387    }
    393388
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