all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* 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

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.