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 704797 - Add a DBus interface to the Wacom plugin and a method to show the OSD
Add a DBus interface to the Wacom plugin and a method to show the OSD
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: wacom
unspecified
Other All
: Normal normal
: ---
Assigned To: Joaquim Rocha
gnome-settings-daemon-maint
Depends on:
Blocks:
 
 
Reported: 2013-07-24 10:49 UTC by Joaquim Rocha
Modified: 2013-07-27 13:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
wacom: Add the gsd_wacom_osd_window_set_edition_mode method (2.10 KB, patch)
2013-07-24 10:49 UTC, Joaquim Rocha
committed Details | Review
wacom: Add a DBus interface and method to show the OSD window (7.08 KB, patch)
2013-07-24 10:53 UTC, Joaquim Rocha
needs-work Details | Review
wacom: Add a DBus interface and method to show the OSD window (6.66 KB, patch)
2013-07-26 15:20 UTC, Joaquim Rocha
none Details | Review
wacom: Add a DBus interface and method to show the OSD window (8.81 KB, patch)
2013-07-26 18:04 UTC, Bastien Nocera
committed Details | Review

Description Joaquim Rocha 2013-07-24 10:49:09 UTC
This is needed because, now that we can assign the buttons through the OSD, when click the g-c-c button to assign those, we should show the OSD if possible.
Comment 1 Joaquim Rocha 2013-07-24 10:49:11 UTC
Created attachment 250019 [details] [review]
wacom: Add the gsd_wacom_osd_window_set_edition_mode method
Comment 2 Bastien Nocera 2013-07-24 10:50:47 UTC
Review of attachment 250019 [details] [review]:

Looks good.
Comment 3 Joaquim Rocha 2013-07-24 10:53:29 UTC
Created attachment 250020 [details] [review]
wacom: Add a DBus interface and method to show the OSD window

There are 2 small problems with this patch that I haven't had the time to tackle yet (but wanted to share with you): 1) it takes too long to get a proxy for the DBus interface (around 1 minute) and 2) once the OSD is shown from the g-c-c, it flashes and then it's impossible to show it again (because the OSD Window isn't destroyed but is not visible, which should never happen).
I'll also attach another patch which ensures that the OSD window is always destroyed before showing it from the DBus handler.
Comment 4 Bastien Nocera 2013-07-24 10:59:12 UTC
Review of attachment 250020 [details] [review]:

::: plugins/wacom/gsd-wacom-manager.c
@@ +85,3 @@
+#define GSD_WACOM_DBUS_PATH GSD_DBUS_PATH "/Wacom"
+#define GSD_WACOM_DBUS_NAME GSD_DBUS_NAME ".Wacom"
+#define SET_OSD_VISIBILITY_DBUS_METHOD    "SetOSDVisibility"

No need for a constant for that.

@@ +122,3 @@
+        /* DBus */
+        GDBusNodeInfo   *introspection_data;
+        GDBusConnection *connection;

You're missing code in stop() to clean this up.

@@ +233,3 @@
+		}
+
+		if (visible ^ right_osd_window_visible) {

why "^"?
No braces for one-liner conditionals.

@@ +1781,3 @@
+
+        if (manager->priv->bus_cancellable == NULL ||
+            g_cancellable_is_cancelled (manager->priv->bus_cancellable)) {

That's not the correct way to check for cancellation.

@@ +1788,3 @@
+        connection = g_bus_get_finish (res, &error);
+
+        if (connection == NULL) {

Here you'd check for the error being G_IO_ERROR, G_IO_ERROR_CANCELLED.

@@ +1796,3 @@
+        manager->priv->connection = connection;
+
+        g_dbus_connection_register_object (connection,

You need to get the retval, and check it for errors, also make sure to unregister the object on stop.
Comment 5 Bastien Nocera 2013-07-24 11:00:47 UTC
(In reply to comment #3)
> Created an attachment (id=250020) [details] [review]
> wacom: Add a DBus interface and method to show the OSD window
> 
> There are 2 small problems with this patch that I haven't had the time to
> tackle yet (but wanted to share with you): 1) it takes too long to get a proxy
> for the DBus interface (around 1 minute)

Check for errors? This sounds like a timeout. I'm not sure how you tested this, but you might want to use the full gnome-settings-daemon binary with "-r" to replace your running instance.

> and 2) once the OSD is shown from the
> g-c-c, it flashes and then it's impossible to show it again (because the OSD
> Window isn't destroyed but is not visible, which should never happen).
> I'll also attach another patch which ensures that the OSD window is always
> destroyed before showing it from the DBus handler.
Comment 6 Joaquim Rocha 2013-07-26 11:20:19 UTC
(In reply to comment #4)
> Review of attachment 250020 [details] [review]:
> 
> ::: plugins/wacom/gsd-wacom-manager.c
> @@ +85,3 @@
> +#define GSD_WACOM_DBUS_PATH GSD_DBUS_PATH "/Wacom"
> +#define GSD_WACOM_DBUS_NAME GSD_DBUS_NAME ".Wacom"
> +#define SET_OSD_VISIBILITY_DBUS_METHOD    "SetOSDVisibility"
> 
> No need for a constant for that.

We're using the method name twice in the code. It's good not to repeat strings IMO.

> 
> @@ +122,3 @@
> +        /* DBus */
> +        GDBusNodeInfo   *introspection_data;
> +        GDBusConnection *connection;
> 
> You're missing code in stop() to clean this up.

Right. I missed that.

> 
> @@ +233,3 @@
> +        }
> +
> +        if (visible ^ right_osd_window_visible) {
> 
> why "^"?

Because we're using the toggle method (destroys the current OSD, if any, and brings up a new one) to control the OSD and it might be already visible, with the correct device displayed or not.
XOR between whether is should be visible and whether we got the right OSD visible is needed.

> No braces for one-liner conditionals.
> 
> @@ +1781,3 @@
> +
> +        if (manager->priv->bus_cancellable == NULL ||
> +            g_cancellable_is_cancelled (manager->priv->bus_cancellable)) {
> 
> That's not the correct way to check for cancellation.

I got most of this code from other plugins. What is the correct way?

> 
> @@ +1788,3 @@
> +        connection = g_bus_get_finish (res, &error);
> +
> +        if (connection == NULL) {
> 
> Here you'd check for the error being G_IO_ERROR, G_IO_ERROR_CANCELLED.

Right. I missed that too.

> 
> @@ +1796,3 @@
> +        manager->priv->connection = connection;
> +
> +        g_dbus_connection_register_object (connection,
> 
> You need to get the retval, and check it for errors, also make sure to
> unregister the object on stop.

Okay.

(In reply to comment #5)
> (In reply to comment #3)
> > Created an attachment (id=250020) [details] [review] [details] [review]
> > wacom: Add a DBus interface and method to show the OSD window
> > 
> > There are 2 small problems with this patch that I haven't had the time to
> > tackle yet (but wanted to share with you): 1) it takes too long to get a proxy
> > for the DBus interface (around 1 minute)
> 
> Check for errors? This sounds like a timeout. I'm not sure how you tested this,
> but you might want to use the full gnome-settings-daemon binary with "-r" to
> replace your running instance.

I do use --replace.
Comment 7 Joaquim Rocha 2013-07-26 15:20:57 UTC
Created attachment 250207 [details] [review]
wacom: Add a DBus interface and method to show the OSD window

New version. The OSD flashing error I mentioned is no longer happening after I rebased the source to include the change to a popup type window.
I still have the big waiting time till it gets the proxy.

About how I deal with the cancellable, I have based the code on the keyboard and xrandr's; please let me know how it should be handled then.
Comment 8 Bastien Nocera 2013-07-26 18:04:28 UTC
Created attachment 250220 [details] [review]
wacom: Add a DBus interface and method to show the OSD window
Comment 9 Bastien Nocera 2013-07-26 18:05:34 UTC
Attachment 250019 [details] pushed as 1b9d99f - wacom: Add the gsd_wacom_osd_window_set_edition_mode method
Attachment 250220 [details] pushed as 8b2f27e - wacom: Add a DBus interface and method to show the OSD window
Comment 10 Joaquim Rocha 2013-07-27 09:56:30 UTC
Hi,

I just tried your changes, with the dbus name being owned, and I still get that long waiting time till it gets the proxy. That's why I hadn't included the code to own the name, because I had tried it and didn't see any changes.

Have you tried this yourself? Does it work for you?
Comment 11 Bastien Nocera 2013-07-27 12:39:34 UTC
It works fine here.
Comment 12 Joaquim Rocha 2013-07-27 13:32:38 UTC
Okay, fair enough. It must be something in my system then.