diff options
author | Matthias Clasen <mclasen@redhat.com> | 2010-04-09 09:05:38 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2010-04-09 09:05:38 -0400 |
commit | b4adea747780fb05a7923707fe431d924c2ada9d (patch) | |
tree | 93365e8be12bfdab2a2a7e88518ebce8b659878a /gdk/x11 | |
parent | f5344f8d930836262c81a70011970f2df6c19a08 (diff) | |
download | gtk+-b4adea747780fb05a7923707fe431d924c2ada9d.tar.gz |
Fix a silly mistake in primary_monitor handling
It doesn't make sense to determine an index into an array, if
you are going to sort the array afterwards...pointed out in
bug 615128 by Florian Scandella.
Diffstat (limited to 'gdk/x11')
-rw-r--r-- | gdk/x11/gdkscreen-x11.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c index f27d4ecf24..4a8fc68baf 100644 --- a/gdk/x11/gdkscreen-x11.c +++ b/gdk/x11/gdkscreen-x11.c @@ -763,21 +763,13 @@ init_randr13 (GdkScreen *screen) monitors = g_array_sized_new (FALSE, TRUE, sizeof (GdkX11Monitor), resources->noutput); - primary_output = XRRGetOutputPrimary (screen_x11->xdisplay, - screen_x11->xroot_window); - for (i = 0; i < resources->noutput; ++i) { XRROutputInfo *output = XRRGetOutputInfo (dpy, resources, resources->outputs[i]); - if (resources->outputs[i] == primary_output) - { - screen_x11->primary_monitor = i; - } - /* Non RandR1.2 X driver have output name "default" */ - randr12_compat |= !g_strcmp0(output->name, "default"); + randr12_compat |= !g_strcmp0 (output->name, "default"); if (output->connection == RR_Disconnected) { @@ -785,12 +777,6 @@ init_randr13 (GdkScreen *screen) continue; } - /* No RandR1.3+ available or no primary set, fall back to prefer LVDS as primary if present */ - if (primary_output == None && g_ascii_strncasecmp (output->name, "LVDS", 4) == 0) - { - screen_x11->primary_monitor = i; - } - if (output->crtc) { GdkX11Monitor monitor; @@ -834,9 +820,25 @@ init_randr13 (GdkScreen *screen) screen_x11->n_monitors = monitors->len; screen_x11->monitors = (GdkX11Monitor *)g_array_free (monitors, FALSE); + screen_x11->primary_monitor = 0; + + primary_output = XRRGetOutputPrimary (screen_x11->xdisplay, + screen_x11->xroot_window); + + for (i = 0; i < screen_x11->n_monitors; ++i) + { + if (screen_x11->monitors[i].output == primary_output) + screen_x11->primary_monitor = i; + + /* No RandR1.3+ available or no primary set, fall back to prefer LVDS as primary if present */ + if (primary_output == None && + g_ascii_strncasecmp (screen_x11->monitors[i].output_name, "LVDS", 4) == 0) + screen_x11->primary_monitor = i; + } + return screen_x11->n_monitors > 0; #endif - + return FALSE; } @@ -875,7 +877,9 @@ init_solaris_xinerama (GdkScreen *screen) monitors[i].x, monitors[i].y, monitors[i].width, monitors[i].height); } - + + screen_x11->primary_monitor = 0; + return TRUE; #endif /* HAVE_SOLARIS_XINERAMA */ @@ -922,6 +926,8 @@ init_xfree_xinerama (GdkScreen *screen) XFree (monitors); + screen_x11->primary_monitor = 0; + return TRUE; #endif /* HAVE_XFREE_XINERAMA */ @@ -1014,6 +1020,7 @@ init_multihead (GdkScreen *screen) /* No multihead support of any kind for this screen */ screen_x11->n_monitors = 1; screen_x11->monitors = g_new0 (GdkX11Monitor, 1); + screen_x11->primary_monitor = 0; init_monitor_geometry (screen_x11->monitors, 0, 0, WidthOfScreen (screen_x11->xscreen), |