auto-hide cursor

svn path=/trunk/kdebase/konsole/; revision=56260
wilder-portage
Carsten Pfeiffer 26 years ago
parent 3b16bf65b3
commit b2cc15d739
  1. 13
      include/TEWidget.h
  2. 2
      include/konsole.h
  3. 30
      src/TEWidget.C

@ -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

@ -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;

@ -60,6 +60,7 @@
#include "TEWidget.moc"
#include <kapp.h>
#include <kcursor.h>
#include <kurl.h>
#include <kdebug.h>
#include <klocale.h>
@ -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 )
{

Loading…
Cancel
Save