diff options
author | Hans de Goede <hdegoede@redhat.com> | 2010-10-07 12:03:24 +0200 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2010-10-15 20:21:51 +0200 |
commit | f41a6c2ba6f6204fda4094750cc71b0faa893b46 (patch) | |
tree | 26c55265c4f42743e1de84a8501c56f27903a25a | |
parent | 3165fcead00f29eabab2133b11dfc2104099cc78 (diff) |
Change default virtual size to match the highest available resolution
With the old default virtual size of 1024x768, using higher resolutions
is not possible without an xorg.conf. Since the default now a days is
to not have an xorg.conf, this is sort of unfortunate.
This patch makes these higher resolutions available, while keeping the
default resolution used when none is specified through xorg.conf at
1024x786, so that the spice client window won't be way too large for
smaller screens by default.
Note that when running inside a vm with a qxl device with a 8MB
framebuffer the code, for automatically setting the virtualsize to the
largest width and height seen in the resolution list, would lead to a too
large virtual size. The 8MB list has both 1920x1080 and 1600x1200
resolution which lead to a virtualsize of 1920x1200 which does not fit,
there is a special check for this situation, which maximizes the available
width in this case. This means that for using 1600x1200 on an 8MB device
an xorg.conf is still necessary.
This change does come at the prize of using more memory, but that
seems like a reasonable price to pay to give us parity wrt supported
resolutions with the windows driver. Also this is a must have to allow
the to be written Linux agent to change the guest resolution to match
the client machines one when running in auto fullscreen mode.
In the long run we should add support for resizing the fb on the fly to
match the resolution.
-rw-r--r-- | src/qxl_driver.c | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/src/qxl_driver.c b/src/qxl_driver.c index 5942335..066794f 100644 --- a/src/qxl_driver.c +++ b/src/qxl_driver.c @@ -1516,6 +1516,8 @@ qxl_pre_init(ScrnInfoPtr pScrn, int flags) qxl_screen_t *qxl = NULL; ClockRangePtr clockRanges = NULL; int *linePitches = NULL; + DisplayModePtr mode; + unsigned int max_x = 0, max_y = 0; CHECK_POINT(); @@ -1572,20 +1574,34 @@ qxl_pre_init(ScrnInfoPtr pScrn, int flags) pScrn->monitor->nVrefresh = 1; } - if (pScrn->display->virtualX == 0 && pScrn->display->virtualY == 0) { - pScrn->display->virtualX = 1024; - pScrn->display->virtualY = 768; - } - /* Add any modes not in xorg's default mode list */ for (i = 0; i < qxl->num_modes; i++) - if (qxl->modes[i].orientation == 0) + if (qxl->modes[i].orientation == 0) { qxl_add_mode(pScrn, qxl->modes[i].x_res, qxl->modes[i].y_res, M_T_DRIVER); + if (qxl->modes[i].x_res > max_x) + max_x = qxl->modes[i].x_res; + if (qxl->modes[i].y_res > max_y) + max_y = qxl->modes[i].y_res; + } + + if (pScrn->display->virtualX == 0 && pScrn->display->virtualY == 0) { + /* It is possible for the largest x + largest y size combined leading + to a virtual size which will not fit into the framebuffer when this + happens we prefer max width and make height as large as possible */ + if (max_x * max_y * (pScrn->bitsPerPixel / 8) > + qxl->rom->surface0_area_size) + pScrn->display->virtualY = qxl->rom->surface0_area_size / + (max_x * (pScrn->bitsPerPixel / 8)); + else + pScrn->display->virtualY = max_y; + + pScrn->display->virtualX = max_x; + } if (0 >= xf86ValidateModes(pScrn, pScrn->monitor->Modes, pScrn->display->modes, clockRanges, linePitches, - 128, 2048, 128 * 4, 128, 2048, + 128, max_x, 128 * 4, 128, max_y, pScrn->display->virtualX, pScrn->display->virtualY, 128 * 1024 * 1024, LOOKUP_BEST_REFRESH)) @@ -1595,6 +1611,14 @@ qxl_pre_init(ScrnInfoPtr pScrn, int flags) xf86PruneDriverModes(pScrn); pScrn->currentMode = pScrn->modes; + /* If no modes are specified in xorg.conf, default to 1024x768 */ + if (pScrn->display->modes == NULL || pScrn->display->modes[0] == NULL) + for (mode = pScrn->modes; mode; mode = mode->next) + if (mode->HDisplay == 1024 && mode->VDisplay == 768) { + pScrn->currentMode = mode; + break; + } + xf86PrintModes(pScrn); xf86SetDpi(pScrn, 0, 0); |