]> git.lyx.org Git - features.git/commitdiff
Move X11 specific selection code from BufferView to the frontends.
authorAbdelrazak Younes <younes@lyx.org>
Sun, 17 Sep 2006 08:35:12 +0000 (08:35 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sun, 17 Sep 2006 08:35:12 +0000 (08:35 +0000)
* BufferView:
 - selectionRequested(): renamed to requestSelection() and cleaned up.
 - selectionLost(): renamed to clearSelection()

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15024 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.C
src/BufferView.h
src/frontends/gtk/GWorkArea.C
src/frontends/qt3/QWorkArea.C
src/frontends/qt4/Application.C

index 709da3c6f6caf07c73a642736753e63b8fe1a505..73977928b419e2d85ab4de099b6a14c0e333d613 100644 (file)
@@ -1014,18 +1014,16 @@ bool BufferView::dispatch(FuncRequest const & cmd)
 }
 
 
-void BufferView::selectionRequested()
+docstring const BufferView::requestSelection()
 {
-       static docstring sel;
-
        if (!buffer_)
-               return;
+               return docstring();
 
        LCursor & cur = cursor_;
 
        if (!cur.selection()) {
                xsel_cache_.set = false;
-               return;
+               return docstring();
        }
 
        if (!xsel_cache_.set ||
@@ -1035,14 +1033,13 @@ void BufferView::selectionRequested()
                xsel_cache_.cursor = cur.top();
                xsel_cache_.anchor = cur.anchor_.top();
                xsel_cache_.set = cur.selection();
-               sel = cur.selectionAsString(false);
-               if (!sel.empty())
-                       owner_->gui().selection().put(sel);
+               return cur.selectionAsString(false);
        }
+       return docstring();
 }
 
 
-void BufferView::selectionLost()
+void BufferView::clearSelection()
 {
        if (buffer_) {
                cursor_.clearSelection();
index 2f580a3263b495f33bd0ee50ea898fe802f36fc7..c03a8873873dc2b897c7b176f79d7a8c044c0bd3 100644 (file)
@@ -174,9 +174,9 @@ public:
        bool dispatch(FuncRequest const & argument);
 
        ///
-       void selectionRequested();
+       lyx::docstring const requestSelection();
        ///
-       void selectionLost();
+       void clearSelection();
 
        ///
        void workAreaResize(int width, int height);
index f85330beea8bd2b9a43c536d81ad80df00d1c4b8..19d973e8ca44637ceb1d67d51a9a97b956022357 100644 (file)
@@ -495,13 +495,15 @@ bool GWorkArea::onKeyPress(GdkEventKey * event)
 void GWorkArea::onClipboardGet(Gtk::SelectionData & /*selection_data*/,
                               guint /*info*/)
 {
-       view_.view()->selectionRequested();
+       lyx::docstring const sel = view_.view()->requestSelection();
+       if (!sel.empty())
+               view_.gui().selection().put(sel);
 }
 
 
 void GWorkArea::onClipboardClear()
 {
-//     selectionLost();
+//     clearSelection();
 }
 
 
index 24d8a110b1f7e416b314acb7e119216ab04c31e6..e24be3c7d5835a74362bdca86de763b7e588c5db 100644 (file)
@@ -110,13 +110,16 @@ bool lyxX11EventFilter(XEvent * xev)
        switch (xev->type) {
        case SelectionRequest:
                lyxerr[Debug::GUI] << "X requested selection." << endl;
-               if (wa_ptr)
-                       wa_ptr->view().view()->selectionRequested();
+               if (wa_ptr) {
+                       lyx::docstring const sel = wa_ptr->view().requestSelection();
+                       if (!sel.empty())
+                               wa_ptr->view().gui().selection().put(sel);
+               }
                break;
        case SelectionClear:
                lyxerr[Debug::GUI] << "Lost selection." << endl;
                if (wa_ptr)
-                       wa_ptr->view().view()->selectionLost();
+                       wa_ptr->view().view()->clearSelection();
                break;
        }
        return false;
index d12aecbac19549cd8147b51d26a00b4edaf60e4d..24d97a72da26c23b006c25ec480d37153833deda 100644 (file)
@@ -79,13 +79,16 @@ bool Application::x11EventFilter(XEvent * xev)
        switch (xev->type) {
        case SelectionRequest:
                lyxerr[Debug::GUI] << "X requested selection." << endl;
-               if (buffer_view_)
-                       buffer_view_->selectionRequested();
+               if (buffer_view_) {
+                       lyx::docstring const sel = buffer_view_->requestSelection();
+                       if (!sel.empty())
+                               gui_.selection().put(sel);
+               }
                break;
        case SelectionClear:
                lyxerr[Debug::GUI] << "Lost selection." << endl;
                if (buffer_view_)
-                       buffer_view_->selectionLost();
+                       buffer_view_->clearSelection();
                break;
        }
        return false;