mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 21:40:19 +00:00
bug 69
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3357 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
1cfd4fceac
commit
813234f7e6
@ -155,6 +155,8 @@ BufferView::Pimpl::Pimpl(BufferView * b, LyXView * o,
|
||||
.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));
|
||||
@ -736,6 +738,15 @@ void BufferView::Pimpl::tripleClick(int /*x*/, int /*y*/, unsigned int button)
|
||||
}
|
||||
|
||||
|
||||
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()) {
|
||||
@ -780,6 +791,11 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
|
||||
if (button == 2)
|
||||
return;
|
||||
|
||||
// finish selection
|
||||
if (button == 1) {
|
||||
workarea_.haveSelection(bv_->getLyXText()->selection.set());
|
||||
}
|
||||
|
||||
setState();
|
||||
owner_->showState();
|
||||
owner_->updateMenubar();
|
||||
|
@ -78,6 +78,8 @@ struct BufferView::Pimpl : public SigC::Object {
|
||||
///
|
||||
void tripleClick(int x, int y, unsigned int button);
|
||||
///
|
||||
void selectionRequested();
|
||||
///
|
||||
void enterView();
|
||||
///
|
||||
void leaveView();
|
||||
|
@ -1,3 +1,11 @@
|
||||
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):
|
||||
|
@ -31,6 +31,10 @@
|
||||
#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;
|
||||
|
||||
@ -64,6 +68,13 @@ extern "C" {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -172,6 +183,10 @@ WorkArea::WorkArea(int xpos, int ypos, int width, int height)
|
||||
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();
|
||||
}
|
||||
|
||||
@ -559,6 +574,27 @@ extern "C" {
|
||||
|
||||
} // 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;
|
||||
|
@ -95,6 +95,8 @@ public:
|
||||
int /*key*/, void * xev);
|
||||
/// xforms callback
|
||||
static void scroll_cb(FL_OBJECT *, long);
|
||||
/// a selection exists
|
||||
void haveSelection(bool) const;
|
||||
///
|
||||
string const getClipboard() const;
|
||||
///
|
||||
@ -124,9 +126,15 @@ public:
|
||||
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;
|
||||
///
|
||||
|
@ -1796,14 +1796,7 @@ void LyXText::cutSelection(BufferView * bview, bool doclear, bool realcut)
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user