From 92904c615a85ba31d21fb5d206a1c5ff7d82c780 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Wed, 20 Mar 2002 10:36:03 +0000 Subject: [PATCH] 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 --- src/BufferView_pimpl.C | 27 ++++++++++++++++++++++----- src/ChangeLog | 10 ++++++++++ src/WorkArea.C | 4 ++-- src/insets/ChangeLog | 4 ++++ src/insets/insetgraphics.C | 2 +- src/lyxtext.h | 2 ++ src/text2.C | 3 +++ 7 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index ae3ee5e487..ec1f53a9c8 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -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); } @@ -765,7 +778,8 @@ void BufferView::Pimpl::selectionLost() hideCursor(); toggleSelection(); bv_->getLyXText()->clearSelection(); - showCursor(); + showCursor(); + bv_->text->xsel_cache.set(false); } } @@ -1439,6 +1453,9 @@ void BufferView::Pimpl::moveCursorUpdate(bool selecting) update(lt, BufferView::SELECT|BufferView::FITCUR); 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? @@ -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); diff --git a/src/ChangeLog b/src/ChangeLog index 2a4ec702cb..5be8e62f43 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2002-03-19 Juergen Vigna + + * 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 * text2.C (setCursorIntern): put debuging code in INSETS channel diff --git a/src/WorkArea.C b/src/WorkArea.C index 9e77c3ff00..6131ec7bb6 100644 --- a/src/WorkArea.C +++ b/src/WorkArea.C @@ -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; diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 216326c7f6..f1cfae1f9b 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,7 @@ +2002-03-19 Juergen Vigna + + * insetgraphics.C (draw): fixed the setting of CHANGED_IN_DRAW! + 2002-03-18 Angus Leeming * insetgraphics.C: Clean up Baruch's comments a little. diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 69e300bf86..ea7cfc0242 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -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); } diff --git a/src/lyxtext.h b/src/lyxtext.h index 18812862ca..b59b37a55a 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -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; diff --git a/src/text2.C b/src/text2.C index 861f4c363a..bbed1cb927 100644 --- a/src/text2.C +++ b/src/text2.C @@ -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); } -- 2.39.5