all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Bug in CVS Emacs frame positioning under X
@ 2006-03-22  3:33 Francis Litterio
  2006-03-22 13:44 ` Richard Stallman
  0 siblings, 1 reply; 23+ messages in thread
From: Francis Litterio @ 2006-03-22  3:33 UTC (permalink / raw)


In the latest CVS Emacs under X, there seems to be a frame positioning bug that
is timing related.  It doesn't happen deterministically, and I'm still trying to
create a test case that reproduces the problem.  However, I added some printf()s
to the code in src/xterm.c, and I've seen the following things happen in this
order:

0. Assume a frame is positioned at x/y location 50/50.

1. The user executes a command that positions the frame by doing something like
   this:

	(set-frame-position theframe 200 200)

2. In src/xterm.c, x_set_offset() is called.

3. x_set_offset() calls XMoveWindow(..., 200, 200).

4. Next, x_set_offset() sees that f->wm_type == X_WMTYPE_UNKNOWN, so it sets
   f->check_expected_move to 1 and stores 200 in f->expected_top and stores 200
   in f->expected_left.  It then returns.

5. Emacs receives a ConfigureNotify event from X, which causes
   handle_one_event() to be called.

6. handle_one_event() calls x_real_positions() to obtain the current real
   x/y location of the frame.  It stores the x offset in f->left_pos and
   the y offset in f->top_pos.  Here is the bug: In some cases, the current
   real x/y location of the frame is 50/50 (i.e., it appears to have not moved
   yet) and in some cases it is 200/200 (i.e., it appears to have moved
   already).

7. handle_one_event() calls x_check_expected_move(), which determines whether
   the window manager is type A or type B.  The difference between type A and B
   window managers is that when positioning a frame to x/y location 0/0, type A
   window managers will put the window decorations at least partly off-screen,
   and type B window managers will not.

8. x_check_expected_move() compares f->expected_top to f->top_pos and
   f->expected_left to f->left_pos.  When f->top_pos is 50 (which it is _some_
   of the time) and f->expected_top is 200, then x_check_expected_move() sets
   f->wm_type to X_WMTYPE_A and sets f->move_offset_top to 150 = 200 - 50.
   Similarly for the 

   From that moment on, all attempts to set the top offset of that frame causes
   150 to be added to the user-supplied top offset!  The same applies for the
   frame's left offset.

When I create a reproduceable test case, I'll send it, but I'm hoping this
description of the problem is enough to perhaps help someone get to the
bottom of the problem.
--
Francis Litterio
flitterio@gmail.com

^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: Bug in CVS Emacs frame positioning under X
@ 2006-03-23 14:53 Francis Litterio
  0 siblings, 0 replies; 23+ messages in thread
From: Francis Litterio @ 2006-03-23 14:53 UTC (permalink / raw)


On 3/22/06, I (Fran Litterio) wrote:

> On 3/22/06, Richard Stallman wrote:
>
> > In the latest CVS Emacs under X, there seems to be a frame positioning bug
> > that is timing related.
> >
> > Does it happen in older CVS versions too?  For instance,
> > did it happen a month ago?  6 months ago?
>
> Unknown. I'll check-out the older sources and rebuild. I'll let you know.

I have checked out the CVS Emacs source code from October 1, 2005, and
the bug existed at that time.  Additionally, I have found a simple way
to reproduce the problem:

  1. Start Emacs under the X Window system using the command: emacs -q

  2. Evaluate the following Elisp:

	(dolist (i '(1 2 3 4 5 6 7 8 9 a b c))
	  (let ((frame (make-frame '((top . 50) (left . 50)))))
	    (set-frame-position frame 200 200)
	    (set-frame-position frame 300 300)
	    (sit-for 0.5)))

You may have to evaluate the above Elisp more than once to see the
malfunction (although I see it every time).

The symptom is that not all of the frames end up positioned at x/y
coordinates 300/300.  Some frames are positioned at 300+A/300+B, where
A is the width of the left border drawn by the window manager and B is
the height of the top border drawn by the window manager.  Some frames
even end up at 400/400 !

I think the cause of this problem is the fact that src/xterm.c assumes
(incorrectly) that, after calling XMoveWindow() for a given frame, the next
ConfigureNotify event to be received for that frame will contain the position
data from the call to XMoveWindow().  In fact, the ConfigureNotify event can
sometimes contain the position of the frame before the call to XMoveWindow()
(this may be a race condition, but I'm not sure).

This incorrect assumption interacts badly with the code in
x_check_expected_move(), which attempts to use the position data from the most
recently received ConfigureNotify to validate that the most recent XMoveWindow()
call correctly positioned the frame.

I don't yet know how to fix this.
--
Fran Litterio

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

end of thread, other threads:[~2006-05-17 20:09 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-22  3:33 Bug in CVS Emacs frame positioning under X Francis Litterio
2006-03-22 13:44 ` Richard Stallman
2006-03-22 13:56   ` Fran Litterio
2006-03-22 21:02     ` Fran Litterio
2006-03-26  0:21       ` Richard Stallman
2006-03-27  6:48         ` Jan Djärv
2006-03-28 16:38         ` Fran Litterio
2006-03-28 16:59           ` Jan Djärv
2006-03-29 23:01           ` Richard Stallman
2006-04-01 15:38             ` Fran Litterio
2006-04-02 20:38               ` Richard Stallman
2006-04-03  7:11               ` Jan D.
2006-04-03  7:32                 ` Jan D.
2006-04-03 18:24                   ` Richard Stallman
2006-04-04  0:42                     ` Fran Litterio
2006-04-04  6:49                       ` Jan D.
2006-04-04 19:57                       ` Richard Stallman
2006-05-08 14:17                         ` Fran Litterio
2006-05-09  4:44                           ` Richard Stallman
2006-05-17 10:13                             ` Fran Litterio
2006-05-17 20:09                               ` Richard Stallman
2006-04-04  6:34                     ` Jan D.
  -- strict thread matches above, loose matches on Subject: below --
2006-03-23 14:53 Francis Litterio

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.