all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ian Eure <ian@digg.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-pretest-bug@gnu.org, 3233@emacsbugs.donarmstrong.com
Subject: bug#3233: 23.0.93; [NS] Regression in x-display-pixel-width
Date: Wed, 6 May 2009 14:22:27 -0700	[thread overview]
Message-ID: <87AAEBEC-E8DD-4BE0-A35A-9C0AEFB2F997@digg.com> (raw)
In-Reply-To: <jwvocu6rore.fsf-monnier+emacsbugreports@gnu.org>

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






  reply	other threads:[~2009-05-06 21:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-06 18:49 bug#3233: 23.0.93; [NS] Regression in x-display-pixel-width Ian Eure
2009-05-06 19:57 ` Stefan Monnier
2009-05-06 21:22   ` Ian Eure [this message]
2009-05-07  1:34     ` Stefan Monnier
2009-05-07  4:50       ` Ian Eure
  -- strict thread matches above, loose matches on Subject: below --
2009-07-23 16:42 Adrian Robert
2009-11-23 16:49 Jimmy Yuen Ho Wong
2010-01-06 16:45 Chong Yidong

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

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

  git send-email \
    --in-reply-to=87AAEBEC-E8DD-4BE0-A35A-9C0AEFB2F997@digg.com \
    --to=ian@digg.com \
    --cc=3233@emacsbugs.donarmstrong.com \
    --cc=emacs-pretest-bug@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.