[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: HowTo: Detect when a frame's size changes
From: |
T.V Raman |
Subject: |
Re: HowTo: Detect when a frame's size changes |
Date: |
Wed, 5 Apr 2017 10:32:54 -0700 |
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
--
--