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

Richard Boulton's patch for improved correctness in selection

handling (generally, selection request timestamps should be set to
the timestamp on the event that caused them).

[originally from svn r3408]
This commit is contained in:
Simon Tatham 2003-08-21 18:03:06 +00:00
parent 92db92af5a
commit 11c9c018ec

View File

@ -81,6 +81,7 @@ struct gui_data {
void *eventlogstuff; void *eventlogstuff;
char *progname, **gtkargvstart; char *progname, **gtkargvstart;
int ngtkargs; int ngtkargs;
guint32 input_event_time; /* Timestamp of the most recent input event. */
}; };
struct draw_ctx { struct draw_ctx {
@ -447,6 +448,9 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
wchar_t ucsoutput[2]; wchar_t ucsoutput[2];
int ucsval, start, end, special, use_ucsoutput; int ucsval, start, end, special, use_ucsoutput;
/* Remember the timestamp. */
inst->input_event_time = event->time;
/* By default, nothing is generated. */ /* By default, nothing is generated. */
end = start = 0; end = start = 0;
special = use_ucsoutput = FALSE; special = use_ucsoutput = FALSE;
@ -1021,6 +1025,9 @@ gint button_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
struct gui_data *inst = (struct gui_data *)data; struct gui_data *inst = (struct gui_data *)data;
int shift, ctrl, alt, x, y, button, act; int shift, ctrl, alt, x, y, button, act;
/* Remember the timestamp. */
inst->input_event_time = event->time;
show_mouseptr(inst, 1); show_mouseptr(inst, 1);
if (event->button == 4 && event->type == GDK_BUTTON_PRESS) { if (event->button == 4 && event->type == GDK_BUTTON_PRESS) {
@ -1077,6 +1084,9 @@ gint motion_event(GtkWidget *widget, GdkEventMotion *event, gpointer data)
struct gui_data *inst = (struct gui_data *)data; struct gui_data *inst = (struct gui_data *)data;
int shift, ctrl, alt, x, y, button; int shift, ctrl, alt, x, y, button;
/* Remember the timestamp. */
inst->input_event_time = event->time;
show_mouseptr(inst, 1); show_mouseptr(inst, 1);
shift = event->state & GDK_SHIFT_MASK; shift = event->state & GDK_SHIFT_MASK;
@ -1391,7 +1401,7 @@ void write_clip(void *frontend, wchar_t * data, int len, int must_deselect)
} }
if (gtk_selection_owner_set(inst->area, GDK_SELECTION_PRIMARY, if (gtk_selection_owner_set(inst->area, GDK_SELECTION_PRIMARY,
GDK_CURRENT_TIME)) { inst->input_event_time)) {
gtk_selection_add_target(inst->area, GDK_SELECTION_PRIMARY, gtk_selection_add_target(inst->area, GDK_SELECTION_PRIMARY,
GDK_SELECTION_TYPE_STRING, 1); GDK_SELECTION_TYPE_STRING, 1);
if (inst->pasteout_data_ctext) if (inst->pasteout_data_ctext)
@ -1427,6 +1437,7 @@ gint selection_clear(GtkWidget *widget, GdkEventSelection *seldata,
gpointer data) gpointer data)
{ {
struct gui_data *inst = (struct gui_data *)data; struct gui_data *inst = (struct gui_data *)data;
term_deselect(inst->term); term_deselect(inst->term);
if (inst->pasteout_data) if (inst->pasteout_data)
sfree(inst->pasteout_data); sfree(inst->pasteout_data);
@ -1461,14 +1472,16 @@ void request_paste(void *frontend)
* fall back to an ordinary string. * fall back to an ordinary string.
*/ */
gtk_selection_convert(inst->area, GDK_SELECTION_PRIMARY, gtk_selection_convert(inst->area, GDK_SELECTION_PRIMARY,
utf8_string_atom, GDK_CURRENT_TIME); utf8_string_atom,
inst->input_event_time);
} else { } else {
/* /*
* If we're in direct-to-font mode, we disable UTF-8 * If we're in direct-to-font mode, we disable UTF-8
* pasting, and go straight to ordinary string data. * pasting, and go straight to ordinary string data.
*/ */
gtk_selection_convert(inst->area, GDK_SELECTION_PRIMARY, gtk_selection_convert(inst->area, GDK_SELECTION_PRIMARY,
GDK_SELECTION_TYPE_STRING, GDK_CURRENT_TIME); GDK_SELECTION_TYPE_STRING,
inst->input_event_time);
} }
} }
@ -1491,7 +1504,8 @@ void selection_received(GtkWidget *widget, GtkSelectionData *seldata,
* text next. * text next.
*/ */
gtk_selection_convert(inst->area, GDK_SELECTION_PRIMARY, gtk_selection_convert(inst->area, GDK_SELECTION_PRIMARY,
compound_text_atom, GDK_CURRENT_TIME); compound_text_atom,
inst->input_event_time);
return; return;
} }
@ -1501,7 +1515,8 @@ void selection_received(GtkWidget *widget, GtkSelectionData *seldata,
* string. * string.
*/ */
gtk_selection_convert(inst->area, GDK_SELECTION_PRIMARY, gtk_selection_convert(inst->area, GDK_SELECTION_PRIMARY,
GDK_SELECTION_TYPE_STRING, GDK_CURRENT_TIME); GDK_SELECTION_TYPE_STRING,
inst->input_event_time);
return; return;
} }
@ -1529,7 +1544,8 @@ void selection_received(GtkWidget *widget, GtkSelectionData *seldata,
* Compound text failed; fall back to STRING. * Compound text failed; fall back to STRING.
*/ */
gtk_selection_convert(inst->area, GDK_SELECTION_PRIMARY, gtk_selection_convert(inst->area, GDK_SELECTION_PRIMARY,
GDK_SELECTION_TYPE_STRING, GDK_CURRENT_TIME); GDK_SELECTION_TYPE_STRING,
inst->input_event_time);
return; return;
} }
text = list[0]; text = list[0];