all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Mathias Dahl <brakjoller@hotmail.com>
Subject: Re: Calculate window size in pixels
Date: 06 May 2005 17:36:43 +0200	[thread overview]
Message-ID: <m2fyx0l62c.fsf@hotmail.com> (raw)
In-Reply-To: 87u0lgigvl.fsf-monnier+gnu.emacs.help@gnu.org

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> > Is it possible to calculate an Emacs window's size in pixels?
> > `window-height' and `window-width' returns lines and columns.
> 
> There's frame-pixel-height in Emacs-CVS.
> There's also window-pixel-edges if you care about windows rather
> than frames.

Which means I can use this:

(defun window-height-pixels ()
  (let ((line-pixel-height-ratio (/ (+ (frame-pixel-height) 0.0) (frame-height)))
        (column-pixel-width-ratio (/ (+ (frame-pixel-width) 0.0) (frame-width))))
    (ftruncate (* (window-height) line-pixel-height-ratio))))

(defun window-width-pixels ()
  (let ((column-pixel-width-ratio (/ (+ (frame-pixel-width) 0.0) (frame-width))))
    (ftruncate (* (window-width) column-pixel-width-ratio))))

I see that the frame-pixel-functions is including window
decorations and stuff, but I guess it can work for my
purposes anyway.

Thanks!

/Mathias

  parent reply	other threads:[~2005-05-06 15:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-06  9:12 Calculate window size in pixels Mathias Dahl
2005-05-06 10:40 ` Pascal Bourguignon
2005-05-06 14:12 ` Stefan Monnier
2005-05-06 14:40   ` Klaus Straubinger
2005-05-06 15:36   ` Mathias Dahl [this message]
2005-05-06 15:40     ` Mathias Dahl
2005-05-06 17:12       ` Mathias Dahl
2005-05-06 17:55       ` Kevin Rodgers
     [not found]       ` <mailman.3776.1115402969.2819.help-gnu-emacs@gnu.org>
2005-05-07 17:51         ` Mathias Dahl
2005-05-09 11:02       ` Ehud Karni
     [not found]       ` <mailman.4226.1115637000.2819.help-gnu-emacs@gnu.org>
2005-05-10 10:28         ` Mathias Dahl
2005-05-11  6:36           ` Mathias Dahl

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=m2fyx0l62c.fsf@hotmail.com \
    --to=brakjoller@hotmail.com \
    /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.