]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiWorkArea.cpp
Fix the tab ordering of GuiDocument components.
[lyx.git] / src / frontends / qt4 / GuiWorkArea.cpp
index 0b8b7ea2f2559cfb9d1199e7f4e2a41e37b26270..026c7699db10dbf98d0ece4c1d1c698a71bc4f2d 100644 (file)
@@ -47,6 +47,7 @@
 #include "support/debug.h"
 #include "support/gettext.h"
 #include "support/FileName.h"
+#include "support/lassert.h"
 
 #include "frontends/Application.h"
 #include "frontends/FontMetrics.h"
@@ -772,18 +773,20 @@ void GuiWorkArea::mousePressEvent(QMouseEvent * e)
                return;
        }
 
+       inputContext()->reset();
+
+       FuncRequest const cmd(LFUN_MOUSE_PRESS, e->x(), e->y(),
+               q_button_state(e->button()));
+       dispatch(cmd, q_key_state(e->modifiers()));
+
        // Save the context menu on mouse press, because also the mouse
        // cursor is set on mouse press. Afterwards, we can either release
        // the mousebutton somewhere else, or the cursor might have moved
-       // due to the DEPM.
+       // due to the DEPM. We need to do this after the mouse has been
+       // set in dispatch(), because the selection state might change.
        if (e->button() == Qt::RightButton)
                context_menu_name_ = buffer_view_->contextMenu(e->x(), e->y());
 
-       inputContext()->reset();
-
-       FuncRequest const cmd(LFUN_MOUSE_PRESS, e->x(), e->y(),
-               q_button_state(e->button()));
-       dispatch(cmd, q_key_state(e->modifiers()));
        e->accept();
 }
 
@@ -943,7 +946,11 @@ void GuiWorkArea::generateSyntheticMouseEvent()
 
        // In which paragraph do we have to set the cursor ?
        Cursor & cur = buffer_view_->cursor();
-       TextMetrics const & tm = buffer_view_->textMetrics(cur.text());
+       // FIXME: we don't know howto handle math.
+       Text * text = cur.text();
+       if (!text)
+               return;
+       TextMetrics const & tm = buffer_view_->textMetrics(text);
 
        pair<pit_type, const ParagraphMetrics *> p = up ? tm.first() : tm.last();
        ParagraphMetrics const & pm = *p.second;
@@ -1009,9 +1016,17 @@ void GuiWorkArea::keyPressEvent(QKeyEvent * ev)
        // it looks like this is only needed on X11
 #ifdef Q_WS_X11
        if (qApp->hasPendingEvents() && ev->isAutoRepeat()) {
-               LYXERR(Debug::KEY, "system is busy: keyPress event ignored");
-               ev->ignore();
-               return;
+               switch (ev->key()) {
+               case Qt::Key_PageDown:
+               case Qt::Key_PageUp:
+               case Qt::Key_Left:
+               case Qt::Key_Right:
+               case Qt::Key_Up:
+               case Qt::Key_Down:
+                       LYXERR(Debug::KEY, "system is busy: scroll key event ignored");
+                       ev->ignore();
+                       return;
+               }
        }
 #endif
 
@@ -1071,7 +1086,7 @@ void GuiWorkArea::resizeEvent(QResizeEvent * ev)
 
 void GuiWorkArea::update(int x, int y, int w, int h)
 {
-       viewport()->repaint(x, y, w, h);
+       viewport()->update(x, y, w, h);
 }