While X11 surfaces can be resized, this is not the case for Quartz
surfaces. Instead of resizing we will invalidate the surface instead.
By giving _gdk_windowing_set_cairo_surface_size() a boolean return
value, we can signal back whether or not resizing was possible. If not
possible, we invalidate the surface.
Either g_type_register_static_simple (used by G_DEFINE_TYPE_EXTENDED)
and G_IMPLEMENT_INTERFACE use automatic variables for GTypeInfo and
GInterfaceInfo structs, while tutorials and source code often use
static variables. This commit consistently adopts the former method.
https://bugzilla.gnome.org/show_bug.cgi?id=600158
Turns out pygtk build broke due to the argument addition to draw_drawable.
So, we now add a new vfunc for the new draw_drawable and are thus
backwards compat.
Use the same code path to get a CGContext for both gdk_draw_* and
gdk_cairo_create and make sure we unlockFocus in both cases. This
fixes the broken rendering in GtkRuler. Also use an average of flush
intervals when checking whether we can flush or not, since otherwise
we get too sensitive and block almost all explicit flushes that are
caused by mouse movements for example.
This fixes a mismatch in save/release gstate for the CGContext. If
this function is ever used for pixmaps, we need to add support for
that, probably will have to do so soon.
2008-08-15 Richard Hult <richard@imendio.com>
* gdk/quartz/gdkdrawable-quartz.c (gdk_quartz_draw_drawable): Some
aftermath of the fix of bug #543868. Clip and flip to the source,
not the destination. Don't save/restore the gstate, it's already
done when getting/releasing the context.
svn path=/trunk/; revision=21136
2008-07-20 Sven Herzberg <sven@imendio.com>
reviewed by: Richard Hult
Fixes#543868: GdkPixmap is upside down on quartz
* gdk/quartz/gdkdrawable-quartz.c (gdk_quartz_draw_drawable): flip the
coordinate space from GTK+ orientation to CoreGraphics orientation
before calling CoreGraphics code
* gdk/quartz/gdkgc-quartz.c (gdk_quartz_draw_tiled_pattern): drop the
coordinate space flipping (we always get it right, now)
* gdk/quartz/gdkpixmap-quartz.c
(gdk_pixmap_impl_quartz_get_context): flip the coordinate space when
creating the CGContextRef
svn path=/trunk/; revision=20870
2008-07-20 Sven Herzberg <sven@imendio.com>
reviewed by: Richard Hult
Extracted the CGContextRef creation into a virtual function of
GdkDrawableImplQuartz; implement get_context() for GdkPixmap and
GdkWindow
* gdk/quartz/gdkdrawable-quartz.c
(gdk_quartz_drawable_get_context): dropped the different
implementations; forward to the virtual function now
* gdk/quartz/gdkdrawable-quartz.h: added the virtual function
* gdk/quartz/gdkpixmap-quartz.c
(gdk_pixmap_impl_quartz_get_context),
(gdk_pixmap_impl_quartz_class_init): implemented get_context()
* gdk/quartz/gdkwindow-quartz.c
(gdk_window_impl_quartz_get_context),
(gdk_window_impl_quartz_class_init): implemented get_context()
svn path=/trunk/; revision=20869
2007-12-10 Richard Hult <richard@imendio.com>
* gdk/quartz/gdkdrawable-quartz.c:
(gdk_quartz_drawable_get_context),
(gdk_quartz_drawable_release_context):
* gdk/quartz/gdkeventloop-quartz.c: (gdk_event_prepare),
(gdk_event_check), (gdk_event_dispatch), (poll_func):
* gdk/quartz/gdkwindow-quartz.h: Replace the autorelease pools
used for each drawing context and in prepare, dispatch and poll
with one that exists across each main loop iteration. Fixes leaks
on leopard and protects against future leaks introduce when the
underlying system changes again (bug #492977).
svn path=/trunk/; revision=19149
2007-06-10 Michael Natterer <mitch@imendio.com>
* gdk/quartz/gdkdrawable-quartz.c (gdk_quartz_draw_arc): fix
angles by flipping the coordinate system back to its original y
direction. The implementtion is still broken for ellipses, will
have to simulate them using bezier curves.
svn path=/trunk/; revision=18095
2007-06-08 Michael Natterer <mitch@imendio.com>
* gdk/quartz/gdkdrawable-quartz.c: add utility function
gdk_quartz_fix_cap_not_last_line() which fixes the coordinates for
GDK_CAP_NOT_LAST lines at least for horizontal and vertical lines.
(gdk_quartz_draw_segments)
(gdk_quartz_draw_lines): use it here.
svn path=/trunk/; revision=18080
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
2007-04-06 Richard Hult <richard@imendio.com>
* gdk/quartz/: Clean up namespaces to make the code more
maintainable.
* gdk/quartz/gdkdrawable-quartz.c:
* gdk/quartz/gdkgc-quartz.c: Fix bug #418384, alignment of tiled
images, by setting the pattern phase for the CG pattern.
svn path=/trunk/; revision=17584
2007-03-10 Richard Hult <richard@imendio.com>
* gdk/quartz/gdkdrawable-quartz.c:
(gdk_quartz_drawable_get_context): Update for the new quartz cairo
surface API (#410442). Don't lock focus unless called outside of an
expose event.
(gdk_quartz_drawable_release_context): Only flush the CG context and
unlock focus if called outside of expose.
(gdk_quartz_ref_cairo_surface): Reuse the surface during its lifetime.
(_gdk_quartz_drawable_finish): New function, used to free the cached
cairo surface.
* gdk/quartz/gdkwindow-quartz.c:
(gdk_window_impl_quartz_begin_paint_region): A few small style changes.
(gdk_window_quartz_process_all_updates): Move the autorelease pool
allocation and freeing outside the loop.
(_gdk_windowing_window_destroy): Finish the drawable.
(move_resize_window_internal): Small cleanup and remove comment.
(_gdk_window_impl_quartz_get_type): No need to make the type info
static.
* gdk/quartz/gdkpixmap-quartz.c: Finish the drawable.
svn path=/trunk/; revision=17463
2006-09-21 Michael Natterer <mitch@imendio.com>
Implement lots of value setters for GdkGC, based on a heavily
modified patch from Thomas Broyer (bug #328853):
* gdk/quartz/gdkcolor-quartz.c: removed functions which set colors
on the CGContext. Instead, added gdk_quartz_get_rgba_from_pixel()
which simply returns RGBA values from a GdkColor's pixel value.
See gdk_quartz_update_context_from_gc() below.
* gdk/quartz/gdkprivate-quartz.h (struct GdkGCQuartz): added lots
of members for the newly suppored GC values. Added enum
GdkQuartzContextValuesMask which is used for setting up the
CGContext for filling and/or stroking.
* gdk/quartz/gdkgc-quartz.c (gdk_quartz_gc_get_values)
(gdk_quartz_gc_set_values)
(_gdk_windowing_gc_copy): support a lot more GC values.
(gdk_quartz_update_context_from_gc): added
GdkQuartzContextValuesMask parameter and set filling/stroking
parameters accordingly. This function also gained full control
over the FG and BG colors (they can't be set separately any more).
The stipple mask part of the patch doesn't work but seems to take
the right approach and doesn't make things worse, so I applied it.
Did *not* apply the clipping part of the patch since I don't
understand it (I don't understand the version in CVS either, but
it at least works :-)
* gdk/quartz/gdkdrawable-quartz.c: pass the right masks to
gdk_quartz_update_context_from_gc() and removed separate color
setting calls. Some minor fixes.
* gdk/quartz/gdkwindow-quartz.c
(gdk_window_impl_quartz_begin_paint_region): set the CGContext's
fill color manually. We don't have/need a GC here.
2006-08-08 Michael Natterer <mitch@imendio.com>
* gdk/quartz/gdkdrawable-quartz.c: some whitespace and indentation
cleanup.
(gdk_quartz_draw_rectangle)
(gdk_quartz_draw_arc)
(gdk_quartz_draw_polygon)
(gdk_quartz_draw_points): for pixel-prefect drawing, stroked
coordinates need to go through pixel centers, while filled ones
need to go along pixel boundaries. Moved +0.5 adjusting to the
if(!filled) branches and added/removed some adjustments where they
were wrong.
2006-08-07 Richard Hult <richard@imendio.com>
* gdk/quartz/gdkdrawable-quartz.c (gdk_quartz_draw_points): Don't
get and release the context for each point, just once, speeds up
drawing many points a lot.
2006-07-31 Richard Hult <richard@imendio.com>
* gdk/quartz/gdkdrawable-quartz.c: (gdk_quartz_draw_drawable):
* gdk/quartz/gdkwindow-quartz.c:
(gdk_window_impl_quartz_begin_paint_region): Patch from Erik van
Pienbroek to implement drawing bg_pixmaps (#348145).
2006-07-29 Richard Hult <richard@imendio.com>
* gdk/quartz/gdkcolor-quartz.c (gdk_colormap_alloc_colors): Always
set success to TRUE.
(gdk_color_change): Implement.
* gdk/quartz/GdkQuartzWindow.c
([GdkQuartzWindow -canBecomeKeyWindow]): Add comment.
* gdk/quartz/gdkevents-quartz.c (gdk_screen_get_setting): Make the
default font a bit smaller until we have made this get the system
setting.
* gdk/quartz/gdkwindow-quartz.c (gdk_window_set_type_hint): Enable
shadows for the right window types.
* gdk/quartz/gdkprivate-quartz.h:
* gdk/quartz/gdkgc-quartz.c:
* gdk/quartz/gdkdrawable-quartz.c:
* gdk/quartz/gdkcolor-quartz.c: Expose the CGContext functions,
update callers.
* gdk/quartz/gdkmain-quartz.c: (_gdk_windowing_init): No need to
get the current process ID, use the right constant instead.
2006-04-16 Richard Hult <richard@imendio.com>
* gdk/quartz/gdkdrawable-quartz.c: (gdk_quartz_draw_drawable): Add check
for source being a window.
* gdk/quartz/gdkwindow-quartz.c: (_gdk_windowing_window_get_pointer):
Don't assert on window not being the root window.
2006-03-21 Anders Carlsson <andersca@imendio.com>
* gdk/quartz/gdkdrawable-quartz.c:
(gdk_quartz_ref_cairo_surface):
(gdk_quartz_draw_rectangle):
(gdk_quartz_draw_arc):
(gdk_quartz_draw_polygon):
(gdk_quartz_draw_drawable):
(gdk_quartz_draw_segments):
(gdk_quartz_draw_lines):
(gdk_quartz_draw_pixbuf):
(gdk_quartz_draw_image):
(_gdk_quartz_drawable_get_context):
* gdk/quartz/gdkdrawable-quartz.h:
Offset coordinates by 0.5 pixels to get consistant results for both
image contexts and screen contexts.
2006-01-18 Anders Carlsson <andersca@imendio.com>
* gdk/quartz/gdkdrawable-quartz.c:
(gdk_quartz_draw_polygon):
(gdk_quartz_draw_lines):
Implement these functions.
(#327226, Thomas Broyer)