Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximizing an Emacs frame to just one monitor with elisp

I use maxframe.el to maximize my Emacs frames.

It works great on all three major platforms, except on my dual-head Mac setup (Macbook Pro 15-inch laptop with 23-inch monitor).

When maximizing an Emacs frame, the frame expands to fill the width of both monitors and the height of the larger monitor.

Obviously, I would like the frame to maximize to fill only the monitor it's on. How can I detect the resolutions of the two individual monitors using elisp?

Thanks, Jacob

EDIT: As Denis points out, setting mf-max-width is a reasonable workaround. But (as I should have mentioned) I was hoping for a solution that works on both monitors and with any resolution. Maybe something OSX-specific in the style of the Windows-specific w32-send-sys-command.

like image 767
Chopmo Avatar asked Sep 18 '08 15:09

Chopmo


2 Answers

I quickly scanned the reference that you provided to maxframe.el and I don't think that you're using the same technique that I use. Does the following code snippet help you?


(defun toggle-fullscreen ()
  "toggles whether the currently selected frame consumes the entire display or is decorated with a window border"
  (interactive)
  (let ((f (selected-frame)))
    (modify-frame-parameters f `((fullscreen . ,(if (eq nil (frame-parameter f 'fullscreen)) 'fullboth nil))))))
like image 171
Greg Mattes Avatar answered Nov 16 '22 03:11

Greg Mattes


Does customising `mf-max-width' work? Its documentation:

"*The maximum display width to support.  This helps better support the true
nature of display-pixel-width.  Since multiple monitors will result in a
very large display pixel width, this value is used to set the stop point for
maximizing the frame.  This could also be used to set a fixed frame size
without going over the display dimensions."
like image 34
EfForEffort Avatar answered Nov 16 '22 01:11

EfForEffort