Commit 89bf66d4 authored by Michael Natterer's avatar Michael Natterer 😴

libgimpwidgets: add gdk_cairo_get_clip_rectangle() to gimp3migration.[ch]

parent 4279023b
......@@ -21,6 +21,8 @@
#include "config.h"
#include <math.h>
#include <gtk/gtk.h>
#include "gimpwidgetstypes.h"
......@@ -177,3 +179,30 @@ gtk_widget_get_modifier_mask (GtkWidget *widget,
}
#endif /* GTK+ 3.3 */
gboolean
gdk_cairo_get_clip_rectangle (cairo_t *cr,
GdkRectangle *rect)
{
double x1, y1, x2, y2;
gboolean clip_exists;
cairo_clip_extents (cr, &x1, &y1, &x2, &y2);
clip_exists = x1 < x2 && y1 < y2;
if (rect)
{
x1 = floor (x1);
y1 = floor (y1);
x2 = ceil (x2);
y2 = ceil (y2);
rect->x = CLAMP (x1, G_MININT, G_MAXINT);
rect->y = CLAMP (y1, G_MININT, G_MAXINT);
rect->width = CLAMP (x2 - x1, G_MININT, G_MAXINT);
rect->height = CLAMP (y2 - y1, G_MININT, G_MAXINT);
}
return clip_exists;
}
......@@ -67,4 +67,8 @@ GdkModifierType gtk_widget_get_modifier_mask (GtkWidget *widget,
GdkModifierIntent intent);
#endif
gboolean gdk_cairo_get_clip_rectangle (cairo_t *cr,
GdkRectangle *rect);
#endif /* __GIMP_3_MIGRATION_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment