emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master f421efdb5f: Make the size of elements the same in pgtk and X in t


From: Lars Ingebrigtsen
Subject: master f421efdb5f: Make the size of elements the same in pgtk and X in tetris
Date: Mon, 22 Aug 2022 07:53:47 -0400 (EDT)

branch: master
commit f421efdb5f03d5f7efc3f6893c280b27e54a33cb
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    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.
---
 lisp/play/gamegrid.el | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/lisp/play/gamegrid.el b/lisp/play/gamegrid.el
index 7a850b07ee..3ad42114d0 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]