emacs-devel
[Top][All Lists]
Advanced

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

Re: master 57d2f24: * lisp/frame.el (make-frame-on-monitor): New command


From: Robert Pluim
Subject: Re: master 57d2f24: * lisp/frame.el (make-frame-on-monitor): New command. (Bug#34516)
Date: Fri, 01 Mar 2019 14:40:37 +0100

Juri Linkov <address@hidden> writes:

>> If Iʼve understood correctly, you want to create a frame that covers
>> the entire workarea of the chosen monitor. Would it not work to
>> specify the x,y of the top corner plus (fullscreen . maximized) rather
>> than specifying the width and height explicitly? That will do the
>> toolbar/titlebar/scrollbar subtractions for you (I haven't tested this).

Now that Iʼve tested this, it works for my primary display, but not
the secondary, which is because the secondary is to my left,
and ns-parse-geometry has an issue with negative offsets.

In any case, I think using x-parse-geometry is not necessary. The
workarea already contains the relevant coördinates, and you can just
pass (fullscreen . maximized) to get the right size. Sample patch
below (which Iʼve tested only on macOS, not under X).

> I already have this for personal customization in ~/.emacs:
>
>   (add-hook 'after-make-frame-functions 'toggle-frame-maximized)
>   (advice-add 'make-frame-on-monitor :around
>               (lambda (orig-fun monitor &optional display parameters)
>                 (funcall orig-fun monitor display '((undecorated . t))))
>               '((name . make-frame-on-monitor-undecorated)))
>
> But my intention was to implement a general command that would make
> a new frame according to the physical monitor attributes returned by
> display-monitor-attributes-list.
>
> I have no idea why display-monitor-attributes-list returns
> workarea that doesn't fit into the created frame on macOS.

It does that because thatʼs what itʼs supposed to do, itʼs describing
the characteristics of the monitor. The issue is with make-frame. From
(elisp) Frame Size:

   The text size of any frame can be set and retrieved with the help of
the ‘height’ and ‘width’ frame parameters (*note Size Parameters::).

Note it says 'text size', which means you have to account for
scrollbars, toolbars, etc.

> While testing it without customization in GDK on GNU/Linux,
> I see that the created frames cover the whole physical monitor,
> including toolbar/titlebar/scrollbar.

That I suspect is window-manager dependent: there are window managers
that won't let you create a frame bigger than the monitor, or maybe
x-parse-geometry is performing clipping.

> Maybe there is still an issue in ns-display-monitor-attributes-list?

Not that I can see.

Sample implementation using (fullscreen . maximized):

diff --git a/lisp/frame.el b/lisp/frame.el
index 8a4a0b6639..f8e9a1ff1a 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -666,19 +666,19 @@ make-frame-on-monitor
                                    (when (equal (cdr (assq 'name a)) monitor)
                                      (cdr (assq 'workarea a))))
                                  (display-monitor-attributes-list display)))))
-         (frame-geometry
-          (when monitor-geometry
-            (x-parse-geometry (format "%dx%d+%d+%d"
-                                      (nth 2 monitor-geometry)
-                                      (nth 3 monitor-geometry)
-                                      (nth 0 monitor-geometry)
-                                      (nth 1 monitor-geometry)))))
          (frame-geometry-in-pixels
-          (when frame-geometry
-            `((top . ,(cdr (assq 'top frame-geometry)))
-              (left . ,(cdr (assq 'left frame-geometry)))
-              (height . (text-pixels . ,(cdr (assq 'height frame-geometry))))
-              (width . (text-pixels . ,(cdr (assq 'width frame-geometry))))))))
+          (when monitor-geometry
+            (let* ((top (nth 1 monitor-geometry))
+                   (left (nth 0 monitor-geometry))
+                   (top (if (< top 0)
+                                 `(- ,(abs top))
+                               top))
+                   (left (if (< left 0)
+                             `(- ,(abs left))
+                           left)))
+              `((top . ,top)
+                (left . ,left)
+                (fullscreen . maximized))))))
     (make-frame (append frame-geometry-in-pixels parameters))))



reply via email to

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