question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Window.mouse_pos incorrect on 4k/retina displays

See original GitHub issue

The default Kivy window size is 800x600. However, when running on a high rez display (4k display, MacBookPro Retina Display), the default window size ends up 1600x1200. Fair enough. But, when querying Window.mouse_pos, the returned value appears as if the window size were 800x600.

For example, this:

   def on_touch_down(self, touch):
      print touch.pos
      print Window.mouse_pos, '\n'

will print out:

(1438.0, 1068.0)
(719.0, 534.0) 

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
hackalogcommented, Oct 7, 2017

This was likely fixed as part of #4403

Just tested on ios with

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.label import Label
from kivy.core.window import Window

class TestLabel(Label):
    def on_touch_down(self, touch):
        self.touch_pos = touch.pos
        self.mouse_pos = Window.mouse_pos

kv = Builder.load_string("""
TestLabel:
    touch_pos: 0,0
    mouse_pos: 0,0
    text: '{} vs {}'.format(self.touch_pos, self.mouse_pos)
""")

class MousePosApp(App):
    def build(self):
        return kv

MousePosApp().run()

and it appears to work as expected

0reactions
eranegozycommented, Oct 7, 2017

I can also confirm that this has been fixed. Thanks

-Eran (iPhone)

On Oct 7, 2017, at 2:26 PM, Peter Badida notifications@github.com wrote:

I’ll look into adding a unittest later. (Note to myself:) It might be enough to just run Kivy with density env var and compare the values, something like this:

os.environ[<density var>] = <value> # setUp (maybe class one) <touch down> self.assertEqual(touch.pos, <calculated pos from 3925930 or more up-to-date change>) os.environ.pop(<density var>) # tearDown — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mouse position wrongly processed on high-dpi screens? #4377
Hi, we experience a strange issue where the mouse pos seems to be wrongly ... Window.mouse_pos incorrect on 4k/retina displays #3960.
Read more >
Mouse problems with display port 1.2 in M… - Apple Community
With macOS Sierra, there is strange thing with 4K display connected via DisplayPort in DP 1.2 MST mode (required for 60Hz refresh rate)....
Read more >
Cursor position is wrong on mixed multi-monitor (retina with ...
Setup Multi-monitor system on Windows 10 or OSX with one "retina" display (on ... On Windows, the cursor is rendered at the wrong...
Read more >
Let's fix this monitor positioning issue after many ... - Reddit
Sometimes the window is too large for 1080p and it will never resize to correct dpi because part of it is still on...
Read more >
Issues with Anim Picker on Retina/High DPI Monitors - Bug
I don't have a 4k monitor to test here, but it's very possible this issue also occurs on retina monitors with windows as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found