mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-22 06:38:37 -05:00
RDB's fix to full-screen mode. Apparently sorts out most of the
fullscreen/maximised confusions, by treating fullscreen as a special case of maximised (fair enough). Removes dependency on multimon.h, but Wez thinks (though he was unable to test) that this version should naturally do the Right Thing on multi-monitor systems anyway. [originally from svn r1365]
This commit is contained in:
parent
2fe380a9ca
commit
4fd313f258
100
window.c
100
window.c
@ -10,11 +10,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (WINVER < 0x0500) && !defined(NO_MULTIMON)
|
|
||||||
#define COMPILE_MULTIMON_STUBS
|
|
||||||
#include <multimon.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@ -79,18 +74,13 @@ static void deinit_fonts(void);
|
|||||||
|
|
||||||
/* Window layout information */
|
/* Window layout information */
|
||||||
static void reset_window(int);
|
static void reset_window(int);
|
||||||
static int full_screen = 0, want_full_screen = 0;
|
static int full_screen = 0;
|
||||||
static int extra_width, extra_height;
|
static int extra_width, extra_height;
|
||||||
static int font_width, font_height, font_dualwidth;
|
static int font_width, font_height, font_dualwidth;
|
||||||
static int offset_width, offset_height;
|
static int offset_width, offset_height;
|
||||||
static int was_zoomed = 0;
|
static int was_zoomed = 0;
|
||||||
static int was_full_screen = 0;
|
|
||||||
static int prev_rows, prev_cols;
|
static int prev_rows, prev_cols;
|
||||||
static int pre_fs_rows, pre_fs_cols;
|
|
||||||
|
|
||||||
static LONG old_wind_style;
|
|
||||||
static WINDOWPLACEMENT old_wind_placement;
|
|
||||||
|
|
||||||
static int pending_netevent = 0;
|
static int pending_netevent = 0;
|
||||||
static WPARAM pend_netevent_wParam = 0;
|
static WPARAM pend_netevent_wParam = 0;
|
||||||
static LPARAM pend_netevent_lParam = 0;
|
static LPARAM pend_netevent_lParam = 0;
|
||||||
@ -1201,7 +1191,7 @@ static void reset_window(int reinit) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsZoomed(hwnd) || full_screen) {
|
if (IsZoomed(hwnd)) {
|
||||||
/* We're fullscreen, this means we must not change the size of
|
/* We're fullscreen, this means we must not change the size of
|
||||||
* the window so it's the font size or the terminal itself.
|
* the window so it's the font size or the terminal itself.
|
||||||
*/
|
*/
|
||||||
@ -2082,11 +2072,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||||||
if (cfg.resize_action != RESIZE_FONT)
|
if (cfg.resize_action != RESIZE_FONT)
|
||||||
term_size(prev_rows, prev_cols, cfg.savelines);
|
term_size(prev_rows, prev_cols, cfg.savelines);
|
||||||
reset_window(0);
|
reset_window(0);
|
||||||
} else if (was_full_screen) {
|
|
||||||
was_full_screen = 0;
|
|
||||||
if (cfg.resize_action != RESIZE_FONT)
|
|
||||||
term_size(pre_fs_rows, pre_fs_cols, cfg.savelines);
|
|
||||||
reset_window(0);
|
|
||||||
}
|
}
|
||||||
/* This is an unexpected resize, these will normally happen
|
/* This is an unexpected resize, these will normally happen
|
||||||
* if the window is too large. Probably either the user
|
* if the window is too large. Probably either the user
|
||||||
@ -3864,58 +3849,53 @@ void beep(int mode)
|
|||||||
*/
|
*/
|
||||||
static void flip_full_screen(void)
|
static void flip_full_screen(void)
|
||||||
{
|
{
|
||||||
want_full_screen = !want_full_screen;
|
WINDOWPLACEMENT wp;
|
||||||
|
LONG style;
|
||||||
|
|
||||||
if (full_screen == want_full_screen)
|
wp.length = sizeof(wp);
|
||||||
return;
|
GetWindowPlacement(hwnd, &wp);
|
||||||
|
|
||||||
full_screen = want_full_screen;
|
full_screen = !full_screen;
|
||||||
|
|
||||||
old_wind_placement.length = sizeof(old_wind_placement);
|
|
||||||
|
|
||||||
if (full_screen) {
|
if (full_screen) {
|
||||||
int x, y, cx, cy;
|
if (wp.showCmd == SW_SHOWMAXIMIZED) {
|
||||||
#if !defined(NO_MULTIMON) && defined(MONITOR_DEFAULTTONEAREST)
|
/* Ooops it was already 'zoomed' we have to unzoom it before
|
||||||
/* The multi-monitor safe way of doing things */
|
* everything will work right.
|
||||||
HMONITOR mon;
|
*/
|
||||||
MONITORINFO mi;
|
wp.showCmd = SW_SHOWNORMAL;
|
||||||
|
SetWindowPlacement(hwnd, &wp);
|
||||||
|
}
|
||||||
|
|
||||||
mon = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
|
style = GetWindowLong(hwnd, GWL_STYLE) & ~WS_CAPTION;
|
||||||
mi.cbSize = sizeof(mi);
|
style &= ~WS_VSCROLL;
|
||||||
GetMonitorInfo(mon, &mi);
|
if (cfg.scrollbar_in_fullscreen)
|
||||||
x = mi.rcMonitor.left;
|
style |= WS_VSCROLL;
|
||||||
y = mi.rcMonitor.top;
|
SetWindowLong(hwnd, GWL_STYLE, style);
|
||||||
cx = mi.rcMonitor.right;
|
|
||||||
cy = mi.rcMonitor.bottom;
|
|
||||||
#else
|
|
||||||
/* good old fashioned way of doing it */
|
|
||||||
x = 0;
|
|
||||||
y = 0;
|
|
||||||
cx = GetSystemMetrics(SM_CXSCREEN);
|
|
||||||
cy = GetSystemMetrics(SM_CYSCREEN);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* save rows for when we "restore" back down again */
|
/* This seems to be needed otherwize explorer doesn't notice
|
||||||
pre_fs_rows = rows;
|
* we want to go fullscreen and it's bar is still visible
|
||||||
pre_fs_cols = cols;
|
*/
|
||||||
|
SetWindowPos(hwnd, NULL, 0, 0, 0, 0,
|
||||||
|
SWP_NOACTIVATE | SWP_NOCOPYBITS |
|
||||||
|
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
|
||||||
|
SWP_FRAMECHANGED);
|
||||||
|
|
||||||
GetWindowPlacement(hwnd, &old_wind_placement);
|
wp.showCmd = SW_SHOWMAXIMIZED;
|
||||||
SetWindowLong(hwnd, GWL_STYLE,
|
SetWindowPlacement(hwnd, &wp);
|
||||||
GetWindowLong(hwnd, GWL_STYLE)
|
|
||||||
& ~((cfg.scrollbar_in_fullscreen ? 0 : WS_VSCROLL)
|
|
||||||
| WS_CAPTION | WS_BORDER | WS_THICKFRAME));
|
|
||||||
/* become topmost */
|
|
||||||
SetWindowPos(hwnd, HWND_TOP, x, y, cx, cy, SWP_FRAMECHANGED);
|
|
||||||
} else {
|
} else {
|
||||||
was_full_screen = 1;
|
style = GetWindowLong(hwnd, GWL_STYLE) | WS_CAPTION;
|
||||||
SetWindowLong(hwnd, GWL_STYLE,
|
style &= ~WS_VSCROLL;
|
||||||
GetWindowLong(hwnd, GWL_STYLE)
|
if (cfg.scrollbar)
|
||||||
| (cfg.scrollbar ? WS_VSCROLL : 0)
|
style |= WS_VSCROLL;
|
||||||
| WS_CAPTION | WS_BORDER | WS_THICKFRAME);
|
SetWindowLong(hwnd, GWL_STYLE, style);
|
||||||
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,
|
|
||||||
SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
|
/* Don't need to do a SetWindowPos as the resize will force a
|
||||||
SetWindowPlacement(hwnd,&old_wind_placement);
|
* full redraw.
|
||||||
|
*/
|
||||||
|
wp.showCmd = SW_SHOWNORMAL;
|
||||||
|
SetWindowPlacement(hwnd, &wp);
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckMenuItem(GetSystemMenu(hwnd, FALSE), IDM_FULLSCREEN,
|
CheckMenuItem(GetSystemMenu(hwnd, FALSE), IDM_FULLSCREEN,
|
||||||
MF_BYCOMMAND| full_screen ? MF_CHECKED : MF_UNCHECKED);
|
MF_BYCOMMAND| full_screen ? MF_CHECKED : MF_UNCHECKED);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user