mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 05:33:33 +00:00
Move X11 specific selection code from BufferView to the frontends.
* 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
This commit is contained in:
parent
2805c29734
commit
574e4444a8
@ -1014,18 +1014,16 @@ bool BufferView::dispatch(FuncRequest const & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BufferView::selectionRequested()
|
docstring const BufferView::requestSelection()
|
||||||
{
|
{
|
||||||
static docstring sel;
|
|
||||||
|
|
||||||
if (!buffer_)
|
if (!buffer_)
|
||||||
return;
|
return docstring();
|
||||||
|
|
||||||
LCursor & cur = cursor_;
|
LCursor & cur = cursor_;
|
||||||
|
|
||||||
if (!cur.selection()) {
|
if (!cur.selection()) {
|
||||||
xsel_cache_.set = false;
|
xsel_cache_.set = false;
|
||||||
return;
|
return docstring();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!xsel_cache_.set ||
|
if (!xsel_cache_.set ||
|
||||||
@ -1035,14 +1033,13 @@ void BufferView::selectionRequested()
|
|||||||
xsel_cache_.cursor = cur.top();
|
xsel_cache_.cursor = cur.top();
|
||||||
xsel_cache_.anchor = cur.anchor_.top();
|
xsel_cache_.anchor = cur.anchor_.top();
|
||||||
xsel_cache_.set = cur.selection();
|
xsel_cache_.set = cur.selection();
|
||||||
sel = cur.selectionAsString(false);
|
return cur.selectionAsString(false);
|
||||||
if (!sel.empty())
|
|
||||||
owner_->gui().selection().put(sel);
|
|
||||||
}
|
}
|
||||||
|
return docstring();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BufferView::selectionLost()
|
void BufferView::clearSelection()
|
||||||
{
|
{
|
||||||
if (buffer_) {
|
if (buffer_) {
|
||||||
cursor_.clearSelection();
|
cursor_.clearSelection();
|
||||||
|
@ -174,9 +174,9 @@ public:
|
|||||||
bool dispatch(FuncRequest const & argument);
|
bool dispatch(FuncRequest const & argument);
|
||||||
|
|
||||||
///
|
///
|
||||||
void selectionRequested();
|
lyx::docstring const requestSelection();
|
||||||
///
|
///
|
||||||
void selectionLost();
|
void clearSelection();
|
||||||
|
|
||||||
///
|
///
|
||||||
void workAreaResize(int width, int height);
|
void workAreaResize(int width, int height);
|
||||||
|
@ -495,13 +495,15 @@ bool GWorkArea::onKeyPress(GdkEventKey * event)
|
|||||||
void GWorkArea::onClipboardGet(Gtk::SelectionData & /*selection_data*/,
|
void GWorkArea::onClipboardGet(Gtk::SelectionData & /*selection_data*/,
|
||||||
guint /*info*/)
|
guint /*info*/)
|
||||||
{
|
{
|
||||||
view_.view()->selectionRequested();
|
lyx::docstring const sel = view_.view()->requestSelection();
|
||||||
|
if (!sel.empty())
|
||||||
|
view_.gui().selection().put(sel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GWorkArea::onClipboardClear()
|
void GWorkArea::onClipboardClear()
|
||||||
{
|
{
|
||||||
// selectionLost();
|
// clearSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -110,13 +110,16 @@ bool lyxX11EventFilter(XEvent * xev)
|
|||||||
switch (xev->type) {
|
switch (xev->type) {
|
||||||
case SelectionRequest:
|
case SelectionRequest:
|
||||||
lyxerr[Debug::GUI] << "X requested selection." << endl;
|
lyxerr[Debug::GUI] << "X requested selection." << endl;
|
||||||
if (wa_ptr)
|
if (wa_ptr) {
|
||||||
wa_ptr->view().view()->selectionRequested();
|
lyx::docstring const sel = wa_ptr->view().requestSelection();
|
||||||
|
if (!sel.empty())
|
||||||
|
wa_ptr->view().gui().selection().put(sel);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SelectionClear:
|
case SelectionClear:
|
||||||
lyxerr[Debug::GUI] << "Lost selection." << endl;
|
lyxerr[Debug::GUI] << "Lost selection." << endl;
|
||||||
if (wa_ptr)
|
if (wa_ptr)
|
||||||
wa_ptr->view().view()->selectionLost();
|
wa_ptr->view().view()->clearSelection();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -79,13 +79,16 @@ bool Application::x11EventFilter(XEvent * xev)
|
|||||||
switch (xev->type) {
|
switch (xev->type) {
|
||||||
case SelectionRequest:
|
case SelectionRequest:
|
||||||
lyxerr[Debug::GUI] << "X requested selection." << endl;
|
lyxerr[Debug::GUI] << "X requested selection." << endl;
|
||||||
if (buffer_view_)
|
if (buffer_view_) {
|
||||||
buffer_view_->selectionRequested();
|
lyx::docstring const sel = buffer_view_->requestSelection();
|
||||||
|
if (!sel.empty())
|
||||||
|
gui_.selection().put(sel);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SelectionClear:
|
case SelectionClear:
|
||||||
lyxerr[Debug::GUI] << "Lost selection." << endl;
|
lyxerr[Debug::GUI] << "Lost selection." << endl;
|
||||||
if (buffer_view_)
|
if (buffer_view_)
|
||||||
buffer_view_->selectionLost();
|
buffer_view_->clearSelection();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user