X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/3aac0d352a270e9cda03c363fb5291657a6b7cb9..5a9bf7646e1e86a8c24570d571e7e7507517700e:/unix/pterm.c diff --git a/unix/pterm.c b/unix/pterm.c index 18239809..f23f07b7 100644 --- a/unix/pterm.c +++ b/unix/pterm.c @@ -1371,7 +1371,7 @@ char * retrieve_cutbuffer(int * nbytes) { char * ptr; ptr = XFetchBytes(GDK_DISPLAY(), nbytes); - if (nbytes <= 0 && ptr != 0) { + if (*nbytes <= 0 && ptr != 0) { XFree(ptr); ptr = 0; } @@ -1424,7 +1424,10 @@ void write_clip(void *frontend, wchar_t * data, int len, int must_deselect) memcpy(inst->pasteout_data_ctext, tp.value, tp.nitems); inst->pasteout_data_ctext_len = tp.nitems; XFree(tp.value); - } + } else { + inst->pasteout_data_ctext = NULL; + inst->pasteout_data_ctext_len = 0; + } } else { inst->pasteout_data_utf8 = NULL; inst->pasteout_data_utf8_len = 0; @@ -1591,34 +1594,35 @@ void selection_received(GtkWidget *widget, GtkSelectionData *seldata, charset = CS_ISO8859_1; free_required = 1; } else { - /* - * Convert COMPOUND_TEXT into UTF-8. - */ - if (seldata->type == compound_text_atom) { - tp.value = seldata->data; - tp.encoding = (Atom) seldata->type; - tp.format = seldata->format; - tp.nitems = seldata->length; - ret = Xutf8TextPropertyToTextList(GDK_DISPLAY(), &tp, &list, &count); - if (ret != 0 || count != 1) { - /* - * Compound text failed; fall back to STRING. - */ - gtk_selection_convert(inst->area, GDK_SELECTION_PRIMARY, - GDK_SELECTION_TYPE_STRING, - inst->input_event_time); - return; + /* + * Convert COMPOUND_TEXT into UTF-8. + */ + if (seldata->type == compound_text_atom) { + tp.value = seldata->data; + tp.encoding = (Atom) seldata->type; + tp.format = seldata->format; + tp.nitems = seldata->length; + ret = Xutf8TextPropertyToTextList(GDK_DISPLAY(), &tp, + &list, &count); + if (ret != 0 || count != 1) { + /* + * Compound text failed; fall back to STRING. + */ + gtk_selection_convert(inst->area, GDK_SELECTION_PRIMARY, + GDK_SELECTION_TYPE_STRING, + inst->input_event_time); + return; + } + text = list[0]; + length = strlen(list[0]); + charset = CS_UTF8; + free_list_required = 1; + } else { + text = (char *)seldata->data; + length = seldata->length; + charset = (seldata->type == utf8_string_atom ? + CS_UTF8 : inst->ucsdata.line_codepage); } - text = list[0]; - length = strlen(list[0]); - charset = CS_UTF8; - free_list_required = 1; - } else { - text = (char *)seldata->data; - length = seldata->length; - charset = (seldata->type == utf8_string_atom ? - CS_UTF8 : inst->ucsdata.line_codepage); - } } if (inst->pastein_data) @@ -2622,23 +2626,27 @@ void setup_fonts_ucs(struct gui_data *inst) } font_charset = set_font_info(inst, 0); - if (inst->cfg.boldfont.name[0]) { - name = inst->cfg.boldfont.name; - guessed = FALSE; + if (inst->cfg.shadowbold) { + inst->fonts[1] = NULL; } else { - name = guess_derived_font_name(inst->fonts[0], TRUE, FALSE); - guessed = TRUE; - } - inst->fonts[1] = name ? gdk_font_load(name) : NULL; - if (inst->fonts[1]) { - set_font_info(inst, 1); - } else if (!guessed) { - fprintf(stderr, "%s: unable to load bold font \"%s\"\n", appname, - inst->cfg.boldfont.name); - exit(1); + if (inst->cfg.boldfont.name[0]) { + name = inst->cfg.boldfont.name; + guessed = FALSE; + } else { + name = guess_derived_font_name(inst->fonts[0], TRUE, FALSE); + guessed = TRUE; + } + inst->fonts[1] = name ? gdk_font_load(name) : NULL; + if (inst->fonts[1]) { + set_font_info(inst, 1); + } else if (!guessed) { + fprintf(stderr, "%s: unable to load bold font \"%s\"\n", appname, + inst->cfg.boldfont.name); + exit(1); + } + if (guessed) + sfree(name); } - if (guessed) - sfree(name); if (inst->cfg.widefont.name[0]) { name = inst->cfg.widefont.name; @@ -2658,33 +2666,37 @@ void setup_fonts_ucs(struct gui_data *inst) if (guessed) sfree(name); - if (inst->cfg.wideboldfont.name[0]) { - name = inst->cfg.wideboldfont.name; - guessed = FALSE; + if (inst->cfg.shadowbold) { + inst->fonts[3] = NULL; } else { - /* - * Here we have some choices. We can widen the bold font, - * bolden the wide font, or widen and bolden the standard - * font. Try them all, in that order! - */ - if (inst->cfg.widefont.name[0]) - name = guess_derived_font_name(inst->fonts[2], TRUE, FALSE); - else if (inst->cfg.boldfont.name[0]) - name = guess_derived_font_name(inst->fonts[1], FALSE, TRUE); - else - name = guess_derived_font_name(inst->fonts[0], TRUE, TRUE); - guessed = TRUE; - } - inst->fonts[3] = name ? gdk_font_load(name) : NULL; - if (inst->fonts[3]) { - set_font_info(inst, 3); - } else if (!guessed) { - fprintf(stderr, "%s: unable to load wide/bold font \"%s\"\n", appname, - inst->cfg.wideboldfont.name); - exit(1); + if (inst->cfg.wideboldfont.name[0]) { + name = inst->cfg.wideboldfont.name; + guessed = FALSE; + } else { + /* + * Here we have some choices. We can widen the bold font, + * bolden the wide font, or widen and bolden the standard + * font. Try them all, in that order! + */ + if (inst->cfg.widefont.name[0]) + name = guess_derived_font_name(inst->fonts[2], TRUE, FALSE); + else if (inst->cfg.boldfont.name[0]) + name = guess_derived_font_name(inst->fonts[1], FALSE, TRUE); + else + name = guess_derived_font_name(inst->fonts[0], TRUE, TRUE); + guessed = TRUE; + } + inst->fonts[3] = name ? gdk_font_load(name) : NULL; + if (inst->fonts[3]) { + set_font_info(inst, 3); + } else if (!guessed) { + fprintf(stderr, "%s: unable to load wide/bold font \"%s\"\n", appname, + inst->cfg.wideboldfont.name); + exit(1); + } + if (guessed) + sfree(name); } - if (guessed) - sfree(name); inst->font_width = gdk_char_width(inst->fonts[0], ' '); inst->font_height = inst->fonts[0]->ascent + inst->fonts[0]->descent; @@ -2841,7 +2853,8 @@ void change_settings_menuitem(GtkMenuItem *item, gpointer data) strcmp(oldcfg.widefont.name, cfg2.widefont.name) || strcmp(oldcfg.wideboldfont.name, cfg2.wideboldfont.name) || strcmp(oldcfg.line_codepage, cfg2.line_codepage) || - oldcfg.vtmode != cfg2.vtmode) { + oldcfg.vtmode != cfg2.vtmode || + oldcfg.shadowbold != cfg2.shadowbold) { setup_fonts_ucs(inst); need_size = 1; } else @@ -3357,7 +3370,8 @@ int pt_main(int argc, char **argv) error = inst->back->init((void *)inst, &inst->backhandle, &inst->cfg, inst->cfg.host, inst->cfg.port, - &realhost, inst->cfg.tcp_nodelay); + &realhost, inst->cfg.tcp_nodelay, + inst->cfg.tcp_keepalives); if (error) { char *msg = dupprintf("Unable to open connection to %s:\n%s",