wacom: Always try to add the stylus page UI on proximity

This used to be done only if the stylus was "brand new", because pages for
previously known styli are added when the tablet is detected/plugged. There
are however situations where this may break: eg. the stylus was previously
known through a tablet that is not plugged ATM. The tool is however "not
new" so no UI is added for it.

We should try to add the stylus invariably on proximity, add_stylus_page()
ensures there is only one page per tool anyway.

Closes: https://gitlab.gnome.org/GNOME/gnome-control-center/issues/315
This commit is contained in:
Carlos Garnacho 2018-12-20 13:31:59 +01:00 committed by Georges Basile Stavracas Neto
parent 2e250f9dc8
commit a4cc9d35b9

View file

@ -346,6 +346,7 @@ update_current_tool (CcWacomPanel *panel,
CcWacomTool *stylus;
GsdDevice *gsd_device;
guint64 serial, id;
gboolean added;
if (!tool)
return;
@ -375,8 +376,6 @@ update_current_tool (CcWacomPanel *panel,
wacom_device, serial);
if (!stylus) {
gboolean added;
id = gdk_device_tool_get_hardware_id (tool);
/* The wacom driver sends a hw id of 0x2 for stylus and 0xa
@ -395,24 +394,24 @@ update_current_tool (CcWacomPanel *panel,
stylus = cc_wacom_tool_new (serial, id, wacom_device);
if (!stylus)
return;
}
added = add_stylus (panel, stylus);
added = add_stylus (panel, stylus);
if (added) {
if (panel->stylus_notebook ==
gtk_stack_get_visible_child (GTK_STACK (panel->stack))) {
GtkWidget *widget;
gint page;
if (added) {
if (panel->stylus_notebook ==
gtk_stack_get_visible_child (GTK_STACK (panel->stack))) {
GtkWidget *widget;
gint page;
widget = g_hash_table_lookup (panel->stylus_pages, stylus);
page = gtk_notebook_page_num (GTK_NOTEBOOK (panel->stylus_notebook), widget);
gtk_notebook_set_current_page (GTK_NOTEBOOK (panel->stylus_notebook), page);
} else {
gtk_container_child_set (GTK_CONTAINER (panel->stack),
panel->stylus_notebook,
"needs-attention", TRUE,
NULL);
}
widget = g_hash_table_lookup (panel->stylus_pages, stylus);
page = gtk_notebook_page_num (GTK_NOTEBOOK (panel->stylus_notebook), widget);
gtk_notebook_set_current_page (GTK_NOTEBOOK (panel->stylus_notebook), page);
} else {
gtk_container_child_set (GTK_CONTAINER (panel->stack),
panel->stylus_notebook,
"needs-attention", TRUE,
NULL);
}
}