mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
* 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
This commit is contained in:
parent
06d51efd7c
commit
c2a49b5b0d
@ -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();
|
||||
|
@ -114,14 +114,19 @@ public:
|
||||
LyXView & createView(unsigned int width, unsigned int height,
|
||||
int posx, int posy, bool maximize);
|
||||
|
||||
///
|
||||
void setBufferView(BufferView * buffer_view);
|
||||
///
|
||||
LyXView const & currentView() const;
|
||||
|
||||
protected:
|
||||
/// This BufferView is the one receiving Clipboard and Selection
|
||||
///
|
||||
LyXView & currentView();
|
||||
|
||||
///
|
||||
void setCurrentView(LyXView & current_view);
|
||||
|
||||
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
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user