Viewing Issue Simple Details Jump to Notes ] Wiki ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0011020 [DCSS] Bug Report minor always 2017-04-18 08:41 2017-04-26 02:57
Reporter bed View Status public  
Assigned To advil
Priority normal Resolution done  
Status resolved   Product Branch 0.21 ancient branch
Summary 0011020: Game mouse cursor doesn't line up with OS mouse cursor
Description The game's mouse cursor appears to the top-left of the OS mouse cursor. I have reproduced the issue in Chrome 57, Firefox 49, and IE 11. The culprit seems to be init_canvas in util.js:

function init_canvas(element, w, h) {
        var ratio = window.devicePixelRatio;
        element.width = w;
        element.height = h; = (w / ratio) + 'px'; = (h / ratio) + 'px';

Scaling canvas elements with CSS causes pain and suffering. The element.width and element.height should be equal to the respective CSS sizes. Canvas dimensions do not need to be scaled by devicePixelRatio because they are already measured in CSS pixels, not physical pixels.

The cursor problem goes away if I remove the pixel scaling:

function init_canvas(element, w, h) {
        element.width = w;
        element.height = h; = w + 'px'; = h + 'px';

Of course, this then makes the display too large, at least in my browser, so I suppose the cell scaling also needs to change or something.
Additional Information
Tags No tags attached.
Attached Files png file icon chrome_2017-04-18_00-14-10.png [^] (367,815 bytes) 2017-04-18 08:41

- Relationships

-  Notes
advil (administrator)
2017-04-18 16:47

I can confirm this can happen on webtiles on firefox and chrome. However, it is probably the result of a bad interaction we have with browser zoom; you should be able to adjust the zoom using menu options (crawl may swallow the usual keystrokes) in your preferred browser to get the mouse tracking back; specifically try resetting the zoom level. In all browsers I have checked (ff, chrome, safari) mouse tracking is fine when zoom is at the reset level, and in safari it is fine no matter the zoom level; I don't have access to IE.

Which isn't to say that scaling canvas elements is good, or is unrelated, I'm just not sure it's the immediate bug.
bed (reporter)
2017-04-19 02:05

I just tried changing the zoom in Chrome and discovered that the mouse tracks properly at 80% zoom. This reminded that I have Windows 10 set for 125% DPI scaling. (It's easy to forget, since it looks normal on my high-DPI display.) Once I switched to 100% DPI scaling, the game worked properly at normal zoom. Is there a way to get browsers to play nicely with DPI scaling?
advil (administrator)
2017-04-19 02:13

oh, interesting, thanks for the followup. This behavior seems like a quirk of chrome, I found some ways to maybe disable that interaction if you want: [^]

Leaving this issue open since mouse behavior ideally shouldn't interact with any of this.
wheals (administrator)
2017-04-19 03:46

I seem to remember running into this issue when I first merged the Webtiles cursor code into modern trunk, on Firefox with normal zoom (but not having the problem on Chrome). It's been a long time, so I don't recall exactly.
advil (administrator)
2017-04-26 02:57

I believe this was fixed in [^] , and at this point it's been tested on firefox, safari, chrome, as well as on a retina display. Hopefully that should translate to other high DPI displays that impact devicePixelRatio. Feel free to reopen if it didn't work for yours.

(It's still scaling, so this doesn't really address the complaint about scaling, but as I understand it scaling was basically required in order to not have webtiles look bad on high DPI displays. There's some references in the commit message if you want to look over the reasoning.)

- Issue History
Date Modified Username Field Change
2017-04-18 08:41 bed New Issue
2017-04-18 08:41 bed File Added: chrome_2017-04-18_00-14-10.png
2017-04-18 15:51 neil Description Updated
2017-04-18 16:47 advil Note Added: 0031592
2017-04-18 16:47 advil Status new => confirmed
2017-04-19 02:05 bed Note Added: 0031593
2017-04-19 02:13 advil Note Added: 0031594
2017-04-19 03:46 wheals Note Added: 0031600
2017-04-26 02:57 advil Note Added: 0031617
2017-04-26 02:57 advil Status confirmed => resolved
2017-04-26 02:57 advil Fixed in Branch => 0.20 development branch
2017-04-26 02:57 advil Resolution open => done
2017-04-26 02:57 advil Assigned To => advil

Mantis 1.1.8[^]
Copyright © 2000 - 2009 Mantis Group
Powered by Mantis Bugtracker