GNU bug report logs -
#3233
23.0.93; [NS] Regression in x-display-pixel-width
Previous Next
Reported by: Ian Eure <ian <at> digg.com>
Date: Wed, 6 May 2009 18:55:04 UTC
Severity: normal
Done: Chong Yidong <cyd <at> stupidchicken.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
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
This bug report was last modified 15 years and 134 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.