[gtk+/xi2: 1188/1239] GdkDisplay: Add gdk_display_get_device_manager().
- From: Carlos Garnacho <carlosg src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+/xi2: 1188/1239] GdkDisplay: Add gdk_display_get_device_manager().
- Date: Tue, 29 Sep 2009 10:57:54 +0000 (UTC)
commit fc28004bb88cacf11f421667895d3ff4ee269de9
Author: Carlos Garnacho <carlos gnome org>
Date: Sat Sep 19 12:06:39 2009 +0200
GdkDisplay: Add gdk_display_get_device_manager().
This function replaces gdk_device_manager_get_for_display (), which has been
removed.
gdk/gdk.symbols | 2 +-
gdk/gdkdevicemanager.c | 30 ------------------------------
gdk/gdkdevicemanager.h | 3 ---
gdk/gdkdisplay.c | 26 +++++++++++++++++++++++---
gdk/gdkdisplay.h | 7 +++++++
gdk/gdkwindow.c | 6 +++---
gdk/x11/gdkdisplay-x11.c | 7 +++++--
gdk/x11/gdkevents-x11.c | 2 +-
gdk/x11/gdkmain-x11.c | 4 ++--
9 files changed, 42 insertions(+), 45 deletions(-)
---
diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols
index 014b37a..87a8801 100644
--- a/gdk/gdk.symbols
+++ b/gdk/gdk.symbols
@@ -390,7 +390,6 @@ gdk_cursor_get_image
#if IN_HEADER(__GDK_DEVICE_MANAGER_H__)
#if IN_FILE(__GDK_DEVICE_MANAGER_C__)
gdk_device_manager_get_display
-gdk_device_manager_get_for_display
gdk_device_manager_get_type G_GNUC_CONST
#endif
#endif
@@ -436,6 +435,7 @@ gdk_display_get_type G_GNUC_CONST
gdk_display_peek_event
gdk_display_put_event
#ifndef GDK_MULTIDEVICE_SAFE
+gdk_display_get_device_manager
gdk_display_get_pointer
gdk_display_get_window_at_pointer
gdk_display_keyboard_ungrab
diff --git a/gdk/gdkdevicemanager.c b/gdk/gdkdevicemanager.c
index 445bbfa..0f901fc 100644
--- a/gdk/gdkdevicemanager.c
+++ b/gdk/gdkdevicemanager.c
@@ -48,7 +48,6 @@ enum {
};
static guint signals [LAST_SIGNAL] = { 0 };
-static GHashTable *device_managers = NULL;
typedef struct GdkDeviceManagerPrivate GdkDeviceManagerPrivate;
@@ -187,35 +186,6 @@ gdk_device_manager_get_property (GObject *object,
}
/**
- * gdk_device_manager_get_for_display:
- * @display: A #GdkDisplay
- *
- * Returns the #GdkDeviceManager attached to @display.
- *
- * Returns: the #GdkDeviceManager attached to @display. This memory
- * is owned by GTK+, and must not be freed or unreffed.
- **/
-GdkDeviceManager *
-gdk_device_manager_get_for_display (GdkDisplay *display)
-{
- GdkDeviceManager *device_manager;
-
- if (G_UNLIKELY (!device_managers))
- device_managers = g_hash_table_new (g_direct_hash,
- g_direct_equal);
-
- device_manager = g_hash_table_lookup (device_managers, display);
-
- if (G_UNLIKELY (!device_manager))
- {
- device_manager = _gdk_device_manager_new (display);
- g_hash_table_insert (device_managers, display, device_manager);
- }
-
- return device_manager;
-}
-
-/**
* gdk_device_manager_get_display:
* @device_manager: a #GdkDeviceManager
*
diff --git a/gdk/gdkdevicemanager.h b/gdk/gdkdevicemanager.h
index 1bfa610..c82971f 100644
--- a/gdk/gdkdevicemanager.h
+++ b/gdk/gdkdevicemanager.h
@@ -26,7 +26,6 @@
#include <gdk/gdktypes.h>
#include <gdk/gdkdevice.h>
-#include <gdk/gdkdisplay.h>
G_BEGIN_DECLS
@@ -64,8 +63,6 @@ struct _GdkDeviceManagerClass
GType gdk_device_manager_get_type (void) G_GNUC_CONST;
-GdkDeviceManager * gdk_device_manager_get_for_display (GdkDisplay *display);
-
GdkDisplay * gdk_device_manager_get_display (GdkDeviceManager *device_manager);
GList * gdk_device_manager_get_devices (GdkDeviceManager *device_manager,
GdkDeviceType type);
diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
index 10d308d..0b8651a 100644
--- a/gdk/gdkdisplay.c
+++ b/gdk/gdkdisplay.c
@@ -257,6 +257,9 @@ gdk_display_finalize (GObject *object)
g_hash_table_destroy (display->pointers_info);
g_hash_table_destroy (display->multiple_click_info);
+ if (display->device_manager)
+ g_object_unref (display->device_manager);
+
G_OBJECT_CLASS (gdk_display_parent_class)->finalize (object);
}
@@ -377,7 +380,7 @@ gdk_display_pointer_ungrab (GdkDisplay *display,
g_return_if_fail (GDK_IS_DISPLAY (display));
- device_manager = gdk_device_manager_get_for_display (display);
+ device_manager = gdk_display_get_device_manager (display);
devices = gdk_device_manager_get_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
/* FIXME: Should this be generic to all backends? */
@@ -445,7 +448,7 @@ gdk_display_keyboard_ungrab (GdkDisplay *display,
g_return_if_fail (GDK_IS_DISPLAY (display));
- device_manager = gdk_device_manager_get_for_display (display);
+ device_manager = gdk_display_get_device_manager (display);
devices = gdk_device_manager_get_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
/* FIXME: Should this be generic to all backends? */
@@ -1670,7 +1673,7 @@ gdk_display_pointer_is_grabbed (GdkDisplay *display)
g_return_val_if_fail (GDK_IS_DISPLAY (display), TRUE);
- device_manager = gdk_device_manager_get_for_display (display);
+ device_manager = gdk_display_get_device_manager (display);
devices = gdk_device_manager_get_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
for (dev = devices; dev; dev = dev->next)
@@ -1702,5 +1705,22 @@ gdk_display_device_is_grabbed (GdkDisplay *display,
return (info && !info->implicit);
}
+/**
+ * gdk_display_get_device_manager:
+ * @display: a #GdkDisplay.
+ *
+ * Returns the #GdkDeviceManager associated to @display.
+ *
+ * Returns: A #GdkDeviceManager, or %NULL. This memory is
+ * owned by GDK and must not be freed or unreferenced.
+ **/
+GdkDeviceManager *
+gdk_display_get_device_manager (GdkDisplay *display)
+{
+ g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
+
+ return display->device_manager;
+}
+
#define __GDK_DISPLAY_C__
#include "gdkaliasdef.c"
diff --git a/gdk/gdkdisplay.h b/gdk/gdkdisplay.h
index 667eac7..b8571ad 100644
--- a/gdk/gdkdisplay.h
+++ b/gdk/gdkdisplay.h
@@ -30,6 +30,7 @@
#include <gdk/gdktypes.h>
#include <gdk/gdkevents.h>
+#include <gdk/gdkdevicemanager.h>
G_BEGIN_DECLS
@@ -111,6 +112,9 @@ struct _GdkDisplay
/* Last reported event time from server */
guint32 last_event_time;
+
+ /* Device manager associated to the display */
+ GdkDeviceManager *device_manager;
};
struct _GdkDisplayClass
@@ -284,6 +288,9 @@ gboolean gdk_display_supports_shapes (GdkDisplay *display);
gboolean gdk_display_supports_input_shapes (GdkDisplay *display);
gboolean gdk_display_supports_composite (GdkDisplay *display);
+GdkDeviceManager * gdk_display_get_device_manager (GdkDisplay *display);
+
+
G_END_DECLS
#endif /* __GDK_DISPLAY_H__ */
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 860e8c3..78b37b3 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -6475,7 +6475,7 @@ gdk_window_hide (GdkWindow *window)
/* May need to break grabs on children */
display = gdk_drawable_get_display (window);
- device_manager = gdk_device_manager_get_for_display (display);
+ device_manager = gdk_display_get_device_manager (display);
/* Get all devices */
devices = gdk_device_manager_get_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
@@ -9499,7 +9499,7 @@ gdk_pointer_grab (GdkWindow * window,
display = gdk_drawable_get_display (window);
serial = _gdk_windowing_window_get_next_serial (display);
- device_manager = gdk_device_manager_get_for_display (display);
+ device_manager = gdk_display_get_device_manager (display);
devices = gdk_device_manager_get_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
/* FIXME: Should this be generic to all backends? */
@@ -9580,7 +9580,7 @@ gdk_keyboard_grab (GdkWindow *window,
display = gdk_drawable_get_display (window);
serial = _gdk_windowing_window_get_next_serial (display);
- device_manager = gdk_device_manager_get_for_display (display);
+ device_manager = gdk_display_get_device_manager (display);
devices = gdk_device_manager_get_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
/* FIXME: Should this be generic to all backends? */
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index eca82f2..eb82d72 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -40,6 +40,7 @@
#include "gdkscreen-x11.h"
#include "gdkinternals.h"
#include "gdkdeviceprivate.h"
+#include "gdkdevicemanager.h"
#include "xsettings-client.h"
#include "gdkalias.h"
@@ -1081,7 +1082,7 @@ _gdk_event_init (GdkDisplay *display)
gdk_event_source_add_translator ((GdkEventSource *) display_x11->event_source,
GDK_EVENT_TRANSLATOR (display));
- device_manager = gdk_device_manager_get_for_display (display);
+ device_manager = gdk_display_get_device_manager (display);
gdk_event_source_add_translator ((GdkEventSource *) display_x11->event_source,
GDK_EVENT_TRANSLATOR (device_manager));
@@ -1100,7 +1101,7 @@ _gdk_input_init (GdkDisplay *display)
GList *list, *l;
display_x11 = GDK_DISPLAY_X11 (display);
- device_manager = gdk_device_manager_get_for_display (display);
+ device_manager = gdk_display_get_device_manager (display);
/* For backwards compatibility, just add
* floating devices that are not keyboards.
@@ -1213,6 +1214,8 @@ gdk_display_open (const gchar *display_name)
/*set the default screen */
display_x11->default_screen = display_x11->screens[DefaultScreen (display_x11->xdisplay)];
+ display->device_manager = _gdk_device_manager_new (display);
+
_gdk_event_init (display);
attr.window_type = GDK_WINDOW_TOPLEVEL;
diff --git a/gdk/x11/gdkevents-x11.c b/gdk/x11/gdkevents-x11.c
index 4b9602b..bc4c771 100644
--- a/gdk/x11/gdkevents-x11.c
+++ b/gdk/x11/gdkevents-x11.c
@@ -2309,7 +2309,7 @@ _gdk_events_queue (GdkDisplay *display)
continue;
}
- device_manager = gdk_device_manager_get_for_display (display);
+ device_manager = gdk_display_get_device_manager (display);
event = gdk_event_translator_translate (GDK_EVENT_TRANSLATOR (device_manager),
display, &xevent);
diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c
index fc0060b..e81acbe 100644
--- a/gdk/x11/gdkmain-x11.c
+++ b/gdk/x11/gdkmain-x11.c
@@ -205,7 +205,7 @@ _gdk_xgrab_check_unmap (GdkWindow *window,
GdkDeviceManager *device_manager;
GList *devices, *d;
- device_manager = gdk_device_manager_get_for_display (display);
+ device_manager = gdk_display_get_device_manager (display);
/* Get all devices */
devices = gdk_device_manager_get_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
@@ -234,7 +234,7 @@ _gdk_xgrab_check_destroy (GdkWindow *window)
GdkDeviceGrabInfo *grab;
GList *devices, *d;
- device_manager = gdk_device_manager_get_for_display (display);
+ device_manager = gdk_display_get_device_manager (display);
/* Get all devices */
devices = gdk_device_manager_get_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]