unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#65025: Possible race in make-frame
@ 2023-08-02 14:02 Anders Blomdell via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-08-02 17:51 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Anders Blomdell via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-08-02 14:02 UTC (permalink / raw)
  To: 65025

When running

   /usr/bin/emacsclient --eval '(make-frame)'

it sometimes (often) opens up a small window (10x21) instead of the expected 40x80 window.

Setting a hook for after-make-frame-functions like this:

(progn
   (setq after-make-frame-functions nil)
   (add-hook
    'after-make-frame-functions
    (lambda (frame)
      (let ((width 80)
            (height 40)
            (start-width (frame-width frame))
            (start-height (frame-height frame))
            (visible (frame-visible-p frame)))
        (print (format "Start %dx%d %S"
                       start-height start-width visible))
        (if (not visible)
            (progn
              (while
                  (not (frame-visible-p frame))
                (progn
                  (sleep-for 0.001)
                  (print (format "X %dx%d"
                                 (frame-height frame)
                                 (frame-width frame)))
                  ))
              (sleep-for 0.001)
              (print (format "Resetting %dx%d -> %dx%d"
                             (frame-height frame) (frame-width frame)
                             height width))
              (set-frame-width frame width)
              (set-frame-height frame height)
              (sleep-for 0.1)
              (print (format "Resetting %dx%d -> %dx%d"
                             (frame-height frame) (frame-width frame)
                             height width))
              (set-frame-width frame width)
              (set-frame-height frame height)
              )
              )
          )
        (print (format "Done %dx%d"
                       (frame-height frame)
                       (frame-width frame)))
        )
    )
   )



usually has two different outcomes:

   "Start 10x38 t"
   "Done 10x38"

or

   "Start 40x80 nil"
   "X 40x80"
   "X 40x80"
   "X 40x80"
   "X 10x21"
   "Resetting 10x21 -> 40x80"
   "Resetting 40x80 -> 40x80"
   "Done 40x80"





-- 
Anders Blomdell                  Email: anders.blomdell@control.lth.se
Department of Automatic Control
Lund University                  Phone:    +46 46 222 8793
P.O. Box 118
SE-221 00 Lund, Sweden





^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#65025: Possible race in make-frame
  2023-08-02 14:02 bug#65025: Possible race in make-frame Anders Blomdell via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-08-02 17:51 ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2023-08-02 17:51 UTC (permalink / raw)
  To: Anders Blomdell; +Cc: 65025

> Date: Wed, 2 Aug 2023 16:02:06 +0200
> From:  Anders Blomdell via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> When running
> 
>    /usr/bin/emacsclient --eval '(make-frame)'
> 
> it sometimes (often) opens up a small window (10x21) instead of the expected 40x80 window.
> 
> Setting a hook for after-make-frame-functions like this:
> 
> (progn
>    (setq after-make-frame-functions nil)
>    (add-hook
>     'after-make-frame-functions
>     (lambda (frame)
>       (let ((width 80)
>             (height 40)
>             (start-width (frame-width frame))
>             (start-height (frame-height frame))
>             (visible (frame-visible-p frame)))
>         (print (format "Start %dx%d %S"
>                        start-height start-width visible))
>         (if (not visible)
>             (progn
>               (while
>                   (not (frame-visible-p frame))
>                 (progn
>                   (sleep-for 0.001)
>                   (print (format "X %dx%d"
>                                  (frame-height frame)
>                                  (frame-width frame)))
>                   ))
>               (sleep-for 0.001)
>               (print (format "Resetting %dx%d -> %dx%d"
>                              (frame-height frame) (frame-width frame)
>                              height width))
>               (set-frame-width frame width)
>               (set-frame-height frame height)
>               (sleep-for 0.1)
>               (print (format "Resetting %dx%d -> %dx%d"
>                              (frame-height frame) (frame-width frame)
>                              height width))
>               (set-frame-width frame width)
>               (set-frame-height frame height)
>               )
>               )
>           )
>         (print (format "Done %dx%d"
>                        (frame-height frame)
>                        (frame-width frame)))
>         )
>     )
>    )
> 
> 
> 
> usually has two different outcomes:
> 
>    "Start 10x38 t"
>    "Done 10x38"
> 
> or
> 
>    "Start 40x80 nil"
>    "X 40x80"
>    "X 40x80"
>    "X 40x80"
>    "X 10x21"
>    "Resetting 10x21 -> 40x80"
>    "Resetting 40x80 -> 40x80"
>    "Done 40x80"

Isn't this because we wait fro X to resize the frame after we ask for
it?





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-02 17:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-02 14:02 bug#65025: Possible race in make-frame Anders Blomdell via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-02 17:51 ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).