emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r112337: Better full-screen frame sup


From: Eli Zaretskii
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r112337: Better full-screen frame support on MS-Windows.
Date: Sat, 20 Apr 2013 10:32:31 +0300
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 112337 [merge]
fixes bug: http://debbugs.gnu.org/14180
author: Erik Charlebois <address@hidden>
committer: Eli Zaretskii <address@hidden>
branch nick: trunk
timestamp: Sat 2013-04-20 10:32:31 +0300
message:
  Better full-screen frame support on MS-Windows.
  
   src/w32fns.c (w32_fullscreen_rect): New function to compute the
   window rectangle for the given fullscreen mode.
   (w32_wnd_proc): When in a fullscreen mode, WM_WINDOWPOSCHANGING no
   longer tunes the window size.  This keeps the window's edges flush
   with the screen and allows the taskbar to hide itself in fullboth.
   src/w32term.c (w32fullscreen_hook): 'fullboth' now shows without
   window decorations and uses the entire screen.
   src/w32term.h  (w32_fullscreen_rect) Add prototype.
   (struct w32_output): Replace normal_width, normal_height,
   normal_top, and normal_left members with a single normal_placement
   struct.
   (FRAME_NORMAL_WIDTH, FRAME_NORMAL_HEIGHT, FRAME_NORMAL_TOP):
   Remove macros.
   (FRAME_NORMAL_PLACEMENT): New macro.
modified:
  src/ChangeLog
  src/w32fns.c
  src/w32term.c
  src/w32term.h
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-04-16 02:52:53 +0000
+++ b/src/ChangeLog     2013-04-20 07:32:31 +0000
@@ -1,3 +1,22 @@
+2013-04-20  Erik Charlebois  <address@hidden>
+
+       * w32fns.c (w32_fullscreen_rect): New function to compute the
+       window rectangle for the given fullscreen mode.
+       (w32_wnd_proc): When in a fullscreen mode, WM_WINDOWPOSCHANGING no
+       longer tunes the window size.  This keeps the window's edges flush
+       with the screen and allows the taskbar to hide itself in fullboth.
+
+       * w32term.c (w32fullscreen_hook): 'fullboth' now shows without
+       window decorations and uses the entire screen.
+
+       * w32term.h  (w32_fullscreen_rect) Add prototype.
+       (struct w32_output): Replace normal_width, normal_height,
+       normal_top, and normal_left members with a single normal_placement
+       struct.
+       (FRAME_NORMAL_WIDTH, FRAME_NORMAL_HEIGHT, FRAME_NORMAL_TOP):
+       Remove macros.
+       (FRAME_NORMAL_PLACEMENT): New macro.
+
 2013-04-16  Juanma Barranquero  <address@hidden>
 
        * minibuf.c (Ftest_completion): Silence compiler warning.

=== modified file 'src/w32fns.c'
--- a/src/w32fns.c      2013-04-15 07:27:56 +0000
+++ b/src/w32fns.c      2013-04-20 07:32:31 +0000
@@ -157,6 +157,8 @@
 typedef HMONITOR (WINAPI * MonitorFromPoint_Proc) (IN POINT pt, IN DWORD 
flags);
 typedef BOOL (WINAPI * GetMonitorInfo_Proc)
   (IN HMONITOR monitor, OUT struct MONITOR_INFO* info);
+typedef HMONITOR (WINAPI * MonitorFromWindow_Proc)
+  (IN HWND hwnd, IN DWORD dwFlags);
 
 TrackMouseEvent_Proc track_mouse_event_fn = NULL;
 ImmGetCompositionString_Proc get_composition_string_fn = NULL;
@@ -165,6 +167,7 @@
 ImmSetCompositionWindow_Proc set_ime_composition_window_fn = NULL;
 MonitorFromPoint_Proc monitor_from_point_fn = NULL;
 GetMonitorInfo_Proc get_monitor_info_fn = NULL;
+MonitorFromWindow_Proc monitor_from_window_fn = NULL;
 
 #ifdef NTGUI_UNICODE
 #define unicode_append_menu AppendMenuW
@@ -336,6 +339,66 @@
   *yptr = rect.top;
 }
 
+/* Returns the window rectangle appropriate for the given fullscreen mode.
+   The normal rect parameter was the window's rectangle prior to entering
+   fullscreen mode.  If multiple monitor support is available, the nearest
+   monitor to the window is chosen.  */
+
+void
+w32_fullscreen_rect (HWND hwnd, int fsmode, RECT normal, RECT *rect)
+{
+  struct MONITOR_INFO mi = { sizeof(mi) };
+  if (monitor_from_window_fn && get_monitor_info_fn)
+    {
+      HMONITOR monitor =
+        monitor_from_window_fn (hwnd, MONITOR_DEFAULT_TO_NEAREST);
+      get_monitor_info_fn (monitor, &mi);
+    }
+  else
+    {
+      mi.rcMonitor.left = 0;
+      mi.rcMonitor.top = 0;
+      mi.rcMonitor.right = GetSystemMetrics (SM_CXSCREEN);
+      mi.rcMonitor.bottom = GetSystemMetrics (SM_CYSCREEN);
+      mi.rcWork.left = 0;
+      mi.rcWork.top = 0;
+      mi.rcWork.right = GetSystemMetrics (SM_CXMAXIMIZED);
+      mi.rcWork.bottom = GetSystemMetrics (SM_CYMAXIMIZED);
+    }
+
+  switch (fsmode)
+    {
+    case FULLSCREEN_BOTH:
+      rect->left = mi.rcMonitor.left;
+      rect->top = mi.rcMonitor.top;
+      rect->right = mi.rcMonitor.right;
+      rect->bottom = mi.rcMonitor.bottom;
+      break;
+    case FULLSCREEN_MAXIMIZED:
+      rect->left = mi.rcWork.left;
+      rect->top = mi.rcWork.top;
+      rect->right = mi.rcWork.right;
+      rect->bottom = mi.rcWork.bottom;
+      break;
+    case FULLSCREEN_WIDTH:
+      rect->left = mi.rcWork.left;
+      rect->top = normal.top;
+      rect->right = mi.rcWork.right;
+      rect->bottom = normal.bottom;
+      break;
+    case FULLSCREEN_HEIGHT:
+      rect->left = normal.left;
+      rect->top = mi.rcWork.top;
+      rect->right = normal.right;
+      rect->bottom = mi.rcWork.bottom;
+      break;
+    case FULLSCREEN_NONE:
+    default:
+      *rect = normal;
+      break;
+    }
+}
+
 
 
 DEFUN ("w32-define-rgb-color", Fw32_define_rgb_color,
@@ -3693,6 +3756,13 @@
       /* Don't restrict the sizing of tip frames.  */
       if (hwnd == tip_window)
        return 0;
+
+      /* Don't restrict the sizing of fullscreened frames, allowing them to be
+         flush with the sides of the screen.  */
+      f = x_window_to_frame (dpyinfo, hwnd);
+      if (f && FRAME_PREV_FSMODE (f) != FULLSCREEN_NONE)
+        return 0;
+
       {
        WINDOWPLACEMENT wp;
        LPWINDOWPOS lppos = (WINDOWPOS *) lParam;
@@ -7637,6 +7707,8 @@
     GetProcAddress (user32_lib, "MonitorFromPoint");
   get_monitor_info_fn = (GetMonitorInfo_Proc)
     GetProcAddress (user32_lib, "GetMonitorInfoA");
+  monitor_from_window_fn = (MonitorFromWindow_Proc)
+    GetProcAddress (user32_lib, "MonitorFromWindow");
 
   {
     HMODULE imm32_lib = GetModuleHandle ("imm32.dll");

=== modified file 'src/w32term.c'
--- a/src/w32term.c     2013-04-01 07:58:04 +0000
+++ b/src/w32term.c     2013-04-14 00:58:45 +0000
@@ -5663,88 +5663,40 @@
 {
   if (FRAME_VISIBLE_P (f))
     {
-      int width, height, top_pos, left_pos, pixel_height, pixel_width;
-      int cur_w = FRAME_COLS (f), cur_h = FRAME_LINES (f);
-      RECT workarea_rect;
-
-      block_input ();
-      /* Record current "normal" dimensions for restoring later.  */
-      if (!(   FRAME_PREV_FSMODE (f) == FULLSCREEN_BOTH
-           || FRAME_PREV_FSMODE (f) == FULLSCREEN_MAXIMIZED))
-       {
-         if (FRAME_PREV_FSMODE (f) != FULLSCREEN_HEIGHT)
-           {
-             FRAME_NORMAL_HEIGHT (f) = cur_h;
-             FRAME_NORMAL_TOP (f) = f->top_pos;
-           }
-         if (FRAME_PREV_FSMODE (f) != FULLSCREEN_WIDTH)
-           {
-             FRAME_NORMAL_WIDTH (f)  = cur_w;
-             FRAME_NORMAL_LEFT (f) = f->left_pos;
-           }
-       }
-      eassert (FRAME_NORMAL_HEIGHT (f) > 0);
-      eassert (FRAME_NORMAL_WIDTH (f) > 0);
-      x_real_positions (f, &f->left_pos, &f->top_pos);
-      x_fullscreen_adjust (f, &width, &height, &top_pos, &left_pos);
-
-      SystemParametersInfo (SPI_GETWORKAREA, 0, &workarea_rect, 0);
-      pixel_height = workarea_rect.bottom - workarea_rect.top;
-      pixel_width  = workarea_rect.right  - workarea_rect.left;
-      /* Need to send SC_RESTORE to the window, in case we are
-        resizing from FULLSCREEN_MAXIMIZED.  Otherwise, the mouse
-        resize hints will not be shown by the window manager when the
-        mouse pointer hovers over the window edges, because the WM
-        will still think the window is maximized.  */
-      if (f->want_fullscreen != FULLSCREEN_BOTH)
-       SendMessage (FRAME_W32_WINDOW (f), WM_SYSCOMMAND, SC_RESTORE, 0);
-
+      HWND hwnd = FRAME_W32_WINDOW(f);
+      DWORD dwStyle = GetWindowLong (hwnd, GWL_STYLE);
+      RECT rect;
+
+      block_input();
+      f->want_fullscreen &= ~FULLSCREEN_WAIT;
+
+      if (FRAME_PREV_FSMODE (f) == FULLSCREEN_NONE)
+        GetWindowPlacement (hwnd, &FRAME_NORMAL_PLACEMENT (f));
+
+      if (FRAME_PREV_FSMODE (f) == FULLSCREEN_BOTH)
+        {
+          SetWindowLong (hwnd, GWL_STYLE, dwStyle | WS_OVERLAPPEDWINDOW);
+          SetWindowPos (hwnd, NULL, 0, 0, 0, 0,
+                        SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
+                        SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
+        }
+
+      w32_fullscreen_rect (hwnd, f->want_fullscreen,
+                           FRAME_NORMAL_PLACEMENT (f).rcNormalPosition, &rect);
       FRAME_PREV_FSMODE (f) = f->want_fullscreen;
-      switch (f->want_fullscreen)
-       {
-       case FULLSCREEN_BOTH:
-         PostMessage (FRAME_W32_WINDOW (f), WM_SYSCOMMAND, SC_MAXIMIZE, 0);
-         break;
-       case FULLSCREEN_MAXIMIZED:
-         height =
-           FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, pixel_height)
-           - XINT (Ftool_bar_lines_needed (selected_frame))
-           + (NILP (Vmenu_bar_mode) ? 1 : 0);
-         width  =
-           FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pixel_width)
-           - FRAME_SCROLL_BAR_COLS (f);
-         left_pos = workarea_rect.left;
-         top_pos = workarea_rect.top;
-         break;
-       case FULLSCREEN_WIDTH:
-         width  =
-           FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pixel_width)
-           - FRAME_SCROLL_BAR_COLS (f);
-         height = FRAME_NORMAL_HEIGHT (f);
-         left_pos = workarea_rect.left;
-         break;
-       case FULLSCREEN_HEIGHT:
-         height =
-           FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, pixel_height)
-           - XINT (Ftool_bar_lines_needed (selected_frame))
-           + (NILP (Vmenu_bar_mode) ? 1 : 0);
-         width = FRAME_NORMAL_WIDTH (f);
-         top_pos = workarea_rect.top;
-         break;
-       case FULLSCREEN_NONE:
-         height = FRAME_NORMAL_HEIGHT (f);
-         width = FRAME_NORMAL_WIDTH (f);
-         left_pos = FRAME_NORMAL_LEFT (f);
-         top_pos = FRAME_NORMAL_TOP (f);
-         break;
-       }
+      if (f->want_fullscreen == FULLSCREEN_BOTH)
+        {
+          SetWindowLong (hwnd, GWL_STYLE, dwStyle & ~WS_OVERLAPPEDWINDOW);
+          SetWindowPos (hwnd, HWND_TOP, rect.left, rect.top,
+                        rect.right - rect.left, rect.bottom - rect.top,
+                        SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
+        }
+      else
+        {
+          SetWindowPos (hwnd, HWND_TOP, rect.left, rect.top,
+                        rect.right - rect.left, rect.bottom - rect.top, 0);
+        }
 
-      if (cur_w != width || cur_h != height)
-       {
-         x_set_offset (f, left_pos, top_pos, 1);
-         x_set_window_size (f, 1, width, height);
-         do_pending_window_change (0);
-       }
       f->want_fullscreen = FULLSCREEN_NONE;
       unblock_input ();
     }

=== modified file 'src/w32term.h'
--- a/src/w32term.h     2013-04-07 04:41:19 +0000
+++ b/src/w32term.h     2013-04-14 00:58:45 +0000
@@ -71,6 +71,8 @@
 };
 
 extern void w32_regenerate_palette (struct frame *f);
+extern void w32_fullscreen_rect (HWND hwnd, int fsmode, RECT normal,
+                                 RECT *rect);
 
 
 /* For each display (currently only one on w32), we have a structure that
@@ -362,7 +364,7 @@
   /* Frame geometry and full-screen mode before it was resized by
      specifying the 'fullscreen' frame parameter.  Used to restore the
      geometry when 'fullscreen' is reset to nil.  */
-  int normal_width, normal_height, normal_top, normal_left;
+  WINDOWPLACEMENT normal_placement;
   int prev_fsmode;
 };
 
@@ -396,11 +398,8 @@
 #define FRAME_SMALLEST_FONT_HEIGHT(F) \
      FRAME_W32_DISPLAY_INFO(F)->smallest_font_height
 
-#define FRAME_NORMAL_WIDTH(F)  ((F)->output_data.w32->normal_width)
-#define FRAME_NORMAL_HEIGHT(F) ((F)->output_data.w32->normal_height)
-#define FRAME_NORMAL_TOP(F)    ((F)->output_data.w32->normal_top)
-#define FRAME_NORMAL_LEFT(F)   ((F)->output_data.w32->normal_left)
-#define FRAME_PREV_FSMODE(F)   ((F)->output_data.w32->prev_fsmode)
+#define FRAME_NORMAL_PLACEMENT(F) ((F)->output_data.w32->normal_placement)
+#define FRAME_PREV_FSMODE(F)      ((F)->output_data.w32->prev_fsmode)
 
 
 /* W32-specific scroll bar stuff.  */


reply via email to

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