Skip to content

Commit a418ede

Browse files
jigpuPinglinux
authored andcommittedAug 8, 2024
Swap the relwheel actions triggered and defaults for vertical scrolling
Relative wheel actions are backwards from how the user thinks about them. If you want to get/set the action that occurs when scrolling up, you currently need to work with the REL_WHEEL_DOWN action. This is difficult to explain to users and is also makes the code more difficult to follow. This commit changes the behavior so that programming the REL_WHEEL_UP action actually affects what happens when you physically scroll the wheel up. The behavior is now: physical scroll wheel up -> positive delta from kernel -> REL_WHEEL_UP action -> X11 mouse button 4 -> window scrolls up. Note that this commit will break any xsetwacom scripts that users may have which change the relative wheel actions from their defaults. It would also affect control panels that rely on xsetwacom or configuring the driver directly. We don't expect this to cause significant problems in reality since Wacom has not produced tools with relative wheels in many years and so there are few scripts/control panels to break. Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
1 parent a91168c commit a418ede

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed
 

‎src/wcmCommon.c

+9-8
Original file line numberDiff line numberDiff line change
@@ -513,17 +513,17 @@ static int getScrollDelta(int current, int old, int wrap, int flags)
513513
* the scrolling axis and the possible events that can be
514514
* sent.
515515
*
516-
* @param delta Amount of change in the scrolling axis
517-
* @param action_up Array index of action to send on scroll up
518-
* @param action_dn Array index of action to send on scroll down
519-
* @return Array index of action that should be performed, or -1 if none.
516+
* @param delta Amount of change in the scrolling axis
517+
* @param action_positive Array index of action to send on a positive delta
518+
* @param action_negative Array index of action to send on negative delta
519+
* @return Array index of action that should be performed, or -1 if none.
520520
*/
521-
static int getWheelButton(int delta, int action_up, int action_dn)
521+
static int getWheelButton(int delta, int action_positive, int action_negative)
522522
{
523523
if (delta > 0)
524-
return action_up;
524+
return action_positive;
525525
else if (delta < 0)
526-
return action_dn;
526+
return action_negative;
527527
else
528528
return -1;
529529
}
@@ -571,7 +571,8 @@ static void sendWheelStripEvents(WacomDevicePtr priv, const WacomDeviceState* ds
571571
sendWheelStripEvent(priv, &priv->strip_actions[idx], ds, axes);
572572
}
573573

574-
/* emulate events for relative wheel */
574+
/* emulate events for relative wheel:
575+
* positive delta = scroll up */
575576
delta = getScrollDelta(ds->relwheel, 0, 0, 0);
576577
idx = getWheelButton(delta, WHEEL_REL_UP, WHEEL_REL_DN);
577578
if (idx >= 0 && (IsCursor(priv) || IsPad(priv)) && priv->oldState.proximity == ds->proximity)

‎src/wcmConfig.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ WacomDevicePtr wcmAllocate(void *frontend, const char *name)
7070
priv->button_default[i] = (i < 3) ? i + 1 : i + 5;
7171

7272
priv->nbuttons = WCM_MAX_BUTTONS; /* Default number of buttons */
73-
priv->wheel_default[WHEEL_REL_UP] = 5;
74-
priv->wheel_default[WHEEL_REL_DN] = 4;
73+
priv->wheel_default[WHEEL_REL_UP] = 4; /* scroll up */
74+
priv->wheel_default[WHEEL_REL_DN] = 5; /* scroll down */
7575
/* wheel events are set to 0, but the pad overwrites this default
7676
* later in wcmParseOptions, when we have IsPad() available */
7777
priv->wheel_default[WHEEL_ABS_UP] = 0;

‎src/wcmUSB.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1935,7 +1935,7 @@ static void usbDispatchEvents(WacomDevicePtr priv)
19351935
{
19361936
switch (event->code) {
19371937
case REL_WHEEL:
1938-
ds->relwheel = -event->value;
1938+
ds->relwheel = event->value;
19391939
ds->time = wcmTimeInMillis();
19401940
common->wcmChannel[channel].dirty |= TRUE;
19411941
break;

0 commit comments

Comments
 (0)