diff -crN kterm-6.2.0/Imakefile kterm-6.2.0.new/Imakefile
*** kterm-6.2.0/Imakefile	Fri Jul 12 14:01:04 1996
--- kterm-6.2.0.new/Imakefile	Mon Aug 20 01:51:17 2001
***************
*** 32,38 ****
  		  -DOSMINORVERSION=$(OSMINORVERSION)
     MISC_DEFINES = /* -DALLOWLOGFILEEXEC */ 
      XKB_DEFINES = XkbClientDefines
!         DEFINES = $(XKB_DEFINES) $(XPOLL_DEF) -DKTERM -DSTATUSLINE -DKEEPALIVE
  
  #ifdef KTERM_XIM
          XIMSRCS = xim.c
--- 32,38 ----
  		  -DOSMINORVERSION=$(OSMINORVERSION)
     MISC_DEFINES = /* -DALLOWLOGFILEEXEC */ 
      XKB_DEFINES = XkbClientDefines
!         DEFINES = $(XKB_DEFINES) $(XPOLL_DEF) -DKTERM -DSTATUSLINE -DKEEPALIVE -DMAITOU_PATCH -DMAITOU_PATCH2
  
  #ifdef KTERM_XIM
          XIMSRCS = xim.c
diff -crN kterm-6.2.0/README.maitou kterm-6.2.0.new/README.maitou
*** kterm-6.2.0/README.maitou	Thu Jan  1 09:00:00 1970
--- kterm-6.2.0.new/README.maitou	Mon Aug 20 02:05:30 2001
***************
*** 0 ****
--- 1,135 ----
+ ======================================================================
+               kterm-6.2.0 + 背景透過機能 + WheelMouse
+                             - Release 4 -
+                              Aug 20, 2001
+ 
+                    (C)1999-2001 Maitou Software <maitou@maitou.gr.jp>
+ ======================================================================
+ 
+ << このソフトウェアパッチについて >>
+ ====================================
+ 
+    　このソフトウェアパッチは、kterm の背景にデスクトップ画像を透過
+    させる機能を追加させることができます。また、kterm で MS 製等のホ
+    イールマウスを利用することができるようになります。透過機能は、「
+    kterm は大きめにとりたい！でも、それではせっかくのデスクトップ画
+    像が見えない！」というジレンマを解決するために作成しました。但し、
+    文字を表示するたびに画像の一部と文字を再描画するため、快適に使用
+    するにはそれなりの CPUパワーを必要とします。ホイールマウスへの対
+    応は、mule を kterm 上で利用する人間にとっては、なんとなくこれで
+    ホイールマウスが使えたらいいなと思ったので対応してみました。
+ 
+ 
+ << 著作権と配布について >>
+ ==========================
+ 
+    　本ソフトウェアパッチは、kterm に対する機能追加のためのプログラ
+    ムです。このパッチの著作権は 伊藤正史＠フジテレビジョン にあり、
+    その配布は本パッチに変更を加えない限り誰でも自由に行って頂いて構
+    いません。本パッチへの変更を加えて配布する場合は、この README.maitou
+    ファイルには変更をすることなく、また切り放すことなく行ってくださ
+    い。また改変者が新たに追加する README ファイルには、オリジナルパッ
+    チの作製者が伊藤正史＠フジテレビジョンであることを明記して下さい。
+ 
+ 
+ << 動作環境 >>
+ ==============
+ 
+      Linux (glibc2) 及び Solaris2.6 で確認しました。
+      尚、X サーバが XFree86 や Astec-X のようなバッキングストア命令
+      に対応しているものである必要があります。Astec-X はデフォルトで
+      はオフになっているので、コントロールパネルから「バッキングスト
+      アを使用する」にチェックをして X サーバを起動してください。
+ 
+ 
+ << インストール方法 >>
+ ======================
+ 
+    　オリジナルの kterm のインストール方法と同じです。
+ 
+ 
+ << ホイールマウス使用時の事前準備 >>
+ ====================================
+ 
+    　ホイールマウスを利用する場合は（画像透過だけ利用する場合は無視
+    してください）事前に、XF86Config (普通 /etc/X11/XF86Config, 
+    /etc/XF86Config, /usr/X11R6/lib/X11/XF86Config などにあります) 
+    ファイルの 「 Section "Pointer" 」 を以下のようにセットして
+    X をホイールマウスに対応させておいてください。
+ 
+    Section "Pointer"
+      Protocol       "imps/2"
+      Device         "/dev/mouse"
+      Resolution     100
+      ZAxisMapping   4 5
+    EndSection
+ 
+ 
+ << 使用方法 >>
+ ======================
+ 
+    　デフォルトでは、背景が透過モードになります。透過モードを解除
+    して実行する場合は引数に、+tp をつけるか (つまり % kterm +tp )、
+    X のリソースで、
+ 
+    KTerm*transParent: False
+ 
+    と指定してください。この指定がない限り、通常の kterm と同様に
+    なります。
+ 
+ 
+    　ホイールマウスへの対応は、kterm のスクロール機能に対応する
+    ものでは ** ありません **。mule や less 等でスクロールする際
+    に使われる [Control]-[n] や [Control]-[p] と同様に働くように
+    するものです。ちなみに、もしも単に kterm のスクロール機能に対
+    応させたいだけなら X のリソースに以下を追加するだけです。
+ 
+    KTerm*VT100*translations:      #override      \
+              None<Btn4Down>:  scroll-back(2,1) \n\
+              None<Btn5Down>:  scroll-forw(2,1) \n
+ 
+ 
+ << バグ >>
+ ==========
+ 
+    　もし、この背景透過機能やホイールマウス対応に関わるバグを見つ
+    けたら maitou@maitou.gr.jp に連絡してください。パッチバージョン
+    とあなたのシステムに関する情報の明記も忘れないでください。
+ 
+ 
+ << まいとうソフトウェアについて >>
+ ==================================
+ 
+      まいとうソフトウェアパッチは、「まいとう情報通信研究会」によ
+    り製作されたソフトウェアパッチです。「まいとう情報通信研究会」
+    は、伊藤正史＠フジテレビジョンにより運営されている任意団体で、
+    情報通信分野に興味を持つ社会人が集まり、会員相互の情報研究に関
+    する知識や技術力の向、ネットワーク社会への貢献を行うことを目的
+    として、通常は Linux や Solaris 等の UNIX 系の OS の情報交換、
+    ソフトウェア・ハードウェア・システム開発等を行っています。ホー
+    ムページは、http://www.maitou.gr.jp/ です。
+ 
+ 
+ << ご意見・ご感想・お問い合わせ >>
+ ==================================
+ 
+     本ソフトウェアに関するご意見・ご感想・お問い合わせは、
+   maitou@maitou.gr.jp へお願い致します。付加して欲しい機能等のご
+   要望もお待ちしています。
+ 
+ 
+ << 変更履歴 >>
+ ==============
+ 
+     Release 1  1999/07/13  ...  最初の公式リリース
+     Release 2  1999/09/21  ...  ホイールマウス対応機能を追加
+     Release 4  2001/08/19  ...  ドキュメント等の修正
+ 
+ 
+ << 作製者 >>
+ ============
+                           伊藤 正史（まいとう） <maitou@maitou.gr.jp>
+ 
+ 
+ ----------------------------------------------------------------------
+                    (C)1999-2001 Maitou Software <maitou@maitou.gr.jp>
diff -crN kterm-6.2.0/Tekproc.c kterm-6.2.0.new/Tekproc.c
*** kterm-6.2.0/Tekproc.c	Fri Jul 12 14:01:40 1996
--- kterm-6.2.0.new/Tekproc.c	Mon Aug 20 01:51:17 2001
***************
*** 801,807 ****
--- 801,811 ----
      register int border = 2 * screen->border;
      register double d;
  
+ #ifdef MAITOU_PATCH
+     if (TWindow(screen)) MYClearWindow(screen->display, TWindow(screen));
+ #else
      if (TWindow(screen)) XClearWindow(screen->display, TWindow(screen));
+ #endif
      TWidth(screen) = w->core.width - border;
      THeight(screen) = w->core.height - border;
      TekScale(screen) = (double)TWidth(screen) / TEKWIDTH;
***************
*** 868,874 ****
--- 872,882 ----
  	register TScreen *screen = &term->screen;
  	register TekLink *tek;
  
+ #ifdef MAITOU_PATCH
+ 	MYClearWindow(screen->display, TWindow(screen));
+ #else
  	XClearWindow(screen->display, TWindow(screen));
+ #endif
  	screen->cur_X = 0;
  	screen->cur_Y = TEKHOME;
  	screen->margin = MARGIN1;
***************
*** 1569,1575 ****
--- 1577,1587 ----
  
  	if (toggle == TOGGLE) {
  	   if (screen->select || screen->always_highlight) 
+ #ifdef MAITOU_PATCH
+ 	       MYFillRectangle(screen->display, TWindow(screen),
+ #else
  	       XFillRectangle(screen->display, TWindow(screen),
+ #endif
  			      screen->TcursorGC, x, y,
  			      cellwidth, cellheight);
  	   else { /* fix to use different GC! */
***************
*** 1584,1590 ****
--- 1596,1606 ----
  	     * event and is easier than trying to figure out exactly
  	     * which part of the cursor needs to be erased.
  	     */
+ #ifdef MAITOU_PATCH
+ 	    MYClearArea(screen->display, TWindow(screen), x, y,
+ #else
  	    XClearArea(screen->display, TWindow(screen), x, y,
+ #endif
  		       cellwidth, cellheight, FALSE);
  	}
  }
diff -crN kterm-6.2.0/charproc.c kterm-6.2.0.new/charproc.c
*** kterm-6.2.0/charproc.c	Fri Jul 12 14:01:36 1996
--- kterm-6.2.0.new/charproc.c	Mon Aug 20 01:51:17 2001
***************
*** 2451,2457 ****
--- 2451,2462 ----
  			FlushScroll(screen);
  	cx = CursorX(screen, screen->cur_col);
  	cy = CursorY(screen, screen->cur_row)+screen->fnt_norm->ascent;
+ #ifdef MAITOU_PATCH
+  	MYDrawImageString(screen, screen->fnt_norm->ascent, reverse,
+ 			  screen->display, TextWindow(screen), currentGC,
+ #else	
   	XDrawImageString(screen->display, TextWindow(screen), currentGC,
+ #endif
  			cx, cy, str, len);
  
  	if((fgs & BOLD) && screen->enbolden) 
***************
*** 3028,3036 ****
--- 3033,3049 ----
  #else /* !STATUSLINE */
  		if(top == 0)
  #endif /* !STATUSLINE */
+ #ifdef MAITOU_PATCH
+ 		        MYClearWindow(screen->display, TextWindow(screen));
+ #else
  			XClearWindow(screen->display, TextWindow(screen));
+ #endif
  		else
+ #ifdef MAITOU_PATCH
  			XClearArea(
+ #else
+ 			XClearArea(
+ #endif
  			    screen->display,
  			    TextWindow(screen),
  			    (int) screen->border + screen->scrollbar,
***************
*** 3884,3889 ****
--- 3897,3905 ----
  	GC	currentGC;
  #endif /* !KTERM */
  	Boolean	in_selection;
+ #ifdef MAITOU_PATCH
+ 	int reverse;
+ #endif
  
  	if (eventMode != NORMAL) return;
  
***************
*** 3933,3938 ****
--- 3949,3957 ----
  		if (( (flags & INVERSE) && !in_selection) ||
  		    (!(flags & INVERSE) &&  in_selection)){
  		    /* text is reverse video */
+ #ifdef MAITOU_PATCH
+ 		  reverse = 0;
+ #endif
  		    if (screen->cursorGC) {
  			currentGC = screen->cursorGC;
  		    } else {
***************
*** 3943,3948 ****
--- 3962,3970 ----
  			}
  		    }
  		} else { /* normal video */
+ #ifdef MAITOU_PATCH
+ 		  reverse = 1;
+ #endif
  		    if (screen->reversecursorGC) {
  			currentGC = screen->reversecursorGC;
  		    } else {
***************
*** 3957,3964 ****
--- 3979,3992 ----
  		if (( (flags & INVERSE) && !in_selection) ||
  		    (!(flags & INVERSE) &&  in_selection)) {
  		    /* text is reverse video */
+ #ifdef MAITOU_PATCH
+ 		  reverse = 1;
+ #endif
  			currentGC = screen->reverseGC;
  		} else { /* normal video */
+ #ifdef MAITOU_PATCH
+ 		  reverse = 0;
+ #endif
  			currentGC = screen->normalGC;
  		}
  	    
***************
*** 3967,3973 ****
--- 3995,4006 ----
  	x = CursorX (screen, screen->cur_col);
  	y = CursorY(screen, screen->cur_row) + 
  	  screen->fnt_norm->ascent;
+ #ifdef MAITOU_PATCH
+ 	MYDrawImageString(screen, screen->fnt_norm->ascent, reverse,
+ 			  screen->display, TextWindow(screen), currentGC,
+ #else
  	XDrawImageString(screen->display, TextWindow(screen), currentGC,
+ #endif
  		x, y, (char *) &c, 1);
  
  	if((flags & BOLD) && screen->enbolden) /* no bold font */
***************
*** 4010,4015 ****
--- 4043,4051 ----
  	char c;
  #endif /* !KTERM */
  	Boolean	in_selection;
+ #ifdef MAITOU_PATCH
+ 	int reverse;
+ #endif
  
  #ifdef STATUSLINE
  	Boolean in_status = (screen->cursor_row > screen->max_row);
***************
*** 4052,4063 ****
--- 4088,4105 ----
  #else /* !KTERM */
  	if (( (flags & INVERSE) && !in_selection) ||
  	    (!(flags & INVERSE) &&  in_selection)) {
+ #ifdef MAITOU_PATCH
+ 	  reverse = 1;
+ #endif
  		if(flags & BOLD) {
  			currentGC = screen->reverseboldGC;
  		} else {
  			currentGC = screen->reverseGC;
  		}
  	} else {
+ #ifdef MAITOU_PATCH
+ 	  reverse = 0;
+ #endif
  		if(flags & BOLD) {
  			currentGC = screen->normalboldGC;
  		} else {
***************
*** 4075,4081 ****
--- 4117,4128 ----
  	 screen->border;
  # endif /* !STATUSLINE */
  	y = y+screen->fnt_norm->ascent;
+ #ifdef MAITOU_PATCH
+ 	MYDrawImageString(screen,screen->fnt_norm->ascent, reverse,
+ 			  screen->display, TextWindow(screen), currentGC,
+ #else
  	XDrawImageString(screen->display, TextWindow(screen), currentGC,
+ #endif
  		x, y, &c, 1);
  	if((flags & BOLD) && screen->enbolden)
  		XDrawString(screen->display, TextWindow(screen), currentGC,
***************
*** 4257,4263 ****
--- 4304,4314 ----
  		j = screen->max_col + 1);
  	bzero(screen->buf[i + 1], j) ;
  # endif /* !KTERM */
+ #ifdef MAITOU_PATCH
+ 	MYFillRectangle(screen->display, TextWindow(screen),
+ #else
  	XFillRectangle(screen->display, TextWindow(screen),
+ #endif
  		screen->reversestatus ? screen->normalGC : screen->reverseGC,
  		screen->border - 1 + screen->scrollbar,
  		Height(screen) + screen->border * 2 + 1,
***************
*** 5082,5088 ****
--- 5133,5143 ----
  
      if (doresize) {
  	if (VWindow(screen)) {
+ #ifdef MAITOU_PATCH
+ 	    MYClearWindow (screen->display, VWindow(screen));
+ #else
  	    XClearWindow (screen->display, VWindow(screen));
+ #endif
  	}
  	DoResizeScreen (term);		/* set to the new natural size */
  	if (screen->scrollWidget)
diff -crN kterm-6.2.0/kterm.h kterm-6.2.0.new/kterm.h
*** kterm-6.2.0/kterm.h	Fri Jul 12 14:01:37 1996
--- kterm-6.2.0.new/kterm.h	Mon Aug 20 01:51:17 2001
***************
*** 24,34 ****
   * 	3-1-1 Tsushima-Naka, Okayama-shi 700, Japan
   * 	kagotani@in.it.okayama-u.ac.jp
   */ 
! 
  #ifndef _KTERM_H_
  #define _KTERM_H_
  
! #define KTERM_VERSION	"6.2.0"
  #define KTERM_MBCS	/* multi-byte character set */
  #define KTERM_MBCC	/* multi-byte character class for word selection */
  #define KTERM_KANJIMODE	/* euc/sjis Kanji modes */
--- 24,42 ----
   * 	3-1-1 Tsushima-Naka, Okayama-shi 700, Japan
   * 	kagotani@in.it.okayama-u.ac.jp
   */ 
! /*
!  * Transparent Patch:
!  *      Masashi Itou
!  *      Department of Information Science and Engineering
!  *      Chuo University
!  *      Maitou Information and Telecommunication Labs.
!  *      maitou@tsujii-lab.ise.chuo-u.ac.jp
!  *      maitou@matiou.gr.jp
!  */
  #ifndef _KTERM_H_
  #define _KTERM_H_
  
! #define KTERM_VERSION	"6.2.0 + Maitou-patch(transparent)1"
  #define KTERM_MBCS	/* multi-byte character set */
  #define KTERM_MBCC	/* multi-byte character class for word selection */
  #define KTERM_KANJIMODE	/* euc/sjis Kanji modes */
***************
*** 39,41 ****
--- 47,50 ----
  #undef  KTERM_XAW3D	/* Xaw3d -DARROW_SCROLLBAR support */
  
  #endif /* !_KTERM_H_ */
+ 
diff -crN kterm-6.2.0/kterm.jman kterm-6.2.0.new/kterm.jman
*** kterm-6.2.0/kterm.jman	Fri Jul 12 14:01:37 1996
--- kterm-6.2.0.new/kterm.jman	Mon Aug 20 01:54:44 2001
***************
*** 132,137 ****
--- 132,143 ----
  .BI \+st
  $B%9%F!<%?%9%i%$%s$,%9%?!<%H;~$KI=<($5$l$J$$$h$&$K$7$^$9!#(B
  .TP 8
+ .BI \-tp
+ $BGX7JF)2a%b!<%I$G<B9T$7$^$9!#(B
+ .TP 8
+ .BI \+tp
+ $BGX7JF)2a%b!<%I$r2r=|$7$^$9!#(B
+ .TP 8
  .BI \-version
  $BC1$K(B \fIkterm\fP $B$N%P!<%8%g%s$rI=<($7$^$9!#(B
  .TP 8
***************
*** 150,155 ****
--- 156,164 ----
  \fIkterm\fP $B$,%U%)%s%H$rF0E*$K%m!<%I$9$k$+$I$&$+$r;XDj$7$^$9!#(B
  $B%G%U%)%k%H$O(B ``true'' $B$G$9!#(B
  .TP 8
+ .B "transParent "
+ $BGX7JF)2a%b!<%I$r@_Dj$7$^$9!#%G%U%)%k%H$O(B ``true'' $B$G$9!#(B
+ .TP 8
  .B "fontList (\fPclass\fB FontList)"
  $B%U%)%s%HL>$N%j%9%H$r;XDj$7$^$9!#%G%U%)%k%H$O(B 
  ``-*-fixed-medium-r-normal--14-*,
***************
*** 314,316 ****
--- 323,328 ----
  $B@PA>:,?.(B ($B3t<02q<R(B SRA),
  $BdFC+M5?M(B ($B2,;3Bg3X(B),
  $BIp@n?J(B ($BF|K\EE?.EEOC3t<02q<R(B)
+ .SH TRANSPARENT PATCH
+ $B0KF#@5;K(B ($B3t<02q<R%U%8%F%l%S%8%g%s(B)
+ 
diff -crN kterm-6.2.0/kterm.man kterm-6.2.0.new/kterm.man
*** kterm-6.2.0/kterm.man	Fri Jul 12 14:01:37 1996
--- kterm-6.2.0.new/kterm.man	Mon Aug 20 01:51:17 2001
***************
*** 134,139 ****
--- 134,145 ----
  .B \+st
  This option causes the status line not to be displayed on startup.
  .TP 8
+ .B \-tp
+ This option causes transparent background mode
+ .TP 8
+ .B \+tp
+ This option causes no transparent background mode
+ .TP 8
  .BI \-version
  Just displays the \fIkterm\fP version and exit.
  .TP 8
***************
*** 152,157 ****
--- 158,166 ----
  Specifies whether or not \fIkterm\fP should load fonts dynamically The
  default is ``true.''
  .TP 8
+ .B "transParent"
+ Specifies whether or not transparent mode.The default is ``true.''
+ .TP 8
  .B "fontList (\fPclass\fB FontList)"
  Specifies the name of the fonts.  The default is
  ``-*-fixed-medium-r-normal--14-*,
***************
*** 325,327 ****
--- 334,338 ----
  Makoto Ishisone (SRA Inc.),
  Hiroto Kagotani (Okayama Univ.),
  Susumu Mukawa (NTT Corp.).
+ .SH TRANSPARENT PATCH
+ Masashi Itou (Fuji Television Network,inc.)
diff -crN kterm-6.2.0/main.c kterm-6.2.0.new/main.c
*** kterm-6.2.0/main.c	Fri Jul 12 14:01:38 1996
--- kterm-6.2.0.new/main.c	Mon Aug 20 01:51:17 2001
***************
*** 140,145 ****
--- 140,148 ----
  #define HAS_UTMP_UT_HOST
  #define LASTLOG
  #define WTMP
+ #ifdef MAITOU_PATCH
+ #include <termbits.h>
+ #endif
  #endif
  
  #include <sys/ioctl.h>
***************
*** 610,615 ****
--- 613,621 ----
  #ifdef KEEPALIVE
      Boolean keepalive;
  #endif
+ #ifdef MAITOU_PATCH
+   Boolean transParent;
+ #endif
  } resource;
  
  /* used by VT (charproc.c) */
***************
*** 649,654 ****
--- 655,664 ----
      {"keepAlive", "KeepAlive", XtRBoolean, sizeof (Boolean),
  	offset(keepalive), XtRString, "false"},
  #endif /* KEEPALIVE */
+ #ifdef MAITOU_PATCH
+     {"transParent", "TransParent", XtRBoolean, sizeof (Boolean),
+        offset(transParent), XtRString, "true"},
+ #endif
  };
  #undef offset
  
***************
*** 770,775 ****
--- 780,789 ----
  {"+vb",		"*visualBell",	XrmoptionNoArg,		(caddr_t) "off"},
  {"-wf",		"*waitForMap",	XrmoptionNoArg,		(caddr_t) "on"},
  {"+wf",		"*waitForMap",	XrmoptionNoArg,		(caddr_t) "off"},
+ #ifdef MAITOU_PATCH
+ {"-tp",         "*transParent", XrmoptionNoArg,         (caddr_t) "on"},
+ {"+tp",         "*transParent", XrmoptionNoArg,         (caddr_t) "off"},
+ #endif
  /* bogus old compatibility stuff for which there are
     standard XtAppInitialize options now */
  #ifndef KTERM_NOTEK
***************
*** 870,875 ****
--- 884,892 ----
  { "-/+t",                  "turn on/off Tek emulation window" },
  { "-tm string",            "terminal mode keywords and characters" },
  { "-tn name",              "TERM environment variable name" },
+ #ifdef MAITOU_PATCH
+ { "-/+tp",                 "use/don't use transparent wallpaper" },
+ #endif
  #ifdef __sgi
  { "-/+ul",                 "use/don't use locale for character input" },
  #endif
***************
*** 1016,1021 ****
--- 1033,1041 ----
  # ifdef KEEPALIVE
      printopt(" [KEEPALIVE]");
  # endif
+ # ifdef MAITOU_PATCH
+     printopt(" [TRANSPARENT]");
+ # endif
      fprintf (stderr, "\n");
  
      exit (0);
***************
*** 1087,1096 ****
--- 1107,1225 ----
  extern fd_set X_mask;
  extern fd_set pty_mask;
  
+ #ifdef MAITOU_PATCH
+ 
+ int is_transparent = 0;
+ int now_abs_x = 0, now_abs_y = 0;
+ int now_width = 0, now_height = 0;
+ GC transparentGC;
+ 
+ void
+ MYClearArea(display, win, x, y, width, height, exposures)
+      Display *display;
+      Window win;
+      int x;
+      int y;
+      unsigned int width;
+      unsigned int height;
+      Bool exposures;
+ {
+   if( is_transparent ){
+     /* x,y width,height は使わない (XEvent のものを使用) */
+     XCopyArea(display, DefaultRootWindow(display),
+ 	      win, transparentGC,
+ 	      x + now_abs_x, y + now_abs_y, width, height, x, y ); /* 座標 OK */
+   }else{
+     XClearArea(display, win, x, y, width, height, exposures);
+   }
+ }
+ 
+ void
+ MYClearWindow(display, win)
+      Display *display;
+      Window win;
+ {
+   if( is_transparent ){
+     MYClearArea(display, win, 0, 0, now_width, now_height, True);
+   }else{
+     XClearWindow(display, win);
+   }
+ }
+ 
+ void
+ MYFillRectangle(display, d, gc, x, y, width, height)
+      Display *display;
+      Drawable d;
+      GC gc;
+      int x;
+      int y;
+      unsigned int width;
+      unsigned int height;
+ {
+   if( is_transparent ){
+     /* x,y width,height は使わない (XEvent のものを使用) */
+     XCopyArea(display, DefaultRootWindow(display), d, transparentGC,
+ 	      x + now_abs_x, y + now_abs_y, width, height, x, y );
+   }else{
+     XFillRectangle(display, d, gc, x, y, width, height);
+   }
+ }
+ 
+ void
+ MYDrawImageString(screen, ascent, reverse, display, d, gc, x, y, string, length )
+      TScreen *screen;
+      int ascent;
+      int reverse;
+      Display *display;
+      Drawable d;
+      GC gc;
+      int x;
+      int y;
+      char *string;
+      int length;
+ {
+   if( !reverse && is_transparent ){
+     MYFillRectangle(display, d, gc, x, y - ascent, FontWidth(screen)*length, FontHeight(screen) );
+     XDrawString(display, d, gc, x, y, string, length);
+   }else{
+     XDrawImageString(display, d, gc, x, y, string, length);
+   }
+ }
+ 
+ void
+ MYDrawImageString16(screen, ascent, reverse, display, d, gc, x, y, string, length)
+      TScreen *screen;
+      int ascent;
+      int reverse;
+      Display *display;
+      Drawable d;
+      GC gc;
+      int x;
+      int y;
+      XChar2b *string;
+      int length;
+ {
+   int i, len = 0;
+   
+   for (i = 0; i < length; i++){
+     len += (string[i].byte1 == 0x00) ? 1 : 2;
+   }
+   if (!reverse && is_transparent){
+     MYFillRectangle(display, d, gc, x, y - ascent, FontWidth(screen)*len, FontHeight(screen) );
+     XDrawString16(display, d, gc, x, y, string, length);
+   }else{
+     XDrawImageString16(display, d, gc, x, y, string, length);
+   }
+ }
+ #endif /* MAITOU_PATCH */
+ 
  main (argc, argv)
  int argc;
  char **argv;
  {
+ #ifdef MAITOU_PATCH
+   XSetWindowAttributes att;
+ #endif
  	register TScreen *screen;
  	int mode;
  	char *base_name();
***************
*** 1651,1656 ****
--- 1780,1800 ----
  #endif	/* DEBUG */
  	XSetErrorHandler(xerror);
  	XSetIOErrorHandler(xioerror);
+ #ifdef MAITOU_PATCH
+ 	if( resource.transParent ){
+ 	  is_transparent = 1;
+ 	  att.backing_store = Always;
+ 	  XChangeWindowAttributes( XtDisplay(toplevel),
+ 				   DefaultRootWindow(XtDisplay(toplevel)),
+ 				   CWBackingStore, &att );
+ 	  transparentGC = XCreateGC( XtDisplay(toplevel), XtWindow(toplevel),
+ 				     0, NULL );
+ 	  XSelectInput( XtDisplay(toplevel), XtWindow(toplevel),
+ 			StructureNotifyMask );
+ 	}else{
+ 	  is_transparent = 0;
+ 	}
+ #endif
  	for( ; ; ) {
  #ifndef KTERM_NOTEK
  		if(screen->TekEmu) {
diff -crN kterm-6.2.0/misc.c kterm-6.2.0.new/misc.c
*** kterm-6.2.0/misc.c	Fri Jul 12 14:01:43 1996
--- kterm-6.2.0.new/misc.c	Mon Aug 20 01:51:17 2001
***************
*** 51,56 ****
--- 51,62 ----
  extern jmp_buf Tekend;
  extern jmp_buf VTend;
  
+ #ifdef MAITOU_PATCH
+ extern int now_abs_x, now_abs_y;
+ extern int now_width, now_height;
+ extern GC transparentGC;
+ #endif
+ 
  #ifndef X_NOT_STDC_ENV
  #include <stdlib.h>
  #else
***************
*** 127,132 ****
--- 133,168 ----
  #endif /* !KTERM_NOTEK */
  		  DoSpecialLeaveNotify (&event.xcrossing);
  
+ #ifdef MAITOU_PATCH
+ 		if(event.type == ConfigureNotify ){
+ 		  extern Widget toplevel;
+ 		  if( event.xconfigure.window == XtWindow(XtParent(term)) ){
+ 		    now_abs_x = event.xconfigure.x;
+ 		    now_abs_y = event.xconfigure.y;
+ 		    now_width = event.xconfigure.width;
+ 		    now_height = event.xconfigure.height;
+ 		    AllRefresh(term);
+ 		  }
+ 		}
+ #endif
+ 
+ #ifdef MAITOU_PATCH2
+  		if( event.type == ButtonPress &&
+  		    ( event.xbutton.state == 0 || event.xbutton.state == 4 )&&
+  		    ( event.xbutton.button == 4||event.xbutton.button == 5 ) ){
+  		  event.type = event.xany.type = KeyPress;
+  		  /* -- 注: xkey.keycode と xbutton.button,
+  		     xkey.state と xbutton.state は同じ所を指している -- */
+  		  if( event.xbutton.state == 0 ){
+  		    event.xkey.keycode=(event.xbutton.button==4)?33:57;
+  		    event.xkey.state = 4;
+  		  }else{
+  		    event.xkey.state = (event.xbutton.button==4)?8:4;
+  		    event.xkey.keycode = 55;
+  		  }
+  		}
+ #endif /* MAITOU_PATCH2 */
+  
  		if (!event.xany.send_event ||
  		    screen->allowSendEvents ||
  		    ((event.xany.type != KeyPress) &&
diff -crN kterm-6.2.0/screen.c kterm-6.2.0.new/screen.c
*** kterm-6.2.0/screen.c	Sun Jun 23 17:00:26 1996
--- kterm-6.2.0.new/screen.c	Mon Aug 20 01:51:17 2001
***************
*** 556,561 ****
--- 556,569 ----
  	int scrollamt = screen->scroll_amt;
  	int max = screen->max_row;
  
+ #ifdef MAITOU_PATCH
+ 	{
+ 	  extern int is_transparent;
+ 	  if( is_transparent ){
+ 	    force = True;
+ 	  }
+ 	}
+ #endif
  #ifdef STATUSLINE
  	if(screen->cursor_col >= leftcol
  	&& screen->cursor_col <= (leftcol + ncols - 1)
***************
*** 587,592 ****
--- 595,603 ----
  	   GC gc;
  #endif /* !KTERM */
  	   Boolean hilite;	
+ #ifdef MAITOU_PATCH
+ 	   int reverse;
+ #endif
  
  #ifdef STATUSLINE
  	   if (row > screen->max_row) { /* implies (row > screen->bot_marg) */
***************
*** 606,612 ****
--- 617,627 ----
  		}
  		if (leftcol + ncols - 1 >= screen->max_col)
  		    width += screen->border;
+ #ifdef MAITOU_PATCH
+ 		MYFillRectangle(screen->display, TextWindow(screen),
+ #else
  		XFillRectangle(screen->display, TextWindow(screen),
+ #endif
  		    screen->reversestatus ? screen->normalGC : screen->reverseGC,
  		    left, Height(screen) + screen->border * 2,
  		    width, screen->statusheight);
***************
*** 691,707 ****
  # ifdef STATUSLINE
  	   if (((!hilite && (flags & INVERSE) != 0) ||
  	        (hilite && (flags & INVERSE) == 0))
  		^ (row > screen->max_row && screen->reversestatus))
  # else /* !STATUSLINE */
  	   if ( (!hilite && (flags & INVERSE) != 0) ||
  	        (hilite && (flags & INVERSE) == 0) )
  # endif /* !STATUSLINE */
  	       if (flags & BOLD) gc = screen->reverseboldGC;
  	       else gc = screen->reverseGC;
  	   else 
  	       if (flags & BOLD) gc = screen->normalboldGC;
  	       else gc = screen->normalGC;
! 
  	   x = CursorX(screen, col);
  #endif /* !KTERM */
  	   lastind = col;
--- 706,740 ----
  # ifdef STATUSLINE
  	   if (((!hilite && (flags & INVERSE) != 0) ||
  	        (hilite && (flags & INVERSE) == 0))
+ #ifdef MAITOU_PATCH
+ 	       ^ (row > screen->max_row && screen->reversestatus)){
+ #else
  		^ (row > screen->max_row && screen->reversestatus))
+ #endif
  # else /* !STATUSLINE */
  	   if ( (!hilite && (flags & INVERSE) != 0) ||
+ #ifdef MAITOU_PATCH
+ 	        (hilite && (flags & INVERSE) == 0) ){
+ #else
  	        (hilite && (flags & INVERSE) == 0) )
+ #endif
  # endif /* !STATUSLINE */
+ #ifdef MAITOU_PATCH
+ 	      reverse = 1;
+ #endif
  	       if (flags & BOLD) gc = screen->reverseboldGC;
  	       else gc = screen->reverseGC;
+ #ifdef MAITOU_PATCH
+ 	   }else{
+ 	     reverse = 1;
+ #else
  	   else 
+ #endif
  	       if (flags & BOLD) gc = screen->normalboldGC;
  	       else gc = screen->normalGC;
! #ifdef MAITOU_PATCH
! 	   }
! #endif
  	   x = CursorX(screen, col);
  #endif /* !KTERM */
  	   lastind = col;
***************
*** 714,720 ****
--- 747,758 ----
  		   ScreenDraw(screen, row + topline, lastind, col, flags, False);
  #else /* !KTERM */
  		if (attrs[col] != flags) {
+ #ifdef MAITOU_PATCH
+ 		   MYDrawImageString(screen, screen->max_ascent, reverse,
+ 				     screen->display, TextWindow(screen), 
+ #else
  		   XDrawImageString(screen->display, TextWindow(screen), 
+ #endif
  		        	gc, x, y, (char *) &chars[lastind], n = col - lastind);
  		   if((flags & BOLD) && screen->enbolden)
  		 	XDrawString(screen->display, TextWindow(screen), 
***************
*** 769,782 ****
--- 807,838 ----
  		^ (row > screen->max_row && screen->reversestatus))
  # else /* !STATUSLINE */
  	   if ( (!hilite && (flags & INVERSE) != 0) ||
+ #ifdef MAITOU_PATCH
+ 	        (hilite && (flags & INVERSE) == 0) ){
+ #else
  	        (hilite && (flags & INVERSE) == 0) )
+ #endif
  # endif /* !STATUSLINE */
+ #ifdef MAITOU_PATCH
+ 	     reverse = 1;
+ #endif
  	       if (flags & BOLD) gc = screen->reverseboldGC;
  	       else gc = screen->reverseGC;
+ #ifdef MAITOU_PATCH
+ 	   }else{
+ 	     reverse = 0;
+ #else
  	   else 
+ #endif
  	       if (flags & BOLD) gc = screen->normalboldGC;
  	       else gc = screen->normalGC;
+ #ifdef MAITOU_PATCH
+ 	   }
+ 	   MYDrawImageString(screen, screen->max_ascent, reverse,
+ 			     screen->display, TextWindow(screen), gc, 
+ #else
  	   XDrawImageString(screen->display, TextWindow(screen), gc, 
+ #endif
  	         x, y, (char *) &chars[lastind], n = col - lastind);
  	   if((flags & BOLD) && screen->enbolden)
  		XDrawString(screen->display, TextWindow(screen), gc,
***************
*** 844,850 ****
--- 900,910 ----
  
  	/* clear the right and bottom internal border because of NorthWest
  	   gravity might have left junk on the right and bottom edges */
+ #ifdef MAITOU_PATCH
+ 	MYClearArea (screen->display, tw,
+ #else
  	XClearArea (screen->display, tw,
+ #endif
  		    width - screen->border, 0,                /* right edge */
  #ifdef STATUSLINE
  		    screen->border, height - screen->statusheight,
***************
*** 852,858 ****
--- 912,922 ----
  		    screen->border, height,           /* from top to bottom */
  #endif /* !STATUSLINE */
  		    False);
+ #ifdef MAITOU_PATCH
+ 	MYClearArea (screen->display, tw, 
+ #else
  	XClearArea (screen->display, tw, 
+ #endif
  #ifdef STATUSLINE
  		    0, height - screen->border - screen->statusheight,
  #else /* !STATUSLINE */
***************
*** 878,884 ****
--- 942,952 ----
  	 && term->misc.resizeGravity == NorthWestGravity) {
  		/* bit_gravity != ForgetGravity */
  		if (rows > screen->max_row + 1) {
+ #ifdef MAITOU_PATCH
+ 		    MYClearArea (screen->display, tw, 
+ #else
  		    XClearArea (screen->display, tw, 
+ #endif
  				screen->scrollbar,
  				(screen->max_row + 1) * FontHeight(screen) +
  				screen->border * 2,
***************
*** 887,893 ****
--- 955,965 ----
  				screen->statusheight,
  				True);
  		} else if (rows < screen->max_row + 1) {
+ #ifdef MAITOU_PATCH
+ 		    MYClearArea (screen->display, tw, 
+ #else
  		    XClearArea (screen->display, tw, 
+ #endif
  				screen->scrollbar,
  				rows * FontHeight(screen) +
  				screen->border * 2,
***************
*** 1147,1152 ****
--- 1219,1227 ----
  	char	drawbuf[256], *dbuf = drawbuf;
  	int	n, c;
  	int	x, y;
+ #ifdef MAITOU_PATCH
+ 	int reverse;
+ #endif
  
  	x = CursorX(screen, col);
  	y = CursorY(screen, row);
***************
*** 1193,1198 ****
--- 1268,1276 ----
  	    LoadOneFont(screen, True, screen->menu_font_number, fnum, True);
  	
  	if (flags & INVERSE) {
+ #ifdef MAITOU_PATCH
+ 	  reverse = 1;
+ #endif
  		if (hilitecursor && screen->reversecursorGC)
  			gc = screen->reversecursorGC;
  		else if (flags & BOLD)
***************
*** 1200,1205 ****
--- 1278,1286 ----
  		else
  			gc = screen->reverseGC;
  	} else {
+ #ifdef MAITOU_PATCH
+ 	  reverse = 0;
+ #endif
  		if (hilitecursor && screen->cursorGC)
  			gc = screen->cursorGC;
  		else if (flags & BOLD)
***************
*** 1243,1249 ****
--- 1324,1335 ----
  
  #ifdef KTERM_MBCS
  		if (gset & MBCS) {
+ #ifdef MAITOU_PATCH
+ 			MYDrawImageString16(screen, screen->max_ascent, reverse,
+ 					    screen->display, TextWindow(screen),
+ #else
  			XDrawImageString16(screen->display, TextWindow(screen),
+ #endif
  				gc, x, Y, dbuf2, n);
  			if (flags & BOLD && screen->normalboldGC == screen->normalGC)
  			    XDrawString16(screen->display, TextWindow(screen),
***************
*** 1251,1257 ****
--- 1337,1348 ----
  		} else
  #endif /* KTERM_MBCS */
  		{
+ #ifdef MAITOU_PATCH
+ 			MYDrawImageString(screen, screen->max_ascent, reverse,
+ 					  screen->display, TextWindow(screen),
+ #else
  			XDrawImageString(screen->display, TextWindow(screen),
+ #endif
  				gc, x, Y, dbuf, n);
  			if (flags & BOLD && screen->normalboldGC == screen->normalGC)
  			    XDrawString(screen->display, TextWindow(screen),
diff -crN kterm-6.2.0/scrollbar.c kterm-6.2.0.new/scrollbar.c
*** kterm-6.2.0/scrollbar.c	Fri Jul 12 14:01:39 1996
--- kterm-6.2.0.new/scrollbar.c	Mon Aug 20 01:51:17 2001
***************
*** 157,162 ****
--- 157,167 ----
  						  repHeight, NULL, NULL);
  	}
  
+ #ifdef MAITOU_PATCH
+ 	FullWidth(screen) = repWidth;
+ 	FullHeight(screen) = repHeight;
+ #endif
+ 
  #ifndef nothack
  	XSetWMNormalHints(screen->display, XtWindow(XtParent(xw)), &sizehints);
  #endif
***************
*** 303,309 ****
--- 308,318 ----
  
  	ScrollSelection(screen, i);
  
+ #ifdef MAITOU_PATCH
+ 	MYClearArea(
+ #else
  	XClearArea(
+ #endif
  	    screen->display,
  	    TextWindow(screen), 
  	    (int) x,
***************
*** 399,405 ****
--- 408,418 ----
  	XtMapWidget(screen->scrollWidget);
  	update_scrollbar ();
  	if (screen->buf) {
+ #ifdef MAITOU_PATCH
+ 	    MYClearWindow (screen->display, XtWindow (term));
+ #else
  	    XClearWindow (screen->display, XtWindow (term));
+ #endif
  	    Redraw ();
  	}
  }
***************
*** 414,420 ****
--- 427,437 ----
  	DoResizeScreen (term);
  	update_scrollbar ();
  	if (screen->buf) {
+ #ifdef MAITOU_PATCH
+ 	    MYClearWindow (screen->display, XtWindow (term));
+ #else
  	    XClearWindow (screen->display, XtWindow (term));
+ #endif
  	    Redraw ();
  	}
  }
diff -crN kterm-6.2.0/util.c kterm-6.2.0.new/util.c
*** kterm-6.2.0/util.c	Tue Jul  2 14:01:53 1996
--- kterm-6.2.0.new/util.c	Mon Aug 20 01:51:17 2001
***************
*** 42,47 ****
--- 42,51 ----
  static int fnum = F_ISO8859_1; /* refered by *GC in many functions */
  #endif /* KTERM */
  
+ #ifdef MAITOU_PATCH
+ extern is_transparent;
+ #endif
+ 
  /*
   * These routines are used for the jump scroll feature
   */
***************
*** 107,119 ****
--- 111,134 ----
  		if((i = screen->top_marg + refreshheight - 1 - bot) > 0)
  			refreshheight -= i;
  	}
+ #ifdef MAITOU_PATCH
+ 	if( is_transparent )
+ 	  ScrollSelection(screen, -(screen->scroll_amt));
+ #endif
  	scrolling_copy_area(screen, scrolltop+screen->scroll_amt,
  			    scrollheight, screen->scroll_amt);
+ #ifdef MAITOU_PATCH
+ 	if( !is_transparent )
+ #endif
  	ScrollSelection(screen, -(screen->scroll_amt));
  	screen->scroll_amt = 0;
  	screen->refresh_amt = 0;
  	if(refreshheight > 0) {
+ #ifdef MAITOU_PATCH
+ 		MYClearArea (
+ #else
  		XClearArea (
+ #endif
  		    screen->display,
  		    TextWindow(screen),
  		    (int) screen->border + screen->scrollbar,
***************
*** 237,243 ****
--- 252,262 ----
  	}
  	scrolling_copy_area(screen, scrolltop+amount, scrollheight, amount);
  	if(refreshheight > 0) {
+ #ifdef MAITOU_PATCH
+ 		MYClearArea (
+ #else
  		XClearArea (
+ #endif
  		   screen->display,
  		   TextWindow(screen),
  		   (int) screen->border + screen->scrollbar,
***************
*** 317,323 ****
--- 336,346 ----
  	}
  	scrolling_copy_area(screen, scrolltop-amount, scrollheight, -amount);
  	if(refreshheight > 0)
+ #ifdef MAITOU_PATCH
+ 		MYClearArea (
+ #else
  		XClearArea (
+ #endif
  		    screen->display,
  		    TextWindow(screen),
  		    (int) screen->border + screen->scrollbar,
***************
*** 346,351 ****
--- 369,377 ----
  	register int refreshheight;
  	register int scrolltop;
  	register int scrollheight;
+ #ifdef MAITOU_PATCH
+ 	int vcopy = 0;
+ #endif
  
  	if (screen->cur_row < screen->top_marg ||
  	 screen->cur_row > screen->bot_marg)
***************
*** 376,384 ****
--- 402,419 ----
  		scrollheight -= i;
  	if((i = screen->cur_row + refreshheight - 1 - bot) > 0)
  		refreshheight -= i;
+ #ifdef MAITOU_PATCH
+ 	if( is_transparent )
+ 	  vcopy = 1;
+ 	else
+ #endif
  	vertical_copy_area(screen, scrolltop-n, scrollheight, -n);
  	if(refreshheight > 0)
+ #ifdef MAITOU_PATCH
+ 		MYClearArea (
+ #else
  		XClearArea (
+ #endif
  		    screen->display,
  		    TextWindow(screen),
  		    (int) screen->border + screen->scrollbar,
***************
*** 390,395 ****
--- 425,434 ----
  	/* adjust screen->buf */
  	ScrnInsertLine(screen->buf, screen->bot_marg, screen->cur_row, n,
  			screen->max_col + 1);
+ #ifdef MAITOU_PATCH
+ 	if( vcopy )
+ 	  ScrnRefresh(screen, scrolltop, 0, scrollheight, screen->max_col + 1, True );
+ #endif
  }
  
  /*
***************
*** 407,412 ****
--- 446,454 ----
  	register int refreshheight;
  	register int scrolltop;
  	register int scrollheight;
+ #ifdef MAITOU_PATCH
+ 	int vcopy = 0;
+ #endif
  
  	if (screen->cur_row < screen->top_marg ||
  	 screen->cur_row > screen->bot_marg)
***************
*** 453,461 ****
--- 495,512 ----
  			}
  		}
  	}
+ #ifdef MAITOU_PATCH
+ 	if( is_transparent )
+ 	  vcopy = 1;
+ 	else
+ #endif
  	vertical_copy_area(screen, scrolltop+n, scrollheight, n);
  	if(refreshheight > 0)
+ #ifdef MAITOU_PATCH
+ 		MYClearArea (
+ #else
  		XClearArea (
+ #endif
  		    screen->display,
  		    TextWindow(screen),
  		    (int) screen->border + screen->scrollbar,
***************
*** 471,476 ****
--- 522,531 ----
  	else
  		ScrnDeleteLine(screen->buf, screen->bot_marg, screen->cur_row,
  		 n, screen->max_col + 1);
+ #ifdef MAITOU_PATCH
+ 	if( vcopy )
+ 	  ScrnRefresh(screen, scrolltop, 0, scrollheight, screen->max_col + 1, True);
+ #endif
  }
  
  /*
***************
*** 481,486 ****
--- 536,544 ----
      register int n;
  {
          register int cx, cy;
+ #ifdef MAITOU_PATCH
+ 	int hcopy = 0;
+ #endif
  
  	if(screen->cursor_state)
  		HideCursor();
***************
*** 504,509 ****
--- 562,572 ----
  		 */
  		if (non_blank_line (screen->buf, screen->cur_row, 
  				    screen->cur_col, screen->max_col + 1))
+ #ifdef MAITOU_PATCH
+ 		  if( is_transparent )
+ 		    hcopy = 1;
+ 		  else
+ #endif
  		    horizontal_copy_area(screen, screen->cur_col,
  					 screen->max_col+1 - (screen->cur_col+n),
  					 n);
***************
*** 511,517 ****
--- 574,584 ----
  		cx = CursorX (screen, screen->cur_col);
  		cy = CursorY (screen, screen->cur_row);
  
+ #ifdef MAITOU_PATCH
+ 		MYFillRectangle(
+ #else
  		XFillRectangle(
+ #endif
  		    screen->display,
  		    TextWindow(screen), 
  #ifdef STATUSLINE
***************
*** 526,531 ****
--- 593,604 ----
  	/* adjust screen->buf */
  	ScrnInsertChar(screen->buf, screen->cur_row, screen->cur_col, n,
  			screen->max_col + 1);
+ #ifdef MAITOU_PATCH
+ 	if( hcopy ){
+ 	  ScrnRefresh(screen, screen->cur_row, screen->cur_col, 1,
+ 		      screen->max_col+1 - screen->cur_col, True );
+ 	}
+ #endif
  }
  
  /*
***************
*** 536,541 ****
--- 609,617 ----
      register int	n;
  {
  	register int width;
+ #ifdef MAITOU_PATCH
+ 	int hcopy = 0;
+ #endif
  
  	if(screen->cursor_state)
  		HideCursor();
***************
*** 559,569 ****
--- 635,654 ----
  		if(screen->scroll_amt)
  			FlushScroll(screen);
  	
+ #ifdef MAITOU_PATCH
+ 		if( is_transparent )
+ 		  hcopy = 1;
+ 		else
+ #endif
  		horizontal_copy_area(screen, screen->cur_col+n,
  				     screen->max_col+1 - (screen->cur_col+n),
  				     -n);
  	
+ #ifdef MAITOU_PATCH
+ 		MYFillRectangle
+ #else
  		XFillRectangle
+ #endif
  		    (screen->display, TextWindow(screen),
  #ifdef STATUSLINE
  		     screen->instatus && screen->reversestatus ?
***************
*** 579,585 ****
  	/* adjust screen->buf */
  	ScrnDeleteChar (screen->buf, screen->cur_row, screen->cur_col, n,
  			screen->max_col + 1);
! 
  }
  
  /*
--- 664,675 ----
  	/* adjust screen->buf */
  	ScrnDeleteChar (screen->buf, screen->cur_row, screen->cur_col, n,
  			screen->max_col + 1);
! #ifdef MAITOU_PATCH
! 	if( hcopy ){
! 	  ScrnRefresh(screen, screen->cur_row, screen->cur_col, 1,
! 		      screen->max_col+1 - screen->cur_col, True );
! 	}
! #endif MAITOU_PATCH
  }
  
  /*
***************
*** 598,604 ****
--- 688,698 ----
  		if((height = screen->cur_row + top) > screen->max_row)
  			height = screen->max_row;
  		if((height -= top) > 0)
+ #ifdef MAITOU_PATCH
+ 			MYClearArea(screen->display, TextWindow(screen),
+ #else
  			XClearArea(screen->display, TextWindow(screen),
+ #endif
  			 screen->border + screen->scrollbar, top *
  			 FontHeight(screen) + screen->border,
  			 Width(screen), height * FontHeight(screen), FALSE);
***************
*** 622,628 ****
--- 716,726 ----
  		if(screen->scroll_amt)
  			FlushScroll(screen);
  		if(++top <= screen->max_row)
+ #ifdef MAITOU_PATCH
+ 			MYClearArea(screen->display, TextWindow(screen),
+ #else
  			XClearArea(screen->display, TextWindow(screen),
+ #endif
  			 screen->border + screen->scrollbar, top *
  			 FontHeight(screen) + screen->border,
  			 Width(screen), (screen->max_row - top + 1) *
***************
*** 652,658 ****
--- 750,760 ----
  	    if(!AddToRefresh(screen)) {
  	if(screen->scroll_amt)
  		FlushScroll(screen);
+ #ifdef MAITOU_PATCH
+ 		MYFillRectangle(screen->display, TextWindow(screen),
+ #else
  		XFillRectangle(screen->display, TextWindow(screen),
+ #endif
  #ifdef STATUSLINE
  		  screen->instatus && screen->reversestatus ?
  		  screen->normalGC :
***************
*** 707,713 ****
--- 809,819 ----
  	    if(!AddToRefresh(screen)) {
  		if(screen->scroll_amt)
  			FlushScroll(screen);
+ #ifdef MAITOU_PATCH
+ 		MYFillRectangle (screen->display, TextWindow(screen),
+ #else
  		XFillRectangle (screen->display, TextWindow(screen),
+ #endif
  #ifdef STATUSLINE
  		     screen->instatus && screen->reversestatus ?
  		     screen->normalGC :
***************
*** 758,764 ****
--- 864,874 ----
  	    if(!AddToRefresh(screen)) {
  		if(screen->scroll_amt)
  			FlushScroll(screen);
+ #ifdef MAITOU_PATCH
+ 		MYFillRectangle (screen->display, TextWindow(screen), 
+ #else
  		XFillRectangle (screen->display, TextWindow(screen), 
+ #endif
  #ifdef STATUSLINE
  		     screen->instatus && screen->reversestatus ?
  		     screen->normalGC :
***************
*** 793,801 ****
--- 903,919 ----
  #else /* !STATUSLINE */
  		if(top == 0)
  #endif /* !STATUSLINE */
+ #ifdef MAITOU_PATCH
+ 			MYClearWindow(screen->display, TextWindow(screen));
+ #else
  			XClearWindow(screen->display, TextWindow(screen));
+ #endif
  		else
+ #ifdef MAITOU_PATCH
+ 			MYClearArea(screen->display, TextWindow(screen),
+ #else
  			XClearArea(screen->display, TextWindow(screen),
+ #endif
  			 screen->border + screen->scrollbar, 
  			 top * FontHeight(screen) + screen->border,	
  		 	 Width(screen), (screen->max_row - top + 1) *
***************
*** 894,905 ****
--- 1012,1035 ----
      int nchars;
      int amount;			/* number of characters to move right */
  {
+ #ifdef MAITOU_PATCH
+   if( is_transparent ){
+     if( amount >= 0 ){
+       ScrnRefresh(screen, screen->cur_row, firstchar, 1, nchars + amount, True );
+     }else{
+       ScrnRefresh(screen, screen->cur_row, firstchar + amount, 1, nchars - amount, True );
+     }
+   }else{
+ #endif
      int src_x = CursorX(screen, firstchar);
      int src_y = CursorY(screen, screen->cur_row);
  
      copy_area(screen, src_x, src_y,
  	      (unsigned)nchars*FontWidth(screen), FontHeight(screen),
  	      src_x + amount*FontWidth(screen), src_y);
+ #ifdef MAITOU_PATCH
+   }
+ #endif
  }
  
  /*
***************
*** 913,924 ****
--- 1043,1069 ----
      int amount;			/* number of lines to move up (neg=down) */
  {
      if(nlines > 0) {
+ #ifdef MAITOU_PATCH
+       if( is_transparent ){
+ 	int amt = screen->scroll_amt;
+ 	screen->scroll_amt = 0;
+ 	if( amount >= 0 ){
+ 	  ScrnRefresh(screen, firstline - amount, 0, nlines, screen->max_col + 1, True );
+ 	}else{
+ 	  ScrnRefresh(screen, firstline - amount, 0, nlines, screen->max_col + 1, True );
+ 	}
+ 	screen->scroll_amt = amt;
+       }else{
+ #endif
  	int src_x = screen->border + screen->scrollbar;
  	int src_y = firstline * FontHeight(screen) + screen->border;
  
  	copy_area(screen, src_x, src_y,
  		  (unsigned)Width(screen), nlines*FontHeight(screen),
  		  src_x, src_y - amount*FontHeight(screen));
+ #ifdef MAITOU_PATCH
+       }
+ #endif
      }
  }
  
***************
*** 994,999 ****
--- 1139,1169 ----
  	register int toprow, leftcol, nrows, ncols;
  	extern Bool waiting_for_initial_map;
  
+ #ifdef MAITOU_PATCH
+ 	if( is_transparent ){
+ 	  Window tw = TextWindow(screen);
+ 	  int width = FullWidth(screen);
+ 	  int height = FullHeight(screen);
+ 
+ 	  MYClearArea(screen->display, tw,
+ 		    screen->scrollbar, 0,
+ 		    screen->border, height,
+ 		    False);
+ 	  MYClearArea(screen->display, tw,
+ 		    0, 0,
+ 		    width, screen->border,
+ 		    False);
+ 	  MYClearArea(screen->display, tw,
+ 		    width - screen->border, 0,
+ 		    screen->border, height,
+ 		    False);
+ 	  MYClearArea(screen->display, tw,
+ 		    0, height - screen->border,
+ 		    width, screen->border,
+ 		    False);
+ 	}
+ #endif
+ 
  	toprow = (rect_y - screen->border) / FontHeight(screen);
  	if(toprow < 0)
  		toprow = 0;
***************
*** 1119,1125 ****
--- 1289,1299 ----
  	    TekReverseVideo(screen);
  	}
  #endif /* !KTERM_NOTEK */
+ #ifdef MAITOU_PATCH
+ 	MYClearWindow(screen->display, TextWindow(screen));
+ #else
  	XClearWindow(screen->display, TextWindow(screen));
+ #endif
  #ifdef STATUSLINE
  	ScrnRefresh (screen, 0, 0, screen->max_row + 1 + !!screen->statusheight,
  				/* !!statusheight == (statusheight ? 1 : 0) */
***************
*** 1129,1135 ****
--- 1303,1313 ----
  	 screen->max_col + 1, False);
  #ifndef KTERM_NOTEK
  	if(screen->Tshow) {
+ #ifdef MAITOU_PATCH
+ 	    MYClearWindow(screen->display, tek);
+ #else
  	    XClearWindow(screen->display, tek);
+ #endif
  	    TekExpose((Widget)NULL, (XEvent *)NULL, (Region)NULL);
  	}
  #endif /* !KTERM_NOTEK */
***************
*** 1143,1148 ****
--- 1321,1366 ----
  }
  
  
+ #ifdef MAITOU_PATCH
+ AllRefresh (termw)
+ 	XtermWidget termw;
+ {
+ 	register TScreen *screen = &termw->screen;
+ #ifndef KTERM_NOTEK
+ 	Window tek = TWindow(screen);
+ #endif /* !KTERM_NOTEK */
+ 
+ #ifdef MAITOU_PATCH
+ 	MYClearWindow(screen->display, TextWindow(screen));
+ #else
+ 	XClearWindow(screen->display, TextWindow(screen));
+ #endif
+ #ifdef STATUSLINE
+ 	ScrnRefresh (screen, 0, 0, screen->max_row + 1 + !!screen->statusheight,
+ 				/* !!statusheight == (statusheight ? 1 : 0) */
+ #else /* !STATUSLINE */
+ 	ScrnRefresh (screen, 0, 0, screen->max_row + 1,
+ #endif /* !STATUSLINE */
+ 	 screen->max_col + 1, False);
+ #ifndef KTERM_NOTEK
+ 	if(screen->Tshow) {
+ #ifdef MAITOU_PATCH
+ 	    MYClearWindow(screen->display, tek);
+ #else
+ 	    XClearWindow(screen->display, tek);
+ #endif
+ 	    TekExpose((Widget)NULL, (XEvent *)NULL, (Region)NULL);
+ 	}
+ #endif /* !KTERM_NOTEK */
+ #ifdef KTERM_XIM
+ 	IMSendColor(screen);
+ #endif /* KTERM_XIM */
+ #ifdef KTERM_KINPUT2
+ 	Kinput2SendColor();
+ #endif /* KTERM_KINPUT2 */
+ }
+ #endif /* MAITOU_PATCH */
+ 
  recolor_cursor (cursor, fg, bg)
      Cursor cursor;			/* X cursor ID to set */
      unsigned long fg, bg;		/* pixel indexes to look up */
***************
*** 1180,1186 ****
--- 1398,1408 ----
  		    if(!AddToRefresh(screen)) {
  			if(screen->scroll_amt)
  				FlushScroll(screen);
+ #ifdef MAITOU_PATCH
+ 			MYFillRectangle(screen->display, TextWindow(screen),
+ #else
  			XFillRectangle(screen->display, TextWindow(screen),
+ #endif
  #ifdef STATUSLINE
  				screen->instatus && screen->reversestatus ?
  				screen->normalGC :

