diff options
| author | Richard M. Stallman | 1997-05-26 06:22:15 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-05-26 06:22:15 +0000 |
| commit | 9829ddba7bb78968059a4de4cf956ab5f12a6a2d (patch) | |
| tree | 49faa8767a83bff2fe73dfc8ba3643c122789f11 /src | |
| parent | 62a7e6ebb4f1cd377aacdf690d92b336dc73107a (diff) | |
| download | emacs-9829ddba7bb78968059a4de4cf956ab5f12a6a2d.tar.gz emacs-9829ddba7bb78968059a4de4cf956ab5f12a6a2d.zip | |
(x_make_frame_visible): Call x_set_offset only after
mapping the window and accepting input.
(x_calc_absolute_position): Do nothing if current position
is already for the top-left corner.
Handle errors in XTranslateCoordinates.
(XTread_socket): Simplify handling of ConfigureNotify events.
Always call x_wm_set_size_hint for them.
No need to call XTranslateCoordinates here.
(x_clear_errors): New function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xterm.c | 135 |
1 files changed, 69 insertions, 66 deletions
diff --git a/src/xterm.c b/src/xterm.c index a375af6aa5e..b191769135b 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -4343,12 +4343,8 @@ XTread_socket (sd, bufp, numchars, expected) | |||
| 4343 | goto OTHER; | 4343 | goto OTHER; |
| 4344 | 4344 | ||
| 4345 | case ConfigureNotify: | 4345 | case ConfigureNotify: |
| 4346 | f = x_any_window_to_frame (dpyinfo, event.xconfigure.window); | 4346 | f = x_top_window_to_frame (dpyinfo, event.xconfigure.window); |
| 4347 | if (f | 4347 | if (f) |
| 4348 | #ifdef USE_X_TOOLKIT | ||
| 4349 | && (event.xconfigure.window == XtWindow (f->output_data.x->widget)) | ||
| 4350 | #endif | ||
| 4351 | ) | ||
| 4352 | { | 4348 | { |
| 4353 | #ifndef USE_X_TOOLKIT | 4349 | #ifndef USE_X_TOOLKIT |
| 4354 | /* In the toolkit version, change_frame_size | 4350 | /* In the toolkit version, change_frame_size |
| @@ -4372,43 +4368,8 @@ XTread_socket (sd, bufp, numchars, expected) | |||
| 4372 | } | 4368 | } |
| 4373 | #endif | 4369 | #endif |
| 4374 | 4370 | ||
| 4375 | /* Formerly, in the USE_X_TOOLKIT version, | ||
| 4376 | we did not test send_event here. */ | ||
| 4377 | if (1 | ||
| 4378 | #ifndef USE_X_TOOLKIT | ||
| 4379 | && ! event.xconfigure.send_event | ||
| 4380 | #endif | ||
| 4381 | ) | ||
| 4382 | { | ||
| 4383 | Window win, child; | ||
| 4384 | int win_x, win_y; | ||
| 4385 | |||
| 4386 | /* Find the position of the outside upper-left corner of | ||
| 4387 | the window, in the root coordinate system. Don't | ||
| 4388 | refer to the parent window here; we may be processing | ||
| 4389 | this event after the window manager has changed our | ||
| 4390 | parent, but before we have reached the ReparentNotify. */ | ||
| 4391 | XTranslateCoordinates (FRAME_X_DISPLAY (f), | ||
| 4392 | |||
| 4393 | /* From-window, to-window. */ | ||
| 4394 | event.xconfigure.window, | ||
| 4395 | FRAME_X_DISPLAY_INFO (f)->root_window, | ||
| 4396 | |||
| 4397 | /* From-position, to-position. */ | ||
| 4398 | -event.xconfigure.border_width, | ||
| 4399 | -event.xconfigure.border_width, | ||
| 4400 | &win_x, &win_y, | ||
| 4401 | |||
| 4402 | /* Child of win. */ | ||
| 4403 | &child); | ||
| 4404 | event.xconfigure.x = win_x; | ||
| 4405 | event.xconfigure.y = win_y; | ||
| 4406 | } | ||
| 4407 | |||
| 4408 | f->output_data.x->pixel_width = event.xconfigure.width; | 4371 | f->output_data.x->pixel_width = event.xconfigure.width; |
| 4409 | f->output_data.x->pixel_height = event.xconfigure.height; | 4372 | f->output_data.x->pixel_height = event.xconfigure.height; |
| 4410 | f->output_data.x->left_pos = event.xconfigure.x; | ||
| 4411 | f->output_data.x->top_pos = event.xconfigure.y; | ||
| 4412 | 4373 | ||
| 4413 | /* What we have now is the position of Emacs's own window. | 4374 | /* What we have now is the position of Emacs's own window. |
| 4414 | Convert that to the position of the window manager window. */ | 4375 | Convert that to the position of the window manager window. */ |
| @@ -4417,17 +4378,17 @@ XTread_socket (sd, bufp, numchars, expected) | |||
| 4417 | x_real_positions (f, &x, &y); | 4378 | x_real_positions (f, &x, &y); |
| 4418 | f->output_data.x->left_pos = x; | 4379 | f->output_data.x->left_pos = x; |
| 4419 | f->output_data.x->top_pos = y; | 4380 | f->output_data.x->top_pos = y; |
| 4420 | /* Formerly we did not do this in the USE_X_TOOLKIT | 4381 | #if 0 |
| 4421 | version. Let's try making them the same. */ | ||
| 4422 | /* #ifndef USE_X_TOOLKIT */ | ||
| 4423 | if (y != event.xconfigure.y) | 4382 | if (y != event.xconfigure.y) |
| 4424 | { | 4383 | { |
| 4384 | #endif | ||
| 4425 | /* Since the WM decorations come below top_pos now, | 4385 | /* Since the WM decorations come below top_pos now, |
| 4426 | we must put them below top_pos in the future. */ | 4386 | we must put them below top_pos in the future. */ |
| 4427 | f->output_data.x->win_gravity = NorthWestGravity; | 4387 | f->output_data.x->win_gravity = NorthWestGravity; |
| 4428 | x_wm_set_size_hint (f, (long) 0, 0); | 4388 | x_wm_set_size_hint (f, (long) 0, 0); |
| 4389 | #if 0 | ||
| 4429 | } | 4390 | } |
| 4430 | /* #endif */ | 4391 | #endif |
| 4431 | } | 4392 | } |
| 4432 | } | 4393 | } |
| 4433 | goto OTHER; | 4394 | goto OTHER; |
| @@ -5030,8 +4991,8 @@ x_check_errors (dpy, format) | |||
| 5030 | error (format, XSTRING (x_error_message_string)->data); | 4991 | error (format, XSTRING (x_error_message_string)->data); |
| 5031 | } | 4992 | } |
| 5032 | 4993 | ||
| 5033 | /* Nonzero if we had any X protocol errors on DPY | 4994 | /* Nonzero if we had any X protocol errors |
| 5034 | since we did x_catch_errors. */ | 4995 | since we did x_catch_errors on DPY. */ |
| 5035 | 4996 | ||
| 5036 | int | 4997 | int |
| 5037 | x_had_errors_p (dpy) | 4998 | x_had_errors_p (dpy) |
| @@ -5043,6 +5004,15 @@ x_had_errors_p (dpy) | |||
| 5043 | return XSTRING (x_error_message_string)->data[0] != 0; | 5004 | return XSTRING (x_error_message_string)->data[0] != 0; |
| 5044 | } | 5005 | } |
| 5045 | 5006 | ||
| 5007 | /* Forget about any errors we have had, since we did x_catch_errors on DPY. */ | ||
| 5008 | |||
| 5009 | int | ||
| 5010 | x_clear_errors (dpy) | ||
| 5011 | Display *dpy; | ||
| 5012 | { | ||
| 5013 | XSTRING (x_error_message_string)->data[0] = 0; | ||
| 5014 | } | ||
| 5015 | |||
| 5046 | /* Stop catching X protocol errors and let them make Emacs die. | 5016 | /* Stop catching X protocol errors and let them make Emacs die. |
| 5047 | DPY should be the display that was passed to x_catch_errors. | 5017 | DPY should be the display that was passed to x_catch_errors. |
| 5048 | COUNT should be the value that was returned by | 5018 | COUNT should be the value that was returned by |
| @@ -5301,6 +5271,11 @@ x_calc_absolute_position (f) | |||
| 5301 | int flags = f->output_data.x->size_hint_flags; | 5271 | int flags = f->output_data.x->size_hint_flags; |
| 5302 | int this_window; | 5272 | int this_window; |
| 5303 | 5273 | ||
| 5274 | /* We have nothing to do if the current position | ||
| 5275 | is already for the top-left corner. */ | ||
| 5276 | if (! ((flags & XNegative) || (flags & YNegative))) | ||
| 5277 | return; | ||
| 5278 | |||
| 5304 | #ifdef USE_X_TOOLKIT | 5279 | #ifdef USE_X_TOOLKIT |
| 5305 | this_window = XtWindow (f->output_data.x->widget); | 5280 | this_window = XtWindow (f->output_data.x->widget); |
| 5306 | #else | 5281 | #else |
| @@ -5308,21 +5283,47 @@ x_calc_absolute_position (f) | |||
| 5308 | #endif | 5283 | #endif |
| 5309 | 5284 | ||
| 5310 | /* Find the position of the outside upper-left corner of | 5285 | /* Find the position of the outside upper-left corner of |
| 5311 | the inner window, with respect to the outer window. */ | 5286 | the inner window, with respect to the outer window. |
| 5287 | But do this only if we will need the results. */ | ||
| 5312 | if (f->output_data.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window) | 5288 | if (f->output_data.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window) |
| 5313 | { | 5289 | { |
| 5290 | int count; | ||
| 5291 | |||
| 5314 | BLOCK_INPUT; | 5292 | BLOCK_INPUT; |
| 5315 | XTranslateCoordinates (FRAME_X_DISPLAY (f), | 5293 | count = x_catch_errors (FRAME_X_DISPLAY (f)); |
| 5294 | while (1) | ||
| 5295 | { | ||
| 5296 | x_clear_errors (FRAME_X_DISPLAY (f)); | ||
| 5297 | XTranslateCoordinates (FRAME_X_DISPLAY (f), | ||
| 5298 | |||
| 5299 | /* From-window, to-window. */ | ||
| 5300 | this_window, | ||
| 5301 | f->output_data.x->parent_desc, | ||
| 5302 | |||
| 5303 | /* From-position, to-position. */ | ||
| 5304 | 0, 0, &win_x, &win_y, | ||
| 5305 | |||
| 5306 | /* Child of win. */ | ||
| 5307 | &child); | ||
| 5308 | if (x_had_errors_p (FRAME_X_DISPLAY (f))) | ||
| 5309 | { | ||
| 5310 | Window newroot, newparent = 0xdeadbeef; | ||
| 5311 | Window *newchildren; | ||
| 5312 | int nchildren; | ||
| 5313 | |||
| 5314 | if (! XQueryTree (FRAME_X_DISPLAY (f), this_window, &newroot, | ||
| 5315 | &newparent, &newchildren, &nchildren)) | ||
| 5316 | break; | ||
| 5316 | 5317 | ||
| 5317 | /* From-window, to-window. */ | 5318 | XFree (newchildren); |
| 5318 | this_window, | ||
| 5319 | f->output_data.x->parent_desc, | ||
| 5320 | 5319 | ||
| 5321 | /* From-position, to-position. */ | 5320 | f->output_data.x->parent_desc = newparent; |
| 5322 | 0, 0, &win_x, &win_y, | 5321 | } |
| 5322 | else | ||
| 5323 | break; | ||
| 5324 | } | ||
| 5323 | 5325 | ||
| 5324 | /* Child of win. */ | 5326 | x_uncatch_errors (FRAME_X_DISPLAY (f), count); |
| 5325 | &child); | ||
| 5326 | UNBLOCK_INPUT; | 5327 | UNBLOCK_INPUT; |
| 5327 | } | 5328 | } |
| 5328 | 5329 | ||
| @@ -5627,16 +5628,6 @@ x_make_frame_visible (f) | |||
| 5627 | 5628 | ||
| 5628 | if (! FRAME_VISIBLE_P (f)) | 5629 | if (! FRAME_VISIBLE_P (f)) |
| 5629 | { | 5630 | { |
| 5630 | /* We test FRAME_GARBAGED_P here to make sure we don't | ||
| 5631 | call x_set_offset a second time | ||
| 5632 | if we get to x_make_frame_visible a second time | ||
| 5633 | before the window gets really visible. */ | ||
| 5634 | if (! FRAME_ICONIFIED_P (f) | ||
| 5635 | && ! f->output_data.x->asked_for_visible) | ||
| 5636 | x_set_offset (f, f->output_data.x->left_pos, f->output_data.x->top_pos, 0); | ||
| 5637 | |||
| 5638 | f->output_data.x->asked_for_visible = 1; | ||
| 5639 | |||
| 5640 | if (! EQ (Vx_no_window_manager, Qt)) | 5631 | if (! EQ (Vx_no_window_manager, Qt)) |
| 5641 | x_wm_set_window_state (f, NormalState); | 5632 | x_wm_set_window_state (f, NormalState); |
| 5642 | #ifdef USE_X_TOOLKIT | 5633 | #ifdef USE_X_TOOLKIT |
| @@ -5661,10 +5652,22 @@ x_make_frame_visible (f) | |||
| 5661 | { | 5652 | { |
| 5662 | Lisp_Object frame; | 5653 | Lisp_Object frame; |
| 5663 | int count = input_signal_count; | 5654 | int count = input_signal_count; |
| 5655 | int orig_left = f->output_data.x->left_pos; | ||
| 5656 | int orig_top = f->output_data.x->top_pos; | ||
| 5664 | 5657 | ||
| 5665 | /* This must come after we set COUNT. */ | 5658 | /* This must come after we set COUNT. */ |
| 5666 | UNBLOCK_INPUT; | 5659 | UNBLOCK_INPUT; |
| 5667 | 5660 | ||
| 5661 | /* We test asked_for_visible here to make sure we don't | ||
| 5662 | call x_set_offset a second time | ||
| 5663 | if we get to x_make_frame_visible a second time | ||
| 5664 | before the window gets really visible. */ | ||
| 5665 | if (! FRAME_ICONIFIED_P (f) | ||
| 5666 | && ! f->output_data.x->asked_for_visible) | ||
| 5667 | x_set_offset (f, orig_left, orig_top, 0); | ||
| 5668 | |||
| 5669 | f->output_data.x->asked_for_visible = 1; | ||
| 5670 | |||
| 5668 | XSETFRAME (frame, f); | 5671 | XSETFRAME (frame, f); |
| 5669 | 5672 | ||
| 5670 | while (1) | 5673 | while (1) |