* RE: [External] : Re: Q4 - the bottom edge of Emacs doesn't stick to the taskbar
2024-12-15 7:47 ` Eli Zaretskii
@ 2024-12-15 17:55 ` Drew Adams
0 siblings, 0 replies; 4+ messages in thread
From: Drew Adams @ 2024-12-15 17:55 UTC (permalink / raw)
To: Eli Zaretskii, help-gnu-emacs@gnu.org
> > > When I use this
> > >
> > > *(add-to-list 'default-frame-alist '(height . 1.0))*
> > >
> > > to tell Emacs be of all height, it takes it too literaly, and its
> > > bottom edge is shown hidden behind the taskbar line. What should
> > > I do to make it stick to the taskbar's up border?
> >
> > 1. Emacs knows nothing about the MS Windows task bar.
>
> That's not true: see display-monitor-attributes-list.
Yes (starting with Emacs 24.4).
I tried to keep things simple in my answer. To take
advantage of `display-monitor-attributes-list' in this
context, I do this kind of thing (in `frame-cmds.el'):
___
`Non-nil option `available-screen-pixel-bounds' lets you
set the upper left and lower right coordinates of the
available screen space:
(defcustom available-screen-pixel-bounds nil
"Upper left and lower right of available screen space for tiling frames.
Integer list: (x0 y0 x1 y1), where (x0, y0) is the upper left position
and (x1, y1) is the lower right position. Coordinates are in pixels,
measured from the screen absolute origin, (0, 0), at the upper left.
If this is nil, then the available space is calculated. That should
give good results in most cases."
:type '(choice
(const :tag "Calculate automatically" nil)
(list :tag "List of (x0 y0 x1 y1)"
(integer :tag "X0 (upper left) - pixels from screen left")
(integer :tag "Y0 (upper left) - pixels from screen top")
(integer :tag "X1 (lower right) - pixels from screen left" )
(integer :tag "Y1 (lower right) - pixels from screen top")))
:group 'Frame-Commands)
With the default value nil, the screen space is calculated
using `display-monitor-attributes-list', like this:
(defun frcmds-available-screen-pixel-bounds ()
"Returns a value of the same form as option `available-screen-pixel-bounds'.
This represents the currently available screen area."
(or available-screen-pixel-bounds ; Use the option value, if available.
(if (fboundp 'mac-display-available-pixel-bounds) ; macOS-specific.
(mac-display-available-pixel-bounds)
(if (fboundp 'display-monitor-attributes-list) ; Emacs 24.4+
(let ((attss (display-monitor-attributes-list))
(x0 most-positive-fixnum)
(y0 most-positive-fixnum)
(x1 0)
(y1 0)
geom)
(dolist (atts attss)
(setq geom (cdr (assq 'geometry atts))
x0 (min x0 (nth 0 geom))
y0 (min y0 (nth 1 geom))
x1 (max x1 (nth 2 geom))
;; Use `max' for the height too, but it does
;; not account for taskbar etc.
y1 (max y1 (nth 3 geom))))
(list x0 y0 x1 y1))
;; Punt. Assume only one monitor.
(list 0 0 (x-display-pixel-width) (x-display-pixel-height))))))
But AFAIK, Emacs still knows nothing about the task bar
_per se_. (Please correct me if I'm wrong, Eli, with
some specifics.)
You would need to get the actual size and position info
from your Windows Settings. You can set the size using
a new name, "TaskbarSi", under HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced.
But perhaps, for a given Windows version you can rely on
the default values.
Then there's the title bar of a Windows frame. For that
I just use 27 as the default value for MS Windows, in
this option `window-mgr-title-bar-pixel-height'. But you
can consult registry (key WindowMetrics, CaptionHeight =
-15 * pixel-height) for the exact value you have.
(defcustom window-mgr-title-bar-pixel-height
(cond ((eq window-system 'mac) 22)
;; For older versions of macOS, 40 might be better.
((eq window-system 'ns) 50)
(t 27))
"Height of frame title bar provided by the window manager, in pixels.
You might alternatively call this constant the title-bar \"width\" or
\"thickness\"."
:type 'integer :group 'Frame-Commands)
This is what I use for the pixel height of a frame:
(defun frcmds-frame-pixel-height (frame)
"Pixel height of FRAME, including the window-manager title bar and menu-bar.
For the title bar, `window-mgr-title-bar-pixel-height' is used.
For the menu-bar, the frame char size is multiplied by frame parameter
`menu-bar-lines'. But that parameter does not take into account
menu-bar wrapping."
(+ window-mgr-title-bar-pixel-height
(frame-pixel-height frame)
(if (not (eq window-system 'x))
0
(+ (* (frame-char-height frame)
(cdr (assq 'menu-bar-lines
(frame-parameters frame))))))))
HTH.
___
https://www.emacswiki.org/emacs/download/frame-cmds.el
^ permalink raw reply [flat|nested] 4+ messages in thread