X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/381b1876bb2fb230d7ada8d64479da7f207bb159..9954aaa37368a233dc614d610ca68c2ce5a7e8cd:/window.c diff --git a/window.c b/window.c index 269d08f8..546a9172 100644 --- a/window.c +++ b/window.c @@ -77,6 +77,7 @@ static int pending_netevent = 0; static WPARAM pend_netevent_wParam = 0; static LPARAM pend_netevent_lParam = 0; static void enact_pending_netevent(void); +static void flash_window(int mode); static time_t last_movement = 0; @@ -573,6 +574,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) * Finally show the window! */ ShowWindow(hwnd, show); + SetForegroundWindow(hwnd); /* * Open the initial log file if there is one. @@ -644,11 +646,14 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) term_out(); term_update(); ShowCaret(hwnd); + + flash_window(1); /* maintain */ + if (in_vbell) /* Hmm, term_update didn't want to do an update too soon ... */ timer_id = SetTimer(hwnd, 1, 50, NULL); else if (!has_focus) - timer_id = SetTimer(hwnd, 1, 2000, NULL); + timer_id = SetTimer(hwnd, 1, 500, NULL); else timer_id = SetTimer(hwnd, 1, 100, NULL); long_timer = 1; @@ -1142,6 +1147,7 @@ Mouse_Button translate_button(Mouse_Button button) return cfg.mouse_is_xterm ? MBT_PASTE : MBT_EXTEND; if (button == MBT_RIGHT) return cfg.mouse_is_xterm ? MBT_EXTEND : MBT_PASTE; + return 0; /* shouldn't happen */ } static void show_mouseptr(int show) @@ -1557,6 +1563,8 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, button = MBT_RIGHT; press = 0; break; + default: + button = press = 0; /* shouldn't happen */ } show_mouseptr(1); if (press) { @@ -1584,11 +1592,11 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, if (wParam & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON)) { Mouse_Button b; if (wParam & MK_LBUTTON) - b = MBT_SELECT; + b = MBT_LEFT; else if (wParam & MK_MBUTTON) - b = cfg.mouse_is_xterm ? MBT_PASTE : MBT_EXTEND; + b = MBT_MIDDLE; else - b = cfg.mouse_is_xterm ? MBT_EXTEND : MBT_PASTE; + b = MBT_RIGHT; term_mouse(b, MA_DRAG, TO_CHR_X(X_POS(lParam)), TO_CHR_Y(Y_POS(lParam)), wParam & MK_SHIFT, wParam & MK_CONTROL); @@ -1640,6 +1648,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, has_focus = TRUE; CreateCaret(hwnd, caretbm, font_width, font_height); ShowCaret(hwnd); + flash_window(0); /* stop */ compose_state = 0; term_out(); term_update(); @@ -2453,8 +2462,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, return 0; } if (wParam == VK_INSERT && shift_state == 1) { - term_mouse(MBT_PASTE, MA_CLICK, 0, 0, 0, 0); - term_mouse(MBT_PASTE, MA_RELEASE, 0, 0, 0, 0); + term_do_paste(); return 0; } if (left_alt && wParam == VK_F4 && cfg.alt_f4) { @@ -2874,7 +2882,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, #ifdef SHOW_TOASCII_RESULT if (r == 1 && !key_down) { if (alt_sum) { - if (utf || dbcs_screenfont) + if (in_utf || dbcs_screenfont) debug((", (U+%04x)", alt_sum)); else debug((", LCH(%d)", alt_sum)); @@ -2918,7 +2926,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, if (!key_down) { if (alt_sum) { - if (utf || dbcs_screenfont) { + if (in_utf || dbcs_screenfont) { keybuf = alt_sum; luni_send(&keybuf, 1); } else { @@ -2945,7 +2953,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, if (!left_alt) keys[0] = 0; /* If we will be using alt_sum fix the 256s */ - else if (keys[0] && (utf || dbcs_screenfont)) + else if (keys[0] && (in_utf || dbcs_screenfont)) keys[0] = 10; } @@ -3173,7 +3181,7 @@ void get_clip(wchar_t ** p, int *len) clipdata = NULL; return; } else if (OpenClipboard(NULL)) { - if (clipdata = GetClipboardData(CF_UNICODETEXT)) { + if ((clipdata = GetClipboardData(CF_UNICODETEXT))) { CloseClipboard(); *p = GlobalLock(clipdata); if (*p) { @@ -3181,7 +3189,7 @@ void get_clip(wchar_t ** p, int *len) *len = p2 - *p; return; } - } else if (clipdata = GetClipboardData(CF_TEXT)) { + } else if ( (clipdata = GetClipboardData(CF_TEXT)) ) { char *s; int i; CloseClipboard(); @@ -3236,6 +3244,42 @@ void fatalbox(char *fmt, ...) } /* + * Manage window caption / taskbar flashing, if enabled. + * 0 = stop, 1 = maintain, 2 = start + */ +static void flash_window(int mode) +{ + static long last_flash = 0; + static int flashing = 0; + if ((mode == 0) || (cfg.beep_ind == B_IND_DISABLED)) { + /* stop */ + if (flashing) { + FlashWindow(hwnd, FALSE); + flashing = 0; + } + + } else if (mode == 2) { + /* start */ + if (!flashing) { + last_flash = GetTickCount(); + flashing = 1; + FlashWindow(hwnd, TRUE); + } + + } else if ((mode == 1) && (cfg.beep_ind == B_IND_FLASH)) { + /* maintain */ + if (flashing) { + long now = GetTickCount(); + long fdiff = now - last_flash; + if (fdiff < 0 || fdiff > 450) { + last_flash = now; + FlashWindow(hwnd, TRUE); /* toggle */ + } + } + } +} + +/* * Beep. */ void beep(int mode) @@ -3269,4 +3313,8 @@ void beep(int mode) cfg.beep = BELL_DEFAULT; } } + /* Otherwise, either visual bell or disabled; do nothing here */ + if (!has_focus) { + flash_window(2); /* start */ + } }