Fix bugs #428733 and #433301. Turns out the lockFocus logic was flawed,

007-05-05  Richard Hult  <richard@imendio.com>

	* gdk/quartz/gdkdrawable-quartz.c:
	(gdk_quartz_drawable_get_context),
	(gdk_quartz_drawable_release_context): Fix bugs #428733 and #433301.
	Turns out the lockFocus logic was flawed, now we only lock/unlock 
	when called outside a real expose event and never flush manually.

svn path=/trunk/; revision=17798
This commit is contained in:
Richard Hult 2007-05-05 10:19:39 +00:00 committed by Richard Hult
parent e6993e9a37
commit d9dedc36ec
2 changed files with 23 additions and 17 deletions

View File

@ -1,3 +1,11 @@
2007-05-05 Richard Hult <richard@imendio.com>
* gdk/quartz/gdkdrawable-quartz.c:
(gdk_quartz_drawable_get_context),
(gdk_quartz_drawable_release_context): Fix bugs #428733 and #433301.
Turns out the lockFocus logic was flawed, now we only lock/unlock
when called outside a real expose event and never flush manually.
2007-05-03 Behdad Esfahbod <behdad@gnome.org>
* gtk/gtklabel.c (gtk_label_ensure_layout):

View File

@ -600,22 +600,23 @@ gdk_quartz_drawable_get_context (GdkDrawable *drawable,
gboolean antialias)
{
GdkDrawableImplQuartz *drawable_impl = GDK_DRAWABLE_IMPL_QUARTZ (drawable);
CGContextRef cg_context;
if (GDK_IS_WINDOW_IMPL_QUARTZ (drawable) &&
GDK_WINDOW_DESTROYED (drawable_impl->wrapper))
return NULL;
CGContextRef cg_context;
if (GDK_IS_WINDOW_IMPL_QUARTZ (drawable))
{
GdkWindowImplQuartz *window_impl = GDK_WINDOW_IMPL_QUARTZ (drawable);
/* Lock focus when not called as part of begin/end paint cycle.
* This is needed to allow broken apps that draw outside of expose
* to still work (somewhat).
/* Lock focus when not called as part of a drawRect call. This
* is needed when called from outside "real" expose events, for
* example for synthesized expose events when realizing windows
* and for widgets that send fake expose events like the arrow
* buttons in spinbuttons.
*/
if (window_impl->begin_paint_count == 0)
if (window_impl->in_paint_rect_count == 0)
{
window_impl->pool = [[NSAutoreleasePool alloc] init];
if (![window_impl->view lockFocusIfCanDraw])
@ -695,14 +696,10 @@ gdk_quartz_drawable_release_context (GdkDrawable *drawable,
CGContextRestoreGState (cg_context);
CGContextSetAllowsAntialiasing (cg_context, TRUE);
/* Only flush and unlock if called outside the expose, since it's
* already handled for otherwise.
*/
if (window_impl->in_paint_rect_count == 0 && window_impl->begin_paint_count == 0)
/* See comment in gdk_quartz_drawable_get_context(). */
if (window_impl->in_paint_rect_count == 0)
{
CGContextFlush (cg_context);
[window_impl->view unlockFocus];
}
if (window_impl->pool)
{
@ -710,6 +707,7 @@ gdk_quartz_drawable_release_context (GdkDrawable *drawable,
window_impl->pool = NULL;
}
}
}
else if (GDK_IS_PIXMAP_IMPL_QUARTZ (drawable))
CGContextRelease (cg_context);
}