unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] problems with initial resizing of the GTK emacs window (needs review)
@ 2010-03-03  0:43 Michael Stapelberg
       [not found] ` <4B8E1475.8020304@swipnet.se>
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Stapelberg @ 2010-03-03  0:43 UTC (permalink / raw)
  To: emacs-devel

Hi emacs developers,

while debugging a problem with emacs running under the i3 window manager [1],
I think I found a bug in emacs itself.

The symptoms are that an emacs window does not display the whole contents
(the bottom bar is missing, don’t know what you call it exactly) of its
window most of the time (sometimes it works, so it’s a classical race
condition).

Further digging showed that this is a problem because emacs uses the wrong
text_lines for a frame. This seems to be caused by this effect:

In redisplay(), the call graph eventually arrives at update_frame_tool_bar()
which then calls xg_frame_set_char_size. A possible problem here *may* be
(this was my first attempt to patch the problem, but I did not remove the
code before testing my second attempt, so this may or may be not necessary)
that FRAME_LINES(f) and FRAME_COLS(f) is used, even though f->new_text_lines
may not be 0. A patch for this looks like this:

--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -4160,7 +4160,11 @@ update_frame_tool_bar (f)
       && ! FRAME_X_OUTPUT (f)->toolbar_detached)
     {
       FRAME_TOOLBAR_HEIGHT (f) = new_req.height;
-      xg_frame_set_char_size (f, FRAME_COLS (f), FRAME_LINES (f));
+
+      int height = (f->new_text_lines ? f->new_text_lines : FRAME_LINES (f));
+      int width = (f->new_text_cols ? f->new_text_cols : FRAME_COLS (f));
+
+      xg_frame_set_char_size (f, width, height);
     }
 
   UNBLOCK_INPUT;


This alone did not do the trick, however. So, when having a look at
xg_frame_set_char_size(), I noticed that x_wm_size_hint_off() is called. In
x_wm_size_hint_off(), the function flush_and_sync() is called, which in
turn processes *new* events sent by the X server. These events can be
ConfigureNotify events, which lead to recalculation of the number of lines
and columns. While the event is handled properly (say the amount of lines
is recalculated to 37 instead of 40), after returning to
xg_frame_set_char_size(), the gtk window is resized (src/gtkutil.c:737),
which leads to the rendering problems I mentioned.

So, a fix for this could either be:
1) Remove the x_wm_size_hint_off() function entirely, as I don’t see why it
   should be needed. Maybe you can enlighten me on that one.
2) Don’t flush/sync in x_wm_size_hint_off() and ensure that the caller
   flushes/syncs after he did all outstanding requests (in this case,
   resizing the window and changing the rows/cols).

To reproduce the problem, here are the steps I took:
1) Install i3-wm and emacs23 on debian testing (versions are i3-wm 3.d-bf1
   and emacs23 23.1+1-5)
2) Start emacs23-x, see that the bottom bar is not rendered correctly.

Best regards,
Michael

[1] http://i3.zekjur.net/




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

* Re: [PATCH] problems with initial resizing of the GTK emacs window (needs review)
       [not found] ` <4B8E1475.8020304@swipnet.se>
@ 2010-03-03  9:12   ` Michael Stapelberg
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Stapelberg @ 2010-03-03  9:12 UTC (permalink / raw)
  To: Jan D.; +Cc: emacs-devel

Hi Jan,

Excerpts from Jan D.'s message of Mi Mär 03 08:49:09 +0100 2010:
> Your Emacs seems to be 23.1.  That version will not be updated, we are 
> releasing 23.2 soon.  You should try the trunk version instead.
In the trunk version, this problem does not seem to happen anymore. Thanks
for the hint.

Best regards,
Michael




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

end of thread, other threads:[~2010-03-03  9:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-03  0:43 [PATCH] problems with initial resizing of the GTK emacs window (needs review) Michael Stapelberg
     [not found] ` <4B8E1475.8020304@swipnet.se>
2010-03-03  9:12   ` Michael Stapelberg

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).