2015-11-26 18:49:10 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
* Copyright (C) 2015 Red Hat
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Author: Carlos Garnacho <carlosg@gnome.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gdkseatdefaultprivate.h"
|
2016-04-09 19:20:07 +00:00
|
|
|
#include "gdkdevicetoolprivate.h"
|
2015-11-26 18:49:10 +00:00
|
|
|
|
|
|
|
typedef struct _GdkSeatDefaultPrivate GdkSeatDefaultPrivate;
|
|
|
|
|
|
|
|
struct _GdkSeatDefaultPrivate
|
|
|
|
{
|
2020-06-18 18:22:20 +00:00
|
|
|
GdkDevice *logical_pointer;
|
|
|
|
GdkDevice *logical_keyboard;
|
|
|
|
GList *physical_pointers;
|
|
|
|
GList *physical_keyboards;
|
2016-02-25 11:18:41 +00:00
|
|
|
GdkSeatCapabilities capabilities;
|
2016-01-29 12:07:13 +00:00
|
|
|
|
|
|
|
GPtrArray *tools;
|
2015-11-26 18:49:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define KEYBOARD_EVENTS (GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | \
|
|
|
|
GDK_FOCUS_CHANGE_MASK)
|
|
|
|
#define TOUCH_EVENTS (GDK_TOUCH_MASK)
|
|
|
|
#define POINTER_EVENTS (GDK_POINTER_MOTION_MASK | \
|
|
|
|
GDK_BUTTON_PRESS_MASK | \
|
|
|
|
GDK_BUTTON_RELEASE_MASK | \
|
|
|
|
GDK_SCROLL_MASK | GDK_SMOOTH_SCROLL_MASK | \
|
|
|
|
GDK_ENTER_NOTIFY_MASK | \
|
|
|
|
GDK_LEAVE_NOTIFY_MASK | \
|
|
|
|
GDK_PROXIMITY_IN_MASK | \
|
2021-09-05 22:32:16 +00:00
|
|
|
GDK_PROXIMITY_OUT_MASK | \
|
|
|
|
GDK_TOUCHPAD_GESTURE_MASK)
|
2015-11-26 18:49:10 +00:00
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GdkSeatDefault, gdk_seat_default, GDK_TYPE_SEAT)
|
|
|
|
|
|
|
|
static void
|
2021-01-08 12:10:56 +00:00
|
|
|
gdk_seat_default_dispose (GObject *object)
|
2015-11-26 18:49:10 +00:00
|
|
|
{
|
|
|
|
GdkSeatDefault *seat = GDK_SEAT_DEFAULT (object);
|
|
|
|
GdkSeatDefaultPrivate *priv = gdk_seat_default_get_instance_private (seat);
|
|
|
|
GList *l;
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
if (priv->logical_pointer)
|
2015-11-26 18:49:10 +00:00
|
|
|
{
|
2020-06-18 18:22:20 +00:00
|
|
|
gdk_seat_device_removed (GDK_SEAT (seat), priv->logical_pointer);
|
|
|
|
g_clear_object (&priv->logical_pointer);
|
2015-11-26 18:49:10 +00:00
|
|
|
}
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
if (priv->logical_keyboard)
|
2015-11-26 18:49:10 +00:00
|
|
|
{
|
2020-06-18 18:22:20 +00:00
|
|
|
gdk_seat_device_removed (GDK_SEAT (seat), priv->logical_keyboard);
|
|
|
|
g_clear_object (&priv->logical_pointer);
|
2015-11-26 18:49:10 +00:00
|
|
|
}
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
for (l = priv->physical_pointers; l; l = l->next)
|
2015-11-26 18:49:10 +00:00
|
|
|
{
|
|
|
|
gdk_seat_device_removed (GDK_SEAT (seat), l->data);
|
|
|
|
g_object_unref (l->data);
|
|
|
|
}
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
for (l = priv->physical_keyboards; l; l = l->next)
|
2015-11-26 18:49:10 +00:00
|
|
|
{
|
|
|
|
gdk_seat_device_removed (GDK_SEAT (seat), l->data);
|
|
|
|
g_object_unref (l->data);
|
|
|
|
}
|
|
|
|
|
2021-01-08 12:11:56 +00:00
|
|
|
g_clear_pointer (&priv->tools, g_ptr_array_unref);
|
2016-01-29 12:07:13 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
g_list_free (priv->physical_pointers);
|
|
|
|
g_list_free (priv->physical_keyboards);
|
|
|
|
priv->physical_pointers = NULL;
|
|
|
|
priv->physical_keyboards = NULL;
|
2015-11-26 18:49:10 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (gdk_seat_default_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkSeatCapabilities
|
|
|
|
gdk_seat_default_get_capabilities (GdkSeat *seat)
|
|
|
|
{
|
2016-02-25 11:18:41 +00:00
|
|
|
GdkSeatDefaultPrivate *priv;
|
|
|
|
|
|
|
|
priv = gdk_seat_default_get_instance_private (GDK_SEAT_DEFAULT (seat));
|
|
|
|
|
|
|
|
return priv->capabilities;
|
2015-11-26 18:49:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GdkGrabStatus
|
|
|
|
gdk_seat_default_grab (GdkSeat *seat,
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface,
|
2015-11-26 18:49:10 +00:00
|
|
|
GdkSeatCapabilities capabilities,
|
|
|
|
gboolean owner_events,
|
|
|
|
GdkCursor *cursor,
|
2020-02-16 16:09:02 +00:00
|
|
|
GdkEvent *event,
|
2015-11-26 18:49:10 +00:00
|
|
|
GdkSeatGrabPrepareFunc prepare_func,
|
|
|
|
gpointer prepare_func_data)
|
|
|
|
{
|
|
|
|
GdkSeatDefaultPrivate *priv;
|
|
|
|
guint32 evtime = event ? gdk_event_get_time (event) : GDK_CURRENT_TIME;
|
|
|
|
GdkGrabStatus status = GDK_GRAB_SUCCESS;
|
2018-05-24 13:42:47 +00:00
|
|
|
gboolean was_visible;
|
2015-11-26 18:49:10 +00:00
|
|
|
|
|
|
|
priv = gdk_seat_default_get_instance_private (GDK_SEAT_DEFAULT (seat));
|
2020-02-25 00:02:34 +00:00
|
|
|
was_visible = gdk_surface_get_mapped (surface);
|
2015-11-26 18:49:10 +00:00
|
|
|
|
|
|
|
if (prepare_func)
|
2018-03-20 14:14:10 +00:00
|
|
|
(prepare_func) (seat, surface, prepare_func_data);
|
2015-11-26 18:49:10 +00:00
|
|
|
|
2020-02-25 00:02:34 +00:00
|
|
|
if (!gdk_surface_get_mapped (surface))
|
2015-11-26 18:49:10 +00:00
|
|
|
{
|
2020-02-25 00:02:34 +00:00
|
|
|
g_critical ("Surface %p has not been mapped in GdkSeatGrabPrepareFunc",
|
2018-03-20 14:14:10 +00:00
|
|
|
surface);
|
2015-11-26 18:49:10 +00:00
|
|
|
return GDK_GRAB_NOT_VIEWABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
|
|
|
|
|
|
|
if (capabilities & GDK_SEAT_CAPABILITY_ALL_POINTING)
|
|
|
|
{
|
2017-09-05 14:44:00 +00:00
|
|
|
/* ALL_POINTING spans 3 capabilities; get the mask for the ones we have */
|
|
|
|
GdkEventMask pointer_evmask = 0;
|
|
|
|
|
|
|
|
/* We let tablet styli take over the pointer cursor */
|
|
|
|
if (capabilities & (GDK_SEAT_CAPABILITY_POINTER |
|
|
|
|
GDK_SEAT_CAPABILITY_TABLET_STYLUS))
|
|
|
|
{
|
|
|
|
pointer_evmask |= POINTER_EVENTS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (capabilities & GDK_SEAT_CAPABILITY_TOUCH)
|
|
|
|
pointer_evmask |= TOUCH_EVENTS;
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
status = gdk_device_grab (priv->logical_pointer, surface,
|
2020-06-22 21:54:46 +00:00
|
|
|
owner_events,
|
2017-09-05 14:44:00 +00:00
|
|
|
pointer_evmask, cursor,
|
2015-11-26 18:49:10 +00:00
|
|
|
evtime);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status == GDK_GRAB_SUCCESS &&
|
|
|
|
capabilities & GDK_SEAT_CAPABILITY_KEYBOARD)
|
|
|
|
{
|
2020-06-18 18:22:20 +00:00
|
|
|
status = gdk_device_grab (priv->logical_keyboard, surface,
|
2020-06-22 21:54:46 +00:00
|
|
|
owner_events,
|
2015-11-26 18:49:10 +00:00
|
|
|
KEYBOARD_EVENTS, cursor,
|
|
|
|
evtime);
|
|
|
|
|
|
|
|
if (status != GDK_GRAB_SUCCESS)
|
|
|
|
{
|
|
|
|
if (capabilities & ~GDK_SEAT_CAPABILITY_KEYBOARD)
|
2020-06-18 18:22:20 +00:00
|
|
|
gdk_device_ungrab (priv->logical_pointer, evtime);
|
2015-11-26 18:49:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-24 13:42:47 +00:00
|
|
|
if (status != GDK_GRAB_SUCCESS && !was_visible)
|
|
|
|
gdk_surface_hide (surface);
|
|
|
|
|
2015-11-26 18:49:10 +00:00
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS;
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_seat_default_ungrab (GdkSeat *seat)
|
|
|
|
{
|
|
|
|
GdkSeatDefaultPrivate *priv;
|
|
|
|
|
|
|
|
priv = gdk_seat_default_get_instance_private (GDK_SEAT_DEFAULT (seat));
|
|
|
|
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
2020-06-18 18:22:20 +00:00
|
|
|
gdk_device_ungrab (priv->logical_pointer, GDK_CURRENT_TIME);
|
|
|
|
gdk_device_ungrab (priv->logical_keyboard, GDK_CURRENT_TIME);
|
2015-11-26 18:49:10 +00:00
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkDevice *
|
2020-06-18 18:22:20 +00:00
|
|
|
gdk_seat_default_get_logical_device (GdkSeat *seat,
|
|
|
|
GdkSeatCapabilities capability)
|
2015-11-26 18:49:10 +00:00
|
|
|
{
|
|
|
|
GdkSeatDefaultPrivate *priv;
|
|
|
|
|
|
|
|
priv = gdk_seat_default_get_instance_private (GDK_SEAT_DEFAULT (seat));
|
|
|
|
|
|
|
|
/* There must be only one flag set */
|
2017-10-06 19:19:42 +00:00
|
|
|
switch ((guint) capability)
|
2015-11-26 18:49:10 +00:00
|
|
|
{
|
|
|
|
case GDK_SEAT_CAPABILITY_POINTER:
|
|
|
|
case GDK_SEAT_CAPABILITY_TOUCH:
|
2020-06-18 18:22:20 +00:00
|
|
|
return priv->logical_pointer;
|
2015-11-26 18:49:10 +00:00
|
|
|
case GDK_SEAT_CAPABILITY_KEYBOARD:
|
2020-06-18 18:22:20 +00:00
|
|
|
return priv->logical_keyboard;
|
2015-11-26 18:49:10 +00:00
|
|
|
default:
|
2016-02-28 17:20:39 +00:00
|
|
|
g_warning ("Unhandled capability %x", capability);
|
2015-11-26 18:49:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkSeatCapabilities
|
|
|
|
device_get_capability (GdkDevice *device)
|
|
|
|
{
|
|
|
|
GdkInputSource source;
|
|
|
|
|
|
|
|
source = gdk_device_get_source (device);
|
|
|
|
|
|
|
|
switch (source)
|
|
|
|
{
|
|
|
|
case GDK_SOURCE_KEYBOARD:
|
|
|
|
return GDK_SEAT_CAPABILITY_KEYBOARD;
|
|
|
|
case GDK_SOURCE_TOUCHSCREEN:
|
|
|
|
return GDK_SEAT_CAPABILITY_TOUCH;
|
2017-10-06 19:19:42 +00:00
|
|
|
case GDK_SOURCE_PEN:
|
2017-11-27 20:24:54 +00:00
|
|
|
return GDK_SEAT_CAPABILITY_TABLET_STYLUS;
|
2017-11-27 20:39:05 +00:00
|
|
|
case GDK_SOURCE_TABLET_PAD:
|
|
|
|
return GDK_SEAT_CAPABILITY_TABLET_PAD;
|
2017-11-27 20:24:54 +00:00
|
|
|
case GDK_SOURCE_MOUSE:
|
|
|
|
case GDK_SOURCE_TOUCHPAD:
|
2017-10-06 19:19:42 +00:00
|
|
|
case GDK_SOURCE_TRACKPOINT:
|
2015-11-26 18:49:10 +00:00
|
|
|
default:
|
|
|
|
return GDK_SEAT_CAPABILITY_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GDK_SEAT_CAPABILITY_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GList *
|
|
|
|
append_filtered (GList *list,
|
|
|
|
GList *devices,
|
|
|
|
GdkSeatCapabilities capabilities)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = devices; l; l = l->next)
|
|
|
|
{
|
|
|
|
GdkSeatCapabilities device_cap;
|
|
|
|
|
|
|
|
device_cap = device_get_capability (l->data);
|
|
|
|
|
|
|
|
if ((device_cap & capabilities) != 0)
|
|
|
|
list = g_list_prepend (list, l->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GList *
|
2020-07-30 15:52:28 +00:00
|
|
|
gdk_seat_default_get_devices (GdkSeat *seat,
|
|
|
|
GdkSeatCapabilities capabilities)
|
2015-11-26 18:49:10 +00:00
|
|
|
{
|
|
|
|
GdkSeatDefaultPrivate *priv;
|
|
|
|
GList *devices = NULL;
|
|
|
|
|
|
|
|
priv = gdk_seat_default_get_instance_private (GDK_SEAT_DEFAULT (seat));
|
|
|
|
|
2017-11-27 20:24:54 +00:00
|
|
|
if (capabilities & (GDK_SEAT_CAPABILITY_ALL_POINTING))
|
2020-06-18 18:22:20 +00:00
|
|
|
devices = append_filtered (devices, priv->physical_pointers, capabilities);
|
2015-11-26 18:49:10 +00:00
|
|
|
|
2017-11-27 20:39:05 +00:00
|
|
|
if (capabilities & (GDK_SEAT_CAPABILITY_KEYBOARD | GDK_SEAT_CAPABILITY_TABLET_PAD))
|
2020-06-18 18:22:20 +00:00
|
|
|
devices = append_filtered (devices, priv->physical_keyboards, capabilities);
|
2015-11-26 18:49:10 +00:00
|
|
|
|
|
|
|
return devices;
|
|
|
|
}
|
|
|
|
|
2020-07-28 14:51:41 +00:00
|
|
|
static GList *
|
|
|
|
gdk_seat_default_get_tools (GdkSeat *seat)
|
2016-01-29 12:07:13 +00:00
|
|
|
{
|
|
|
|
GdkSeatDefaultPrivate *priv;
|
|
|
|
GdkDeviceTool *tool;
|
2020-07-28 14:51:41 +00:00
|
|
|
GList *tools = NULL;
|
2016-01-29 12:07:13 +00:00
|
|
|
guint i;
|
|
|
|
|
|
|
|
priv = gdk_seat_default_get_instance_private (GDK_SEAT_DEFAULT (seat));
|
|
|
|
|
|
|
|
if (!priv->tools)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
for (i = 0; i < priv->tools->len; i++)
|
|
|
|
{
|
|
|
|
tool = g_ptr_array_index (priv->tools, i);
|
2020-07-28 14:51:41 +00:00
|
|
|
tools = g_list_prepend (tools, tool);
|
2016-01-29 12:07:13 +00:00
|
|
|
}
|
|
|
|
|
2020-07-28 14:51:41 +00:00
|
|
|
return tools;
|
2016-01-29 12:07:13 +00:00
|
|
|
}
|
|
|
|
|
2015-11-26 18:49:10 +00:00
|
|
|
static void
|
|
|
|
gdk_seat_default_class_init (GdkSeatDefaultClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GdkSeatClass *seat_class = GDK_SEAT_CLASS (klass);
|
|
|
|
|
2021-01-08 12:10:56 +00:00
|
|
|
object_class->dispose = gdk_seat_default_dispose;
|
2015-11-26 18:49:10 +00:00
|
|
|
|
|
|
|
seat_class->get_capabilities = gdk_seat_default_get_capabilities;
|
|
|
|
|
|
|
|
seat_class->grab = gdk_seat_default_grab;
|
|
|
|
seat_class->ungrab = gdk_seat_default_ungrab;
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
seat_class->get_logical_device = gdk_seat_default_get_logical_device;
|
2020-07-30 15:52:28 +00:00
|
|
|
seat_class->get_devices = gdk_seat_default_get_devices;
|
2020-07-28 14:51:41 +00:00
|
|
|
seat_class->get_tools = gdk_seat_default_get_tools;
|
2015-11-26 18:49:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_seat_default_init (GdkSeatDefault *seat)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
GdkSeat *
|
2020-06-18 18:22:20 +00:00
|
|
|
gdk_seat_default_new_for_logical_pair (GdkDevice *pointer,
|
|
|
|
GdkDevice *keyboard)
|
2015-11-26 18:49:10 +00:00
|
|
|
{
|
|
|
|
GdkSeatDefaultPrivate *priv;
|
|
|
|
GdkDisplay *display;
|
|
|
|
GdkSeat *seat;
|
|
|
|
|
|
|
|
display = gdk_device_get_display (pointer);
|
|
|
|
|
|
|
|
seat = g_object_new (GDK_TYPE_SEAT_DEFAULT,
|
|
|
|
"display", display,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
priv = gdk_seat_default_get_instance_private (GDK_SEAT_DEFAULT (seat));
|
2020-06-18 18:22:20 +00:00
|
|
|
priv->logical_pointer = g_object_ref (pointer);
|
|
|
|
priv->logical_keyboard = g_object_ref (keyboard);
|
2015-11-26 18:49:10 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
gdk_seat_device_added (seat, priv->logical_pointer);
|
|
|
|
gdk_seat_device_added (seat, priv->logical_keyboard);
|
2015-11-26 18:49:10 +00:00
|
|
|
|
|
|
|
return seat;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-06-18 18:22:20 +00:00
|
|
|
gdk_seat_default_add_physical_device (GdkSeatDefault *seat,
|
|
|
|
GdkDevice *device)
|
2015-11-26 18:49:10 +00:00
|
|
|
{
|
|
|
|
GdkSeatDefaultPrivate *priv;
|
|
|
|
GdkSeatCapabilities capability;
|
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_SEAT_DEFAULT (seat));
|
|
|
|
g_return_if_fail (GDK_IS_DEVICE (device));
|
|
|
|
|
|
|
|
priv = gdk_seat_default_get_instance_private (seat);
|
|
|
|
capability = device_get_capability (device);
|
|
|
|
|
2017-11-27 20:24:54 +00:00
|
|
|
if (capability & GDK_SEAT_CAPABILITY_ALL_POINTING)
|
2020-06-18 18:22:20 +00:00
|
|
|
priv->physical_pointers = g_list_prepend (priv->physical_pointers, g_object_ref (device));
|
2017-11-27 20:39:05 +00:00
|
|
|
else if (capability & (GDK_SEAT_CAPABILITY_KEYBOARD | GDK_SEAT_CAPABILITY_TABLET_PAD))
|
2020-06-18 18:22:20 +00:00
|
|
|
priv->physical_keyboards = g_list_prepend (priv->physical_keyboards, g_object_ref (device));
|
2015-11-26 18:49:10 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
g_critical ("Unhandled capability %x for device '%s'",
|
|
|
|
capability, gdk_device_get_name (device));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-02-25 11:18:41 +00:00
|
|
|
priv->capabilities |= capability;
|
|
|
|
|
2015-11-26 18:49:10 +00:00
|
|
|
gdk_seat_device_added (GDK_SEAT (seat), device);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-06-18 18:22:20 +00:00
|
|
|
gdk_seat_default_remove_physical_device (GdkSeatDefault *seat,
|
|
|
|
GdkDevice *device)
|
2015-11-26 18:49:10 +00:00
|
|
|
{
|
|
|
|
GdkSeatDefaultPrivate *priv;
|
2016-02-25 11:18:41 +00:00
|
|
|
GList *l;
|
2015-11-26 18:49:10 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_SEAT_DEFAULT (seat));
|
|
|
|
g_return_if_fail (GDK_IS_DEVICE (device));
|
|
|
|
|
|
|
|
priv = gdk_seat_default_get_instance_private (seat);
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
if (g_list_find (priv->physical_pointers, device))
|
2015-11-26 18:49:10 +00:00
|
|
|
{
|
2020-06-18 18:22:20 +00:00
|
|
|
priv->physical_pointers = g_list_remove (priv->physical_pointers, device);
|
2016-02-25 11:18:41 +00:00
|
|
|
|
2017-11-27 20:24:54 +00:00
|
|
|
priv->capabilities &= ~(GDK_SEAT_CAPABILITY_ALL_POINTING);
|
2020-06-18 18:22:20 +00:00
|
|
|
for (l = priv->physical_pointers; l; l = l->next)
|
2016-02-25 11:18:41 +00:00
|
|
|
priv->capabilities |= device_get_capability (GDK_DEVICE (l->data));
|
|
|
|
|
2015-11-26 18:49:10 +00:00
|
|
|
gdk_seat_device_removed (GDK_SEAT (seat), device);
|
2020-01-26 23:59:56 +00:00
|
|
|
g_object_unref (device);
|
2015-11-26 18:49:10 +00:00
|
|
|
}
|
2020-06-18 18:22:20 +00:00
|
|
|
else if (g_list_find (priv->physical_keyboards, device))
|
2015-11-26 18:49:10 +00:00
|
|
|
{
|
2020-06-18 18:22:20 +00:00
|
|
|
priv->physical_keyboards = g_list_remove (priv->physical_keyboards, device);
|
2016-02-25 11:18:41 +00:00
|
|
|
|
2017-11-27 20:39:05 +00:00
|
|
|
priv->capabilities &= ~(GDK_SEAT_CAPABILITY_KEYBOARD | GDK_SEAT_CAPABILITY_TABLET_PAD);
|
2020-06-18 18:22:20 +00:00
|
|
|
for (l = priv->physical_keyboards; l; l = l->next)
|
2017-11-27 20:39:05 +00:00
|
|
|
priv->capabilities |= device_get_capability (GDK_DEVICE (l->data));
|
2016-02-25 11:18:41 +00:00
|
|
|
|
2015-11-26 18:49:10 +00:00
|
|
|
gdk_seat_device_removed (GDK_SEAT (seat), device);
|
2020-01-26 23:59:56 +00:00
|
|
|
g_object_unref (device);
|
2015-11-26 18:49:10 +00:00
|
|
|
}
|
|
|
|
}
|
2016-01-29 12:07:13 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
gdk_seat_default_add_tool (GdkSeatDefault *seat,
|
|
|
|
GdkDeviceTool *tool)
|
|
|
|
{
|
|
|
|
GdkSeatDefaultPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_SEAT_DEFAULT (seat));
|
|
|
|
g_return_if_fail (tool != NULL);
|
|
|
|
|
|
|
|
priv = gdk_seat_default_get_instance_private (seat);
|
|
|
|
|
|
|
|
if (!priv->tools)
|
|
|
|
priv->tools = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
|
|
|
|
|
|
|
|
g_ptr_array_add (priv->tools, g_object_ref (tool));
|
|
|
|
g_signal_emit_by_name (seat, "tool-added", tool);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_seat_default_remove_tool (GdkSeatDefault *seat,
|
|
|
|
GdkDeviceTool *tool)
|
|
|
|
{
|
|
|
|
GdkSeatDefaultPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_SEAT_DEFAULT (seat));
|
|
|
|
g_return_if_fail (tool != NULL);
|
|
|
|
|
|
|
|
priv = gdk_seat_default_get_instance_private (seat);
|
|
|
|
|
2021-01-07 11:27:26 +00:00
|
|
|
if (tool != gdk_seat_get_tool (GDK_SEAT (seat), tool->serial, tool->hw_id, tool->type))
|
2016-01-29 12:07:13 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
g_signal_emit_by_name (seat, "tool-removed", tool);
|
|
|
|
g_ptr_array_remove (priv->tools, tool);
|
|
|
|
}
|