From d48e5330bee3218336fb443d726b625c84eacf10 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Sun, 8 Feb 2015 17:41:28 +0100 Subject: [PATCH] Add pref option to disable middle-mouse-button paste Fixes: #9399 --- src/LyXRC.cpp | 15 +++++++++++ src/LyXRC.h | 3 +++ src/Text3.cpp | 12 +++++---- src/frontends/qt4/GuiPrefs.cpp | 4 +++ src/frontends/qt4/ui/PrefInputUi.ui | 40 ++++++++++++++++++----------- src/mathed/InsetMathNest.cpp | 2 +- 6 files changed, 55 insertions(+), 21 deletions(-) diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 7b6a6f51b6..b6462d5d99 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -142,6 +142,7 @@ LexerKeyword lyxrcTags[] = { { "\\macro_edit_style", LyXRC::RC_MACRO_EDIT_STYLE }, { "\\make_backup", LyXRC::RC_MAKE_BACKUP }, { "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE }, + { "\\mouse_middlebutton_paste", LyXRC::RC_MOUSE_MIDDLEBUTTON_PASTE }, { "\\mouse_wheel_speed", LyXRC::RC_MOUSE_WHEEL_SPEED }, { "\\nomencl_command", LyXRC::RC_NOMENCL_COMMAND }, { "\\num_lastfiles", LyXRC::RC_NUMLASTFILES }, @@ -377,6 +378,7 @@ void LyXRC::setDefaults() default_length_unit = Length::CM; cursor_width = 1; close_buffer_with_last_view = "yes"; + mouse_middlebutton_paste = true; } @@ -1292,6 +1294,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) } break; + case RC_MOUSE_MIDDLEBUTTON_PASTE: + lexrc >> mouse_middlebutton_paste; + break; + case RC_LAST: break; // this is just a dummy } @@ -2243,6 +2249,14 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c } if (tag != RC_LAST) break; + case RC_MOUSE_MIDDLEBUTTON_PASTE: + if (ignore_system_lyxrc || + mouse_middlebutton_paste != system_lyxrc.mouse_middlebutton_paste) { + os << "\\mouse_middlebutton_paste " + << convert(mouse_middlebutton_paste) << '\n'; + } + if (tag != RC_LAST) + break; case RC_COMPLETION_INLINE_DELAY: if (ignore_system_lyxrc || completion_inline_delay != system_lyxrc.completion_inline_delay) { @@ -2974,6 +2988,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_MAKE_BACKUP: case LyXRC::RC_MARK_FOREIGN_LANGUAGE: case LyXRC::RC_MOUSE_WHEEL_SPEED: + case LyXRC::RC_MOUSE_MIDDLEBUTTON_PASTE: case LyXRC::RC_NUMLASTFILES: case LyXRC::RC_PARAGRAPH_MARKERS: case LyXRC::RC_PATH_PREFIX: diff --git a/src/LyXRC.h b/src/LyXRC.h index d1326685f0..613a9c7f06 100644 --- a/src/LyXRC.h +++ b/src/LyXRC.h @@ -119,6 +119,7 @@ public: RC_MAKE_BACKUP, RC_MARK_FOREIGN_LANGUAGE, RC_MOUSE_WHEEL_SPEED, + RC_MOUSE_MIDDLEBUTTON_PASTE, RC_NOMENCL_COMMAND, RC_NUMLASTFILES, RC_OPEN_BUFFERS_IN_TABS, @@ -305,6 +306,8 @@ public: std::string hunspelldir_path; /// bool auto_region_delete; + /// enable middle-mouse-button paste + bool mouse_middlebutton_paste; /// flag telling whether lastfiles should be checked for existance bool auto_reset_options; /// diff --git a/src/Text3.cpp b/src/Text3.cpp index 4c99c15774..fc8846ea5b 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -1549,11 +1549,13 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) break; case mouse_button::button2: - // Middle mouse pasting. - bv->mouseSetCursor(cur); - lyx::dispatch( - FuncRequest(LFUN_COMMAND_ALTERNATIVES, - "selection-paste ; primary-selection-paste paragraph")); + if (lyxrc.mouse_middlebutton_paste) { + // Middle mouse pasting. + bv->mouseSetCursor(cur); + lyx::dispatch( + FuncRequest(LFUN_COMMAND_ALTERNATIVES, + "selection-paste ; primary-selection-paste paragraph")); + } cur.noScreenUpdate(); break; diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 01f24321cc..df0675a4a2 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -497,6 +497,8 @@ PrefInput::PrefInput(GuiPreferences * form) this, SIGNAL(changed())); connect(dontswapCB, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + connect(mmPasteCB, SIGNAL(toggled(bool)), + this, SIGNAL(changed())); // reveal checkbox for switching Ctrl and Meta on Mac: bool swapcb = false; @@ -532,6 +534,7 @@ void PrefInput::applyRC(LyXRC & rc) const rc.scroll_wheel_zoom = LyXRC::SCROLL_WHEEL_ZOOM_OFF; } rc.mac_dontswap_ctrl_meta = dontswapCB->isChecked(); + rc.mouse_middlebutton_paste = mmPasteCB->isChecked(); } @@ -560,6 +563,7 @@ void PrefInput::updateRC(LyXRC const & rc) break; } dontswapCB->setChecked(rc.mac_dontswap_ctrl_meta); + mmPasteCB->setChecked(rc.mouse_middlebutton_paste); } diff --git a/src/frontends/qt4/ui/PrefInputUi.ui b/src/frontends/qt4/ui/PrefInputUi.ui index 92cc5473c8..9964e3f664 100644 --- a/src/frontends/qt4/ui/PrefInputUi.ui +++ b/src/frontends/qt4/ui/PrefInputUi.ui @@ -7,7 +7,7 @@ 0 0 350 - 303 + 316 @@ -142,8 +142,21 @@ true - - + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + &Wheel scrolling speed: @@ -153,7 +166,7 @@ - + 1.0 is the standard scrolling speed with the mouse wheel. Higher values will speed it up, low values slow it down. @@ -175,18 +188,15 @@ - - - - Qt::Horizontal + + + + If this is checked, the middle mouse button will paste the recent selection - - - 40 - 20 - + + &Middle mouse button pasting - + @@ -214,7 +224,7 @@ 10 30 304 - 27 + 29 diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index 74ee70d141..179d7775f3 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -1551,7 +1551,7 @@ void InsetMathNest::lfunMousePress(Cursor & cur, FuncRequest & cmd) // cur.result().update(): don't overwrite previously set flags. cur.screenUpdateFlags(Update::Decoration | Update::FitCursor | cur.result().screenUpdate()); - } else if (cmd.button() == mouse_button::button2) { + } else if (cmd.button() == mouse_button::button2 && lyxrc.mouse_middlebutton_paste) { if (cap::selection()) { // See comment in Text::dispatch why we do this cap::copySelectionToStack(); -- 2.39.5