* HowTo: Detect when a frame's size changes @ 2017-04-05 3:03 raman 2017-04-05 6:58 ` martin rudalics 0 siblings, 1 reply; 9+ messages in thread From: raman @ 2017-04-05 3:03 UTC (permalink / raw) To: emacs-devel Is there a way to tell from elisp if the size of a frame changes? I went looking for some type of frame-resize-hook but didn't find any --- -- ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: HowTo: Detect when a frame's size changes 2017-04-05 3:03 HowTo: Detect when a frame's size changes raman @ 2017-04-05 6:58 ` martin rudalics 2017-04-05 7:54 ` martin rudalics 0 siblings, 1 reply; 9+ messages in thread From: martin rudalics @ 2017-04-05 6:58 UTC (permalink / raw) To: raman, emacs-devel > Is there a way to tell from elisp if the size of a frame changes? I went > looking for some type of frame-resize-hook but didn't find any --- If and when the change of the frame size is propagated to the frame's windows, then with Emacs 26 `window-size-change-functions' should catch them all. With earlier Emacsen you might have to consult `window-configuration-change-hook' as well. And maybe some size changes will not even be noticed. Note that `window-size-change-functions' is also called when the relative sizes of windows change. So you have to store the previous frame size and compare it with the current one to find out whether the frame really changed size or only some of its windows. Also note that size changes that do not affect the inner frame (like adding or removing the menu or tool bar or a border) might not be tracked at all. In any case I'll have to add an appropriate link to the Elisp manual. martin ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: HowTo: Detect when a frame's size changes 2017-04-05 6:58 ` martin rudalics @ 2017-04-05 7:54 ` martin rudalics [not found] ` <p91a87uhon5.fsf@raman-glaptop2> 0 siblings, 1 reply; 9+ messages in thread From: martin rudalics @ 2017-04-05 7:54 UTC (permalink / raw) To: raman, emacs-devel > Note that `window-size-change-functions' is also called when the > relative sizes of windows change. So you have to store the previous > frame size and compare it with the current one to find out whether the > frame really changed size or only some of its windows. Actually that shouldn't be necessary. Try with (defun beep-when-frame-size-changed (frame) (when (or (/= (window-pixel-width-before-size-change (frame-root-window frame)) (window-pixel-width (frame-root-window frame))) (/= (window-pixel-height-before-size-change (frame-root-window frame)) (window-pixel-height (frame-root-window frame)))) (ding))) (add-hook 'window-size-change-functions 'beep-when-frame-size-changed) martin ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <p91a87uhon5.fsf@raman-glaptop2>]
* Re: HowTo: Detect when a frame's size changes [not found] ` <p91a87uhon5.fsf@raman-glaptop2> @ 2017-04-05 17:26 ` martin rudalics 2017-04-05 17:32 ` T.V Raman 0 siblings, 1 reply; 9+ messages in thread From: martin rudalics @ 2017-04-05 17:26 UTC (permalink / raw) To: raman, emacs-devel > Thanks! will try that Hmmm... rather not. You will still get false positives when the minibuffer window is resized. For the moment stick to my earlier proposal: When you run your ‘window-size-change-functions’ function remember the old values of ‘frame-pixel-width’ and ‘frame-pixel-height’ (maybe in a frame parameter) and the next time you run it compare them with the current values. I will fix that soon probably by providing a ‘frame-size-changed-p’ function that you can use during ‘window-size-change-functions’. Providing a separate ‘frame-size-change-functions’ hook would be also possible but the interaction of these could be tricky. martin ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: HowTo: Detect when a frame's size changes 2017-04-05 17:26 ` martin rudalics @ 2017-04-05 17:32 ` T.V Raman 2017-04-05 18:05 ` martin rudalics 2017-04-11 10:55 ` martin rudalics 0 siblings, 2 replies; 9+ messages in thread From: T.V Raman @ 2017-04-05 17:32 UTC (permalink / raw) To: rudalics; +Cc: emacs-devel, raman Thanks Martin! frame-size-changed-p would be nice --- Basically I was writing myself some code in Emacspeak so it would cue me via sounds to the position of the current window relative to the overall layout. I wrote myself this function: -- and was looking to see if I could avoid some of the computes by cacheing values --- though for now it doesn't look like the code I have is sufficiently inefficient to deserve cacheing. (sox-multiwindow ...) used below uses SoX to produce a short tone, and the tone's pitch and left/right pan get paramaeterized appropriately (defun emacspeak--sox-multiwindow (corners) "Takes `window-edges' and plays a sound cue based on position of current window with respect to the overall window layout." (let ((tr 0) (mr (/ (frame-height) 2)) (br (1- (frame-height))) (lc 0) (mc (/ (frame-width) 2)) (rc (frame-width))) (cond ((equal corners `(,lc ,tr ,mc ,br)) (sox-multiwindow) 'left-half) ((equal corners `(,mc ,tr ,rc, br)) (sox-multiwindow 'swap) 'right-half) ((equal corners `(,lc ,tr ,rc ,mr)) (sox-multiwindow nil 2) 'top-half) ((equal corners `(,lc ,mr ,rc ,br)) (sox-multiwindow nil 1.3) 'bottom-half) ((equal corners `(,lc ,tr ,mc ,mr)) (sox-multiwindow nil 2.5) 'top-left) ((equal corners `(,mc ,tr ,rc ,mr)) (sox-multiwindow t 2.5) 'top-right) ((equal corners `(,lc ,mr ,mc ,br)) (sox-multiwindow nil 0.9) 'bottom-left) ((equal corners `(,mc ,mr ,rc ,br)) (sox-multiwindow 'swap 0.9) 'bottom-right) (t "")))) martin rudalics writes: > > Thanks! will try that > > Hmmm... rather not. You will still get false positives when the > minibuffer window is resized. For the moment stick to my earlier > proposal: When you run your ‘window-size-change-functions’ function > remember the old values of ‘frame-pixel-width’ and ‘frame-pixel-height’ > (maybe in a frame parameter) and the next time you run it compare them > with the current values. > > I will fix that soon probably by providing a ‘frame-size-changed-p’ > function that you can use during ‘window-size-change-functions’. > Providing a separate ‘frame-size-change-functions’ hook would be also > possible but the interaction of these could be tricky. > > martin -- -- ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: HowTo: Detect when a frame's size changes 2017-04-05 17:32 ` T.V Raman @ 2017-04-05 18:05 ` martin rudalics 2017-04-05 18:12 ` T.V Raman 2017-04-11 10:55 ` martin rudalics 1 sibling, 1 reply; 9+ messages in thread From: martin rudalics @ 2017-04-05 18:05 UTC (permalink / raw) To: T.V Raman; +Cc: emacs-devel > frame-size-changed-p would be nice --- Basically I was writing myself > some code in Emacspeak so it would cue me via sounds to the position > of the current window relative to the overall layout. With "current window" do you mean the "selected window" or the "selected frame" in Emacs parlance? Note that Emacs currently does not tell you when the position of a frame changes. For Emacs 26 I plan to add a hook ‘move-frame-functions’ that will be called on that occasion. martin ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: HowTo: Detect when a frame's size changes 2017-04-05 18:05 ` martin rudalics @ 2017-04-05 18:12 ` T.V Raman 0 siblings, 0 replies; 9+ messages in thread From: T.V Raman @ 2017-04-05 18:12 UTC (permalink / raw) To: rudalics; +Cc: emacs-devel, raman I meant window in terms of Emacs. I use stumpwm as my window manager and the only things I run are Emacs (with emacspeak talking) and Chrome with ChromeVox making Chrome talk. For the most part, I work with Stumpwm just showing the Emacs window -- -- and the emacs Frame showing either one or two emacs windows. martin rudalics writes: > > frame-size-changed-p would be nice --- Basically I was writing myself > > some code in Emacspeak so it would cue me via sounds to the position > > of the current window relative to the overall layout. > > With "current window" do you mean the "selected window" or the "selected > frame" in Emacs parlance? Note that Emacs currently does not tell you > when the position of a frame changes. For Emacs 26 I plan to add a hook > ‘move-frame-functions’ that will be called on that occasion. > > martin -- -- ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: HowTo: Detect when a frame's size changes 2017-04-05 17:32 ` T.V Raman 2017-04-05 18:05 ` martin rudalics @ 2017-04-11 10:55 ` martin rudalics 2017-04-12 15:22 ` raman 1 sibling, 1 reply; 9+ messages in thread From: martin rudalics @ 2017-04-11 10:55 UTC (permalink / raw) To: T.V Raman; +Cc: emacs-devel > frame-size-changed-p would be nice This function exists now on master. Run ‘window-size-change-functions’ and within the function you've put there ‘frame-size-changed-p’ will tell you whether the frame size really changed or there was a false positive. martin ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: HowTo: Detect when a frame's size changes 2017-04-11 10:55 ` martin rudalics @ 2017-04-12 15:22 ` raman 0 siblings, 0 replies; 9+ messages in thread From: raman @ 2017-04-12 15:22 UTC (permalink / raw) To: martin rudalics; +Cc: emacs-devel Awesome! -- ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-04-12 15:22 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-04-05 3:03 HowTo: Detect when a frame's size changes raman 2017-04-05 6:58 ` martin rudalics 2017-04-05 7:54 ` martin rudalics [not found] ` <p91a87uhon5.fsf@raman-glaptop2> 2017-04-05 17:26 ` martin rudalics 2017-04-05 17:32 ` T.V Raman 2017-04-05 18:05 ` martin rudalics 2017-04-05 18:12 ` T.V Raman 2017-04-11 10:55 ` martin rudalics 2017-04-12 15:22 ` raman
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.