As the title says.

This patch supports all frontends and is straight forward. I intent to put this general code in some code common to all frontends in the future.

Abdel.

Log:
* BufferView:
 - BufferView::selectionRequested() changed to
docstring const & getStringSelection(), the X11 selection part is transfered to the frontends.

Index: BufferView.C
===================================================================
--- BufferView.C        (revision 15018)
+++ BufferView.C        (working copy)
@@ -1014,7 +1014,7 @@
 }
 
 
-void BufferView::selectionRequested()
+docstring const & BufferView::getStringSelection()
 {
        static docstring sel;
 
@@ -1039,6 +1039,7 @@
                if (!sel.empty())
                        owner_->gui().selection().put(sel);
        }
+       return sel;
 }
 
 
Index: BufferView.h
===================================================================
--- BufferView.h        (revision 15018)
+++ BufferView.h        (working copy)
@@ -174,7 +174,7 @@
        bool dispatch(FuncRequest const & argument);
 
        ///
-       void selectionRequested();
+       lyx::docstring const & getStringSelection();
        ///
        void selectionLost();
 
Index: frontends/gtk/GWorkArea.C
===================================================================
--- frontends/gtk/GWorkArea.C   (revision 15012)
+++ frontends/gtk/GWorkArea.C   (working copy)
@@ -495,7 +495,9 @@
 void GWorkArea::onClipboardGet(Gtk::SelectionData & /*selection_data*/,
                               guint /*info*/)
 {
-       view_.view()->selectionRequested();
+       lyx::docstring const & sel = view_.view()->getStringSelection();
+       if (!sel.empty())
+               view_.gui().selection().put(sel);
 }
 
 
Index: frontends/qt3/QWorkArea.C
===================================================================
--- frontends/qt3/QWorkArea.C   (revision 15012)
+++ frontends/qt3/QWorkArea.C   (working copy)
@@ -110,8 +110,11 @@
        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().getStringSelection();
+                       if (!sel.empty())
+                               wa_ptr->view().gui().selection().put(sel);
+               }
                break;
        case SelectionClear:
                lyxerr[Debug::GUI] << "Lost selection." << endl;
Index: frontends/qt4/Application.C
===================================================================
--- frontends/qt4/Application.C (revision 15012)
+++ frontends/qt4/Application.C (working copy)
@@ -79,8 +79,11 @@
        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_->getStringSelection();
+                       if (!sel.empty())
+                               gui_.selection().put(sel);
+               }
                break;
        case SelectionClear:
                lyxerr[Debug::GUI] << "Lost selection." << endl;

Reply via email to