]> git.lyx.org Git - features.git/commitdiff
* Application:
authorAbdelrazak Younes <younes@lyx.org>
Tue, 7 Nov 2006 17:19:33 +0000 (17:19 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Tue, 7 Nov 2006 17:19:33 +0000 (17:19 +0000)
  - 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

src/frontends/Application.C
src/frontends/Application.h
src/frontends/WorkArea.C
src/frontends/qt4/GuiApplication.C
src/frontends/qt4/GuiWorkArea.C

index 1993b45b5d0814f17cc9067e8439a7d1e815af89..a4902161f27a7356fc0e241cff924cb70d61c7b6 100644 (file)
@@ -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_ = &current_view;
+}
+
+
 int Application::start(std::string const & /*batch*/)
 {
        return exec();
index fa4d49ebf78c0b5966d8643a07c42628bdcce6f6..7fcfa03e6bbcefba7bf05f4ee5b2a7e451996878 100644 (file)
@@ -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
 
index 0d65d628cc83f476bd9b2893ffc40d3bfb8da62d..ec44b875a421526a16afcc630a0c317f3485716f 100644 (file)
@@ -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();
 }
 
 
index a535f2e877248d9c9ba528c33a9cd82c71e64dfc..6a59f7ae47c0a74545fba885dfb177b622e72435 100644 (file)
@@ -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;
index e2475d50ec3934dd91334494a26011bcbfae2a60..433d97de2d97358a91e11e87d97a6b0fc7e8b5b1 100644 (file)
@@ -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();
 }