From eac423830d4a87e48bb5b1a76c9380525ca026fe Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Fri, 3 Aug 2007 16:02:25 +0000 Subject: [PATCH] Fix several middle-click pasting problems * src/BufferView.cpp (workAreaDispatch): be sure to call haveSelection() as we do in LyXFunc::dispatch. * src/Text3.cpp (doDispatch): refactor the handling of LFUN_MOUSE_PRESS. In particular, make sure that the cursor is alsways set through BufferView::mouseSetCursor, so that the selection is correctly saved. * src/CutAndPaste.cpp (pasteSelection): do not set the selection, since paste methods do not do it. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@19292 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.cpp | 4 ++++ src/CutAndPaste.cpp | 1 - src/Text3.cpp | 31 +++++++++++-------------------- status.15x | 5 +++++ 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 390b62e01d..5ee6410efc 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -63,6 +63,7 @@ #include "frontends/alert.h" #include "frontends/FileDialog.h" #include "frontends/FontMetrics.h" +#include "frontends/Selection.h" #include "graphics/Previews.h" @@ -1225,6 +1226,9 @@ bool BufferView::workAreaDispatch(FuncRequest const & cmd0) if (!cur.result().dispatched()) cur.dispatch(cmd); + //Do we have a selection? + theSelection().haveSelection(cursor().selection()); + // Redraw if requested and necessary. if (cur.result().dispatched() && cur.result().update()) return update(cur.result().update()); diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp index c34fc5d230..491d4a0e76 100644 --- a/src/CutAndPaste.cpp +++ b/src/CutAndPaste.cpp @@ -791,7 +791,6 @@ void pasteSelection(Cursor & cur, ErrorList & errorList) recordUndo(cur); pasteParagraphList(cur, selectionBuffer[0].first, selectionBuffer[0].second, errorList); - cur.setSelection(); } diff --git a/src/Text3.cpp b/src/Text3.cpp index f3f5f6b3d1..3c3b937993 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -1015,43 +1015,34 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) // Single-click on work area case LFUN_MOUSE_PRESS: { - cap::saveSelection(bv->cursor()); // Right click on a footnote flag opens float menu if (cmd.button() == mouse_button::button3) cur.clearSelection(); - // Middle button press pastes if we have a selection - // We do this here as if the selection was inside an inset - // it could get cleared on the unlocking of the inset so - // we have to check this first - bool paste_internally = false; - if (cmd.button() == mouse_button::button2 && cap::selection()) { - // Copy the selection buffer to the clipboard - // stack, because we want it to appear in the - // "Edit->Paste recent" menu. - cap::copySelectionToStack(); - paste_internally = true; - } + // Set the cursor + bool update = bv->mouseSetCursor(cur); // Insert primary selection with middle mouse // if there is a local selection in the current buffer, // insert this if (cmd.button() == mouse_button::button2) { - if (paste_internally) { - cap::pasteSelection(cur, bv->buffer()->errorList("Paste")); + if (cap::selection()) { + // Copy the selection buffer to the clipboard + // stack, because we want it to appear in the + // "Edit->Paste recent" menu. + cap::copySelectionToStack(); + + cap::pasteSelection(bv->cursor(), + bv->buffer()->errorList("Paste")); bv->buffer()->errors("Paste"); - cur.clearSelection(); // bug 393 bv->buffer()->markDirty(); finishUndo(); } else { - bv->mouseSetCursor(cur); lyx::dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph")); } } - // we have to update after dePM triggered - bool update = bv->mouseSetCursor(cur); - + // we have to update after dEPM triggered if (!update && cmd.button() == mouse_button::button1) { needsUpdate = false; cur.noUpdate(); diff --git a/status.15x b/status.15x index 4e584221af..195bc92e80 100644 --- a/status.15x +++ b/status.15x @@ -43,6 +43,11 @@ What's new - Fix bug where using pdfsync marks the document 'changed' (bug 4023). +- Fix pasting a selection from the same LyX document with middle mouse + button. + +- Fix pasting of a selection from other applications (X11 only). + - Coherent behaviour when inserting over a selection: now the selection is always replaced by the insertion (bug 672).