[gimp/gtk3-port: 42/235] app: port device management to GdkDeviceManager
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 42/235] app: port device management to GdkDeviceManager
- Date: Sun, 2 Oct 2011 14:48:14 +0000 (UTC)
commit 036c9f959f81c3050f65406c76c9be7596ac4afa
Author: Michael Natterer <mitch gimp org>
Date: Mon Oct 18 17:58:48 2010 +0200
app: port device management to GdkDeviceManager
app/widgets/gimpdevicemanager.c | 93 +++++++++++++++++++++++++++++++--------
1 files changed, 75 insertions(+), 18 deletions(-)
---
diff --git a/app/widgets/gimpdevicemanager.c b/app/widgets/gimpdevicemanager.c
index a7d2c46..933bbc5 100644
--- a/app/widgets/gimpdevicemanager.c
+++ b/app/widgets/gimpdevicemanager.c
@@ -74,10 +74,10 @@ static void gimp_device_manager_display_closed (GdkDisplay *display,
gboolean is_error,
GimpDeviceManager *manager);
-static void gimp_device_manager_device_added (GdkDisplay *gdk_display,
+static void gimp_device_manager_device_added (GdkDeviceManager *gdk_manager,
GdkDevice *device,
GimpDeviceManager *manager);
-static void gimp_device_manager_device_removed (GdkDisplay *gdk_display,
+static void gimp_device_manager_device_removed (GdkDeviceManager *gdk_manager,
GdkDevice *device,
GimpDeviceManager *manager);
@@ -130,6 +130,8 @@ gimp_device_manager_constructed (GObject *object)
GSList *displays;
GSList *list;
GdkDisplay *display;
+ GdkDeviceManager *gdk_manager;
+ GdkDevice *client_pointer;
if (G_OBJECT_CLASS (parent_class)->constructed)
G_OBJECT_CLASS (parent_class)->constructed (object);
@@ -154,10 +156,12 @@ gimp_device_manager_constructed (GObject *object)
G_CALLBACK (gimp_device_manager_display_opened),
manager);
- display = gdk_display_get_default ();
+ display = gdk_display_get_default ();
+ gdk_manager = gdk_display_get_device_manager (display);
- private->current_device =
- gimp_device_info_get_by_device (gdk_display_get_core_pointer (display));
+ client_pointer = gdk_device_manager_get_client_pointer (gdk_manager);
+
+ private->current_device = gimp_device_info_get_by_device (client_pointer);
}
static void
@@ -279,16 +283,45 @@ gimp_device_manager_display_opened (GdkDisplayManager *disp_manager,
GdkDisplay *gdk_display,
GimpDeviceManager *manager)
{
- GList *list;
+ GdkDeviceManager *gdk_manager;
+ GList *devices;
+ GList *list;
+
+ gdk_manager = gdk_display_get_device_manager (gdk_display);
+
+ devices = gdk_device_manager_list_devices (gdk_manager,
+ GDK_DEVICE_TYPE_MASTER);
+
+ /* create device info structures for present devices */
+ for (list = devices; list; list = g_list_next (list))
+ {
+ GdkDevice *device = list->data;
+
+ gimp_device_manager_device_added (gdk_manager, device, manager);
+ }
+
+ g_list_free (devices);
+
+ devices = gdk_device_manager_list_devices (gdk_manager,
+ GDK_DEVICE_TYPE_FLOATING);
/* create device info structures for present devices */
- for (list = gdk_display_list_devices (gdk_display); list; list = list->next)
+ for (list = devices; list; list = g_list_next (list))
{
GdkDevice *device = list->data;
- gimp_device_manager_device_added (gdk_display, device, manager);
+ gimp_device_manager_device_added (gdk_manager, device, manager);
}
+ g_list_free (devices);
+
+ g_signal_connect (gdk_manager, "device-added",
+ G_CALLBACK (gimp_device_manager_device_added),
+ manager);
+ g_signal_connect (gdk_manager, "device-removed",
+ G_CALLBACK (gimp_device_manager_device_removed),
+ manager);
+
g_signal_connect (gdk_display, "closed",
G_CALLBACK (gimp_device_manager_display_closed),
manager);
@@ -299,35 +332,59 @@ gimp_device_manager_display_closed (GdkDisplay *gdk_display,
gboolean is_error,
GimpDeviceManager *manager)
{
- GList *list;
+ GdkDeviceManager *gdk_manager;
+ GList *devices;
+ GList *list;
+
+ gdk_manager = gdk_display_get_device_manager (gdk_display);
- for (list = gdk_display_list_devices (gdk_display); list; list = list->next)
+ devices = gdk_device_manager_list_devices (gdk_manager,
+ GDK_DEVICE_TYPE_MASTER);
+
+ for (list = devices; list; list = list->next)
{
GdkDevice *device = list->data;
- gimp_device_manager_device_removed (gdk_display, device, manager);
+ gimp_device_manager_device_removed (gdk_manager, device, manager);
}
+
+ g_list_free (devices);
+
+ devices = gdk_device_manager_list_devices (gdk_manager,
+ GDK_DEVICE_TYPE_FLOATING);
+
+ for (list = devices; list; list = list->next)
+ {
+ GdkDevice *device = list->data;
+
+ gimp_device_manager_device_removed (gdk_manager, device, manager);
+ }
+
+ g_list_free (devices);
}
static void
-gimp_device_manager_device_added (GdkDisplay *gdk_display,
+gimp_device_manager_device_added (GdkDeviceManager *gdk_manager,
GdkDevice *device,
GimpDeviceManager *manager)
{
GimpDeviceManagerPrivate *private = GET_PRIVATE (manager);
+ GdkDisplay *display;
GimpDeviceInfo *device_info;
+ display = gdk_device_manager_get_display (gdk_manager);
+
device_info =
GIMP_DEVICE_INFO (gimp_container_get_child_by_name (GIMP_CONTAINER (manager),
- device->name));
+ gdk_device_get_name (device)));
if (device_info)
{
- gimp_device_info_set_device (device_info, device, gdk_display);
+ gimp_device_info_set_device (device_info, device, display);
}
else
{
- device_info = gimp_device_info_new (private->gimp, device, gdk_display);
+ device_info = gimp_device_info_new (private->gimp, device, display);
gimp_container_add (GIMP_CONTAINER (manager), GIMP_OBJECT (device_info));
g_object_unref (device_info);
@@ -335,7 +392,7 @@ gimp_device_manager_device_added (GdkDisplay *gdk_display,
}
static void
-gimp_device_manager_device_removed (GdkDisplay *gdk_display,
+gimp_device_manager_device_removed (GdkDeviceManager *gdk_manager,
GdkDevice *device,
GimpDeviceManager *manager)
{
@@ -344,7 +401,7 @@ gimp_device_manager_device_removed (GdkDisplay *gdk_display,
device_info =
GIMP_DEVICE_INFO (gimp_container_get_child_by_name (GIMP_CONTAINER (manager),
- device->name));
+ gdk_device_get_name (device)));
if (device_info)
{
@@ -352,7 +409,7 @@ gimp_device_manager_device_removed (GdkDisplay *gdk_display,
if (device_info == private->current_device)
{
- device = gdk_display_get_core_pointer (gdk_display);
+ device = gdk_device_manager_get_client_pointer (gdk_manager);
device_info = gimp_device_info_get_by_device (device);
gimp_device_manager_set_current_device (manager, device_info);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]