[Xfce4-commits] <xfce4-settings:master> Improve calculation of screen sizes
Nick Schermer
noreply at xfce.org
Sat Aug 28 23:04:03 CEST 2010
Updating branch refs/heads/master
to b78da049cd645dd8c10f640b9ead314cbd8de2a8 (commit)
from 4aba3dde5eff169f833ba82a5e14a7ab0913de29 (commit)
commit b78da049cd645dd8c10f640b9ead314cbd8de2a8
Author: Lionel Le Folgoc <mrpouit at gmail.com>
Date: Thu Jun 10 20:11:28 2010 +0200
Improve calculation of screen sizes
Reevaluate them even when disabling an output, and take into account the
positions of the outputs.
xfce4-settings-helper/displays.c | 69 +++++++++++++++++++++++++++++---------
1 files changed, 53 insertions(+), 16 deletions(-)
diff --git a/xfce4-settings-helper/displays.c b/xfce4-settings-helper/displays.c
index 2a95f2f..450f26d 100644
--- a/xfce4-settings-helper/displays.c
+++ b/xfce4-settings-helper/displays.c
@@ -165,6 +165,43 @@ xfce_displays_helper_finalize (GObject *object)
#ifdef HAS_RANDR_ONE_POINT_TWO
+static void
+xfce_displays_helper_process_screen_size (Display *xdisplay,
+ GdkWindow *root_window,
+ gint mode_width,
+ gint mode_height,
+ gint crtc_pos_x,
+ gint crtc_pos_y,
+ gint *width,
+ gint *height,
+ gint *mm_width,
+ gint *mm_height)
+{
+ gdouble dpi = 0;
+
+ g_return_if_fail (xdisplay != NULL);
+ g_return_if_fail (root_window != NULL);
+
+ *width = MAX (*width, crtc_pos_x + mode_width);
+ *height = MAX (*height, crtc_pos_y + mode_height);
+
+ dpi = 25.4 * DisplayHeight (xdisplay, GDK_WINDOW_XID (root_window));
+ dpi /= DisplayHeightMM (xdisplay, GDK_WINDOW_XID (root_window));
+
+ if ((int) dpi == 0)
+ {
+ *mm_width = DisplayWidthMM (xdisplay, GDK_WINDOW_XID (root_window));
+ *mm_height = DisplayHeightMM (xdisplay, GDK_WINDOW_XID (root_window));
+ }
+ else
+ {
+ *mm_width = 25.4 * (*width) / dpi;
+ *mm_height = 25.4 * (*height) / dpi;
+ }
+}
+
+
+
static RRCrtc
xfce_displays_helper_find_crtc (Display *xdisplay,
XRRScreenResources *resources,
@@ -420,25 +457,25 @@ xfce_displays_helper_channel_apply (XfceDisplaysHelper *helper,
outputs = &resources->outputs[m];
}
+ /* get the sizes of the mode to enforce */
+ if (rot == RR_Rotate_90 || rot == RR_Rotate_270)
+ xfce_displays_helper_process_screen_size (xdisplay, root_window,
+ resources->modes[j].height,
+ resources->modes[j].width,
+ crtc_info->x, crtc_info->y,
+ &width, &height, &mm_width,
+ &mm_height);
+ else
+ xfce_displays_helper_process_screen_size (xdisplay, root_window,
+ resources->modes[j].width,
+ resources->modes[j].height,
+ crtc_info->x, crtc_info->y,
+ &width, &height, &mm_width,
+ &mm_height);
+
/* check if we really need to do something */
if (crtc_info->mode != mode || crtc_info->rotation != rot)
{
- /* 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 */
- if (rot == RR_Rotate_0 || rot == RR_Rotate_180)
- {
- width += resources->modes[j].width;
- height += resources->modes[j].height;
- }
- else
- {
- height += resources->modes[j].width;
- width += resources->modes[j].height;
- }
-
if (XRRSetCrtcConfig (xdisplay, resources, crtc,
crtc_info->timestamp, crtc_info->x, crtc_info->y,
mode, rot, outputs, noutput) != RRSetConfigSuccess)
More information about the Xfce4-commits
mailing list