]> git.lyx.org Git - features.git/blobdiff - src/BufferView.cpp
Fixup 9f92fc92: improve FIXME in SystemcallPrivate::startProcess
[features.git] / src / BufferView.cpp
index 79bf01f3ce49581027a1d6f6babd3734968e7f8a..bff44cdbf02ae98d4f8d15b789ea911cfa7bfc03 100644 (file)
@@ -331,16 +331,20 @@ BufferView::~BufferView()
 }
 
 
-int BufferView::rightMargin() const
+int BufferView::defaultMargin() const
 {
        // The value used to be hardcoded to 10
-       int const default_margin = zoomedPixels(10);
+       return zoomedPixels(20);
+}
+
+
+int BufferView::rightMargin() const
+{
        // The additional test for the case the outliner is opened.
-       if (!full_screen_ || !lyxrc.full_screen_limit
-           || width_ < lyxrc.full_screen_width + 2 * default_margin)
-               return default_margin;
+       if (full_screen_ && lyxrc.full_screen_limit)
+               return max(defaultMargin(), (width_ - lyxrc.full_screen_width) / 2);
 
-       return (width_ - lyxrc.full_screen_width) / 2;
+       return defaultMargin();
 }
 
 
@@ -2383,12 +2387,50 @@ Inset const * BufferView::getCoveringInset(Text const & text,
 }
 
 
+Inset const * BufferView::clickableMathInset(InsetMathNest const * inset,
+               CoordCache::Insets const & inset_cache, int x, int y) const
+{
+       for (size_t i = 0; i < inset->nargs(); ++i) {
+               MathData const & ar = inset->cell(i);
+               for (size_t j = 0; j < ar.size(); ++j) {
+                       string const name = lyxerr.debugging(Debug::MATHED)
+                               ? insetName(ar[j].nucleus()->lyxCode())
+                               : string();
+                       LYXERR(Debug::MATHED, "Checking inset: " << name);
+                       if (ar[j].nucleus()->clickable(*this, x, y)) {
+                               if (inset_cache.covers(ar[j].nucleus(), x, y)) {
+                                       LYXERR(Debug::MATHED, "Clickable inset: "
+                                              << name);
+                                       return ar[j].nucleus();
+                               }
+                       }
+                       InsetMathNest const * imn =
+                               ar[j].nucleus()->asNestInset();
+                       if (imn) {
+                               Inset const * inner =
+                                       clickableMathInset(imn, inset_cache, x, y);
+                               if (inner)
+                                       return inner;
+                       }
+               }
+       }
+       return nullptr;
+}
+
+
 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);
+       if (covering_inset && covering_inset->asInsetMath()) {
+               Inset const * inner_inset = clickableMathInset(
+                               covering_inset->asInsetMath()->asNestInset(),
+                               coordCache().getInsets(), x, y);
+               if (inner_inset)
+                       covering_inset = inner_inset;
+       }
 
        d->clickable_inset_ = covering_inset && covering_inset->clickable(*this, x, y);
 
@@ -3159,7 +3201,9 @@ void BufferView::caretPosAndDim(Point & p, Dimension & dim) const
        } else {
                Font const font = cur.real_current_font;
                frontend::FontMetrics const & fm = theFontMetrics(font);
-               dim.wid = fm.lineWidth();
+               // lineWidth() can be 0 to mean 'thin line' on HiDpi, but the
+               // caret drawing code is not prepared for that.
+               dim.wid = max(fm.lineWidth(), 1);
                dim.asc = fm.maxAscent();
                dim.des = fm.maxDescent();
        }