Commit 0b0f1101 authored by Alexander Larsson's avatar Alexander Larsson

Avoid spurious emissions of monitors-changed

The monitor change detection code in _gdk_x11_screen_size_changed() and
process_monitors_change() goes to some length to make sure its only emitted
when there is an actual change to the data visible via the GdkScreen monitors
api.

However, commit 662e69ad added some code that always emits "monitors-changed"
in _gdk_x11_screen_size_changed when we have randr13 and get a ConfigureNotify
on the root window (even though we may already have emitted it in the
RRScreenChangesNotify event!).

As far as I can tell this is due to a comment in the bug referenced by the
commit (https://bugzilla.gnome.org/show_bug.cgi?id=601712#c4) where it says:

  This version of the patch changes GdkDisplay to emit "monitors-changed" when
  the primary monitor changes (see the change in _gdk_x11_screen_size_changed).

And, if you remove this part of the change the signal is not emitted when just
the primary is changed. However, this is not really the right approach. We
should just also check for if the primary changes in process_monitors_change()
to avoid spurious signal emissions.

https://bugzilla.gnome.org/show_bug.cgi?id=643216
parent 66e23b3a
......@@ -867,9 +867,11 @@ process_monitors_change (GdkScreen *screen)
{
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
gint n_monitors;
gint primary_monitor;
GdkX11Monitor *monitors;
gboolean changed;
primary_monitor = x11_screen->primary_monitor;
n_monitors = x11_screen->n_monitors;
monitors = x11_screen->monitors;
......@@ -878,8 +880,11 @@ process_monitors_change (GdkScreen *screen)
init_multihead (screen);
changed = !compare_monitors (monitors, n_monitors,
x11_screen->monitors, x11_screen->n_monitors);
changed =
!compare_monitors (monitors, n_monitors,
x11_screen->monitors, x11_screen->n_monitors) ||
x11_screen->primary_monitor != primary_monitor;
free_monitors (monitors, n_monitors);
......@@ -903,10 +908,7 @@ _gdk_x11_screen_size_changed (GdkScreen *screen,
display_x11 = GDK_X11_DISPLAY (gdk_screen_get_display (screen));
if (display_x11->have_randr13 && event->type == ConfigureNotify)
{
g_signal_emit_by_name (screen, "monitors-changed");
return;
}
return;
XRRUpdateConfiguration (event);
#else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment