Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tabs and separate scroll axis accumulated ticks #28

Merged
merged 1 commit into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 33 additions & 23 deletions libweston/backend-rdp/rdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1496,41 +1496,51 @@ rdp_notify_wheel_scroll(RdpPeerContext *peerContext, UINT16 flags, uint32_t axis
int ivalue;
double value;
struct timespec time;
int *accumWheelRotationPrecise;
int *accumWheelRotationDiscrete;

/*
* The RDP specs says the lower bits of flags contains the "the number of rotation
* units the mouse wheel was rotated".
*
* https://blogs.msdn.microsoft.com/oldnewthing/20130123-00/?p=5473 explains the 120 value
*/
* The RDP specs says the lower bits of flags contains the "the number of rotation
* units the mouse wheel was rotated".
*
* https://blogs.msdn.microsoft.com/oldnewthing/20130123-00/?p=5473 explains the 120 value
*/
if (flags & PTR_FLAGS_WHEEL_NEGATIVE)
ivalue = (int)((char)(flags & 0xff));
else
ivalue = (flags & 0xff);

/*
* Flip the scroll direction as the RDP direction is inverse of X/Wayland
* for vertical scroll
*/
if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
* Flip the scroll direction as the RDP direction is inverse of X/Wayland
* for vertical scroll
*/
if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) {
ivalue *= -1;

accumWheelRotationPrecise = &peerContext->verticalAccumWheelRotationPrecise;
accumWheelRotationDiscrete = &peerContext->verticalAccumWheelRotationDiscrete;
}
else {
accumWheelRotationPrecise = &peerContext->horizontalAccumWheelRotationPrecise;
accumWheelRotationDiscrete = &peerContext->horizontalAccumWheelRotationDiscrete;
}

/*
* Accumulate the wheel increments.
*
* Every 12 wheel increments, we will send an update to our Wayland
* clients with an updated value for the wheel for smooth scrolling.
*
* Every 120 wheel increments, we tick one discrete wheel click.
*/
peerContext->accumWheelRotationPrecise += ivalue;
peerContext->accumWheelRotationDiscrete += ivalue;
if (abs(peerContext->accumWheelRotationPrecise) >= 12) {
value = (double)(peerContext->accumWheelRotationPrecise / 12);
* Accumulate the wheel increments.
*
* Every 12 wheel increments, we will send an update to our Wayland
* clients with an updated value for the wheel for smooth scrolling.
*
* Every 120 wheel increments, we tick one discrete wheel click.
*/
*accumWheelRotationPrecise += ivalue;
*accumWheelRotationDiscrete += ivalue;
if (abs(*accumWheelRotationPrecise) >= 12) {
value = (double)(*accumWheelRotationPrecise / 12);

weston_event.axis = axis;
weston_event.value = value;
weston_event.discrete = peerContext->accumWheelRotationDiscrete / 120;
weston_event.discrete = *accumWheelRotationDiscrete / 120;
weston_event.has_discrete = true;

rdp_debug_verbose(b, "wheel: value:%f discrete:%d\n",
Expand All @@ -1540,8 +1550,8 @@ rdp_notify_wheel_scroll(RdpPeerContext *peerContext, UINT16 flags, uint32_t axis

notify_axis(peerContext->item.seat, &time, &weston_event);

peerContext->accumWheelRotationPrecise %= 12;
peerContext->accumWheelRotationDiscrete %= 120;
*accumWheelRotationPrecise %= 12;
*accumWheelRotationDiscrete %= 120;

return true;
}
Expand Down
6 changes: 4 additions & 2 deletions libweston/backend-rdp/rdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,10 @@ struct rdp_peer_context {

bool button_state[5];
char key_state[0xff/8]; // one bit per key.
int accumWheelRotationPrecise;
int accumWheelRotationDiscrete;
int verticalAccumWheelRotationPrecise;
int verticalAccumWheelRotationDiscrete;
int horizontalAccumWheelRotationPrecise;
int horizontalAccumWheelRotationDiscrete;

// RAIL support
HANDLE vcm;
Expand Down