Lines 146-151
public:
Link Here
|
146 |
|
146 |
|
147 |
KHTMLViewPrivate() |
147 |
KHTMLViewPrivate() |
148 |
: underMouse( 0 ), underMouseNonShared( 0 ) |
148 |
: underMouse( 0 ), underMouseNonShared( 0 ) |
|
|
149 |
#ifndef NO_SMOOTH_SCROLL_HACK |
150 |
, dx(0), dy(0), ddx(0), ddy(0), rdx(0), rdy(0), scrolling(false) |
151 |
#endif |
149 |
{ |
152 |
{ |
150 |
#ifndef KHTML_NO_CARET |
153 |
#ifndef KHTML_NO_CARET |
151 |
m_caretViewContext = 0; |
154 |
m_caretViewContext = 0; |
Lines 381-386
public:
Link Here
|
381 |
int m_mouseScroll_byY : 4; |
384 |
int m_mouseScroll_byY : 4; |
382 |
QTimer *m_mouseScrollTimer; |
385 |
QTimer *m_mouseScrollTimer; |
383 |
QWidget *m_mouseScrollIndicator; |
386 |
QWidget *m_mouseScrollIndicator; |
|
|
387 |
#ifndef NO_SMOOTH_SCROLL_HACK |
388 |
QTimer timer2; |
389 |
int dx; |
390 |
int dy; |
391 |
// Step size * 16 and residual to avoid huge difference between 1px/step and 2px/step |
392 |
int ddx; |
393 |
int ddy; |
394 |
int rdx; |
395 |
int rdy; |
396 |
bool scrolling; |
397 |
#endif |
384 |
}; |
398 |
}; |
385 |
|
399 |
|
386 |
#ifndef QT_NO_TOOLTIP |
400 |
#ifndef QT_NO_TOOLTIP |
Lines 489-494
KHTMLView::KHTMLView( KHTMLPart *part, Q
Link Here
|
489 |
init(); |
503 |
init(); |
490 |
|
504 |
|
491 |
viewport()->show(); |
505 |
viewport()->show(); |
|
|
506 |
#ifndef NO_SMOOTH_SCROLL_HACK |
507 |
#define timer timer2 |
508 |
connect(&d->timer, SIGNAL(timeout()), this, SLOT(scrollTick())); |
509 |
#undef timer |
510 |
#endif |
492 |
} |
511 |
} |
493 |
|
512 |
|
494 |
KHTMLView::~KHTMLView() |
513 |
KHTMLView::~KHTMLView() |
Lines 1657-1664
void KHTMLView::keyReleaseEvent(QKeyEven
Link Here
|
1657 |
d->scrollSuspendPreActivate = false; |
1676 |
d->scrollSuspendPreActivate = false; |
1658 |
if( _ke->key() == Key_Shift && d->scrollSuspendPreActivate && _ke->state() == Qt::ShiftButton |
1677 |
if( _ke->key() == Key_Shift && d->scrollSuspendPreActivate && _ke->state() == Qt::ShiftButton |
1659 |
&& !(KApplication::keyboardMouseState() & Qt::ShiftButton)) |
1678 |
&& !(KApplication::keyboardMouseState() & Qt::ShiftButton)) |
|
|
1679 |
{ |
1660 |
if (d->scrollTimerId) |
1680 |
if (d->scrollTimerId) |
1661 |
d->scrollSuspended = !d->scrollSuspended; |
1681 |
{ |
|
|
1682 |
d->scrollSuspended = !d->scrollSuspended; |
1683 |
#ifndef NO_SMOOTH_SCROLL_HACK |
1684 |
if( d->scrollSuspended ) |
1685 |
stopScrolling(); |
1686 |
#endif |
1687 |
} |
1688 |
} |
1662 |
|
1689 |
|
1663 |
// Send keyup event |
1690 |
// Send keyup event |
1664 |
if ( dispatchKeyEvent( _ke ) ) |
1691 |
if ( dispatchKeyEvent( _ke ) ) |
Lines 2797-2803
void KHTMLView::viewportWheelEvent(QWhee
Link Here
|
2797 |
else |
2824 |
else |
2798 |
{ |
2825 |
{ |
2799 |
d->scrollBarMoved = true; |
2826 |
d->scrollBarMoved = true; |
|
|
2827 |
#ifndef NO_SMOOTH_SCROLL_HACK |
2828 |
scrollViewWheelEvent( e ); |
2829 |
#else |
2800 |
QScrollView::viewportWheelEvent( e ); |
2830 |
QScrollView::viewportWheelEvent( e ); |
|
|
2831 |
#endif |
2801 |
|
2832 |
|
2802 |
QMouseEvent *tempEvent = new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1), QPoint(-1,-1), Qt::NoButton, e->state() ); |
2833 |
QMouseEvent *tempEvent = new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1), QPoint(-1,-1), Qt::NoButton, e->state() ); |
2803 |
emit viewportMouseMoveEvent ( tempEvent ); |
2834 |
emit viewportMouseMoveEvent ( tempEvent ); |
Lines 3986-3989
void KHTMLView::moveCaretToLineEnd()
Link Here
|
3986 |
|
4017 |
|
3987 |
#endif // KHTML_NO_CARET |
4018 |
#endif // KHTML_NO_CARET |
3988 |
|
4019 |
|
|
|
4020 |
#ifndef NO_SMOOTH_SCROLL_HACK |
4021 |
#define timer timer2 |
4022 |
|
4023 |
// All scrolls must be completed within 240ms of last keypress |
4024 |
static const int SCROLL_TIME = 240; |
4025 |
// Each step is 20 ms == 50 frames/second |
4026 |
static const int SCROLL_TICK = 20; |
4027 |
|
4028 |
void KHTMLView::scrollBy(int dx, int dy) |
4029 |
{ |
4030 |
KConfigGroup cfg( KGlobal::config(), "KDE" ); |
4031 |
if( !cfg.readBoolEntry( "SmoothScrolling", true )) { |
4032 |
QScrollView::scrollBy( dx, dy ); |
4033 |
return; |
4034 |
} |
4035 |
// scrolling destination |
4036 |
int full_dx = d->dx + dx; |
4037 |
int full_dy = d->dy + dy; |
4038 |
|
4039 |
// scrolling speed |
4040 |
int ddx = 0; |
4041 |
int ddy = 0; |
4042 |
|
4043 |
int steps = SCROLL_TIME/SCROLL_TICK; |
4044 |
|
4045 |
ddx = (full_dx*16)/steps; |
4046 |
ddy = (full_dy*16)/steps; |
4047 |
|
4048 |
// don't go under 1px/step |
4049 |
if (ddx > 0 && ddx < 16) ddx = 16; |
4050 |
if (ddy > 0 && ddy < 16) ddy = 16; |
4051 |
if (ddx < 0 && ddx > -16) ddx = -16; |
4052 |
if (ddy < 0 && ddy > -16) ddy = -16; |
4053 |
|
4054 |
d->dx = full_dx; |
4055 |
d->dy = full_dy; |
4056 |
d->ddx = ddx; |
4057 |
d->ddy = ddy; |
4058 |
|
4059 |
if (!d->scrolling) { |
4060 |
scrollTick(); |
4061 |
startScrolling(); |
4062 |
} |
4063 |
} |
4064 |
|
4065 |
void KHTMLView::scrollTick() { |
4066 |
if (d->dx == 0 && d->dy == 0) { |
4067 |
stopScrolling(); |
4068 |
return; |
4069 |
} |
4070 |
|
4071 |
int tddx = d->ddx + d->rdx; |
4072 |
int tddy = d->ddy + d->rdy; |
4073 |
|
4074 |
int ddx = tddx / 16; |
4075 |
int ddy = tddy / 16; |
4076 |
d->rdx = tddx % 16; |
4077 |
d->rdy = tddy % 16; |
4078 |
|
4079 |
if (d->dx > 0 && ddx > d->dx) ddx = d->dx; |
4080 |
else |
4081 |
if (d->dx < 0 && ddx < d->dx) ddx = d->dx; |
4082 |
|
4083 |
if (d->dy > 0 && ddy > d->dy) ddy = d->dy; |
4084 |
else |
4085 |
if (d->dy < 0 && ddy < d->dy) ddy = d->dy; |
4086 |
|
4087 |
d->dx -= ddx; |
4088 |
d->dy -= ddy; |
4089 |
|
4090 |
// QScrollView::setContentsPos( contentsX() + ddx, contentsY() + ddy); |
4091 |
QScrollView::scrollBy(ddx, ddy); |
4092 |
} |
4093 |
|
4094 |
void KHTMLView::startScrolling() |
4095 |
{ |
4096 |
d->scrolling = true; |
4097 |
d->timer.start(SCROLL_TICK, false); |
4098 |
} |
4099 |
|
4100 |
void KHTMLView::stopScrolling() |
4101 |
{ |
4102 |
d->timer.stop(); |
4103 |
d->dx = d->dy = 0; |
4104 |
d->scrolling = false; |
4105 |
} |
4106 |
|
4107 |
// Overloaded from QScrollView and QScrollBar |
4108 |
void KHTMLView::scrollViewWheelEvent( QWheelEvent *e ) |
4109 |
{ |
4110 |
int pageStep = verticalScrollBar()->pageStep(); |
4111 |
int lineStep = verticalScrollBar()->lineStep(); |
4112 |
int step = QMIN( QApplication::wheelScrollLines()*lineStep, pageStep ); |
4113 |
if ( ( e->state() & ControlButton ) || ( e->state() & ShiftButton ) ) |
4114 |
step = pageStep; |
4115 |
|
4116 |
int dy = (e->delta()*step)/120; |
4117 |
scrollBy(0,-dy); |
4118 |
e->accept(); |
4119 |
} |
4120 |
|
4121 |
#undef timer |
4122 |
|
4123 |
#endif // NO_SMOOTH_SCROLL_HACK |
4124 |
|
3989 |
#undef DEBUG_CARETMODE |
4125 |
#undef DEBUG_CARETMODE |