GNU bug report logs - #30074
26.0; Add function(s) for current monitor info

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Wed, 10 Jan 2018 23:13:01 UTC

Severity: wishlist

Tags: wontfix

Found in version 26.0

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 30074 in the body.
You can then email your comments to 30074 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#30074; Package emacs. (Wed, 10 Jan 2018 23:13:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Drew Adams <drew.adams <at> oracle.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 10 Jan 2018 23:13:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.0; Add function(s) for current monitor info
Date: Wed, 10 Jan 2018 15:08:27 -0800 (PST)
Please consider adding a function that returns the info describing the
monitor that dominates a frame (default: selected frame).  In
particular, the size of the monitor.  This can be useful, for example,
for positioning a frame when there are multiple monitors.

I've been using this, but you might have a better implementation in
mind:

(defun current-monitor (&optional frame)
  "Attributes of monitor that dominates FRAME (default: `selected-frame')."
  (catch 'current-monitor
    (dolist (atts  (display-monitor-attributes-list frame))
      (when (member (or frame  (selected-frame)) (cdr (assq 'frames atts)))
        (throw 'current-monitor atts)))
    nil))                              ; Should never happen (?)

(defun current-monitor-size (&optional frame workarea-p)
  "Size of the monitor that dominates FRAME (default: `selected-frame').
This is a cons (WIDTH . HEIGHT) where WIDTH and HEIGHT are in pixels.

Uses the full area of the monitor (attribute `geometry' of
`display-monitor-attributes-list') by default.  Non-nil optional arg
WORKAREA-P means use only the available work area (attribute
`workarea') instead."
  (let* ((att  (if workarea-p 'workarea 'geometry))
         (mon  (assq att (current-monitor frame))))
    (cons (nth 3 mon) (nth 4 mon))))

Dunno whether the fallback value of nil is needed.  I haven't come
across a frame that is not listed in attribute `frames' of
`display-monitor-attributes-list'.  Even invisible frames are listed.
Dunno about deleted frames.

Whether it would also be useful to have functions corresponding to
attributes such as `mm-size' and `name' is another question.


In GNU Emacs 26.0.90 (build 3, x86_64-w64-mingw32)
 of 2017-10-13
Repository revision: 906224eba147bdfc0514090064e8e8f53160f1d4
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --without-dbus --host=x86_64-w64-mingw32
 --without-compress-install 'CFLAGS=-O2 -static -g3''




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#30074; Package emacs. (Sun, 14 Jul 2019 17:47:01 GMT) Full text and rfc822 format available.

Message #8 received at 30074 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 30074 <at> debbugs.gnu.org
Subject: Re: bug#30074: 26.0; Add function(s) for current monitor info
Date: Sun, 14 Jul 2019 19:46:42 +0200
Drew Adams <drew.adams <at> oracle.com> writes:

> Please consider adding a function that returns the info describing the
> monitor that dominates a frame (default: selected frame).  In
> particular, the size of the monitor.  This can be useful, for example,
> for positioning a frame when there are multiple monitors.
>
> I've been using this, but you might have a better implementation in
> mind:
>
> (defun current-monitor (&optional frame)
>   "Attributes of monitor that dominates FRAME (default: `selected-frame')."
>   (catch 'current-monitor
>     (dolist (atts  (display-monitor-attributes-list frame))
>       (when (member (or frame  (selected-frame)) (cdr (assq 'frames atts)))
>         (throw 'current-monitor atts)))
>     nil))                              ; Should never happen (?)

I guess it's possible for a frame to be on several monitors?  (Half on
one and half on another.)  What would this function return in that case?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#30074; Package emacs. (Sun, 14 Jul 2019 19:53:02 GMT) Full text and rfc822 format available.

Message #11 received at 30074 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 30074 <at> debbugs.gnu.org, Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#30074: 26.0; Add function(s) for current monitor info
Date: Sun, 14 Jul 2019 22:49:23 +0300
>> Please consider adding a function that returns the info describing the
>> monitor that dominates a frame (default: selected frame).  In
>> particular, the size of the monitor.  This can be useful, for example,
>> for positioning a frame when there are multiple monitors.
>>
>> I've been using this, but you might have a better implementation in
>> mind:
>>
>> (defun current-monitor (&optional frame)
>>   "Attributes of monitor that dominates FRAME (default: `selected-frame')."
>>   (catch 'current-monitor
>>     (dolist (atts  (display-monitor-attributes-list frame))
>>       (when (member (or frame  (selected-frame)) (cdr (assq 'frames atts)))
>>         (throw 'current-monitor atts)))
>>     nil))                              ; Should never happen (?)
>
> I guess it's possible for a frame to be on several monitors?  (Half on
> one and half on another.)  What would this function return in that case?

There is already `frame-monitor-attributes' added in Emacs 24 (see NEWS.24),
e.g.

  (frame-monitor-attributes (selected-frame))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#30074; Package emacs. (Sun, 14 Jul 2019 22:09:02 GMT) Full text and rfc822 format available.

Message #14 received at 30074 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 30074 <at> debbugs.gnu.org
Subject: RE: bug#30074: 26.0; Add function(s) for current monitor info
Date: Sun, 14 Jul 2019 15:07:57 -0700 (PDT)
> > Please consider adding a function that returns the info describing the
> > monitor that dominates a frame (default: selected frame).  In
> > particular, the size of the monitor.  This can be useful, for example,
> > for positioning a frame when there are multiple monitors.
> >
> > I've been using this, but you might have a better implementation in
> > mind:
> >
> > (defun current-monitor (&optional frame)
> >   "Attributes of monitor that dominates FRAME (default: `selected-frame')."
> >   (catch 'current-monitor
> >     (dolist (atts  (display-monitor-attributes-list frame))
> >       (when (member (or frame  (selected-frame)) (cdr (assq 'frames atts)))
> >         (throw 'current-monitor atts)))
> >     nil))                              ; Should never happen (?)
> 
> I guess it's possible for a frame to be on several monitors?  (Half on
> one and half on another.)  What would this function return in that case?

I'm not in front of multiple monitors now.  Perhaps
I can check later, when I am.

In any case, all we have, AFAIK, is
`display-monitor-attributes-list'.  It decides what
it returns.  Attribute `frames' is described thus:

"frames -- List of frames dominated by the physical monitor"

For the same frame to be "dominated" by more than
one monitor I would wonder what good the word
"dominated" could possibly do here.  It suggests
that one of the monitors dominates a given frame.

Anyway, I'll try to remember to check, when I'm
in the presence of > 1 monitor, unless someone
beats me to it.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#30074; Package emacs. (Mon, 15 Jul 2019 10:15:02 GMT) Full text and rfc822 format available.

Message #17 received at 30074 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 30074 <at> debbugs.gnu.org, Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#30074: 26.0; Add function(s) for current monitor info
Date: Mon, 15 Jul 2019 12:13:57 +0200
Juri Linkov <juri <at> linkov.net> writes:

>>> Please consider adding a function that returns the info describing the
>>> monitor that dominates a frame (default: selected frame).  In
>>> particular, the size of the monitor.  This can be useful, for example,
>>> for positioning a frame when there are multiple monitors.
>>>
>>> I've been using this, but you might have a better implementation in
>>> mind:
>>>
>>> (defun current-monitor (&optional frame)
>>>   "Attributes of monitor that dominates FRAME (default: `selected-frame')."
>>>   (catch 'current-monitor
>>>     (dolist (atts  (display-monitor-attributes-list frame))
>>>       (when (member (or frame  (selected-frame)) (cdr (assq 'frames atts)))
>>>         (throw 'current-monitor atts)))
>>>     nil))                              ; Should never happen (?)
>>
>> I guess it's possible for a frame to be on several monitors?  (Half on
>> one and half on another.)  What would this function return in that case?
>
> There is already `frame-monitor-attributes' added in Emacs 24 (see NEWS.24),
> e.g.
>
>   (frame-monitor-attributes (selected-frame))

So there is.  Drew, does this function do what you want?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#30074; Package emacs. (Mon, 15 Jul 2019 15:22:02 GMT) Full text and rfc822 format available.

Message #20 received at 30074 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>, Juri Linkov <juri <at> linkov.net>
Cc: 30074 <at> debbugs.gnu.org
Subject: RE: bug#30074: 26.0; Add function(s) for current monitor info
Date: Mon, 15 Jul 2019 08:21:00 -0700 (PDT)
> > There is already `frame-monitor-attributes' 
> >   (frame-monitor-attributes (selected-frame))
> 
> So there is.  Drew, does this function do what you want?

Yes, that takes care of the `current-monitor'
function, but not `current-monitor-size.
Please consider this bug report to be a
request for a function like that.

---

The doc string of `frame-monitor-attributes'
also answers Lars's question about dominating
monitor:

 A frame is dominated by a physical monitor when either the
 largest area of the frame resides in the monitor, or the monitor
 is the closest to the frame if the frame does not intersect any
 physical monitors.

That makes it clear that there is only one
dominating monitor for a given frame.  (It
does so only indirectly, though, by saying
"largest" and "the" "closest" monitor.)

And the doc string of `display-monitor-attributes-list'
repeats that same text and adds this, which
makes it explicit:

 Every (non-tooltip) frame (including invisible ones)
 in a graphical display is dominated by exactly one physical
 monitor at a time, though it can span multiple (or no) physical
 monitors.

And testing shows that that is the case.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#30074; Package emacs. (Mon, 15 Jul 2019 15:27:02 GMT) Full text and rfc822 format available.

Message #23 received at 30074 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 30074 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#30074: 26.0; Add function(s) for current monitor info
Date: Mon, 15 Jul 2019 17:25:55 +0200
Drew Adams <drew.adams <at> oracle.com> writes:

>> > There is already `frame-monitor-attributes' 
>> >   (frame-monitor-attributes (selected-frame))
>> 
>> So there is.  Drew, does this function do what you want?
>
> Yes, that takes care of the `current-monitor'
> function, but not `current-monitor-size.
> Please consider this bug report to be a
> request for a function like that.

Well, there's

(x-display-pixel-width (selected-frame))
=> 1920

(and height), so it seems like we're covered...  (I don't know whether
that function works on non-X systems, though.)

And the function above also returns the same size data, but as an alist:

(frame-monitor-attributes (selected-frame))
=> ((name . "eDP1") (geometry 0 0 1920 1080) (workarea 0 27 1920 1053) (mm-size 310 170) (frames #<frame movie.el 0x563f20223a30> #<frame emacs 0x563f22915f10>) (source . "Gdk"))

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#30074; Package emacs. (Mon, 15 Jul 2019 16:07:02 GMT) Full text and rfc822 format available.

Message #26 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Andy Moreton <andrewjmoreton <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#30074: 26.0; Add function(s) for current monitor info
Date: Mon, 15 Jul 2019 17:05:55 +0100
On Mon 15 Jul 2019, Drew Adams wrote:

>> > There is already `frame-monitor-attributes' 
>> >   (frame-monitor-attributes (selected-frame))
>> 
>> So there is.  Drew, does this function do what you want?
>
> Yes, that takes care of the `current-monitor'
> function, but not `current-monitor-size.
> Please consider this bug report to be a
> request for a function like that.

Doesn't the returned monitor attributes list give you that information ?
E.g. on a Windows box:

(frame-monitor-attributes (selected-frame))
=> ((geometry 0 0 1920 1080)  ; Monitor size and position
    (workarea 0 0 1920 1050)  ; Space available for drawing frames
    (mm-size 509 286)         ; Physical dimensions
    (name . "\\\\.\\DISPLAY1")
    (frames ...))

What other information do you need ?

    AndyM





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#30074; Package emacs. (Mon, 15 Jul 2019 16:18:01 GMT) Full text and rfc822 format available.

Message #29 received at 30074 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 30074 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: RE: bug#30074: 26.0; Add function(s) for current monitor info
Date: Mon, 15 Jul 2019 09:17:42 -0700 (PDT)
> > Yes, that takes care of the `current-monitor'
> > function, but not `current-monitor-size.
> > Please consider this bug report to be a
> > request for a function like that.
> 
> Well, there's
> (x-display-pixel-width (selected-frame))
> => 1920
> (and height), so it seems like we're covered...

No, we're not covered. `C-h f x-display-pixel-width':

 On "multi-monitor" setups this refers to the pixel width for all
 physical monitors associated with DISPLAY.  To get information for
 each physical monitor, use 'display-monitor-attributes-list'.

IOW, use `display-monitor-attributes-list'.

I think you're missing the point of this
request.  Yes, all such info is available
from `display-monitor-attributes-list'.
The point is to have specific functions
that provide it directly.

> And the function above also returns the same size data, but as an alist:
> 
> (frame-monitor-attributes (selected-frame))
> => ((name . "eDP1") (geometry 0 0 1920 1080) (workarea 0 27 1920 1053) (mm-
> size 310 170) (frames #<frame movie.el 0x563f20223a30> #<frame emacs
> 0x563f22915f10>) (source . "Gdk"))

`current-monitor-size' is a convenience function.
Obviously you can get the info it provides by
digging it out of `display-monitor-attributes-list'
(or `frame-monitor-attributes', which just calls
`d-m-a-l').

`current-monitor-size' gives you directly,
au choix, the geometry or workarea size.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#30074; Package emacs. (Mon, 15 Jul 2019 16:25:01 GMT) Full text and rfc822 format available.

Message #32 received at 30074 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Andy Moreton <andrewjmoreton <at> gmail.com>, 30074 <at> debbugs.gnu.org
Subject: RE: bug#30074: 26.0; Add function(s) for current monitor info
Date: Mon, 15 Jul 2019 09:24:33 -0700 (PDT)
> > Please consider this bug report to be a
> > request for a function like [`current-monitor-size'].
> 
> Doesn't the returned monitor attributes list give you that information ?

Yes, and the bug report made that clear from the
beginning (with `display-monitor-attributes-list').

> (frame-monitor-attributes (selected-frame))
> => ((geometry 0 0 1920 1080)...)
> 
> What other information do you need ?

It's not about _needing other information_.
It's about having a function that gives you
the size info directly.

This is getting a bit ridiculous.  Why do
you think we have functions like this?

(defun frame-width (&optional frame)
  "Return number of columns available for display on FRAME.
If FRAME is omitted, describe the currently selected frame."
  (cdr (assq 'width (frame-parameters frame))))

Why don't you complain that `frame-parameters'
already gives you that information? "What other
information do you need?"




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#30074; Package emacs. (Mon, 15 Jul 2019 16:36:02 GMT) Full text and rfc822 format available.

Message #35 received at 30074 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 30074 <at> debbugs.gnu.org, Andy Moreton <andrewjmoreton <at> gmail.com>
Subject: Re: bug#30074: 26.0; Add function(s) for current monitor info
Date: Mon, 15 Jul 2019 18:35:46 +0200
Drew Adams <drew.adams <at> oracle.com> writes:

> This is getting a bit ridiculous.  Why do
> you think we have functions like this?
>
> (defun frame-width (&optional frame)
>   "Return number of columns available for display on FRAME.
> If FRAME is omitted, describe the currently selected frame."
>   (cdr (assq 'width (frame-parameters frame))))
>
> Why don't you complain that `frame-parameters'
> already gives you that information? "What other
> information do you need?"

Because getting the frame width is something you need quite a bit.
Monitor width -- not so much.

I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) wontfix. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 15 Jul 2019 16:37:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 30074 <at> debbugs.gnu.org and Drew Adams <drew.adams <at> oracle.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 15 Jul 2019 16:37:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#30074; Package emacs. (Mon, 15 Jul 2019 16:43:01 GMT) Full text and rfc822 format available.

Message #42 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Andy Moreton <andrewjmoreton <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#30074: 26.0; Add function(s) for current monitor info
Date: Mon, 15 Jul 2019 17:42:26 +0100
On Mon 15 Jul 2019, Drew Adams wrote:

>> > Please consider this bug report to be a
>> > request for a function like [`current-monitor-size'].
>> 
>> Doesn't the returned monitor attributes list give you that information ?
>
> Yes, and the bug report made that clear from the
> beginning (with `display-monitor-attributes-list').
>
>> (frame-monitor-attributes (selected-frame))
>> => ((geometry 0 0 1920 1080)...)
>> 
>> What other information do you need ?
>
> It's not about _needing other information_.
> It's about having a function that gives you
> the size info directly.
>
> This is getting a bit ridiculous.  Why do
> you think we have functions like this?

If your question had been more clearly phrased, then it would have been
clear that you wanted a trivial helper function rather than reporting of
additional information. Having read the entire thread that was not
obvious, hence my question.

> Why don't you complain that `frame-parameters'
> already gives you that information? "What other
> information do you need?"

There's no need to be rude when replying to a simple query. Feel free to
write a patch with the helper routines that you would find helpful.

    AndyM





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 13 Aug 2019 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 229 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.