[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: PATCH: mouse acceleration improvements
From: Daniel Naber <daniel.naber () t-online ! de>
Date: 2003-05-17 18:18:51
[Download RAW message or body]
On Saturday 17 May 2003 17:25, Dirk Mueller wrote:
> I would just fix the one line that passes the value to XChangePointer to
> generate a denomiator like "fract(double_accel * 10) % 10", and you're
> done.
Sorry, I don't understand what you mean here, there doesn't seem to be
something like fract()? Anyway, here's an improved version that saves a
double now, which makes things simpler.
Regards
Daniel
--
http://www.danielnaber.de
["mouse_v2.diff" (text/x-diff)]
Index: mouse.cpp
===================================================================
RCS file: /home/kde/kdebase/kcontrol/input/mouse.cpp,v
retrieving revision 1.81
diff -u -r1.81 mouse.cpp
--- mouse.cpp 12 May 2003 14:38:36 -0000 1.81
+++ mouse.cpp 17 May 2003 18:09:50 -0000
@@ -48,6 +48,7 @@
#include <unistd.h>
#include <sys/stat.h>
#include <stdlib.h>
+#include <math.h>
#include <qfileinfo.h>
#include <qlayout.h>
@@ -173,13 +174,13 @@
QBoxLayout *lay = new QVBoxLayout(tab2, KDialog::marginHint(),
KDialog::spacingHint());
- accel = new KIntNumInput(20, tab2);
+ accel = new KDoubleNumInput(2, tab2);
accel->setLabel(i18n("Pointer acceleration:"));
- accel->setRange(1,20,2);
+ accel->setPrecision(1);
+ accel->setRange(1,20);
accel->setSuffix("x");
- accel->setSteps(1,1);
lay->addWidget(accel);
- connect(accel, SIGNAL(valueChanged(int)), this, SLOT(changed()));
+ connect(accel, SIGNAL(valueChanged(double)), this, SLOT(changed()));
wtstr = i18n("This option allows you to change the relationship"
" between the distance that the mouse pointer moves on the"
@@ -190,15 +191,12 @@
" movements of the mouse pointer on the screen even when"
" you only make a small movement with the physical device."
" Selecting very high values may result in the mouse pointer"
- " flying across the screen, making it hard to control!<p>"
- " You can set the acceleration value by dragging the slider"
- " button or by clicking the up/down arrows on the spin-button"
- " to the left of the slider.");
+ " flying across the screen, making it hard to control!");
QWhatsThis::add( accel, wtstr );
thresh = new KIntNumInput(accel, 20, tab2);
thresh->setLabel(i18n("Pointer threshold:"));
- thresh->setRange(1,20,2);
+ thresh->setRange(0,20,2);
thresh->setSuffix(i18n(" pixels"));
thresh->setSteps(1,1);
lay->addWidget(thresh);
@@ -212,10 +210,7 @@
" there is no acceleration at all, giving you a greater degree"
" of control over the mouse pointer. With larger movements of"
" the physical device, you can move the mouse pointer"
- " rapidly to different areas on the screen.<p>"
- " You can set the threshold value by dragging the slider button"
- " or by clicking the up/down arrows on the spin-button to the"
- " left of the slider.");
+ " rapidly to different areas on the screen.");
QWhatsThis::add( thresh, wtstr );
// It would be nice if the user had a test field.
@@ -364,12 +359,12 @@
delete settings;
}
-int MouseConfig::getAccel()
+double MouseConfig::getAccel()
{
return accel->value();
}
-void MouseConfig::setAccel(int val)
+void MouseConfig::setAccel(double val)
{
accel->setValue(val);
}
@@ -613,9 +608,10 @@
void MouseSettings::load(KConfig *config)
{
int accel_num, accel_den, threshold;
+ double accel;
XGetPointerControl( kapp->getDisplay(),
&accel_num, &accel_den, &threshold );
- accel_num /= accel_den; // integer acceleration only
+ accel = float(accel_num) / float(accel_den);
// get settings from X server
int h = RIGHT_HANDED;
@@ -660,9 +656,9 @@
}
config->setGroup("Mouse");
- int a = config->readNumEntry("Acceleration",-1);
+ double a = config->readDoubleNumEntry("Acceleration",-1);
if (a == -1)
- accelRate = accel_num;
+ accelRate = accel;
else
accelRate = a;
@@ -699,7 +695,7 @@
void MouseSettings::apply()
{
XChangePointerControl( kapp->getDisplay(),
- true, true, accelRate, 1, thresholdMove);
+ true, true, int(round(accelRate*10)), 10, thresholdMove);
unsigned char map[5];
Index: mouse.h
===================================================================
RCS file: /home/kde/kdebase/kcontrol/input/mouse.h,v
retrieving revision 1.30
diff -u -r1.30 mouse.h
--- mouse.h 12 May 2003 14:38:36 -0000 1.30
+++ mouse.h 17 May 2003 18:09:50 -0000
@@ -65,7 +65,7 @@
bool handedEnabled;
bool m_handedNeedsApply;
int handed;
- int accelRate;
+ double accelRate;
int thresholdMove;
int doubleClickInterval;
int dragStartTime;
@@ -102,17 +102,17 @@
private:
- int getAccel();
+ double getAccel();
int getThreshold();
int getHandedness();
- void setAccel(int);
+ void setAccel(double);
void setThreshold(int);
void setHandedness(int);
void fixCursorFile();
- KIntNumInput *accel;
+ KDoubleNumInput *accel;
KIntNumInput *thresh;
KIntNumInput *doubleClickInterval;
KIntNumInput *dragStartTime;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic