Fix polling of selection request to not call the asString function every time.

Fixed a redraw problem for InsetGraphics (fix #271).


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3787 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2002-03-20 10:36:03 +00:00
parent b719bc24b4
commit 92904c615a
7 changed files with 44 additions and 8 deletions

View File

@ -748,11 +748,24 @@ void BufferView::Pimpl::tripleClick(int /*x*/, int /*y*/, unsigned int button)
void BufferView::Pimpl::selectionRequested()
{
static string sel;
if (!available())
return;
string const sel(bv_->getLyXText()->selectionAsString(bv_->buffer(),
false));
LyXText * text = bv_->getLyXText();
if (text->selection.set() &&
(!bv_->text->xsel_cache.set() ||
text->selection.start != bv_->text->xsel_cache.start ||
text->selection.end != bv_->text->xsel_cache.end))
{
bv_->text->xsel_cache = text->selection;
sel = text->selectionAsString(bv_->buffer(), false);
} else if (!text->selection.set()) {
sel = string();
bv_->text->xsel_cache.set(false);
}
if (!sel.empty()) {
workarea_.putClipboard(sel);
}
@ -766,6 +779,7 @@ void BufferView::Pimpl::selectionLost()
toggleSelection();
bv_->getLyXText()->clearSelection();
showCursor();
bv_->text->xsel_cache.set(false);
}
}
@ -1440,6 +1454,9 @@ void BufferView::Pimpl::moveCursorUpdate(bool selecting)
showCursor();
}
if (!lt->selection.set())
workarea_.haveSelection(false);
/* ---> Everytime the cursor is moved, show the current font state. */
// should this too me moved out of this func?
//owner->showState();
@ -3082,7 +3099,6 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
case LFUN_PARENTINSERT:
{
lyxerr << "arg " << argument << endl;
InsetCommandParams p("lyxparent", argument);
Inset * inset = new InsetParent(p, *buffer_);
if (!insertInset(inset, "Standard"))
@ -3157,6 +3173,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
| BufferView::FITCUR
| BufferView::CHANGE);
}
workarea_.haveSelection(false);
}
beforeChange(lt);

View File

@ -1,3 +1,13 @@
2002-03-19 Juergen Vigna <jug@sad.it>
* text2.C (clearSelection): reset also xsel_cache.
* BufferView_pimpl.C (Dispatch): call WorkArea::haveSelection(false)
where it needs to be called (John tells us to do so too :)
(selectionLost): reset sel_cache.
* WorkArea.C (event_cb): leave ret to 0 (John tells us to do so :)
2002-03-19 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* text2.C (setCursorIntern): put debuging code in INSETS channel

View File

@ -574,12 +574,12 @@ int WorkArea::event_cb(XEvent * xev)
case SelectionRequest:
lyxerr[Debug::GUI] << "X requested selection." << endl;
selectionRequested.emit();
ret = 1;
// ret = 1;
break;
case SelectionClear:
lyxerr[Debug::GUI] << "Lost selection." << endl;
selectionLost.emit();
ret = 1;
// ret = 1;
break;
}
return ret;

View File

@ -1,3 +1,7 @@
2002-03-19 Juergen Vigna <jug@sad.it>
* insetgraphics.C (draw): fixed the setting of CHANGED_IN_DRAW!
2002-03-18 Angus Leeming <a.leeming@ic.ac.uk>
* insetgraphics.C: Clean up Baruch's comments a little.

View File

@ -341,7 +341,7 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
// the status message may mean we changed size, so indicate
// we need a row redraw
if (old_status_ != cached_status_) {
if (old_status_ != grfx::ErrorUnknown && old_status_ != cached_status_) {
bv->getLyXText()->status(bv, LyXText::CHANGED_IN_DRAW);
}

View File

@ -273,6 +273,8 @@ public:
};
mutable Selection selection;
// this is used to handle XSelection events in the right manner
mutable Selection xsel_cache;
/// needed for the toggling (cursor position on last selection made)
mutable LyXCursor last_sel_cursor;

View File

@ -1024,6 +1024,9 @@ void LyXText::clearSelection() const
selection.set(false);
selection.mark(false);
last_sel_cursor = selection.end = selection.start = selection.cursor = cursor;
// reset this in the bv_owner!
if (bv_owner && bv_owner->text)
bv_owner->text->xsel_cache.set(false);
}