aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--calendar/gui/e-day-view-main-item.c13
-rw-r--r--calendar/gui/e-day-view-time-item.c15
-rw-r--r--calendar/gui/e-day-view-top-item.c13
-rw-r--r--calendar/gui/e-meeting-time-sel-item.c18
-rw-r--r--calendar/gui/e-week-view-event-item.c13
-rw-r--r--calendar/gui/e-week-view-main-item.c13
-rw-r--r--calendar/gui/e-week-view-titles-item.c13
-rw-r--r--libgnomecanvas/gnome-canvas-line.c12
-rw-r--r--libgnomecanvas/gnome-canvas-pixbuf.c28
-rw-r--r--libgnomecanvas/gnome-canvas-rich-text.c32
-rw-r--r--libgnomecanvas/gnome-canvas-shape.c39
-rw-r--r--libgnomecanvas/gnome-canvas-text.c45
-rw-r--r--libgnomecanvas/gnome-canvas-widget.c31
-rw-r--r--libgnomecanvas/gnome-canvas.c64
-rw-r--r--libgnomecanvas/gnome-canvas.h13
-rw-r--r--widgets/misc/e-calendar-item.c13
-rw-r--r--widgets/misc/e-canvas-background.c16
-rw-r--r--widgets/misc/e-canvas.c10
-rw-r--r--widgets/table/e-table-field-chooser-item.c8
-rw-r--r--widgets/table/e-table-header-item.c8
-rw-r--r--widgets/table/e-table-item.c9
-rw-r--r--widgets/text/e-reflow.c18
-rw-r--r--widgets/text/e-text.c14
23 files changed, 138 insertions, 320 deletions
diff --git a/calendar/gui/e-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c
index 148843b397..33e45bbef3 100644
--- a/calendar/gui/e-day-view-main-item.c
+++ b/calendar/gui/e-day-view-main-item.c
@@ -1235,21 +1235,14 @@ day_view_main_item_draw (GnomeCanvasItem *canvas_item,
gdk_region_destroy (draw_region);
}
-static gdouble
+static GnomeCanvasItem *
day_view_main_item_point (GnomeCanvasItem *item,
gdouble x,
gdouble y,
gint cx,
- gint cy,
- GnomeCanvasItem **actual_item)
+ gint cy)
{
- /* This is supposed to return the nearest item to the point
- * and the distance. Since we are the only item we just return
- * ourself and 0 for the distance. This is needed so that we
- * get button/motion events. */
- *actual_item = item;
-
- return 0.0;
+ return item;
}
static void
diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c
index 9e430ecf41..e952515c89 100644
--- a/calendar/gui/e-day-view-time-item.c
+++ b/calendar/gui/e-day-view-time-item.c
@@ -80,10 +80,9 @@ static void e_day_view_time_item_draw (GnomeCanvasItem *item,
GdkDrawable *drawable,
gint x, gint y,
gint width, gint height);
-static double e_day_view_time_item_point (GnomeCanvasItem *item,
- double x, double y,
- gint cx, gint cy,
- GnomeCanvasItem **actual_item);
+static GnomeCanvasItem *e_day_view_time_item_point (GnomeCanvasItem *item,
+ double x, double y,
+ gint cx, gint cy);
static gint e_day_view_time_item_event (GnomeCanvasItem *item,
GdkEvent *event);
static void e_day_view_time_item_increment_time (gint *hour,
@@ -649,13 +648,11 @@ e_day_view_time_item_increment_time (gint *hour,
}
}
-static double
+static GnomeCanvasItem *
e_day_view_time_item_point (GnomeCanvasItem *item, double x, double y,
- gint cx, gint cy,
- GnomeCanvasItem **actual_item)
+ gint cx, gint cy)
{
- *actual_item = item;
- return 0.0;
+ return item;
}
static gint
diff --git a/calendar/gui/e-day-view-top-item.c b/calendar/gui/e-day-view-top-item.c
index c0b718d63b..41a2b665df 100644
--- a/calendar/gui/e-day-view-top-item.c
+++ b/calendar/gui/e-day-view-top-item.c
@@ -781,21 +781,14 @@ day_view_top_item_draw (GnomeCanvasItem *canvas_item,
cairo_destroy (cr);
}
-static double
+static GnomeCanvasItem *
day_view_top_item_point (GnomeCanvasItem *item,
gdouble x,
gdouble y,
gint cx,
- gint cy,
- GnomeCanvasItem **actual_item)
+ gint cy)
{
- /* This is supposed to return the nearest item the the point
- * and the distance. Since we are the only item we just return
- * ourself and 0 for the distance. This is needed so that we
- * get button/motion events. */
- *actual_item = item;
-
- return 0.0;
+ return item;
}
static void
diff --git a/calendar/gui/e-meeting-time-sel-item.c b/calendar/gui/e-meeting-time-sel-item.c
index 72d7d724a3..18b21949a1 100644
--- a/calendar/gui/e-meeting-time-sel-item.c
+++ b/calendar/gui/e-meeting-time-sel-item.c
@@ -54,10 +54,9 @@ static void e_meeting_time_selector_item_draw (GnomeCanvasItem *item,
GdkDrawable *drawable,
gint x, gint y,
gint width, gint height);
-static double e_meeting_time_selector_item_point (GnomeCanvasItem *item,
- double x, double y,
- gint cx, gint cy,
- GnomeCanvasItem **actual_item);
+static GnomeCanvasItem *e_meeting_time_selector_item_point (GnomeCanvasItem *item,
+ double x, double y,
+ gint cx, gint cy);
static gint e_meeting_time_selector_item_event (GnomeCanvasItem *item,
GdkEvent *event);
static gint e_meeting_time_selector_item_button_press (EMeetingTimeSelectorItem *mts_item,
@@ -779,16 +778,11 @@ e_meeting_time_selector_item_paint_attendee_busy_periods (EMeetingTimeSelectorIt
* CANVAS ITEM ROUTINES - functions to be a GnomeCanvasItem.
*/
-/* This is supposed to return the nearest item the the point and the distance.
- Since we are the only item we just return ourself and 0 for the distance.
- This is needed so that we get button/motion events. */
-static double
+static GnomeCanvasItem *
e_meeting_time_selector_item_point (GnomeCanvasItem *item, double x, double y,
- gint cx, gint cy,
- GnomeCanvasItem **actual_item)
+ gint cx, gint cy)
{
- *actual_item = item;
- return 0.0;
+ return item;
}
static gint
diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c
index f2b3471e66..8309dcd8dc 100644
--- a/calendar/gui/e-week-view-event-item.c
+++ b/calendar/gui/e-week-view-event-item.c
@@ -1126,21 +1126,14 @@ week_view_event_item_draw (GnomeCanvasItem *canvas_item,
gdk_region_destroy (draw_region);
}
-static double
+static GnomeCanvasItem *
week_view_event_item_point (GnomeCanvasItem *item,
gdouble x,
gdouble y,
gint cx,
- gint cy,
- GnomeCanvasItem **actual_item)
+ gint cy)
{
- /* This is supposed to return the nearest item the the point
- * and the distance. Since we are the only item we just return
- * ourself and 0 for the distance. This is needed so that we
- * get button/motion events. */
- *actual_item = item;
-
- return 0.0;
+ return item;
}
static gint
diff --git a/calendar/gui/e-week-view-main-item.c b/calendar/gui/e-week-view-main-item.c
index a42b60ea40..5d09d45660 100644
--- a/calendar/gui/e-week-view-main-item.c
+++ b/calendar/gui/e-week-view-main-item.c
@@ -411,21 +411,14 @@ week_view_main_item_draw (GnomeCanvasItem *canvas_item,
}
}
-static gdouble
+static GnomeCanvasItem *
week_view_main_item_point (GnomeCanvasItem *item,
gdouble x,
gdouble y,
gint cx,
- gint cy,
- GnomeCanvasItem **actual_item)
+ gint cy)
{
- /* This is supposed to return the nearest item the the point
- * and the distance. Since we are the only item we just return
- * ourself and 0 for the distance. This is needed so that we
- * get button/motion events. */
- *actual_item = item;
-
- return 0.0;
+ return item;
}
static void
diff --git a/calendar/gui/e-week-view-titles-item.c b/calendar/gui/e-week-view-titles-item.c
index ab7a9db652..2e058d1056 100644
--- a/calendar/gui/e-week-view-titles-item.c
+++ b/calendar/gui/e-week-view-titles-item.c
@@ -243,21 +243,14 @@ week_view_titles_item_draw (GnomeCanvasItem *canvas_item,
g_object_unref (layout);
}
-static double
+static GnomeCanvasItem *
week_view_titles_item_point (GnomeCanvasItem *item,
gdouble x,
gdouble y,
gint cx,
- gint cy,
- GnomeCanvasItem **actual_item)
+ gint cy)
{
- /* This is supposed to return the nearest item the the point
- * and the distance. Since we are the only item we just return
- * ourself and 0 for the distance. This is needed so that we
- * get button/motion events. */
- *actual_item = item;
-
- return 0.0;
+ return item;
}
static void
diff --git a/libgnomecanvas/gnome-canvas-line.c b/libgnomecanvas/gnome-canvas-line.c
index 4e6364d7e0..20cde8a6d9 100644
--- a/libgnomecanvas/gnome-canvas-line.c
+++ b/libgnomecanvas/gnome-canvas-line.c
@@ -95,8 +95,8 @@ static void gnome_canvas_line_get_property (GObject *object,
static void gnome_canvas_line_update (GnomeCanvasItem *item, gdouble *affine, ArtSVP *clip_path, gint flags);
static void gnome_canvas_line_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
gint x, gint y, gint width, gint height);
-static gdouble gnome_canvas_line_point (GnomeCanvasItem *item, gdouble x, gdouble y,
- gint cx, gint cy, GnomeCanvasItem **actual_item);
+static GnomeCanvasItem *gnome_canvas_line_point (GnomeCanvasItem *item, gdouble x, gdouble y,
+ gint cx, gint cy);
static void gnome_canvas_line_bounds (GnomeCanvasItem *item, gdouble *x1, gdouble *y1, gdouble *x2, gdouble *y2);
static GnomeCanvasItemClass *parent_class;
@@ -995,9 +995,9 @@ gnome_canvas_line_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
}
}
-static double
+static GnomeCanvasItem *
gnome_canvas_line_point (GnomeCanvasItem *item, gdouble x, gdouble y,
- gint cx, gint cy, GnomeCanvasItem **actual_item)
+ gint cx, gint cy)
{
GnomeCanvasLine *line;
gdouble *line_points = NULL, *coords;
@@ -1015,8 +1015,6 @@ gnome_canvas_line_point (GnomeCanvasItem *item, gdouble x, gdouble y,
line = GNOME_CANVAS_LINE (item);
- *actual_item = item;
-
best = 1.0e36;
/* Handle smoothed lines by generating an expanded set ot points */
@@ -1174,7 +1172,7 @@ done:
if ((line_points != static_points) && (line_points != line->coords))
g_free (line_points);
- return best;
+ return best == 0.0 ? item : NULL;
}
static void
diff --git a/libgnomecanvas/gnome-canvas-pixbuf.c b/libgnomecanvas/gnome-canvas-pixbuf.c
index b591724153..bb824cb53a 100644
--- a/libgnomecanvas/gnome-canvas-pixbuf.c
+++ b/libgnomecanvas/gnome-canvas-pixbuf.c
@@ -93,12 +93,11 @@ static void gnome_canvas_pixbuf_update (GnomeCanvasItem *item, gdouble *affine,
ArtSVP *clip_path, gint flags);
static void gnome_canvas_pixbuf_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
gint x, gint y, gint width, gint height);
-static gdouble gnome_canvas_pixbuf_point (GnomeCanvasItem *item,
- gdouble x,
- gdouble y,
- gint cx,
- gint cy,
- GnomeCanvasItem **actual_item);
+static GnomeCanvasItem *gnome_canvas_pixbuf_point (GnomeCanvasItem *item,
+ gdouble x,
+ gdouble y,
+ gint cx,
+ gint cy);
static void gnome_canvas_pixbuf_bounds (GnomeCanvasItem *item,
gdouble *x1, gdouble *y1, gdouble *x2, gdouble *y2);
@@ -816,13 +815,12 @@ gnome_canvas_pixbuf_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
/* Point handler for the pixbuf canvas item */
-static double
+static GnomeCanvasItem *
gnome_canvas_pixbuf_point (GnomeCanvasItem *item,
gdouble x,
gdouble y,
gint cx,
- gint cy,
- GnomeCanvasItem **actual_item)
+ gint cy)
{
GnomeCanvasPixbuf *gcp;
PixbufPrivate *priv;
@@ -837,12 +835,10 @@ gnome_canvas_pixbuf_point (GnomeCanvasItem *item,
priv = gcp->priv;
pixbuf = priv->pixbuf;
- *actual_item = item;
-
no_hit = item->canvas->pixels_per_unit * 2 + 10;
if (!priv->pixbuf)
- return no_hit;
+ return NULL;
gnome_canvas_item_i2c_affine (item, i2c);
compute_render_affine (gcp, render_affine, i2c);
@@ -856,19 +852,19 @@ gnome_canvas_pixbuf_point (GnomeCanvasItem *item,
if (px < 0 || px >= gdk_pixbuf_get_width (pixbuf) ||
py < 0 || py >= gdk_pixbuf_get_height (pixbuf))
- return no_hit;
+ return NULL;
if (!gdk_pixbuf_get_has_alpha (pixbuf))
- return 0.0;
+ return item;
src = gdk_pixbuf_get_pixels (pixbuf) +
py * gdk_pixbuf_get_rowstride (pixbuf) +
px * gdk_pixbuf_get_n_channels (pixbuf);
if (src[3] < 128)
- return no_hit;
+ return NULL;
else
- return 0.0;
+ return item;
}
diff --git a/libgnomecanvas/gnome-canvas-rich-text.c b/libgnomecanvas/gnome-canvas-rich-text.c
index 5c7ed05709..64efcbddd7 100644
--- a/libgnomecanvas/gnome-canvas-rich-text.c
+++ b/libgnomecanvas/gnome-canvas-rich-text.c
@@ -121,10 +121,9 @@ static void gnome_canvas_rich_text_update (GnomeCanvasItem *item, gdouble *affin
ArtSVP *clip_path, gint flags);
static void gnome_canvas_rich_text_realize (GnomeCanvasItem *item);
static void gnome_canvas_rich_text_unrealize (GnomeCanvasItem *item);
-static gdouble gnome_canvas_rich_text_point (GnomeCanvasItem *item,
- gdouble x, gdouble y,
- gint cx, gint cy,
- GnomeCanvasItem **actual_item);
+static GnomeCanvasItem * gnome_canvas_rich_text_point (GnomeCanvasItem *item,
+ gdouble x, gdouble y,
+ gint cx, gint cy);
static void gnome_canvas_rich_text_draw (GnomeCanvasItem *item,
GdkDrawable *drawable,
gint x, gint y, gint width, gint height);
@@ -2008,16 +2007,13 @@ gnome_canvas_rich_text_update (GnomeCanvasItem *item, gdouble *affine,
gnome_canvas_update_bbox (item, x1, y1, x2, y2);
} /* gnome_canvas_rich_text_update */
-static double
+static GnomeCanvasItem *
gnome_canvas_rich_text_point (GnomeCanvasItem *item, gdouble x, gdouble y,
- gint cx, gint cy, GnomeCanvasItem **actual_item)
+ gint cx, gint cy)
{
GnomeCanvasRichText *text = GNOME_CANVAS_RICH_TEXT (item);
gdouble ax, ay;
gdouble x1, x2, y1, y2;
- gdouble dx, dy;
-
- *actual_item = item;
/* This is a lame cop-out. Anywhere inside of the bounding box. */
@@ -2030,23 +2026,9 @@ gnome_canvas_rich_text_point (GnomeCanvasItem *item, gdouble x, gdouble y,
y2 = ay + text->_priv->height;
if ((x > x1) && (y > y1) && (x < x2) && (y < y2))
- return 0.0;
-
- if (x < x1)
- dx = x1 - x;
- else if (x > x2)
- dx = x - x2;
- else
- dx = 0.0;
-
- if (y < y1)
- dy = y1 - y;
- else if (y > y2)
- dy = y - y2;
- else
- dy = 0.0;
+ return item;
- return sqrt (dx * dx + dy * dy);
+ return NULL;
} /* gnome_canvas_rich_text_point */
static void
diff --git a/libgnomecanvas/gnome-canvas-shape.c b/libgnomecanvas/gnome-canvas-shape.c
index 70f3516160..d1e7c1c3c3 100644
--- a/libgnomecanvas/gnome-canvas-shape.c
+++ b/libgnomecanvas/gnome-canvas-shape.c
@@ -75,8 +75,8 @@ static void gnome_canvas_shape_realize (GnomeCanvasItem *item);
static void gnome_canvas_shape_unrealize (GnomeCanvasItem *item);
static void gnome_canvas_shape_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
gint x, gint y, gint width, gint height);
-static gdouble gnome_canvas_shape_point (GnomeCanvasItem *item, gdouble x, gdouble y,
- gint cx, gint cy, GnomeCanvasItem **actual_item);
+static GnomeCanvasItem *gnome_canvas_shape_point (GnomeCanvasItem *item, gdouble x, gdouble y,
+ gint cx, gint cy);
static void gnome_canvas_shape_bounds (GnomeCanvasItem *item,
gdouble *x1, gdouble *y1, gdouble *x2, gdouble *y2);
@@ -1084,12 +1084,11 @@ gnome_canvas_shape_update (GnomeCanvasItem *item, gdouble *affine, ArtSVP *clip_
gnome_canvas_shape_update_gdk (shape, affine, clip_path, flags);
}
-static double
+static GnomeCanvasItem *
gnome_canvas_shape_point (GnomeCanvasItem *item, gdouble x, gdouble y,
- gint cx, gint cy, GnomeCanvasItem **actual_item)
+ gint cx, gint cy)
{
GnomeCanvasShape *shape;
- gdouble dist;
gint wind;
#if 0
@@ -1104,35 +1103,19 @@ gnome_canvas_shape_point (GnomeCanvasItem *item, gdouble x, gdouble y,
/* todo: update? */
if (shape->priv->fill_set && shape->priv->fill_svp) {
wind = art_svp_point_wind (shape->priv->fill_svp, cx, cy);
- if ((shape->priv->wind == ART_WIND_RULE_NONZERO) && (wind != 0)) {
- *actual_item = item;
- return 0.0;
- }
- if ((shape->priv->wind == ART_WIND_RULE_ODDEVEN) && ((wind & 0x1) != 0)) {
- *actual_item = item;
- return 0.0;
- }
+ if ((shape->priv->wind == ART_WIND_RULE_NONZERO) && (wind != 0))
+ return item;
+ if ((shape->priv->wind == ART_WIND_RULE_ODDEVEN) && ((wind & 0x1) != 0))
+ return item;
}
if (shape->priv->outline_set && shape->priv->outline_svp) {
wind = art_svp_point_wind (shape->priv->outline_svp, cx, cy);
- if (wind) {
- *actual_item = item;
- return 0.0;
- }
- }
-
- if (shape->priv->outline_set && shape->priv->outline_svp) {
- dist = art_svp_point_dist (shape->priv->outline_svp, cx, cy);
- } else if (shape->priv->fill_set && shape->priv->outline_svp) {
- dist = art_svp_point_dist (shape->priv->fill_svp, cx, cy);
- } else {
- return 1e12;
+ if (wind)
+ return item;
}
- *actual_item = item;
-
- return dist;
+ return NULL;
}
/* Helpers */
diff --git a/libgnomecanvas/gnome-canvas-text.c b/libgnomecanvas/gnome-canvas-text.c
index f85df6666a..d857eceac0 100644
--- a/libgnomecanvas/gnome-canvas-text.c
+++ b/libgnomecanvas/gnome-canvas-text.c
@@ -119,12 +119,11 @@ static void gnome_canvas_text_realize (GnomeCanvasItem *item);
static void gnome_canvas_text_unrealize (GnomeCanvasItem *item);
static void gnome_canvas_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
gint x, gint y, gint width, gint height);
-static gdouble gnome_canvas_text_point (GnomeCanvasItem *item,
- gdouble x,
- gdouble y,
- gint cx,
- gint cy,
- GnomeCanvasItem **actual_item);
+static GnomeCanvasItem *gnome_canvas_text_point (GnomeCanvasItem *item,
+ gdouble x,
+ gdouble y,
+ gint cx,
+ gint cy);
static void gnome_canvas_text_bounds (GnomeCanvasItem *item,
gdouble *x1, gdouble *y1, gdouble *x2, gdouble *y2);
@@ -1348,28 +1347,22 @@ gnome_canvas_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
}
/* Point handler for the text item */
-static double
+static GnomeCanvasItem *
gnome_canvas_text_point (GnomeCanvasItem *item, gdouble x, gdouble y,
- gint cx, gint cy, GnomeCanvasItem **actual_item)
+ gint cx, gint cy)
{
GnomeCanvasText *text;
PangoLayoutIter *iter;
gint x1, y1, x2, y2;
- gint dx, dy;
- gdouble dist, best;
text = GNOME_CANVAS_TEXT (item);
- *actual_item = item;
-
/* The idea is to build bounding rectangles for each of the lines of
* text (clipped by the clipping rectangle, if it is activated) and see
* whether the point is inside any of these. If it is, we are done.
* Otherwise, calculate the distance to the nearest rectangle.
*/
- best = 1.0e36;
-
iter = pango_layout_get_iter (text->layout);
do {
PangoRectangle log_rect;
@@ -1400,34 +1393,16 @@ gnome_canvas_text_point (GnomeCanvasItem *item, gdouble x, gdouble y,
/* Calculate distance from point to rectangle */
- if (cx < x1)
- dx = x1 - cx;
- else if (cx >= x2)
- dx = cx - x2 + 1;
- else
- dx = 0;
-
- if (cy < y1)
- dy = y1 - cy;
- else if (cy >= y2)
- dy = cy - y2 + 1;
- else
- dy = 0;
-
- if ((dx == 0) && (dy == 0)) {
+ if (cx >= x1 && cx < x2 && cy >= y1 && cy < y2) {
pango_layout_iter_free (iter);
- return 0.0;
+ return item;
}
- dist = sqrt (dx * dx + dy * dy);
- if (dist < best)
- best = dist;
-
} while (pango_layout_iter_next_line (iter));
pango_layout_iter_free (iter);
- return best / item->canvas->pixels_per_unit;
+ return NULL;
}
/* Bounds handler for the text item */
diff --git a/libgnomecanvas/gnome-canvas-widget.c b/libgnomecanvas/gnome-canvas-widget.c
index 2229803872..84450bc080 100644
--- a/libgnomecanvas/gnome-canvas-widget.c
+++ b/libgnomecanvas/gnome-canvas-widget.c
@@ -62,12 +62,11 @@ static void gnome_canvas_widget_update (GnomeCanvasItem *item,
gdouble *affine,
ArtSVP *clip_path,
gint flags);
-static gdouble gnome_canvas_widget_point (GnomeCanvasItem *item,
+static GnomeCanvasItem *gnome_canvas_widget_point (GnomeCanvasItem *item,
gdouble x,
gdouble y,
gint cx,
- gint cy,
- GnomeCanvasItem **actual_item);
+ gint cy);
static void gnome_canvas_widget_bounds (GnomeCanvasItem *item,
gdouble *x1,
gdouble *y1,
@@ -424,18 +423,15 @@ gnome_canvas_widget_draw (GnomeCanvasItem *item,
#endif
}
-static double
+static GnomeCanvasItem *
gnome_canvas_widget_point (GnomeCanvasItem *item, gdouble x, gdouble y,
- gint cx, gint cy, GnomeCanvasItem **actual_item)
+ gint cx, gint cy)
{
GnomeCanvasWidget *witem;
gdouble x1, y1, x2, y2;
- gdouble dx, dy;
witem = GNOME_CANVAS_WIDGET (item);
- *actual_item = item;
-
gnome_canvas_c2w (item->canvas, witem->cx, witem->cy, &x1, &y1);
x2 = x1 + (witem->cwidth - 1) / item->canvas->pixels_per_unit;
@@ -444,25 +440,10 @@ gnome_canvas_widget_point (GnomeCanvasItem *item, gdouble x, gdouble y,
/* Is point inside widget bounds? */
if ((x >= x1) && (y >= y1) && (x <= x2) && (y <= y2))
- return 0.0;
+ return item;
/* Point is outside widget bounds */
-
- if (x < x1)
- dx = x1 - x;
- else if (x > x2)
- dx = x - x2;
- else
- dx = 0.0;
-
- if (y < y1)
- dy = y1 - y;
- else if (y > y2)
- dy = y - y2;
- else
- dy = 0.0;
-
- return sqrt (dx * dx + dy * dy);
+ return NULL;
}
static void
diff --git a/libgnomecanvas/gnome-canvas.c b/libgnomecanvas/gnome-canvas.c
index f79b37e75e..958fc45e1c 100644
--- a/libgnomecanvas/gnome-canvas.c
+++ b/libgnomecanvas/gnome-canvas.c
@@ -512,13 +512,12 @@ gnome_canvas_item_invoke_update (GnomeCanvasItem *item,
* This is potentially evil, as we are relying on matrix inversion (Lauris)
*/
-static double
+static GnomeCanvasItem *
gnome_canvas_item_invoke_point (GnomeCanvasItem *item,
gdouble x,
gdouble y,
gint cx,
- gint cy,
- GnomeCanvasItem **actual_item)
+ gint cy)
{
/* Calculate x & y in item local coordinates */
@@ -555,9 +554,9 @@ gnome_canvas_item_invoke_point (GnomeCanvasItem *item,
#endif
if (GNOME_CANVAS_ITEM_GET_CLASS (item)->point)
- return GNOME_CANVAS_ITEM_GET_CLASS (item)->point (item, x, y, cx, cy, actual_item);
+ return GNOME_CANVAS_ITEM_GET_CLASS (item)->point (item, x, y, cx, cy);
- return 1e18;
+ return NULL;
}
/**
@@ -1400,10 +1399,9 @@ static void gnome_canvas_group_draw (GnomeCanvasItem *item,
GdkDrawable *drawable,
gint x, gint y,
gint width, gint height);
-static gdouble gnome_canvas_group_point (GnomeCanvasItem *item,
+static GnomeCanvasItem *gnome_canvas_group_point (GnomeCanvasItem *item,
gdouble x, gdouble y,
- gint cx, gint cy,
- GnomeCanvasItem **actual_item);
+ gint cx, gint cy);
static void gnome_canvas_group_bounds (GnomeCanvasItem *item,
gdouble *x1, gdouble *y1,
gdouble *x2, gdouble *y2);
@@ -1746,55 +1744,34 @@ gnome_canvas_group_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
}
/* Point handler for canvas groups */
-static double
+static GnomeCanvasItem *
gnome_canvas_group_point (GnomeCanvasItem *item,
gdouble x,
gdouble y,
gint cx,
- gint cy,
- GnomeCanvasItem **actual_item)
+ gint cy)
{
GnomeCanvasGroup *group;
GList *list;
GnomeCanvasItem *child, *point_item;
- gdouble gx, gy;
- gdouble dist, best;
- gint has_point;
group = GNOME_CANVAS_GROUP (item);
- best = 0.0;
- *actual_item = NULL;
-
- gx = x;
- gy = y;
-
- dist = 0.0; /* keep gcc happy */
-
- for (list = group->item_list; list; list = list->next) {
+ for (list = g_list_last (group->item_list); list; list = list->prev) {
child = list->data;
if ((child->x1 > cx) || (child->y1 > cy) || (child->x2 < cx) || (child->y2 < cy))
continue;
- point_item = NULL; /* cater for incomplete item implementations */
-
- if ((child->flags & GNOME_CANVAS_ITEM_VISIBLE)
- && GNOME_CANVAS_ITEM_GET_CLASS (child)->point) {
- dist = gnome_canvas_item_invoke_point (child, gx, gy, cx, cy, &point_item);
- has_point = TRUE;
- } else
- has_point = FALSE;
+ if (!(child->flags & GNOME_CANVAS_ITEM_VISIBLE))
+ continue;
- if (has_point
- && point_item
- && ((gint) (dist * item->canvas->pixels_per_unit + 0.5) <= 0)) {
- best = dist;
- *actual_item = point_item;
- }
+ point_item = gnome_canvas_item_invoke_point (child, x, y, cx, cy);
+ if (point_item)
+ return point_item;
}
- return best;
+ return NULL;
}
/* Bounds handler for canvas groups */
@@ -2690,8 +2667,7 @@ pick_current_item (GnomeCanvas *canvas, GdkEvent *event)
/* find the closest item */
if (canvas->root->flags & GNOME_CANVAS_ITEM_VISIBLE)
- gnome_canvas_item_invoke_point (canvas->root, x, y, cx, cy,
- &canvas->new_current_item);
+ canvas->new_current_item = gnome_canvas_item_invoke_point (canvas->root, x, y, cx, cy);
else
canvas->new_current_item = NULL;
} else
@@ -3570,19 +3546,13 @@ gnome_canvas_update_now (GnomeCanvas *canvas)
GnomeCanvasItem *
gnome_canvas_get_item_at (GnomeCanvas *canvas, gdouble x, gdouble y)
{
- GnomeCanvasItem *item;
- gdouble dist;
gint cx, cy;
g_return_val_if_fail (GNOME_IS_CANVAS (canvas), NULL);
gnome_canvas_w2c (canvas, x, y, &cx, &cy);
- dist = gnome_canvas_item_invoke_point (canvas->root, x, y, cx, cy, &item);
- if ((gint) (dist * canvas->pixels_per_unit + 0.5) <= 0)
- return item;
- else
- return NULL;
+ return gnome_canvas_item_invoke_point (canvas->root, x, y, cx, cy);
}
/* Queues an update of the canvas */
diff --git a/libgnomecanvas/gnome-canvas.h b/libgnomecanvas/gnome-canvas.h
index 864f9e649f..70a8f5c736 100644
--- a/libgnomecanvas/gnome-canvas.h
+++ b/libgnomecanvas/gnome-canvas.h
@@ -171,14 +171,13 @@ struct _GnomeCanvasItemClass {
void (* draw) (GnomeCanvasItem *item, GdkDrawable *drawable,
gint x, gint y, gint width, gint height);
- /* Calculate the distance from an item to the specified point. It also
- * returns a canvas item which is the item itself in the case of the
- * object being an actual leaf item, or a child in case of the object
- * being a canvas group. (cx, cy) are the canvas pixel coordinates that
- * correspond to the item-relative coordinates (x, y).
+ /* Returns the canvas item which is at the given location. This is the
+ * item itself in the case of the object being an actual leaf item, or
+ * a child in case of the object being a canvas group. (cx, cy) are
+ * the canvas pixel coordinates that correspond to the item-relative
+ * coordinates (x, y).
*/
- gdouble (* point) (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy,
- GnomeCanvasItem **actual_item);
+ GnomeCanvasItem * (* point) (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy);
/* Fetch the item's bounding box (need not be exactly tight). This
* should be in item-relative coordinates.
diff --git a/widgets/misc/e-calendar-item.c b/widgets/misc/e-calendar-item.c
index f5d2f870af..5ca1143c96 100644
--- a/widgets/misc/e-calendar-item.c
+++ b/widgets/misc/e-calendar-item.c
@@ -90,12 +90,11 @@ static void e_calendar_item_draw_day_numbers (ECalendarItem *calitem,
gint start_weekday,
gint cells_x,
gint cells_y);
-static gdouble e_calendar_item_point (GnomeCanvasItem *item,
+static GnomeCanvasItem *e_calendar_item_point (GnomeCanvasItem *item,
gdouble x,
gdouble y,
gint cx,
- gint cy,
- GnomeCanvasItem **actual_item);
+ gint cy);
static void e_calendar_item_stop_selecting (ECalendarItem *calitem,
guint32 time);
static void e_calendar_item_selection_add_days (ECalendarItem *calitem,
@@ -1760,13 +1759,11 @@ e_calendar_item_get_week_number (ECalendarItem *calitem,
/* This is supposed to return the nearest item the the point and the distance.
Since we are the only item we just return ourself and 0 for the distance.
This is needed so that we get button/motion events. */
-static double
+static GnomeCanvasItem *
e_calendar_item_point (GnomeCanvasItem *item, gdouble x, gdouble y,
- gint cx, gint cy,
- GnomeCanvasItem **actual_item)
+ gint cx, gint cy)
{
- *actual_item = item;
- return 0.0;
+ return item;
}
static void
diff --git a/widgets/misc/e-canvas-background.c b/widgets/misc/e-canvas-background.c
index f6179379e4..b2be246f21 100644
--- a/widgets/misc/e-canvas-background.c
+++ b/widgets/misc/e-canvas-background.c
@@ -371,23 +371,21 @@ ecb_draw (GnomeCanvasItem *item,
x1, y1, x2 - x1, y2 - y1);
}
-static double
-ecb_point (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy,
- GnomeCanvasItem **actual_item)
+static GnomeCanvasItem *
+ecb_point (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy)
{
ECanvasBackground *ecb = E_CANVAS_BACKGROUND (item);
if (ecb->priv->x1 >= 0 && ecb->priv->x1 > x)
- return 1.0;
+ return NULL;
if (ecb->priv->x2 >= 0 && ecb->priv->x2 < x)
- return 1.0;
+ return NULL;
if (ecb->priv->y1 >= 0 && ecb->priv->y1 > y)
- return 1.0;
+ return NULL;
if (ecb->priv->y2 >= 0 && ecb->priv->y2 < y)
- return 1.0;
- *actual_item = item;
+ return NULL;
- return 0.0;
+ return item;
}
static void
diff --git a/widgets/misc/e-canvas.c b/widgets/misc/e-canvas.c
index dfa529ec6b..0b24b84cb9 100644
--- a/widgets/misc/e-canvas.c
+++ b/widgets/misc/e-canvas.c
@@ -167,13 +167,12 @@ canvas_emit_event (GnomeCanvas *canvas,
* invariant. */
#define HACKISH_AFFINE
-static double
+static GnomeCanvasItem *
gnome_canvas_item_invoke_point (GnomeCanvasItem *item,
gdouble x,
gdouble y,
gint cx,
- gint cy,
- GnomeCanvasItem **actual_item)
+ gint cy)
{
#ifdef HACKISH_AFFINE
gdouble i2w[6], w2c[6], i2c[6], c2i[6];
@@ -193,7 +192,7 @@ gnome_canvas_item_invoke_point (GnomeCanvasItem *item,
#endif
return (* GNOME_CANVAS_ITEM_CLASS (G_OBJECT_GET_CLASS (item))->point) (
- item, x, y, cx, cy, actual_item);
+ item, x, y, cx, cy);
}
/* Re-picks the current item in the canvas, based on the event's coordinates.
@@ -287,8 +286,7 @@ pick_current_item (GnomeCanvas *canvas, GdkEvent *event)
/* find the closest item */
if (canvas->root->flags & GNOME_CANVAS_ITEM_VISIBLE)
- gnome_canvas_item_invoke_point (canvas->root, x, y, cx, cy,
- &canvas->new_current_item);
+ canvas->new_current_item = gnome_canvas_item_invoke_point (canvas->root, x, y, cx, cy);
else
canvas->new_current_item = NULL;
} else
diff --git a/widgets/table/e-table-field-chooser-item.c b/widgets/table/e-table-field-chooser-item.c
index 67beee9d52..20048007d7 100644
--- a/widgets/table/e-table-field-chooser-item.c
+++ b/widgets/table/e-table-field-chooser-item.c
@@ -522,12 +522,10 @@ etfci_draw (GnomeCanvasItem *item,
}
}
-static double
-etfci_point (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy,
- GnomeCanvasItem **actual_item)
+static GnomeCanvasItem *
+etfci_point (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy)
{
- *actual_item = item;
- return 0.0;
+ return item;
}
static gboolean
diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c
index f3ed548463..0f7444285a 100644
--- a/widgets/table/e-table-header-item.c
+++ b/widgets/table/e-table-header-item.c
@@ -1070,12 +1070,10 @@ ethi_draw (GnomeCanvasItem *item,
g_hash_table_destroy (arrows);
}
-static double
-ethi_point (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy,
- GnomeCanvasItem **actual_item)
+static GnomeCanvasItem *
+ethi_point (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy)
{
- *actual_item = item;
- return 0.0;
+ return item;
}
/*
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
index 7bd0ed4427..d68c69a220 100644
--- a/widgets/table/e-table-item.c
+++ b/widgets/table/e-table-item.c
@@ -2042,13 +2042,10 @@ exit:
cairo_destroy (cr);
}
-static double
-eti_point (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy,
- GnomeCanvasItem **actual_item)
+static GnomeCanvasItem *
+eti_point (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy)
{
- *actual_item = item;
-
- return 0.0;
+ return item;
}
static gboolean
diff --git a/widgets/text/e-reflow.c b/widgets/text/e-reflow.c
index 3e062f0f93..4974fd8f04 100644
--- a/widgets/text/e-reflow.c
+++ b/widgets/text/e-reflow.c
@@ -43,7 +43,7 @@ static void e_reflow_unrealize (GnomeCanvasItem *item);
static void e_reflow_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
gint x, gint y, gint width, gint height);
static void e_reflow_update (GnomeCanvasItem *item, gdouble affine[6], ArtSVP *clip_path, gint flags);
-static gdouble e_reflow_point (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy, GnomeCanvasItem **actual_item);
+static GnomeCanvasItem *e_reflow_point (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy);
static void e_reflow_reflow (GnomeCanvasItem *item, gint flags);
static void set_empty (EReflow *reflow);
@@ -1347,22 +1347,16 @@ e_reflow_update (GnomeCanvasItem *item, gdouble affine[6], ArtSVP *clip_path, gi
}
}
-static double
+static GnomeCanvasItem *
e_reflow_point (GnomeCanvasItem *item,
- gdouble x, gdouble y, gint cx, gint cy,
- GnomeCanvasItem **actual_item)
+ gdouble x, gdouble y, gint cx, gint cy)
{
- gdouble distance = 1;
-
- *actual_item = NULL;
+ GnomeCanvasItem *child;
if (GNOME_CANVAS_ITEM_CLASS (e_reflow_parent_class)->point)
- distance = GNOME_CANVAS_ITEM_CLASS (e_reflow_parent_class)->point (item, x, y, cx, cy, actual_item);
- if ((gint) (distance * item->canvas->pixels_per_unit + 0.5) <= 0 && *actual_item)
- return distance;
+ child = GNOME_CANVAS_ITEM_CLASS (e_reflow_parent_class)->point (item, x, y, cx, cy);
- *actual_item = item;
- return 0;
+ return child ? child : item;
#if 0
if (y >= E_REFLOW_BORDER_WIDTH && y <= reflow->height - E_REFLOW_BORDER_WIDTH) {
gfloat n_x;
diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c
index 378a8dfc0e..e58d5bf8a2 100644
--- a/widgets/text/e-text.c
+++ b/widgets/text/e-text.c
@@ -1620,9 +1620,9 @@ e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
}
/* Point handler for the text item */
-static double
+static GnomeCanvasItem *
e_text_point (GnomeCanvasItem *item, gdouble x, gdouble y,
- gint cx, gint cy, GnomeCanvasItem **actual_item)
+ gint cx, gint cy)
{
EText *text;
gdouble clip_width;
@@ -1630,8 +1630,6 @@ e_text_point (GnomeCanvasItem *item, gdouble x, gdouble y,
text = E_TEXT (item);
- *actual_item = item;
-
/* The idea is to build bounding rectangles for each of the lines of
* text (clipped by the clipping rectangle, if it is activated) and see
* whether the point is inside any of these. If it is, we are done.
@@ -1656,17 +1654,17 @@ e_text_point (GnomeCanvasItem *item, gdouble x, gdouble y,
cx > text->clip_cx + clip_width ||
cy < text->clip_cy ||
cy > text->clip_cy + clip_height)
- return 1;
+ return NULL;
if (text->fill_clip_rectangle || !text->text || !*text->text)
- return 0;
+ return item;
cx -= text->cx;
if (pango_layout_xy_to_index (text->layout, cx, cy, NULL, NULL))
- return 0;
+ return item;
- return 1;
+ return NULL;
}
/* Bounds handler for the text item */