[gnome-panel/wip-warnings-next: 10/20] multiscreen: reformat code
- From: Sebastian Geiger <segeiger src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/wip-warnings-next: 10/20] multiscreen: reformat code
- Date: Tue, 25 Feb 2020 14:40:00 +0000 (UTC)
commit 16efff5e653d19424f33b619af215b5e8f69fd0b
Author: Sebastian Geiger <sbastig gmx net>
Date: Tue Feb 25 11:49:52 2020 +0100
multiscreen: reformat code
gnome-panel/panel-multiscreen.c | 172 ++++++++++++++++++++--------------------
1 file changed, 88 insertions(+), 84 deletions(-)
---
diff --git a/gnome-panel/panel-multiscreen.c b/gnome-panel/panel-multiscreen.c
index 82da2f333..fb52e6e7b 100644
--- a/gnome-panel/panel-multiscreen.c
+++ b/gnome-panel/panel-multiscreen.c
@@ -272,108 +272,112 @@ panel_multiscreen_get_raw_monitors_for_screen (int *monitors_ret,
static inline gboolean
rectangle_overlaps (GdkRectangle *a,
- GdkRectangle *b)
+ GdkRectangle *b)
{
- return gdk_rectangle_intersect (a, b, NULL);
+ return gdk_rectangle_intersect (a, b, NULL);
}
static long
pixels_in_rectangle (GdkRectangle *r)
{
- return (long) (r->width * r->height);
+ return (long) (r->width * r->height);
}
static void
panel_multiscreen_compress_overlapping_monitors (int *num_monitors_inout,
- GdkRectangle **geometries_inout)
+ GdkRectangle **geometries_inout)
{
- int num_monitors;
- GdkRectangle *monitor_geometries;
- int i;
-
- num_monitors = *num_monitors_inout;
- monitor_geometries = *geometries_inout;
-
- /* http://bugzilla.gnome.org/show_bug.cgi?id=530969
- * https://bugzilla.novell.com/show_bug.cgi?id=310208
- * and many other such bugs...
- *
- * RANDR sometimes gives us monitors that overlap (i.e. outputs whose
- * bounding rectangles overlap). This is sometimes right and sometimes
- * wrong:
- *
- * * Right - two 1024x768 outputs at the same offset (0, 0) that show
- * the same thing. Think "laptop plus projector with the same
- * resolution".
- *
- * * Wrong - one 1280x1024 output ("laptop internal LCD") and another
- * 1024x768 output ("external monitor"), both at offset (0, 0).
- * There is no way for the monitor with the small resolution to
- * show the complete image from the laptop's LCD, unless one uses
- * panning (but nobody wants panning, right!?).
- *
- * With overlapping monitors, we may end up placing the panel with
- * respect to the "wrong" one. This is always wrong, as the panel
- * appears "in the middle of the screen" of the monitor with the
- * smaller resolution, instead of at the edge.
- *
- * Our strategy is to find the subsets of overlapping monitors, and
- * "compress" each such set to being like if there were a single
- * monitor with the biggest resolution of each of that set's monitors.
- * Say we have four monitors
- *
- * A, B, C, D
- *
- * where B and D overlap. In that case, we'll generate a new list that
- * looks like
- *
- * A, MAX(B, D), C
- *
- * with three monitors.
- *
- * NOTE FOR THE FUTURE: We could avoid most of this mess if we had a
- * concept of a "primary monitor". Also, we could look at each
- * output's name or properties to see if it is the built-in LCD in a
- * laptop. However, with GTK+ 2.14.x we don't get output names, since
- * it gets the list outputs from Xinerama, not RANDR (and Xinerama
- * doesn't provide output names).
- */
-
- for (i = 0; i < num_monitors; i++) {
- long max_pixels;
- int j;
+ int num_monitors;
+ GdkRectangle *monitor_geometries;
+ int i;
- max_pixels = pixels_in_rectangle (&monitor_geometries[i]);
+ num_monitors = *num_monitors_inout;
+ monitor_geometries = *geometries_inout;
- j = i + 1;
+ /* http://bugzilla.gnome.org/show_bug.cgi?id=530969
+ * https://bugzilla.novell.com/show_bug.cgi?id=310208
+ * and many other such bugs...
+ *
+ * RANDR sometimes gives us monitors that overlap (i.e. outputs whose
+ * bounding rectangles overlap). This is sometimes right and sometimes
+ * wrong:
+ *
+ * * Right - two 1024x768 outputs at the same offset (0, 0) that show
+ * the same thing. Think "laptop plus projector with the same
+ * resolution".
+ *
+ * * Wrong - one 1280x1024 output ("laptop internal LCD") and another
+ * 1024x768 output ("external monitor"), both at offset (0, 0).
+ * There is no way for the monitor with the small resolution to
+ * show the complete image from the laptop's LCD, unless one uses
+ * panning (but nobody wants panning, right!?).
+ *
+ * With overlapping monitors, we may end up placing the panel with
+ * respect to the "wrong" one. This is always wrong, as the panel
+ * appears "in the middle of the screen" of the monitor with the
+ * smaller resolution, instead of at the edge.
+ *
+ * Our strategy is to find the subsets of overlapping monitors, and
+ * "compress" each such set to being like if there were a single
+ * monitor with the biggest resolution of each of that set's monitors.
+ * Say we have four monitors
+ *
+ * A, B, C, D
+ *
+ * where B and D overlap. In that case, we'll generate a new list that
+ * looks like
+ *
+ * A, MAX(B, D), C
+ *
+ * with three monitors.
+ *
+ * NOTE FOR THE FUTURE: We could avoid most of this mess if we had a
+ * concept of a "primary monitor". Also, we could look at each
+ * output's name or properties to see if it is the built-in LCD in a
+ * laptop. However, with GTK+ 2.14.x we don't get output names, since
+ * it gets the list outputs from Xinerama, not RANDR (and Xinerama
+ * doesn't provide output names).
+ */
- while (j < num_monitors) {
- if (rectangle_overlaps (&monitor_geometries[i],
- &monitor_geometries[j])) {
- long pixels;
+ for (i = 0; i < num_monitors; i++)
+ {
+ long max_pixels;
+ int j;
- pixels = pixels_in_rectangle (&monitor_geometries[j]);
- if (pixels > max_pixels) {
- max_pixels = pixels;
- /* keep the maximum */
- monitor_geometries[i] = monitor_geometries[j];
- }
+ max_pixels = pixels_in_rectangle (&monitor_geometries[i]);
- /* Shift the remaining monitors to the left */
- if (num_monitors - j - 1 > 0)
- memmove (&monitor_geometries[j],
- &monitor_geometries[j + 1],
- sizeof (monitor_geometries[0]) * (num_monitors - j - 1));
+ j = i + 1;
- num_monitors--;
- g_assert (num_monitors > 0);
- } else
- j++;
- }
- }
+ while (j < num_monitors)
+ {
+ if (rectangle_overlaps (&monitor_geometries[i],
+ &monitor_geometries[j]))
+ {
+ long pixels;
+
+ pixels = pixels_in_rectangle (&monitor_geometries[j]);
+ if (pixels > max_pixels)
+ {
+ max_pixels = pixels;
+ /* keep the maximum */
+ monitor_geometries[i] = monitor_geometries[j];
+ }
+
+ /* Shift the remaining monitors to the left */
+ if (num_monitors - j - 1 > 0)
+ memmove (&monitor_geometries[j],
+ &monitor_geometries[j + 1],
+ sizeof (monitor_geometries[0]) * (num_monitors - j - 1));
+
+ num_monitors--;
+ g_assert (num_monitors > 0);
+ } else
+ j++;
+ }
+ }
- *num_monitors_inout = num_monitors;
- *geometries_inout = monitor_geometries;
+ *num_monitors_inout = num_monitors;
+ *geometries_inout = monitor_geometries;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]