]> git.lyx.org Git - features.git/commitdiff
Fix polling of selection request to not call the asString function every time.
authorJürgen Vigna <jug@sad.it>
Wed, 20 Mar 2002 10:36:03 +0000 (10:36 +0000)
committerJürgen Vigna <jug@sad.it>
Wed, 20 Mar 2002 10:36:03 +0000 (10:36 +0000)
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
src/ChangeLog
src/WorkArea.C
src/insets/ChangeLog
src/insets/insetgraphics.C
src/lyxtext.h
src/text2.C

index ae3ee5e487429c3d77effd0e07f3701e015d9a5c..ec1f53a9c81d9275be31d95c689887e9691b767c 100644 (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);
        }
@@ -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);
index 2a4ec702cba7e528dceb3f2b273a3528ecb0ed67..5be8e62f439019ca19503656d619f94cce89ae77 100644 (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
index 9e77c3ff0077f034f95e1f819958714950fd6422..6131ec7bb6d5e4183b622e09985831b50565e1f5 100644 (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;
index 216326c7f63575631619a65343a7352a3d3cd277..f1cfae1f9bb72387fa36ed0dcbed1d07c3f6fa43 100644 (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.
index 69e300bf864abf4ebfe5280444451b6d7df77b56..ea7cfc0242ae9b6949636b572a037b2ca92f06be 100644 (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);
        }
  
index 18812862ca2d0f6c9ec31331ae8b444d34eeb880..b59b37a55a674b3447df299cdd630e487006722f 100644 (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; 
index 861f4c363ae8f315d40636532c5e4324fe2639f1..bbed1cb927a4ea36885393d199201ecce00a9aca 100644 (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);
 }