frame y-point)
(%trace "; screen/window-scroll-y-absolute! "screen" "frame" "y-point"\n")
(with-updated-window
- frame 'SCROLL-Y-ABSOLUTE!
+ screen frame 'SCROLL-Y-ABSOLUTE!
(lambda (widget)
(let ((cursor (text-widget-cursor-ink widget))
(view (fix-layout-view widget)))
(fix-layout-scroll-to! widget x y*)
(update-start-mark widget)))
-(define (with-updated-window frame what operation)
- (let* ((widget (window-text-widget* frame))
- (widget* (or widget
- (let ((screen (window-screen frame)))
- (%trace "; forcibly updating "screen" for "what"\n")
- (update-widgets screen)
- (window-text-widget* frame)))))
- (if (not widget*)
- (error "No widget:" frame))
- (if (and widget ignore-change-region)
- (operation widget)
- (begin
- (%trace "; forcibly updating "widget*" for "what"\n")
- (and (update-drawing (window-screen frame)
- (text-widget-buffer-drawing widget*))
- (fluid-let ((ignore-change-region #t))
- (update-window widget)
- (operation widget)))))))
+(define (with-updated-window screen frame what operation)
+ (%trace "; with-updated-window "screen" "frame" "what"\n")
+
+ (if (not (screen-in-update? screen))
+ ;; Don't loop when used during screen update(!).
+ (begin
+ (%trace "; forcing update...\n")
+ (update-screens! #t)
+ (%trace "; ...forced update finished.\n"))
+ (%trace "; in update, with widget "(window-text-widget* frame)"\n"))
+
+ (let ((widget (window-text-widget* frame)))
+ (if (not widget) (error "No widget:" frame))
+ (%trace "; "what"...\n")
+ (let ((value (operation widget)))
+ (%trace "; ..."what" => "value"\n")
+ value)))
(define-method screen/window-scroll-y-relative! ((screen <gtk-screen>)
frame delta)
(%trace "; screen/window-scroll-y-relative! "screen" "frame" "delta"\n")
(with-updated-window
- frame 'SCROLL-Y-RELATIVE!
+ screen frame 'SCROLL-Y-RELATIVE!
(lambda (widget)
(let ((view (fix-layout-view widget))
(delta* (row->y screen delta)))
frame mark force?)
(%trace "; screen/set-window-start-mark! "screen" "frame" "mark" "force?"\n")
(with-updated-window
- frame 'SET-START-MARK!
+ screen frame 'SET-START-MARK!
(lambda (widget)
(let ((view (fix-layout-view widget))
(line (find-line-at mark widget)))
(define-method screen/window-mark-visible? ((screen <gtk-screen>) frame mark)
(%trace "; screen/window-mark-visible? "screen" "frame" "mark"\n")
(with-updated-window
- frame 'MARK-VISIBLE?
+ screen frame 'MARK-VISIBLE?
(lambda (widget)
(let ((view (fix-layout-view widget))
(line (find-line-at mark widget)))
(define-method screen/window-mark->y ((screen <gtk-screen>) frame mark)
(%trace "; screen/window-mark->y "screen" "frame" "mark"\n")
(with-updated-window
- frame 'MARK->Y
+ screen frame 'MARK->Y
(lambda (widget)
(line->row screen widget (find-line-at mark widget)))))
frame mark)
(%trace "; screen/window-mark->coordinates "screen" "frame" "mark"\n")
(with-updated-window
- frame 'MARK->COORDINATES
+ screen frame 'MARK->COORDINATES
(lambda (widget)
(let ((line (find-line-at mark widget)))
(cons
frame x y)
(%trace "; screen/window-coordinates->mark "screen" "frame" "x" "y"\n")
(with-updated-window
- frame 'COORDINATES->MARK
+ screen frame 'COORDINATES->MARK
(lambda (widget)
(let* ((y* (fix:+ (row->y screen y)
(fix-rect-y (fix-layout-view widget))))
(define-method update-screen! ((screen <gtk-screen>) display-style)
(%trace "; (update-screen! <gtk-screen>) "screen" "display-style"\n")
- (cond
- ((display-style/no-screen-output? display-style)
- (%trace "; (update-screen! <gtk-screen>) done: no-output\n")
- 'NO-OUTPUT)
- ((eq? (screen-visibility screen) 'OBSCURED)
- (update-name screen)
- (%trace "; (update-screen! <gtk-screen>) done: completely obscured\n")
- 'INVISIBLE)
- (else
- (update-name screen)
- (update-widgets screen)
- (and (begin
- (%trace "; update drawings\n")
- (for-each-text-widget screen update-widget-drawing)
- (if (every (lambda (entry) (update-drawing screen (cdr entry)))
- (gtk-screen-drawings screen))
- (begin
- (%trace "; update drawings done\n")
- #t)
- (begin
- (%trace "; (update-screen! <gtk-screen>) done: halted\n")
- #f)))
- ;; From here on, drawings are up-to-date, a change region
- ;; notwithstanding.
- (fluid-let ((ignore-change-region #t))
- (%trace "; update windows\n")
- (for-each-text-widget screen update-window)
- (if (display-style/discard-screen-contents? display-style)
- (for-each-text-widget screen gtk-widget-queue-draw))
- (update-blinking screen)
- (%trace "; (update-screen! <gtk-screen>) done: finished\n")
- #t)))))
+ (with-screen-in-update
+ screen
+ (lambda ()
+ (cond
+ ((display-style/no-screen-output? display-style)
+ (%trace "; (update-screen! <gtk-screen>) done: no-output\n")
+ 'NO-OUTPUT)
+ ((eq? (screen-visibility screen) 'OBSCURED)
+ (update-name screen)
+ (%trace "; (update-screen! <gtk-screen>) done: completely obscured\n")
+ 'INVISIBLE)
+ (else
+ (update-name screen)
+ (update-widgets screen)
+ (and (begin
+ (%trace "; update drawings\n")
+ (for-each-text-widget screen update-widget-buffer)
+ (if (every (lambda (entry) (update-drawing screen (cdr entry)))
+ (gtk-screen-drawings screen))
+ (begin
+ (%trace "; update drawings done\n")
+ #t)
+ (begin
+ (%trace "; (update-screen! <gtk-screen>) done: halted\n")
+ #f)))
+ ;; From here on, drawings are up-to-date, a change region
+ ;; notwithstanding.
+ (fluid-let ((ignore-change-region #t))
+ (%trace "; update windows\n")
+ (for-each-text-widget screen update-window)
+ (if (display-style/discard-screen-contents? display-style)
+ (for-each-text-widget screen gtk-widget-queue-draw))
+ (update-blinking screen)
+ (%trace "; (update-screen! <gtk-screen>) done: finished\n")
+ #t)))))))
+
+(define-integrable with-screen-in-update
+ (named-lambda (with-screen-in-update screen thunk)
+ (if (screen-in-update? screen)
+ (error "Recursive update:" screen))
+ (set-screen-in-update?! screen #t)
+ (let ((v (thunk)))
+ (set-screen-in-update?! screen #f)
+ v)))
(define (update-blinking screen)
;; Sometimes called by a callback (i.e. without-interrupts). Frobs
(define-method update-screen-window!
((screen <gtk-screen>) window display-style)
(%trace "; (update-screen-window! <gtk-screen>) "screen" "window"\n")
- (cond
- ((display-style/no-screen-output? display-style)
- (%trace "; display-style: no-output\n")
- 'NO-OUTPUT)
- ((not (memq (screen-visibility screen) '(VISIBLE PARTIALLY-OBSCURED)))
- (update-name screen)
- (%trace "; display-style: completely obscured\n")
- 'INVISIBLE)
- ((null? (gtk-container-reverse-children (gtk-screen-toplevel screen)))
- (%trace "; uninitialized "screen"\n")
- 'UNINITIALIZED)
- (else
- (update-name screen)
- (let ((widget (window-text-widget* window)))
- (if (not widget) (error "No widget:" window))
- (let ((drawing (text-widget-buffer-drawing widget)))
- (if (not drawing) (error "No drawing:" widget))
- (if (update-drawing screen drawing)
- (fluid-let ((ignore-change-region #t))
- (%trace "; redraw finished\n")
- (update-window widget)
- (if (display-style/discard-screen-contents? display-style)
- (gtk-widget-queue-draw widget))
- (gdk-window-process-updates (fix-layout-window widget) #f)
- (%trace "; (update-screen-window! <gtk-screen>) done: finished\n")
- #t)
- (begin
- (%trace "; (update-screen-window! <gtk-screen>) done: halted\n")
- #f)))))))
+ (let ((v (update-screens! display-style)))
+ (%trace "; (update-screen-window! <gtk-screen>) "screen" "window" => "v"\n")
+ v))
(define (update-widget-buffer widget)
(%trace "; update-widget-buffer "widget"\n")