- 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
}
-void Application::setBufferView(BufferView * buffer_view)
-{
- buffer_view_ = buffer_view;
-}
-
-
LyXView & Application::createView(unsigned int width,
unsigned int height,
int posx, int posy,
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();
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
lyx_view_.disconnectBufferView();
}
- theApp->setBufferView(buffer_view);
-
hideCursor();
buffer_view_ = buffer_view;
toggleCursor();
theLyXFunc().setLyXView(&lyx_view_);
- buffer_view_->workAreaDispatch(cmd0);
+ bool needRedraw = buffer_view_->workAreaDispatch(cmd0);
// Skip these when selecting
if (cmd0.action != LFUN_MOUSE_MOTION) {
// of the new status here.
lyx_view_.clearMessage();
- redraw();
+ // Show the cursor immediately after any operation.
+ hideCursor();
+ toggleCursor();
+
+ if (needRedraw)
+ redraw();
}
#include "QLImage.h"
#include "socket_callback.h"
+#include "frontends/LyXView.h"
+
#include "graphics/LoaderQueue.h"
#include "support/lstrings.h"
#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;
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;
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.
void GuiWorkArea::focusOutEvent(QFocusEvent * /*event*/)
{
+ // No need to do anything if we didn't change views...
+ if (&lyx_view_ == &theApp->currentView())
+ return;
+
stopBlinkingCursor();
}