mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-22 14:39:24 -05:00
Only engage a GTK idle function when absolutely necessary, otherwise
the whole app spins on it and takes up CPU all the time. [originally from svn r2052]
This commit is contained in:
parent
7dff77fccf
commit
8bc305cafe
1
putty.h
1
putty.h
@ -484,6 +484,7 @@ void term_update(void);
|
|||||||
void term_invalidate(void);
|
void term_invalidate(void);
|
||||||
void term_blink(int set_cursor);
|
void term_blink(int set_cursor);
|
||||||
void term_do_paste(void);
|
void term_do_paste(void);
|
||||||
|
int term_paste_pending(void);
|
||||||
void term_paste(void);
|
void term_paste(void);
|
||||||
void term_nopaste(void);
|
void term_nopaste(void);
|
||||||
int term_ldisc(int option);
|
int term_ldisc(int option);
|
||||||
|
@ -3708,6 +3708,11 @@ void term_nopaste()
|
|||||||
paste_len = 0;
|
paste_len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int term_paste_pending(void)
|
||||||
|
{
|
||||||
|
return paste_len != 0;
|
||||||
|
}
|
||||||
|
|
||||||
void term_paste()
|
void term_paste()
|
||||||
{
|
{
|
||||||
static long last_paste = 0;
|
static long last_paste = 0;
|
||||||
|
27
unix/pterm.c
27
unix/pterm.c
@ -38,6 +38,7 @@ struct gui_data {
|
|||||||
int pasteout_data_len;
|
int pasteout_data_len;
|
||||||
int font_width, font_height;
|
int font_width, font_height;
|
||||||
int ignore_sbar;
|
int ignore_sbar;
|
||||||
|
guint term_paste_idle_id;
|
||||||
GdkAtom compound_text_atom;
|
GdkAtom compound_text_atom;
|
||||||
char wintitle[sizeof(((Config *)0)->wintitle)];
|
char wintitle[sizeof(((Config *)0)->wintitle)];
|
||||||
};
|
};
|
||||||
@ -750,13 +751,6 @@ gint timer_func(gpointer data)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint idle_func(gpointer data)
|
|
||||||
{
|
|
||||||
/* struct gui_data *inst = (struct gui_data *)data; */
|
|
||||||
term_paste();
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void pty_input_func(gpointer data, gint sourcefd, GdkInputCondition condition)
|
void pty_input_func(gpointer data, gint sourcefd, GdkInputCondition condition)
|
||||||
{
|
{
|
||||||
/* struct gui_data *inst = (struct gui_data *)data; */
|
/* struct gui_data *inst = (struct gui_data *)data; */
|
||||||
@ -924,6 +918,8 @@ void request_paste(void)
|
|||||||
GDK_SELECTION_TYPE_STRING, GDK_CURRENT_TIME);
|
GDK_SELECTION_TYPE_STRING, GDK_CURRENT_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gint idle_paste_func(gpointer data); /* forward ref */
|
||||||
|
|
||||||
void selection_received(GtkWidget *widget, GtkSelectionData *seldata,
|
void selection_received(GtkWidget *widget, GtkSelectionData *seldata,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
@ -940,8 +936,24 @@ void selection_received(GtkWidget *widget, GtkSelectionData *seldata,
|
|||||||
inst->pastein_data, inst->pastein_data_len);
|
inst->pastein_data, inst->pastein_data_len);
|
||||||
|
|
||||||
term_do_paste();
|
term_do_paste();
|
||||||
|
|
||||||
|
if (term_paste_pending())
|
||||||
|
inst->term_paste_idle_id = gtk_idle_add(idle_paste_func, inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gint idle_paste_func(gpointer data)
|
||||||
|
{
|
||||||
|
struct gui_data *inst = (struct gui_data *)data;
|
||||||
|
|
||||||
|
if (term_paste_pending())
|
||||||
|
term_paste();
|
||||||
|
else
|
||||||
|
gtk_idle_remove(inst->term_paste_idle_id);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void get_clip(wchar_t ** p, int *len)
|
void get_clip(wchar_t ** p, int *len)
|
||||||
{
|
{
|
||||||
if (p) {
|
if (p) {
|
||||||
@ -1345,7 +1357,6 @@ int main(int argc, char **argv)
|
|||||||
GTK_SIGNAL_FUNC(selection_clear), inst);
|
GTK_SIGNAL_FUNC(selection_clear), inst);
|
||||||
gtk_signal_connect(GTK_OBJECT(inst->sbar_adjust), "value_changed",
|
gtk_signal_connect(GTK_OBJECT(inst->sbar_adjust), "value_changed",
|
||||||
GTK_SIGNAL_FUNC(scrollbar_moved), inst);
|
GTK_SIGNAL_FUNC(scrollbar_moved), inst);
|
||||||
gtk_idle_add(idle_func, inst);
|
|
||||||
gtk_timeout_add(20, timer_func, inst);
|
gtk_timeout_add(20, timer_func, inst);
|
||||||
gdk_input_add(pty_master_fd, GDK_INPUT_READ, pty_input_func, inst);
|
gdk_input_add(pty_master_fd, GDK_INPUT_READ, pty_input_func, inst);
|
||||||
gtk_widget_add_events(GTK_WIDGET(inst->area),
|
gtk_widget_add_events(GTK_WIDGET(inst->area),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user