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;
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
*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;
+ }
+}
+
\f
DEFUN ("w32-define-rgb-color", Fw32_define_rgb_color,
/* 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;
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");
{
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;
+ HWND hwnd = FRAME_W32_WINDOW(f);
+ DWORD dwStyle = GetWindowLong (hwnd, GWL_STYLE);
+ RECT 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);
+ 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 ();
}
};
extern void w32_regenerate_palette (struct frame *f);
+extern void w32_fullscreen_rect (HWND hwnd, int fsmode, RECT normal,
+ RECT *rect);
\f
/* For each display (currently only one on w32), we have a structure that
/* 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;
};
#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)
\f
/* W32-specific scroll bar stuff. */