mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-23 20:30:15 +00:00
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
This commit is contained in:
parent
9355ef9ee5
commit
fd8c2c01a9
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
||||
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.
|
||||
|
||||
2007-12-10 Tor Lillqvist <tml@novell.com>
|
||||
|
||||
* gtk-zip.sh.in: Include bin/gtk-builder-convert in the dev
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ gboolean
|
||||
gdk_events_pending (void)
|
||||
{
|
||||
return (_gdk_event_queue_find_first (_gdk_display) ||
|
||||
(_gdk_quartz_event_loop_get_current () != NULL));
|
||||
(_gdk_quartz_event_loop_check_pending ()));
|
||||
}
|
||||
|
||||
GdkEvent*
|
||||
@ -1829,14 +1829,15 @@ gdk_event_translate (NSEvent *nsevent)
|
||||
void
|
||||
_gdk_events_queue (GdkDisplay *display)
|
||||
{
|
||||
NSEvent *current_event = _gdk_quartz_event_loop_get_current ();
|
||||
NSEvent *event;
|
||||
|
||||
if (current_event)
|
||||
event = _gdk_quartz_event_loop_get_pending ();
|
||||
if (event)
|
||||
{
|
||||
if (!gdk_event_translate (current_event))
|
||||
[NSApp sendEvent:current_event];
|
||||
|
||||
_gdk_quartz_event_loop_release_current ();
|
||||
if (!gdk_event_translate (event))
|
||||
[NSApp sendEvent:event];
|
||||
|
||||
_gdk_quartz_event_loop_release_event (event);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,8 +158,9 @@ extern GdkWindow *_gdk_quartz_keyboard_grab_window;
|
||||
extern GdkWindow *_gdk_quartz_pointer_grab_window;
|
||||
|
||||
/* Event loop */
|
||||
NSEvent * _gdk_quartz_event_loop_get_current (void);
|
||||
void _gdk_quartz_event_loop_release_current (void);
|
||||
gboolean _gdk_quartz_event_loop_check_pending (void);
|
||||
NSEvent * _gdk_quartz_event_loop_get_pending (void);
|
||||
void _gdk_quartz_event_loop_release_event (NSEvent *event);
|
||||
|
||||
/* FIXME: image */
|
||||
GdkImage *_gdk_quartz_image_copy_to_image (GdkDrawable *drawable,
|
||||
|
Loading…
Reference in New Issue
Block a user