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 701200 - Use OSD to configure the tablets' HW buttons
Use OSD to configure the tablets' HW buttons
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: wacom
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Joaquim Rocha
gnome-settings-daemon-maint
Depends on:
Blocks: 703148
 
 
Reported: 2013-05-29 15:46 UTC by Joaquim Rocha
Modified: 2013-07-24 09:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
wacom: Use the OSD window to edit the tablets' buttons (48.31 KB, patch)
2013-06-21 15:36 UTC, Joaquim Rocha
none Details | Review
wacom: Add libgd as a git submodule (2.14 KB, patch)
2013-07-15 09:58 UTC, Joaquim Rocha
rejected Details | Review
wacom: Include and link libgd when linking (1.94 KB, patch)
2013-07-15 09:59 UTC, Joaquim Rocha
rejected Details | Review
wacom: Use the OSD window to edit the tablets' buttons (57.15 KB, patch)
2013-07-15 10:02 UTC, Joaquim Rocha
none Details | Review
wacom: Move the OSD related key release processing to the GsdWacomOSDWindow (3.81 KB, patch)
2013-07-15 10:04 UTC, Joaquim Rocha
needs-work Details | Review
wacom: Use the OSD window to edit the tablets' buttons (56.52 KB, patch)
2013-07-15 10:36 UTC, Joaquim Rocha
needs-work Details | Review
wacom: Use the OSD window to edit the tablets' buttons (62.69 KB, patch)
2013-07-16 17:31 UTC, Joaquim Rocha
none Details | Review
wacom: Move the OSD related key release processing to the GsdWacomOSDWindow (3.74 KB, patch)
2013-07-16 17:32 UTC, Joaquim Rocha
accepted-commit_now Details | Review
wacom: Use the OSD window to edit the tablets' buttons (63.30 KB, patch)
2013-07-17 16:34 UTC, Joaquim Rocha
needs-work Details | Review
Screenshot #0 (220.49 KB, image/png)
2013-07-19 10:04 UTC, Joaquim Rocha
  Details
Screenshot #1 (222.59 KB, image/png)
2013-07-19 10:04 UTC, Joaquim Rocha
  Details
Screenshot #2 (221.57 KB, image/png)
2013-07-19 10:05 UTC, Joaquim Rocha
  Details
wacom: Use the OSD window to edit the tablets' buttons (63.68 KB, patch)
2013-07-22 17:31 UTC, Joaquim Rocha
needs-work Details | Review
wacom: Use the OSD window to edit the tablets' buttons (63.67 KB, patch)
2013-07-22 17:33 UTC, Joaquim Rocha
none Details | Review
wacom: Use the OSD window to edit the tablets' buttons (64.04 KB, patch)
2013-07-22 17:59 UTC, Joaquim Rocha
needs-work Details | Review
wacom: Use the OSD window to edit the tablets' buttons (65.06 KB, patch)
2013-07-23 14:24 UTC, Joaquim Rocha
needs-work Details | Review
wacom: Use the OSD window to edit the tablets' buttons (64.01 KB, patch)
2013-07-23 20:51 UTC, Joaquim Rocha
accepted-commit_now Details | Review

Description Joaquim Rocha 2013-05-29 15:46:21 UTC
The proposal can be found here:

https://mail.gnome.org/archives/gnomecc-list/2013-May/msg00002.html
Comment 1 Joaquim Rocha 2013-06-03 17:59:12 UTC
It would be wonderful if Jakub could come up with a fast sketch of what this assignation should look. As soon as I get it, I will implement this.

Adding ui-review.
Comment 2 Joaquim Rocha 2013-06-21 15:36:40 UTC
Created attachment 247461 [details] [review]
wacom: Use the OSD window to edit the tablets' buttons

This adds a new edition mode to the OSD window and two new widgets:
a button editor and the key shortcut button.

It is a big patch because it's a big change.
Comment 3 Joaquim Rocha 2013-06-21 16:53:03 UTC
Hi,

Here is a video showing the edition of buttons:
https://docs.google.com/file/d/0B9mCgEAuiw_IazFtOGdpWm9Zc00/edit?usp=sharing

(BTW, I moved the "old" configure button to the top when on edition mode but comments about this are welcome)
Comment 4 Jakub Steiner 2013-06-21 18:28:10 UTC
Wow, good work. The only thing I don't like is how the dialog remains open after the assignment (the editing itself is a modal). It would be nicer for the assignment to happen in spatial relation to the button.

As soon as you'd hit the button, along with the nice prelight, the label "None" would become a dropdown and the optional additional control in line on the right of it. I would either add a timer to allow correcting the shortcut or add an inline done button (that's different to the 'done editing' global one at the bottom).
Comment 5 Joaquim Rocha 2013-06-24 09:37:48 UTC
Hi Jakub,

About the modal, I can add a timeout as you say, and hide the editor widget if it remains untouched.

I'll try to put the action combo on top of the buttons' label but it'd be nice that you tried to sketch it because we got two widgets: the combo and the shortcut button. While this is not something complicated, we'll need to check how it looks when the OSD's control aren't on the left (i.e. the tablet is rotated).

Another thing that needs to be given some thought is the old button's assignation. I think that, ideally, when one has no button assigned to the help window, we could have the "Configure Buttons" button in the g-c-c page call the OSD window already in edition mode but the OSD belongs to g-s-d so I don't know how we can easily call it.

We'd only keep the old assignation code for tablet's that don't have a known layout (no OSD?).
Comment 6 Jakub Steiner 2013-06-24 11:54:23 UTC
I'll do my best to mock these up ASAP. 

As for the old assignment UI, we should really feel ashamed when we fall back to that. :) But yea, it's reasonable to have a fall back if we don't know the model.
Comment 7 Jakub Steiner 2013-07-09 18:17:49 UTC
Default OSD view — https://raw.github.com/gnome-design-team/gnome-mockups/master/system-settings/tablets/osd-cintiq-21UX-view.png

Edit button is a toggle:
https://raw.github.com/gnome-design-team/gnome-mockups/master/system-settings/tablets/osd-cintiq-21UX-edit-0.png

Pushing tablet button will fade out all other controls and provide a dropdown to select action. Hitting Esc or toggling the edit button will cancel the new assignment:
https://raw.github.com/gnome-design-team/gnome-mockups/master/system-settings/tablets/osd-cintiq-21UX-edit-1.png

Selecting 'send keystroke' will immediately foc the assignment entry and start listening to shortcuts:
https://raw.github.com/gnome-design-team/gnome-mockups/master/system-settings/tablets/osd-cintiq-21UX-edit-2.png

Right hand side buttons are a little eeky as the assignment will make labels/controls jump around, but still better than left aligning I think:
https://raw.github.com/gnome-design-team/gnome-mockups/master/system-settings/tablets/osd-cintiq-21UX-edit-3r.png
Comment 8 Joaquim Rocha 2013-07-15 09:58:42 UTC
Created attachment 249166 [details] [review]
wacom: Add libgd as a git submodule

It will be necessary for the Wacom plugin which will use the GdKeyShortcutButton.

I'm adding this patch because I don't know if the GtkKeyShortcutButton will be used of libgd's.
Comment 9 Joaquim Rocha 2013-07-15 09:59:02 UTC
Created attachment 249167 [details] [review]
wacom: Include and link libgd when linking
Comment 10 Joaquim Rocha 2013-07-15 10:02:50 UTC
Created attachment 249169 [details] [review]
wacom: Use the OSD window to edit the tablets' buttons

This adds a new edition mode to the OSD window and a new widget to edit the tablets' buttons.

Apart from eventual minor cosmetic changes, this should implement the behavior that Jakub has sketched up.
Comment 11 Joaquim Rocha 2013-07-15 10:04:31 UTC
Created attachment 249170 [details] [review]
wacom: Move the OSD related key release processing to the GsdWacomOSDWindow

Instead of doing it in the GsdWacomManager; this way, it gets more modular and
makes it easier for the OSD to process the keys.
Also changes what some keys do.

This is an important patch to go on top of 249169. I separated it because it deals only with how keys are processed.
Comment 12 Joaquim Rocha 2013-07-15 10:36:25 UTC
Created attachment 249178 [details] [review]
wacom: Use the OSD window to edit the tablets' buttons

This adds a new edition mode to the OSD window and a new widget to edit the tablets' buttons.

(This new version removes the "mapped" function which had mistakenly been left in when rebasing with master)
Comment 13 Bastien Nocera 2013-07-16 13:42:13 UTC
Review of attachment 249166 [details] [review]:

As mentioned on IRC, I'd rather whatever we needed in libgd (apparently just one widget) was in g-s-d directly.
Comment 14 Bastien Nocera 2013-07-16 13:42:35 UTC
Review of attachment 249167 [details] [review]:

As above.
Comment 15 Bastien Nocera 2013-07-16 13:45:45 UTC
Review of attachment 249170 [details] [review]:

::: plugins/wacom/gsd-wacom-manager.c
@@ +974,3 @@
 	/* Connect some signals to the OSD window */
+	g_signal_connect (widget, "destroy",
+			  G_CALLBACK(on_osd_window_destroyed), manager);

Or simply:
g_object_add_weak_pointer (G_OBJECT (widget), &manager->priv->osd_window);
Presumably destroying the window also unref's it, right?

::: plugins/wacom/gsd-wacom-osd-window.c
@@ +1589,3 @@
+	osd_window = GSD_WACOM_OSD_WINDOW (widget);
+
+	if (event->type != GDK_KEY_RELEASE)

This isn't an event handler, you need to chain up.
if (event->...)
  goto out;

and then in out: call the parent vfunc.
Comment 16 Bastien Nocera 2013-07-16 13:54:27 UTC
Review of attachment 249178 [details] [review]:

::: plugins/wacom/gsd-wacom-button-editor.c
@@ +1,2 @@
+/*
+ * Copyright © 2013 Red Hat, Inc.

Bonus points for UTF-8!

@@ +27,3 @@
+#include "gsd-wacom-button-editor.h"
+
+#define BACK_OPACITY                .8

0.8 please.

@@ +113,3 @@
+
+static void
+change_button_action_type (GsdWacomButtonEditor *self,

It looks like a lot of that code is the same as gnome-control-center but doesn't do thing like setting the OLED label.
Can that code be shared? If we're going to remove the button editing from gnome-control-center (to only use the OSD) then make sure that bug fixes are getting propagated before removing the g-c-c code.

::: plugins/wacom/gsd-wacom-key-shortcut-button.c
@@ +29,3 @@
+#define GSD_WACOM_KEY_SHORTCUT_BUTTON_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GSD_WACOM_KEY_SHORTCUT_BUTTON_TYPE, GsdWacomKeyShortcutButtonPrivate))
+
+G_DEFINE_TYPE (GsdWacomKeyShortcutButton, gsd_wacom_key_shortcut_button, GTK_TYPE_BUTTON);

Is this the button that would have been in libgd?

::: plugins/wacom/gsd-wacom-manager.c
@@ +923,3 @@
+
+	/* If it's in edition mode, we don't destroy the window */
+	g_object_get (widget, "edition-mode", &editing_mode, NULL);

Add an accessor for edition-mode to the window object directly.

::: plugins/wacom/gsd-wacom-osd-window.c
@@ +1245,3 @@
+	gchar       *message;
+
+	if (osd_window->priv->pad == NULL)

How come?

@@ +1260,3 @@
+	gchar       *message;
+
+	message = g_strdup_printf ("<big><b>%s</b></big>\n<span foreground=\"%s\">%s</span>",

return g_strdup_printf ()...

@@ +1922,3 @@
 	osd_window->priv = GSD_WACOM_OSD_WINDOW_GET_PRIVATE (osd_window);
 	osd_window->priv->cursor_timeout = 0;
+	gtk_widget_add_events (GTK_WIDGET (osd_window), GDK_ALL_EVENTS_MASK);

You don't need all events to capture keyboard events.
Comment 17 Joaquim Rocha 2013-07-16 17:31:32 UTC
Created attachment 249306 [details] [review]
wacom: Use the OSD window to edit the tablets' buttons

New version after Bastien's comments.
Comment 18 Joaquim Rocha 2013-07-16 17:32:17 UTC
Created attachment 249307 [details] [review]
wacom: Move the OSD related key release processing to the GsdWacomOSDWindow

... and the same for the keys commit.
Comment 19 Joaquim Rocha 2013-07-17 16:34:55 UTC
Created attachment 249420 [details] [review]
wacom: Use the OSD window to edit the tablets' buttons

New version after removing the old configure button that called g-c-c. Jakub explained to me that it is no longer necessary.
Comment 20 Joaquim Rocha 2013-07-19 10:04:07 UTC
Created attachment 249592 [details]
Screenshot #0
Comment 21 Joaquim Rocha 2013-07-19 10:04:35 UTC
Created attachment 249593 [details]
Screenshot #1
Comment 22 Joaquim Rocha 2013-07-19 10:05:18 UTC
Created attachment 249594 [details]
Screenshot #2

Series of screenshots with the latest implementation of this feature.
Comment 23 Bastien Nocera 2013-07-19 19:58:01 UTC
Review of attachment 249307 [details] [review]:

::: plugins/wacom/gsd-wacom-osd-window.c
@@ +1563,3 @@
+	osd_window = GSD_WACOM_OSD_WINDOW (widget);
+
+	if (event->type != GDK_KEY_RELEASE)

You don't need that, by definition, ->key_release_event will only receive key release events :)

@@ +1567,3 @@
+
+	if (osd_window->priv->edition_mode) {
+		if (event->keyval == GDK_KEY_Escape && !gtk_widget_get_visible (osd_window->priv->editor))

Split on two lines after the &&

@@ +1568,3 @@
+	if (osd_window->priv->edition_mode) {
+		if (event->keyval == GDK_KEY_Escape && !gtk_widget_get_visible (osd_window->priv->editor))
+			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (osd_window->priv->change_mode_button),

One line for that.
Comment 24 Bastien Nocera 2013-07-19 20:00:35 UTC
Review of attachment 249420 [details] [review]:

Will need to review the code still, that's a drive-by comment.

::: plugins/wacom/gsd-wacom-osd-window.c
@@ +1325,3 @@
+{
+	return g_strdup_printf ("<big><b>%s</b></big>\n<span foreground=\"%s\">%s</span>",
+				_("Push a button to configure"), INACTIVE_COLOR, _("(Esc to cancel)"));

Push? I would like to make it clear that the physical button on the tablet needs to be pressed to edit it. For a little while, I thought you meant clicking on the buttons in the OSD with a mouse (or stylus).
Comment 25 Bastien Nocera 2013-07-22 11:38:31 UTC
Review of attachment 249420 [details] [review]:

::: plugins/wacom/gsd-wacom-button-editor.c
@@ +74,3 @@
+  GtkCellView     *cell_view;
+  GtkCellRenderer *renderer;
+} ActivateCellAreaHelper;

That's not use anymore, is it?

@@ +92,3 @@
+  strv = g_settings_get_strv (button->settings, CUSTOM_ELEVATOR_ACTION_KEY);
+
+  if (strv != NULL)

That can never happen.

@@ +109,3 @@
+                       (const gchar * const*) strs);
+
+  g_clear_pointer (&strv, g_strfreev);

strv cannot be null

@@ +190,3 @@
+reset_shortcut_button_label (GsdWacomButtonEditor *self)
+{
+  gtk_button_set_label (GTK_BUTTON (self->priv->shortcut_button), _("None"));

This will need a context.

@@ +243,3 @@
+      strs[2] = NULL;
+      strs[0] = strs[1] = "";
+      strv = g_settings_get_strv (button->settings, CUSTOM_ELEVATOR_ACTION_KEY);

Can never be NULL.

@@ +313,3 @@
+  for (i = 0; i < G_N_ELEMENTS (action_table); i++)
+    {
+      if ((button->type == WACOM_TABLET_BUTTON_TYPE_STRIP ||

This really isn't readable, please split it up.

::: plugins/wacom/gsd-wacom-key-shortcut-button.c
@@ +27,3 @@
+
+/**
+ * SECTION:gtkkeyshortcutbutton

It's not gtk.

@@ +168,3 @@
+{
+  GsdWacomKeyShortcutButtonPrivate *priv;
+  GdkDevice *device, *keyb, *pointer;

*kbd;

@@ +189,3 @@
+    return;
+
+  if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)

All that event code isn't needed. Get the keyboard and pointer by looping over the devices from the display manager.

@@ +328,3 @@
+    }
+
+  tmp_event = priv->tmp_event;

I really don't understand what tmp_event is for.

@@ +340,3 @@
+
+  g_signal_emit (self, signals[KEY_SHORTCUT_EDITED], 0);
+

Extraneous line feed.

::: plugins/wacom/gsd-wacom-osd-window.c
@@ +828,3 @@
+		if (osd_button->priv->active) {
+			color_str = gsd_wacom_osd_button_get_color_str (osd_button);
+			buttons_section = g_strconcat (buttons_section,

g_strdup_printf would probably have been cleaner.

@@ +841,3 @@
+		} else if (osd_window_editing_button (osd_window) &&
+			   osd_button != osd_window->priv->current_button) {
+			buttons_section = g_strconcat (buttons_section,

Ditto.

@@ +1758,3 @@
+		gtk_widget_hide (priv->editor);
+
+		gsd_wacom_button_editor_set_button (GSD_WACOM_BUTTON_EDITOR (priv->editor), button, dir);

Remove the linefeeds above and below.

@@ +1809,3 @@
+						gtk_widget_hide (osd_window->priv->editor);
+
+						gsd_wacom_button_editor_set_button (GSD_WACOM_BUTTON_EDITOR (osd_window->priv->editor), tablet_button, dir);

Ditto.
Comment 26 Joaquim Rocha 2013-07-22 17:31:59 UTC
Created attachment 249821 [details] [review]
wacom: Use the OSD window to edit the tablets' buttons

New version.
Comment 27 Joaquim Rocha 2013-07-22 17:33:53 UTC
Created attachment 249822 [details] [review]
wacom: Use the OSD window to edit the tablets' buttons

Actually this one's better :)
Comment 28 Bastien Nocera 2013-07-22 17:39:30 UTC
Review of attachment 249821 [details] [review]:

It's just minor niggles now, apart from the tmp_event stuff which I still don't understand.

::: plugins/wacom/gsd-wacom-key-shortcut-button.c
@@ +194,3 @@
+      current_device = l->data;
+      if (!kbd && gdk_device_get_source (current_device) == GDK_SOURCE_KEYBOARD)
+        {

Remove the brace for one-line conditionals.

@@ +198,3 @@
+        }
+      else if (!pointer && gdk_device_get_source (current_device) == GDK_SOURCE_MOUSE)
+        {

Ditto.

@@ +335,3 @@
+    }
+
+  tmp_event = priv->tmp_event;

I still don't understand the tmp_event code.

::: plugins/wacom/gsd-wacom-osd-window.c
@@ +820,3 @@
 	buttons_section = g_strdup ("");
 	for (l = osd_window->priv->buttons; l != NULL; l = l->next) {
+		gchar *color_str, *css;

const char *css;
Comment 29 Joaquim Rocha 2013-07-22 17:59:05 UTC
Created attachment 249827 [details] [review]
wacom: Use the OSD window to edit the tablets' buttons

Hope we're there now ;)
Comment 30 Bastien Nocera 2013-07-23 13:07:02 UTC
Review of attachment 249827 [details] [review]:

::: plugins/wacom/gsd-wacom-key-shortcut-button.c
@@ +428,3 @@
+       * So, we keep track (with tmp_event) of the pressed keys if they're modifiers
+       * and so far and assign them when a key-release happens */
+      priv->tmp_event = (GdkEventKey *) gdk_event_copy ((GdkEvent *) event);

Seeing as you only use a few of the fields from the event, could you please copy those fields instead of the whole event?
It will make it easier to see which fields are of importance, and which are completely ignored.
Comment 31 Joaquim Rocha 2013-07-23 14:24:38 UTC
Created attachment 249895 [details] [review]
wacom: Use the OSD window to edit the tablets' buttons

New version.
Comment 32 Bastien Nocera 2013-07-23 15:47:23 UTC
Review of attachment 249895 [details] [review]:

::: plugins/wacom/gsd-wacom-key-shortcut-button.c
@@ +65,3 @@
+  GdkModifierType mods;
+  guint32 time;
+} ShortcutInfo;

As mentioned on IRC, the goal was to avoid allocating/deallocating a structure. Move those in GsdWacomKeyShortcutButtonPrivate instead.
Comment 33 Joaquim Rocha 2013-07-23 20:51:25 UTC
Created attachment 249941 [details] [review]
wacom: Use the OSD window to edit the tablets' buttons

New version.
Comment 34 Bastien Nocera 2013-07-23 21:32:28 UTC
Review of attachment 249941 [details] [review]:

Looks good.
Comment 35 Joaquim Rocha 2013-07-24 09:13:47 UTC
Pushed.

commit b9744e37a4ea263f5959b0f09642f3fabfb92a5c
commit e4df87580db38444a85e72c45d129ce78ff51db6