1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-10 15:48:06 -05:00

Ability to hide the mouse pointer on a keypress a la Word

[originally from svn r883]
This commit is contained in:
Simon Tatham 2001-01-22 16:38:43 +00:00
parent 83066d174c
commit beeaa85fc5
4 changed files with 40 additions and 0 deletions

View File

@ -196,6 +196,7 @@ typedef struct {
int fontcharset;
char logfilename[FILENAME_MAX];
int logtype;
int hide_mouseptr;
/* Colour options */
int try_palette;
int bold_colour;

View File

@ -95,6 +95,7 @@ void save_settings (char *section, int do_host, Config *cfg) {
write_setting_i (sesskey, "ComposeKey", cfg->compose_key);
write_setting_i (sesskey, "LdiscTerm", cfg->ldisc_term);
write_setting_i (sesskey, "AlwaysOnTop", cfg->alwaysontop);
write_setting_i (sesskey, "HideMousePtr", cfg->hide_mouseptr);
write_setting_i (sesskey, "CurType", cfg->cursor_type);
write_setting_i (sesskey, "BlinkCur", cfg->blink_cur);
write_setting_i (sesskey, "Beep", cfg->beep);
@ -238,6 +239,7 @@ void load_settings (char *section, int do_host, Config *cfg) {
gppi (sesskey, "ComposeKey", 0, &cfg->compose_key);
gppi (sesskey, "LdiscTerm", 0, &cfg->ldisc_term);
gppi (sesskey, "AlwaysOnTop", 0, &cfg->alwaysontop);
gppi (sesskey, "HideMousePtr", 0, &cfg->hide_mouseptr);
gppi (sesskey, "CurType", 0, &cfg->cursor_type);
gppi (sesskey, "BlinkCur", 0, &cfg->blink_cur);
gppi (sesskey, "Beep", 1, &cfg->beep);

View File

@ -275,6 +275,7 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
IDC_BOX_APPEARANCE1, IDC_BOXT_APPEARANCE1,
IDC_BOX_APPEARANCE2, IDC_BOXT_APPEARANCE2,
IDC_BOX_APPEARANCE3, IDC_BOXT_APPEARANCE3,
IDC_BOX_APPEARANCE4, IDC_BOXT_APPEARANCE4,
IDC_CURSORSTATIC,
IDC_CURBLOCK,
IDC_CURUNDER,
@ -285,6 +286,7 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
IDC_WINTITLE,
IDC_WINEDIT,
IDC_WINNAME,
IDC_HIDEMOUSE,
appearancepanelend,
connectionpanelstart,
@ -496,6 +498,7 @@ static void init_dlg_ctrls(HWND hwnd) {
SetDlgItemText (hwnd, IDC_WINEDIT, cfg.wintitle);
CheckDlgButton (hwnd, IDC_WINNAME, cfg.win_name_always);
CheckDlgButton (hwnd, IDC_HIDEMOUSE, cfg.hide_mouseptr);
CheckRadioButton (hwnd, IDC_CURBLOCK, IDC_CURVERT,
cfg.cursor_type==0 ? IDC_CURBLOCK :
cfg.cursor_type==1 ? IDC_CURUNDER : IDC_CURVERT);
@ -892,6 +895,11 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
IDC_WINEDIT, 100, NULL);
checkbox(&cp, "Avoid ever using &icon title", IDC_WINNAME);
endbox(&cp);
beginbox(&cp, "Adjust the use of the mouse pointer",
IDC_BOX_APPEARANCE4, IDC_BOXT_APPEARANCE4);
checkbox(&cp, "Hide mouse &pointer when typing in window",
IDC_HIDEMOUSE);
endbox(&cp);
treeview_insert(&tvfaff, 1, "Appearance");
}
@ -1502,6 +1510,11 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
HIWORD(wParam) == BN_DOUBLECLICKED)
cfg.win_name_always = IsDlgButtonChecked (hwnd, IDC_WINNAME);
break;
case IDC_HIDEMOUSE:
if (HIWORD(wParam) == BN_CLICKED ||
HIWORD(wParam) == BN_DOUBLECLICKED)
cfg.hide_mouseptr = IsDlgButtonChecked (hwnd, IDC_HIDEMOUSE);
break;
case IDC_CURBLOCK:
if (HIWORD(wParam) == BN_CLICKED ||
HIWORD(wParam) == BN_DOUBLECLICKED)

View File

@ -1054,6 +1054,17 @@ static void click (Mouse_Button b, int x, int y) {
lasttime = thistime;
}
static void show_mouseptr(int show) {
static int cursor_visible = 1;
if (!cfg.hide_mouseptr) /* override if this feature disabled */
show = 1;
if (cursor_visible && !show)
ShowCursor(FALSE);
else if (!cursor_visible && show)
ShowCursor(TRUE);
cursor_visible = show;
}
static LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam) {
HDC hdc;
@ -1087,6 +1098,7 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
case WM_CREATE:
break;
case WM_CLOSE:
show_mouseptr(1);
if (!cfg.warn_on_close || session_closed ||
MessageBox(hwnd, "Are you sure you want to close this session?",
"PuTTY Exit Confirmation",
@ -1094,6 +1106,7 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
DestroyWindow(hwnd);
return 0;
case WM_DESTROY:
show_mouseptr(1);
PostQuitMessage (0);
return 0;
case WM_SYSCOMMAND:
@ -1329,40 +1342,47 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
#define TO_CHR_Y(y) (((y)<0 ? (y)-font_height+1: (y)) / font_height)
case WM_LBUTTONDOWN:
show_mouseptr(1);
click (MB_SELECT, TO_CHR_X(X_POS(lParam)),
TO_CHR_Y(Y_POS(lParam)));
SetCapture(hwnd);
return 0;
case WM_LBUTTONUP:
show_mouseptr(1);
term_mouse (MB_SELECT, MA_RELEASE, TO_CHR_X(X_POS(lParam)),
TO_CHR_Y(Y_POS(lParam)));
ReleaseCapture();
return 0;
case WM_MBUTTONDOWN:
show_mouseptr(1);
SetCapture(hwnd);
click (cfg.mouse_is_xterm ? MB_PASTE : MB_EXTEND,
TO_CHR_X(X_POS(lParam)),
TO_CHR_Y(Y_POS(lParam)));
return 0;
case WM_MBUTTONUP:
show_mouseptr(1);
term_mouse (cfg.mouse_is_xterm ? MB_PASTE : MB_EXTEND,
MA_RELEASE, TO_CHR_X(X_POS(lParam)),
TO_CHR_Y(Y_POS(lParam)));
ReleaseCapture();
return 0;
case WM_RBUTTONDOWN:
show_mouseptr(1);
SetCapture(hwnd);
click (cfg.mouse_is_xterm ? MB_EXTEND : MB_PASTE,
TO_CHR_X(X_POS(lParam)),
TO_CHR_Y(Y_POS(lParam)));
return 0;
case WM_RBUTTONUP:
show_mouseptr(1);
term_mouse (cfg.mouse_is_xterm ? MB_EXTEND : MB_PASTE,
MA_RELEASE, TO_CHR_X(X_POS(lParam)),
TO_CHR_Y(Y_POS(lParam)));
ReleaseCapture();
return 0;
case WM_MOUSEMOVE:
show_mouseptr(1);
/*
* Add the mouse position and message time to the random
* number noise.
@ -1428,6 +1448,7 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
term_update();
break;
case WM_KILLFOCUS:
show_mouseptr(1);
has_focus = FALSE;
DestroyCaret();
term_out();
@ -1594,6 +1615,9 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
if (len == -1)
return DefWindowProc (hwnd, message, wParam, lParam);
ldisc->send (buf, len);
if (len > 0)
show_mouseptr(0);
}
}
return 0;