summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Sabo <DanielSabo@gmail.com>2013-10-29 14:43:05 -0700
committerMatthias Clasen <mclasen@redhat.com>2013-11-09 00:01:05 -0500
commit80dd1a851a8a79770c94b8efbe034304af4458d9 (patch)
treef93fe37bc18746e5fb0f9822cb65468654d2f570
parent0c46807e4388be30bff847bac2d3bb90094ae862 (diff)
downloadgtk+-80dd1a851a8a79770c94b8efbe034304af4458d9.tar.gz
Add an event_compression setting to GdkWindow
Setting event compression to false will allow inter-frame mouse motion events to be delivered, which are necessary for painting applications to produce smooth strokes. https://bugzilla.gnome.org/show_bug.cgi?id=702392
-rw-r--r--docs/reference/gdk/gdk3-sections.txt2
-rw-r--r--gdk/gdkevents.c3
-rw-r--r--gdk/gdkinternals.h1
-rw-r--r--gdk/gdkwindow.c44
-rw-r--r--gdk/gdkwindow.h6
5 files changed, 56 insertions, 0 deletions
diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt
index dc0413d65f..8652973a76 100644
--- a/docs/reference/gdk/gdk3-sections.txt
+++ b/docs/reference/gdk/gdk3-sections.txt
@@ -491,6 +491,8 @@ gdk_window_get_device_events
gdk_window_set_device_events
gdk_window_get_source_events
gdk_window_set_source_events
+gdk_window_get_event_compression
+gdk_window_set_event_compression
<SUBSECTION>
gdk_offscreen_window_get_surface
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index e770f4777b..6d926aef2c 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -293,6 +293,9 @@ _gdk_event_queue_handle_motion_compression (GdkDisplay *display)
pending_motion_device != event->event.motion.device)
break;
+ if (!event->event.motion.window->event_compression)
+ break;
+
pending_motion_window = event->event.motion.window;
pending_motion_device = event->event.motion.device;
pending_motions = tmp_list;
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index 87d9941874..b2456662ec 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -227,6 +227,7 @@ struct _GdkWindow
guint applied_shape : 1;
guint in_update : 1;
guint geometry_dirty : 1;
+ guint event_compression : 1;
GdkFullscreenMode fullscreen_mode;
/* The GdkWindow that has the impl, ref:ed if another window.
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index ee10901481..8c121ed741 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -1284,6 +1284,7 @@ gdk_window_new (GdkWindow *parent,
window->accept_focus = TRUE;
window->focus_on_map = TRUE;
+ window->event_compression = TRUE;
if (attributes_mask & GDK_WA_X)
x = attributes->x;
@@ -9712,6 +9713,49 @@ gdk_window_set_focus_on_map (GdkWindow *window,
}
/**
+ * gdk_window_set_event_compression:
+ * @window: a #GdkWindow
+ * @event_compression: %TRUE if motion events should be compressed
+ *
+ * Determines whether or not extra unprocessed motion events in
+ * the event queue can be discarded. If %TRUE only the most recent
+ * event will be delivered.
+ *
+ * Some types of applications, e.g. paint programs, need to see all
+ * motion events and will benefit from turning off event compression.
+ *
+ * By default, event compression is enabled.
+ *
+ * Since: 3.12
+ **/
+void
+gdk_window_set_event_compression (GdkWindow *window,
+ gboolean event_compression)
+{
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ window->event_compression = event_compression;
+}
+
+/**
+ * gdk_window_get_event_compression:
+ * @window: a #GdkWindow
+ *
+ * Get the current event compression setting for this window.
+ *
+ * Return value: %TRUE if motion events will be compressed
+ *
+ * Since: 3.12
+ **/
+gboolean
+gdk_window_get_event_compression (GdkWindow *window)
+{
+ g_return_val_if_fail (GDK_IS_WINDOW (window), TRUE);
+
+ return window->event_compression;
+}
+
+/**
* gdk_window_set_icon_list:
* @window: The #GdkWindow toplevel window to set the icon of.
* @pixbufs: (transfer none) (element-type GdkPixbuf):
diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h
index de7872e4bb..014f2f70e8 100644
--- a/gdk/gdkwindow.h
+++ b/gdk/gdkwindow.h
@@ -1090,6 +1090,12 @@ GDK_AVAILABLE_IN_3_10
void gdk_window_set_opaque_region (GdkWindow *window,
cairo_region_t *region);
+GDK_AVAILABLE_IN_3_12
+void gdk_window_set_event_compression (GdkWindow *window,
+ gboolean event_compression);
+GDK_AVAILABLE_IN_3_12
+gboolean gdk_window_get_event_compression (GdkWindow *window);
+
G_END_DECLS
#endif /* __GDK_WINDOW_H__ */