emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 02138cb: Improve toggling fullscreen state of frame


From: Martin Rudalics
Subject: [Emacs-diffs] master 02138cb: Improve toggling fullscreen state of frames.
Date: Wed, 11 Feb 2015 08:09:00 +0000

branch: master
commit 02138cb0b88c5f6addf891d725967d9867eda3f9
Author: Martin Rudalics <address@hidden>
Commit: Martin Rudalics <address@hidden>

    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.
---
 doc/lispref/ChangeLog   |    5 +++
 doc/lispref/frames.texi |   33 +++++++++++++++------
 lisp/ChangeLog          |    7 ++++
 lisp/frame.el           |   73 +++++++++++++++++++++++------------------------
 src/ChangeLog           |   12 ++++++++
 src/w32term.c           |   30 +++++++++++++------
 src/xterm.c             |   10 ++++++-
 7 files changed, 113 insertions(+), 57 deletions(-)

diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 0c76a6b..3e5d9ac 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,8 @@
+2015-02-11  Martin Rudalics  <address@hidden>
+
+       * frames.texi (Size Parameters): Update description of
+       fullscreen frame parameter.
+
 2015-02-09  Eli Zaretskii  <address@hidden>
 
        * positions.texi (Screen Lines): Update the documentation of
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi
index a6f4081..559f4cc 100644
--- a/doc/lispref/frames.texi
+++ b/doc/lispref/frames.texi
@@ -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
address@hidden specifies that width shall be as wide as possible.
-The value @code{fullheight} specifies that height shall be as tall as
address@hidden 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
address@hidden 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.
address@hidden 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
address@hidden (@pxref{Size and Position}) to a
address@hidden value in order to make a frame appear ``maximized'' or
-``fullscreen''.
address@hidden (@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
address@hidden can help to overcome that.
 @end table
 
+
 @node Layout Parameters
 @subsubsection Layout Parameters
 @cindex layout parameters of frames
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 03b465e..a6e5f59 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
+2015-02-11  Martin Rudalics  <address@hidden>
+
+       * 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  <address@hidden>
 
        * net/shr.el (shr-insert): Make sure the space inserted has the
diff --git a/lisp/frame.el b/lisp/frame.el
index ecb433e..dfcebf1 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -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
 
diff --git a/src/ChangeLog b/src/ChangeLog
index b4abdc5..f8e65d5 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,15 @@
+2015-02-11  Martin Rudalics  <address@hidden>
+
+       * 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  <address@hidden>
 
        Use bool for boolean in xdisp.c
diff --git a/src/w32term.c b/src/w32term.c
index fb9d238..a9ed2a8 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -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
diff --git a/src/xterm.c b/src/xterm.c
index 6a63a45..0b3efe7 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -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);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]