From b2cc15d7399e10a046bc0997a6f2ef89d5da9330 Mon Sep 17 00:00:00 2001 From: Carsten Pfeiffer Date: Wed, 12 Jul 2000 02:31:53 +0000 Subject: [PATCH] auto-hide cursor svn path=/trunk/kdebase/konsole/; revision=56260 --- include/TEWidget.h | 13 ++++++++----- include/konsole.h | 2 ++ src/TEWidget.C | 30 ++++++++++++++++++++++++++++-- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/include/TEWidget.h b/include/TEWidget.h index 543bd739..9314fcdd 100644 --- a/include/TEWidget.h +++ b/include/TEWidget.h @@ -41,7 +41,7 @@ public: const ColorEntry* getColorTable() const; void setColorTable(const ColorEntry table[]); - + void setScrollbarLocation(int loc); enum { SCRNONE=0, SCRLEFT=1, SCRRIGHT=2 }; @@ -51,7 +51,7 @@ public: void emitSelection(); public: - + void setImage(const ca* const newimg, int lines, int columns); int Lines() { return lines; } @@ -60,7 +60,7 @@ public: void calcGeometry(); void propagateSize(); QSize calcSize(int cols, int lins) const; - + QSize sizeHint() const; public: @@ -87,7 +87,7 @@ protected: bool eventFilter( QObject *, QEvent * ); - void drawAttrStr(QPainter &paint, QRect rect, + void drawAttrStr(QPainter &paint, QRect rect, QString& str, ca attr, BOOL pm, BOOL clear); void paintEvent( QPaintEvent * ); @@ -100,6 +100,9 @@ protected: void mousePressEvent( QMouseEvent* ); void mouseReleaseEvent( QMouseEvent* ); void mouseMoveEvent( QMouseEvent* ); + + void focusInEvent( QFocusEvent * ); + void focusOutEvent( QFocusEvent * ); // Dnd void dragEnterEvent(QDragEnterEvent* event); void dropEvent(QDropEvent* event); @@ -127,7 +130,7 @@ protected slots: void blinkEvent(); private: - + QChar (*fontMap)(QChar); // possible vt100 font extention bool fixed_font; // has fixed pitch diff --git a/include/konsole.h b/include/konsole.h index 68748d3b..161d0fd6 100644 --- a/include/konsole.h +++ b/include/konsole.h @@ -38,6 +38,7 @@ class QDragEnterEvent; class QDropEvent; +class KAccel; class KRootPixmap; class Konsole : public KTMainWindow @@ -131,6 +132,7 @@ private: KMenuBar* menubar; KStatusBar* statusbar; + KAccel* accel; QPopupMenu* m_file; QPopupMenu* m_sessions; diff --git a/src/TEWidget.C b/src/TEWidget.C index 92cfb1c5..0d6eb649 100644 --- a/src/TEWidget.C +++ b/src/TEWidget.C @@ -60,6 +60,7 @@ #include "TEWidget.moc" #include +#include #include #include #include @@ -270,6 +271,7 @@ TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) setColorTable(base_color_table); // init color table qApp->installEventFilter( this ); //FIXME: see below + KCursor::setAutoHideCursor( this, true ); // Init DnD //////////////////////////////////////////////////////////////// currentSession = NULL; @@ -279,6 +281,9 @@ TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) m_drop->insertItem( i18n("cd"), 1); connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); + // we need focus so that the auto-hide cursor feature works + setFocus(); + setFocusPolicy( WheelFocus ); } //FIXME: make proper destructor @@ -636,6 +641,10 @@ void TEWidget::mousePressEvent(QMouseEvent* ev) void TEWidget::mouseMoveEvent(QMouseEvent* ev) { + // for auto-hiding the cursor, we need mouseTracking + if (ev->state() == NoButton ) + return; + if (actSel == 0) return; if (ev->state() & MidButton) return; // don't extend selection while pasting @@ -726,7 +735,7 @@ void TEWidget::mouseMoveEvent(QMouseEvent* ev) void TEWidget::mouseReleaseEvent(QMouseEvent* ev) { -// printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); + // printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); if ( ev->button() == LeftButton) { if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); @@ -797,6 +806,18 @@ void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) } } +void TEWidget::focusInEvent( QFocusEvent * ) +{ + // do nothing, to prevent repainting +} + + +void TEWidget::focusOutEvent( QFocusEvent *e ) +{ + // do nothing, to prevent repainting +} + + int TEWidget::charClass(char ch) const { // This might seem like overkill, but imagine if ch was a Unicode @@ -873,6 +894,11 @@ void TEWidget::onClearSelection() // which would also let you have an in-focus cursor and an out-focus // cursor like xterm does. +// for the auto-hide cursor feature, I added empty focusInEvent() and +// focusOutEvent() so that update() isn't called. +// For auto-hide, we need to get keypress-events, but we only get them when +// we have focus. + void TEWidget::doScroll(int lines) { scrollbar->setValue(scrollbar->value()+lines); @@ -894,7 +920,7 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e ) // know where the current selection is. emit keyPressedSignal(ke); // expose - return TRUE; // accept event + return false; // accept event } if ( e->type() == QEvent::Enter ) {