mirror of
https://review.haiku-os.org/haiku
synced 2025-01-31 18:56:49 +01:00
* 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:
parent
7cd194fffb
commit
11efbf0160
@ -91,7 +91,7 @@ const uint32 MSG_REMOVE_RESIZE_VIEW_IF_NEEDED = 'rmrv';
|
||||
const uint32 MSG_TERMINAL_BUFFER_CHANGED = 'bufc';
|
||||
const uint32 MSG_SET_TERMNAL_TITLE = 'sett';
|
||||
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
|
||||
const char* const PREF_HALF_FONT_FAMILY = "Half Font Family";
|
||||
|
@ -1094,6 +1094,10 @@ TermParse::_DecPrivateModeSet(int value)
|
||||
// screen).
|
||||
// Not supported yet.
|
||||
break;
|
||||
case 9:
|
||||
// Set Mouse X and Y on button press.
|
||||
fBuffer->ReportX10MouseEvent(true);
|
||||
break;
|
||||
case 12:
|
||||
// Start Blinking Cursor.
|
||||
// Not supported yet.
|
||||
@ -1107,7 +1111,13 @@ TermParse::_DecPrivateModeSet(int value)
|
||||
fBuffer->UseAlternateScreenBuffer(false);
|
||||
break;
|
||||
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;
|
||||
case 1003:
|
||||
// Use All Motion Mouse Tracking
|
||||
@ -1155,6 +1165,10 @@ TermParse::_DecPrivateModeReset(int value)
|
||||
// Normal Video (Leaves Reverse Video, cf. there).
|
||||
// Not supported yet.
|
||||
break;
|
||||
case 9:
|
||||
// Disable Mouse X and Y on button press.
|
||||
fBuffer->ReportX10MouseEvent(false);
|
||||
break;
|
||||
case 12:
|
||||
// Stop Blinking Cursor.
|
||||
// Not supported yet.
|
||||
@ -1168,7 +1182,13 @@ TermParse::_DecPrivateModeReset(int value)
|
||||
fBuffer->UseNormalScreenBuffer();
|
||||
break;
|
||||
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;
|
||||
case 1003:
|
||||
// Disable All Motion Mouse Tracking.
|
||||
|
@ -171,6 +171,9 @@ TermView::TermView(BRect frame, int32 argc, const char** argv, int32 historySize
|
||||
fRows(ROWS_DEFAULT),
|
||||
fEncoding(M_UTF8),
|
||||
fScrBufSize(historySize),
|
||||
fReportX10MouseEvent(false),
|
||||
fReportNormalMouseEvent(false),
|
||||
fReportButtonMouseEvent(false),
|
||||
fReportAnyMouseEvent(false)
|
||||
{
|
||||
_InitObject(argc, argv);
|
||||
@ -185,6 +188,9 @@ TermView::TermView(int rows, int columns, int32 argc, const char** argv,
|
||||
fRows(rows),
|
||||
fEncoding(M_UTF8),
|
||||
fScrBufSize(historySize),
|
||||
fReportX10MouseEvent(false),
|
||||
fReportNormalMouseEvent(false),
|
||||
fReportButtonMouseEvent(false),
|
||||
fReportAnyMouseEvent(false)
|
||||
{
|
||||
_InitObject(argc, argv);
|
||||
@ -210,6 +216,9 @@ TermView::TermView(BMessage* archive)
|
||||
fRows(ROWS_DEFAULT),
|
||||
fEncoding(M_UTF8),
|
||||
fScrBufSize(1000),
|
||||
fReportX10MouseEvent(false),
|
||||
fReportNormalMouseEvent(false),
|
||||
fReportButtonMouseEvent(false),
|
||||
fReportAnyMouseEvent(false)
|
||||
{
|
||||
// We need this
|
||||
@ -280,6 +289,10 @@ TermView::_InitObject(int32 argc, const char** argv)
|
||||
fMouseTracking = false;
|
||||
fIMflag = false;
|
||||
fCheckMouseTracking = false;
|
||||
fPrevPos = TermPos(-1, - 1);
|
||||
fReportX10MouseEvent = false;
|
||||
fReportNormalMouseEvent = false;
|
||||
fReportButtonMouseEvent = false;
|
||||
fReportAnyMouseEvent = false;
|
||||
|
||||
fTextBuffer = new(std::nothrow) TerminalBuffer;
|
||||
@ -1521,11 +1534,20 @@ TermView::MessageReceived(BMessage *msg)
|
||||
SetTitle(title);
|
||||
break;
|
||||
}
|
||||
case MSG_REPORT_ANY_MOUSE_EVENT:
|
||||
case MSG_REPORT_MOUSE_EVENT:
|
||||
{
|
||||
bool reportAnyMouseEvent;
|
||||
if (msg->FindBool("reportAnyMouseEvent", &reportAnyMouseEvent) == B_OK)
|
||||
fReportAnyMouseEvent = reportAnyMouseEvent;
|
||||
bool report;
|
||||
if (msg->FindBool("reportX10MouseEvent", &report) == B_OK)
|
||||
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;
|
||||
}
|
||||
case MSG_REMOVE_RESIZE_VIEW_IF_NEEDED:
|
||||
@ -2077,8 +2099,8 @@ TermView::MouseDown(BPoint where)
|
||||
|
||||
fMouseButtons = buttons;
|
||||
|
||||
if (fReportAnyMouseEvent) {
|
||||
|
||||
if (fReportAnyMouseEvent || fReportButtonMouseEvent
|
||||
|| fReportNormalMouseEvent || fReportX10MouseEvent) {
|
||||
TermPos clickPos = _ConvertToTerminal(where);
|
||||
_SendMouseEvent(buttons, modifier, clickPos.x, clickPos.y, false);
|
||||
return;
|
||||
@ -2169,11 +2191,20 @@ TermView::MouseDown(BPoint where)
|
||||
void
|
||||
TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *message)
|
||||
{
|
||||
if (fReportAnyMouseEvent) {
|
||||
if (fReportAnyMouseEvent || fReportButtonMouseEvent) {
|
||||
int32 modifier;
|
||||
Window()->CurrentMessage()->FindInt32("modifiers", &modifier);
|
||||
|
||||
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);
|
||||
return;
|
||||
}
|
||||
@ -2254,7 +2285,8 @@ TermView::MouseUp(BPoint where)
|
||||
int32 buttons;
|
||||
Window()->CurrentMessage()->FindInt32("buttons", &buttons);
|
||||
|
||||
if (fReportAnyMouseEvent) {
|
||||
if (fReportAnyMouseEvent || fReportButtonMouseEvent
|
||||
|| fReportNormalMouseEvent) {
|
||||
TermPos clickPos = _ConvertToTerminal(where);
|
||||
_SendMouseEvent(0, 0, clickPos.x, clickPos.y, false);
|
||||
} else {
|
||||
|
@ -177,7 +177,7 @@ private:
|
||||
void _ScrollTo(float y, bool scrollGfx);
|
||||
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);
|
||||
private:
|
||||
class CharClassifier;
|
||||
@ -253,7 +253,12 @@ private:
|
||||
bool fCheckMouseTracking;
|
||||
int fSelectGranularity;
|
||||
BPoint fLastClickPoint;
|
||||
|
||||
|
||||
// mouse
|
||||
TermPos fPrevPos;
|
||||
bool fReportX10MouseEvent;
|
||||
bool fReportNormalMouseEvent;
|
||||
bool fReportButtonMouseEvent;
|
||||
bool fReportAnyMouseEvent;
|
||||
|
||||
// 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
|
||||
TerminalBuffer::ReportAnyMouseEvent(bool reportAnyMouseEvent)
|
||||
{
|
||||
if (fListenerValid) {
|
||||
BMessage message(MSG_REPORT_ANY_MOUSE_EVENT);
|
||||
BMessage message(MSG_REPORT_MOUSE_EVENT);
|
||||
message.AddBool("reportAnyMouseEvent", reportAnyMouseEvent);
|
||||
fListener.SendMessage(&message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,8 +34,11 @@ public:
|
||||
|
||||
void UseAlternateScreenBuffer(bool clear);
|
||||
void UseNormalScreenBuffer();
|
||||
|
||||
void ReportAnyMouseEvent(bool reportAnyMouseEvent);
|
||||
|
||||
void ReportX10MouseEvent(bool report);
|
||||
void ReportNormalMouseEvent(bool report);
|
||||
void ReportButtonMouseEvent(bool report);
|
||||
void ReportAnyMouseEvent(bool report);
|
||||
|
||||
protected:
|
||||
virtual void NotifyListener();
|
||||
|
Loading…
x
Reference in New Issue
Block a user