Improve toggling fullscreen state of frames.

* frame.el (toggle-frame-maximized, toggle-frame-fullscreen):
Rename frame parameter `maximized' to `fullscreen-restore'.
Restore fullwidth/-height after fullboth state.  Update
doc-strings.
* w32term.c (w32_read_socket): In SIZE_MAXIMIZED and
SIZE_RESTORED cases correctly handle `maximized' value for the
`fullscreen' parameter.  Don't use the 'maximized' parameter any
more.
(w32fullscreen_hook): Include menu bar height when calculating
new text height in FULLSCREEN_BOTH case.
* xterm.c (do_ewmh_fullscreen): Handle transition from
FULLSCREEN_BOTH to FULLSCREEN_MAXIMIZED when
x_frame_normalize_before_maximize is set.
* frames.texi (Size Parameters): Update description of
fullscreen frame parameter.
This commit is contained in:
Martin Rudalics 2015-02-11 09:07:24 +01:00
parent 6ebbeafc94
commit 02138cb0b8
7 changed files with 113 additions and 57 deletions

View file

@ -1,3 +1,8 @@
2015-02-11 Martin Rudalics <rudalics@gmx.at>
* frames.texi (Size Parameters): Update description of
fullscreen frame parameter.
2015-02-09 Eli Zaretskii <eliz@gnu.org>
* positions.texi (Screen Lines): Update the documentation of

View file

@ -701,6 +701,7 @@ parameters represent the user's stated preference; otherwise, use
@code{nil}.
@end table
@node Size Parameters
@subsubsection Size Parameters
@cindex window size on display
@ -731,22 +732,34 @@ user-position}) does for the position parameters @code{top} and
@vindex fullscreen, a frame parameter
@item fullscreen
Specify that width, height or both shall be maximized. The value
@code{fullwidth} specifies that width shall be as wide as possible.
The value @code{fullheight} specifies that height shall be as tall as
@code{fullwidth} specifies that width shall be as wide as possible. The
value @code{fullheight} specifies that height shall be as tall as
possible. The value @code{fullboth} specifies that both the width and
the height shall be set to the size of the screen. The value
@code{maximized} specifies that the frame shall be maximized. The
difference between @code{maximized} and @code{fullboth} is that the
former can still be resized by dragging window manager decorations
with the mouse, while the latter really covers the whole screen and
does not allow resizing by mouse dragging.
@code{maximized} specifies that the frame shall be maximized.
The difference between @code{maximized} and @code{fullboth} is that a
maximized frame usually keeps its title bar and the buttons for resizing
and closing the frame. Also, maximized frames typically avoid hiding
any task bar or panels displayed on the desktop. ``Fullboth'' frames,
on the other hand, usually omit the title bar and occupy the entire
available screen space.
``Fullheight'' and ``fullwidth'' frames are more similar to maximized
frames in this regard. However, these typically display an external
border which might be absent with maximized frames. Hence the heights
of maximized and fullheight frames and the widths of maximized and
fullwidth frames often differ by a few pixels.
With some window managers you may have to customize the variable
@code{frame-resize-pixelwise} (@pxref{Size and Position}) to a
non-@code{nil} value in order to make a frame appear ``maximized'' or
``fullscreen''.
@code{frame-resize-pixelwise} (@pxref{Size and Position}) in order to
make a frame truly appear ``maximized'' or ``fullscreen''. Moreover,
some window managers might not support smooth transition between the
various fullscreen or maximization states. Customizing the variable
@code{x-frame-normalize-before-maximize} can help to overcome that.
@end table
@node Layout Parameters
@subsubsection Layout Parameters
@cindex layout parameters of frames

View file

@ -1,3 +1,10 @@
2015-02-11 Martin Rudalics <rudalics@gmx.at>
* frame.el (toggle-frame-maximized, toggle-frame-fullscreen):
Rename frame parameter `maximized' to `fullscreen-restore'.
Restore fullwidth/-height after fullboth state. Update
doc-strings.
2015-02-11 Lars Ingebrigtsen <larsi@gnus.org>
* net/shr.el (shr-insert): Make sure the space inserted has the

View file

@ -1874,57 +1874,56 @@ terminals, cursor blinking is controlled by the terminal."
;; Frame maximization/fullscreen
(defun toggle-frame-maximized ()
"Toggle maximization state of the selected frame.
Maximize the selected frame or un-maximize if it is already maximized.
Respect window manager screen decorations.
If the frame is in fullscreen mode, don't change its mode,
just toggle the temporary frame parameter `maximized',
so the frame will go to the right maximization state
after disabling fullscreen mode.
"Toggle maximization state of selected frame.
Maximize selected frame or un-maximize if it is already maximized.
If the frame is in fullscreen state, don't change its state, but
set the frame's `fullscreen-restore' parameter to `maximized', so
the frame will be maximized after disabling fullscreen state.
Note that with some window managers you may have to set
`frame-resize-pixelwise' to non-nil in order to make a frame
appear truly maximized.
appear truly maximized. In addition, you may have to set
`x-frame-normalize-before-maximize' in order to enable
transitions from one fullscreen state to another.
See also `toggle-frame-fullscreen'."
(interactive)
(if (memq (frame-parameter nil 'fullscreen) '(fullscreen fullboth))
(modify-frame-parameters
nil
`((maximized
. ,(unless (eq (frame-parameter nil 'maximized) 'maximized)
'maximized))))
(modify-frame-parameters
nil
`((fullscreen
. ,(unless (eq (frame-parameter nil 'fullscreen) 'maximized)
'maximized))))))
(let ((fullscreen (frame-parameter nil 'fullscreen)))
(cond
((memq fullscreen '(fullscreen fullboth))
(set-frame-parameter nil 'fullscreen-restore 'maximized))
((eq fullscreen 'maximized)
(set-frame-parameter nil 'fullscreen nil))
(t
(set-frame-parameter nil 'fullscreen 'maximized)))))
(defun toggle-frame-fullscreen ()
"Toggle fullscreen mode of the selected frame.
Enable fullscreen mode of the selected frame or disable if it is
already fullscreen. Ignore window manager screen decorations.
When turning on fullscreen mode, remember the previous value of the
maximization state in the temporary frame parameter `maximized'.
Restore the maximization state when turning off fullscreen mode.
"Toggle fullscreen state of selected frame.
Make selected frame fullscreen or restore its previous size if it
is already fullscreen.
Before making the frame fullscreen remember the current value of
the frame's `fullscreen' parameter in the `fullscreen-restore'
parameter of the frame. That value is used to restore the
frame's size when toggling fullscreen the next time.
Note that with some window managers you may have to set
`frame-resize-pixelwise' to non-nil in order to make a frame
appear truly fullscreen.
appear truly fullscreen. In addition, you may have to set
`x-frame-normalize-before-maximize' in order to enable
transitions from one fullscreen state to another.
See also `toggle-frame-maximized'."
(interactive)
(modify-frame-parameters
nil
`((maximized
. ,(unless (memq (frame-parameter nil 'fullscreen) '(fullscreen fullboth))
(frame-parameter nil 'fullscreen)))
(fullscreen
. ,(if (memq (frame-parameter nil 'fullscreen) '(fullscreen fullboth))
(if (eq (frame-parameter nil 'maximized) 'maximized)
'maximized)
'fullscreen)))))
(let ((fullscreen (frame-parameter nil 'fullscreen)))
(if (memq fullscreen '(fullscreen fullboth))
(let ((fullscreen-restore (frame-parameter nil 'fullscreen-restore)))
(if (memq fullscreen-restore '(maximized fullheight fullwidth))
(set-frame-parameter nil 'fullscreen fullscreen-restore)
(set-frame-parameter nil 'fullscreen nil)))
(modify-frame-parameters
nil `((fullscreen . fullboth) (fullscreen-restore . ,fullscreen))))))
;;;; Key bindings

View file

@ -1,3 +1,15 @@
2015-02-11 Martin Rudalics <rudalics@gmx.at>
* w32term.c (w32_read_socket): In SIZE_MAXIMIZED and
SIZE_RESTORED cases correctly handle `maximized' value for the
`fullscreen' parameter. Don't use 'maximized' frame parameter
any more.
(w32fullscreen_hook): Include menu bar height when calculating
new text height in FULLSCREEN_BOTH case.
* xterm.c (do_ewmh_fullscreen): Handle transition from
FULLSCREEN_BOTH to FULLSCREEN_MAXIMIZED when
x_frame_normalize_before_maximize is set.
2015-02-10 Paul Eggert <eggert@cs.ucla.edu>
Use bool for boolean in xdisp.c

View file

@ -5052,6 +5052,7 @@ w32_read_socket (struct terminal *terminal,
case SIZE_MAXIMIZED:
{
bool iconified = FRAME_ICONIFIED_P (f);
Lisp_Object fullscreen = get_frame_param (f, Qfullscreen);
SET_FRAME_VISIBLE (f, 1);
SET_FRAME_ICONIFIED (f, false);
@ -5082,12 +5083,22 @@ w32_read_socket (struct terminal *terminal,
to update the frame titles
in case this is the second frame. */
record_asynch_buffer_change ();
}
if (EQ (get_frame_param (f, Qfullscreen), Qnil))
set_frame_param (f, Qfullscreen, Qmaximized);
else if (! EQ (get_frame_param (f, Qfullscreen), Qmaximized))
set_frame_param (f, Qmaximized, Qmaximized);
/* Windows can send us a SIZE_MAXIMIZED message even
when fullscreen is fullboth. The following is a
simple hack to check that based on the fact that
only a maximized fullscreen frame should have both
top/left outside the screen. */
if (EQ (fullscreen, Qfullwidth) || EQ (fullscreen, Qfullheight)
|| NILP (fullscreen))
{
int x, y;
x_real_positions (f, &x, &y);
if (x < 0 && y < 0)
store_frame_param (f, Qfullscreen, Qmaximized);
}
}
break;
@ -5128,9 +5139,7 @@ w32_read_socket (struct terminal *terminal,
}
if (EQ (get_frame_param (f, Qfullscreen), Qmaximized))
set_frame_param (f, Qfullscreen, Qnil);
else if (! EQ (get_frame_param (f, Qmaximized), Qnil))
set_frame_param (f, Qmaximized, Qnil);
store_frame_param (f, Qfullscreen, Qnil);
break;
}
@ -6008,6 +6017,8 @@ w32fullscreen_hook (struct frame *f)
}
else if (f->want_fullscreen == FULLSCREEN_BOTH)
{
int menu_bar_height = GetSystemMetrics (SM_CYMENU);
w32_fullscreen_rect (hwnd, f->want_fullscreen,
FRAME_NORMAL_PLACEMENT (f).rcNormalPosition, &rect);
SetWindowLong (hwnd, GWL_STYLE, dwStyle & ~WS_OVERLAPPEDWINDOW);
@ -6016,7 +6027,8 @@ w32fullscreen_hook (struct frame *f)
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
change_frame_size
(f, FRAME_PIXEL_TO_TEXT_WIDTH (f, rect.right - rect.left),
FRAME_PIXEL_TO_TEXT_HEIGHT (f, rect.bottom - rect.top),
FRAME_PIXEL_TO_TEXT_HEIGHT (f, (rect.bottom - rect.top
- menu_bar_height)),
0, 1, 0, 1);
}
else

View file

@ -9271,7 +9271,15 @@ do_ewmh_fullscreen (struct frame *f)
}
break;
case FULLSCREEN_MAXIMIZED:
if (x_frame_normalize_before_maximize && cur == FULLSCREEN_WIDTH)
if (x_frame_normalize_before_maximize && cur == FULLSCREEN_BOTH)
{
set_wm_state (frame, false,
dpyinfo->Xatom_net_wm_state_fullscreen, None);
set_wm_state (frame, true,
dpyinfo->Xatom_net_wm_state_maximized_horz,
dpyinfo->Xatom_net_wm_state_maximized_vert);
}
else if (x_frame_normalize_before_maximize && cur == FULLSCREEN_WIDTH)
{
set_wm_state (frame, false,
dpyinfo->Xatom_net_wm_state_maximized_horz, None);