From: Abdelrazak Younes Date: Tue, 7 Nov 2006 17:19:33 +0000 (+0000) Subject: * Application: X-Git-Tag: 1.6.10~12002 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=c2a49b5b0d0f864db7ca36160bbd659faaa1f44c;p=features.git * Application: - setBufferView(): deleted - currentView(), setCurrentView(): new method to set the current LyXView * GuiApplication::x11EventFilter(): use currentView().view() to get the current BufferView. This should solves the X11 selection bug. * WorkArea: - dispatch(): redraw only if needRedraw in preparation for the painting optimization patch. Show the cursor immediately on mouse click. - setBufferView(): remove call to Application::setBufferView() * GuiWorkArea: - focusInEvent(): update only if we changed LyXView - focusInEvent(): stop the cursor only if we changed LyXView. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15783 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/Application.C b/src/frontends/Application.C index 1993b45b5d..a4902161f2 100644 --- a/src/frontends/Application.C +++ b/src/frontends/Application.C @@ -48,12 +48,6 @@ Application::Application(int &, char **) } -void Application::setBufferView(BufferView * buffer_view) -{ - buffer_view_ = buffer_view; -} - - LyXView & Application::createView(unsigned int width, unsigned int height, int posx, int posy, @@ -69,10 +63,30 @@ LyXView & Application::createView(unsigned int width, view.init(); view.setGeometry(width, height, posx, posy, maximize); + setCurrentView(view); + return view; } +LyXView const & Application::currentView() const +{ + return *current_view_; +} + + +LyXView & Application::currentView() +{ + return *current_view_; +} + + +void Application::setCurrentView(LyXView & current_view) +{ + current_view_ = ¤t_view; +} + + int Application::start(std::string const & /*batch*/) { return exec(); diff --git a/src/frontends/Application.h b/src/frontends/Application.h index fa4d49ebf7..7fcfa03e6b 100644 --- a/src/frontends/Application.h +++ b/src/frontends/Application.h @@ -114,14 +114,19 @@ public: LyXView & createView(unsigned int width, unsigned int height, int posx, int posy, bool maximize); + /// + LyXView const & currentView() const; + + /// + LyXView & currentView(); + /// - void setBufferView(BufferView * buffer_view); + void setCurrentView(LyXView & current_view); -protected: - /// This BufferView is the one receiving Clipboard and Selection +private: + /// This LyXView is the one receiving Clipboard and Selection /// Events - /// FIXME: \todo use Gui::currentView() in the future - BufferView * buffer_view_; + LyXView * current_view_; }; // Application diff --git a/src/frontends/WorkArea.C b/src/frontends/WorkArea.C index 0d65d628cc..ec44b875a4 100644 --- a/src/frontends/WorkArea.C +++ b/src/frontends/WorkArea.C @@ -94,8 +94,6 @@ void WorkArea::setBufferView(BufferView * buffer_view) lyx_view_.disconnectBufferView(); } - theApp->setBufferView(buffer_view); - hideCursor(); buffer_view_ = buffer_view; toggleCursor(); @@ -200,7 +198,7 @@ void WorkArea::dispatch(FuncRequest const & cmd0) theLyXFunc().setLyXView(&lyx_view_); - buffer_view_->workAreaDispatch(cmd0); + bool needRedraw = buffer_view_->workAreaDispatch(cmd0); // Skip these when selecting if (cmd0.action != LFUN_MOUSE_MOTION) { @@ -214,7 +212,12 @@ void WorkArea::dispatch(FuncRequest const & cmd0) // of the new status here. lyx_view_.clearMessage(); - redraw(); + // Show the cursor immediately after any operation. + hideCursor(); + toggleCursor(); + + if (needRedraw) + redraw(); } diff --git a/src/frontends/qt4/GuiApplication.C b/src/frontends/qt4/GuiApplication.C index a535f2e877..6a59f7ae47 100644 --- a/src/frontends/qt4/GuiApplication.C +++ b/src/frontends/qt4/GuiApplication.C @@ -18,6 +18,8 @@ #include "QLImage.h" #include "socket_callback.h" +#include "frontends/LyXView.h" + #include "graphics/LoaderQueue.h" #include "support/lstrings.h" @@ -282,19 +284,21 @@ void GuiApplication::unregisterSocketCallback(int fd) #ifdef Q_WS_X11 bool GuiApplication::x11EventFilter(XEvent * xev) { - switch (xev->type) { + BufferView * bv = currentView().view(); + + switch (ev->type) { case SelectionRequest: lyxerr[Debug::GUI] << "X requested selection." << endl; - if (buffer_view_) { - lyx::docstring const sel = buffer_view_->requestSelection(); + if (bv) { + lyx::docstring const sel = bv->requestSelection(); if (!sel.empty()) selection_.put(sel); } break; case SelectionClear: lyxerr[Debug::GUI] << "Lost selection." << endl; - if (buffer_view_) - buffer_view_->clearSelection(); + if (bv) + bv->clearSelection(); break; } return false; @@ -360,7 +364,7 @@ OSErr GuiApplication::handleOpenDocuments(const AppleEvent* inEvent, FSRefMakePath(&ref, (UInt8*)qstr_buf, 1024); s_arg=QString::fromUtf8(qstr_buf); -// buffer_view_->workAreaDispatch( +// bv->workAreaDispatch( // FuncRequest(LFUN_FILE_OPEN, // fromqstr(s_arg))); break; diff --git a/src/frontends/qt4/GuiWorkArea.C b/src/frontends/qt4/GuiWorkArea.C index e2475d50ec..433d97de2d 100644 --- a/src/frontends/qt4/GuiWorkArea.C +++ b/src/frontends/qt4/GuiWorkArea.C @@ -295,9 +295,16 @@ void GuiWorkArea::dropEvent(QDropEvent* event) void GuiWorkArea::focusInEvent(QFocusEvent * /*event*/) { + // No need to do anything if we didn't change views... + if (&lyx_view_ == &theApp->currentView()) + return; + + theApp->setCurrentView(lyx_view_); + // FIXME: it would be better to send a signal "newBuffer()" - // in BufferList that could be connected to the different tabbar. + // in BufferList that could be connected to the different tabbars. lyx_view_.updateTab(); + startBlinkingCursor(); //FIXME: Use case: Two windows share the same buffer. @@ -320,6 +327,10 @@ void GuiWorkArea::focusInEvent(QFocusEvent * /*event*/) void GuiWorkArea::focusOutEvent(QFocusEvent * /*event*/) { + // No need to do anything if we didn't change views... + if (&lyx_view_ == &theApp->currentView()) + return; + stopBlinkingCursor(); }