diff -uNr aterm-0.4.2-orig/autoconf/Make.common.in aterm-0.4.2/autoconf/Make.common.in --- aterm-0.4.2-orig/autoconf/Make.common.in 2001-09-06 18:38:07.000000000 +0200 +++ aterm-0.4.2/autoconf/Make.common.in 2004-05-03 01:50:40.995441752 +0200 @@ -59,7 +59,7 @@ XINC = @X_CFLAGS@ @XPM_CFLAGS@ # extra libraries needed by X on some systems, X library location -XLIB = @AFTERSTEP_LIBS@ @X_LIBS@ @X_PRE_LIBS@ @X_EXTRA_LIBS@ @XPM_LIBS@ -lX11 +XLIB = @AFTERSTEP_LIBS@ @X_LIBS@ @X_PRE_LIBS@ @X_EXTRA_LIBS@ @XPM_LIBS@ -lX11 -lXmu # End of common section of the Makefile #------------------------------------------------------------------------- diff -uNr aterm-0.4.2-orig/src/command.c aterm-0.4.2/src/command.c --- aterm-0.4.2-orig/src/command.c 2004-05-03 01:38:01.000000000 +0200 +++ aterm-0.4.2/src/command.c 2004-05-03 01:46:54.413887384 +0200 @@ -2651,7 +2651,7 @@ switch (ev->xbutton.button) { case Button1: case Button3: - selection_make(ev->xbutton.time); + selection_make(ev->xbutton.time, ev->xbutton.state); break; case Button2: diff -uNr aterm-0.4.2-orig/src/command.c.orig aterm-0.4.2/src/command.c.orig --- aterm-0.4.2-orig/src/command.c.orig 2001-09-06 18:38:07.000000000 +0200 +++ aterm-0.4.2/src/command.c.orig 2004-05-03 01:46:54.421886168 +0200 @@ -425,9 +425,8 @@ signal(sig, SIG_DFL); #ifdef UTMP_SUPPORT - privileges(RESTORE); - cleanutent(); - privileges(IGNORE); + if (!(Options & Opt_utmpInhibit)) + removeFromUtmp(); #endif kill(getpid(), sig); @@ -452,7 +451,8 @@ chown(ttydev, ttyfd_stat.st_uid, ttyfd_stat.st_gid); #endif #ifdef UTMP_SUPPORT - cleanutent(); + if (!(Options & Opt_utmpInhibit)) + removeFromUtmp(); #endif privileges(IGNORE); } @@ -1060,10 +1060,8 @@ exit(EXIT_FAILURE); } #ifdef UTMP_SUPPORT - privileges(RESTORE); if (!(Options & Opt_utmpInhibit)) - makeutent(ttydev, display_name); /* stamp /etc/utmp */ - privileges(IGNORE); + addToUtmp(ttydev, display_name, ptyfd); #endif return ptyfd; diff -uNr aterm-0.4.2-orig/src/screen.c aterm-0.4.2/src/screen.c --- aterm-0.4.2-orig/src/screen.c 2001-09-06 18:38:07.000000000 +0200 +++ aterm-0.4.2/src/screen.c 2004-05-03 01:46:54.433884344 +0200 @@ -44,7 +44,7 @@ #include #include /* get the typedef for CARD32 */ - +#include static screen_t screen; @@ -2759,21 +2759,34 @@ long nread; unsigned long bytes_after, nitems; unsigned char *data; + XTextProperty ct; Atom actual_type; int actual_fmt; + int dummy_count; + char **cl; if (prop == None) return; + for (nread = 0, bytes_after = 1; bytes_after > 0; nread += nitems) { if ((XGetWindowProperty(Xdisplay, win, prop, (nread / 4), PROP_SIZE, - Delete, AnyPropertyType, &actual_type, - &actual_fmt, &nitems, &bytes_after, - &data) != Success)) { - XFree(data); + Delete, AnyPropertyType, &ct.encoding, &ct.format, + &ct.nitems, &bytes_after, &ct.value) != Success)) { + XFree(ct.value); return; } - PasteIt(data, nitems); - XFree(data); + + if (XmbTextPropertyToTextList(Xdisplay, &ct, &cl, &dummy_count) == Success && cl) { + PasteIt(cl[0], strlen(cl[0])); + XFreeStringList(cl); + } else { + PasteIt(ct.value, (unsigned int)ct.nitems); + } + + nread += ct.nitems; + + if (ct.value) + XFree(ct.value); } } @@ -2787,6 +2800,9 @@ selection_request(Time tm, int x, int y) { Atom prop; + Atom xa; + + xa = XInternAtom(Xdisplay, "COMPOUND_TEXT", False); if (x < 0 || x >= TermWin.width || y < 0 || y >= TermWin.height) return; /* outside window */ @@ -2797,7 +2813,7 @@ selection_paste(Xroot, XA_CUT_BUFFER0, False); } else { prop = XInternAtom(Xdisplay, "VT_SELECTION", False); - XConvertSelection(Xdisplay, XA_PRIMARY, XA_STRING, prop, TermWin.vt, + XConvertSelection(Xdisplay, XA_PRIMARY, xa, prop, TermWin.vt, tm); } } @@ -2827,7 +2843,7 @@ */ /* PROTO */ void -selection_make(Time tm) +selection_make(Time tm, unsigned int key_state) { int i, col, end_col, row, end_row; unsigned char *new_selection_text; @@ -2894,7 +2910,13 @@ FREE(selection.text); selection.text = new_selection_text; - XSetSelectionOwner(Xdisplay, XA_PRIMARY, TermWin.vt, tm); + // selecting with ALT will put the text to clipboard + if (key_state & Mod1Mask) { + XSetSelectionOwner(Xdisplay, XA_CLIPBOARD(Xdisplay), TermWin.vt, tm); + } else { + XSetSelectionOwner(Xdisplay, XA_PRIMARY, TermWin.vt, tm); + } + if (XGetSelectionOwner(Xdisplay, XA_PRIMARY) != TermWin.vt) print_error("can't get primary selection"); XChangeProperty(Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, @@ -3329,11 +3351,21 @@ selection_send(XSelectionRequestEvent * rq) { XEvent ev; - Atom32 target_list[2]; + Atom32 target_list[4]; + Atom target; static Atom xa_targets = None; - + static Atom xa_compound_text = None; + static Atom xa_text = None; + XTextProperty ct; + XICCEncodingStyle style; + char *cl[4]; + + if (xa_text == None) + xa_text = XInternAtom(Xdisplay, "TEXT", False); + if (xa_compound_text == None) + xa_compound_text = XInternAtom(Xdisplay, "COMPOUND_TEXT", False); if (xa_targets == None) - xa_targets = XInternAtom(Xdisplay, "TARGETS", False); + xa_targets = XInternAtom(Xdisplay, "TARGETS", False); ev.xselection.type = SelectionNotify; ev.xselection.property = None; @@ -3344,18 +3376,37 @@ ev.xselection.time = rq->time; if (rq->target == xa_targets) { - target_list[0] = (Atom32) xa_targets; - target_list[1] = (Atom32) XA_STRING; + target_list[0] = (Atom32) xa_targets; + target_list[1] = (Atom32) XA_STRING; + target_list[2] = (Atom32) xa_text; + target_list[3] = (Atom32) xa_compound_text; + XChangeProperty(Xdisplay, rq->requestor, rq->property, rq->target, - (8 * sizeof(target_list[0])), PropModeReplace, - (unsigned char *)target_list, - (sizeof(target_list) / sizeof(target_list[0]))); - ev.xselection.property = rq->property; - } else if (rq->target == XA_STRING) { - XChangeProperty(Xdisplay, rq->requestor, rq->property, rq->target, - 8, PropModeReplace, selection.text, selection.len); - ev.xselection.property = rq->property; + (8 * sizeof(target_list[0])), PropModeReplace, + (unsigned char *)target_list, + (sizeof(target_list) / sizeof(target_list[0]))); + ev.xselection.property = rq->property; + + } else if (rq->target == XA_STRING + || rq->target == xa_compound_text + || rq->target == xa_text) { + + if (rq->target == XA_STRING) { + style = XStringStyle; + target = XA_STRING; + } else { + target = xa_compound_text; + style = (rq->target == xa_compound_text) ? XCompoundTextStyle + : XStdICCTextStyle; + } + + cl[0] = selection.text; + XmbTextListToTextProperty(Xdisplay, cl, 1, style, &ct); + XChangeProperty(Xdisplay, rq->requestor, rq->property, + target, 8, PropModeReplace, ct.value, ct.nitems); + ev.xselection.property = rq->property; } + XSendEvent(Xdisplay, rq->requestor, False, 0, &ev); }