The only hook I know of that might help is window-size-change-functions
.
Code such as this, for example (replace the message
call by whatever you want done:
(defun foo (frame)
(let ((fullscreen (frame-parameter frame 'fullscreen)))
(when (memq fullscreen '(fullscreen fullboth))
(message "Do what you want here."))))
(add-hook 'window-size-change-functions 'foo)
This hook runs each time there is a change in any window size the hook functions are invoked. C-h v
says:
Functions called during redisplay, if window sizes have changed.
The value should be a list of functions that take one argument.
During the first part of redisplay, for each frame, if any of its windows
have changed size since the last redisplay, or have been split or deleted,
all the functions in the list are called, with the frame as argument.
If redisplay decides to resize the minibuffer window, it calls these
functions on behalf of that as well.
You can instead advise a function, such as toggle-frame-fullscreen
(bound to <f11>
), that makes the frame fullscreen.
Emacs hooks and such advice will not, however, be called when you use window-manager artifacts, such as a maximize/restore icon/button.
It's possible to invoke Elisp code when some window-manager events, such as clicking the iconify/minimize icon/button. You do that using keymap special-event-map
.
For example, to do something different from iconifying when you click the iconify/minimize button, you can do this:
(define-key special-event-map [iconify-frame] 'my-frame-action)
I take advantage of that, optionally, in my library thumb-frm.el
, for example -- Fisheye With Thumbs.
(Be aware of this fact/feature, which is true of any binding on
keymap special-event-map
: The event interrupts any key sequence
in progress, to invoke its command, and then the key sequence as a
whole is processed, ignoring the special event.)
However, as far as I can tell, the maximize/restore icon/button is not associated by Emacs with a special event. (Iconify/minimize is, but maximize is not.) So I don't see a way to make the window-manager maximize/restore button invoke Elisp code. Maybe someone else has some suggestion about this.