unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Fix fit-frame-to-buffer for multi-monitor setup.
@ 2020-02-29 13:10 Сергей Трофимов
  2020-02-29 16:05 ` martin rudalics
  0 siblings, 1 reply; 6+ messages in thread
From: Сергей Трофимов @ 2020-02-29 13:10 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 446 bytes --]

I've noticed `fit-frame-to-buffer` results in incorrect frame position
when the frame is not a child frame. I've looked into the code and
seems that there are two issues: first is that frame monitor is
ignored, always first monitor in `display-monitor-attributes-list` is
used. Second is that `workarea` and `geometry` are in the form of `(X
Y WIDTH HEIGHT)` but code treats them as `(X1 Y1 X2 Y2)`. I'm
providing a patch that fixes both issues.

[-- Attachment #2: 0001-Fix-fit-frame-to-buffer-for-multi-monitor-setup.patch --]
[-- Type: text/x-patch, Size: 2424 bytes --]

From 59a83f32fe5bb8920351bdf8e2fbcdd0dee1aba7 Mon Sep 17 00:00:00 2001
From: Sergey Trofimov <sarg@sarg.org.ru>
Date: Sat, 29 Feb 2020 14:00:38 +0100
Subject: [PATCH] Fix fit-frame-to-buffer for multi-monitor setup.

---
 lisp/window.el | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/lisp/window.el b/lisp/window.el
index bd825c0..3190c15 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -8806,8 +8806,7 @@ parameters of FRAME."
            (parent (frame-parent frame))
            (monitor-attributes
             (unless parent
-              (car (display-monitor-attributes-list
-                    (frame-parameter frame 'display)))))
+              (frame-monitor-attributes frame)))
            ;; FRAME'S parent or display sizes.  Used in connection
            ;; with margins.
            (geometry
@@ -8816,11 +8815,11 @@ parameters of FRAME."
            (parent-or-display-width
             (if parent
                 (frame-native-width parent)
-              (- (nth 2 geometry) (nth 0 geometry))))
+              (nth 2 geometry)))
            (parent-or-display-height
             (if parent
                 (frame-native-height parent)
-              (- (nth 3 geometry) (nth 1 geometry))))
+              (nth 3 geometry)))
            ;; FRAME's parent or workarea sizes.  Used when no margins
            ;; are specified.
            (parent-or-workarea
@@ -8882,13 +8881,13 @@ parameters of FRAME."
                                 (window--sanitize-margin
                                  (nth 2 margins) left-margin
                                  parent-or-display-width))
-                           (nth 2 parent-or-workarea)))
+                           (+ (nth 0 parent-or-workarea) (nth 2 parent-or-workarea))))
            (bottom-margin (if (nth 3 margins)
                               (- parent-or-display-height
                                  (window--sanitize-margin
                                   (nth 3 margins) top-margin
                                   parent-or-display-height))
-                            (nth 3 parent-or-workarea)))
+                            (+ (nth 1 parent-or-workarea) (nth 3 parent-or-workarea))))
            ;; Minimum and maximum sizes specified for FRAME.
            (sizes (or (frame-parameter frame 'fit-frame-to-buffer-sizes)
                       fit-frame-to-buffer-sizes))
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-03-01 19:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-29 13:10 [PATCH] Fix fit-frame-to-buffer for multi-monitor setup Сергей Трофимов
2020-02-29 16:05 ` martin rudalics
2020-02-29 18:31   ` Sergey Trofimov
2020-03-01  8:52     ` martin rudalics
2020-03-01 15:46       ` Eli Zaretskii
2020-03-01 19:25         ` martin rudalics

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).