X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/96add4441605991d48fcdee861c115216d355f6f..f55eceeddc68307909fab6cedf7bbfd8decb0f9f:/unix/pterm.c?ds=sidebyside diff --git a/unix/pterm.c b/unix/pterm.c index e53499d5..b1b98c1e 100644 --- a/unix/pterm.c +++ b/unix/pterm.c @@ -16,10 +16,11 @@ #include #include #include -#include -#include #include #include +#include +#include +#include #define PUTTY_DO_GLOBALS /* actually _define_ globals */ #include "putty.h" @@ -68,6 +69,13 @@ struct draw_ctx { static int send_raw_mouse; +static char *app_name = "pterm"; + +char *x_get_default(char *key) +{ + return XGetDefault(GDK_DISPLAY(), app_name, key); +} + void ldisc_update(void *frontend, int echo, int edit) { /* @@ -1390,7 +1398,7 @@ void do_text_internal(Context ctx, int x, int y, char *text, int len, struct gui_data *inst = dctx->inst; GdkGC *gc = dctx->gc; - int nfg, nbg, t, fontid, shadow; + int nfg, nbg, t, fontid, shadow, rlen; /* * NYI: @@ -1427,13 +1435,25 @@ void do_text_internal(Context ctx, int x, int y, char *text, int len, return; if (x + len*2 > inst->term->cols) len = (inst->term->cols-x)/2; /* trim to LH half */ + rlen = len * 2; + } else + rlen = len; + + { + GdkRectangle r; + + r.x = x*inst->font_width+cfg.window_border; + r.y = y*inst->font_height+cfg.window_border; + r.width = rlen*inst->font_width; + r.height = inst->font_height; + gdk_gc_set_clip_rectangle(gc, &r); } gdk_gc_set_foreground(gc, &inst->cols[nbg]); gdk_draw_rectangle(inst->pixmap, gc, 1, x*inst->font_width+cfg.window_border, y*inst->font_height+cfg.window_border, - len*inst->font_width, inst->font_height); + rlen*inst->font_width, inst->font_height); gdk_gc_set_foreground(gc, &inst->cols[nfg]); gdk_draw_text(inst->pixmap, inst->fonts[fontid], gc, @@ -1726,8 +1746,6 @@ char *get_x_display(void *frontend) return gdk_get_display(); } -char *app_name = "pterm"; - static void help(FILE *fp) { if(fprintf(fp, "pterm option summary:\n" @@ -1921,12 +1939,27 @@ int do_cmdline(int argc, char **argv, int do_everything) return err; } +static void block_signal(int sig, int block_it) { + sigset_t ss; + + sigemptyset(&ss); + sigaddset(&ss, sig); + if(sigprocmask(block_it ? SIG_BLOCK : SIG_UNBLOCK, &ss, 0) < 0) { + perror("sigprocmask"); + exit(1); + } +} + int main(int argc, char **argv) { extern int pty_master_fd; /* declared in pty.c */ extern void pty_pre_init(void); /* declared in pty.c */ struct gui_data *inst; + /* defer any child exit handling until we're ready to deal with + * it */ + block_signal(SIGCHLD, 1); + pty_pre_init(); gtk_init(&argc, &argv); @@ -2084,6 +2117,10 @@ int main(int argc, char **argv) inst->master_func_id = gdk_input_add(pty_master_fd, GDK_INPUT_READ, pty_input_func, inst); + /* now we're reday to deal with the child exit handler being + * called */ + block_signal(SIGCHLD, 0); + gtk_main(); return 0;