diff options
author | Richard Hult <richard@imendio.com> | 2007-12-10 19:00:23 +0000 |
---|---|---|
committer | Richard Hult <rhult@src.gnome.org> | 2007-12-10 19:00:23 +0000 |
commit | fd8c2c01a9e4f8f9bb20de818c8d7be31c4b0df3 (patch) | |
tree | 7ee88bf350b035f03edb4177629b76ae9ae4f4a7 /gdk/quartz/gdkeventloop-quartz.c | |
parent | 9355ef9ee5bcbfec773ab6551331ce7671190dfe (diff) | |
download | gtk+-fd8c2c01a9e4f8f9bb20de818c8d7be31c4b0df3.tar.gz |
Fix a bug where we could end up trying to handle the same event more than
2007-12-10 Richard Hult <richard@imendio.com>
* gdk/quartz/gdkprivate-quartz.h:
* gdk/quartz/gdkeventloop-quartz.c:
(_gdk_quartz_event_loop_get_pending),
(_gdk_quartz_event_loop_check_pending),
(_gdk_quartz_event_loop_release_event), (gdk_event_prepare),
(gdk_event_check), (gdk_event_dispatch):
* gdk/quartz/gdkevents-quartz.c: (gdk_events_pending)
(_gdk_events_queue): Fix a bug where we could end up trying to
handle the same event more than once. Based on patch from Paul
Davis.
svn path=/trunk/; revision=19143
Diffstat (limited to 'gdk/quartz/gdkeventloop-quartz.c')
-rw-r--r-- | gdk/quartz/gdkeventloop-quartz.c | 63 |
1 files changed, 41 insertions, 22 deletions
diff --git a/gdk/quartz/gdkeventloop-quartz.c b/gdk/quartz/gdkeventloop-quartz.c index d9e9ad85e7..a696a39e75 100644 --- a/gdk/quartz/gdkeventloop-quartz.c +++ b/gdk/quartz/gdkeventloop-quartz.c @@ -24,12 +24,37 @@ static guint n_pollfds; static CFRunLoopSourceRef select_main_thread_source; static CFRunLoopRef main_thread_run_loop; +gboolean +_gdk_quartz_event_loop_check_pending (void) +{ + return current_event != NULL; +} + +NSEvent* +_gdk_quartz_event_loop_get_pending (void) +{ + NSEvent *event; + + event = current_event; + current_event = NULL; + + return event; +} + +void +_gdk_quartz_event_loop_release_event (NSEvent *event) +{ + [event release]; +} + static gboolean gdk_event_prepare (GSource *source, gint *timeout) { NSEvent *event; gboolean retval; + + GDK_THREADS_ENTER (); GDK_QUARTZ_ALLOC_POOL; @@ -45,19 +70,27 @@ gdk_event_prepare (GSource *source, GDK_QUARTZ_RELEASE_POOL; + GDK_THREADS_LEAVE (); + return retval; } static gboolean gdk_event_check (GSource *source) { + gboolean retval; + + GDK_THREADS_ENTER (); + if (_gdk_event_queue_find_first (_gdk_display) != NULL || - current_event) - return TRUE; + _gdk_quartz_event_loop_check_pending ()) + retval = TRUE; + else + retval = FALSE; - /* FIXME: We should maybe try to fetch an event again here */ + GDK_THREADS_LEAVE (); - return FALSE; + return retval; } static gboolean @@ -67,6 +100,8 @@ gdk_event_dispatch (GSource *source, { GdkEvent *event; + GDK_THREADS_ENTER (); + GDK_QUARTZ_ALLOC_POOL; _gdk_events_queue (_gdk_display); @@ -83,6 +118,8 @@ gdk_event_dispatch (GSource *source, GDK_QUARTZ_RELEASE_POOL; + GDK_THREADS_LEAVE (); + return TRUE; } @@ -264,11 +301,6 @@ poll_func (GPollFD *ufds, guint nfds, gint timeout_) { ufds[0].revents = G_IO_IN; - /* FIXME: We can't assert here, but we might need to have a - * queue for events instead. - */ - /*g_assert (current_event == NULL);*/ - current_event = [event retain]; n_active ++; @@ -298,16 +330,3 @@ _gdk_quartz_event_loop_init (void) } -NSEvent * -_gdk_quartz_event_loop_get_current (void) -{ - return current_event; -} - -void -_gdk_quartz_event_loop_release_current (void) -{ - [current_event release]; - current_event = NULL; -} - |