Commit d1655783 authored by Martin Rudalics's avatar Martin Rudalics

Try to improve handling of fullwidth/-height frames.

* frame.el (frame-notice-user-settings): Update
`frame-size-history'.
(make-frame): Update `frame-size-history'.  Call
`frame-after-make-frame'.
* faces.el (face-set-after-frame-default): Remove call to
frame-can-run-window-configuration-change-hook.
* frame.c (frame_size_history_add): New function.
(frame_inhibit_resize): Consider frame_inhibit_implied_resize
only after frame's after_make_frame slot is true.  Inhibit
resizing fullwidth-/height frames in one direction only.  Update
frame_size_history.
(adjust_frame_size): Call frame_size_history_add.
(make_frame): Initalize after_make_frame slot.
(Fmake_terminal_frame): Adjust adjust_frame_size call.
(Fcan_run_window_configuration_change_hook): Rename to
Fframe_after_make_frame.  Set after_make_frame slot.  Return
second argument.
(x_set_frame_parameters): Postpone handling fullscreen parameter
until after width and height parameters have been set.  Apply
width and height changes only if can_x_set_window_size is true.
Update frame_size_history.
(Qadjust_frame_size_1, Qadjust_frame_size_2)
(Qadjust_frame_size_3, QEmacsFrameResize, Qframe_inhibit_resize)
(Qx_set_fullscreen, Qx_check_fullscreen, Qx_set_window_size_1)
(Qxg_frame_resized, Qxg_frame_set_char_size_1)
(Qxg_frame_set_char_size_2, Qxg_frame_set_char_size_3)
(Qxg_change_toolbar_position, Qx_net_wm_state)
(Qx_handle_net_wm_state, Qtb_size_cb, Qupdate_frame_tool_bar)
(Qfree_frame_tool_bar): New symbol for updating
frame_size_history.
(Qtip_frame, Qterminal_frame): New symbols.
(Vframe_adjust_size_history): Rename to frame_size_history.
* frame.h (struct frame): Rename
can_run_window_configuration_change_hook slot to
after_make_frame.
(frame_size_history_add): Extern.
* gtkutil.c (xg_frame_resized): Call frame_size_history_add.
Don't set FRAME_PIXEL_WIDTH and FRAME_PIXEL_HEIGHT here.
(xg_frame_set_char_size): Try to preserve the status of
fullwidth/-height frames.  Call frame_size_history_add.
(tb_size_cb, update_frame_tool_bar, free_frame_tool_bar)
(xg_change_toolbar_position): Call frame_size_history_add.
* w32fns.c (x_change_tool_bar_height): Handle frame's fullscreen
status.
(Fx_create_frame): Process fullscreen parameter after frame has
been resized.
(x_create_tip_frame): Pass Qtip_frame to adjust_frame_size.
(Fx_frame_geometry): Don't pollute pure storage.
* w32term.c (w32_read_socket): For WM_WINDOWPOSCHANGED,
WM_ACTIVATE and WM_ACTIVATEAPP set frame's visibility before
calling w32fullscreen_hook.  For WM_DISPLAYCHANGE call
w32fullscreen_hook immediately.
(x_fullscreen_adjust, x_check_fullscreen): Remove.
(w32fullscreen_hook): Call change_frame_size just as with a
"normal" frame resize operation.  Call do_pending_window_change.
(x_set_window_size): Try to handle fullwidth and fullheight more
accurately.  Don't rely on w32_enable_frame_resize_hack.
(w32_enable_frame_resize_hack): Remove variable.
* widget.c (EmacsFrameResize): Remove dead code.  Call
frame_size_history_add
* window.c (run_window_configuration_change_hook): Check
f->after_make_frame instead of
f->can_run_window_configuration_change_hook.
* xfns.c (x_change_tool_bar_height): Handle frame's fullscreen status.
(Fx_create_frame): Process fullscreen parameter after frame has
been resized.
(Fx_frame_geometry): Don't pollute pure storage.
* xterm.c (x_net_wm_state, x_handle_net_wm_state): Call
frame_size_history_add.
(do_ewmh_fullscreen): Handle x_frame_normalize_before_maximize.
(x_check_fullscreen): Count in menubar when calling
XResizeWindow.  Wait for ConfigureNotify event.  Call
frame_size_history_add.
(x_set_window_size_1): Remove PIXELWISE argument.  Try to handle
changing a fullheight frame's width or a fullwidth frame's
height.  Call frame_size_history_add.
(x_set_window_size): Simplify xg_frame_set_char_size and
x_set_window_size_1 calls.
(x_frame_normalize_before_maximize): New variable.
parent cf498e5b
2015-02-07 Martin Rudalics <rudalics@gmx.at>
* frame.el (frame-notice-user-settings): Update
`frame-size-history'.
(make-frame): Update `frame-size-history'. Call
`frame-after-make-frame'.
* faces.el (face-set-after-frame-default): Remove call to
frame-can-run-window-configuration-change-hook.
2015-02-06 Dmitry Gutov <dgutov@yandex.ru>
* vc/vc-cvs.el (vc-cvs-dir-status-files): Don't pass DIR to
......
......@@ -2092,8 +2092,7 @@ frame parameters in PARAMETERS."
(value (cdr (assq param-name parameters))))
(if value
(set-face-attribute (nth 1 param) frame
(nth 2 param) value))))
(frame-can-run-window-configuration-change-hook frame t)))
(nth 2 param) value))))))
(defun tty-handle-reverse-video (frame parameters)
"Handle the reverse-video frame parameter for terminal frames."
......
......@@ -465,6 +465,16 @@ there (in decreasing order of priority)."
(frame-set-background-mode frame-initial-frame))
(face-set-after-frame-default frame-initial-frame)
(setq newparms (delq new-bg newparms)))
(when (numberp (car frame-size-history))
(setq frame-size-history
(cons (1- (car frame-size-history))
(cons
(list frame-initial-frame
"frame-notice-user-settings"
nil newparms)
(cdr frame-size-history)))))
(modify-frame-parameters frame-initial-frame newparms)))))
;; Restore the original buffer.
......@@ -686,7 +696,7 @@ the new frame according to its own rules."
;; Now make the frame.
(run-hooks 'before-make-frame-hook)
;; (setq frame-adjust-size-history '(t))
;; (setq frame-size-history '(1000))
(setq frame
(funcall (gui-method frame-creation-function w) params))
......@@ -697,11 +707,14 @@ the new frame according to its own rules."
(let ((val (frame-parameter oldframe param)))
(when val (set-frame-parameter frame param val)))))
(when (eq (car frame-adjust-size-history) t)
(setq frame-adjust-size-history
(cons t (cons (list "Frame made")
(cdr frame-adjust-size-history)))))
(when (numberp (car frame-size-history))
(setq frame-size-history
(cons (1- (car frame-size-history))
(cons (list frame "make-frame")
(cdr frame-size-history)))))
;; We can run `window-configuration-change-hook' for this frame now.
(frame-after-make-frame frame t)
(run-hook-with-args 'after-make-frame-functions frame)
frame))
......
2015-02-07 Martin Rudalics <rudalics@gmx.at>
* frame.c (frame_size_history_add): New function.
(frame_inhibit_resize): Consider frame_inhibit_implied_resize
only after frame's after_make_frame slot is true. Inhibit
resizing fullwidth-/height frames in one direction only. Update
frame_size_history.
(adjust_frame_size): Call frame_size_history_add.
(make_frame): Initalize after_make_frame slot.
(Fmake_terminal_frame): Adjust adjust_frame_size call.
(Fcan_run_window_configuration_change_hook): Rename to
Fframe_after_make_frame. Set after_make_frame slot. Return
second argument.
(x_set_frame_parameters): Postpone handling fullscreen parameter
until after width and height parameters have been set. Apply
width and height changes only if can_x_set_window_size is true.
Update frame_size_history.
(Qadjust_frame_size_1, Qadjust_frame_size_2)
(Qadjust_frame_size_3, QEmacsFrameResize, Qframe_inhibit_resize)
(Qx_set_fullscreen, Qx_check_fullscreen, Qx_set_window_size_1)
(Qxg_frame_resized, Qxg_frame_set_char_size_1)
(Qxg_frame_set_char_size_2, Qxg_frame_set_char_size_3)
(Qxg_change_toolbar_position, Qx_net_wm_state)
(Qx_handle_net_wm_state, Qtb_size_cb, Qupdate_frame_tool_bar)
(Qfree_frame_tool_bar): New symbol for updating
frame_size_history.
(Qtip_frame, Qterminal_frame): New symbols.
(Vframe_adjust_size_history): Rename to frame_size_history.
* frame.h (struct frame): Rename
can_run_window_configuration_change_hook slot to
after_make_frame.
(frame_size_history_add): Extern.
* gtkutil.c (xg_frame_resized): Call frame_size_history_add.
Don't set FRAME_PIXEL_WIDTH and FRAME_PIXEL_HEIGHT here.
(xg_frame_set_char_size): Try to preserve the status of
fullwidth/-height frames. Call frame_size_history_add.
(tb_size_cb, update_frame_tool_bar, free_frame_tool_bar)
(xg_change_toolbar_position): Call frame_size_history_add.
* w32fns.c (x_change_tool_bar_height): Handle frame's fullscreen
status.
(Fx_create_frame): Process fullscreen parameter after frame has
been resized.
(x_create_tip_frame): Pass Qtip_frame to adjust_frame_size.
(Fx_frame_geometry): Don't pollute pure storage.
* w32term.c (w32_read_socket): For WM_WINDOWPOSCHANGED,
WM_ACTIVATE and WM_ACTIVATEAPP set frame's visibility before
calling w32fullscreen_hook. For WM_DISPLAYCHANGE call
w32fullscreen_hook immediately.
(x_fullscreen_adjust, x_check_fullscreen): Remove.
(w32fullscreen_hook): Call change_frame_size just as with a
"normal" frame resize operation. Call do_pending_window_change.
(x_set_window_size): Try to handle fullwidth and fullheight more
accurately. Don't rely on w32_enable_frame_resize_hack.
(w32_enable_frame_resize_hack): Remove variable.
* widget.c (EmacsFrameResize): Remove dead code. Call
frame_size_history_add
* window.c (run_window_configuration_change_hook): Check
f->after_make_frame instead of
f->can_run_window_configuration_change_hook.
* xfns.c (x_change_tool_bar_height): Handle frame's fullscreen status.
(Fx_create_frame): Process fullscreen parameter after frame has
been resized.
(Fx_frame_geometry): Don't pollute pure storage.
* xterm.c (x_net_wm_state, x_handle_net_wm_state): Call
frame_size_history_add.
(do_ewmh_fullscreen): Handle x_frame_normalize_before_maximize.
(x_check_fullscreen): Count in menubar when calling
XResizeWindow. Wait for ConfigureNotify event. Call
frame_size_history_add.
(x_set_window_size_1): Remove PIXELWISE argument. Try to handle
changing a fullheight frame's width or a fullwidth frame's
height. Call frame_size_history_add.
(x_set_window_size): Simplify xg_frame_set_char_size and
x_set_window_size_1 calls.
(x_frame_normalize_before_maximize): New variable.
2015-02-07 Paul Eggert <eggert@cs.ucla.edu>
Remove no-longer-used cursor_in_echo_area code
......
......@@ -149,6 +149,33 @@ get_frame_param (register struct frame *frame, Lisp_Object prop)
return Fcdr (tem);
}
void
frame_size_history_add (struct frame *f, Lisp_Object fun_symbol,
int width, int height, Lisp_Object rest)
{
Lisp_Object frame;
int number;
XSETFRAME (frame, f);
if (CONSP (frame_size_history)
&& NUMBERP (Fcar (frame_size_history))
&& ((number = XINT (Fcar (frame_size_history))) > 0))
frame_size_history =
Fcons (make_number (number - 1),
Fcons (list4
(frame, fun_symbol,
((width > 0)
? list4 (make_number (FRAME_TEXT_WIDTH (f)),
make_number (FRAME_TEXT_HEIGHT (f)),
make_number (width),
make_number (height))
: Qnil),
rest),
Fcdr (frame_size_history)));
}
/* Return 1 if `frame-inhibit-implied-resize' is non-nil or fullscreen
state of frame F would be affected by a vertical (horizontal if
HORIZONTAL is true) resize. PARAMETER is the symbol of the frame
......@@ -156,11 +183,27 @@ get_frame_param (register struct frame *frame, Lisp_Object prop)
bool
frame_inhibit_resize (struct frame *f, bool horizontal, Lisp_Object parameter)
{
return (EQ (frame_inhibit_implied_resize, Qt)
|| (CONSP (frame_inhibit_implied_resize)
&& !NILP (Fmemq (parameter, frame_inhibit_implied_resize)))
|| !NILP (get_frame_param (f, Qfullscreen))
|| FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f));
Lisp_Object fullscreen = get_frame_param (f, Qfullscreen);
bool inhibit
= ((f->after_make_frame
&& (EQ (frame_inhibit_implied_resize, Qt)
|| (CONSP (frame_inhibit_implied_resize)
&& !NILP (Fmemq (parameter, frame_inhibit_implied_resize)))))
|| (horizontal
&& !EQ (fullscreen, Qnil) && !EQ (fullscreen, Qfullheight))
|| (!horizontal
&& !EQ (fullscreen, Qnil) && !EQ (fullscreen, Qfullwidth))
|| FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f));
if (inhibit && !FRAME_TERMCAP_P (f) && !FRAME_MSDOS_P (f))
frame_size_history_add
(f, Qframe_inhibit_resize, 0, 0,
list5 (horizontal ? Qt : Qnil, parameter,
f->after_make_frame ? Qt : Qnil,
frame_inhibit_implied_resize,
fullscreen));
return inhibit;
}
static void
......@@ -369,18 +412,9 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit,
XSETFRAME (frame, f);
/* `make-frame' initializes Vframe_adjust_size_history to (Qt) and
strips its car when exiting. Just in case make sure its size never
exceeds 100. */
if (!NILP (Fconsp (Vframe_adjust_size_history))
&& EQ (Fcar (Vframe_adjust_size_history), Qt)
&& XFASTINT (Fsafe_length (Vframe_adjust_size_history)) <= 100)
Vframe_adjust_size_history =
Fcons (Qt, Fcons (list5 (make_number (0),
make_number (new_text_width),
make_number (new_text_height),
make_number (inhibit), parameter),
Fcdr (Vframe_adjust_size_history)));
frame_size_history_add
(f, Qadjust_frame_size_1, new_text_width, new_text_height,
list2 (parameter, make_number (inhibit)));
/* The following two values are calculated from the old window body
sizes and any "new" settings for scroll bars, dividers, fringes and
......@@ -391,7 +425,7 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit,
= frame_windows_min_size (frame, Qnil, (inhibit == 5) ? Qt : Qnil, Qt);
if (inhibit >= 2 && inhibit <= 4)
/* If INHIBIT is in [2..4] inhibit if the "old" window sizes stay
/* When INHIBIT is in [2..4] inhibit if the "old" window sizes stay
within the limits and either frame_inhibit_resize tells us to do
so or INHIBIT equals 4. */
{
......@@ -449,16 +483,10 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit,
else if (inhibit_vertical)
new_text_height = old_text_height;
if (!NILP (Fconsp (Vframe_adjust_size_history))
&& EQ (Fcar (Vframe_adjust_size_history), Qt)
&& XFASTINT (Fsafe_length (Vframe_adjust_size_history)) <= 100)
Vframe_adjust_size_history =
Fcons (Qt, Fcons (list5 (make_number (1),
make_number (new_text_width),
make_number (new_text_height),
make_number (new_cols),
make_number (new_lines)),
Fcdr (Vframe_adjust_size_history)));
frame_size_history_add
(f, Qadjust_frame_size_2, new_text_width, new_text_height,
list2 (inhibit_horizontal ? Qt : Qnil,
inhibit_vertical ? Qt : Qnil));
x_set_window_size (f, 0, new_text_width, new_text_height, 1);
f->resized_p = true;
......@@ -525,6 +553,11 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit,
FrameRows (FRAME_TTY (f)) = new_lines + FRAME_TOP_MARGIN (f);
}
frame_size_history_add
(f, Qadjust_frame_size_3, new_text_width, new_text_height,
list4 (make_number (old_pixel_width), make_number (old_pixel_height),
make_number (new_pixel_width), make_number (new_pixel_height)));
/* Assign new sizes. */
FRAME_TEXT_WIDTH (f) = new_text_width;
FRAME_TEXT_HEIGHT (f) = new_text_height;
......@@ -533,17 +566,6 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit,
SET_FRAME_COLS (f, new_cols);
SET_FRAME_LINES (f, new_lines);
if (!NILP (Fconsp (Vframe_adjust_size_history))
&& EQ (Fcar (Vframe_adjust_size_history), Qt)
&& XFASTINT (Fsafe_length (Vframe_adjust_size_history)) <= 100)
Vframe_adjust_size_history =
Fcons (Qt, Fcons (list5 (make_number (2),
make_number (new_text_width),
make_number (new_text_height),
make_number (new_cols),
make_number (new_lines)),
Fcdr (Vframe_adjust_size_history)));
{
struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f));
int text_area_x, text_area_y, text_area_width, text_area_height;
......@@ -608,7 +630,7 @@ make_frame (bool mini_p)
f->redisplay = true;
f->garbaged = true;
f->can_x_set_window_size = false;
f->can_run_window_configuration_change_hook = false;
f->after_make_frame = false;
f->tool_bar_redisplayed_once = false;
f->column_width = 1; /* !FRAME_WINDOW_P value. */
f->line_height = 1; /* !FRAME_WINDOW_P value. */
......@@ -1020,7 +1042,8 @@ affects all frames on the same terminal device. */)
{
int width, height;
get_tty_size (fileno (FRAME_TTY (f)->input), &width, &height);
adjust_frame_size (f, width, height - FRAME_MENU_BAR_LINES (f), 5, 0, Qnil);
adjust_frame_size (f, width, height - FRAME_MENU_BAR_LINES (f),
5, 0, Qterminal_frame);
}
adjust_frame_glyphs (f);
......@@ -2260,24 +2283,25 @@ If there is no window system support, this function does nothing. */)
return Qnil;
}
DEFUN ("frame-can-run-window-configuration-change-hook",
Fcan_run_window_configuration_change_hook,
Scan_run_window_configuration_change_hook, 2, 2, 0,
doc: /* Whether `window-configuration-change-hook' is run for frame FRAME.
FRAME nil means use the selected frame. Second argument ALLOW non-nil
DEFUN ("frame-after-make-frame",
Fframe_after_make_frame,
Sframe_after_make_frame, 2, 2, 0,
doc: /* Mark FRAME as made.
FRAME nil means use the selected frame. Second argument MADE non-nil
means functions on `window-configuration-change-hook' are called
whenever the window configuration of FRAME changes. ALLOW nil means
whenever the window configuration of FRAME changes. MADE nil means
these functions are not called.
This function is currently called by `face-set-after-frame-default' only
and should be otherwise used with utter care to avoid that running
functions on `window-configuration-change-hook' is impeded forever. */)
(Lisp_Object frame, Lisp_Object allow)
This function is currently called by `make-frame' only and should be
otherwise used with utter care to avoid that running functions on
`window-configuration-change-hook' is impeded forever. */)
(Lisp_Object frame, Lisp_Object made)
{
struct frame *f = decode_live_frame (frame);
f->can_run_window_configuration_change_hook = NILP (allow) ? false : true;
return Qnil;
f->after_make_frame = NILP (made) ? false : true;
return made;
}
......@@ -3037,7 +3061,7 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist)
set them both at once. So we wait until we've looked at the
entire list before we set them. */
int width IF_LINT (= 0), height IF_LINT (= 0);
bool width_change = 0, height_change = 0;
bool width_change = false, height_change = false;
/* Same here. */
Lisp_Object left, top;
......@@ -3045,6 +3069,10 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist)
/* Same with these. */
Lisp_Object icon_left, icon_top;
/* And with this. */
Lisp_Object fullscreen;
bool fullscreen_change = false;
/* Record in these vectors all the parms specified. */
Lisp_Object *parms;
Lisp_Object *values;
......@@ -3138,6 +3166,11 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist)
icon_top = val;
else if (EQ (prop, Qicon_left))
icon_left = val;
else if (EQ (prop, Qfullscreen))
{
fullscreen = val;
fullscreen_change = true;
}
else if (EQ (prop, Qforeground_color)
|| EQ (prop, Qbackground_color)
|| EQ (prop, Qfont))
......@@ -3218,14 +3251,14 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist)
that here since otherwise a size change implied by an
intermittent font change may get lost as in Bug#17142. */
if (!width_change)
width = (f->new_width
width = ((f->can_x_set_window_size && f->new_width)
? (f->new_pixelwise
? f->new_width
: (f->new_width * FRAME_COLUMN_WIDTH (f)))
: FRAME_TEXT_WIDTH (f));
if (!height_change)
height = (f->new_height
height = ((f->can_x_set_window_size && f->new_height)
? (f->new_pixelwise
? f->new_height
: (f->new_height * FRAME_LINE_HEIGHT (f)))
......@@ -3298,6 +3331,20 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist)
/* Actually set that position, and convert to absolute. */
x_set_offset (f, leftpos, toppos, -1);
}
if (fullscreen_change)
{
Lisp_Object old_value = get_frame_param (f, Qfullscreen);
frame_size_history_add
(f, Qx_set_fullscreen, 0, 0, list2 (old_value, fullscreen));
store_frame_param (f, Qfullscreen, fullscreen);
if (!EQ (fullscreen, old_value))
x_set_fullscreen (f, fullscreen, old_value);
}
#ifdef HAVE_X_WINDOWS
if ((!NILP (icon_left) || !NILP (icon_top))
&& ! (icon_left_no_change && icon_top_no_change))
......@@ -4834,11 +4881,33 @@ syms_of_frame (void)
DEFSYM (Qtool_bar_external, "tool-bar-external");
DEFSYM (Qtool_bar_size, "tool-bar-size");
DEFSYM (Qframe_inner_size, "frame-inner-size");
/* The following are used for frame_size_history. */
DEFSYM (Qadjust_frame_size_1, "adjust-frame-size-1");
DEFSYM (Qadjust_frame_size_2, "adjust-frame-size-2");
DEFSYM (Qadjust_frame_size_3, "adjust-frame-size-3");
DEFSYM (QEmacsFrameResize, "EmacsFrameResize");
DEFSYM (Qframe_inhibit_resize, "frame-inhibit-resize");
DEFSYM (Qx_set_fullscreen, "x-set-fullscreen");
DEFSYM (Qx_check_fullscreen, "x-check-fullscreen");
DEFSYM (Qx_set_window_size_1, "x-set-window-size-1");
DEFSYM (Qxg_frame_resized, "xg-frame-resized");
DEFSYM (Qxg_frame_set_char_size_1, "xg-frame-set-char-size-1");
DEFSYM (Qxg_frame_set_char_size_2, "xg-frame-set-char-size-2");
DEFSYM (Qxg_frame_set_char_size_3, "xg-frame-set-char-size-3");
DEFSYM (Qxg_change_toolbar_position, "xg-change-toolbar-position");
DEFSYM (Qx_net_wm_state, "x-net-wm-state");
DEFSYM (Qx_handle_net_wm_state, "x-handle-net-wm-state");
DEFSYM (Qtb_size_cb, "tb-size-cb");
DEFSYM (Qupdate_frame_tool_bar, "update-frame-tool-bar");
DEFSYM (Qfree_frame_tool_bar, "free-frame-tool-bar");
DEFSYM (Qchange_frame_size, "change-frame-size");
DEFSYM (Qxg_frame_set_char_size, "xg-frame-set-char-size");
DEFSYM (Qset_window_configuration, "set-window-configuration");
DEFSYM (Qx_create_frame_1, "x-create-frame-1");
DEFSYM (Qx_create_frame_2, "x-create-frame-2");
DEFSYM (Qtip_frame, "tip-frame");
DEFSYM (Qterminal_frame, "terminal-frame");
#ifdef HAVE_NS
DEFSYM (Qns_parse_geometry, "ns-parse-geometry");
......@@ -5106,9 +5175,22 @@ even if this option is non-nil. */);
frame_inhibit_implied_resize = Qt;
#endif
DEFVAR_LISP ("frame-adjust-size-history", Vframe_adjust_size_history,
doc: /* History of frame size adjustments. */);
Vframe_adjust_size_history = Qnil;
DEFVAR_LISP ("frame-size-history", frame_size_history,
doc: /* History of frame size adjustments.
If non-nil, list recording frame size adjustment. Adjustments are
recorded only if the first element of this list is a positive number.
Adding an adjustment decrements that number by one.
The remaining elements are the adjustments. Each adjustment is a list
of four elements `frame', `function', `sizes' and `more'. `frame' is
the affected frame and `function' the invoking function. `sizes' is
usually a list of four elements `old-width', `old-height', `new-width'
and `new-height' representing the old and new sizes recorded/requested
by `function'. `more' is a list with additional information.
The function `frame--size-history' displays the value of this variable
in a more readable form. */);
frame_size_history = Qnil;
staticpro (&Vframe_list);
......@@ -5141,7 +5223,7 @@ even if this option is non-nil. */);
defsubr (&Sraise_frame);
defsubr (&Slower_frame);
defsubr (&Sx_focus_frame);
defsubr (&Scan_run_window_configuration_change_hook);
defsubr (&Sframe_after_make_frame);
defsubr (&Sredirect_frame_focus);
defsubr (&Sframe_focus);
defsubr (&Sframe_parameters);
......
......@@ -332,9 +332,8 @@ struct frame
frame. */
bool_bf can_x_set_window_size : 1;
/* True means run_window_configuration_change_hook can be processed
for this frame. */
bool_bf can_run_window_configuration_change_hook : 1;
/* Set to true after this frame was made by `make-frame'. */
bool_bf after_make_frame : 1;
/* True means tool bar has been redisplayed at least once in current
session. */
......@@ -392,9 +391,9 @@ struct frame
int left_pos, top_pos;
/* Total width of this frame (including fringes, vertical scroll bar
and internal border widths) and total height (including menu bar,
tool bar, horizontal scroll bar and internal border widths) in
pixels. */
and internal border widths) and total height (including internal
menu and tool bars, horizontal scroll bar and internal border
widths) in pixels. */
int pixel_width, pixel_height;
/* These many pixels are the difference between the outer window (i.e. the
......@@ -1124,6 +1123,8 @@ extern void frame_make_pointer_visible (struct frame *);
extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object);
extern bool frame_inhibit_resize (struct frame *, bool, Lisp_Object);
extern void adjust_frame_size (struct frame *, int, int, int, bool, Lisp_Object);
extern void frame_size_history_add (struct frame *f, Lisp_Object fun_symbol,
int width, int height, Lisp_Object rest);
extern Lisp_Object Vframe_list;
......
......@@ -886,23 +886,25 @@ xg_frame_resized (struct frame *f, int pixelwidth, int pixelheight)
if (pixelwidth == -1 && pixelheight == -1)
{
if (FRAME_GTK_WIDGET (f) && gtk_widget_get_mapped (FRAME_GTK_WIDGET (f)))
gdk_window_get_geometry (gtk_widget_get_window (FRAME_GTK_WIDGET (f)),
0, 0,
&pixelwidth, &pixelheight);
else return;
gdk_window_get_geometry (gtk_widget_get_window (FRAME_GTK_WIDGET (f)),
0, 0, &pixelwidth, &pixelheight);
else
return;
}
width = FRAME_PIXEL_TO_TEXT_WIDTH (f, pixelwidth);
height = FRAME_PIXEL_TO_TEXT_HEIGHT (f, pixelheight);
frame_size_history_add
(f, Qxg_frame_resized, width, height, Qnil);
if (width != FRAME_TEXT_WIDTH (f)
|| height != FRAME_TEXT_HEIGHT (f)
|| pixelwidth != FRAME_PIXEL_WIDTH (f)
|| pixelheight != FRAME_PIXEL_HEIGHT (f))
{
FRAME_PIXEL_WIDTH (f) = pixelwidth;
FRAME_PIXEL_HEIGHT (f) = pixelheight;
/** FRAME_PIXEL_WIDTH (f) = pixelwidth; **/
/** FRAME_PIXEL_HEIGHT (f) = pixelheight; **/
xg_clear_under_internal_border (f);
change_frame_size (f, width, height, 0, 1, 0, 1);
......@@ -921,24 +923,71 @@ xg_frame_set_char_size (struct frame *f, int width, int height)
{
int pixelwidth = FRAME_TEXT_TO_PIXEL_WIDTH (f, width);
int pixelheight = FRAME_TEXT_TO_PIXEL_HEIGHT (f, height);
Lisp_Object fullscreen = get_frame_param (f, Qfullscreen);
gint gwidth, gheight;
if (FRAME_PIXEL_HEIGHT (f) == 0)
return;
gtk_window_get_size (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
&gwidth, &gheight);
/* Do this before resize, as we don't know yet if we will be resized. */
xg_clear_under_internal_border (f);
/* Must resize our top level widget. Font size may have changed,
but not rows/cols. */
gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
pixelwidth + FRAME_TOOLBAR_WIDTH (f),
pixelheight + FRAME_TOOLBAR_HEIGHT (f)
+ FRAME_MENUBAR_HEIGHT (f));
x_wm_set_size_hint (f, 0, 0);
/* Resize the top level widget so rows and columns remain constant.
When the frame is fullheight and we only want to change the width
or it is fullwidth and we only want to change the height we should
be able to preserve the fullscreen property. However, due to the
fact that we have to send a resize request anyway, the window
manager will abolish it. At least the respective size should
remain unchanged but giving the frame back its normal size will
be broken ... */
if (EQ (fullscreen, Qfullwidth) && width == FRAME_TEXT_WIDTH (f))
{
frame_size_history_add
(f, Qxg_frame_set_char_size_1, width, height,
list2 (make_number (gheight),
make_number (pixelheight + FRAME_TOOLBAR_HEIGHT (f)
+ FRAME_MENUBAR_HEIGHT (f))));
gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
gwidth,
pixelheight + FRAME_TOOLBAR_HEIGHT (f)
+ FRAME_MENUBAR_HEIGHT (f));
}
else if (EQ (fullscreen, Qfullheight) && height == FRAME_TEXT_HEIGHT (f))
{
frame_size_history_add
(f, Qxg_frame_set_char_size_2, width, height,
list2 (make_number (gwidth),
make_number (pixelwidth + FRAME_TOOLBAR_WIDTH (f))));
gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
pixelwidth + FRAME_TOOLBAR_WIDTH (f),
gheight);
}
else
{
frame_size_history_add
(f, Qxg_frame_set_char_size_3, width, height,
list2 (make_number (pixelwidth + FRAME_TOOLBAR_WIDTH (f)),
make_number (pixelheight + FRAME_TOOLBAR_HEIGHT (f)
+ FRAME_MENUBAR_HEIGHT (f))));
gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
pixelwidth + FRAME_TOOLBAR_WIDTH (f),
pixelheight + FRAME_TOOLBAR_HEIGHT (f)
+ FRAME_MENUBAR_HEIGHT (f));
fullscreen = Qnil;
}
SET_FRAME_GARBAGED (f);
cancel_mouse_face (f);
x_wm_set_size_hint (f, 0, 0);
/* We can not call change_frame_size for a mapped frame,
we can not set pixel width/height either. The window manager may
override our resize request, XMonad does this all the time.
......@@ -952,9 +1001,17 @@ xg_frame_set_char_size (struct frame *f, int width, int height)
(void)gtk_events_pending ();
gdk_flush ();
x_wait_for_event (f, ConfigureNotify);
if (!NILP (fullscreen))
/* Try to restore fullscreen state. */
{
store_frame_param (f, Qfullscreen, fullscreen);
x_set_fullscreen (f, fullscreen, fullscreen);
}
}
else
adjust_frame_size (f, -1, -1, 5, 0, Qxg_frame_set_char_size);
adjust_frame_size (f, width, height, 5, 0, Qxg_frame_set_char_size);
}
/* Handle height/width changes (i.e. add/remove/move menu/toolbar).
......@@ -4214,8 +4271,12 @@ tb_size_cb (GtkWidget *widget,
allocated between widgets, it may get another. So we must update
size hints if tool bar size changes. Seen on Fedora 18 at least. */
struct frame *f = user_data;
if (xg_update_tool_bar_sizes (f))
adjust_frame_size (f, -1, -1, 2, 0, Qtool_bar_lines);
{
frame_size_history_add (f, Qtb_size_cb, 0, 0, Qnil);
adjust_frame_size (f, -1, -1, 5, 0, Qtool_bar_lines);
}
}
/* Create a tool bar for frame F. */
......@@ -4489,10 +4550,11 @@ xg_update_tool_bar_sizes (struct frame *f)
FRAME_TOOLBAR_RIGHT_WIDTH (f) = nr;
FRAME_TOOLBAR_TOP_HEIGHT (f) = nt;
FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = nb;
return 1;
}
return 0;
return true;
}
else
return false;
}
static char *
......@@ -4815,7 +4877,10 @@ update_frame_tool_bar (struct frame *f)
xg_pack_tool_bar (f, FRAME_TOOL_BAR_POSITION (f));
gtk_widget_show_all (x->toolbar_widget);
if (xg_update_tool_bar_sizes (f))
adjust_frame_size (f, -1, -1, 2, 0, Qtool_bar_lines);