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 relative mouse motion for most cases. #97

Merged
merged 2 commits into from
Sep 27, 2023
Merged
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
9 changes: 7 additions & 2 deletions src/selkies_gstreamer/webrtc_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import Xlib
from Xlib import display
from Xlib.ext import xfixes
from Xlib.ext import xfixes, xtest
import asyncio
import base64
import pynput
Expand Down Expand Up @@ -269,7 +270,11 @@ def send_mouse(self, action, data):
self.__mouse_emit(uinput.REL_X, x, syn=False)
self.__mouse_emit(uinput.REL_Y, y)
else:
self.mouse.move(x, y)
# NOTE: the pynput mouse.move method moves the mouse relative to the current position using its internal tracked position.
# this does not work for relative motion where the input should just be a delta value.
# instead, send the X fake input directly.
xtest.fake_input(self.xdisplay, Xlib.X.MotionNotify, detail=True, root=Xlib.X.NONE, x=x, y=y)
self.xdisplay.sync()
elif action == MOUSE_SCROLL_UP:
# Scroll up
if self.uinput_mouse_socket_path:
Expand Down