After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 766528 - wayland-outputs: Refactor event sending to ensure we're consistent
wayland-outputs: Refactor event sending to ensure we're consistent
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: wayland
unspecified
Other All
: Normal normal
: ---
Assigned To: mutter-maint
mutter-maint
Depends on:
Blocks:
 
 
Reported: 2016-05-16 18:38 UTC by Rui Matos
Modified: 2016-05-20 13:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
wayland-outputs: Refactor event sending to ensure we're consistent (10.18 KB, patch)
2016-05-16 18:38 UTC, Rui Matos
none Details | Review
wayland-outputs: Refactor event sending to ensure we're consistent (10.24 KB, patch)
2016-05-17 14:08 UTC, Rui Matos
committed Details | Review

Description Rui Matos 2016-05-16 18:38:23 UTC
This makes us behave the same both on bind and when an output
changes. In particular, we were not sending scale and done events on
output changes. We were also unconditionally sending mode events on
output changes even though these should only be sent if there is an
actual mode change.
Comment 1 Rui Matos 2016-05-16 18:38:28 UTC
Created attachment 328004 [details] [review]
wayland-outputs: Refactor event sending to ensure we're consistent
Comment 2 Jonas Ådahl 2016-05-17 00:45:25 UTC
Review of attachment 328004 [details] [review]:

::: src/wayland/meta-wayland-outputs.c
@@ +64,3 @@
+send_output (struct wl_resource *resource,
+             MetaWaylandOutput *wayland_output,
+             MetaMonitorInfo *monitor_info)

nit: "send_output" sounds like we are sending an output, but we are sending the output metadata/state/info. Maybe rename it to reflect that?

nit: While at it, align the function argument names.

@@ +79,3 @@
+  gboolean need_done = FALSE;
+
+  if (old_monitor_info == monitor_info ||

Shouldn't this be "!old_monitor_info || old_monitor_info != monitor_info"? Why would you always send the new state if the monitor info didn't change?

Reading the code some more it seems that "old_monitor_info" sometimes isn't the old monitor info, but the current one, since in the binding case it wasn't changed. That is a bit confusing. Maybe just have a flag to force the function to send all state, for the binding case?

@@ +99,3 @@
+    mode_flags |= WL_OUTPUT_MODE_PREFERRED;
+
+  if (old_monitor_info == monitor_info ||

Same as above.

@@ +115,3 @@
+  if (version >= WL_OUTPUT_SCALE_SINCE_VERSION)
+    {
+      if (old_monitor_info == monitor_info ||

Same as above.

@@ +164,3 @@
+static void
+wayland_output_set_monitor_info (MetaWaylandOutput *wayland_output,
+                                 MetaMonitorInfo *monitor_info)

nit: Align argument names.
Comment 3 Rui Matos 2016-05-17 14:08:48 UTC
Created attachment 328084 [details] [review]
wayland-outputs: Refactor event sending to ensure we're consistent

--

(In reply to Jonas Ådahl from comment #2)
> nit: "send_output" sounds like we are sending an output, but we are sending
> the output metadata/state/info. Maybe rename it to reflect that?

True, changed to send_output_events as that's literally what it does

> Shouldn't this be "!old_monitor_info || old_monitor_info != monitor_info"?

old_monitor_info won't ever be NULL here

> Why would you always send the new state if the monitor info didn't change?
>
> Reading the code some more it seems that "old_monitor_info" sometimes isn't
> the old monitor info, but the current one, since in the binding case it
> wasn't changed.

Right, that's what I intended

> That is a bit confusing. Maybe just have a flag to force the
> function to send all state, for the binding case?

Agreed, I changed it to have an explicit argument to send all events
for the bind case now.
Comment 4 Jonas Ådahl 2016-05-19 15:30:36 UTC
Review of attachment 328084 [details] [review]:

Looks good to me.
Comment 5 Olivier Fourdan 2016-05-19 15:42:41 UTC
I tested this patch and can attest it fixes the missing "output done" event (see https://bugs.freedesktop.org/show_bug.cgi?id=95491)
Comment 6 Rui Matos 2016-05-20 13:48:22 UTC
Attachment 328084 [details] pushed as 15300ae - wayland-outputs: Refactor event sending to ensure we're consistent