Mercurial > emacs
comparison src/window.c @ 87847:800f21c9f989
(set_window_buffer): Don't unnecessarily reset hscroll and
vscroll if we're setting window-buffer to the value it already has.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sat, 19 Jan 2008 05:11:02 +0000 |
parents | 107ccd98fa12 |
children | 449ffc76e463 |
comparison
equal
deleted
inserted
replaced
87846:50aec4a9ce08 | 87847:800f21c9f989 |
---|---|
3319 int run_hooks_p, keep_margins_p; | 3319 int run_hooks_p, keep_margins_p; |
3320 { | 3320 { |
3321 struct window *w = XWINDOW (window); | 3321 struct window *w = XWINDOW (window); |
3322 struct buffer *b = XBUFFER (buffer); | 3322 struct buffer *b = XBUFFER (buffer); |
3323 int count = SPECPDL_INDEX (); | 3323 int count = SPECPDL_INDEX (); |
3324 int samebuf = EQ (buffer, w->buffer); | |
3324 | 3325 |
3325 w->buffer = buffer; | 3326 w->buffer = buffer; |
3326 | 3327 |
3327 if (EQ (window, selected_window)) | 3328 if (EQ (window, selected_window)) |
3328 b->last_selected_window = window; | 3329 b->last_selected_window = window; |
3337 | 3338 |
3338 XSETFASTINT (w->window_end_pos, 0); | 3339 XSETFASTINT (w->window_end_pos, 0); |
3339 XSETFASTINT (w->window_end_vpos, 0); | 3340 XSETFASTINT (w->window_end_vpos, 0); |
3340 bzero (&w->last_cursor, sizeof w->last_cursor); | 3341 bzero (&w->last_cursor, sizeof w->last_cursor); |
3341 w->window_end_valid = Qnil; | 3342 w->window_end_valid = Qnil; |
3342 w->hscroll = w->min_hscroll = make_number (0); | 3343 if (!(keep_margins_p && samebuf)) |
3343 w->vscroll = 0; | 3344 { /* If we're not actually changing the buffer, Don't reset hscroll and |
3344 set_marker_both (w->pointm, buffer, BUF_PT (b), BUF_PT_BYTE (b)); | 3345 vscroll. This case happens for example when called from |
3345 set_marker_restricted (w->start, | 3346 change_frame_size_1, where we use a dummy call to |
3346 make_number (b->last_window_start), | 3347 Fset_window_buffer on the frame's selected window (and no other) |
3347 buffer); | 3348 just in order to run window-configuration-change-hook. |
3348 w->start_at_line_beg = Qnil; | 3349 Resetting hscroll and vscroll here is problematic for things like |
3349 w->force_start = Qnil; | 3350 image-mode and doc-view-mode since it resets the image's position |
3350 XSETFASTINT (w->last_modified, 0); | 3351 whenever we resize the frame. */ |
3351 XSETFASTINT (w->last_overlay_modified, 0); | 3352 w->hscroll = w->min_hscroll = make_number (0); |
3353 w->vscroll = 0; | |
3354 set_marker_both (w->pointm, buffer, BUF_PT (b), BUF_PT_BYTE (b)); | |
3355 set_marker_restricted (w->start, | |
3356 make_number (b->last_window_start), | |
3357 buffer); | |
3358 w->start_at_line_beg = Qnil; | |
3359 w->force_start = Qnil; | |
3360 XSETFASTINT (w->last_modified, 0); | |
3361 XSETFASTINT (w->last_overlay_modified, 0); | |
3362 } | |
3363 /* Maybe we could move this into the `if' but it's not obviously safe and | |
3364 I doubt it's worth the trouble. */ | |
3352 windows_or_buffers_changed++; | 3365 windows_or_buffers_changed++; |
3353 | 3366 |
3354 /* We must select BUFFER for running the window-scroll-functions. | 3367 /* We must select BUFFER for running the window-scroll-functions. |
3355 If WINDOW is selected, switch permanently. | 3368 If WINDOW is selected, switch permanently. |
3356 Otherwise, switch but go back to the ambient buffer afterward. */ | 3369 Otherwise, switch but go back to the ambient buffer afterward. */ |