[gimp] app: update when device axes/keys change.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: update when device axes/keys change.
- Date: Tue, 8 Dec 2020 22:20:22 +0000 (UTC)
commit 1c06751c08c41df39a027592a7d52755445843e1
Author: Jehan <jehan girinstud io>
Date: Tue Dec 8 23:17:23 2020 +0100
app: update when device axes/keys change.
Earlier code was assuming it should not happen. Actually it can happen,
in particular with virtual devices (on which several physical devices
can be attached and switching to one or the other would update the
virtual device to mimick its features).
app/widgets/gimpdeviceinfo.c | 41 +++++++++++++++++++++++++++++++++++++----
1 file changed, 37 insertions(+), 4 deletions(-)
---
diff --git a/app/widgets/gimpdeviceinfo.c b/app/widgets/gimpdeviceinfo.c
index 80fe2d2af6..3ca8edf74c 100644
--- a/app/widgets/gimpdeviceinfo.c
+++ b/app/widgets/gimpdeviceinfo.c
@@ -126,6 +126,8 @@ static void gimp_device_info_guess_icon (GimpDeviceInfo *info);
static void gimp_device_info_tool_changed (GdkDevice *device,
GdkDeviceTool *tool,
GimpDeviceInfo *info);
+static void gimp_device_info_device_changed (GdkDevice *device,
+ GimpDeviceInfo *info);
static void gimp_device_info_updated (GimpDeviceInfo *info);
@@ -306,7 +308,18 @@ gimp_device_info_set_property (GObject *object,
switch (property_id)
{
case PROP_DEVICE:
+ /* Nothing to disconnect, it's G_PARAM_CONSTRUCT_ONLY. */
info->priv->device = g_value_get_object (value);
+
+ if (info->priv->device)
+ {
+ g_signal_connect_object (info->priv->device, "tool-changed",
+ G_CALLBACK (gimp_device_info_tool_changed),
+ G_OBJECT (info), 0);
+ g_signal_connect_object (info->priv->device, "changed",
+ G_CALLBACK (gimp_device_info_device_changed),
+ G_OBJECT (info), 0);
+ }
break;
case PROP_DISPLAY:
@@ -329,7 +342,9 @@ gimp_device_info_set_property (GObject *object,
if (device)
{
- if (info->priv->n_axes != 0 && info->priv->n_axes != n_device_values)
+ if (info->priv->n_axes != 0 &&
+ gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_MASTER &&
+ info->priv->n_axes != n_device_values)
g_printerr ("%s: stored 'num-axes' for device '%s' doesn't match "
"number of axes present in device\n",
G_STRFUNC, gdk_device_get_name (device));
@@ -588,6 +603,16 @@ gimp_device_info_tool_changed (GdkDevice *device,
g_object_thaw_notify (G_OBJECT (info));
}
+static void
+gimp_device_info_device_changed (GdkDevice *device,
+ GimpDeviceInfo *info)
+{
+ /* Number of axes or keys can change on virtual devices when the
+ * physical device changes.
+ */
+ gimp_device_info_updated (info);
+}
+
static void
gimp_device_info_updated (GimpDeviceInfo *info)
{
@@ -780,15 +805,23 @@ gimp_device_info_set_device (GimpDeviceInfo *info,
g_signal_handlers_disconnect_by_func (info->priv->device,
gimp_device_info_tool_changed,
info);
+ g_signal_handlers_disconnect_by_func (info->priv->device,
+ gimp_device_info_device_changed,
+ info);
}
mode = gimp_device_info_get_mode (info);
info->priv->device = device;
info->priv->display = display;
if (info->priv->device)
- g_signal_connect_object (info->priv->device, "tool-changed",
- G_CALLBACK (gimp_device_info_tool_changed),
- G_OBJECT (info), 0);
+ {
+ g_signal_connect_object (info->priv->device, "tool-changed",
+ G_CALLBACK (gimp_device_info_tool_changed),
+ G_OBJECT (info), 0);
+ g_signal_connect_object (info->priv->device, "changed",
+ G_CALLBACK (gimp_device_info_device_changed),
+ G_OBJECT (info), 0);
+ }
gimp_device_info_updated (info);
/* The info existed from a previous run. Restore its mode. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]