VirtualBox

Changeset 27601 in vbox


Ignore:
Timestamp:
Mar 22, 2010 4:22:13 PM (15 years ago)
Author:
vboxsync
Message:

Additions/x11: VBoxClient now handles dynamic resizing using library calls, not a shell script, and for older server versions too

Location:
trunk/src/VBox/Additions
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/freebsd/Makefile.kmk

    r25592 r27601  
    135135fbsd_add_inst-nobin_MODE = a+r,u+w
    136136fbsd_add_inst-nobin_SOURCES = \
    137                 ../x11/Installer/VBoxRandR.sh \
    138137                ../x11/Installer/98vboxadd-xclient \
    139138                ../x11/Installer/vboxclient.desktop \
  • trunk/src/VBox/Additions/linux/Makefile.kmk

    r26551 r27601  
    110110
    111111VBOX_ADD_BIN.linux += \
    112         VBoxClient-all \
    113         VBoxRandR
     112        VBoxClient-all
    114113
    115114VBOX_ADD_STRIP_SBIN += \
     
    375374 LnxAdd-Nostrip-Bin_MODE    = a+rx,u+w
    376375 LnxAdd-Nostrip-Bin_SOURCES = \
    377         $(VBOX_REL_X11_ADD_INST)VBoxRandR.sh=>VBoxRandR \
    378376        $(VBOX_REL_X11_ADD_INST)98vboxadd-xclient=>VBoxClient-all
    379377
  • trunk/src/VBox/Additions/linux/installer/vboxadd-x11.sh

    r27507 r27601  
    297297    nopsaux="--nopsaux"
    298298    test -c /dev/psaux && nopsaux=""
    299     # And on newer servers, we want to test whether dynamic resizing will work
    300     testrandr="true"
    301299    # The video driver to install for X.Org 6.9+
    302300    vboxvideo_src=
     
    378376            vboxmouse_src=vboxmouse_drv_71.so
    379377            automouse=""
    380             testrandr=""
    381378            ;;
    382379        6.9.* | 7.0.* )
     
    385382            vboxmouse_src=vboxmouse_drv_70.so
    386383            automouse=""
    387             testrandr=""
    388384            ;;
    389385        6.7* | 6.8.* | 4.2.* | 4.3.* )
     
    395391            ln -s "$lib_dir/vboxmouse_drv.o" "$modules_dir/input/vboxmouse_drv.o"
    396392            automouse=""
    397             testrandr=""
    398393            succ_msg
    399394            ;;
     
    410405        ln -s "$lib_dir/$vboxmouse_src" "$modules_dir/input/vboxmouse_drv.so" &&
    411406        succ_msg
    412     fi
    413     if test -n "$testrandr"; then
    414         # Run VBoxRandR in test mode as it prints out useful information if
    415         # dynamic resizing can't be used.  Don't fail here though.
    416         /usr/bin/VBoxRandR --test 1>&2
    417     else
    418         cat << EOF
    419 
    420 You appear to be running an older version of the X Window system in your
    421 guest.  Seamless mode and dynamic resizing will not work!
    422 
    423 EOF
    424407    fi
    425408
  • trunk/src/VBox/Additions/solaris/Makefile.kmk

    r26641 r27601  
    111111        $(VBOX_PATH_X11_ADDITION_INSTALLER)/x11config15sol.pl \
    112112        $(VBOX_PATH_X11_ADDITION_INSTALLER)/x11restore.pl \
    113         $(VBOX_PATH_X11_ADDITION_INSTALLER)/VBoxRandR.sh \
    114113        $(VBOX_PATH_X11_ADDITION_INSTALLER)/98vboxadd-xclient=>1099.vboxclient \
    115114        $(VBOX_PATH_X11_ADDITION_INSTALLER)/solaris_xorg.conf \
     
    191190        x11config15sol.pl \
    192191        x11restore.pl \
    193         VBoxRandR.sh \
    194192        VBox.sh \
    195193        1099.vboxclient \
     
    266264                $(VBOX_PATH_X11_ADDITION_INSTALLER)/solaris_xorg.conf \
    267265                $(VBOX_PATH_X11_ADDITION_INSTALLER)/solaris_xorg_modeless.conf \
    268                 $(VBOX_PATH_X11_ADDITION_INSTALLER)/VBoxRandR.sh \
    269266                $(if $(VBOX_OSE),,$(VBOX_BRAND_LICENSE_TXT)) \
    270267                $(PATH_ROOT)/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.conf \
     
    289286        $(call MSG_L1,Creating install package: $@)
    290287        $(QUIET)$(MKDIR) -p $(SOLARIS_ADD_ETCFS_DIR)
    291         $(QUIET)$(LN_SYMLINK) -f ../..$(SOLARIS_VBOXADDINST_SUBDIR)/VBoxRandR.sh                              $(SOLARIS_ADD_USRBIN_DIR)/VBoxRandR
    292288        $(QUIET)$(LN_SYMLINK) -f ../..$(SOLARIS_VBOXADDINST_SUBDIR)/1099.vboxclient                           $(SOLARIS_ADD_USRBIN_DIR)/VBoxClient-all
    293289ifdef VBOX_WITH_COMBINED_SOLARIS_GUEST_PACKAGE
     
    382378
    383379#
    384 # Symlinks from /usr/bin/ to /opt/VirtualBoxAdditions (some like VBoxRandR created manually)
     380# Symlinks from /usr/bin/ to /opt/VirtualBoxAdditions
    385381#
    386382$(addprefix $(SOLARIS_ADD_USRBIN_DIR)/,$(SOLARIS_ADD_USRBIN_LINKS)): \
     
    512508                $(VBOX_PATH_X11_ADDITION_INSTALLER)/solaris_xorg_modeless.conf \
    513509                $(VBOX_SOLPACKFILES) \
    514                 $(VBOX_PATH_X11_ADDITION_INSTALLER)/VBoxRandR.sh \
    515510                $(if $(VBOX_OSE),,$(VBOX_BRAND_LICENSE_TXT)) \
    516511                $(PATH_ROOT)/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.conf \
     
    547542        $(QUIET)$(INSTALL) -m 0644 $(VBOX_PATH_X11_ADDITION_INSTALLER)/solaris_xorg.conf                    $(SOLARIS_ADD_INST_DIR)/solaris_xorg.conf
    548543        $(QUIET)$(INSTALL) -m 0644 $(VBOX_PATH_X11_ADDITION_INSTALLER)/solaris_xorg_modeless.conf           $(SOLARIS_ADD_INST_DIR)/solaris_xorg_modeless.conf
    549         $(QUIET)$(INSTALL) -m 0755 $(VBOX_PATH_X11_ADDITION_INSTALLER)/VBoxRandR.sh                         $(SOLARIS_ADD_INST_DIR)/VBoxRandR.sh
    550544        $(QUIET)$(INSTALL) -m 0644 $(PATH_ROOT)/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.conf  $(SOLARIS_ADD_INST_DIR)/vboxguest.conf
    551545ifdef VBOX_WITH_COMBINED_SOLARIS_GUEST_PACKAGE
  • trunk/src/VBox/Additions/x11/Installer/98vboxadd-xclient

    r23941 r27601  
    2727done
    2828
     29# Check whether the display we are running on running a known buggy version
     30# of X.Org which might crash when we resize.
     31no_display=
     32xorgbin=Xorg
     33found=`which Xorg | grep "no Xorg"`
     34if test ! -z "$found"; then
     35    if test -f "/usr/X11/bin/Xorg"; then
     36        xorgbin=/usr/X11/bin/Xorg
     37    else
     38        exit 1
     39    fi
     40fi
     41xout=`$xorgbin -version 2>&1`
     42if echo "$xout" | grep "1\.4\.99\.90[12345]" > /dev/null
     43then
     44    no_display=1
     45fi
     46
    2947/usr/bin/VBoxClient --clipboard
    3048/usr/bin/VBoxClient --checkhostversion
    31 /usr/bin/VBoxClient --display
     49test -z "$no_display" &&
     50    /usr/bin/VBoxClient --display
    3251/usr/bin/VBoxClient --seamless
  • trunk/src/VBox/Additions/x11/VBoxClient/Makefile.kmk

    r25473 r27601  
    5353        $(VBOX_LIB_IPRT_GUEST_R3) \
    5454        X11 \
     55        Xrandr \
    5556        Xt
    5657# These are static replacements for gcc-specific parts of libstdc++
  • trunk/src/VBox/Additions/x11/VBoxClient/display.cpp

    r26792 r27601  
    2929#include <X11/Xlib.h>
    3030#include <X11/cursorfont.h>
     31#include <X11/extensions/Xrandr.h>
    3132
    3233#include <iprt/assert.h>
     
    3940#include "VBoxClient.h"
    4041
    41 static int initDisplay()
     42static int initDisplay(Display *pDisplay)
    4243{
    4344    int rc = VINF_SUCCESS;
    44     int rcSystem, rcErrno;
    4545    uint32_t fMouseFeatures = 0;
    4646
    47     LogFlowFunc(("enabling dynamic resizing\n"));
    48     rcSystem = system("VBoxRandR --test");
    49     if (-1 == rcSystem)
    50     {
    51         rcErrno = errno;
    52         rc = RTErrConvertFromErrno(rcErrno);
    53     }
    54     if (RT_SUCCESS(rc))
    55     {
    56         if (0 != WEXITSTATUS(rcSystem))
    57             rc = VERR_NOT_SUPPORTED;
    58     }
     47    LogFlowFunc(("testing dynamic resizing\n"));
     48    int iDummy;
     49    if (!XRRQueryExtension(pDisplay, &iDummy, &iDummy))
     50        rc = VERR_NOT_SUPPORTED;
    5951    if (RT_SUCCESS(rc))
    6052        rc = VbglR3CtlFilterMask(VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST, 0);
     
    116108
    117109/**
     110 * This method first resets the current resolution using RandR to wake up
     111 * the graphics driver, then sets the resolution requested if it is among
     112 * those offered by the driver.
     113 */
     114static void setSize(Display *pDisplay, uint32_t cx, uint32_t cy)
     115{
     116    XRRScreenConfiguration *pConfig;
     117    XRRScreenSize *pSizes;
     118    int cSizes;
     119    pConfig = XRRGetScreenInfo(pDisplay, DefaultRootWindow(pDisplay));
     120    /* Reset the current mode */
     121    LogFlowFunc(("Setting size %ux%u\n", cx, cy));
     122    if (pConfig)
     123    {
     124        pSizes = XRRConfigSizes(pConfig, &cSizes);
     125        unsigned uDist = UINT32_MAX;
     126        int iMode = -1;
     127        for (int i = 0; i < cSizes; ++i)
     128        {
     129#define VBCL_SQUARE(x) (x) * (x)
     130            unsigned uThisDist =   VBCL_SQUARE(pSizes[i].width - cx)
     131                                 + VBCL_SQUARE(pSizes[i].height - cy);
     132            LogFlowFunc(("Found size %dx%d, distance %u\n", pSizes[i].width,
     133                         pSizes[i].height, uThisDist));
     134#undef VBCL_SQUARE
     135            if (uThisDist < uDist)
     136            {
     137                uDist = uThisDist;
     138                iMode = i;
     139            }
     140        }
     141        if (iMode >= 0)
     142        {
     143            Time config_timestamp = 0;
     144            XRRConfigTimes(pConfig, &config_timestamp);
     145            LogFlowFunc(("Setting new size %d\n", iMode));
     146            XRRSetScreenConfig(pDisplay, pConfig,
     147                               DefaultRootWindow(pDisplay), iMode,
     148                               RR_Rotate_0, config_timestamp);
     149        }
     150        XRRFreeScreenConfigInfo(pConfig);
     151    }
     152}
     153
     154/**
    118155 * Display change request monitor thread function.
    119156 * Before entering the loop, we re-read the last request
     
    122159 * stale.
    123160 */
    124 int runDisplay()
     161static int runDisplay(Display *pDisplay)
    125162{
    126163    LogFlowFunc(("\n"));
    127     Display *pDisplay = XOpenDisplay(NULL);
    128     if (pDisplay == NULL)
    129         return VERR_NOT_FOUND;
    130164    Cursor hClockCursor = XCreateFontCursor(pDisplay, XC_watch);
    131165    Cursor hArrowCursor = XCreateFontCursor(pDisplay, XC_left_ptr);
     
    140174                             | VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED,
    141175                             RT_INDEFINITE_WAIT, &fEvents);
     176        /* Jiggle the mouse pointer to wake up the driver. */
     177        XGrabPointer(pDisplay,
     178                     DefaultRootWindow(pDisplay), true, 0, GrabModeAsync,
     179                     GrabModeAsync, None, hClockCursor, CurrentTime);
     180        XFlush(pDisplay);
     181        XGrabPointer(pDisplay,
     182                     DefaultRootWindow(pDisplay), true, 0, GrabModeAsync,
     183                     GrabModeAsync, None, hArrowCursor, CurrentTime);
     184        XFlush(pDisplay);
     185        XUngrabPointer(pDisplay, CurrentTime);
     186        XFlush(pDisplay);
     187        /* And if it is a size hint, set the new size now that the video
     188         * driver has had a chance to update its list. */
    142189        if (RT_SUCCESS(rc) && (fEvents & VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST))
    143190        {
     
    149196                RTThreadYield();
    150197            else
    151                 system("VBoxRandR");
    152         }
    153         if (   RT_SUCCESS(rc)
    154             && (fEvents & VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED))
    155         {
    156             XGrabPointer(pDisplay,
    157                          DefaultRootWindow(pDisplay), true, 0, GrabModeAsync,
    158                          GrabModeAsync, None, hClockCursor, CurrentTime);
    159             XFlush(pDisplay);
    160             XGrabPointer(pDisplay,
    161                          DefaultRootWindow(pDisplay), true, 0, GrabModeAsync,
    162                          GrabModeAsync, None, hArrowCursor, CurrentTime);
    163             XFlush(pDisplay);
    164             XUngrabPointer(pDisplay, CurrentTime);
    165             XFlush(pDisplay);
     198                setSize(pDisplay, cx, cy);
    166199        }
    167200    }
     
    179212    virtual int run(bool fDaemonised /* = false */)
    180213    {
    181         int rc = initDisplay();
     214        Display *pDisplay = XOpenDisplay(NULL);
     215        if (!pDisplay)
     216            return VERR_NOT_FOUND;
     217        int rc = initDisplay(pDisplay);
    182218        if (RT_SUCCESS(rc))
    183             rc = runDisplay();
     219            rc = runDisplay(pDisplay);
     220        XCloseDisplay(pDisplay);
    184221        return rc;
    185222    }
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