diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-10-09 12:01:54 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-10-09 12:01:54 (GMT) |
commit | 52867011954887f3bde7579ee25de18530eaa817 (patch) | |
tree | 99989d9f237ac4d45ce8c0e9950215bcd54d0034 /unix/tkUnixEvent.c | |
parent | 5eafeee26a48a24edcf9f727ea55ccf0e22cc856 (diff) | |
download | tk-52867011954887f3bde7579ee25de18530eaa817.zip tk-52867011954887f3bde7579ee25de18530eaa817.tar.gz tk-52867011954887f3bde7579ee25de18530eaa817.tar.bz2 |
Fix [a01b6f7227]: WidthMMOfScreen returns 0 in VirtualBox VM using XWayland.
Actually, this is an XWayland bug, but better work-around it when possible.
Diffstat (limited to 'unix/tkUnixEvent.c')
-rw-r--r-- | unix/tkUnixEvent.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/unix/tkUnixEvent.c b/unix/tkUnixEvent.c index a92b868..43f695c 100644 --- a/unix/tkUnixEvent.c +++ b/unix/tkUnixEvent.c @@ -166,7 +166,7 @@ TkpOpenDisplay( if (display == NULL) { /*fprintf(stderr,"event=%d error=%d major=%d minor=%d reason=%d\nDisabling xkb\n", event, error, major, minor, reason);*/ - display = XOpenDisplay(displayNameStr); + display = XOpenDisplay(displayNameStr); } else { use_xkb = TK_DISPLAY_USE_XKB; /*fprintf(stderr, "Using xkb %d.%d\n", major, minor);*/ @@ -188,6 +188,25 @@ TkpOpenDisplay( DisplayFileProc, dispPtr); /* + * Observed weird WidthMMOfScreen() in X on Wayland on a + * Fedora 30/i386 running in a VM. Fallback to 75 dpi, + * otherwise many other strange things may happen later. + * See: [https://core.tcl-lang.org/tk/tktview?name=a01b6f7227] + */ + if (WidthMMOfScreen(DefaultScreenOfDisplay(display)) <= 0) { + int mm; + + mm = WidthOfScreen(DefaultScreenOfDisplay(display)) * (25.4 / 75.0); + WidthMMOfScreen(DefaultScreenOfDisplay(display)) = mm; + } + if (HeightMMOfScreen(DefaultScreenOfDisplay(display)) <= 0) { + int mm; + + mm = HeightOfScreen(DefaultScreenOfDisplay(display)) * (25.4 / 75.0); + HeightMMOfScreen(DefaultScreenOfDisplay(display)) = mm; + } + + /* * Key map info must be available immediately, because of "send event". */ TkpInitKeymapInfo(dispPtr); |