* Applied patch by Olivier to implement more mouse reporting modes, and thus
fixing bug #2854. Thanks! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30374 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -91,7 +91,7 @@ const uint32 MSG_REMOVE_RESIZE_VIEW_IF_NEEDED = 'rmrv';
|
|||||||
const uint32 MSG_TERMINAL_BUFFER_CHANGED = 'bufc';
|
const uint32 MSG_TERMINAL_BUFFER_CHANGED = 'bufc';
|
||||||
const uint32 MSG_SET_TERMNAL_TITLE = 'sett';
|
const uint32 MSG_SET_TERMNAL_TITLE = 'sett';
|
||||||
const uint32 MSG_QUIT_TERMNAL = 'qutt';
|
const uint32 MSG_QUIT_TERMNAL = 'qutt';
|
||||||
const uint32 MSG_REPORT_ANY_MOUSE_EVENT = 'mous';
|
const uint32 MSG_REPORT_MOUSE_EVENT = 'mous';
|
||||||
|
|
||||||
// Preference Read/Write Keys
|
// Preference Read/Write Keys
|
||||||
const char* const PREF_HALF_FONT_FAMILY = "Half Font Family";
|
const char* const PREF_HALF_FONT_FAMILY = "Half Font Family";
|
||||||
|
|||||||
@@ -1094,6 +1094,10 @@ TermParse::_DecPrivateModeSet(int value)
|
|||||||
// screen).
|
// screen).
|
||||||
// Not supported yet.
|
// Not supported yet.
|
||||||
break;
|
break;
|
||||||
|
case 9:
|
||||||
|
// Set Mouse X and Y on button press.
|
||||||
|
fBuffer->ReportX10MouseEvent(true);
|
||||||
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
// Start Blinking Cursor.
|
// Start Blinking Cursor.
|
||||||
// Not supported yet.
|
// Not supported yet.
|
||||||
@@ -1107,7 +1111,13 @@ TermParse::_DecPrivateModeSet(int value)
|
|||||||
fBuffer->UseAlternateScreenBuffer(false);
|
fBuffer->UseAlternateScreenBuffer(false);
|
||||||
break;
|
break;
|
||||||
case 1000:
|
case 1000:
|
||||||
// TODO: Send Mouse X & Y on button press and release.
|
// Send Mouse X & Y on button press and release.
|
||||||
|
fBuffer->ReportNormalMouseEvent(true);
|
||||||
|
break;
|
||||||
|
case 1002:
|
||||||
|
// Send Mouse X and Y on button press and release, and on motion
|
||||||
|
// when the mouse enter a new cell
|
||||||
|
fBuffer->ReportButtonMouseEvent(true);
|
||||||
break;
|
break;
|
||||||
case 1003:
|
case 1003:
|
||||||
// Use All Motion Mouse Tracking
|
// Use All Motion Mouse Tracking
|
||||||
@@ -1155,6 +1165,10 @@ TermParse::_DecPrivateModeReset(int value)
|
|||||||
// Normal Video (Leaves Reverse Video, cf. there).
|
// Normal Video (Leaves Reverse Video, cf. there).
|
||||||
// Not supported yet.
|
// Not supported yet.
|
||||||
break;
|
break;
|
||||||
|
case 9:
|
||||||
|
// Disable Mouse X and Y on button press.
|
||||||
|
fBuffer->ReportX10MouseEvent(false);
|
||||||
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
// Stop Blinking Cursor.
|
// Stop Blinking Cursor.
|
||||||
// Not supported yet.
|
// Not supported yet.
|
||||||
@@ -1168,7 +1182,13 @@ TermParse::_DecPrivateModeReset(int value)
|
|||||||
fBuffer->UseNormalScreenBuffer();
|
fBuffer->UseNormalScreenBuffer();
|
||||||
break;
|
break;
|
||||||
case 1000:
|
case 1000:
|
||||||
// TODO: Don't send Mouse X & Y on button press and release.
|
// Don't send Mouse X & Y on button press and release.
|
||||||
|
fBuffer->ReportNormalMouseEvent(false);
|
||||||
|
break;
|
||||||
|
case 1002:
|
||||||
|
// Don't send Mouse X and Y on button press and release, and on motion
|
||||||
|
// when the mouse enter a new cell
|
||||||
|
fBuffer->ReportButtonMouseEvent(false);
|
||||||
break;
|
break;
|
||||||
case 1003:
|
case 1003:
|
||||||
// Disable All Motion Mouse Tracking.
|
// Disable All Motion Mouse Tracking.
|
||||||
|
|||||||
@@ -171,6 +171,9 @@ TermView::TermView(BRect frame, int32 argc, const char** argv, int32 historySize
|
|||||||
fRows(ROWS_DEFAULT),
|
fRows(ROWS_DEFAULT),
|
||||||
fEncoding(M_UTF8),
|
fEncoding(M_UTF8),
|
||||||
fScrBufSize(historySize),
|
fScrBufSize(historySize),
|
||||||
|
fReportX10MouseEvent(false),
|
||||||
|
fReportNormalMouseEvent(false),
|
||||||
|
fReportButtonMouseEvent(false),
|
||||||
fReportAnyMouseEvent(false)
|
fReportAnyMouseEvent(false)
|
||||||
{
|
{
|
||||||
_InitObject(argc, argv);
|
_InitObject(argc, argv);
|
||||||
@@ -185,6 +188,9 @@ TermView::TermView(int rows, int columns, int32 argc, const char** argv,
|
|||||||
fRows(rows),
|
fRows(rows),
|
||||||
fEncoding(M_UTF8),
|
fEncoding(M_UTF8),
|
||||||
fScrBufSize(historySize),
|
fScrBufSize(historySize),
|
||||||
|
fReportX10MouseEvent(false),
|
||||||
|
fReportNormalMouseEvent(false),
|
||||||
|
fReportButtonMouseEvent(false),
|
||||||
fReportAnyMouseEvent(false)
|
fReportAnyMouseEvent(false)
|
||||||
{
|
{
|
||||||
_InitObject(argc, argv);
|
_InitObject(argc, argv);
|
||||||
@@ -210,6 +216,9 @@ TermView::TermView(BMessage* archive)
|
|||||||
fRows(ROWS_DEFAULT),
|
fRows(ROWS_DEFAULT),
|
||||||
fEncoding(M_UTF8),
|
fEncoding(M_UTF8),
|
||||||
fScrBufSize(1000),
|
fScrBufSize(1000),
|
||||||
|
fReportX10MouseEvent(false),
|
||||||
|
fReportNormalMouseEvent(false),
|
||||||
|
fReportButtonMouseEvent(false),
|
||||||
fReportAnyMouseEvent(false)
|
fReportAnyMouseEvent(false)
|
||||||
{
|
{
|
||||||
// We need this
|
// We need this
|
||||||
@@ -280,6 +289,10 @@ TermView::_InitObject(int32 argc, const char** argv)
|
|||||||
fMouseTracking = false;
|
fMouseTracking = false;
|
||||||
fIMflag = false;
|
fIMflag = false;
|
||||||
fCheckMouseTracking = false;
|
fCheckMouseTracking = false;
|
||||||
|
fPrevPos = TermPos(-1, - 1);
|
||||||
|
fReportX10MouseEvent = false;
|
||||||
|
fReportNormalMouseEvent = false;
|
||||||
|
fReportButtonMouseEvent = false;
|
||||||
fReportAnyMouseEvent = false;
|
fReportAnyMouseEvent = false;
|
||||||
|
|
||||||
fTextBuffer = new(std::nothrow) TerminalBuffer;
|
fTextBuffer = new(std::nothrow) TerminalBuffer;
|
||||||
@@ -1521,11 +1534,20 @@ TermView::MessageReceived(BMessage *msg)
|
|||||||
SetTitle(title);
|
SetTitle(title);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MSG_REPORT_ANY_MOUSE_EVENT:
|
case MSG_REPORT_MOUSE_EVENT:
|
||||||
{
|
{
|
||||||
bool reportAnyMouseEvent;
|
bool report;
|
||||||
if (msg->FindBool("reportAnyMouseEvent", &reportAnyMouseEvent) == B_OK)
|
if (msg->FindBool("reportX10MouseEvent", &report) == B_OK)
|
||||||
fReportAnyMouseEvent = reportAnyMouseEvent;
|
fReportX10MouseEvent = report;
|
||||||
|
|
||||||
|
if (msg->FindBool("reportNormalMouseEvent", &report) == B_OK)
|
||||||
|
fReportNormalMouseEvent = report;
|
||||||
|
|
||||||
|
if (msg->FindBool("reportButtonMouseEvent", &report) == B_OK)
|
||||||
|
fReportButtonMouseEvent = report;
|
||||||
|
|
||||||
|
if (msg->FindBool("reportAnyMouseEvent", &report) == B_OK)
|
||||||
|
fReportAnyMouseEvent = report;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MSG_REMOVE_RESIZE_VIEW_IF_NEEDED:
|
case MSG_REMOVE_RESIZE_VIEW_IF_NEEDED:
|
||||||
@@ -2077,8 +2099,8 @@ TermView::MouseDown(BPoint where)
|
|||||||
|
|
||||||
fMouseButtons = buttons;
|
fMouseButtons = buttons;
|
||||||
|
|
||||||
if (fReportAnyMouseEvent) {
|
if (fReportAnyMouseEvent || fReportButtonMouseEvent
|
||||||
|
|| fReportNormalMouseEvent || fReportX10MouseEvent) {
|
||||||
TermPos clickPos = _ConvertToTerminal(where);
|
TermPos clickPos = _ConvertToTerminal(where);
|
||||||
_SendMouseEvent(buttons, modifier, clickPos.x, clickPos.y, false);
|
_SendMouseEvent(buttons, modifier, clickPos.x, clickPos.y, false);
|
||||||
return;
|
return;
|
||||||
@@ -2169,11 +2191,20 @@ TermView::MouseDown(BPoint where)
|
|||||||
void
|
void
|
||||||
TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *message)
|
TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *message)
|
||||||
{
|
{
|
||||||
if (fReportAnyMouseEvent) {
|
if (fReportAnyMouseEvent || fReportButtonMouseEvent) {
|
||||||
int32 modifier;
|
int32 modifier;
|
||||||
Window()->CurrentMessage()->FindInt32("modifiers", &modifier);
|
Window()->CurrentMessage()->FindInt32("modifiers", &modifier);
|
||||||
|
|
||||||
TermPos clickPos = _ConvertToTerminal(where);
|
TermPos clickPos = _ConvertToTerminal(where);
|
||||||
|
|
||||||
|
if (fReportButtonMouseEvent) {
|
||||||
|
if (fPrevPos.x != clickPos.x || fPrevPos.y != clickPos.y) {
|
||||||
|
_SendMouseEvent(fMouseButtons, modifier, clickPos.x, clickPos.y,
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
fPrevPos = clickPos;
|
||||||
|
return;
|
||||||
|
}
|
||||||
_SendMouseEvent(fMouseButtons, modifier, clickPos.x, clickPos.y, true);
|
_SendMouseEvent(fMouseButtons, modifier, clickPos.x, clickPos.y, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2254,7 +2285,8 @@ TermView::MouseUp(BPoint where)
|
|||||||
int32 buttons;
|
int32 buttons;
|
||||||
Window()->CurrentMessage()->FindInt32("buttons", &buttons);
|
Window()->CurrentMessage()->FindInt32("buttons", &buttons);
|
||||||
|
|
||||||
if (fReportAnyMouseEvent) {
|
if (fReportAnyMouseEvent || fReportButtonMouseEvent
|
||||||
|
|| fReportNormalMouseEvent) {
|
||||||
TermPos clickPos = _ConvertToTerminal(where);
|
TermPos clickPos = _ConvertToTerminal(where);
|
||||||
_SendMouseEvent(0, 0, clickPos.x, clickPos.y, false);
|
_SendMouseEvent(0, 0, clickPos.x, clickPos.y, false);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ private:
|
|||||||
void _ScrollTo(float y, bool scrollGfx);
|
void _ScrollTo(float y, bool scrollGfx);
|
||||||
void _ScrollToRange(TermPos start, TermPos end);
|
void _ScrollToRange(TermPos start, TermPos end);
|
||||||
|
|
||||||
void _SendMouseEvent(int32 button, int32 mode, int32 x,
|
void _SendMouseEvent(int32 button, int32 mode, int32 x,
|
||||||
int32 y, bool motion);
|
int32 y, bool motion);
|
||||||
private:
|
private:
|
||||||
class CharClassifier;
|
class CharClassifier;
|
||||||
@@ -253,7 +253,12 @@ private:
|
|||||||
bool fCheckMouseTracking;
|
bool fCheckMouseTracking;
|
||||||
int fSelectGranularity;
|
int fSelectGranularity;
|
||||||
BPoint fLastClickPoint;
|
BPoint fLastClickPoint;
|
||||||
|
|
||||||
|
// mouse
|
||||||
|
TermPos fPrevPos;
|
||||||
|
bool fReportX10MouseEvent;
|
||||||
|
bool fReportNormalMouseEvent;
|
||||||
|
bool fReportButtonMouseEvent;
|
||||||
bool fReportAnyMouseEvent;
|
bool fReportAnyMouseEvent;
|
||||||
|
|
||||||
// Input Method parameter.
|
// Input Method parameter.
|
||||||
@@ -267,4 +272,4 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //TERMVIEW_H
|
#endif // TERMVIEW_H
|
||||||
|
|||||||
@@ -74,14 +74,47 @@ TerminalBuffer::Encoding() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TerminalBuffer::ReportX10MouseEvent(bool reportX10MouseEvent)
|
||||||
|
{
|
||||||
|
if (fListenerValid) {
|
||||||
|
BMessage message(MSG_REPORT_MOUSE_EVENT);
|
||||||
|
message.AddBool("reportX10MouseEvent", reportX10MouseEvent);
|
||||||
|
fListener.SendMessage(&message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TerminalBuffer::ReportNormalMouseEvent(bool reportNormalMouseEvent)
|
||||||
|
{
|
||||||
|
if (fListenerValid) {
|
||||||
|
BMessage message(MSG_REPORT_MOUSE_EVENT);
|
||||||
|
message.AddBool("reportNormalMouseEvent", reportNormalMouseEvent);
|
||||||
|
fListener.SendMessage(&message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TerminalBuffer::ReportButtonMouseEvent(bool report)
|
||||||
|
{
|
||||||
|
if (fListenerValid) {
|
||||||
|
BMessage message(MSG_REPORT_MOUSE_EVENT);
|
||||||
|
message.AddBool("reportButtonMouseEvent", report);
|
||||||
|
fListener.SendMessage(&message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TerminalBuffer::ReportAnyMouseEvent(bool reportAnyMouseEvent)
|
TerminalBuffer::ReportAnyMouseEvent(bool reportAnyMouseEvent)
|
||||||
{
|
{
|
||||||
if (fListenerValid) {
|
if (fListenerValid) {
|
||||||
BMessage message(MSG_REPORT_ANY_MOUSE_EVENT);
|
BMessage message(MSG_REPORT_MOUSE_EVENT);
|
||||||
message.AddBool("reportAnyMouseEvent", reportAnyMouseEvent);
|
message.AddBool("reportAnyMouseEvent", reportAnyMouseEvent);
|
||||||
fListener.SendMessage(&message);
|
fListener.SendMessage(&message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,11 @@ public:
|
|||||||
|
|
||||||
void UseAlternateScreenBuffer(bool clear);
|
void UseAlternateScreenBuffer(bool clear);
|
||||||
void UseNormalScreenBuffer();
|
void UseNormalScreenBuffer();
|
||||||
|
|
||||||
void ReportAnyMouseEvent(bool reportAnyMouseEvent);
|
void ReportX10MouseEvent(bool report);
|
||||||
|
void ReportNormalMouseEvent(bool report);
|
||||||
|
void ReportButtonMouseEvent(bool report);
|
||||||
|
void ReportAnyMouseEvent(bool report);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void NotifyListener();
|
virtual void NotifyListener();
|
||||||
|
|||||||
Reference in New Issue
Block a user