mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-08 10:51:03 +00:00
fix some crash when we start selection outside an inset and get the
first motion event inside this iset git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8930 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
edbef46cd7
commit
6cb284c727
@ -924,17 +924,17 @@ void MathNestInset::lfunMousePress(LCursor & cur, FuncRequest & cmd)
|
||||
void MathNestInset::lfunMouseMotion(LCursor & cur, FuncRequest & cmd)
|
||||
{
|
||||
// only select with button 1
|
||||
if (cmd.button() != mouse_button::button1)
|
||||
return;
|
||||
if (cmd.button() == mouse_button::button1) {
|
||||
LCursor & bvcur = cur.bv().cursor();
|
||||
if (abs(cmd.x - first_x) + abs(cmd.y - first_y) > 4
|
||||
&& cur.size() <= bvcur.anchor_.size()) {
|
||||
first_x = cmd.x;
|
||||
first_y = cmd.y;
|
||||
|
||||
if (abs(cmd.x - first_x) < 2 && abs(cmd.y - first_y) < 2)
|
||||
return;
|
||||
|
||||
first_x = cmd.x;
|
||||
first_y = cmd.y;
|
||||
|
||||
cur.bv().cursor().setCursor(cur);
|
||||
cur.bv().cursor().selection() = true;
|
||||
bvcur.setCursor(cur);
|
||||
bvcur.selection() = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -943,7 +943,6 @@ void MathNestInset::lfunMouseRelease(LCursor & cur, FuncRequest & cmd)
|
||||
lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl;
|
||||
|
||||
if (cmd.button() == mouse_button::button1) {
|
||||
// try to dispatch to enclosed insets first
|
||||
//cur.bv().stuffClipboard(cur.grabSelection());
|
||||
return;
|
||||
}
|
||||
|
74
src/text3.C
74
src/text3.C
@ -1060,43 +1060,6 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_MOUSE_MOTION: {
|
||||
// Only use motion with button 1
|
||||
//if (cmd.button() != mouse_button::button1)
|
||||
// return false;
|
||||
// We want to use only motion events for which
|
||||
// the button press event was on the drawing area too.
|
||||
if (!selection_possible) {
|
||||
lyxerr[Debug::ACTION] << "BufferView::Pimpl::"
|
||||
"dispatch: no selection possible\n";
|
||||
lyxerr << "BufferView::Pimpl::dispatch: no selection possible\n";
|
||||
break;
|
||||
}
|
||||
|
||||
// ignore motions deeper nested than the real anchor
|
||||
LCursor & bvcur = cur.bv().cursor();
|
||||
if (bvcur.selection() && bvcur.anchor_.size() < cur.size())
|
||||
break;
|
||||
|
||||
CursorSlice old = cur.top();
|
||||
setCursorFromCoordinates(cur, cmd.x, cmd.y);
|
||||
|
||||
// This is to allow jumping over large insets
|
||||
// FIXME: shouldn't be top-text-specific
|
||||
if (isMainText() && cur.top() == old) {
|
||||
if (cmd.y - bv->top_y() >= bv->workHeight())
|
||||
cursorDown(cur);
|
||||
else if (cmd.y - bv->top_y() < 0)
|
||||
cursorUp(cur);
|
||||
}
|
||||
|
||||
// don't set anchor_
|
||||
bv->cursor().setCursor(cur);
|
||||
bv->cursor().selection() = true;
|
||||
lyxerr << "MOTION: " << bv->cursor() << endl;
|
||||
break;
|
||||
}
|
||||
|
||||
// Single-click on work area
|
||||
case LFUN_MOUSE_PRESS: {
|
||||
// Right click on a footnote flag opens float menu
|
||||
@ -1151,6 +1114,43 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_MOUSE_MOTION: {
|
||||
// Only use motion with button 1
|
||||
//if (cmd.button() != mouse_button::button1)
|
||||
// return false;
|
||||
// We want to use only motion events for which
|
||||
// the button press event was on the drawing area too.
|
||||
if (!selection_possible) {
|
||||
lyxerr[Debug::ACTION] << "BufferView::Pimpl::"
|
||||
"dispatch: no selection possible\n";
|
||||
lyxerr << "BufferView::Pimpl::dispatch: no selection possible\n";
|
||||
break;
|
||||
}
|
||||
|
||||
// ignore motions deeper nested than the real anchor
|
||||
LCursor & bvcur = cur.bv().cursor();
|
||||
if (bvcur.anchor_.size() < cur.size())
|
||||
break;
|
||||
|
||||
CursorSlice old = cur.top();
|
||||
setCursorFromCoordinates(cur, cmd.x, cmd.y);
|
||||
|
||||
// This is to allow jumping over large insets
|
||||
// FIXME: shouldn't be top-text-specific
|
||||
if (isMainText() && cur.top() == old) {
|
||||
if (cmd.y - bv->top_y() >= bv->workHeight())
|
||||
cursorDown(cur);
|
||||
else if (cmd.y - bv->top_y() < 0)
|
||||
cursorUp(cur);
|
||||
}
|
||||
|
||||
// don't set anchor_
|
||||
bv->cursor().setCursor(cur);
|
||||
bv->cursor().selection() = true;
|
||||
lyxerr << "MOTION: " << bv->cursor() << endl;
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_MOUSE_RELEASE: {
|
||||
selection_possible = false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user