Commit 6cde835a authored by Carlos Garnacho's avatar Carlos Garnacho
Browse files

GdkDeviceManager: Add gdk_device_manager_get_client_pointer().

This function makes a better replacement for
gdk_display_get_core_pointer(), wherever it might yet be needed, for
XI2 resorts to XIGetClientPointer(), for the others return the only
core pointer.

https://bugzilla.gnome.org/show_bug.cgi?id=621685
parent 009e26f3
......@@ -1020,6 +1020,7 @@ GdkGrabOwnership
gdk_enable_multidevice
gdk_device_manager_get_display
gdk_device_manager_list_devices
gdk_device_manager_get_client_pointer
<SUBSECTION>
gdk_device_get_name
......
......@@ -386,6 +386,7 @@ gdk_cursor_get_image
gdk_device_manager_get_display
gdk_device_manager_get_type G_GNUC_CONST
gdk_device_manager_list_devices
gdk_device_manager_get_client_pointer
#endif
#endif
......
......@@ -298,5 +298,29 @@ gdk_device_manager_list_devices (GdkDeviceManager *device_manager,
return GDK_DEVICE_MANAGER_GET_CLASS (device_manager)->list_devices (device_manager, type);
}
/**
* gdk_device_manager_get_client_pointer:
* @device_manager: a #GdkDeviceManager
*
* Returns the client pointer, that is, the master pointer that acts as the core pointer
* for this application. In X11, window managers may change this depending on the interaction
* pattern under the presence of several pointers.
*
* You should use this function sheldomly, only in code that isn't triggered by a #GdkEvent
* and there aren't other means to get a meaningful #GdkDevice to operate on.
*
* Returns: The client pointer.
*
* Since: 3.0
**/
GdkDevice *
gdk_device_manager_get_client_pointer (GdkDeviceManager *device_manager)
{
g_return_val_if_fail (GDK_IS_DEVICE_MANAGER (device_manager), NULL);
return GDK_DEVICE_MANAGER_GET_CLASS (device_manager)->get_client_pointer (device_manager);
}
#define __GDK_DEVICE_MANAGER_C__
#include "gdkaliasdef.c"
......@@ -63,6 +63,7 @@ struct _GdkDeviceManagerClass
/* VMethods */
GList * (* list_devices) (GdkDeviceManager *device_manager,
GdkDeviceType type);
GdkDevice * (* get_client_pointer) (GdkDeviceManager *device_manager);
};
GType gdk_device_manager_get_type (void) G_GNUC_CONST;
......@@ -70,6 +71,7 @@ GType gdk_device_manager_get_type (void) G_GNUC_CONST;
GdkDisplay * gdk_device_manager_get_display (GdkDeviceManager *device_manager);
GList * gdk_device_manager_list_devices (GdkDeviceManager *device_manager,
GdkDeviceType type);
GdkDevice * gdk_device_manager_get_client_pointer (GdkDeviceManager *device_manager);
G_END_DECLS
......
......@@ -605,7 +605,7 @@ gdk_event_send_clientmessage_toall (GdkEvent *event)
* Return value: the core pointer device; this is owned by the
* display and should not be freed.
*
* Deprecated: 3.0: Use gdk_display_get_device_manager() instead, or
* Deprecated: 3.0: Use gdk_display_get_client_pointer() instead, or
* gdk_event_get_device() if a #GdkEvent with pointer device
* information is available.
**/
......@@ -626,7 +626,7 @@ gdk_device_get_core_pointer (void)
*
* Since: 2.2
*
* Deprecated: 3.0: Use gdk_display_get_device_manager() instead, or
* Deprecated: 3.0: Use gdk_display_get_client_pointer() instead, or
* gdk_event_get_device() if a #GdkEvent with device
* information is available.
**/
......
......@@ -34,6 +34,7 @@ static void gdk_device_manager_core_constructed (GObject *object);
static GList * gdk_device_manager_core_list_devices (GdkDeviceManager *device_manager,
GdkDeviceType type);
static GdkDevice * gdk_device_manager_core_get_client_pointer (GdkDeviceManager *device_manager);
G_DEFINE_TYPE (GdkDeviceManagerCore, gdk_device_manager_core, GDK_TYPE_DEVICE_MANAGER)
......@@ -47,6 +48,7 @@ gdk_device_manager_core_class_init (GdkDeviceManagerCoreClass *klass)
object_class->finalize = gdk_device_manager_core_finalize;
object_class->constructed = gdk_device_manager_core_constructed;
device_manager_class->list_devices = gdk_device_manager_core_list_devices;
device_manager_class->get_client_pointer = gdk_device_manager_core_get_client_pointer;
}
static GdkDevice *
......@@ -128,3 +130,12 @@ gdk_device_manager_core_list_devices (GdkDeviceManager *device_manager,
return devices;
}
static GdkDevice *
gdk_device_manager_core_get_client_pointer (GdkDeviceManager *device_manager)
{
GdkDeviceManagerCore *device_manager_core;
device_manager_core = (GdkDeviceManagerCore *) device_manager;
return device_manager_core->core_pointer;
}
......@@ -69,6 +69,7 @@ static void gdk_device_manager_win32_constructed (GObject *object);
static GList * gdk_device_manager_win32_list_devices (GdkDeviceManager *device_manager,
GdkDeviceType type);
static GdkDevice * gdk_device_manager_win32_get_client_pointer (GdkDeviceManager *device_manager);
G_DEFINE_TYPE (GdkDeviceManagerWin32, gdk_device_manager_win32, GDK_TYPE_DEVICE_MANAGER)
......@@ -82,6 +83,7 @@ gdk_device_manager_win32_class_init (GdkDeviceManagerWin32Class *klass)
object_class->finalize = gdk_device_manager_win32_finalize;
object_class->constructed = gdk_device_manager_win32_constructed;
device_manager_class->list_devices = gdk_device_manager_win32_list_devices;
device_manager_class->get_client_pointer = gdk_device_manager_win32_get_client_pointer;
}
static GdkDevice *
......@@ -690,6 +692,15 @@ gdk_device_manager_win32_list_devices (GdkDeviceManager *device_manager,
return devices;
}
static GdkDevice *
gdk_device_manager_win32_get_client_pointer (GdkDeviceManager *device_manager)
{
GdkDeviceManagerWin32 *device_manager_win32;
device_manager_win32 = (GdkDeviceManagerWin32 *) device_manager;
return device_manager_win32->core_pointer;
}
void
_gdk_input_set_tablet_active (void)
{
......
......@@ -42,6 +42,7 @@ static void gdk_device_manager_core_constructed (GObject *object);
static GList * gdk_device_manager_core_list_devices (GdkDeviceManager *device_manager,
GdkDeviceType type);
static GdkDevice * gdk_device_manager_core_get_client_pointer (GdkDeviceManager *device_manager);
static void gdk_device_manager_event_translator_init (GdkEventTranslatorIface *iface);
......@@ -64,6 +65,7 @@ gdk_device_manager_core_class_init (GdkDeviceManagerCoreClass *klass)
object_class->finalize = gdk_device_manager_core_finalize;
object_class->constructed = gdk_device_manager_core_constructed;
device_manager_class->list_devices = gdk_device_manager_core_list_devices;
device_manager_class->get_client_pointer = gdk_device_manager_core_get_client_pointer;
}
static void
......@@ -900,5 +902,14 @@ gdk_device_manager_core_list_devices (GdkDeviceManager *device_manager,
return devices;
}
static GdkDevice *
gdk_device_manager_core_get_client_pointer (GdkDeviceManager *device_manager)
{
GdkDeviceManagerCore *device_manager_core;
device_manager_core = (GdkDeviceManagerCore *) device_manager;
return device_manager_core->core_pointer;
}
#define __GDK_DEVICE_MANAGER_CORE_C__
#include "gdkaliasdef.c"
......@@ -38,6 +38,7 @@ static void gdk_device_manager_xi2_finalize (GObject *object);
static GList * gdk_device_manager_xi2_list_devices (GdkDeviceManager *device_manager,
GdkDeviceType type);
static GdkDevice * gdk_device_manager_xi2_get_client_pointer (GdkDeviceManager *device_manager);
static void gdk_device_manager_xi2_event_translator_init (GdkEventTranslatorIface *iface);
......@@ -66,6 +67,7 @@ gdk_device_manager_xi2_class_init (GdkDeviceManagerXI2Class *klass)
object_class->finalize = gdk_device_manager_xi2_finalize;
device_manager_class->list_devices = gdk_device_manager_xi2_list_devices;
device_manager_class->get_client_pointer = gdk_device_manager_xi2_get_client_pointer;
}
static void
......@@ -419,6 +421,23 @@ gdk_device_manager_xi2_list_devices (GdkDeviceManager *device_manager,
return g_list_copy (list);
}
static GdkDevice *
gdk_device_manager_xi2_get_client_pointer (GdkDeviceManager *device_manager)
{
GdkDeviceManagerXI2 *device_manager_xi2;
GdkDisplay *display;
int device_id;
device_manager_xi2 = (GdkDeviceManagerXI2 *) device_manager;
display = gdk_device_manager_get_display (device_manager);
XIGetClientPointer (GDK_DISPLAY_XDISPLAY (display),
None, &device_id);
return g_hash_table_lookup (device_manager_xi2->id_table,
GINT_TO_POINTER (device_id));
}
static void
gdk_device_manager_xi2_event_translator_init (GdkEventTranslatorIface *iface)
{
......
......@@ -45,6 +45,8 @@ struct _GdkDeviceManagerXI2
GList *slave_devices;
GList *floating_devices;
GdkDevice *client_pointer;
int opcode;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment