/* Nonzero after init_window_once has finished. */
static int window_initialized;
+/* Hook to run when window config changes. */
+Lisp_Object Qwindow_configuration_change_hook;
+Lisp_Object Vwindow_configuration_change_hook;
+
/* Nonzero means scroll commands try to put point
at the same screen height as previously. */
static int scroll_preserve_screen_position;
+/* Non-nil means we can split a frame even if it is "unsplittable". */
+static int frame_override_unsplittable;
+
#define min(a, b) ((a) < (b) ? (a) : (b))
extern int scroll_margin;
"Remove WINDOW from the display. Default is selected window.")
(window)
register Lisp_Object window;
+{
+ delete_window (window);
+
+ if (! NILP (Vwindow_configuration_change_hook)
+ && ! NILP (Vrun_hooks))
+ call1 (Vrun_hooks, Qwindow_configuration_change_hook);
+
+ return Qnil;
+}
+
+delete_window (window)
+ register Lisp_Object window;
{
register Lisp_Object tem, parent, sib;
register struct window *p;
if (NILP (p->buffer)
&& NILP (p->hchild)
&& NILP (p->vchild))
- return Qnil;
+ return;
parent = p->parent;
if (NILP (parent))
/* Mark this window as deleted. */
p->buffer = p->hchild = p->vchild = Qnil;
-
- return Qnil;
}
\f
&& ! NILP (w->parent)
&& height < window_min_height)
{
- Fdelete_window (window);
+ delete_window (window);
return;
}
if (!nodelete && width < window_min_width && !NILP (w->parent))
{
- Fdelete_window (window);
+ delete_window (window);
return;
}
if (EQ (window, selected_window))
XBUFFER (w->buffer)->last_selected_window = window;
+ if (INTEGERP (XBUFFER (buffer)->display_count))
+ XSETINT (XBUFFER (buffer)->display_count,
+ XINT (XBUFFER (buffer)->display_count) + 1);
XSETFASTINT (w->window_end_pos, 0);
w->window_end_valid = Qnil;
run_hook_with_args_2 (Qwindow_scroll_functions, window,
Fmarker_position (w->start));
+ if (! NILP (Vwindow_configuration_change_hook)
+ && ! NILP (Vrun_hooks))
+ call1 (Vrun_hooks, Qwindow_configuration_change_hook);
+
unbind_to (count, Qnil);
return Qnil;
&& window_height (window) >= window_min_height << 1)
window = Fsplit_window (window, Qnil, Qnil);
/* If Fget_lru_window returned nil, try other approaches. */
+
/* Try visible frames first. */
+ if (NILP (window))
+ window = Fget_buffer_window (buffer, Qvisible);
if (NILP (window))
window = Fget_largest_window (Qvisible);
/* If that didn't work, try iconified frames. */
+ if (NILP (window))
+ window = Fget_buffer_window (buffer, make_number (0));
if (NILP (window))
window = Fget_largest_window (make_number (0));
/* Try invisible frames. */
+ if (NILP (window))
+ window = Fget_buffer_window (buffer, Qt);
if (NILP (window))
window = Fget_largest_window (Qt);
/* As a last resort, make a new frame. */
other = lower = XWINDOW (window)->next, upper = window;
if (!NILP (other)
/* Check that OTHER and WINDOW are vertically arrayed. */
- && XWINDOW (other)->top != XWINDOW (window)->top
- && XWINDOW (other)->height > XWINDOW (window)->height)
+ && !EQ (XWINDOW (other)->top, XWINDOW (window)->top)
+ && (XFASTINT (XWINDOW (other)->height)
+ > XFASTINT (XWINDOW (window)->height)))
{
- int total = XWINDOW (other)->height + XWINDOW (window)->height;
+ int total = (XFASTINT (XWINDOW (other)->height)
+ + XFASTINT (XWINDOW (window)->height));
Lisp_Object old_selected_window;
old_selected_window = selected_window;
selected_window = upper;
- change_window_height (total / 2 - XWINDOW (upper)->height, 0);
+ change_window_height ((total / 2
+ - XFASTINT (XWINDOW (upper)->height)),
+ 0);
selected_window = old_selected_window;
}
}
if (MINI_WINDOW_P (o))
error ("Attempt to split minibuffer window");
- else if (FRAME_NO_SPLIT_P (fo))
+ else if (FRAME_NO_SPLIT_P (fo) && ! frame_override_unsplittable)
error ("Attempt to split unsplittable frame");
check_min_window_sizes ();
p->parent = o->parent;
p->buffer = Qt;
- Fset_window_buffer (new, o->buffer);
-
/* Apportion the available frame space among the two new windows */
if (!NILP (horflag))
XSETFASTINT (p->top, XFASTINT (o->top) + size_int);
}
+ Fset_window_buffer (new, o->buffer);
+
return new;
}
\f
{
CHECK_NUMBER (arg, 0);
change_window_height (XINT (arg), !NILP (side));
+
+ if (! NILP (Vwindow_configuration_change_hook))
+ call1 (Vrun_hooks, Qwindow_configuration_change_hook);
+
return Qnil;
}
{
CHECK_NUMBER (arg, 0);
change_window_height (-XINT (arg), !NILP (side));
+
+ if (! NILP (Vwindow_configuration_change_hook))
+ call1 (Vrun_hooks, Qwindow_configuration_change_hook);
+
return Qnil;
}
if (*sizep + delta < MINSIZE (window))
{
- Fdelete_window (window);
+ delete_window (window);
return;
}
/* Look at one sibling at a time,
moving away from this window in both directions alternately,
and take as much as we can get without deleting that sibling. */
- while (delta > 0)
+ while (delta != 0)
{
if (delta == 0)
break;
FRAME_ROOT_WINDOW (f) = data->root_window;
Fselect_window (data->current_window);
+ XBUFFER (XWINDOW (selected_window)->buffer)->last_selected_window
+ = selected_window;
if (NILP (data->focus_frame)
|| (FRAMEP (data->focus_frame)
Fset_buffer (new_current_buffer);
Vminibuf_scroll_window = data->minibuf_scroll_window;
+
+ if (! NILP (Vwindow_configuration_change_hook)
+ && ! NILP (Vrun_hooks))
+ call1 (Vrun_hooks, Qwindow_configuration_change_hook);
+
return (Qnil);
}
syms_of_window ()
{
+ staticpro (&Qwindow_configuration_change_hook);
+ Qwindow_configuration_change_hook
+ = intern ("window-configuration-change-hook");
+
Qwindowp = intern ("windowp");
staticpro (&Qwindowp);
"*Nonzero means scroll commands move point to keep its screen line unchanged.");
scroll_preserve_screen_position = 0;
+ DEFVAR_LISP ("window-configuration-change-hook",
+ &Vwindow_configuration_change_hook,
+ "Functions to call when window configuration changes.\n\
+The selected frae is the one whose configuration has changed.");
+ Vwindow_configuration_change_hook = Qnil;
+
+ DEFVAR_BOOL ("frame-override-unsplittable", &frame_override_unsplittable,
+ "Non-nil means allow splitting an `unsplittable' frame.\n\
+\(That means, a frame whise `unsplittable' parameter is non-nil.)\n\
+Packages such as Ispell that work by splitting the selected frame\n\
+can bind this, so that they will work when used in an unsplittable frame.");
+
defsubr (&Sselected_window);
defsubr (&Sminibuffer_window);
defsubr (&Swindow_minibuffer_p);