Skip to content

Commit

Permalink
Fix relative mouse motion for most cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
danisla committed Sep 23, 2023
1 parent a26d5a8 commit 08eb740
Showing 1 changed file with 7 additions and 2 deletions.
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 it's 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

0 comments on commit 08eb740

Please sign in to comment.