Skip to content

Commit 5981c8e

Browse files
almarkleinKorijn
andauthored
Glfw mouse position fix (#241)
* Fix mouse position for macos on glfw * new black * pyinstaller needs jaraco, it seems * undo add jaraco * print pyinstaller version * give latest pyinstaller a try * is the ~xfail? * Update test_wgpu.py * discard ci xfail again * try pyinstaller workaround * arg wrong url * revert pyinstaller hack Co-authored-by: Korijn van Golen <[email protected]>
1 parent 904c9d0 commit 5981c8e

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ jobs:
117117
- name: Test PyInstaller
118118
if: matrix.PYINSTALLER == 1
119119
run: |
120-
pip install psutil pyinstaller>=4
120+
pip install psutil pyinstaller>=4.9
121+
pyinstaller --version
121122
pytest -v wgpu/__pyinstaller
122123
123124
# The release builds are done for the platforms that we want to build wheels for.

download-wgpu-native.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def get_os_string():
7777

7878
def get_arch():
7979
# See e.g.: https://stackoverflow.com/questions/45124888
80-
is_64_bit = sys.maxsize > 2 ** 32
80+
is_64_bit = sys.maxsize > 2**32
8181
machine = platform.machine()
8282

8383
# See if this is run by cibuildwheel and check to see if ARCHFLAGS is

wgpu/backends/rs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def feature_flag_to_feature_names(flag):
174174
feature_names = {} # import this from mappings?
175175
features = []
176176
for i in range(32):
177-
val = int(2 ** i)
177+
val = int(2**i)
178178
if flag & val:
179179
features.append(feature_names.get(val, val))
180180
return tuple(sorted(features))

wgpu/gui/glfw.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ def __init__(self, *, size=None, title=None, **kwargs):
177177

178178
# Initialize the size
179179
self._pixel_ratio = -1
180+
self._screen_size_is_logical = False
180181
self.set_logical_size(*size)
181182
self._request_draw()
182183

@@ -259,6 +260,7 @@ def _set_logical_size(self, new_logical_size):
259260
int(new_logical_size[0] * pixel_ratio * screen_ratio),
260261
int(new_logical_size[1] * pixel_ratio * screen_ratio),
261262
)
263+
self._screen_size_is_logical = screen_ratio != 1
262264
# If this causes the widget size to change, then _on_size_change will
263265
# be called, but we may want force redetermining the size.
264266
if pixel_ratio != self._pixel_ratio:
@@ -415,7 +417,10 @@ def _follow_double_click(self, action, button):
415417

416418
def _on_cursor_pos(self, window, x, y):
417419
# Store pointer position in logical coordinates
418-
self._pointer_pos = x / self._pixel_ratio, y / self._pixel_ratio
420+
if self._screen_size_is_logical:
421+
self._pointer_pos = x, y
422+
else:
423+
self._pointer_pos = x / self._pixel_ratio, y / self._pixel_ratio
419424

420425
ev = {
421426
"event_type": "pointer_move",

0 commit comments

Comments
 (0)