1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-03-22 14:39:24 -05:00

Wez Furlong's patch to tidy up full-screen mode: make it

multi-monitor aware and make the scrollbar separately configurable
in and out of full-screen mode. Also (not Wez's patch, this bit) fix
the case where the user reconfigures _while_ the window is
full-screen, and disables full-screening. (In this case the window
should return gracefully to normal, rather than losing all its title
bars and getting confused.)

[originally from svn r1310]
This commit is contained in:
Simon Tatham 2001-10-17 21:21:03 +00:00
parent 22deaf4e08
commit 05226e43a9
7 changed files with 101 additions and 22 deletions

View File

@ -67,7 +67,7 @@
# LFLAGS = /debug # LFLAGS = /debug
# Disable debug and incremental linking and compiling # Disable debug and incremental linking and compiling
CFLAGS = /nologo /W3 /O1 /D_WINDOWS /D_WIN32_WINDOWS=0x401 CFLAGS = /nologo /W3 /O1 /D_WINDOWS /D_WIN32_WINDOWS=0x401 /DWINVER=0x401
LFLAGS = /incremental:no /fixed LFLAGS = /incremental:no /fixed
# Use MSVC DLL # Use MSVC DLL

View File

@ -130,6 +130,9 @@ print
"# so that the .rsp files still depend on the correct makefile.\n". "# so that the .rsp files still depend on the correct makefile.\n".
"MAKEFILE = Makefile.bor\n". "MAKEFILE = Makefile.bor\n".
"\n". "\n".
"# C compilation flags\n".
"CFLAGS = -DWINVER=0x0401\n".
"\n".
"# Get include directory for resource compiler\n". "# Get include directory for resource compiler\n".
"!if !\$d(BCB)\n". "!if !\$d(BCB)\n".
"BCB = \$(MAKEDIR)\\..\n". "BCB = \$(MAKEDIR)\\..\n".
@ -139,7 +142,7 @@ print
"\tbcc32 -w-aus -w-ccc -w-par \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) /c \$*.c\n". "\tbcc32 -w-aus -w-ccc -w-par \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) /c \$*.c\n".
".rc.res:\n". ".rc.res:\n".
"\tbrcc32 \$(FWHACK) \$(RCFL) -i \$(BCB)\\include \\\n". "\tbrcc32 \$(FWHACK) \$(RCFL) -i \$(BCB)\\include \\\n".
"\t\t-r -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0400 \$*.rc\n". "\t\t-r -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401 \$*.rc\n".
"\n". "\n".
"OBJ=obj\n". "OBJ=obj\n".
"RES=res\n". "RES=res\n".

View File

@ -303,6 +303,7 @@ typedef struct {
int bellovl_s; /* period of silence to re-enable bell (s) */ int bellovl_s; /* period of silence to re-enable bell (s) */
char bell_wavefile[FILENAME_MAX]; char bell_wavefile[FILENAME_MAX];
int scrollbar; int scrollbar;
int scrollbar_in_fullscreen;
enum { RESIZE_TERM, RESIZE_DISABLED, RESIZE_FONT } resize_action; enum { RESIZE_TERM, RESIZE_DISABLED, RESIZE_FONT } resize_action;
int bce; int bce;
int blinktext; int blinktext;

View File

@ -250,6 +250,7 @@ void save_settings(char *section, int do_host, Config * cfg)
write_setting_s(sesskey, "LineCodePage", cfg->line_codepage); write_setting_s(sesskey, "LineCodePage", cfg->line_codepage);
write_setting_i(sesskey, "CapsLockCyr", cfg->xlat_capslockcyr); write_setting_i(sesskey, "CapsLockCyr", cfg->xlat_capslockcyr);
write_setting_i(sesskey, "ScrollBar", cfg->scrollbar); write_setting_i(sesskey, "ScrollBar", cfg->scrollbar);
write_setting_i(sesskey, "ScrollBarFullScreen", cfg->scrollbar_in_fullscreen);
write_setting_i(sesskey, "ScrollOnKey", cfg->scroll_on_key); write_setting_i(sesskey, "ScrollOnKey", cfg->scroll_on_key);
write_setting_i(sesskey, "ScrollOnDisp", cfg->scroll_on_disp); write_setting_i(sesskey, "ScrollOnDisp", cfg->scroll_on_disp);
write_setting_i(sesskey, "LockSize", cfg->resize_action); write_setting_i(sesskey, "LockSize", cfg->resize_action);
@ -473,6 +474,7 @@ void load_settings(char *section, int do_host, Config * cfg)
sizeof(cfg->line_codepage)); sizeof(cfg->line_codepage));
gppi (sesskey, "CapsLockCyr", 0, &cfg->xlat_capslockcyr); gppi (sesskey, "CapsLockCyr", 0, &cfg->xlat_capslockcyr);
gppi(sesskey, "ScrollBar", 1, &cfg->scrollbar); gppi(sesskey, "ScrollBar", 1, &cfg->scrollbar);
gppi(sesskey, "ScrollBarFullScreen", 0, &cfg->scrollbar_in_fullscreen);
gppi(sesskey, "ScrollOnKey", 0, &cfg->scroll_on_key); gppi(sesskey, "ScrollOnKey", 0, &cfg->scroll_on_key);
gppi(sesskey, "ScrollOnDisp", 1, &cfg->scroll_on_disp); gppi(sesskey, "ScrollOnDisp", 1, &cfg->scroll_on_disp);
gppi(sesskey, "LockSize", 0, &cfg->resize_action); gppi(sesskey, "LockSize", 0, &cfg->resize_action);

View File

@ -34,24 +34,24 @@ BEGIN
END END
/* Accelerators used: aco */ /* Accelerators used: aco */
IDD_MAINBOX DIALOG DISCARDABLE 0, 0, 280, 242 IDD_MAINBOX DIALOG DISCARDABLE 0, 0, 280, 252
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "PuTTY Configuration" CAPTION "PuTTY Configuration"
FONT 8, "MS Sans Serif" FONT 8, "MS Sans Serif"
BEGIN BEGIN
DEFPUSHBUTTON "&Open", IDOK, 184, 225, 44, 14 DEFPUSHBUTTON "&Open", IDOK, 184, 235, 44, 14
PUSHBUTTON "&Cancel", IDCANCEL, 231, 225, 44, 14 PUSHBUTTON "&Cancel", IDCANCEL, 231, 235, 44, 14
PUSHBUTTON "&About", IDC_ABOUT, 3, 225, 44, 14, NOT WS_TABSTOP PUSHBUTTON "&About", IDC_ABOUT, 3, 235, 44, 14, NOT WS_TABSTOP
END END
/* Accelerators used: ac */ /* Accelerators used: ac */
IDD_RECONF DIALOG DISCARDABLE 0, 0, 280, 242 IDD_RECONF DIALOG DISCARDABLE 0, 0, 280, 252
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "PuTTY Reconfiguration" CAPTION "PuTTY Reconfiguration"
FONT 8, "MS Sans Serif" FONT 8, "MS Sans Serif"
BEGIN BEGIN
DEFPUSHBUTTON "&Apply", IDOK, 184, 225, 44, 14 DEFPUSHBUTTON "&Apply", IDOK, 184, 235, 44, 14
PUSHBUTTON "&Cancel", IDCANCEL, 231, 225, 44, 14 PUSHBUTTON "&Cancel", IDCANCEL, 231, 235, 44, 14
END END
/* Accelerators used: co */ /* Accelerators used: co */

View File

@ -359,6 +359,7 @@ enum { IDCX_ABOUT =
IDC_RESIZEFONT, IDC_RESIZEFONT,
IDC_RESIZENONE, IDC_RESIZENONE,
IDC_SCROLLBAR, IDC_SCROLLBAR,
IDC_SCROLLBARFULLSCREEN,
IDC_CLOSEWARN, IDC_CLOSEWARN,
IDC_SAVESTATIC, IDC_SAVESTATIC,
IDC_SAVEEDIT, IDC_SAVEEDIT,
@ -675,6 +676,7 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
cfg.cursor_type == 1 ? IDC_CURUNDER : IDC_CURVERT); cfg.cursor_type == 1 ? IDC_CURUNDER : IDC_CURVERT);
CheckDlgButton(hwnd, IDC_BLINKCUR, cfg.blink_cur); CheckDlgButton(hwnd, IDC_BLINKCUR, cfg.blink_cur);
CheckDlgButton(hwnd, IDC_SCROLLBAR, cfg.scrollbar); CheckDlgButton(hwnd, IDC_SCROLLBAR, cfg.scrollbar);
CheckDlgButton(hwnd, IDC_SCROLLBARFULLSCREEN, cfg.scrollbar_in_fullscreen);
CheckRadioButton(hwnd, IDC_RESIZETERM, IDC_RESIZENONE, CheckRadioButton(hwnd, IDC_RESIZETERM, IDC_RESIZENONE,
cfg.resize_action == RESIZE_TERM ? IDC_RESIZETERM : cfg.resize_action == RESIZE_TERM ? IDC_RESIZETERM :
cfg.resize_action == RESIZE_FONT ? IDC_RESIZEFONT : cfg.resize_action == RESIZE_FONT ? IDC_RESIZEFONT :
@ -1040,7 +1042,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
} }
if (panel == windowpanelstart) { if (panel == windowpanelstart) {
/* The Window panel. Accelerators used: [acgo] rmz sdkp w4ylt f */ /* The Window panel. Accelerators used: [acgo] rmz sdikp w4ylt f */
struct ctlpos cp; struct ctlpos cp;
ctlposinit(&cp, hwnd, 80, 3, 13); ctlposinit(&cp, hwnd, 80, 3, 13);
bartitle(&cp, "Options controlling PuTTY's window", bartitle(&cp, "Options controlling PuTTY's window",
@ -1059,6 +1061,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
staticedit(&cp, "Lines of &scrollback", staticedit(&cp, "Lines of &scrollback",
IDC_SAVESTATIC, IDC_SAVEEDIT, 50); IDC_SAVESTATIC, IDC_SAVEEDIT, 50);
checkbox(&cp, "&Display scrollbar", IDC_SCROLLBAR); checkbox(&cp, "&Display scrollbar", IDC_SCROLLBAR);
checkbox(&cp, "D&isplay scrollbar in full screen mode", IDC_SCROLLBARFULLSCREEN);
checkbox(&cp, "Reset scrollback on &keypress", IDC_SCROLLKEY); checkbox(&cp, "Reset scrollback on &keypress", IDC_SCROLLKEY);
checkbox(&cp, "Reset scrollback on dis&play activity", checkbox(&cp, "Reset scrollback on dis&play activity",
IDC_SCROLLDISP); IDC_SCROLLDISP);
@ -1432,7 +1435,7 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
r.left = 3; r.left = 3;
r.right = r.left + 75; r.right = r.left + 75;
r.top = 13; r.top = 13;
r.bottom = r.top + 206; r.bottom = r.top + 219;
MapDialogRect(hwnd, &r); MapDialogRect(hwnd, &r);
treeview = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "", treeview = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "",
WS_CHILD | WS_VISIBLE | WS_CHILD | WS_VISIBLE |
@ -2114,6 +2117,12 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
cfg.scrollbar = cfg.scrollbar =
IsDlgButtonChecked(hwnd, IDC_SCROLLBAR); IsDlgButtonChecked(hwnd, IDC_SCROLLBAR);
break; break;
case IDC_SCROLLBARFULLSCREEN:
if (HIWORD(wParam) == BN_CLICKED ||
HIWORD(wParam) == BN_DOUBLECLICKED)
cfg.scrollbar_in_fullscreen =
IsDlgButtonChecked(hwnd, IDC_SCROLLBARFULLSCREEN);
break;
case IDC_RESIZETERM: case IDC_RESIZETERM:
case IDC_RESIZEFONT: case IDC_RESIZEFONT:
case IDC_RESIZENONE: case IDC_RESIZENONE:

View File

@ -9,6 +9,12 @@
#include <winsock.h> #include <winsock.h>
#endif #endif
#endif #endif
#if WINVER < 0x0500
#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>
@ -42,6 +48,7 @@
#define IDM_ABOUT 0x0140 #define IDM_ABOUT 0x0140
#define IDM_SAVEDSESS 0x0150 #define IDM_SAVEDSESS 0x0150
#define IDM_COPYALL 0x0160 #define IDM_COPYALL 0x0160
#define IDM_FULLSCREEN 0x0170
#define IDM_SESSLGP 0x0250 /* log type printable */ #define IDM_SESSLGP 0x0250 /* log type printable */
#define IDM_SESSLGA 0x0260 /* log type all chars */ #define IDM_SESSLGA 0x0260 /* log type all chars */
@ -72,11 +79,14 @@ 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, extra_width, extra_height; static int full_screen = 0, want_full_screen = 0;
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 LONG old_wind_style;
static WINDOWPLACEMENT old_wind_placement; static WINDOWPLACEMENT old_wind_placement;
@ -579,6 +589,8 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
AppendMenu(m, MF_ENABLED, IDM_CLRSB, "C&lear Scrollback"); AppendMenu(m, MF_ENABLED, IDM_CLRSB, "C&lear Scrollback");
AppendMenu(m, MF_ENABLED, IDM_RESET, "Rese&t Terminal"); AppendMenu(m, MF_ENABLED, IDM_RESET, "Rese&t Terminal");
AppendMenu(m, MF_SEPARATOR, 0, 0); AppendMenu(m, MF_SEPARATOR, 0, 0);
AppendMenu(m, MF_ENABLED, IDM_FULLSCREEN, "&Full Screen");
AppendMenu(m, MF_SEPARATOR, 0, 0);
AppendMenu(m, MF_ENABLED, IDM_ABOUT, "&About PuTTY"); AppendMenu(m, MF_ENABLED, IDM_ABOUT, "&About PuTTY");
} }
@ -1189,7 +1201,7 @@ static void reset_window(int reinit) {
#endif #endif
} }
if (IsZoomed(hwnd)) { if (IsZoomed(hwnd) || full_screen) {
/* 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.
*/ */
@ -1497,6 +1509,11 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
if (!do_reconfig(hwnd)) if (!do_reconfig(hwnd))
break; break;
/* If user forcibly disables full-screen, gracefully unzoom */
if (full_screen && !cfg.fullscreenonaltenter) {
flip_full_screen();
}
if (strcmp(prev_cfg.logfilename, cfg.logfilename) || if (strcmp(prev_cfg.logfilename, cfg.logfilename) ||
prev_cfg.logtype != cfg.logtype) { prev_cfg.logtype != cfg.logtype) {
logfclose(); /* reset logging */ logfclose(); /* reset logging */
@ -1661,6 +1678,9 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
if( lParam == 0 ) if( lParam == 0 )
PostMessage(hwnd, WM_CHAR, ' ', 0); PostMessage(hwnd, WM_CHAR, ' ', 0);
break; break;
case IDM_FULLSCREEN:
flip_full_screen();
break;
default: default:
if (wParam >= IDM_SAVED_MIN && wParam <= IDM_SAVED_MAX) { if (wParam >= IDM_SAVED_MIN && wParam <= IDM_SAVED_MAX) {
SendMessage(hwnd, WM_SYSCOMMAND, IDM_SAVEDSESS, wParam); SendMessage(hwnd, WM_SYSCOMMAND, IDM_SAVEDSESS, wParam);
@ -1983,7 +2003,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
return rv; return rv;
} }
break;
/* break; (never reached) */ /* break; (never reached) */
case WM_SIZE: case WM_SIZE:
#ifdef RDB_DEBUG_PATCH #ifdef RDB_DEBUG_PATCH
@ -2032,6 +2051,11 @@ 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
@ -3804,23 +3828,63 @@ void beep(int mode)
/* /*
* Toggle full screen mode. Thanks to cwis@nerim.fr for the * Toggle full screen mode. Thanks to cwis@nerim.fr for the
* implementation. * implementation.
* Revised by <wez@thebrainroom.com>
*/ */
static void flip_full_screen(void) static void flip_full_screen(void)
{ {
if (!full_screen) { want_full_screen = !want_full_screen;
int cx, cy;
if (full_screen == want_full_screen)
return;
full_screen = want_full_screen;
old_wind_placement.length = sizeof(old_wind_placement);
if (full_screen) {
int x, y, cx, cy;
#ifdef MONITOR_DEFAULTTONEAREST
/* The multi-monitor safe way of doing things */
HMONITOR mon;
MONITORINFO mi;
mon = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
mi.cbSize = sizeof(mi);
GetMonitorInfo(mon, &mi);
x = mi.rcMonitor.left;
y = mi.rcMonitor.top;
cx = mi.rcMonitor.right;
cy = mi.rcMonitor.bottom;
#else
/* good old fashioned way of doing it */
x = 0;
y = 0;
cx = GetSystemMetrics(SM_CXSCREEN); cx = GetSystemMetrics(SM_CXSCREEN);
cy = GetSystemMetrics(SM_CYSCREEN); cy = GetSystemMetrics(SM_CYSCREEN);
#endif
/* save rows for when we "restore" back down again */
pre_fs_rows = rows;
pre_fs_cols = cols;
GetWindowPlacement(hwnd, &old_wind_placement); GetWindowPlacement(hwnd, &old_wind_placement);
old_wind_style = GetWindowLong(hwnd, GWL_STYLE);
SetWindowLong(hwnd, GWL_STYLE, SetWindowLong(hwnd, GWL_STYLE,
old_wind_style & ~(WS_CAPTION | WS_BORDER | WS_THICKFRAME)); GetWindowLong(hwnd, GWL_STYLE)
SetWindowPos(hwnd, HWND_TOP, 0, 0, cx, cy, SWP_SHOWWINDOW); & ~((cfg.scrollbar_in_fullscreen ? 0 : WS_VSCROLL)
full_screen = 1; | WS_CAPTION | WS_BORDER | WS_THICKFRAME));
/* become topmost */
SetWindowPos(hwnd, HWND_TOP, x, y, cx, cy, SWP_FRAMECHANGED);
} else { } else {
SetWindowLong(hwnd, GWL_STYLE, old_wind_style); was_full_screen = 1;
SetWindowLong(hwnd, GWL_STYLE,
GetWindowLong(hwnd, GWL_STYLE)
| (cfg.scrollbar ? WS_VSCROLL : 0)
| WS_CAPTION | WS_BORDER | WS_THICKFRAME);
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
SetWindowPlacement(hwnd,&old_wind_placement); SetWindowPlacement(hwnd,&old_wind_placement);
full_screen = 0;
} }
CheckMenuItem(GetSystemMenu(hwnd, FALSE), IDM_FULLSCREEN,
MF_BYCOMMAND| full_screen ? MF_CHECKED : MF_UNCHECKED);
} }