[gtk+] Add gdk_event_get/set_display
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Add gdk_event_get/set_display
- Date: Tue, 31 Oct 2017 02:22:18 +0000 (UTC)
commit c74ee7a15940d1892922d5a2e557b30abd64c13d
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Oct 30 21:49:30 2017 -0400
Add gdk_event_get/set_display
The GdkScreen apis are going away, this is a replacement.
gdk/gdkevents.c | 46 +++++++++++++++++++++++++++++++++-------------
gdk/gdkevents.h | 6 ++++++
gdk/gdkinternals.h | 2 +-
3 files changed, 40 insertions(+), 14 deletions(-)
---
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index 466ab54..f03af6e 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -506,7 +506,7 @@ gdk_event_new (GdkEventType type)
new_private = g_slice_new0 (GdkEventPrivate);
new_private->flags = 0;
- new_private->screen = NULL;
+ new_private->display = NULL;
g_hash_table_insert (event_hash, new_private, GUINT_TO_POINTER (1));
@@ -658,7 +658,7 @@ gdk_event_copy (const GdkEvent *event)
{
GdkEventPrivate *private = (GdkEventPrivate *)event;
- new_private->screen = private->screen;
+ new_private->display = private->display;
new_private->device = private->device ? g_object_ref (private->device) : NULL;
new_private->source_device = private->source_device ? g_object_ref (private->source_device) : NULL;
new_private->seat = private->seat;
@@ -2042,7 +2042,7 @@ gdk_events_get_center (GdkEvent *event1,
* gdk_event_set_screen:
* @event: a #GdkEvent
* @screen: a #GdkScreen
- *
+ *
* Sets the screen for @event to @screen. The event must
* have been allocated by GTK+, for instance, by
* gdk_event_copy().
@@ -2053,13 +2053,7 @@ void
gdk_event_set_screen (GdkEvent *event,
GdkScreen *screen)
{
- GdkEventPrivate *private;
-
- g_return_if_fail (gdk_event_is_allocated (event));
-
- private = (GdkEventPrivate *)event;
-
- private->screen = screen;
+ gdk_event_set_display (event, gdk_screen_get_display (screen));
}
/**
@@ -2081,16 +2075,42 @@ gdk_event_set_screen (GdkEvent *event,
GdkScreen *
gdk_event_get_screen (const GdkEvent *event)
{
+ GdkDisplay *display;
+
+ display = gdk_event_get_display (event);
+
+ if (display)
+ return gdk_display_get_default_screen (display);
+
+ return NULL;
+}
+
+void
+gdk_event_set_display (GdkEvent *event,
+ GdkDisplay *display)
+{
+ GdkEventPrivate *private;
+
+ g_return_if_fail (gdk_event_is_allocated (event));
+
+ private = (GdkEventPrivate *)event;
+
+ private->display = display;
+}
+
+GdkDisplay *
+gdk_event_get_display (const GdkEvent *event)
+{
if (gdk_event_is_allocated (event))
{
GdkEventPrivate *private = (GdkEventPrivate *)event;
- if (private->screen)
- return private->screen;
+ if (private->display)
+ return private->display;
}
if (event->any.window)
- return gdk_window_get_screen (event->any.window);
+ return gdk_window_get_display (event->any.window);
return NULL;
}
diff --git a/gdk/gdkevents.h b/gdk/gdkevents.h
index 41e8ff2..92b05fa 100644
--- a/gdk/gdkevents.h
+++ b/gdk/gdkevents.h
@@ -673,6 +673,12 @@ void gdk_event_set_screen (GdkEvent *event,
GDK_AVAILABLE_IN_ALL
GdkScreen *gdk_event_get_screen (const GdkEvent *event);
+GDK_AVAILABLE_IN_3_94
+void gdk_event_set_display (GdkEvent *event,
+ GdkDisplay *display);
+GDK_AVAILABLE_IN_3_94
+GdkDisplay *gdk_event_get_display (const GdkEvent *event);
+
GDK_AVAILABLE_IN_3_4
GdkEventSequence *gdk_event_get_event_sequence (const GdkEvent *event);
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index fa016ee..6674b3b 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -144,7 +144,7 @@ struct _GdkEventPrivate
{
GdkEvent event;
guint flags;
- GdkScreen *screen;
+ GdkDisplay *display;
gpointer windowing_data;
GdkDevice *device;
GdkDevice *source_device;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]