wacom: apply display rotation to device
When an output is mapped to a device, match the device rotation with the output (bug #676170)
This commit is contained in:
parent
62f34db332
commit
1612735104
2 changed files with 37 additions and 2 deletions
|
@ -199,6 +199,17 @@ update_mapping (CcWacomMappingPanel *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
gsd_wacom_device_set_display (self->priv->device, monitor);
|
gsd_wacom_device_set_display (self->priv->device, monitor);
|
||||||
|
|
||||||
|
if (monitor >= 0) {
|
||||||
|
GsdWacomRotation rotation;
|
||||||
|
GSettings *settings;
|
||||||
|
|
||||||
|
rotation = gsd_wacom_device_get_display_rotation (self->priv->device);
|
||||||
|
settings = gsd_wacom_device_get_settings (self->priv->device);
|
||||||
|
g_settings_set_string (settings,
|
||||||
|
"rotation",
|
||||||
|
gsd_wacom_device_rotation_type_to_name (rotation));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -748,13 +748,34 @@ tabletmode_changed_cb (GtkComboBox *combo, gpointer user_data)
|
||||||
g_settings_set_boolean (priv->wacom_settings, "is-absolute", is_absolute);
|
g_settings_set_boolean (priv->wacom_settings, "is-absolute", is_absolute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const gchar*
|
||||||
|
opposite_rotation (const gchar *rotation)
|
||||||
|
{
|
||||||
|
/* Order matters here, if not found we return "none" */
|
||||||
|
static const gchar *rotations[] = { "half", "cw", "none", "ccw" };
|
||||||
|
guint i, n;
|
||||||
|
|
||||||
|
n = G_N_ELEMENTS (rotations);
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
if (strcmp (rotation, rotations[i]) == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rotations[(i + n / 2) % n];
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
left_handed_toggled_cb (GtkSwitch *sw, GParamSpec *pspec, gpointer *user_data)
|
left_handed_toggled_cb (GtkSwitch *sw, GParamSpec *pspec, gpointer *user_data)
|
||||||
{
|
{
|
||||||
CcWacomPagePrivate *priv = CC_WACOM_PAGE(user_data)->priv;
|
CcWacomPagePrivate *priv = CC_WACOM_PAGE(user_data)->priv;
|
||||||
|
GsdWacomDevice *device = priv->stylus;
|
||||||
|
GsdWacomRotation display_rotation;
|
||||||
const gchar* rotation;
|
const gchar* rotation;
|
||||||
|
|
||||||
rotation = gtk_switch_get_active (sw) ? "half" : "none";
|
display_rotation = gsd_wacom_device_get_display_rotation (device);
|
||||||
|
rotation = gsd_wacom_device_rotation_type_to_name (display_rotation);
|
||||||
|
if (gtk_switch_get_active (sw))
|
||||||
|
rotation = opposite_rotation (rotation);
|
||||||
|
|
||||||
g_settings_set_string (priv->wacom_settings, "rotation", rotation);
|
g_settings_set_string (priv->wacom_settings, "rotation", rotation);
|
||||||
}
|
}
|
||||||
|
@ -763,10 +784,13 @@ static void
|
||||||
set_left_handed_from_gsettings (CcWacomPage *page)
|
set_left_handed_from_gsettings (CcWacomPage *page)
|
||||||
{
|
{
|
||||||
CcWacomPagePrivate *priv = CC_WACOM_PAGE(page)->priv;
|
CcWacomPagePrivate *priv = CC_WACOM_PAGE(page)->priv;
|
||||||
|
GsdWacomDevice *device = priv->stylus;
|
||||||
|
GsdWacomRotation display_rotation;
|
||||||
const gchar* rotation;
|
const gchar* rotation;
|
||||||
|
|
||||||
|
display_rotation = gsd_wacom_device_get_display_rotation (device);
|
||||||
rotation = g_settings_get_string (priv->wacom_settings, "rotation");
|
rotation = g_settings_get_string (priv->wacom_settings, "rotation");
|
||||||
if (strcmp (rotation, "half") == 0)
|
if (strcmp (rotation, gsd_wacom_device_rotation_type_to_name (display_rotation)) != 0)
|
||||||
gtk_switch_set_active (GTK_SWITCH (WID ("switch-left-handed")), TRUE);
|
gtk_switch_set_active (GTK_SWITCH (WID ("switch-left-handed")), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue