mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-26 01:32:25 +00:00
Slight improvement to cursor blink timing: since the cursor doesn't
blink when the window doesn't have focus, we don't schedule blink timers at that point either. Infrastructure change: term->has_focus should now not be written directly from outside terminal.c. Instead, use the function term_set_focus, which will sort out the blink timers as well. [originally from svn r4911]
This commit is contained in:
parent
02b0474f57
commit
92f3b101f5
@ -1042,7 +1042,7 @@ static void mac_activateterm(WindowPtr window, EventRecord *event)
|
|||||||
Boolean active = (event->modifiers & activeFlag) != 0;
|
Boolean active = (event->modifiers & activeFlag) != 0;
|
||||||
|
|
||||||
s = mac_windowsession(window);
|
s = mac_windowsession(window);
|
||||||
s->term->has_focus = active;
|
term_set_focus(s->term, active);
|
||||||
term_update(s->term);
|
term_update(s->term);
|
||||||
if (active)
|
if (active)
|
||||||
ShowControl(s->scrollbar);
|
ShowControl(s->scrollbar);
|
||||||
|
1
putty.h
1
putty.h
@ -664,6 +664,7 @@ void term_provide_resize_fn(Terminal *term,
|
|||||||
void (*resize_fn)(void *, int, int),
|
void (*resize_fn)(void *, int, int),
|
||||||
void *resize_ctx);
|
void *resize_ctx);
|
||||||
void term_provide_logctx(Terminal *term, void *logctx);
|
void term_provide_logctx(Terminal *term, void *logctx);
|
||||||
|
void term_set_focus(Terminal *term, int has_focus);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Exports from logging.c.
|
* Exports from logging.c.
|
||||||
|
14
terminal.c
14
terminal.c
@ -1043,9 +1043,8 @@ static void seen_disp_event(Terminal *term)
|
|||||||
*/
|
*/
|
||||||
static void term_schedule_tblink(Terminal *term)
|
static void term_schedule_tblink(Terminal *term)
|
||||||
{
|
{
|
||||||
if (term->tblink_pending)
|
|
||||||
return; /* already well in hand */
|
|
||||||
if (term->blink_is_real) {
|
if (term->blink_is_real) {
|
||||||
|
if (!term->tblink_pending)
|
||||||
term->next_tblink = schedule_timer(TBLINK_DELAY, term_timer, term);
|
term->next_tblink = schedule_timer(TBLINK_DELAY, term_timer, term);
|
||||||
term->tblink_pending = TRUE;
|
term->tblink_pending = TRUE;
|
||||||
} else {
|
} else {
|
||||||
@ -1059,9 +1058,8 @@ static void term_schedule_tblink(Terminal *term)
|
|||||||
*/
|
*/
|
||||||
static void term_schedule_cblink(Terminal *term)
|
static void term_schedule_cblink(Terminal *term)
|
||||||
{
|
{
|
||||||
if (term->cblink_pending)
|
if (term->cfg.blink_cur && term->has_focus) {
|
||||||
return; /* already well in hand */
|
if (!term->cblink_pending)
|
||||||
if (term->cfg.blink_cur) {
|
|
||||||
term->next_cblink = schedule_timer(CBLINK_DELAY, term_timer, term);
|
term->next_cblink = schedule_timer(CBLINK_DELAY, term_timer, term);
|
||||||
term->cblink_pending = TRUE;
|
term->cblink_pending = TRUE;
|
||||||
} else {
|
} else {
|
||||||
@ -6074,3 +6072,9 @@ void term_provide_logctx(Terminal *term, void *logctx)
|
|||||||
{
|
{
|
||||||
term->logctx = logctx;
|
term->logctx = logctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void term_set_focus(Terminal *term, int has_focus)
|
||||||
|
{
|
||||||
|
term->has_focus = has_focus;
|
||||||
|
term_schedule_cblink(term);
|
||||||
|
}
|
||||||
|
@ -1218,7 +1218,7 @@ void destroy(GtkWidget *widget, gpointer data)
|
|||||||
gint focus_event(GtkWidget *widget, GdkEventFocus *event, gpointer data)
|
gint focus_event(GtkWidget *widget, GdkEventFocus *event, gpointer data)
|
||||||
{
|
{
|
||||||
struct gui_data *inst = (struct gui_data *)data;
|
struct gui_data *inst = (struct gui_data *)data;
|
||||||
inst->term->has_focus = event->in;
|
term_set_focus(inst->term, event->in);
|
||||||
term_update(inst->term);
|
term_update(inst->term);
|
||||||
show_mouseptr(inst, 1);
|
show_mouseptr(inst, 1);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -770,7 +770,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
|||||||
logpal = NULL;
|
logpal = NULL;
|
||||||
init_palette();
|
init_palette();
|
||||||
|
|
||||||
term->has_focus = (GetForegroundWindow() == hwnd);
|
term_set_focus(term, GetForegroundWindow() == hwnd);
|
||||||
UpdateWindow(hwnd);
|
UpdateWindow(hwnd);
|
||||||
|
|
||||||
if (GetMessage(&msg, NULL, 0, 0) == 1) {
|
if (GetMessage(&msg, NULL, 0, 0) == 1) {
|
||||||
@ -787,7 +787,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* The messages seem unreliable; especially if we're being tricky */
|
/* The messages seem unreliable; especially if we're being tricky */
|
||||||
term->has_focus = (GetForegroundWindow() == hwnd);
|
term_set_focus(term, GetForegroundWindow() == hwnd);
|
||||||
|
|
||||||
net_pending_errors();
|
net_pending_errors();
|
||||||
|
|
||||||
@ -2317,7 +2317,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||||||
net_pending_errors();
|
net_pending_errors();
|
||||||
return 0;
|
return 0;
|
||||||
case WM_SETFOCUS:
|
case WM_SETFOCUS:
|
||||||
term->has_focus = TRUE;
|
term_set_focus(term, TRUE);
|
||||||
CreateCaret(hwnd, caretbm, font_width, font_height);
|
CreateCaret(hwnd, caretbm, font_width, font_height);
|
||||||
ShowCaret(hwnd);
|
ShowCaret(hwnd);
|
||||||
flash_window(0); /* stop */
|
flash_window(0); /* stop */
|
||||||
@ -2326,7 +2326,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||||||
break;
|
break;
|
||||||
case WM_KILLFOCUS:
|
case WM_KILLFOCUS:
|
||||||
show_mouseptr(1);
|
show_mouseptr(1);
|
||||||
term->has_focus = FALSE;
|
term_set_focus(term, FALSE);
|
||||||
DestroyCaret();
|
DestroyCaret();
|
||||||
caret_x = caret_y = -1; /* ensure caret is replaced next time */
|
caret_x = caret_y = -1; /* ensure caret is replaced next time */
|
||||||
term_update(term);
|
term_update(term);
|
||||||
|
Loading…
Reference in New Issue
Block a user