unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Eli Zaretskii <eliz@gnu.org>,
	"help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: RE: [External] : Re: Q4 - the bottom edge of Emacs doesn't stick to the taskbar
Date: Sun, 15 Dec 2024 17:55:16 +0000	[thread overview]
Message-ID: <DS7PR10MB5232D02A69D6B4B18B9114D3F33A2@DS7PR10MB5232.namprd10.prod.outlook.com> (raw)
In-Reply-To: <86ldwhs7z4.fsf@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



      reply	other threads:[~2024-12-15 17:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-15  0:22 Q4 - the bottom edge of Emacs doesn't stick to the taskbar Tatsu Takamaro
2024-12-15  2:30 ` [External] : " Drew Adams
2024-12-15  7:47   ` Eli Zaretskii
2024-12-15 17:55     ` Drew Adams [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DS7PR10MB5232D02A69D6B4B18B9114D3F33A2@DS7PR10MB5232.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=eliz@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).