summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2016-06-22 19:17:40 +0200
committerCarlos Garnacho <carlosg@gnome.org>2016-07-20 19:27:24 +0200
commit6225cc6e6013e3707524249fb7e5ba720136e135 (patch)
tree5ce2789d65317abd5dd9d41449e67db3944e648a
parent4c4b40d4683a6bc9e0012ea267758f38644e4fd0 (diff)
downloadmutter-6225cc6e6013e3707524249fb7e5ba720136e135.tar.gz
core: Add meta_display_request_pad_osd() function
There may be external/compositor-specific reasons to trigger the pad OSD. Expose this call so the pad OSD can be triggered looking up the right settings, monitor, etc...
-rw-r--r--src/core/display-private.h2
-rw-r--r--src/core/display.c95
-rw-r--r--src/meta/display.h3
3 files changed, 98 insertions, 2 deletions
diff --git a/src/core/display-private.h b/src/core/display-private.h
index 531c6f70c..fa5fff454 100644
--- a/src/core/display-private.h
+++ b/src/core/display-private.h
@@ -277,6 +277,8 @@ struct _MetaDisplay
int xinput_event_base;
int xinput_opcode;
+ ClutterActor *current_pad_osd;
+
MetaStartupNotification *startup_notification;
int xsync_event_base;
diff --git a/src/core/display.c b/src/core/display.c
index 699326d91..7b09e4a2f 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -360,7 +360,9 @@ meta_display_class_init (MetaDisplayClass *klass)
* @display: the #MetaDisplay instance
* @pad: the pad device
* @settings: the pad device settings
+ * @layout_path: path to the layout image
* @edition_mode: Whether the OSD should be shown in edition mode
+ * @monitor_idx: Monitor to show the OSD on
*
* Requests the pad button mapping OSD to be shown.
*
@@ -371,8 +373,8 @@ meta_display_class_init (MetaDisplayClass *klass)
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, NULL, NULL, NULL,
- CLUTTER_TYPE_ACTOR, 3, CLUTTER_TYPE_INPUT_DEVICE,
- G_TYPE_SETTINGS, G_TYPE_BOOLEAN);
+ CLUTTER_TYPE_ACTOR, 5, CLUTTER_TYPE_INPUT_DEVICE,
+ G_TYPE_SETTINGS, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INT);
g_object_class_install_property (object_class,
PROP_FOCUS_WINDOW,
@@ -551,6 +553,27 @@ on_startup_notification_changed (MetaStartupNotification *sn,
g_signal_emit_by_name (display->screen, "startup-sequence-changed", sequence);
}
+static void
+check_pad_removed (MetaDisplay *display,
+ ClutterInputDevice *device,
+ ClutterDeviceManager *device_manager)
+{
+ ClutterInputDevice *pad;
+
+ if (!display->current_pad_osd)
+ return;
+
+ pad = g_object_get_data (G_OBJECT (display->current_pad_osd),
+ "meta-pad-osd-device");
+
+ if (pad == device)
+ {
+ /* Close pad OSD */
+ clutter_actor_destroy (display->current_pad_osd);
+ display->current_pad_osd = NULL;
+ }
+}
+
/**
* meta_display_open:
*
@@ -974,6 +997,10 @@ meta_display_open (void)
meta_idle_monitor_init_dbus ();
+ g_signal_connect_swapped (clutter_device_manager_get_default (),
+ "device-removed", G_CALLBACK (check_pad_removed),
+ display);
+
/* Done opening new display */
display->display_opening = FALSE;
@@ -3094,6 +3121,70 @@ meta_display_set_alarm_filter (MetaDisplay *display,
display->alarm_filter_data = data;
}
+void
+meta_display_request_pad_osd (MetaDisplay *display,
+ ClutterInputDevice *pad,
+ gboolean edition_mode)
+{
+ MetaInputSettings *input_settings;
+ const gchar *layout_path = NULL;
+ ClutterActor *osd;
+ MetaOutput *output;
+ gint monitor_idx;
+ GSettings *settings;
+#ifdef HAVE_LIBWACOM
+ WacomDevice *wacom_device;
+#endif
+
+ input_settings = meta_input_settings_get ();
+
+ if (display->current_pad_osd)
+ {
+ clutter_actor_destroy (display->current_pad_osd);
+ display->current_pad_osd = NULL;
+ }
+
+ if (input_settings)
+ {
+ settings = meta_input_settings_get_tablet_settings (input_settings, pad);
+ output = meta_input_settings_get_tablet_output (input_settings, pad);
+#ifdef HAVE_LIBWACOM
+ wacom_device = meta_input_settings_get_tablet_wacom_device (input_settings,
+ pad);
+ layout_path = libwacom_get_layout_filename (wacom_device);
+#endif
+ }
+
+ if (!layout_path || !settings)
+ return;
+
+ if (output && output->crtc)
+ {
+ monitor_idx = meta_screen_get_monitor_index_for_rect (display->screen,
+ &output->crtc->rect);
+ }
+ else
+ {
+ monitor_idx = meta_screen_get_current_monitor (display->screen);
+ }
+
+ g_signal_emit (display, display_signals[SHOW_PAD_OSD], 0,
+ pad, settings, layout_path,
+ edition_mode, monitor_idx, &osd);
+
+ if (osd)
+ {
+ display->current_pad_osd = osd;
+ g_object_set_data (G_OBJECT (display->current_pad_osd),
+ "meta-pad-osd-device", pad);
+ g_object_add_weak_pointer (G_OBJECT (display->current_pad_osd),
+ (gpointer *) &display->current_pad_osd);
+ clutter_actor_grab_key_focus (osd);
+ }
+
+ g_object_unref (settings);
+}
+
gchar *
meta_display_get_pad_action_label (MetaDisplay *display,
ClutterInputDevice *pad,
diff --git a/src/meta/display.h b/src/meta/display.h
index e6d8ba9f1..3d70d8dab 100644
--- a/src/meta/display.h
+++ b/src/meta/display.h
@@ -188,6 +188,9 @@ void meta_display_unfreeze_keyboard (MetaDisplay *display,
gboolean meta_display_is_pointer_emulating_sequence (MetaDisplay *display,
ClutterEventSequence *sequence);
+void meta_display_request_pad_osd (MetaDisplay *display,
+ ClutterInputDevice *pad,
+ gboolean edition_mode);
gchar * meta_display_get_pad_action_label (MetaDisplay *display,
ClutterInputDevice *pad,
MetaPadActionType action_type,