Georg Baum wrote:
selection, so a sensible cleanup IMO would be to rename selectionRequested to requestSelection and selectionLost to clearSelection.

I've done that and verified that it will compile under X11. Will commit soon.

Abdel.
Index: BufferView.C
===================================================================
--- BufferView.C        (revision 15018)
+++ BufferView.C        (working copy)
@@ -1014,18 +1014,16 @@
 }
 
 
-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 @@
                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: BufferView.h
===================================================================
--- BufferView.h        (revision 15018)
+++ BufferView.h        (working copy)
@@ -174,9 +174,9 @@
        bool dispatch(FuncRequest const & argument);
 
        ///
-       void selectionRequested();
+       lyx::docstring const requestSelection();
        ///
-       void selectionLost();
+       void clearSelection();
 
        ///
        void workAreaResize(int width, int height);
Index: frontends/gtk/GWorkArea.C
===================================================================
--- frontends/gtk/GWorkArea.C   (revision 15012)
+++ frontends/gtk/GWorkArea.C   (working copy)
@@ -495,13 +495,15 @@
 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: frontends/qt3/QWorkArea.C
===================================================================
--- frontends/qt3/QWorkArea.C   (revision 15012)
+++ frontends/qt3/QWorkArea.C   (working copy)
@@ -110,13 +110,16 @@
        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: frontends/qt4/Application.C
===================================================================
--- frontends/qt4/Application.C (revision 15012)
+++ frontends/qt4/Application.C (working copy)
@@ -79,13 +79,16 @@
        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;

Reply via email to