File gnome-control-center-bnc461755-randr-rotate-wacom.diff of Package gnome-control-center
bnc461755 - For tablets, call xsetwacom to rotate the stylus when the monitor is rotated
This also needs a change in the gnome-settings-daemon package.
diff --git a/capplets/display/display-capplet.glade b/capplets/display/display-capplet.glade
index 7500993..5e5bd85 100644
--- a/capplets/display/display-capplet.glade
+++ b/capplets/display/display-capplet.glade
@@ -524,6 +524,77 @@ Upside-down
<property name="fill">False</property>
</packing>
</child>
+
+ <child>
+ <widget class="GtkVBox" id="rotate-tablet-box">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">12</property>
+
+ <child>
+ <widget class="GtkLabel" id="label9">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Pressure-sensitive tablet</b></property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment3">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">1</property>
+ <property name="yscale">1</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">12</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkCheckButton" id="rotate-tablet">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Ro_tate tablet as well as the monitor</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="padding">0</property>
diff --git a/capplets/display/xrandr-capplet.c b/capplets/display/xrandr-capplet.c
index 0505d65..4144063 100644
--- a/capplets/display/xrandr-capplet.c
+++ b/capplets/display/xrandr-capplet.c
@@ -58,6 +58,8 @@ struct App
GtkWidget *panel_checkbox;
GtkWidget *clone_checkbox;
GtkWidget *show_icon_checkbox;
+ GtkWidget *rotate_tablet_box;
+ GtkWidget *rotate_tablet_checkbox;
GtkWidget *area;
gboolean ignore_gui_changes;
@@ -70,6 +72,8 @@ static gboolean output_overlaps (GnomeOutputInfo *output, GnomeRRConfig *config)
static void select_current_output_from_dialog_position (App *app);
static void monitor_on_off_toggled_cb (GtkToggleButton *toggle, gpointer data);
+#define ROTATE_TABLET_KEY "/apps/gnome_settings_daemon/xrandr/rotate_tablet_with_monitor"
+
static void
error_message (App *app, const char *primary_text, const char *secondary_text)
{
@@ -373,11 +377,12 @@ rebuild_rate_combo (App *app)
gtk_widget_set_sensitive (
app->refresh_combo, app->current_output && app->current_output->on);
- if (!(modes = get_current_modes (app)))
+ if (!app->current_output
+ || !(modes = get_current_modes (app)))
return;
rates = g_hash_table_new_full (
- g_str_hash, g_str_equal, (GFreeFunc)g_free, NULL);
+ g_str_hash, g_str_equal, (GFreeFunc) g_free, NULL);
best = -1;
for (i = 0; modes[i] != NULL; ++i)
@@ -514,6 +519,7 @@ rebuild_resolution_combo (App *app)
clear_combo (app->resolution_combo);
if (!(modes = get_current_modes (app))
+ || !app->current_output
|| !app->current_output->on)
{
gtk_widget_set_sensitive (app->resolution_combo, FALSE);
@@ -568,7 +574,7 @@ rebuild_gui (App *app)
app->ignore_gui_changes = TRUE;
- sensitive = app->current_output? TRUE : FALSE;
+ sensitive = app->current_output ? TRUE : FALSE;
#if 0
g_debug ("rebuild gui, is on: %d", app->current_output->on);
@@ -769,7 +775,7 @@ lay_out_outputs_horizontally (App *app)
x += output->width;
}
-
+
}
static void
@@ -1812,7 +1818,7 @@ get_nearest_output (GnomeRRConfig *configuration, int x, int y)
return configuration->outputs[nearest_index];
else
return NULL;
-
+
}
/* Gets the output that contains the largest intersection with the window.
@@ -1924,6 +1930,42 @@ hide_help_button (App *app)
}
static void
+rotate_tablet_toggled_cb (GtkToggleButton *button, gpointer data)
+{
+ App *app = data;
+
+ gconf_client_set_bool (app->client, ROTATE_TABLET_KEY, gtk_toggle_button_get_active (app->rotate_tablet_checkbox), NULL);
+}
+
+static gboolean
+tablet_is_present (void)
+{
+ char *path;
+
+ /* This heuristic *SUCKS*, but it will have to do for now */
+
+ path = g_find_program_in_path ("xsetwacom");
+ if (path) {
+ g_free (path);
+ return TRUE;
+ } else
+ return FALSE;
+}
+
+/* Make sure to call this function *before* connecting to app->rotate_tablet_checkbox's "toggled" signal */
+static void
+set_rotate_tablet_widgets (App *app)
+{
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->rotate_tablet_checkbox),
+ gconf_client_get_bool (app->client, ROTATE_TABLET_KEY, NULL));
+
+ if (tablet_is_present ())
+ gtk_widget_show_all (app->rotate_tablet_box);
+ else
+ gtk_widget_hide (app->rotate_tablet_box);
+}
+
+static void
run_application (App *app)
{
#ifndef GLADEDIR
@@ -2000,6 +2042,11 @@ run_application (App *app)
app->panel_checkbox = glade_xml_get_widget (xml, "panel_checkbox");
+ app->rotate_tablet_box = glade_xml_get_widget (xml, "rotate-tablet-box");
+ app->rotate_tablet_checkbox = glade_xml_get_widget (xml, "rotate-tablet");
+ set_rotate_tablet_widgets (app);
+ g_signal_connect (app->rotate_tablet_checkbox, "toggled", G_CALLBACK (rotate_tablet_toggled_cb), app);
+
make_text_combo (app->resolution_combo, 4);
make_text_combo (app->refresh_combo, 3);
make_text_combo (app->rotation_combo, -1);