[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: PATCH: mouse acceleration improvements
From: Daniel Naber <daniel.naber () t-online ! de>
Date: 2003-05-17 14:28:59
[Download RAW message or body]
Hi,
can someone check this patch? It implements wishes 27698: "fractional mouse
acceleration values" and 31189: "Mouse acceleration with threshold 0 not
possible". It works for me, but I'm mot sure if int() and round() are used
correctly.
Also some help text is deleted, as I think "You can set the value by
dragging the slider" doesn't really belong there.
Regards
Daniel
--
http://www.danielnaber.de
["mouse.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 14:19:11 -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.
@@ -366,10 +361,15 @@
int MouseConfig::getAccel()
{
- return accel->value();
+ return int(accel->value());
}
-void MouseConfig::setAccel(int val)
+int MouseConfig::getAccelDenominator()
+{
+ return int(round((accel->value()-int(accel->value()))*10));
+}
+
+void MouseConfig::setAccel(double val)
{
accel->setValue(val);
}
@@ -414,7 +414,7 @@
tab1->rightHanded->setEnabled(settings->handedEnabled);
tab1->leftHanded->setEnabled(settings->handedEnabled);
- setAccel(settings->accelRate);
+ setAccel(settings->accelRate+float(settings->accelRateDen)/10);
setThreshold(settings->thresholdMove);
setHandedness(settings->handed);
@@ -454,6 +454,7 @@
void MouseConfig::save()
{
settings->accelRate = getAccel();
+ settings->accelRateDen = getAccelDenominator();
settings->thresholdMove = getThreshold();
settings->handed = getHandedness();
@@ -615,7 +616,9 @@
int accel_num, accel_den, threshold;
XGetPointerControl( kapp->getDisplay(),
&accel_num, &accel_den, &threshold );
+ int tmp = int((float(accel_num)/float(accel_den) - accel_num/accel_den) * 10);
accel_num /= accel_den; // integer acceleration only
+ accel_den = tmp;
// get settings from X server
int h = RIGHT_HANDED;
@@ -666,6 +669,12 @@
else
accelRate = a;
+ int a_den = config->readNumEntry("AccelerationDen",-1);
+ if (a_den == -1)
+ accelRateDen = accel_den;
+ else
+ accelRateDen = a_den;
+
int t = config->readNumEntry("Threshold",-1);
if (t == -1)
thresholdMove = threshold;
@@ -699,8 +708,7 @@
void MouseSettings::apply()
{
XChangePointerControl( kapp->getDisplay(),
- true, true, accelRate, 1, thresholdMove);
-
+ true, true, accelRate*10+accelRateDen, 10, thresholdMove);
unsigned char map[5];
int remap=1;
@@ -772,6 +780,7 @@
{
config->setGroup("Mouse");
config->writeEntry("Acceleration",accelRate);
+ config->writeEntry("AccelerationDen",accelRateDen);
config->writeEntry("Threshold",thresholdMove);
if (handed == RIGHT_HANDED)
config->writeEntry("MouseButtonMapping",QString("RightHanded"));
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 14:19:11 -0000
@@ -66,6 +66,7 @@
bool m_handedNeedsApply;
int handed;
int accelRate;
+ int accelRateDen;
int thresholdMove;
int doubleClickInterval;
int dragStartTime;
@@ -103,16 +104,17 @@
private:
int getAccel();
+ int getAccelDenominator();
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