]> git.lyx.org Git - features.git/commitdiff
Introduce Application::currentWindow() and get rid of lyx_view_ member in LyXFunc.
authorAbdelrazak Younes <younes@lyx.org>
Tue, 22 Sep 2009 21:25:32 +0000 (21:25 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Tue, 22 Sep 2009 21:25:32 +0000 (21:25 +0000)
This commit also move the Selection saving to  QEvent::WindowActivate in GuiView.cpp.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31443 a592a061-630c-0410-9148-cb99ea01b6c8

13 files changed:
src/LyXFunc.cpp
src/LyXFunc.h
src/frontends/Application.h
src/frontends/qt4/Action.cpp
src/frontends/qt4/Dialog.cpp
src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/GuiApplication.h
src/frontends/qt4/GuiCommandBuffer.cpp
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiWorkArea.cpp
src/frontends/qt4/InsertTableWidget.cpp
src/frontends/qt4/LayoutBox.cpp
src/frontends/qt4/Menus.cpp

index 2fa52b8cabe987e8e60bf365da0502ab0cdba5b8..1a68452d2ef42a9ae08d18fd962a950ad63590df 100644 (file)
@@ -197,7 +197,7 @@ Change::Type lookupChangeType(DocIterator const & dit, bool outer = false)
 
 
 LyXFunc::LyXFunc()
-       : lyx_view_(0), encoded_last_key(0), meta_fake_bit(NoModifier)
+       : encoded_last_key(0), meta_fake_bit(NoModifier)
 {
 }
 
@@ -209,25 +209,15 @@ void LyXFunc::initKeySequences(KeyMap * kb)
 }
 
 
-void LyXFunc::setLyXView(LyXView * lv)
-{
-       if (lyx_view_ && lyx_view_->currentBufferView() && lyx_view_ != lv)
-               // save current selection to the selection buffer to allow
-               // middle-button paste in another window
-               cap::saveSelection(lyx_view_->currentBufferView()->cursor());
-       lyx_view_ = lv;
-}
-
-
 void LyXFunc::handleKeyFunc(FuncCode action)
 {
        char_type c = encoded_last_key;
 
        if (keyseq.length())
                c = 0;
-
-       LASSERT(lyx_view_ && lyx_view_->currentBufferView(), /**/);
-       BufferView * bv = lyx_view_->currentBufferView();
+       LyXView * lv = theApp()->currentWindow();
+       LASSERT(lv && lv->currentBufferView(), /**/);
+       BufferView * bv = lv->currentBufferView();
        bv->getIntl().getTransManager().deadkey(
                c, get_accent(action).accent, bv->cursor().innerText(),
                bv->cursor());
@@ -243,7 +233,8 @@ void LyXFunc::handleKeyFunc(FuncCode action)
 // to GuiView and be GuiView and be window dependent.
 void LyXFunc::gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer)
 {
-       LASSERT(lyx_view_, /**/);
+       LyXView * lv = theApp()->currentWindow();
+       LASSERT(lv, /**/);
        if (!theSession().bookmarks().isValid(idx))
                return;
        BookmarksSection::Bookmark const & bm = theSession().bookmarks().bookmark(idx);
@@ -268,15 +259,15 @@ void LyXFunc::gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer)
                dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"));
 
        // if the current buffer is not that one, switch to it.
-       if (!lyx_view_->documentBufferView()
-               || lyx_view_->documentBufferView()->buffer().fileName() != tmp.filename) {
+       if (!lv->documentBufferView()
+               || lv->documentBufferView()->buffer().fileName() != tmp.filename) {
                if (!switchToBuffer)
                        return;
                dispatch(FuncRequest(LFUN_BUFFER_SWITCH, file));
        }
 
        // moveToPosition try paragraph id first and then paragraph (pit, pos).
-       if (!lyx_view_->documentBufferView()->moveToPosition(
+       if (!lv->documentBufferView()->moveToPosition(
                tmp.bottom_pit, tmp.bottom_pos, tmp.top_id, tmp.top_pos))
                return;
 
@@ -285,7 +276,7 @@ void LyXFunc::gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer)
                return;
 
        // Cursor jump succeeded!
-       Cursor const & cur = lyx_view_->documentBufferView()->cursor();
+       Cursor const & cur = lv->documentBufferView()->cursor();
        pit_type new_pit = cur.pit();
        pos_type new_pos = cur.pos();
        int new_id = cur.paragraph().id();
@@ -304,21 +295,23 @@ void LyXFunc::processKeySym(KeySymbol const & keysym, KeyModifier state)
 {
        LYXERR(Debug::KEY, "KeySym is " << keysym.getSymbolName());
 
+       LyXView * lv = theApp()->currentWindow();
+
        // Do nothing if we have nothing (JMarc)
        if (!keysym.isOK()) {
                LYXERR(Debug::KEY, "Empty kbd action (probably composing)");
-               lyx_view_->restartCursor();
+               lv->restartCursor();
                return;
        }
 
        if (keysym.isModifier()) {
                LYXERR(Debug::KEY, "isModifier true");
-               if (lyx_view_)
-                       lyx_view_->restartCursor();
+               if (lv)
+                       lv->restartCursor();
                return;
        }
 
-       //Encoding const * encoding = lyx_view_->documentBufferView()->cursor().getEncoding();
+       //Encoding const * encoding = lv->documentBufferView()->cursor().getEncoding();
        //encoded_last_key = keysym.getISOEncoded(encoding ? encoding->name() : "");
        // FIXME: encoded_last_key shadows the member variable of the same
        // name. Is that intended?
@@ -355,7 +348,7 @@ void LyXFunc::processKeySym(KeySymbol const & keysym, KeyModifier state)
        // num_bytes == 0? (Lgb)
 
        if (keyseq.length() > 1)
-               lyx_view_->message(keyseq.print(KeySequence::ForGui));
+               lv->message(keyseq.print(KeySequence::ForGui));
 
 
        // Maybe user can only reach the key via holding down shift.
@@ -376,8 +369,8 @@ void LyXFunc::processKeySym(KeySymbol const & keysym, KeyModifier state)
                                           FuncRequest::KEYBOARD);
                } else {
                        LYXERR(Debug::KEY, "Unknown, !isText() - giving up");
-                       lyx_view_->message(_("Unknown function."));
-                       lyx_view_->restartCursor();
+                       lv->message(_("Unknown function."));
+                       lv->restartCursor();
                        return;
                }
        }
@@ -391,7 +384,7 @@ void LyXFunc::processKeySym(KeySymbol const & keysym, KeyModifier state)
                }
        } else {
                dispatch(func);
-               if (!lyx_view_)
+               if (!lv)
                        return;
        }
 }
@@ -411,13 +404,14 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
           GuiView::getStatus), then several functions will not be
           handled correctly.
        */
+       frontend::LyXView * lv_current = theApp()->currentWindow();
        frontend::LyXView * lv = 0;
        Buffer * buf = 0;
-       if (lyx_view_ 
-           && (cmd.origin != FuncRequest::MENU || lyx_view_->hasFocus())) {
-               lv = lyx_view_;
-               if (lyx_view_->documentBufferView())
-                       buf = &lyx_view_->documentBufferView()->buffer();
+       if (lv_current 
+           && (cmd.origin != FuncRequest::MENU || lv_current->hasFocus())) {
+               lv = lv_current;
+               if (lv_current->documentBufferView())
+                       buf = &lv_current->documentBufferView()->buffer();
        }
 
        if (cmd.action == LFUN_NOACTION) {
@@ -624,8 +618,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        }
 
        // Are we in a DELETED change-tracking region?
-       if (lyx_view_ && lyx_view_->documentBufferView()
-               && (lookupChangeType(lyx_view_->documentBufferView()->cursor(), true)
+       if (lv && lv->documentBufferView()
+               && (lookupChangeType(lv->documentBufferView()->cursor(), true)
                    == Change::DELETED)
            && !lyxaction.funcHasFlag(cmd.action, LyXAction::ReadOnly)
            && !lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer)) {
@@ -664,6 +658,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
        //This is done unless explicitely requested otherwise
        Update::flags updateFlags = Update::FitCursor;
 
+       LyXView * lv = theApp()->currentWindow();
+
        FuncStatus const flag = getStatus(cmd);
        if (!flag.enabled()) {
                // We cannot use this function here
@@ -671,21 +667,21 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                       << lyxaction.getActionName(action)
                       << " [" << action << "] is disabled at this location");
                setErrorMessage(flag.message());
-               if (lyx_view_)
-                       lyx_view_->restartCursor();
+               if (lv)
+                       lv->restartCursor();
        } else {
                Buffer * buffer = 0;
-               if (lyx_view_ && lyx_view_->currentBufferView())
-                       buffer = &lyx_view_->currentBufferView()->buffer();
+               if (lv && lv->currentBufferView())
+                       buffer = &lv->currentBufferView()->buffer();
                switch (action) {
 
                case LFUN_COMMAND_PREFIX:
-                       LASSERT(lyx_view_, /**/);
-                       lyx_view_->message(keyseq.printOptions(true));
+                       LASSERT(lv, /**/);
+                       lv->message(keyseq.printOptions(true));
                        break;
 
                case LFUN_CANCEL:
-                       LASSERT(lyx_view_ && lyx_view_->currentBufferView(), /**/);
+                       LASSERT(lv && lv->currentBufferView(), /**/);
                        keyseq.reset();
                        meta_fake_bit = NoModifier;
                        if (buffer)
@@ -702,12 +698,12 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                // --- Menus -----------------------------------------------
                case LFUN_RECONFIGURE:
                        // argument is any additional parameter to the configure.py command
-                       reconfigure(lyx_view_, argument);
+                       reconfigure(lv, argument);
                        break;
 
                // --- lyxserver commands ----------------------------
                case LFUN_SERVER_GET_FILENAME:
-                       LASSERT(lyx_view_ && buffer, /**/);
+                       LASSERT(lv && buffer, /**/);
                        setMessage(from_utf8(buffer->absFileName()));
                        LYXERR(Debug::INFO, "FNAME["
                                << buffer->absFileName() << ']');
@@ -719,7 +715,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        break;
 
                case LFUN_SERVER_GOTO_FILE_ROW: {
-                       LASSERT(lyx_view_, /**/);
+                       LASSERT(lv, /**/);
                        string file_name;
                        int row;
                        istringstream is(argument);
@@ -749,10 +745,10 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                if (theBufferList().exists(s))
                                        buf = theBufferList().getBuffer(s);
                                else if (s.exists()) {
-                                       buf = lyx_view_->loadDocument(s);
+                                       buf = lv->loadDocument(s);
                                        loaded = true;
                                } else
-                                       lyx_view_->message(bformat(
+                                       lv->message(bformat(
                                                _("File does not exist: %1$s"),
                                                makeDisplayPath(file_name)));
                        }
@@ -763,8 +759,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        }
 
                        buf->updateLabels();
-                       lyx_view_->setBuffer(buf);
-                       lyx_view_->documentBufferView()->setCursorFromRow(row);
+                       lv->setBuffer(buf);
+                       lv->documentBufferView()->setCursorFromRow(row);
                        if (loaded)
                                buf->errors("Parse");
                        updateFlags = Update::FitCursor;
@@ -773,7 +769,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
 
 
                case LFUN_DIALOG_SHOW_NEW_INSET: {
-                       LASSERT(lyx_view_, /**/);
+                       LASSERT(lv, /**/);
                        string const name = cmd.getArg(0);
                        InsetCode code = insetCode(name);
                        string data = trim(to_utf8(cmd.argument()).substr(name.size()));
@@ -879,7 +875,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                }
 
                case LFUN_CITATION_INSERT: {
-                       LASSERT(lyx_view_, /**/);
+                       LASSERT(lv, /**/);
                        if (!argument.empty()) {
                                // we can have one optional argument, delimited by '|'
                                // citation-insert <key>|<text_before>
@@ -904,7 +900,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                }
 
                case LFUN_CURSOR_FOLLOWS_SCROLLBAR_TOGGLE:
-                       LASSERT(lyx_view_, /**/);
+                       LASSERT(lv, /**/);
                        lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
                        break;
 
@@ -1057,8 +1053,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                // Nothing more to do.
                                return;
 
-                       // Everything below is only for active lyx_view_
-                       if (lyx_view_ == 0)
+                       // Everything below is only for active window
+                       if (lv == 0)
                                break;
 
                        // Start an undo group. This may be needed for
@@ -1067,8 +1063,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                buffer->undo().beginUndoGroup();
                                
                        // Let the current LyXView dispatch its own actions.
-                       if (lyx_view_->dispatch(cmd)) {
-                               BufferView * bv = lyx_view_->currentBufferView();
+                       if (lv->dispatch(cmd)) {
+                               BufferView * bv = lv->currentBufferView();
                                if (bv) {
                                        buffer = &(bv->buffer());
                                        updateFlags = bv->cursor().result().update();
@@ -1078,7 +1074,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                break;
                        }
 
-                       BufferView * bv = lyx_view_->currentBufferView();
+                       BufferView * bv = lv->currentBufferView();
                        LASSERT(bv, /**/);
 
                        // Let the current BufferView dispatch its own actions.
@@ -1091,7 +1087,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                break;
                        }
 
-                       BufferView * doc_bv = lyx_view_->documentBufferView();
+                       BufferView * doc_bv = lv->documentBufferView();
                        // Try with the document BufferView dispatch if any.
                        if (doc_bv && doc_bv->dispatch(cmd)) {
                                // The BufferView took care of its own updates if needed.
@@ -1155,11 +1151,11 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        if (cmd.origin == FuncRequest::KEYBOARD) {
                                if (cmd.action == LFUN_SELF_INSERT
                                    || (cmd.action == LFUN_ERT_INSERT && bv->cursor().inMathed()))
-                                       lyx_view_->updateCompletion(bv->cursor(), true, true);
+                                       lv->updateCompletion(bv->cursor(), true, true);
                                else if (cmd.action == LFUN_CHAR_DELETE_BACKWARD)
-                                       lyx_view_->updateCompletion(bv->cursor(), false, true);
+                                       lv->updateCompletion(bv->cursor(), false, true);
                                else
-                                       lyx_view_->updateCompletion(bv->cursor(), false, false);
+                                       lv->updateCompletion(bv->cursor(), false, false);
                        }
 
                        updateFlags = bv->cursor().result().update();
@@ -1171,22 +1167,22 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                    && !lyxaction.funcHasFlag(action, LyXAction::ReadOnly))
                        buffer->markDirty();                    
 
-               if (lyx_view_ && lyx_view_->currentBufferView()) {
+               if (lv && lv->currentBufferView()) {
                        // BufferView::update() updates the ViewMetricsInfo and
                        // also initializes the position cache for all insets in
                        // (at least partially) visible top-level paragraphs.
                        // We will redraw the screen only if needed.
-                       lyx_view_->currentBufferView()->processUpdateFlags(updateFlags);
+                       lv->currentBufferView()->processUpdateFlags(updateFlags);
 
                        // Do we have a selection?
                        theSelection().haveSelection(
-                               lyx_view_->currentBufferView()->cursor().selection());
+                               lv->currentBufferView()->cursor().selection());
                        
                        // update gui
-                       lyx_view_->restartCursor();
+                       lv->restartCursor();
                }
        }
-       if (lyx_view_) {
+       if (lv) {
                // Some messages may already be translated, so we cannot use _()
                sendDispatchMessage(translateIfPossible(getMessage()), cmd);
        }
@@ -1199,10 +1195,11 @@ void LyXFunc::sendDispatchMessage(docstring const & msg, FuncRequest const & cmd
                              || cmd.origin == FuncRequest::TOOLBAR
                              || cmd.origin == FuncRequest::COMMANDBUFFER);
 
+       LyXView * lv = theApp()->currentWindow();
        if (cmd.action == LFUN_SELF_INSERT || !verbose) {
                LYXERR(Debug::ACTION, "dispatch msg is " << to_utf8(msg));
                if (!msg.empty())
-                       lyx_view_->message(msg);
+                       lv->message(msg);
                return;
        }
 
@@ -1235,11 +1232,11 @@ void LyXFunc::sendDispatchMessage(docstring const & msg, FuncRequest const & cmd
 
        LYXERR(Debug::ACTION, "verbose dispatch msg " << to_utf8(dispatch_msg));
        if (!dispatch_msg.empty())
-               lyx_view_->message(dispatch_msg);
+               lv->message(dispatch_msg);
 }
 
 
-// Each "lyx_view_" should have it's own message method. lyxview and
+// Each LyXView should have it's own message method. lyxview and
 // the minibuffer would use the minibuffer, but lyxserver would
 // send an ERROR signal to its client.  Alejandro 970603
 // This function is bit problematic when it comes to NLS, to make the
@@ -1269,11 +1266,12 @@ docstring LyXFunc::viewStatusMessage()
        if (keyseq.length() > 0 && !keyseq.deleted())
                return keyseq.printOptions(true);
 
-       LASSERT(lyx_view_, /**/);
-       if (!lyx_view_->currentBufferView())
+       LyXView * lv = theApp()->currentWindow();
+       LASSERT(lv, /**/);
+       if (!lv->currentBufferView())
                return _("Welcome to LyX!");
 
-       return lyx_view_->currentBufferView()->cursor().currentState();
+       return lv->currentBufferView()->cursor().currentState();
 }
 
 
index b4060831a7a77f22e5be911dd4799fd5f91619b4..091204fe665529ad67bafd957b46b4e806c2708f 100644 (file)
@@ -53,9 +53,6 @@ public:
        /// LyX dispatcher, executes lyx actions.
        void dispatch(FuncRequest const &);
 
-       ///
-       void setLyXView(frontend::LyXView * lv);
-       
        ///
        void initKeySequences(KeyMap * kb);
 
@@ -93,9 +90,6 @@ public:
        int cursorBeforeDispatchY() const { return cursorPosBeforeDispatchY_; }
 
 private:
-       ///
-       frontend::LyXView * lyx_view_;
-
        /// the last character added to the key sequence, in UCS4 encoded form
        char_type encoded_last_key;
 
index 72173ebe1638b078fff1f6bf826cbe111ce77e75..fa470f2f5d629830ab49fc83a17cdfca781f5c89 100644 (file)
@@ -167,7 +167,8 @@ public:
        Application() {}
        ///
        virtual ~Application() {}
-
+       ///
+       virtual LyXView * currentWindow() = 0;
        ///
        virtual bool getStatus(FuncRequest const & cmd, FuncStatus & flag) const = 0;
        /// dispatch command.
index 4c13e636ca22dbf8a31f7da1c6f47e97f39e5b76..ca229fbbe5dc0eb48222c2b4a7b592c9de88eb8f 100644 (file)
@@ -63,9 +63,6 @@ void Action::action()
 {
        //LYXERR(Debug::ACTION, "calling LyXFunc::dispatch: func_: ");
 
-       if (lyxView_)
-               theLyXFunc().setLyXView(lyxView_);
-
        lyx::dispatch(func_);
        triggered(this);
 }
index ef1f017559bfc140a34edab305d9b7cef3b288a7..15aeca52b2c030c4eab60aedd97188988e0fb340 100644 (file)
@@ -58,7 +58,6 @@ bool Dialog::canApply() const
 
 void Dialog::dispatch(FuncRequest const & fr) const
 {
-       theLyXFunc().setLyXView(lyxview_);
        lyx::dispatch(fr);
 }
 
index 09c6d4e086fee58c45acb961552e18b14444feb9..77ffd4c0da01e701a2a26e02d6d2f95176d89cff 100644 (file)
@@ -800,6 +800,11 @@ docstring GuiApplication::iconName(FuncRequest const & f, bool unknown)
 }
 
 
+LyXView * GuiApplication::currentWindow()
+{
+       return current_view_;
+}
+
 
 bool GuiApplication::getStatus(FuncRequest const & cmd, FuncStatus & flag) const
 {
@@ -1443,10 +1448,8 @@ void GuiApplication::unregisterView(GuiView * gv)
 {
        LASSERT(d->views_[gv->id()] == gv, /**/);
        d->views_.remove(gv->id());
-       if (current_view_ == gv) {
+       if (current_view_ == gv)
                current_view_ = 0;
-               theLyXFunc().setLyXView(0);
-       }
 }
 
 
index b4236905abf36bf0fe350ef31dde0420e3ff226d..4b01f257fec666bc71657238ad86ffe4ab18ee3d 100644 (file)
@@ -57,6 +57,7 @@ public:
 
        /// Method inherited from \c Application class
        //@{
+       LyXView * currentWindow();
        bool getStatus(FuncRequest const & cmd, FuncStatus & flag) const;
        bool dispatch(FuncRequest const &);
        void dispatchDelayed(FuncRequest const &);
index 129439a3c4d77d68de5a1b0e423e3e5dda5ec4c6..b66860439b69ad3681032c9ad48519da7c663063 100644 (file)
@@ -304,7 +304,6 @@ docstring const GuiCommandBuffer::getCurrentState() const
 void GuiCommandBuffer::hide() const
 {
        FuncRequest cmd(LFUN_COMMAND_EXECUTE, "off");
-       theLyXFunc().setLyXView(view_);
        lyx::dispatch(cmd);
 }
 
@@ -359,7 +358,6 @@ void GuiCommandBuffer::dispatch(string const & str)
        downPB->setEnabled(history_pos_ != history_.end());
        FuncRequest func = lyxaction.lookupFunc(str);
        func.origin = FuncRequest::COMMANDBUFFER;
-       theLyXFunc().setLyXView(view_);
        lyx::dispatch(func);
 }
 
index e242e26fce3e32fbfa6dff66daf1da93bebffba5..12f270b24ad39638c51a2cb0687112e8b1c0bbee 100644 (file)
@@ -303,7 +303,7 @@ GuiView::GuiView(int id)
        // set ourself as the current view. This is needed for the menu bar
        // filling, at least for the static special menu item on Mac. Otherwise
        // they are greyed out.
-       theLyXFunc().setLyXView(this);
+       guiApp->setCurrentView(this);
        
        // Fill up the menu bar.
        guiApp->menus().fillMenuBar(menuBar(), this, true);
@@ -512,7 +512,6 @@ void GuiView::setFocus()
        LYXERR(Debug::DEBUG, "GuiView::setFocus()" << this);
        // Make sure LyXFunc points to the correct view.
        guiApp->setCurrentView(this);
-       theLyXFunc().setLyXView(this);
        QMainWindow::setFocus();
        if (d.current_work_area_)
                d.current_work_area_->setFocus();
@@ -653,7 +652,6 @@ void GuiView::clearMessage()
 {
        if (!hasFocus())
                return;
-       theLyXFunc().setLyXView(this);
        statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
        d.statusbar_timer_.stop();
 }
@@ -731,7 +729,6 @@ void GuiView::updateStatusBar()
        if (d.statusbar_timer_.isActive())
                return;
 
-       theLyXFunc().setLyXView(this);
        statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
 }
 
@@ -762,12 +759,17 @@ bool GuiView::event(QEvent * e)
        //      break;
 
        case QEvent::WindowActivate: {
-               if (this == guiApp->currentView()) {
+               GuiView * old_view = guiApp->currentView();
+               if (this == old_view) {
                        setFocus();
                        return QMainWindow::event(e);
                }
+               if (old_view) {
+                       // save current selection to the selection buffer to allow
+                       // middle-button paste in this window.
+                       cap::saveSelection(old_view->currentBufferView()->cursor());
+               }
                guiApp->setCurrentView(this);
-               theLyXFunc().setLyXView(this);
                if (d.current_work_area_) {
                        BufferView & bv = d.current_work_area_->bufferView();
                        connectBufferView(bv);
@@ -815,7 +817,6 @@ bool GuiView::event(QEvent * e)
 
                // Allow processing of shortcuts that are allowed even when no Buffer
                // is viewed.
-               theLyXFunc().setLyXView(this);
                KeySymbol sym;
                setKeySymbol(&sym, ke);
                theLyXFunc().processKeySym(sym, q_key_state(ke->modifiers()));
@@ -1588,7 +1589,7 @@ static bool import(GuiView * lv, FileName const & filename,
                                          formats.extension(loader_format));
                lv->currentBufferView()->insertPlaintextFile(FileName(filename2),
                        as_paragraphs);
-               theLyXFunc().setLyXView(lv);
+               guiApp->setCurrentView(lv);
                lyx::dispatch(FuncRequest(LFUN_MARK_OFF));
        }
 
@@ -2877,14 +2878,14 @@ bool isValidName(string const & name)
 void GuiView::resetDialogs()
 {
        // Make sure that no LFUN uses any LyXView.
-       theLyXFunc().setLyXView(0);
+       guiApp->setCurrentView(0);
        saveLayout();
        menuBar()->clear();
        constructToolbars();
        guiApp->menus().fillMenuBar(menuBar(), this, false);
        d.layout_->updateContents(true);
        // Now update controls with current buffer.
-       theLyXFunc().setLyXView(this);
+       guiApp->setCurrentView(this);
        restoreLayout();
        restartCursor();
 }
index 6a15b78b5848f4898ed4483e42178b1babd28877..4780ebbd711cf01ec0af115db321ee6ae688ceff 100644 (file)
@@ -455,8 +455,6 @@ void GuiWorkArea::processKeySym(KeySymbol const & key, KeyModifier mod)
        // we better stop the blinking cursor...
        // the cursor gets restarted in GuiView::restartCursor()
        stopBlinkingCursor();
-
-       theLyXFunc().setLyXView(lyx_view_);
        theLyXFunc().processKeySym(key, mod);
 }
 
@@ -469,8 +467,6 @@ void GuiWorkArea::dispatch(FuncRequest const & cmd0, KeyModifier mod)
                return;
        }
 
-       theLyXFunc().setLyXView(lyx_view_);
-
        FuncRequest cmd;
 
        if (cmd0.action == LFUN_MOUSE_PRESS) {
index 76b852356fe983afce2b896408fba539199d4034..036cd1d390868d79b5bd229215608f9a2913b47a 100644 (file)
@@ -108,7 +108,6 @@ void InsertTableWidget::mouseReleaseEvent(QMouseEvent * /*event*/)
 {
        if (underMouse_) {
                QString const data = QString("%1 %2").arg(bottom_).arg(right_);
-               theLyXFunc().setLyXView(&lyxView_);
                lyx::dispatch(FuncRequest(LFUN_TABULAR_INSERT, fromqstr(data)));
        }
        // emit signal
index f8c99d59e8ccc36e2e51fe3d220a1bda3795c1ba..23017cf6f89e8f8d75ecedfdca2528560bf206b6 100644 (file)
@@ -687,7 +687,6 @@ void LayoutBox::selected(int index)
        // find corresponding text class
        if (d->text_class_->hasLayout(layoutName)) {
                FuncRequest const func(LFUN_LAYOUT, layoutName, FuncRequest::TOOLBAR);
-               theLyXFunc().setLyXView(&d->owner_);
                lyx::dispatch(func);
                updateContents(false);
                d->resetFilter();
index 4e5d5da6ae323e79a7d9391815f6737ced5ae8fd..b1e06fc00d31a3b348c18623addba10012aef534 100644 (file)
@@ -1850,9 +1850,6 @@ void Menus::updateMenu(Menu * qmenu)
        if (qmenu->d->name.isEmpty())
                return;
 
-       // Here, We make sure that theLyXFunc points to the correct LyXView.
-       theLyXFunc().setLyXView(qmenu->d->view);
-
        if (!d->hasMenu(qmenu->d->name)) {
                qmenu->addAction(qt_("No Action Defined!"));
                LYXERR(Debug::GUI, "\tWARNING: non existing menu: "