[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#7296: display-pixel-height not enough

From: Drew Adams
Subject: bug#7296: display-pixel-height not enough
Date: Sat, 30 Oct 2010 08:06:47 -0700

> >> The Emacs frame can be partly hidden by the taskbar...
> >> if the height is ... x-dsiplay-pixel-height...
> Every function that tries to maximize just height will do it.

Can you give a recipe starting from emacs -Q?  How are you setting the frame
height?  Remember that the frame `height' parameter should not include the frame
area outside the space available for text, and it is measured in lines, not

If you are setting the `height' parameter based on the `x-display-pixel-height'
then you should first subtract frame borders, horizontal scroll bar (well, there
isn't any, but the same method applies for the width), title bar, and (except on
Mac) menu bar.  And then convert pixels to char size -  the `height' parameter
is the number of text lines available at the frame's char size.

See http://www.emacswiki.org/emacs/frame-cmds.el for examples.  The code
compensates for MacIntosh thingies that reduce the available space, but it uses
`x-display-pixel-height' otherwise.  See `maximize-frame-vertically' and
`maximize-frame', which do not overlap the Windows task bar.

Something like this calculates the `height' frame parameter:

(- (/ (- (x-display-pixel-height)
         (* 2 (cdr (assq 'border-width (frame-parameters FRAME))))
         (frame-extra-pixels-height FRAME)
      (frame-char-height FRAME))
   (if (eq window-system 'mac)
       0 ; Menu bar for Carbon Emacs is not in the frame.
     (cdr (assq 'menu-bar-lines (frame-parameters FRAME)))))))


(defun frame-extra-pixels-height (frame)
  "Pixel diff between FRAME total height and its text area height."
  (- (frame-pixel-height frame)
     (* (frame-char-height frame) (frame-height frame))))

(defcustom window-mgr-title-bar-pixel-height
           (if (eq window-system 'mac) 22 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\".  There is no way for Emacs to determine this, so you
must set it."
  :type 'integer)

(defun smart-tool-bar-pixel-height (&optional frame)
  "Pixel height of Mac smart tool bar."
  (if (and (boundp 'mac-tool-bar-display-mode)
           (> (frame-parameter frame 'tool-bar-lines) 0))
      (if (eq mac-tool-bar-display-mode 'icons) 40 56)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]