diff options
author | Chris Liddell <chris.liddell@artifex.com> | 2022-02-21 16:43:52 +0000 |
---|---|---|
committer | Chris Liddell <chris.liddell@artifex.com> | 2022-06-01 15:17:49 +0100 |
commit | 1030e59c64c93024c52fd7b33a8f5a4564c230ee (patch) | |
tree | 252aa470b2a4898e45240f901d8127c543d82d7f /devices/gdevxini.c | |
parent | 212fff3ade018a5969f97f70d094d71716a64710 (diff) | |
download | ghostpdl-1030e59c64c93024c52fd7b33a8f5a4564c230ee.tar.gz |
Bug 703308: Revise X11 devices to honour HWResolution
It was observed some time ago that some X11 implementations would crash or
(effectively) freeze if a sufficiently large area window was requested.
The original solution was to refuse requests to change the resolution, and clamp
the media size to the available screen area. The resulting behaviour means
some Postscript programs don't behave the manner one might expect.
This changes the code to allow changes in HWResolution then, again, clamps the
media size to the available screen area.
It still leaves (what I consider) slightly unexpected behaviour when we are
forced to clamp the values.
Diffstat (limited to 'devices/gdevxini.c')
-rw-r--r-- | devices/gdevxini.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/devices/gdevxini.c b/devices/gdevxini.c index fafcd42a8..fcaab232c 100644 --- a/devices/gdevxini.c +++ b/devices/gdevxini.c @@ -906,16 +906,22 @@ gdev_x_put_params(gx_device * dev, gs_param_list * plist) /* Get work area */ x_get_work_area(xdev, &area_width, &area_height); - /* Preserve screen resolution */ - dev->x_pixels_per_inch = values.x_pixels_per_inch; - dev->y_pixels_per_inch = values.y_pixels_per_inch; - dev->HWResolution[0] = values.HWResolution[0]; - dev->HWResolution[1] = values.HWResolution[1]; - - /* Recompute window size using screen resolution and available work area size*/ - /* pixels */ - dev->width = min(dev->width, area_width); - dev->height = min(dev->height, area_height); + /* Prioritize HWResolution over page size. If we can't fit the + page size at the requested resolution in the available screen + area, keep the resolution, clamp the page size. + This replaces the previous solution which refused requests to + change resolution at all. + */ + if (dev->width > area_width) { + outprintf(dev->memory, "\nWARNING: page width %f at %f dpi exceeds available area, clamping width to %f\n", + ((dev->width / 72.0) * dev->HWResolution[0]), dev->HWResolution[0], ((area_width / 72) * dev->HWResolution[0])); + dev->width = area_width; + } + if (dev->height > area_height) { + outprintf(dev->memory, "\nWARNING: page height %f at %f dpi exceeds available area, clamping height to %f\n", + ((dev->height / 72.0) * dev->HWResolution[1]), dev->HWResolution[1], ((area_height / 72) * dev->HWResolution[1])); + dev->height = area_height; + } if (dev->width <= 0 || dev->height <= 0) { emprintf3(dev->memory, "Requested pagesize %d x %d not supported by %s device\n", @@ -924,8 +930,8 @@ gdev_x_put_params(gx_device * dev, gs_param_list * plist) } /* points */ - dev->MediaSize[0] = (float)dev->width / xdev->x_pixels_per_inch * 72; - dev->MediaSize[1] = (float)dev->height / xdev->y_pixels_per_inch * 72; + dev->MediaSize[0] = (float)dev->width / dev->HWResolution[0] * 72; + dev->MediaSize[1] = (float)dev->height / dev->HWResolution[1] * 72; dw = dev->width - values.width; dh = dev->height - values.height; |