+void BufferView::updateHoveredInset() const
+{
+ // Get inset under mouse, if there is one.
+ int const x = d->mouse_position_cache_.x_;
+ int const y = d->mouse_position_cache_.y_;
+ Inset const * covering_inset = getCoveringInset(buffer_.text(), x, y);
+
+ d->clickable_inset_ = covering_inset && covering_inset->clickable(x, y);
+
+ if (covering_inset == d->last_inset_)
+ // Same inset, no need to do anything...
+ return;
+
+ bool need_redraw = false;
+ if (d->last_inset_) {
+ // Remove the hint on the last hovered inset (if any).
+ need_redraw |= d->last_inset_->setMouseHover(this, false);
+ d->last_inset_ = 0;
+ }
+
+ // const_cast because of setMouseHover().
+ Inset * inset = const_cast<Inset *>(covering_inset);
+ if (inset && inset->setMouseHover(this, true)) {
+ need_redraw = true;
+ // Only the insets that accept the hover state, do
+ // clear the last_inset_, so only set the last_inset_
+ // member if the hovered setting is accepted.
+ d->last_inset_ = inset;
+ }
+
+ if (need_redraw) {
+ LYXERR(Debug::PAINTING, "Mouse hover detected at: ("
+ << d->mouse_position_cache_.x_ << ", "
+ << d->mouse_position_cache_.y_ << ")");
+
+ d->update_strategy_ = DecorationUpdate;
+
+ // This event (moving without mouse click) is not passed further.
+ // This should be changed if it is further utilized.
+ buffer_.changed(false);
+ }
+}
+
+
+void BufferView::clearLastInset(Inset * inset) const
+{
+ if (d->last_inset_ != inset) {
+ LYXERR0("Wrong last_inset!");
+ LASSERT(false, /**/);
+ }
+ d->last_inset_ = 0;
+}
+
+