1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Remove TermWin's is_minimised method.

Again, I've replaced it with a push-based notification going in the
other direction, so that when the terminal output stream includes a
query for 'is the window minimised?', the Terminal doesn't have to
consult the TermWin, because it already knows the answer.

The GTK API I'm using here (getting a GdkEventWindowState via
GtkWidget's window-state-event) is not present in GTK 1. The API I was
previously using (gdk_window_is_viewable) _is_, but it turns out that
that API doesn't reliably give the right answer: it only checks
visibility of GDK window ancestors, not X window ancestors. So in fact
GTK 1 PuTTY/pterm was only ever _pretending_ to reliably support the
'am I minimised' terminal query. Now it won't pretend any more.
This commit is contained in:
Simon Tatham 2021-02-07 19:59:20 +00:00
parent 42ad454f4f
commit 61571376cc
6 changed files with 26 additions and 25 deletions

View File

@ -88,7 +88,6 @@ static void fuzz_request_resize(TermWin *tw, int w, int h) {}
static void fuzz_set_title(TermWin *tw, const char *title) {} static void fuzz_set_title(TermWin *tw, const char *title) {}
static void fuzz_set_icon_title(TermWin *tw, const char *icontitle) {} static void fuzz_set_icon_title(TermWin *tw, const char *icontitle) {}
static void fuzz_set_minimised(TermWin *tw, bool minimised) {} static void fuzz_set_minimised(TermWin *tw, bool minimised) {}
static bool fuzz_is_minimised(TermWin *tw) { return false; }
static void fuzz_set_maximised(TermWin *tw, bool maximised) {} static void fuzz_set_maximised(TermWin *tw, bool maximised) {}
static void fuzz_move(TermWin *tw, int x, int y) {} static void fuzz_move(TermWin *tw, int x, int y) {}
static void fuzz_set_zorder(TermWin *tw, bool top) {} static void fuzz_set_zorder(TermWin *tw, bool top) {}
@ -117,7 +116,6 @@ static const TermWinVtable fuzz_termwin_vt = {
.set_title = fuzz_set_title, .set_title = fuzz_set_title,
.set_icon_title = fuzz_set_icon_title, .set_icon_title = fuzz_set_icon_title,
.set_minimised = fuzz_set_minimised, .set_minimised = fuzz_set_minimised,
.is_minimised = fuzz_is_minimised,
.set_maximised = fuzz_set_maximised, .set_maximised = fuzz_set_maximised,
.move = fuzz_move, .move = fuzz_move,
.set_zorder = fuzz_set_zorder, .set_zorder = fuzz_set_zorder,

View File

@ -1138,7 +1138,6 @@ struct TermWinVtable {
* the window it remembers whether to go back to normal or * the window it remembers whether to go back to normal or
* maximised. */ * maximised. */
void (*set_minimised)(TermWin *, bool minimised); void (*set_minimised)(TermWin *, bool minimised);
bool (*is_minimised)(TermWin *);
void (*set_maximised)(TermWin *, bool maximised); void (*set_maximised)(TermWin *, bool maximised);
void (*move)(TermWin *, int x, int y); void (*move)(TermWin *, int x, int y);
void (*set_zorder)(TermWin *, bool top); void (*set_zorder)(TermWin *, bool top);
@ -1638,6 +1637,7 @@ void term_keyinput(Terminal *, int codepage, const void *buf, int len);
void term_keyinputw(Terminal *, const wchar_t * widebuf, int len); void term_keyinputw(Terminal *, const wchar_t * widebuf, int len);
void term_get_cursor_position(Terminal *term, int *x, int *y); void term_get_cursor_position(Terminal *term, int *x, int *y);
void term_setup_window_titles(Terminal *term, const char *title_hostname); void term_setup_window_titles(Terminal *term, const char *title_hostname);
void term_notify_minimised(Terminal *term, bool minimised);
typedef enum SmallKeypadKey { typedef enum SmallKeypadKey {
SKK_HOME, SKK_END, SKK_INSERT, SKK_DELETE, SKK_PGUP, SKK_PGDN, SKK_HOME, SKK_END, SKK_INSERT, SKK_DELETE, SKK_PGUP, SKK_PGDN,

View File

@ -1792,6 +1792,7 @@ Terminal *term_init(Conf *myconf, struct unicode_data *ucsdata, TermWin *win)
term->window_title = dupstr(""); term->window_title = dupstr("");
term->icon_title = dupstr(""); term->icon_title = dupstr("");
term->minimised = false;
return term; return term;
} }
@ -4425,8 +4426,7 @@ static void term_out(Terminal *term)
break; break;
case 11: case 11:
if (term->ldisc) if (term->ldisc)
ldisc_send(term->ldisc, ldisc_send(term->ldisc, term->minimised ?
win_is_minimised(term->win) ?
"\033[2t" : "\033[1t", 4, "\033[2t" : "\033[1t", 4,
false); false);
break; break;
@ -7322,3 +7322,8 @@ int term_get_userpass_input(Terminal *term, prompts_t *p, bufchain *input)
return +1; /* all done */ return +1; /* all done */
} }
} }
void term_notify_minimised(Terminal *term, bool minimised)
{
term->minimised = minimised;
}

View File

@ -344,6 +344,7 @@ struct terminal_tag {
int mouse_paste_clipboard; int mouse_paste_clipboard;
char *window_title, *icon_title; char *window_title, *icon_title;
bool minimised;
}; };
static inline bool in_utf(Terminal *term) static inline bool in_utf(Terminal *term)

View File

@ -565,15 +565,6 @@ static void gtkwin_set_maximised(TermWin *tw, bool maximised)
#endif #endif
} }
/*
* Report whether the window is minimised, for terminal reports.
*/
static bool gtkwin_is_minimised(TermWin *tw)
{
GtkFrontend *inst = container_of(tw, GtkFrontend, termwin);
return !gdk_window_is_viewable(gtk_widget_get_window(inst->window));
}
/* /*
* Report the window's position, for terminal reports. * Report the window's position, for terminal reports.
*/ */
@ -670,6 +661,16 @@ gint delete_window(GtkWidget *widget, GdkEvent *event, GtkFrontend *inst)
return false; return false;
} }
#if GTK_CHECK_VERSION(2,0,0)
static void window_state_event(GtkWidget *widget, GdkEventWindowState *event,
gpointer user_data)
{
GtkFrontend *inst = (GtkFrontend *)user_data;
term_notify_minimised(
inst->term, event->new_window_state & GDK_WINDOW_STATE_ICONIFIED);
}
#endif
static void update_mouseptr(GtkFrontend *inst) static void update_mouseptr(GtkFrontend *inst)
{ {
switch (inst->busy_status) { switch (inst->busy_status) {
@ -5148,7 +5149,6 @@ static const TermWinVtable gtk_termwin_vt = {
.set_title = gtkwin_set_title, .set_title = gtkwin_set_title,
.set_icon_title = gtkwin_set_icon_title, .set_icon_title = gtkwin_set_icon_title,
.set_minimised = gtkwin_set_minimised, .set_minimised = gtkwin_set_minimised,
.is_minimised = gtkwin_is_minimised,
.set_maximised = gtkwin_set_maximised, .set_maximised = gtkwin_set_maximised,
.move = gtkwin_move, .move = gtkwin_move,
.set_zorder = gtkwin_set_zorder, .set_zorder = gtkwin_set_zorder,
@ -5506,6 +5506,12 @@ void new_session_window(Conf *conf, const char *geometry_string)
term_size(inst->term, inst->height, inst->width, term_size(inst->term, inst->height, inst->width,
conf_get_int(inst->conf, CONF_savelines)); conf_get_int(inst->conf, CONF_savelines));
#if GTK_CHECK_VERSION(2,0,0)
/* Delay this signal connection until after inst->term exists */
g_signal_connect(G_OBJECT(inst->window), "window_state_event",
G_CALLBACK(window_state_event), inst);
#endif
inst->exited = false; inst->exited = false;
start_backend(inst); start_backend(inst);

View File

@ -244,7 +244,6 @@ static void wintw_request_resize(TermWin *, int w, int h);
static void wintw_set_title(TermWin *, const char *title); static void wintw_set_title(TermWin *, const char *title);
static void wintw_set_icon_title(TermWin *, const char *icontitle); static void wintw_set_icon_title(TermWin *, const char *icontitle);
static void wintw_set_minimised(TermWin *, bool minimised); static void wintw_set_minimised(TermWin *, bool minimised);
static bool wintw_is_minimised(TermWin *);
static void wintw_set_maximised(TermWin *, bool maximised); static void wintw_set_maximised(TermWin *, bool maximised);
static void wintw_move(TermWin *, int x, int y); static void wintw_move(TermWin *, int x, int y);
static void wintw_set_zorder(TermWin *, bool top); static void wintw_set_zorder(TermWin *, bool top);
@ -272,7 +271,6 @@ static const TermWinVtable windows_termwin_vt = {
.set_title = wintw_set_title, .set_title = wintw_set_title,
.set_icon_title = wintw_set_icon_title, .set_icon_title = wintw_set_icon_title,
.set_minimised = wintw_set_minimised, .set_minimised = wintw_set_minimised,
.is_minimised = wintw_is_minimised,
.set_maximised = wintw_set_maximised, .set_maximised = wintw_set_maximised,
.move = wintw_move, .move = wintw_move,
.set_zorder = wintw_set_zorder, .set_zorder = wintw_set_zorder,
@ -2980,6 +2978,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
"...", "...",
LOWORD(lParam), HIWORD(lParam)); LOWORD(lParam), HIWORD(lParam));
#endif #endif
term_notify_minimised(term, wParam == SIZE_MINIMIZED);
if (wParam == SIZE_MINIMIZED) if (wParam == SIZE_MINIMIZED)
SetWindowText(hwnd, SetWindowText(hwnd,
conf_get_bool(conf, CONF_win_name_always) ? conf_get_bool(conf, CONF_win_name_always) ?
@ -5611,14 +5610,6 @@ static void wintw_set_maximised(TermWin *tw, bool maximised)
} }
} }
/*
* Report whether the window is iconic, for terminal reports.
*/
static bool wintw_is_minimised(TermWin *tw)
{
return IsIconic(wgs.term_hwnd);
}
/* /*
* Report the window's position, for terminal reports. * Report the window's position, for terminal reports.
*/ */