[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#3233: 23.0.93; [NS] Regression in x-display-pixel-width
From: |
Ian Eure |
Subject: |
bug#3233: 23.0.93; [NS] Regression in x-display-pixel-width |
Date: |
Wed, 6 May 2009 14:22:27 -0700 |
On May 6, 2009, at 12:57 PM, Stefan Monnier wrote:
It looks like the rewrite of (ns_get_screen) has some problems. In
recent
nightlies, the following code breaks:
(x-display-pixel-width (frame-parameter (selected-frame) 'display))
With:
Wrong type argument: terminal-live-p, "electron.local"
It worked as of 05/05,
As of 05/05 it treated any string as equivalent to nil, indeed.
Not sure if that qualifies as "worked". Can you point us to code that
is affected?
I don't think there's anything in Emacs itself, but it broke my code
which centers an Emacs frame:
(defun screen-usable-height (&optional display)
"Return the usable height of the display.
Some window-systems have portions of the screen which Emacs
cannot address. This function should return the height of the
screen, minus anything which is not usable."
(- (display-pixel-height display)
(cond ((eq window-system 'ns) 22)
(t 0))))
(defun screen-usable-width (&optional display)
"Return the usable width of the display.
This works like `screen-usable-height', but for the width of the
display."
(display-pixel-width display))
(defun frame-box-get-center (w h cw ch)
"Center a box inside another box.
Returns a list of `(TOP LEFT)' representing the centered position
of the box `(w h)' inside the box `(cw ch)'."
(list (/ (- cw w) 2) (/ (- ch h) 2)))
(defun frame-get-center (frame)
"Return the center position of FRAME on it's display."
(let ((disp (frame-parameter frame 'display)))
(frame-box-get-center (frame-pixel-width frame) (frame-pixel-
height frame)
(screen-usable-width disp)
(screen-usable-height disp))))
(defun frame-center (&optional frame)
"Center a frame on the screen."
(interactive)
(let ((frame (or frame (selected-frame))))
(apply 'set-frame-position `(,frame ,@(frame-get-center frame)))))
I don't know how (display-pixel-height) handles multihead displays,
but it seems saner to explicitly pass the display the frame occupies.
- Ian