RemoteGraphicsView.py : fix deprecated mouse positions

This commit is contained in:
KIU Shueng Chuan 2021-05-13 08:57:15 +08:00
parent 70c123a95c
commit 3b32e27083

View File

@ -100,7 +100,8 @@ class RemoteGraphicsView(QtGui.QWidget):
return args return args
def serialize_mouse_event(self, ev): def serialize_mouse_event(self, ev):
lpos, gpos = ev.localPos(), ev.screenPos() lpos = ev.position() if hasattr(ev, 'position') else ev.localPos()
gpos = ev.globalPosition() if hasattr(ev, 'globalPosition') else ev.screenPos()
typ, btn, btns, mods = self.serialize_mouse_enum( typ, btn, btns, mods = self.serialize_mouse_enum(
ev.type(), ev.button(), ev.buttons(), ev.modifiers()) ev.type(), ev.button(), ev.buttons(), ev.modifiers())
return (typ, lpos, gpos, btn, btns, mods) return (typ, lpos, gpos, btn, btns, mods)
@ -137,7 +138,11 @@ class RemoteGraphicsView(QtGui.QWidget):
return super().wheelEvent(ev) return super().wheelEvent(ev)
def enterEvent(self, ev): def enterEvent(self, ev):
lws = ev.localPos(), ev.windowPos(), ev.screenPos() lpos = ev.position() if hasattr(ev, 'position') else ev.localPos()
wpos = ev.scenePosition() if hasattr(ev, 'scenePosition') else ev.windowPos()
gpos = ev.globalPosition() if hasattr(ev, 'globalPosition') else ev.screenPos()
lws = lpos, wpos, gpos
self._view.enterEvent(lws, _callSync='off') self._view.enterEvent(lws, _callSync='off')
return super().enterEvent(ev) return super().enterEvent(ev)