.connect(slot(this, &BufferView::Pimpl::tripleClick));
workarea_.workAreaKeyPress
.connect(slot(this, &BufferView::Pimpl::workAreaKeyPress));
+ workarea_.selectionRequested
+ .connect(slot(this, &BufferView::Pimpl::selectionRequested));
cursor_timeout.timeout.connect(slot(this,
&BufferView::Pimpl::cursorToggle));
}
+void BufferView::Pimpl::selectionRequested()
+{
+ string const sel(bv_->getLyXText()->selectionAsString(bv_->buffer(), false));
+ if (!sel.empty()) {
+ workarea_.putClipboard(sel);
+ }
+}
+
+
void BufferView::Pimpl::enterView()
{
if (active() && available()) {
if (button == 2)
return;
+ // finish selection
+ if (button == 1) {
+ workarea_.haveSelection(bv_->getLyXText()->selection.set());
+ }
+
setState();
owner_->showState();
owner_->updateMenubar();
///
void tripleClick(int x, int y, unsigned int button);
///
+ void selectionRequested();
+ ///
void enterView();
///
void leaveView();
+2001-11-26 John Levon <moz@compsoc.man.ac.uk>
+
+ * BufferView_pimpl.h:
+ * BufferView_pimpl.C:
+ * WorkArea.h:
+ * WorkArea.C:
+ * text2.C: tell X when we have made a selection for copying
+
2002-01-13 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* BufferView_pimpl.C (MenuInsertLyXFile):
#include <cmath>
#include <cctype>
+// xforms doesn't define this (but it should be in <forms.h>).
+extern "C"
+FL_APPEVENT_CB fl_set_preemptive_callback(Window, FL_APPEVENT_CB, void *);
+
using std::endl;
using std::abs;
return WorkArea::work_area_handler(ob, event,
0, 0, key, xev);
}
+
+ static
+ int C_WorkAreaEventCB(FL_FORM * form, void * xev) {
+ WorkArea * wa=static_cast<WorkArea*>(form->u_vdata);
+ wa->event_cb(static_cast<XEvent*>(xev));
+ return 0;
+ }
}
fl_set_object_resize(obj, FL_RESIZE_ALL);
fl_set_object_gravity(obj, NorthWestGravity, SouthEastGravity);
+ /// X selection hook - xforms gets it wrong
+ fl_current_form->u_vdata = this;
+ fl_register_raw_callback(fl_current_form, FL_ALL_EVENT, C_WorkAreaEventCB);
+
fl_unfreeze_all_forms();
}
} // namespace anon
+void WorkArea::event_cb(XEvent * xev)
+{
+ if (xev->type != SelectionRequest)
+ return;
+
+ selectionRequested.emit();
+ return;
+}
+
+
+void WorkArea::haveSelection(bool yes) const
+{
+ if (!yes) {
+ XSetSelectionOwner(fl_get_display(), XA_PRIMARY, None, CurrentTime);
+ return;
+ }
+
+ XSetSelectionOwner(fl_get_display(), XA_PRIMARY, FL_ObjWin(work_area), CurrentTime);
+}
+
+
string const WorkArea::getClipboard() const
{
clipboard_read = false;
int /*key*/, void * xev);
/// xforms callback
static void scroll_cb(FL_OBJECT *, long);
+ /// a selection exists
+ void haveSelection(bool) const;
///
string const getClipboard() const;
///
SigC::Signal3<void, int, int, unsigned int> workAreaDoubleClick;
///
SigC::Signal3<void, int, int, unsigned int> workAreaTripleClick;
+ /// emitted when an X client has requested our selection
+ SigC::Signal0<void> selectionRequested;
+
+ /// handles SelectionRequest X Event, to fill the clipboard
+ void WorkArea::event_cb(XEvent * xev);
private:
///
void createPixmap(int, int);
+
///
FL_OBJECT * backgroundbox;
///
void LyXText::copySelection(BufferView * bview)
{
- // Stuff what we got on the clipboard. Even if there is no selection.
-
- // There is a problem with having the stuffing here in that the
- // larger the selection the slower LyX will get. This can be
- // solved by running the line below only when the selection has
- // finished. The solution used currently just works, to make it
- // faster we need to be more clever and probably also have more
- // calls to stuffClipboard. (Lgb)
+ // stuff the selection onto the X clipboard, from an explicit copy request
bview->stuffClipboard(selectionAsString(bview->buffer(), true));
// this doesnt make sense, if there is no selection