* bug#30074: 26.0; Add function(s) for current monitor info
@ 2018-01-10 23:08 Drew Adams
2019-07-14 17:46 ` Lars Ingebrigtsen
0 siblings, 1 reply; 12+ messages in thread
From: Drew Adams @ 2018-01-10 23:08 UTC (permalink / raw)
To: 30074
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''
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#30074: 26.0; Add function(s) for current monitor info
2018-01-10 23:08 bug#30074: 26.0; Add function(s) for current monitor info Drew Adams
@ 2019-07-14 17:46 ` Lars Ingebrigtsen
2019-07-14 19:49 ` Juri Linkov
2019-07-14 22:07 ` Drew Adams
0 siblings, 2 replies; 12+ messages in thread
From: Lars Ingebrigtsen @ 2019-07-14 17:46 UTC (permalink / raw)
To: Drew Adams; +Cc: 30074
Drew Adams <drew.adams@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
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#30074: 26.0; Add function(s) for current monitor info
2019-07-14 17:46 ` Lars Ingebrigtsen
@ 2019-07-14 19:49 ` Juri Linkov
2019-07-15 10:13 ` Lars Ingebrigtsen
2019-07-14 22:07 ` Drew Adams
1 sibling, 1 reply; 12+ messages in thread
From: Juri Linkov @ 2019-07-14 19:49 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 30074
>> 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))
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#30074: 26.0; Add function(s) for current monitor info
2019-07-14 19:49 ` Juri Linkov
@ 2019-07-15 10:13 ` Lars Ingebrigtsen
2019-07-15 15:21 ` Drew Adams
0 siblings, 1 reply; 12+ messages in thread
From: Lars Ingebrigtsen @ 2019-07-15 10:13 UTC (permalink / raw)
To: Juri Linkov; +Cc: 30074
Juri Linkov <juri@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
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#30074: 26.0; Add function(s) for current monitor info
2019-07-15 10:13 ` Lars Ingebrigtsen
@ 2019-07-15 15:21 ` Drew Adams
2019-07-15 15:25 ` Lars Ingebrigtsen
2019-07-15 16:05 ` Andy Moreton
0 siblings, 2 replies; 12+ messages in thread
From: Drew Adams @ 2019-07-15 15:21 UTC (permalink / raw)
To: Lars Ingebrigtsen, Juri Linkov; +Cc: 30074
> > 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.
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#30074: 26.0; Add function(s) for current monitor info
2019-07-15 15:21 ` Drew Adams
@ 2019-07-15 15:25 ` Lars Ingebrigtsen
2019-07-15 16:17 ` Drew Adams
2019-07-15 16:05 ` Andy Moreton
1 sibling, 1 reply; 12+ messages in thread
From: Lars Ingebrigtsen @ 2019-07-15 15:25 UTC (permalink / raw)
To: Drew Adams; +Cc: 30074, Juri Linkov
Drew Adams <drew.adams@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
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#30074: 26.0; Add function(s) for current monitor info
2019-07-15 15:25 ` Lars Ingebrigtsen
@ 2019-07-15 16:17 ` Drew Adams
0 siblings, 0 replies; 12+ messages in thread
From: Drew Adams @ 2019-07-15 16:17 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 30074, Juri Linkov
> > 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.
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#30074: 26.0; Add function(s) for current monitor info
2019-07-15 15:21 ` Drew Adams
2019-07-15 15:25 ` Lars Ingebrigtsen
@ 2019-07-15 16:05 ` Andy Moreton
2019-07-15 16:24 ` Drew Adams
1 sibling, 1 reply; 12+ messages in thread
From: Andy Moreton @ 2019-07-15 16:05 UTC (permalink / raw)
To: 30074
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#30074: 26.0; Add function(s) for current monitor info
2019-07-15 16:05 ` Andy Moreton
@ 2019-07-15 16:24 ` Drew Adams
2019-07-15 16:35 ` Lars Ingebrigtsen
2019-07-15 16:42 ` Andy Moreton
0 siblings, 2 replies; 12+ messages in thread
From: Drew Adams @ 2019-07-15 16:24 UTC (permalink / raw)
To: Andy Moreton, 30074
> > 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?"
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#30074: 26.0; Add function(s) for current monitor info
2019-07-15 16:24 ` Drew Adams
@ 2019-07-15 16:35 ` Lars Ingebrigtsen
2019-07-15 16:42 ` Andy Moreton
1 sibling, 0 replies; 12+ messages in thread
From: Lars Ingebrigtsen @ 2019-07-15 16:35 UTC (permalink / raw)
To: Drew Adams; +Cc: 30074, Andy Moreton
Drew Adams <drew.adams@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
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#30074: 26.0; Add function(s) for current monitor info
2019-07-15 16:24 ` Drew Adams
2019-07-15 16:35 ` Lars Ingebrigtsen
@ 2019-07-15 16:42 ` Andy Moreton
1 sibling, 0 replies; 12+ messages in thread
From: Andy Moreton @ 2019-07-15 16:42 UTC (permalink / raw)
To: 30074
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#30074: 26.0; Add function(s) for current monitor info
2019-07-14 17:46 ` Lars Ingebrigtsen
2019-07-14 19:49 ` Juri Linkov
@ 2019-07-14 22:07 ` Drew Adams
1 sibling, 0 replies; 12+ messages in thread
From: Drew Adams @ 2019-07-14 22:07 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 30074
> > 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.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2019-07-15 16:42 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-10 23:08 bug#30074: 26.0; Add function(s) for current monitor info Drew Adams
2019-07-14 17:46 ` Lars Ingebrigtsen
2019-07-14 19:49 ` Juri Linkov
2019-07-15 10:13 ` Lars Ingebrigtsen
2019-07-15 15:21 ` Drew Adams
2019-07-15 15:25 ` Lars Ingebrigtsen
2019-07-15 16:17 ` Drew Adams
2019-07-15 16:05 ` Andy Moreton
2019-07-15 16:24 ` Drew Adams
2019-07-15 16:35 ` Lars Ingebrigtsen
2019-07-15 16:42 ` Andy Moreton
2019-07-14 22:07 ` Drew Adams
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.