forked from AuroraMiddleware/gtk
gdk: Add gdk_seat_get_tools() API call
There's GdkSeat::tool-added and ::tool-removed, but there's no API to query the known tools. Add this call.
This commit is contained in:
parent
254007a142
commit
b52ad33031
@ -439,6 +439,7 @@ gdk_seat_get_capabilities
|
||||
gdk_seat_get_pointer
|
||||
gdk_seat_get_keyboard
|
||||
gdk_seat_get_physical_devices
|
||||
gdk_seat_get_tools
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GDK_SEAT
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <glib-object.h>
|
||||
#include "gdkdisplay.h"
|
||||
#include "gdkdevice.h"
|
||||
#include "gdkdevicetoolprivate.h"
|
||||
#include "gdkseatprivate.h"
|
||||
#include "gdkdeviceprivate.h"
|
||||
#include "gdkintl.h"
|
||||
@ -438,11 +439,45 @@ GdkDeviceTool *
|
||||
gdk_seat_get_tool (GdkSeat *seat,
|
||||
guint64 serial,
|
||||
guint64 hw_id)
|
||||
{
|
||||
GdkDeviceTool *match = NULL;
|
||||
GList *tools, *l;
|
||||
|
||||
tools = gdk_seat_get_tools (seat);
|
||||
|
||||
for (l = tools; l; l = l->next)
|
||||
{
|
||||
GdkDeviceTool *tool = l->data;
|
||||
|
||||
if (tool->serial == serial && tool->hw_id == hw_id)
|
||||
{
|
||||
match = tool;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_list_free (tools);
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_seat_get_tools:
|
||||
* @seat: A #GdkSeat
|
||||
*
|
||||
* Returns all #GdkDeviceTool<!-- -->s that are known to the
|
||||
* application.
|
||||
*
|
||||
* Returns: (transfer container) (element-type Gdk.DeviceTool): A list of tools. Free with
|
||||
* g_list_free().
|
||||
**/
|
||||
GList *
|
||||
gdk_seat_get_tools (GdkSeat *seat)
|
||||
{
|
||||
GdkSeatClass *seat_class;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_SEAT (seat), NULL);
|
||||
|
||||
seat_class = GDK_SEAT_GET_CLASS (seat);
|
||||
return seat_class->get_tool (seat, serial, hw_id);
|
||||
return seat_class->get_tools (seat);
|
||||
}
|
||||
|
@ -78,6 +78,8 @@ GDK_AVAILABLE_IN_ALL
|
||||
GList * gdk_seat_get_physical_devices (GdkSeat *seat,
|
||||
GdkSeatCapabilities capabilities);
|
||||
|
||||
GList * gdk_seat_get_tools (GdkSeat *seat);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDevice * gdk_seat_get_pointer (GdkSeat *seat);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
@ -279,13 +279,12 @@ gdk_seat_default_get_physical_devices (GdkSeat *seat,
|
||||
return devices;
|
||||
}
|
||||
|
||||
static GdkDeviceTool *
|
||||
gdk_seat_default_get_tool (GdkSeat *seat,
|
||||
guint64 serial,
|
||||
guint64 hw_id)
|
||||
static GList *
|
||||
gdk_seat_default_get_tools (GdkSeat *seat)
|
||||
{
|
||||
GdkSeatDefaultPrivate *priv;
|
||||
GdkDeviceTool *tool;
|
||||
GList *tools = NULL;
|
||||
guint i;
|
||||
|
||||
priv = gdk_seat_default_get_instance_private (GDK_SEAT_DEFAULT (seat));
|
||||
@ -296,12 +295,10 @@ gdk_seat_default_get_tool (GdkSeat *seat,
|
||||
for (i = 0; i < priv->tools->len; i++)
|
||||
{
|
||||
tool = g_ptr_array_index (priv->tools, i);
|
||||
|
||||
if (tool->serial == serial && tool->hw_id == hw_id)
|
||||
return tool;
|
||||
tools = g_list_prepend (tools, tool);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return tools;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -319,8 +316,7 @@ gdk_seat_default_class_init (GdkSeatDefaultClass *klass)
|
||||
|
||||
seat_class->get_logical_device = gdk_seat_default_get_logical_device;
|
||||
seat_class->get_physical_devices = gdk_seat_default_get_physical_devices;
|
||||
|
||||
seat_class->get_tool = gdk_seat_default_get_tool;
|
||||
seat_class->get_tools = gdk_seat_default_get_tools;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -57,9 +57,7 @@ struct _GdkSeatClass
|
||||
GList * (* get_physical_devices) (GdkSeat *seat,
|
||||
GdkSeatCapabilities capabilities);
|
||||
|
||||
GdkDeviceTool * (* get_tool) (GdkSeat *seat,
|
||||
guint64 serial,
|
||||
guint64 tool_id);
|
||||
GList * (* get_tools) (GdkSeat *seat);
|
||||
};
|
||||
|
||||
void gdk_seat_device_added (GdkSeat *seat,
|
||||
|
@ -4749,6 +4749,22 @@ gdk_wayland_seat_get_physical_devices (GdkSeat *seat,
|
||||
return physical_devices;
|
||||
}
|
||||
|
||||
static GList *
|
||||
gdk_wayland_seat_get_tools (GdkSeat *seat)
|
||||
{
|
||||
GdkWaylandSeat *wayland_seat = GDK_WAYLAND_SEAT (seat);
|
||||
GList *tools = NULL, *l;
|
||||
|
||||
for (l = wayland_seat->tablet_tools; l; l = l->next)
|
||||
{
|
||||
GdkWaylandTabletToolData *tool = l->data;
|
||||
|
||||
tools = g_list_prepend (tools, tool->tool);
|
||||
}
|
||||
|
||||
return tools;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_seat_class_init (GdkWaylandSeatClass *klass)
|
||||
{
|
||||
@ -4762,6 +4778,7 @@ gdk_wayland_seat_class_init (GdkWaylandSeatClass *klass)
|
||||
seat_class->ungrab = gdk_wayland_seat_ungrab;
|
||||
seat_class->get_logical_device = gdk_wayland_seat_get_logical_device;
|
||||
seat_class->get_physical_devices = gdk_wayland_seat_get_physical_devices;
|
||||
seat_class->get_tools = gdk_wayland_seat_get_tools;
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user