Raised by Edward O'Connor in emacs-devel thread [1], filing in
bugtracker so it doesn't get lost over the feature freeze period.
Emacs doesn't appear to currently provide a hook that is reliably called
when the _display_ geometry changes on graphical window systems. e.g.
screen resolution changed by user, monitor hotplugging.
Emacs frame/window geometry might sometimes be considered to remain the
same by the window system terms despite changing overall display
geometry, so e.g. window-configuration-change-hook is not always run
when the display geometry changes.
Attached is an initial x11-only stab at an implementation that calls
window-configuration-change-hook when display geometry changes, though a
separate hook would be another design option.
For ns, Edward also mentioned:
"On GNUStep and Mac OS X, applications can listen for
NSApplicationDidChangeScreenParametersNotification for this sort of thing"
Dunno about w32 as yet, but presumably it has something similar.
[1] http://lists.gnu.org/archive/html/emacs-devel/2011-08/msg00544.html
From: "Edward O'Connor" <...>
Date: Fri, 12 Aug 2011 10:51:25 -0700
Message-ID:
<CAME3nGLnjLXixmSY45BWFX6qtCp2_XBR4x6a281hO6Mu=rn...@mail.gmail.com>
Subject: is there a hook run when display geometry changes?
On MS-Windows there's the WM_DISPLAYCHANGE message sent to the message
pump. Emacs already accepts that message (see w32term.c), but
currently does nothing with it except announcing the change to the
attached debugger.
However, on Windows the message also specifies the new resolution, so
this:
> + inev.ie.kind = SCREEN_CHANGE_NOTIFY_EVENT;
> + inev.ie.frame_or_window = XCAR(dpyinfo->name_list_element);
is not general enough: there should be a way to provide the new
dimensions to the event queue. It also means that a "normal" hook is
insufficient to handle this event, it should be a -functions style
hook.
Technically the incoming x11 event does too, but as you can re-query
with the existing #'display-pixel-width etc. functions (and get the new
values) anyway by the time the hook actually runs (on x11), wasn't sure
we needed to allow for propagation of the info really.
Ted