[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Frame size changes

From: Jan Djärv
Subject: Re: Frame size changes
Date: Fri, 03 Oct 2008 09:08:21 +0200
User-agent: Thunderbird (X11/20080925)

Chong Yidong skrev:
> For a while, there's been a bug regarding erratic frame sizing: see
> bug#598, possibly also bug#708.
> I've been able to reproduce this using the Terminus font (for those
> using Debian or Ubuntu, this is from the xfonts-terminus package).  When
> this font is used, the initial frame size is unpredictable.
> This seems to arise from ConfigureNotify events that Emacs receives,
> which causes its frame size in rows/columns to change (because of the
> ConfigureNotify event, handle_one_xevent (xterm.c:6774) calls
> xg_frame_resized (gtkutil.c:642), which changes the frame size.
> I don't know why these ConfigureNotify events are issued.  It's strange,
> because none of the changes during the startup process ought to change
> the number or rows/columns in the initial frame.  Another strange thing
> is that this happens with the Terminus font, but not other fonts I've
> tried.
> Does anyone have ideas about what's causing this?

If this only happens for the first frame but not for frames created later, I
think it is the interraction between Emacs and the window manager and the fact
that Emacs adjust frame size a lot during startup.

Something like this:
Emacs calculates the frame size based on some initial font, and sets wm
manager hints based on that (i.e. restricts width/height to a multiple of the
font width/height).

Then Emacs reads .emacs and that changes the font, thus a new size and a new
wm hints is calculated and a new frame size is set.

To complicate things further, either the tool bar and/or the menu bar may be
added/removed, thus the frame size is changed again.

The window manager applies the size hints and sends configure notify to Emacs
when it does.  But if Emacs has read the second font size before the
ConfigureNotify for the first font size changes arrives, things get strange.
The window manager bases the size on the first font, but Emacs bases it on the
second.  So when Emacs tries to cope, it probably does a resize again (because
the fonts sizes differ and we want the frame to be a multiple of the font
size).  This may lead to another ConfigureNotify, which may be based on the
first or second font size (resize from Emacs and setting of wm hints does not
go the same way and can be seen out of order by the WM), there is a race
there.  And the same thing happens again.

This should not happen on frames created after the first one, because at that
point we know the font to use, so no font changes (and wm hint changes) needs
to take place.

This is tricky.  Iäve tried many solutions but they all fail in some case or
another, or with some WM (this is WM dependent also).  I think the only proper
solution to this is to make Emacs read .emacs before it maps the first frame.

        Jan D.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]