[gimp/gtk3-port: 56/137] app: port device management to GdkDeviceManager
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 56/137] app: port device management to GdkDeviceManager
- Date: Mon, 22 Nov 2010 10:24:48 +0000 (UTC)
commit 988f274ec49c561b61722b0204eef00d740dce52
Author: Michael Natterer <mitch gimp org>
Date: Mon Oct 18 17:58:48 2010 +0200
app: port device management to GdkDeviceManager
app/widgets/gimpdevices.c | 85 +++++++++++++++++++++++++++++++++++++--------
1 files changed, 70 insertions(+), 15 deletions(-)
---
diff --git a/app/widgets/gimpdevices.c b/app/widgets/gimpdevices.c
index 13be8ab..fd74382 100644
--- a/app/widgets/gimpdevices.c
+++ b/app/widgets/gimpdevices.c
@@ -78,10 +78,10 @@ static void gimp_devices_display_closed (GdkDisplay *display,
gboolean is_error,
GimpDeviceManager *manager);
-static void gimp_devices_device_added (GdkDisplay *gdk_display,
+static void gimp_devices_device_added (GdkDeviceManager *gdk_manager,
GdkDevice *device,
GimpDeviceManager *manager);
-static void gimp_devices_device_removed (GdkDisplay *gdk_display,
+static void gimp_devices_device_removed (GdkDeviceManager *gdk_manager,
GdkDevice *device,
GimpDeviceManager *manager);
@@ -97,6 +97,8 @@ gimp_devices_init (Gimp *gimp,
GSList *displays;
GSList *list;
GdkDisplay *gdk_display;
+ GdkDeviceManager *gdk_manager;
+ GdkDevice *client_pointer;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (gimp_device_manager_get (gimp) == NULL);
@@ -131,9 +133,11 @@ gimp_devices_init (Gimp *gimp,
manager);
gdk_display = gdk_display_get_default ();
+ gdk_manager = gdk_display_get_device_manager (gdk_display);
- manager->current_device =
- gimp_device_info_get_by_device (gdk_display_get_core_pointer (gdk_display));
+ client_pointer = gdk_device_manager_get_client_pointer (gdk_manager);
+
+ manager->current_device = gimp_device_info_get_by_device (client_pointer);
}
void
@@ -423,16 +427,45 @@ gimp_devices_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 = gdk_display_list_devices (gdk_display); list; list = list->next)
+ for (list = devices; list; list = g_list_next (list))
{
GdkDevice *device = list->data;
- gimp_devices_device_added (gdk_display, device, manager);
+ gimp_devices_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 = devices; list; list = g_list_next (list))
+ {
+ GdkDevice *device = list->data;
+
+ gimp_devices_device_added (gdk_manager, device, manager);
+ }
+
+ g_list_free (devices);
+
+ g_signal_connect (gdk_manager, "device-added",
+ G_CALLBACK (gimp_devices_device_added),
+ manager);
+ g_signal_connect (gdk_manager, "device-removed",
+ G_CALLBACK (gimp_devices_device_removed),
+ manager);
+
g_signal_connect (gdk_display, "closed",
G_CALLBACK (gimp_devices_display_closed),
manager);
@@ -443,21 +476,43 @@ gimp_devices_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);
+
+ devices = gdk_device_manager_list_devices (gdk_manager,
+ GDK_DEVICE_TYPE_MASTER);
+
+ for (list = devices; list; list = list->next)
+ {
+ GdkDevice *device = list->data;
+
+ gimp_devices_device_removed (gdk_manager, device, manager);
+ }
- for (list = gdk_display_list_devices (gdk_display); list; list = list->next)
+ 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_devices_device_removed (gdk_display, device, manager);
+ gimp_devices_device_removed (gdk_manager, device, manager);
}
+
+ g_list_free (devices);
}
static void
-gimp_devices_device_added (GdkDisplay *gdk_display,
+gimp_devices_device_added (GdkDeviceManager *gdk_manager,
GdkDevice *device,
GimpDeviceManager *manager)
{
+ GdkDisplay *display = gdk_device_manager_get_display (gdk_manager);
GimpDeviceInfo *device_info;
device_info =
@@ -466,11 +521,11 @@ gimp_devices_device_added (GdkDisplay *gdk_display,
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 (manager->gimp, device, gdk_display);
+ device_info = gimp_device_info_new (manager->gimp, device, display);
gimp_container_add (manager->device_info_list, GIMP_OBJECT (device_info));
g_object_unref (device_info);
@@ -478,7 +533,7 @@ gimp_devices_device_added (GdkDisplay *gdk_display,
}
static void
-gimp_devices_device_removed (GdkDisplay *gdk_display,
+gimp_devices_device_removed (GdkDeviceManager *gdk_manager,
GdkDevice *device,
GimpDeviceManager *manager)
{
@@ -494,7 +549,7 @@ gimp_devices_device_removed (GdkDisplay *gdk_display,
if (device_info == manager->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_devices_select_device (manager->gimp, device_info);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]