[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[mgp-users-jp 01381] Re: 1.11aのリリース



From: Kenichi Handa <handa@m17n.org>
Subject: Re: [mgp-users-jp 01379] Re: 1.11aのリリース
Date: Wed, 1 Sep 2004 21:30:19 +0900 (JST)
Message-ID: <200409011230.VAA08320@etlken.m17n.org>

 > In article <>, nishida@csl.sony.co.jp writes:
 > > なるほど。こんな感じにしてみました。
 > 
 > えっと、これは基本的に window を作ってそれを移動させるという
 > 点は何も変っていなくって、単に「%grad で横や斜め方向に色を変
 > えていると背景の処理が変になる」というのを fix したというも
 > のですよね。
 > 
 > 僕の提案は subwindow は作らずに、直接 state->target に draw 
 > して、XFlush&usleep 後に予め XGetImage していたimage のうち 
 > draw されたエリアに対応する部分のみ XPutImage で元に戻すとい
 > うものです。

ああ、なるほど。XMoveWindowすることを前提にコードを考えてしまっていました。
ということで書き直してみました。
--
西田佳史
Yoshifumi Nishida
nishida@csl.sony.co.jp

*** draw.c.orig	2004-09-02 00:28:25.000000000 +0900
--- draw.c	2004-09-02 00:21:29.000000000 +0900
***************
*** 26,32 ****
   * SUCH DAMAGE.
   */
  /*
!  * $Id: draw.c,v 1.221 2004/08/19 16:28:57 nishida Exp $
   */
  
  #include "mgp.h"
--- 26,32 ----
   * SUCH DAMAGE.
   */
  /*
!  * $Id: draw.c,v 1.222 2004/09/01 03:50:32 nishida Exp $
   */
  
  #include "mgp.h"
***************
*** 1048,1062 ****
  	int dir;
  {
  	u_int step, x, xoff, yoff;
! 	int i;
! 	int sx;
! 	int round;
! 	Window cutinWin;
! 
! #ifdef USE_M17N
! 	// we cannot use cutin with m17n-lib so far.
! 	return;
! #endif
  
  	if (state->repaint)
  		return;
--- 1048,1058 ----
  	int dir;
  {
  	u_int step, x, xoff, yoff;
! 	int i, sx, round;
! 	int root_x, root_y, use_copy;
! 	Window cutinWin, junkwin;
! 	XImage *copywin; 
! 	static XWindowAttributes xa;
  
  	if (state->repaint)
  		return;
***************
*** 1064,1069 ****
--- 1060,1073 ----
  	if (!state->linewidth)
  		return;
  
+ 	if (!xa.width) 
+ 		XGetWindowAttributes(display, DefaultRootWindow(display), &xa);
+ 	XTranslateCoordinates(display, window, DefaultRootWindow(display), 
+ 		0, 0, &root_x ,&root_y, &junkwin);
+ 	use_copy = 1;
+ 	if ((root_x + window_width > xa.width) || (root_y + window_height > xa.height) ||
+ 			(root_x < 0 || root_y < 0)) use_copy = 1;
+ 
  	sx = (0 < dir) ? 0 : state->width - state->linewidth;
  	round = 20;	/*XXX*/
  #ifndef abs
***************
*** 1076,1104 ****
  
  	step = (lx - sx) / round;
  
! 	cutinWin = XCreateSimpleWindow(display, state->target,
! 		sx, ly, state->linewidth, state->maxascent + state->maxdescent,
! 		0, fore_color[caching], back_color[caching]);
! 	XSetWindowBackgroundPixmap(display, cutinWin, None);
! 	XMapSubwindows(display, state->target);
  
  	xoff = state->xoff;	
  	yoff = state->yoff;	
  	state->xoff = state->yoff = 0;
  	if (state->obj) {
! 		obj_draw(state, cutinWin, 0, 0);
  	}
  	XFlush(display);
  
  	x = sx;
  	for (i = 0; i < round; i++) {
! 		XMoveWindow(display, cutinWin, x + xoff, ly + yoff);
  		XFlush(display);
  		usleep(CUTIN_DELAY);
  		x += step;
  	}
  
! 	XDestroyWindow(display, cutinWin);
  	state->xoff = xoff;	
  	state->yoff = yoff;	
  }
--- 1080,1124 ----
  
  	step = (lx - sx) / round;
  
! 	if (!use_copy){
! 		cutinWin = XCreateSimpleWindow(display, state->target,
! 			sx, ly, state->linewidth, state->maxascent + state->maxdescent,
! 			0, fore_color[caching], back_color[caching]);
! 		XSetWindowBackgroundPixmap(display, cutinWin, None);
! 		XMapSubwindows(display, state->target);
! 	} else {
! 		copywin = XGetImage(display, window, state->xoff, ly + state->yoff, state->linewidth + abs(lx - sx),	
! 					state->maxascent + state->maxdescent, AllPlanes, ZPixmap);
! 	}
  
  	xoff = state->xoff;	
  	yoff = state->yoff;	
  	state->xoff = state->yoff = 0;
  	if (state->obj) {
! 		if (use_copy)
! 			obj_draw(state, state->target, x + xoff, ly + yoff);
! 		else
! 			obj_draw(state, cutinWin, 0, 0);
  	}
  	XFlush(display);
  
  	x = sx;
  	for (i = 0; i < round; i++) {
! 		if (use_copy && state->obj) 
! 				obj_draw(state, state->target, x + xoff, ly + yoff);
! 		else 
! 				XMoveWindow(display, cutinWin, x + xoff, ly + yoff);
  		XFlush(display);
  		usleep(CUTIN_DELAY);
+ 		if (use_copy && state->obj) {
+ 			XPutImage(display, state->target, gc_cache, copywin, 
+ 				x, 0, x + xoff, ly + yoff, 
+ 				state->linewidth, state->maxascent + state->maxdescent);
+ 		}
  		x += step;
  	}
  
! 	if (!use_copy) XDestroyWindow(display, cutinWin);
  	state->xoff = xoff;	
  	state->yoff = yoff;	
  }
***************
*** 4633,4640 ****
  	static char etab[3][20] = { "iso-2022-jp", "gb2312", "ksc5601"};
  	static char rtab[3][20] = { "jisx208", "gb2312", "ksc5601"};
  	static char prefix[3][20] = { "\033$B", "\033$A", "\033$(C"};
! 	char buf16[1024];
! 	const char *p16;
  	char out16[1024], *o16;
  	int ileft, oleft;
  #ifdef HAVE_ICONV
--- 4653,4659 ----
  	static char etab[3][20] = { "iso-2022-jp", "gb2312", "ksc5601"};
  	static char rtab[3][20] = { "jisx208", "gb2312", "ksc5601"};
  	static char prefix[3][20] = { "\033$B", "\033$A", "\033$(C"};
! 	char buf16[1024], *p16;
  	char out16[1024], *o16;
  	int ileft, oleft;
  #ifdef HAVE_ICONV