[gtk/getters-and-setters: 2/4] device: Add missing getters
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/getters-and-setters: 2/4] device: Add missing getters
- Date: Mon, 24 Feb 2020 14:17:17 +0000 (UTC)
commit 9ce6e98487712fa7c5760a4501f80582415015ab
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Feb 24 08:00:11 2020 -0500
device: Add missing getters
This adds getters for a few properties that were
missing them, and renames the input-mode and input-source
properties to match their existing getters.
docs/reference/gdk/gdk4-sections.txt | 2 ++
gdk/gdkdevice.c | 50 +++++++++++++++++++++---------------
gdk/gdkdevice.h | 7 +++++
gdk/gdkdeviceprivate.h | 2 --
gdk/gdksurface.c | 2 +-
5 files changed, 40 insertions(+), 23 deletions(-)
---
diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt
index e2943f152d..5aa4e0deed 100644
--- a/docs/reference/gdk/gdk4-sections.txt
+++ b/docs/reference/gdk/gdk4-sections.txt
@@ -463,6 +463,8 @@ gdk_device_get_n_axes
gdk_device_get_n_keys
gdk_device_get_axes
gdk_device_get_seat
+gdk_device_get_num_touches
+gdk_device_get_device_tool
<SUBSECTION>
gdk_device_get_state
diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c
index b9d0e47bfe..725366f0e2 100644
--- a/gdk/gdkdevice.c
+++ b/gdk/gdkdevice.c
@@ -92,8 +92,8 @@ enum {
PROP_NAME,
PROP_ASSOCIATED_DEVICE,
PROP_TYPE,
- PROP_INPUT_SOURCE,
- PROP_INPUT_MODE,
+ PROP_SOURCE,
+ PROP_MODE,
PROP_HAS_CURSOR,
PROP_N_AXES,
PROP_VENDOR_ID,
@@ -169,12 +169,12 @@ gdk_device_class_init (GdkDeviceClass *klass)
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
- * GdkDevice:input-source:
+ * GdkDevice:source:
*
* Source type for the device.
*/
- device_props[PROP_INPUT_SOURCE] =
- g_param_spec_enum ("input-source",
+ device_props[PROP_SOURCE] =
+ g_param_spec_enum ("source",
P_("Input source"),
P_("Source type for the device"),
GDK_TYPE_INPUT_SOURCE,
@@ -183,12 +183,12 @@ gdk_device_class_init (GdkDeviceClass *klass)
G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
/*
- * GdkDevice:input-mode:
+ * GdkDevice:mode:
*
* Input mode for the device.
*/
- device_props[PROP_INPUT_MODE] =
- g_param_spec_enum ("input-mode",
+ device_props[PROP_MODE] =
+ g_param_spec_enum ("mode",
P_("Input mode for the device"),
P_("Input mode for the device"),
GDK_TYPE_INPUT_MODE,
@@ -414,10 +414,10 @@ gdk_device_set_property (GObject *object,
case PROP_TYPE:
device->type = g_value_get_enum (value);
break;
- case PROP_INPUT_SOURCE:
+ case PROP_SOURCE:
device->source = g_value_get_enum (value);
break;
- case PROP_INPUT_MODE:
+ case PROP_MODE:
gdk_device_set_mode (device, g_value_get_enum (value));
break;
case PROP_HAS_CURSOR:
@@ -463,10 +463,10 @@ gdk_device_get_property (GObject *object,
case PROP_TYPE:
g_value_set_enum (value, device->type);
break;
- case PROP_INPUT_SOURCE:
+ case PROP_SOURCE:
g_value_set_enum (value, device->source);
break;
- case PROP_INPUT_MODE:
+ case PROP_MODE:
g_value_set_enum (value, device->mode);
break;
case PROP_HAS_CURSOR:
@@ -519,7 +519,7 @@ gdk_device_get_state (GdkDevice *device,
GdkModifierType *mask)
{
g_return_if_fail (GDK_IS_DEVICE (device));
- g_return_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD);
+ g_return_if_fail (device->source != GDK_SOURCE_KEYBOARD);
g_return_if_fail (GDK_IS_SURFACE (surface));
g_return_if_fail (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_SLAVE ||
gdk_display_device_is_grabbed (gdk_device_get_display (device), device));
@@ -542,7 +542,7 @@ gdk_device_get_position (GdkDevice *device,
double *y)
{
g_return_if_fail (GDK_IS_DEVICE (device));
- g_return_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD);
+ g_return_if_fail (device->source != GDK_SOURCE_KEYBOARD);
g_return_if_fail (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_SLAVE ||
gdk_display_device_is_grabbed (gdk_device_get_display (device), device));
@@ -577,7 +577,7 @@ gdk_device_get_surface_at_position (GdkDevice *device,
GdkSurface *surface;
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
- g_return_val_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD, NULL);
+ g_return_val_if_fail (device->source != GDK_SOURCE_KEYBOARD, NULL);
g_return_val_if_fail (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_SLAVE ||
gdk_display_device_is_grabbed (gdk_device_get_display (device), device), NULL);
@@ -626,7 +626,7 @@ gdk_device_get_history (GdkDevice *device,
gint *n_events)
{
g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
- g_return_val_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD, FALSE);
+ g_return_val_if_fail (device->source != GDK_SOURCE_KEYBOARD, FALSE);
g_return_val_if_fail (GDK_IS_SURFACE (surface), FALSE);
if (n_events)
@@ -772,7 +772,7 @@ gdk_device_set_mode (GdkDevice *device,
return FALSE;
device->mode = mode;
- g_object_notify_by_pspec (G_OBJECT (device), device_props[PROP_INPUT_MODE]);
+ g_object_notify_by_pspec (G_OBJECT (device), device_props[PROP_MODE]);
return TRUE;
}
@@ -1754,8 +1754,18 @@ gdk_device_update_tool (GdkDevice *device,
}
}
-GdkInputMode
-gdk_device_get_input_mode (GdkDevice *device)
+guint
+gdk_device_get_num_touches (GdkDevice *device)
{
- return device->mode;
+ g_return_val_if_fail (GDK_IS_DEVICE (device), 0);
+
+ return device->num_touches;
+}
+
+GdkDeviceTool *
+gdk_device_get_device_tool (GdkDevice *device)
+{
+ g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
+
+ return device->last_tool;
}
diff --git a/gdk/gdkdevice.h b/gdk/gdkdevice.h
index 9a2cc758bf..d69e18ca21 100644
--- a/gdk/gdkdevice.h
+++ b/gdk/gdkdevice.h
@@ -24,6 +24,7 @@
#include <gdk/gdkversionmacros.h>
#include <gdk/gdktypes.h>
+#include <gdk/gdkdevicetool.h>
G_BEGIN_DECLS
@@ -221,6 +222,12 @@ GdkSeat *gdk_device_get_seat (GdkDevice *device);
GDK_AVAILABLE_IN_ALL
GdkAxisFlags gdk_device_get_axes (GdkDevice *device);
+GDK_AVAILABLE_IN_ALL
+guint gdk_device_get_num_touches (GdkDevice *device);
+
+GDK_AVAILABLE_IN_ALL
+GdkDeviceTool * gdk_device_get_device_tool (GdkDevice *device);
+
G_END_DECLS
#endif /* __GDK_DEVICE_H__ */
diff --git a/gdk/gdkdeviceprivate.h b/gdk/gdkdeviceprivate.h
index 29a9dc6de5..aab3166d2b 100644
--- a/gdk/gdkdeviceprivate.h
+++ b/gdk/gdkdeviceprivate.h
@@ -180,8 +180,6 @@ void gdk_device_set_seat (GdkDevice *device,
void gdk_device_update_tool (GdkDevice *device,
GdkDeviceTool *tool);
-GdkInputMode gdk_device_get_input_mode (GdkDevice *device);
-
G_END_DECLS
#endif /* __GDK_DEVICE_PRIVATE_H__ */
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 0717106aee..dfdc9c0cb1 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -2695,7 +2695,7 @@ _gdk_windowing_got_event (GdkDisplay *display,
_gdk_display_device_grab_update (display, device, source_device, serial);
- if (gdk_device_get_input_mode (device) == GDK_MODE_DISABLED ||
+ if (gdk_device_get_mode (device) == GDK_MODE_DISABLED ||
!_gdk_display_check_grab_ownership (display, device, serial))
{
/* Device events are blocked by another
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]