+void
+CanvasNoteEvent::set_mouse_fractions (GdkEvent* ev)
+{
+ double ix, iy;
+ double bx1, bx2, by1, by2;
+ bool set_cursor = false;
+
+ switch (ev->type) {
+ case GDK_MOTION_NOTIFY:
+ ix = ev->motion.x;
+ iy = ev->motion.y;
+ set_cursor = true;
+ break;
+ case GDK_ENTER_NOTIFY:
+ ix = ev->crossing.x;
+ iy = ev->crossing.y;
+ set_cursor = true;
+ break;
+ case GDK_BUTTON_PRESS:
+ case GDK_BUTTON_RELEASE:
+ ix = ev->button.x;
+ iy = ev->button.y;
+ break;
+ default:
+ _mouse_x_fraction = -1.0;
+ _mouse_y_fraction = -1.0;
+ return;
+ }
+
+ _item->get_bounds (bx1, by1, bx2, by2);
+ _item->w2i (ix, iy);
+ /* hmm, something wrong here. w2i should give item-local coordinates
+ but it doesn't. for now, finesse this.
+ */
+ ix = ix - bx1;
+ iy = iy - by1;
+
+ /* fraction of width/height */
+ double xf;
+ double yf;
+ bool notify = false;
+
+ xf = ix / (bx2 - bx1);
+ yf = iy / (by2 - by1);
+
+ if (xf != _mouse_x_fraction || yf != _mouse_y_fraction) {
+ notify = true;
+ }
+
+ _mouse_x_fraction = xf;
+ _mouse_y_fraction = yf;
+
+ if (notify) {
+ _region.note_mouse_position (_mouse_x_fraction, _mouse_y_fraction, set_cursor);
+ }
+}
+