The cursor didn't start blinking, unless the window was activated (by clicking outside and then inside the window).
Copied the BTextView mechanism: Activate and Deactivate the view on MakeFocus and WindowActivated. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34061 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -170,6 +170,7 @@ TermView::TermView(BRect frame, int32 argc, const char** argv, int32 historySize
|
|||||||
fColumns(COLUMNS_DEFAULT),
|
fColumns(COLUMNS_DEFAULT),
|
||||||
fRows(ROWS_DEFAULT),
|
fRows(ROWS_DEFAULT),
|
||||||
fEncoding(M_UTF8),
|
fEncoding(M_UTF8),
|
||||||
|
fActive(false),
|
||||||
fScrBufSize(historySize),
|
fScrBufSize(historySize),
|
||||||
fReportX10MouseEvent(false),
|
fReportX10MouseEvent(false),
|
||||||
fReportNormalMouseEvent(false),
|
fReportNormalMouseEvent(false),
|
||||||
@@ -187,6 +188,7 @@ TermView::TermView(int rows, int columns, int32 argc, const char** argv,
|
|||||||
fColumns(columns),
|
fColumns(columns),
|
||||||
fRows(rows),
|
fRows(rows),
|
||||||
fEncoding(M_UTF8),
|
fEncoding(M_UTF8),
|
||||||
|
fActive(false),
|
||||||
fScrBufSize(historySize),
|
fScrBufSize(historySize),
|
||||||
fReportX10MouseEvent(false),
|
fReportX10MouseEvent(false),
|
||||||
fReportNormalMouseEvent(false),
|
fReportNormalMouseEvent(false),
|
||||||
@@ -215,6 +217,7 @@ TermView::TermView(BMessage* archive)
|
|||||||
fColumns(COLUMNS_DEFAULT),
|
fColumns(COLUMNS_DEFAULT),
|
||||||
fRows(ROWS_DEFAULT),
|
fRows(ROWS_DEFAULT),
|
||||||
fEncoding(M_UTF8),
|
fEncoding(M_UTF8),
|
||||||
|
fActive(false),
|
||||||
fScrBufSize(1000),
|
fScrBufSize(1000),
|
||||||
fReportX10MouseEvent(false),
|
fReportX10MouseEvent(false),
|
||||||
fReportNormalMouseEvent(false),
|
fReportNormalMouseEvent(false),
|
||||||
@@ -752,6 +755,33 @@ TermView::_DetachShell()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TermView::_Activate()
|
||||||
|
{
|
||||||
|
fActive = true;
|
||||||
|
|
||||||
|
if (fCursorBlinkRunner == NULL) {
|
||||||
|
BMessage blinkMessage(kBlinkCursor);
|
||||||
|
fCursorBlinkRunner = new (std::nothrow) BMessageRunner(
|
||||||
|
BMessenger(this), &blinkMessage, kCursorBlinkInterval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TermView::_Deactivate()
|
||||||
|
{
|
||||||
|
// DoIMConfirm();
|
||||||
|
// make sure the cursor becomes visible
|
||||||
|
fCursorState = 0;
|
||||||
|
_InvalidateTextRect(fCursor.x, fCursor.y, fCursor.x, fCursor.y);
|
||||||
|
delete fCursorBlinkRunner;
|
||||||
|
fCursorBlinkRunner = NULL;
|
||||||
|
|
||||||
|
fActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Draw part of a line in the given view.
|
//! Draw part of a line in the given view.
|
||||||
void
|
void
|
||||||
TermView::_DrawLinePart(int32 x1, int32 y1, uint16 attr, char *buf,
|
TermView::_DrawLinePart(int32 x1, int32 y1, uint16 attr, char *buf,
|
||||||
@@ -1111,21 +1141,27 @@ void
|
|||||||
TermView::WindowActivated(bool active)
|
TermView::WindowActivated(bool active)
|
||||||
{
|
{
|
||||||
BView::WindowActivated(active);
|
BView::WindowActivated(active);
|
||||||
if (active) {
|
if (active && IsFocus()) {
|
||||||
// start cursor blinking
|
if (!fActive)
|
||||||
if (fCursorBlinkRunner == NULL) {
|
_Activate();
|
||||||
BMessage blinkMessage(kBlinkCursor);
|
|
||||||
fCursorBlinkRunner = new (std::nothrow) BMessageRunner(
|
|
||||||
BMessenger(this), &blinkMessage, kCursorBlinkInterval);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// DoIMConfirm();
|
if (fActive)
|
||||||
|
_Deactivate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// make sure the cursor becomes visible
|
|
||||||
fCursorState = 0;
|
void
|
||||||
_InvalidateTextRect(fCursor.x, fCursor.y, fCursor.x, fCursor.y);
|
TermView::MakeFocus(bool focusState)
|
||||||
delete fCursorBlinkRunner;
|
{
|
||||||
fCursorBlinkRunner = NULL;
|
BView::MakeFocus(focusState);
|
||||||
|
|
||||||
|
if (focusState && Window() && Window()->IsActive()) {
|
||||||
|
if (!fActive)
|
||||||
|
_Activate();
|
||||||
|
} else {
|
||||||
|
if (fActive)
|
||||||
|
_Deactivate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ protected:
|
|||||||
virtual void DetachedFromWindow();
|
virtual void DetachedFromWindow();
|
||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
virtual void WindowActivated(bool active);
|
virtual void WindowActivated(bool active);
|
||||||
|
virtual void MakeFocus(bool focusState = true);
|
||||||
virtual void KeyDown(const char* bytes, int32 numBytes);
|
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||||
|
|
||||||
virtual void MouseDown(BPoint where);
|
virtual void MouseDown(BPoint where);
|
||||||
@@ -122,6 +123,9 @@ private:
|
|||||||
status_t _AttachShell(Shell* shell);
|
status_t _AttachShell(Shell* shell);
|
||||||
void _DetachShell();
|
void _DetachShell();
|
||||||
|
|
||||||
|
void _Activate();
|
||||||
|
void _Deactivate();
|
||||||
|
|
||||||
void _AboutRequested();
|
void _AboutRequested();
|
||||||
|
|
||||||
void _DrawLinePart(int32 x1, int32 y1, uint16 attr,
|
void _DrawLinePart(int32 x1, int32 y1, uint16 attr,
|
||||||
@@ -217,7 +221,7 @@ private:
|
|||||||
int fRows;
|
int fRows;
|
||||||
|
|
||||||
int fEncoding;
|
int fEncoding;
|
||||||
|
bool fActive;
|
||||||
// Object pointer.
|
// Object pointer.
|
||||||
TerminalBuffer* fTextBuffer;
|
TerminalBuffer* fTextBuffer;
|
||||||
BasicTerminalBuffer* fVisibleTextBuffer;
|
BasicTerminalBuffer* fVisibleTextBuffer;
|
||||||
|
|||||||
Reference in New Issue
Block a user