aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.c
diff options
context:
space:
mode:
authorKaroly Lorentey2005-12-03 14:25:50 +0000
committerKaroly Lorentey2005-12-03 14:25:50 +0000
commit9ef706664e98e37e9633712126bae99869904677 (patch)
tree193bce7424700e4c7d70f54b04f7f81d64525554 /src/window.c
parent950bed4bb96d2a580818bdaab64a164c7c9a1c1e (diff)
parent9f6efa0c78099f2f028c4db1db5a58567a1cfb4e (diff)
downloademacs-9ef706664e98e37e9633712126bae99869904677.tar.gz
emacs-9ef706664e98e37e9633712126bae99869904677.zip
Merged from miles@gnu.org--gnu-2005 (patch 659-663)
Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-659 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-660 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-661 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-662 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-663 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-445
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c137
1 files changed, 136 insertions, 1 deletions
diff --git a/src/window.c b/src/window.c
index 69cee518ca4..2d974b4647f 100644
--- a/src/window.c
+++ b/src/window.c
@@ -212,6 +212,10 @@ Lisp_Object Vwindow_configuration_change_hook;
212 212
213Lisp_Object Vscroll_preserve_screen_position; 213Lisp_Object Vscroll_preserve_screen_position;
214 214
215/* Incremented by 1 whenever a window is deleted. */
216
217int window_deletion_count;
218
215#if 0 /* This isn't used anywhere. */ 219#if 0 /* This isn't used anywhere. */
216/* Nonzero means we can split a frame even if it is "unsplittable". */ 220/* Nonzero means we can split a frame even if it is "unsplittable". */
217static int inhibit_frame_unsplittable; 221static int inhibit_frame_unsplittable;
@@ -1335,7 +1339,7 @@ delete_window (window)
1335 CHECK_WINDOW (window); 1339 CHECK_WINDOW (window);
1336 p = XWINDOW (window); 1340 p = XWINDOW (window);
1337 1341
1338 /* It's okay to delete an already-deleted window. */ 1342 /* It's a no-op to delete an already-deleted window. */
1339 if (NILP (p->buffer) 1343 if (NILP (p->buffer)
1340 && NILP (p->hchild) 1344 && NILP (p->hchild)
1341 && NILP (p->vchild)) 1345 && NILP (p->vchild))
@@ -1399,6 +1403,9 @@ delete_window (window)
1399 } 1403 }
1400 } 1404 }
1401 1405
1406 /* Now we know we can delete this one. */
1407 window_deletion_count++;
1408
1402 tem = p->buffer; 1409 tem = p->buffer;
1403 /* tem is null for dummy parent windows 1410 /* tem is null for dummy parent windows
1404 (which have inferiors but not any contents themselves) */ 1411 (which have inferiors but not any contents themselves) */
@@ -4233,9 +4240,136 @@ enlarge_window (window, delta, horiz_flag, preserve_before)
4233 adjust_glyphs (XFRAME (WINDOW_FRAME (XWINDOW (window)))); 4240 adjust_glyphs (XFRAME (WINDOW_FRAME (XWINDOW (window))));
4234} 4241}
4235 4242
4243
4244/* Adjust the size of WINDOW by DELTA, moving only its trailing edge.
4245 HORIZ_FLAG nonzero means adjust the width, moving the right edge.
4246 zero means adjust the height, moving the bottom edge.
4247
4248 Following siblings of the selected window are resized to fulfill
4249 the size request. If they become too small in the process, they
4250 are not deleted; instead, we signal an error. */
4251
4252static void
4253adjust_window_trailing_edge (window, delta, horiz_flag)
4254 Lisp_Object window;
4255 int delta, horiz_flag;
4256{
4257 Lisp_Object parent, child;
4258 struct window *p;
4259 Lisp_Object old_config = Fcurrent_window_configuration (Qnil);
4260 int delcount = window_deletion_count;
4261
4262 /* Check values of window_min_width and window_min_height for
4263 validity. */
4264 check_min_window_sizes ();
4265
4266 if (NILP (window))
4267 window = Fselected_window ();
4268
4269 CHECK_WINDOW (window);
4270
4271 /* Give up if this window cannot be resized. */
4272 if (window_fixed_size_p (XWINDOW (window), horiz_flag, 1))
4273 error ("Window is not resizable");
4274
4275 while (1)
4276 {
4277 p = XWINDOW (window);
4278 parent = p->parent;
4279
4280 /* Make sure there is a following window. */
4281 if (NILP (parent)
4282 && (horiz_flag ? 1
4283 : NILP (XWINDOW (window)->next)))
4284 {
4285 Fset_window_configuration (old_config);
4286 error ("No other window following this one");
4287 }
4288
4289 /* Don't make this window too small. */
4290 if (XINT (CURSIZE (window)) + delta
4291 < (horiz_flag ? window_min_width : window_min_height))
4292 {
4293 Fset_window_configuration (old_config);
4294 error ("Cannot adjust window size as specified");
4295 }
4296
4297 /* Clear out some redisplay caches. */
4298 XSETFASTINT (p->last_modified, 0);
4299 XSETFASTINT (p->last_overlay_modified, 0);
4300
4301 /* Adjust this window's edge. */
4302 XSETINT (CURSIZE (window),
4303 XINT (CURSIZE (window)) + delta);
4304
4305 /* If this window has following siblings in the desired dimension,
4306 make them smaller.
4307 (If we reach the top of the tree and can never do this,
4308 we will fail and report an error, above.) */
4309 if (horiz_flag
4310 ? !NILP (XWINDOW (parent)->hchild)
4311 : !NILP (XWINDOW (parent)->vchild))
4312 {
4313 if (!NILP (XWINDOW (window)->next))
4314 {
4315 XSETINT (CURBEG (p->next),
4316 XINT (CURBEG (p->next)) + delta);
4317 size_window (p->next, XINT (CURSIZE (p->next)) - delta,
4318 horiz_flag, 0);
4319 break;
4320 }
4321 }
4322 else
4323 /* Here we have a chain of parallel siblings, in the other dimension.
4324 Change the size of the other siblings. */
4325 for (child = (horiz_flag
4326 ? XWINDOW (parent)->vchild
4327 : XWINDOW (parent)->hchild);
4328 ! NILP (child);
4329 child = XWINDOW (child)->next)
4330 if (! EQ (child, window))
4331 size_window (child, XINT (CURSIZE (child)) + delta,
4332 horiz_flag, 0);
4333
4334 window = parent;
4335 }
4336
4337 /* If we made a window so small it got deleted,
4338 we failed. Report failure. */
4339 if (delcount != window_deletion_count)
4340 {
4341 Fset_window_configuration (old_config);
4342 error ("Cannot adjust window size as specified");
4343 }
4344
4345 /* Adjust glyph matrices. */
4346 adjust_glyphs (XFRAME (WINDOW_FRAME (XWINDOW (window))));
4347}
4348
4236#undef CURBEG 4349#undef CURBEG
4237#undef CURSIZE 4350#undef CURSIZE
4238 4351
4352DEFUN ("adjust-window-trailing-edge", Fadjust_window_trailing_edge,
4353 Sadjust_window_trailing_edge, 3, 3, 0,
4354 doc: /* Adjust the bottom or right edge of WINDOW by DELTA.
4355If HORIZ_FLAG is t, that means adjust the width, moving the right edge.
4356Otherwise, adjust the height, moving the bottom edge.
4357
4358Following siblings of the selected window are resized to fulfill
4359the size request. If they become too small in the process, they
4360are not deleted; instead, we signal an error. */)
4361 (window, delta, horizontal)
4362 Lisp_Object window, delta, horizontal;
4363{
4364 CHECK_NUMBER (delta);
4365 adjust_window_trailing_edge (window, XINT (delta), !NILP (horizontal));
4366
4367 if (! NILP (Vwindow_configuration_change_hook))
4368 call1 (Vrun_hooks, Qwindow_configuration_change_hook);
4369
4370 return Qnil;
4371}
4372
4239 4373
4240 4374
4241/*********************************************************************** 4375/***********************************************************************
@@ -7116,6 +7250,7 @@ The selected frame is the one whose configuration has changed. */);
7116 defsubr (&Ssplit_window); 7250 defsubr (&Ssplit_window);
7117 defsubr (&Senlarge_window); 7251 defsubr (&Senlarge_window);
7118 defsubr (&Sshrink_window); 7252 defsubr (&Sshrink_window);
7253 defsubr (&Sadjust_window_trailing_edge);
7119 defsubr (&Sscroll_up); 7254 defsubr (&Sscroll_up);
7120 defsubr (&Sscroll_down); 7255 defsubr (&Sscroll_down);
7121 defsubr (&Sscroll_left); 7256 defsubr (&Sscroll_left);