]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiWorkArea.cpp
Avoid extra space in tooltips
[lyx.git] / src / frontends / qt4 / GuiWorkArea.cpp
index d68185c4b6af4753961caf5bcc33048703ab9f98..129656444b73b5a6e9ef33d41cd48b52abae3774 100644 (file)
@@ -897,7 +897,23 @@ void GuiWorkArea::wheelEvent(QWheelEvent * ev)
 {
        // Wheel rotation by one notch results in a delta() of 120 (see
        // documentation of QWheelEvent)
+       // But first we have to ignore horizontal scroll events.
+#if QT_VERSION < 0x050000
+       if (ev->orientation() == Qt::Horizontal) {
+               ev->accept();
+               return;
+       }
        double const delta = ev->delta() / 120.0;
+#else
+       QPoint const aDelta = ev->angleDelta();
+       // skip horizontal wheel event
+       if (abs(aDelta.x()) > abs(aDelta.y())) {
+               ev->accept();
+               return;
+       }
+       double const delta = aDelta.y() / 120.0;
+#endif
+
        bool zoom = false;
        switch (lyxrc.scroll_wheel_zoom) {
        case LyXRC::SCROLL_WHEEL_ZOOM_CTRL:
@@ -1245,11 +1261,15 @@ void GuiWorkArea::Private::paintPreeditText(GuiPainter & pain)
 void GuiWorkArea::paintEvent(QPaintEvent * ev)
 {
        // Do not trigger the painting machinery if we are not ready (see
-       // bug #10989). However, since macOS has turned the screen black at
-       // this point, our backing store has to be copied to screen.
-       if (view().busy()) {
-               // this is a no-op except on macOS.
+       // bug #10989). The second test triggers when in the middle of a
+       // dispatch operation.
+       if (view().busy() || d->buffer_view_->buffer().undo().activeUndoGroup()) {
+               // Since macOS has turned the screen black at this point, our
+               // backing store has to be copied to screen (this is a no-op
+               // except on macOS).
                d->updateScreen(ev->rect());
+               // Ignore this paint event, but request a new one for later.
+               viewport()->update(ev->rect());
                ev->accept();
                return;
        }
@@ -1288,12 +1308,13 @@ void GuiWorkArea::inputMethodEvent(QInputMethodEvent * e)
 
        // insert the processed text in the document (handles undo)
        if (!e->commitString().isEmpty()) {
-               d->buffer_view_->cursor().beginUndoGroup();
-               d->buffer_view_->cursor().insert(qstring_to_ucs4(e->commitString()));
+               FuncRequest cmd(LFUN_SELF_INSERT,
+                               qstring_to_ucs4(e->commitString()),
+                               FuncRequest::KEYBOARD);
+               dispatch(cmd);
+               // FIXME: this is supposed to remove traces from preedit
+               // string. Can we avoid calling it explicitely?
                d->buffer_view_->updateMetrics();
-               d->buffer_view_->cursor().endUndoGroup();
-               d->updateCaretGeometry();
-               viewport()->update();
        }
 
        // Hide the caret during the test transformation.