diff --git a/source/clog-gui.lisp b/source/clog-gui.lisp index dd6eef9..91903a4 100644 --- a/source/clog-gui.lisp +++ b/source/clog-gui.lisp @@ -386,7 +386,6 @@ in on-resize, on-full-screen-change and on-orientation-change events.")) (maphash (lambda (key value) (declare (ignore key)) (cond ((window-maximized-p value) - (window-normalize value :focus nil) (window-maximize value :focus nil)) (t (make-in-bounds value mbh bh bw)))) @@ -784,6 +783,14 @@ The on-window-change clog-obj received is the new window")) (set-on-pointer-move obj nil) (set-on-pointer-cancel obj nil) (set-on-pointer-up obj nil) + (cond ((window-maximized-p (drag-obj app)) + (window-maximize (drag-obj app) :focus nil)) + (t + (let* ((body (connection-data-item (drag-obj app) "clog-body")) + (mbh (menu-bar-height (drag-obj app))) + (bh (height (html-document body))) + (bw (width (html-document body)))) + (make-in-bounds (drag-obj app) mbh bh bw)))) (cond ((equalp (in-drag app) "m") (fire-on-window-move-done (drag-obj app))) ((equalp (in-drag app) "s") @@ -1053,26 +1060,27 @@ the browser.")) :focus (default t).")) (defmethod window-maximize ((obj clog-gui-window) &key (focus t)) - (let ((app (connection-data-item obj "clog-gui"))) - (when focus - (unless (keep-on-top obj) - (window-focus obj))) - (when (fire-on-window-can-maximize obj) - (unless (window-maximized-p obj) - (setf (last-x obj) (left obj)) - (setf (last-y obj) (top obj)) - (setf (last-height obj) (height obj)) - (setf (last-width obj) (width obj))) - (setf (top obj) (unit :px (menu-bar-height obj))) - (setf (left obj) (unit :px 0)) - (setf (width obj) (unit :vw 100)) - (setf (left obj) (unit :px (body-left-offset app))) - (setf (width obj) (- (width obj) - (body-left-offset app) - (body-right-offset app))) - (setf (height obj) - (- (inner-height (window (body app))) (menu-bar-height obj))) - (fire-on-window-size-done obj)))) + (with-sync-event (obj) ; prevent race condition of maximize/normalize + (let ((app (connection-data-item obj "clog-gui"))) + (when focus + (unless (keep-on-top obj) + (window-focus obj))) + (when (fire-on-window-can-maximize obj) + (unless (window-maximized-p obj) + (setf (last-x obj) (left obj)) + (setf (last-y obj) (top obj)) + (setf (last-height obj) (height obj)) + (setf (last-width obj) (width obj))) + (setf (top obj) (unit :px (menu-bar-height obj))) + (setf (left obj) (unit :px 0)) + (setf (width obj) (unit :vw 100)) + (setf (left obj) (unit :px (body-left-offset app))) + (setf (width obj) (- (width obj) + (body-left-offset app) + (body-right-offset app))) + (setf (height obj) + (- (inner-height (window (body app))) (menu-bar-height obj))) + (fire-on-window-size-done obj))))) ;;;;;;;;;;;;;;;;;;;;;; ;; window-normalize ;; @@ -1083,17 +1091,18 @@ the browser.")) :focus (default t).")) (defmethod window-normalize ((obj clog-gui-window) &key (focus t)) - (when focus - (unless (keep-on-top obj) - (window-focus obj))) - (when (fire-on-window-can-normalize obj) - (when (window-maximized-p obj) - (setf (width obj) (last-width obj)) - (setf (height obj) (last-height obj)) - (setf (top obj) (last-y obj)) - (setf (left obj) (last-x obj)) - (setf (last-width obj) nil) - (fire-on-window-size-done obj)))) + (with-sync-event (obj) ; prevent race condition of maximize/normalize + (when focus + (unless (keep-on-top obj) + (window-focus obj))) + (when (fire-on-window-can-normalize obj) + (when (window-maximized-p obj) + (setf (width obj) (last-width obj)) + (setf (height obj) (last-height obj)) + (setf (top obj) (last-y obj)) + (setf (left obj) (last-x obj)) + (setf (last-width obj) nil) + (fire-on-window-size-done obj))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; window-toggle-maximize ;; @@ -1399,15 +1408,6 @@ interactions. Use window-end-modal to undo.")) (setf (on-window-move-done obj) handler)) (defmethod fire-on-window-move-done ((obj clog-gui-window)) - (cond ((window-maximized-p obj) - (window-normalize obj :focus nil) - (window-maximize obj :focus nil)) - (t - (let* ((body (connection-data-item obj "clog-body")) - (mbh (menu-bar-height obj)) - (bh (height (html-document body))) - (bw (width (html-document body)))) - (make-in-bounds obj mbh bh bw)))) (when (on-window-move-done obj) (funcall (on-window-move-done obj) obj)))