summaryrefslogtreecommitdiff
path: root/lisp/play
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2022-08-22 13:53:33 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2022-08-22 13:53:33 +0200
commitf421efdb5f03d5f7efc3f6893c280b27e54a33cb (patch)
tree37df4479944d61772f59081a9980fb294cb5a879 /lisp/play
parentd9214248913e205f81ffe221a351f85c92f486bd (diff)
downloademacs-f421efdb5f03d5f7efc3f6893c280b27e54a33cb.tar.gz
Make the size of elements the same in pgtk and X in tetris
* lisp/play/gamegrid.el (gamegrid-glyph-height-mm): Decrease height a bit (since it wasn't really that height). (gamegrid-calculate-glyph-size): Change calculation to work on both X and pgtk (bug#49937). (gamegrid-make-glyph): Inhibit image scaling.
Diffstat (limited to 'lisp/play')
-rw-r--r--lisp/play/gamegrid.el25
1 files changed, 17 insertions, 8 deletions
diff --git a/lisp/play/gamegrid.el b/lisp/play/gamegrid.el
index 7a850b07ee4..3ad42114d01 100644
--- a/lisp/play/gamegrid.el
+++ b/lisp/play/gamegrid.el
@@ -72,7 +72,7 @@ directory will be used.")
(defvar gamegrid-mono-x-face nil)
(defvar gamegrid-mono-tty-face nil)
-(defvar gamegrid-glyph-height-mm 7.0
+(defvar gamegrid-glyph-height-mm 5.0
"Desired glyph height in mm.")
;; ;;;;;;;;;;;;; glyph generation ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -80,12 +80,20 @@ directory will be used.")
(defun gamegrid-calculate-glyph-size ()
"Calculate appropriate glyph size in pixels based on display resolution.
Return a multiple of 8 no less than 16."
- (if (and (display-pixel-height) (display-mm-height))
- (let* ((y-pitch (/ (display-pixel-height) (float (display-mm-height))))
- (pixels (* y-pitch gamegrid-glyph-height-mm))
- (rounded (* (floor (/ (+ pixels 4) 8)) 8)))
- (max 16 rounded))
- 16))
+ (let ((atts (car (display-monitor-attributes-list)))
+ y-pitch)
+ (setq y-pitch (cond
+ (atts
+ (/ (nth 4 (assq 'geometry atts))
+ (nth 2 (assq 'mm-size atts))
+ (or (cdr (assq 'scale-factor atts)) 1.0)))
+ ((and (display-pixel-height) (display-mm-height))
+ (/ (display-pixel-height) (float (display-mm-height))))))
+ (if y-pitch
+ (let* ((pixels (* y-pitch gamegrid-glyph-height-mm))
+ (rounded (* (floor (/ (+ pixels 4) 8)) 8)))
+ (max 16 rounded))
+ 16)))
;; Example of glyph in XPM format:
;;
@@ -336,7 +344,8 @@ format."
(defun gamegrid-make-glyph (data-spec-list color-spec-list)
(let ((data (gamegrid-match-spec-list data-spec-list))
- (color (gamegrid-match-spec-list color-spec-list)))
+ (color (gamegrid-match-spec-list color-spec-list))
+ (image-scaling-factor 1.0))
(cond ((characterp data)
(vector data))
((eq data 'colorize)