[Xfce4-commits] <xfce4-settings:master> Ensure that the screen size is sufficient
Nick Schermer
noreply at xfce.org
Sat Aug 28 23:02:16 CEST 2010
Updating branch refs/heads/master
to c7e6abe167519bf439752838d0c94c7c102fd2f1 (commit)
from 3094451e9b4831f8f27f5cbd95780308627bcdf8 (commit)
commit c7e6abe167519bf439752838d0c94c7c102fd2f1
Author: Lionel Le Folgoc <mrpouit at gmail.com>
Date: Sun Jun 6 00:06:18 2010 +0200
Ensure that the screen size is sufficient
xfce4-settings-helper/displays.c | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/xfce4-settings-helper/displays.c b/xfce4-settings-helper/displays.c
index b370251..6bc2200 100644
--- a/xfce4-settings-helper/displays.c
+++ b/xfce4-settings-helper/displays.c
@@ -174,6 +174,8 @@ xfce_displays_helper_channel_apply (XfceDisplaysHelper *helper,
GdkWindow *root_window;
XRRScreenResources *resources;
gchar property[512];
+ gint min_width, min_height, max_width, max_height;
+ gint mm_width, mm_height, width, height;
gint j, l, m, n, num_outputs, output_rot, noutput;
#ifdef HAS_RANDR_ONE_POINT_THREE
gint is_primary;
@@ -200,6 +202,17 @@ xfce_displays_helper_channel_apply (XfceDisplaysHelper *helper,
/* get the screen resource */
resources = XRRGetScreenResources (xdisplay, GDK_WINDOW_XID (root_window));
+ /* get the range of screen sizes */
+ if (XRRGetScreenSizeRange (xdisplay, GDK_WINDOW_XID (root_window), &min_width,
+ &min_height, &max_width, &max_height) != Success)
+ {
+ g_warning ("Unable to get the range of screen sizes, aborting.");
+ XRRFreeScreenResources (resources);
+ gdk_flush ();
+ gdk_error_trap_pop ();
+ return;
+ }
+
/* get the number of outputs */
g_snprintf (property, sizeof (property), "/%s/NumOutputs", scheme);
num_outputs = xfconf_channel_get_int (helper->channel, property, 0);
@@ -327,6 +340,24 @@ xfce_displays_helper_channel_apply (XfceDisplaysHelper *helper,
outputs = crtc_info->outputs;
}
+ /* do not change the screen size if the output is going to be disabled */
+ if (mode != None)
+ {
+ /* get the "physical sizes" of the output */
+ mm_width += output_info->mm_width;
+ mm_height += output_info->mm_height;
+
+ /* get the sizes of the mode to enforce */
+ width += resources->modes[j]->width;
+ height += resources->modes[j]->height;
+
+ /* set the screen size before apply the resolution, only if it's valid */
+ if (width >= min_width && width <= max_width
+ && height >= min_height && height <= max_height)
+ XRRSetScreenSize (xdisplay, GDK_WINDOW_XID (root_window),
+ width, height, mm_width, mm_height);
+ }
+
if (XRRSetCrtcConfig (xdisplay, resources, output_info->crtc,
crtc_info->timestamp, crtc_info->x, crtc_info->y,
mode, rot, outputs, noutput) != Success)
More information about the Xfce4-commits
mailing list