LECTURE 12 XIM ¤Ë¤è¤ëÆüËܸìÆþÎÏ

¡û ¤Ï¤¸¤á¤Ë

LECTURE 5 ¤ÇÀâÌÀ¤·¤¿Ê¸»úÎóÉÁ²è¤È LECTURE 10 ¤ÇÀâÌÀ¤·¤¿¥­¡¼¥Ü¡¼¥É¥¤¥Ù¥ó¥È¤ò»È¤¨¤Ð¡¢±Ñ¿ô»ú¤Î¤è¤¦¤Ê¥·¥ó¥°¥ë¥Ð¥¤¥Èʸ»ú¤ò¥­¡¼¥Ü¡¼¥É¤«¤éÆþÎϤ·¤Æɽ¼¨¤¹¤ë¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤òºîÀ®¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹( ¥Æ¥­¥¹¥È¥Õ¥£¡¼¥ë¥É¡¢etc. )¡£¤·¤«¤·¡¢¤³¤ì¤À¤±¤Ç¤ÏÆüËܸìʸ»úÎó¤òÆþÎϤ¹¤ë¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡£ÆüËܸì¤Î¤è¤¦¤Ê¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤òÆþÎϤȤ·¤Æ¼õ¤±¼è¤ë¤Ë¤Ï¡¢Ê̤ÎÊýË¡¤ò»È¤ï¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£

¤³¤³¤Ç¤Ï XIM ( X Input Method protocol ) ¤òÍѤ¤¤ÆÆüËܸìʸ»úÎó(¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó)¤òÆþÎϤ¹¤ëÊýË¡¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Æ¤¤¤­¤Þ¤¹¡£

¡û ÆüËܸìÆþÎϥ᥽¥Ã¥É/¥¢¥×¥ê¥±¡¼¥·¥ç¥ó/¥æ¡¼¥¶´Ö¤Î¤ä¤ê¤È¤ê

Ä̾ï Linux® ( Unix ) ¤ÇÆüËܸì¤òÆþÎϤ¹¤ë¾ì¹ç¤Ï¡¢¤Þ¤º kinput2 ¤Ê¤É¤Î´Á»úÊÑ´¹ÆþÎÏ¥×¥í¥°¥é¥à ( IM ) ¤òµ¯Æ°¤·¡¢¥­¡¼¥Ü¡¼¥É¤«¤é´Á»úÊÑ´¹Á°¤ÎÆüËܸìʸ»úÎó¤òÆþÎÏ¡¢ÊÑ´¹¤ò¹Ô¤¤ºÇ½ªÅª¤ËÆþÎÏʸ»úÎó¤ò³ÎÄꤹ¤ë¤È¤¤¤¦¼ê½ç¤È¤Ê¤ê¤Þ¤¹¡£¤³¤Î»þ¤Î IM ¤È¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¤ä¤ê¤È¤ê¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£

  1. ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¥­¡¼ÆþÎϤò IM ¤ËÅϤ¹
  2. ÆþÎϥ᥽¥Ã¥É¤Ï¼õ¤±¼è¤Ã¤¿¥­¡¼ÆþÎϤò¼õ¤±¼è¤ê¡¢Á°ÊÔ½¸Ê¸»úÎó¤òɽ¼¨¤¹¤ë
  3. ÊÑ´¹»Ø¼¨¤ò¼õ¤±¼è¤ë¤È¡¢IM ¤Ï´Á»úÊÑ´¹¥µ¡¼¥Ð(Ä̾ï¤ÏÊÌ¥×¥í¥»¥¹)¤È¤ä¤ê¤È¤ê¤·¡¢ ÊÑ´¹Ãæ¤Îɽ¼¨Ê¸»úÎó¤ò¼õ¤±¼è¤Ã¤Æɽ¼¨¤¹¤ë
  4. ÆþÎÏʸ»úÎ󤬳ÎÄꤵ¤ì¤ë¤È¡¢IM ¤Ï³ÎÄêʸ»úÎó¤ò¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ËÅϤ·¥¢¥×¥ê ¥±¡¼¥·¥ç¥ó¤¬¤³¤ì¤òɽ¼¨¤¹¤ë

¤Ä¤Þ¤ê¡¢ÆüËܸìÆþÎϤò¹Ô¤¦¤¿¤á¤Ë¤Ï IM ¤È¤Î¤ä¤ê¤È¤ê¤ò¼ÂÁõ¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤Î¤Ç¤¹¡£

IM ¤È¤Î¤ä¤ê¤È¤ê¤Ë¤Ï¡¢Kinput2 ¥×¥í¥È¥³¥ë¤Î¤è¤¦¤Ë IM Æȼ«¤Î¥×¥í¥È¥³¥ë¤â¸ºß¤·¤Þ¤¹¤¬¡¢¤³¤³¤Ç¤Ï X ¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¤Î¥ê¥ê¡¼¥¹ 5 ¤«¤é ÍÑ°Õ¤µ¤ì¤¿ XIM ( X Input Method protocol ) ¤È¤¤¤¦¹ñºÝ²½¥Æ¥­¥¹¥ÈÆþÎϤΤ¿¤á¤Î¥×¥í¥È¥³¥ë¤Ë½¾¤¤¤Þ¤¹¡£

IM ¤È¥æ¡¼¥¶¤È¤Î¤ä¤ê¤È¤ê¤Ë´Ø¤·¤Æ¤Ï¡¢¼¡¤Î¥¹¥¯¥ê¡¼¥óÎΰ褪¤è¤ÓÂÐÏ÷Á¼°¤¬ XIM »ÅÍͤȤ·¤ÆÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£

¥¹¥¯¥ê¡¼¥óÎΰè
Îΰè̾ ÀâÌÀ
¾õÂÖɽ¼¨Îΰè ÆþÎϥ᥽¥Ã¥É¤ÎÆâÉô¾õÂÖ¤òɽ¼¨¤¹¤ë¤¿¤á¤Î½ÐÎÏÎΰè
Á°ÊÔ½¸Îΰè ÊÑ´¹³ÎÄêÁ°¤ÎÆþÎÏʸ»úÎó¤òɽ¼¨¤¹¤ë¤¿¤á¤ÎÎΰè
Êä½õÎΰè ÆþÎϥ᥽¥Ã¥É¤¬É¬ÍפȤ¹¤ë°ì»þ¥¦¥£¥ó¥É¥¦

ÂÐÏ÷Á¼°
·Á¼°Ì¾ ÀâÌÀ
¥ë¡¼¥È¥¦¥£¥ó¥É¥¦·¿ ÆþÎϥ᥽¥Ã¥É¤Ï¥Ç¡¼¥¿¤ò¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤È¤ÏÊ̸ĤΥ¦¥£¥ó¥É¥¦ (¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤Î»Ò¥¦¥£¥ó¥É¥¦)¤Ëɽ¼¨¤¹¤ë
off-the-spot ·¿ Á°ÊÔ½¸Ãæ¤Î¥Ç¡¼¥¿¤ò¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥¦¥£¥ó¥É¥¦¤Î¤¢¤ëÎΰè¤Ëɽ¼¨¤¹¤ë¡£ Îΰè¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ÎÊý¤Ç»ØÄꤹ¤ë
over-the-spot ·¿ Á°ÊÔ½¸Ãæ¤Î¥Ç¡¼¥¿¤ò¡¢¸½ºß¤ÎÁÞÆþÅÀ¤Ë½Å¤Í¤ÆÃÖ¤«¤ì¤¿ÆÈΩ¥¦¥£¥ó¥É¥¦¤Ëɽ¼¨¤¹¤ë
on-the-spot ·¿ ÆþÎϥ᥽¥Ã¥É¤Ï¡¢Á°ÊÔ½¸Ãæ¤Î¥Ç¡¼¥¿¤òɽ¼¨¤¹¤ë¤è¤¦¤Ë¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ë»Ø¼¨¤¹¤ë (¤³¤Î¾ì¹ç¡¢Á°ÊÔ½¸¥Ç¡¼¥¿¤òɽ¼¨¤¹¤ë¤Î¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤È¤Ê¤ë)

¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¦¤Ï¾å¤ÎÂÐÏ÷Á¼°¤ÎÃ椫¤é°ì¤Ä¤òÁª¤Ó¡¢¤½¤ì¤ËɬÍפÊÁ°ÊÔ½¸Îΰ褪¤è¤Ó¾õÂÖɽ¼¨Îΰè¤òÍÑ°Õ¤·¤Ê¤±¤ì¤Ð¤¤¤±¤Þ¤»¤ó¡£on-the-spot ·¿ ¤Ë¤Ä¤¤¤Æ¤Ï¤µ¤é¤ËÆþÎϥ᥽¥Ã¥É¤¬¸Æ¤Ó½Ð¤¹¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô¤òÍÑ°Õ¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£

ËÜ¥Ú¡¼¥¸¤Ç¤Ï¡¢¥ë¡¼¥È¥¦¥£¥ó¥É¥¦·¿¤ª¤è¤Ó off-the-spot ·¿¤Ë¤Ä¤¤¤Æ¼è¤êµó¤²¤Þ¤¹¡£over-the-spot ·¿¤ª¤è¤Ó on-the-spot ·¿¤Ë´Ø¤·¤Æ¤Ï¤ß¤Ê¤µ¤ó¤ÎÊý¤ÇÊÙ¶¯¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤(ñ¤ËËͤÎÊÙ¶¯ÉÔ­¤Ç¤¹¡£¤¹¤ß¤Þ¤»¤óm(__)m )¡£

¡û ¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à ( ¥ë¡¼¥È¥¦¥£¥ó¥É¥¦·¿ )

¥ë¡¼¥È¥¦¥£¥ó¥É¥¦·¿¤È¤¤¤¦ÂÐÏ÷Á¼°¤ÇÆüËܸìʸ»úÎó¤òÆþÎÏ¡¢¥¦¥£¥ó¥É¥¦¤Ëɽ¼¨¤¹¤ë¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à xim_root.c ¤Ç¤¹¡£¤Ï¤¸¤á¤Ë ¤Î¥Ú¡¼¥¸¤«¤é¡¢Á´¤Æ¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ò¸Ç¤á¤¿ tar ¥Ü¡¼¥ë¤ò¥À¥¦¥ó¥í¡¼¥É¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£

¼Â¹Ô¤·¤Æ²¾Ì¾´Á»úÊÑ´¹ÍѤΠIM ¤òµ¯Æ°¤¹¤ë¤È¡¢²¼¤ÎÍͤ˲¾Ì¾´Á»úÊÑ´¹ÆþÎÏÍѤΥ¦¥£¥ó¥É¥¦¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£¤³¤Î¥¦¥£¥ó¥É¥¦¤Ï¡¢¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤Î»Ò¥¦¥£¥ó¥É¥¦¤È¤Ê¤ê¤Þ¤¹¡£¤³¤Î¥¦¥£¥ó¥É¥¦¤Çʸ»úÎó¤òÆþÎÏ¡¢ÊÑ´¹¤ò³ÎÄꤹ¤ë¤È¤½¤Î³ÎÄêʸ»úÎ󤬾å¤Î¥¦¥£¥ó¥É¥¦¤Ëɽ¼¨¤µ¤ì¤Þ¤¹¡£

012xim_root_window.jpg
012xim_root_im.jpg

--- xim_root.c ---

    1	/*
    2	 * ¥ë¡¼¥È¥¦¥£¥ó¥É¥¦·¿(ÊÌ¥¦¥£¥ó¥É¥¦¤Ë²¾Ì¾´Á»úÊÑ´¹Ê¸»úÎó
    3	 * ¤òɽ¼¨¤¹¤ë¥¿¥¤¥×)¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à 
    4	 */
    5	
    6	#include <X11/Xlib.h>
    7	#include <X11/Xlocale.h>
    8	#include <X11/Xutil.h>
    9	#include <X11/keysym.h>
   10	#include <stdio.h>
   11	
   12	
   13	#define BORDER  2    /* ¥Ü¡¼¥À¤ÎÉý */
   14	#define COL     30   /* 30Îó */
   15	#define ROW     20   /* 20¹Ô */
   16	
   17	static Display*          dpy;          /* ¥Ç¥£¥¹¥×¥ì¥¤ */
   18	static int               screen;       /* ¥¹¥¯¥ê¡¼¥ó */
   19	static Window            root;         /* ¥ë¡¼¥È¥¦¥£¥ó¥É¥¦ */
   20	static Window            win;          /* ɽ¼¨¤¹¤ë¥¦¥£¥ó¥É¥¦ */
   21	static int               win_w, win_h; /* ¥¦¥£¥ó¥É¥¦¤ÎÉý¤È¹â¤µ */
   22	static unsigned long     black, white; /* ¹õ¡¢Çò¤Î¥Ô¥¯¥»¥ëÃÍ */
   23	static GC                gc;           /* ¥°¥é¥Õ¥£¥Ã¥¯¥¹¥³¥ó¥Æ¥­¥¹¥È */
   24	static XFontSet          fs;           /* ¥Õ¥©¥ó¥È¥»¥Ã¥È */
   25	static int               font_w;       /* ʸ»úÉý */
   26	static int               font_h;       /* ʸ»ú¹â */
   27	static int               ascent;       /* ʸ»ú¤Î¥¢¥»¥ó¥È */
   28	static int               descent;      /* ʸ»ú¤Î¥Ç¥£¥»¥ó¥È */
   29	static XIM               im;           /* ¥¤¥ó¥×¥Ã¥È¥á¥½¥Ã¥É */
   30	static XIC               ic;           /* ¥¤¥ó¥×¥Ã¥È¥³¥ó¥Æ¥­¥¹¥È */
   31	static Atom              protocol;     /* ¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ãÍÑÊÑ¿ô */
   32	
   33	
   34	static int  xim_setlocale();
   35	static void xim_init();
   36	static void xim_create_fontset();
   37	static void xim_create_window();
   38	static int  xim_init_inputmethod();
   39	static void xim_event_loop();
   40	static void xim_draw( XEvent* event );
   41	static void xim_close();
   42	
   43	
   44	int 
   45	main( void )
   46	{
   47		/* ¥¤¥ó¥×¥Ã¥È¥á¥½¥Ã¥É¤¬É¬ÍפȤ¹¤ë¥¤¥Ù¥ó¥È */
   48		unsigned long fevent;
   49	
   50		if ( xim_setlocale() == -1 ) {
   51			return 1;
   52		}
   53	
   54		xim_init();
   55		xim_create_fontset();
   56		xim_create_window();
   57	
   58		/* ¥¤¥ó¥×¥Ã¥È¥á¥½¥Ã¥É¤Î½é´ü²½ */
   59		if ( xim_init_inputmethod() == -1 ) {
   60			return 1;
   61		}
   62	
   63		/* ¥¦¥£¥ó¥É¥¦Ç˲õ¥¤¥Ù¥ó¥È¤ò¼õ¤±¼è¤ë */
   64		protocol = XInternAtom( dpy, "WM_DELETE_WINDOW", True );
   65		XSetWMProtocols( dpy, win, &protocol, 1 );
   66	
   67		/* ¥¤¥ó¥×¥Ã¥È¥á¥½¥Ã¥É¤¬É¬ÍפȤ¹¤ë¥¤¥Ù¥ó¥È¤òÌ䤤¹ç¤ï¤»¤ë */
   68		XGetICValues( ic, XNFilterEvents, &fevent, NULL );
   69	
   70		XSelectInput( dpy, win, 
   71		      ExposureMask | KeyPressMask | FocusChangeMask | fevent );
   72		XMapWindow( dpy, win );
   73	
   74		xim_event_loop();
   75		xim_close();
   76	
   77		return 0;
   78	}
   79	
   80	
   81	static int 
   82	xim_setlocale( void )
   83	{
   84		if ( setlocale( LC_CTYPE, "" ) == NULL ) {
   85			printf( "Can't set locale.\n" );
   86			return -1;
   87		}
   88	
   89		if ( ! XSupportsLocale() ) {
   90			printf( "Current locale is not supported\n" );
   91			return -1;
   92		}
   93	
   94		/* ¥æ¡¼¥¶»ØÄê¤Î¥â¥Ç¥£¥Õ¥¡¥¤¥¢¤òÏ¢·ë¤¹¤ë */
   95		if ( XSetLocaleModifiers( "" ) == NULL ) {
   96			printf( "Can't set locale modifiers\n" );
   97			return -1;
   98		}
   99	
  100		return 0;
  101	}
  102	
  103	
  104	static void 
  105	xim_init( void )
  106	{
  107		dpy = XOpenDisplay( "" );
  108	
  109		root   = DefaultRootWindow( dpy );
  110		screen = DefaultScreen( dpy );
  111		white  = WhitePixel( dpy, screen );
  112		black  = BlackPixel( dpy, screen );
  113	}
  114	
  115	
  116	static void 
  117	xim_create_fontset( void )
  118	{
  119		XFontSetExtents*  fs_extents;
  120		int    missing_count;
  121		char** missing_list;
  122		char*  def_string;
  123	
  124		
  125		fs = XCreateFontSet( dpy, "-*-fixed-medium-r-normal--14-*-*-*", 
  126			     &missing_list, &missing_count, &def_string );
  127	
  128		XFreeStringList( missing_list );   
  129	
  130		/* ¥Õ¥©¥ó¥È¾ðÊó¤Î¼èÆÀ */
  131		fs_extents = XExtentsOfFontSet(fs);
  132	
  133		font_w     = fs_extents->max_logical_extent.width;
  134		font_h     = fs_extents->max_logical_extent.height;
  135		ascent     = - fs_extents->max_logical_extent.y;
  136		descent    = fs_extents->max_logical_extent.height - ascent;
  137	
  138		/* ¥¦¥£¥ó¥É¥¦Éý¤È¹â¤µ¤òÀßÄê */
  139		win_w = font_w * COL;
  140		win_h = font_h * ROW;
  141	}
  142	
  143	
  144	static void 
  145	xim_create_window( void )
  146	{
  147		win = XCreateSimpleWindow( dpy, root,
  148			   0, 0, win_w, win_h, BORDER, black, white );
  149	
  150		gc = XCreateGC( dpy, win, 0, NULL );
  151		XSetBackground( dpy, gc, white );
  152		XSetForeground( dpy, gc, black );
  153	}
  154	
  155	
  156	static int 
  157	xim_init_inputmethod( void )
  158	{
  159		/* ¥¤¥ó¥×¥Ã¥È¥á¥½¥Ã¥É¤ò¥ª¡¼¥×¥ó¤¹¤ë */
  160		if ( ( im = XOpenIM( dpy, NULL, NULL, NULL ) ) == NULL ) {
  161			printf( "Couldn't open input method.\n" );
  162			return -1;
  163		}
  164	
  165	
  166		/* ¥¤¥ó¥×¥Ã¥È¥³¥ó¥Æ¥­¥¹¥È¤ÎºîÀ® */
  167		ic = XCreateIC( im,
  168				XNInputStyle, 
  169				XIMPreeditNothing | XIMStatusNothing,
  170				XNClientWindow, 
  171				win,
  172				NULL );
  173	
  174		if ( ic == NULL ) {
  175			printf( "Couldn't create input context.\n" );
  176			XCloseIM( im );
  177			return -1;
  178		}
  179	
  180		return 0;
  181	}
  182	
  183	
  184	static void 
  185	xim_event_loop( void )
  186	{
  187		XEvent event;
  188	
  189		while( 1 ) {
  190			XNextEvent( dpy, &event );
  191	
  192			/* ¥¤¥ó¥×¥Ã¥È¥á¥½¥Ã¥É¤Ë¥¤¥Ù¥ó¥È¤òÅϤ¹ */
  193			if( XFilterEvent( &event, ( Window )NULL ) == True ) {
  194				/* ¥¤¥Ù¥ó¥È¤Ï¥Õ¥£¥ë¥¿¥ê¥ó¥°¤µ¤ì¤¿ */
  195				continue;
  196			}
  197	
  198			switch( event.type ) {
  199				/* 
  200				 * Expose ¥¤¥Ù¥ó¥È¤òÍÑ°Õ¤·¤Æ¤¤¤Ê¤¤¤Î¤Ç¡¢¥¦¥£¥ó¥É¥¦¤¬
  201				 * ±£¤ì¤¿¾ì¹ç¤Ê¤É¤Ë¤ÏÉÁ²èÆâÍƤϼº¤ï¤ì¤ë¡£
  202				 */
  203				case KeyPress :
  204					xim_draw( &event );
  205					break;
  206	
  207				case FocusIn :
  208					XSetICFocus( ic );
  209					break;
  210	
  211				case FocusOut :
  212					XUnsetICFocus( ic );
  213					break;
  214	
  215				case ClientMessage:
  216					if ( event.xclient.data.l[0] == protocol ) {
  217						return;
  218					}
  219		      
  220					break;
  221			}
  222		}
  223	}
  224	
  225	
  226	static void
  227	xim_draw( XEvent* event )
  228	{
  229		Status status;
  230		KeySym keysym;
  231		int cnt = 0;
  232	
  233		/* COL Îó¤Î 2 ¥Ð¥¤¥Èʸ»úʬ¤ÎÎΰè¤ò 1 ¹Ô¤ÎºÇÂçʸ»ú¿ô¤È¤¹¤ë */
  234		char buffer[ COL * 2 ];
  235	
  236		static int row = 0;
  237		static int col = 0;
  238	
  239	
  240		/* ÆþÎÏʸ»úÎó¤Î¼èÆÀ */
  241		cnt = XmbLookupString( ic, ( XKeyPressedEvent* )event,
  242				       buffer, sizeof( buffer ), &keysym, &status );
  243	
  244		/* 
  245		 * ¤³¤Î²þ¹Ô½èÍý¤ò²¼¤Î if ʸ¤è¤êÀè¤Ë¹Ô¤ï¤Ê¤¤¤È¡¢¤½¤Á¤é¤Ë¥¤¥Ù¥ó¥È¤ò
  246		 * ½¦¤ï¤ì¤Æ²þ¹Ô½èÍý¤¬¹Ô¤ï¤ì¤Ê¤¤¤Î¤ÇÃí°Õ 
  247		 */
  248		if ( status == XLookupBoth && keysym == XK_Return ) {
  249			/* ºÇ²¼ÃʤËÅþ㤷¤¿¤é¡¢ÀèƬ¹Ô¤ËÌá¤ë */
  250			if ( ++ row >= ROW ) {
  251				row = 0; 
  252			}
  253			col = 0;
  254			
  255			/* ¿·¤·¤¤¹Ô¤ò¥¯¥ê¥¢¤¹¤ë */
  256			XClearArea( dpy, win, 0, font_h * row, win_w, font_h, False );
  257		}
  258		else if ( status == XLookupChars || status == XLookupBoth ) {
  259			/* 
  260			 * ÆþÎÏʸ»ú(ʸ»úÎó)¤ÎÉÁ²è 
  261			 *
  262			 * ÉÁ²è¸¶ÅÀ¤Î x ºÂɸ¤ò·è¤á¤ëºÝ¤Ë¡¢font_w / 2 ¤È¤¤¤¦·×»»¤ò
  263			 * ¤·¤Æ¤¤¤ë¤¬¡¢¤³¤ì¤Ï 1 ¥Ð¥¤¥Èʸ»ú¤ÎÉý¤ËÁêÅö¤¹¤ë¡£ÆüËܸì
  264			 * ʸ»ú(ʸ»úÎó)¤¬ÆþÎϤµ¤ì¤¿¾ì¹ç¤Ë¤Ï 2 ¥Ð¥¤¥È¤º¤Ä char ¤Î
  265			 * Ãͤò¼õ¤±¼è¤ë¤Î¤Ç¡¢¸½ºß¤Î col ¤Ë font_w / 2 ¤ò¤«¤±¤ì¤Ð
  266			 * ¼¡¤ËÉÁ²è¤¹¤Ù¤­ÉÁ²è¸¶ÅÀ¤Î x ºÂɸ¤ò·èÄê¤Ç¤­¤ë¡£
  267			 */
  268			XmbDrawString( dpy, win, fs, gc,
  269				       ( font_w / 2 ) * col, font_h * row + ascent,
  270				       buffer, cnt );
  271	
  272			col += cnt;
  273		}
  274	
  275		/* 
  276		 * status ¤¬ XBufferOverflow ¤Î¾ì¹ç¤Ï¡¢ÍÑ°Õ¤·¤¿¥Ð¥Ã¥Õ¥¡¤Ëʸ»úÎó
  277		 * ¤ò³ÊǼ¤·¤­¤ì¤Ê¤«¤Ã¤¿¤È¤¤¤¦¤³¤È¤Ê¤Î¤Ç¡¢¤³¤Î¾ì¹ç¤Ï½¼Ê¬¤Ê¥Ð¥Ã¥Õ¥¡
  278		 * ¤òÍÑ°Õ¤·¤¿¾å¤ÇºÆÅÙ XmbLookupString() ¤ò¼Â¹Ô¤¹¤ëɬÍפ¬¤¢¤ë¡£
  279		 */
  280	}
  281	
  282	
  283	static void 
  284	xim_close( void )
  285	{
  286		printf( "Exit application.\n" );
  287	
  288		XDestroyIC( ic );
  289		XCloseIM( im );
  290		XFreeGC( dpy, gc );
  291		XDestroyWindow( dpy, win );
  292		XCloseDisplay( dpy );
  293	}
  294	
  295	
  296	/* End of xim_root.c */

¡û ¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à (¥ë¡¼¥È¥¦¥£¥ó¥É¥¦·¿) ¤ÎÀâÌÀ

¤½¤ì¤Ç¤Ï¡¢¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Æ¤¤¤­¤Þ¤¹¡£

  • 13 ¡Á 15 ¹ÔÌÜ

    ¤³¤³¤Ç¤Ï¥¦¥£¥ó¥É¥¦¥µ¥¤¥º¤òÄêµÁ¤¹¤ë¤Î¤Ç¤Ï¤Ê¤¯¡¢20 ¹Ô¡¢30 Îó¤Îʸ»úÎó¤òɽ¼¨¤Ç¤­¤ëÎΰè¤È¤· ¤Æ¥¦¥£¥ó¥É¥¦¤ÎÂ礭¤µ¤òÄêµÁ¤·¤Æ¤¤¤Þ¤¹¡£¤Ê¤ª¤³¤Î¿ôÃͤÏÁ´³Ñʸ»ú¤Îɽ¼¨¿ô¤òɽ¤·¤Æ¤¤¤Þ¤¹¡£

  • 17 ¡Á 31 ¹ÔÌÜ

    xctrl.c ¤ÈƱÍͤ˽èÍý¤ò´Ø¿ôñ°Ì¤ÇÀÚ¤êʬ¤±¤Æ¤¤¤ë¤¿¤á¡¢´Ø¿ô´Ö¤Ç¶¦Í­¤¹¤ëÊÑ¿ô¤ò static ÊÑ¿ô ¤È¤·¤ÆÀë¸À¤·¤Æ¤¤¤Þ¤¹¡£25¡¢26 ¹Ô¤Î font_w¡¢font_h ¤Ï¤½¤ì¤¾¤ìʸ»úÉý¡¢Ê¸»ú¹â¤µ¤ò³ÊǼ¤¹¤ëÊÑ¿ô ¤Ç¤¹¡£

    ʸ»ú¤òÉÁ²è¤¹¤ëºÝ¤Ë»ØÄꤹ¤ë°ÌÃÖºÂɸ¤Ï¡¢Ê¸»ú¤ËÀßÄꤵ¤ì¤Æ¤¤¤ëÉÁ²è¸¶ÅÀ¤Ç¤¹¡£¤È¤³¤í¤Ç¤³¤ÎÉÁ ²è¸¶ÅÀ¤Ï¡¢font_w ¤ª¤è¤Ó font_h ¤Çɽ¤µ¤ì¤ëĹÊý·Á¤ÎĺÅÀ¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó (¤½¤¦¤¤¤¦¾ì¹ç¤â¤¢¤ë¤« ¤â¤·¤ì¤Þ¤»¤ó¤¬)¡£ascent ¤ª¤è¤Ó descent ¤Ï¤½¤ì¤¾¤ì¡¢Ê¸»ú¹â¤µ¤Î¤¦¤ÁÉÁ²è¸¶ÅÀ¤è¤ê¾å / ²¼ ¤ÎÉô ʬ¤ÎÃͤò»Ø¤·¤Þ¤¹¡£

    XIM ·¿ÊÑ¿ô¤Î im ¤ª¤è¤Ó XIC ·¿¤ÎÊÑ¿ô ic ¤Ï¡¢¤½¤ì¤¾¤ì IM ¤È¤ä¤ê¤È¤ê¤¹¤ë¤¿¤á¤ËɬÍפʾðÊó ¤ò³ÊǼ¤¹¤ë¤¿¤á¤Î¤â¤Î¤Ç¤¹¡£

  • 44 ¡Á 78 ¹ÔÌÜ ( main() )

    xim_root.c ¤Î main ´Ø¿ô¤Ç¤¹¡£¤ª¤ª¤Þ¤«¤Ê½èÍý¤Ï¡¢

    • ¥í¥±¡¼¥ë¤Î³ÎΩ ( xim_setlocale() )
    • ½é´ü½èÍý ( xim_init() )
    • ¥Õ¥©¥ó¥È¥»¥Ã¥È¤ÎÀ¸À®¡¢¤ª¤è¤Ó¥Õ¥©¥ó¥È¾ðÊó¤Î¼èÆÀ ( xim_create_fontset() )
    • ¥¦¥£¥ó¥É¥¦ / GC ¤ÎºîÀ® ( xim_create_window() )
    • IM ¤Î½é´ü²½ ( xim_init_inputmethod() )
    • ¥¦¥£¥ó¥É¥¦Ç˲õ¥¤¥Ù¥ó¥È¤ò¼õ¤±¼è¤ë¤¿¤á¤Î¡¢WM_PROTOCOLS ¥×¥í¥Ñ¥Æ¥£¤ÎÀßÄê
    • IM ¤¬É¬ÍפȤ¹¤ë¥¤¥Ù¥ó¥È¤ÎÌ䤤¹ç¤ï¤» ( XGetICValues() )
    • ¥¤¥Ù¥ó¥È¤ÎÁªÂò ( XSelectInput() )
    • ¥¦¥£¥ó¥É¥¦¤Î¥Þ¥Ã¥× ( XMapWindow() )
    • ¥¤¥Ù¥ó¥È¥ë¡¼¥× ( xim_event_loop() )
    • ½ªÎ»½èÍý ( xim_close() )

    ¤È¤Ê¤ê¤Þ¤¹¡£¥¦¥£¥ó¥É¥¦Ç˲õ¥¤¥Ù¥ó¥È¤Ë´Ø¤·¤Æ¤Ï¡¢LECTURE 13 ¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¤È¤Î¤ä¤ê¤È¤ê¤Î»þ¤Ë¾Ü¤·¤¯ÀâÌÀ¤·¤Þ¤¹¤Î¤Ç¡¢¤³¤³¤Ç¤Ï¤½¤¦¤¤¤¦½èÍý¤ò ¤ä¤Ã¤Æ¤¤¤ë¤ó¤À¤È¤¯¤é¤¤¤Ë»×¤Ã¤Æ¤¤¤Æ²¼¤µ¤¤¡£

    IM ¤Ï¼«Ê¬¤¬É¬ÍפȤ¹¤ë¥¤¥Ù¥ó¥È¤ò¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤«¤é¼õ¤±¼è¤ê¡¢¥¤¥Ù¥ó¥È¤Ë±þ¤¸¤ÆÆ°ºî¤·¤Þ¤¹¡£ ¤½¤Î¤¿¤á¤Ë¤Ï¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï XSelectInput() ¤Ç¥¤¥Ù¥ó¥È¥Þ¥¹¥¯¤òÀßÄꤹ¤ëºÝ¤Ë¡¢IM ¤¬É¬ ÍפȤ¹¤ëÁ´¤Æ¤Î¥¤¥Ù¥ó¥È¤âÀßÄꤷ¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£IM ¤¬É¬ÍפȤ¹¤ë¥¤¥Ù¥ó¥È¤òÃΤë¤Ë¤Ï XGetICValues() ¤ò»È¤Ã¤Æ IC ¤ËÀßÄꤵ¤ì¤¿Â°À­¤ò¼èÆÀ¤·¤Þ¤¹¡£

      char* XGetICValues( XIC ic, ... );
      ... : XIC ¤Î°À­Ãͤò¼èÆÀ¤¹¤ë¤¿¤á¤Î²ÄÊÑĹ°ú¿ô¥ê¥¹¥È¤ò»ØÄê
    
    

    XGetICValues() ¤Î²ÄÊÑĹ°ú¿ô¤Ë¤Ï¡¢¼èÆÀ¤·¤¿¤¤Â°À­¤Î̾Á°¤È¼èÆÀ¤·¤¿Â°À­Ãͤò³ÊǼ¤¹¤ë¤¿¤á¤ÎÊÑ ¿ô¤Ø¤Î¥Ý¥¤¥ó¥¿¤ò»ØÄꤷ¤Þ¤¹¡£°ú¿ô¤Î½ª¤ï¤ê¤Ë¤Ï NULL ¤òÀßÄꤷ¤Þ¤¹¡£¤³¤³¤Ç¤Ï IM ¤¬É¬ÍפȤ¹ ¤ë¥¤¥Ù¥ó¥È¥Þ¥¹¥¯¤ò¼èÆÀ¤¹¤ë¤¿¤á¤Ë¡¢XNFilterEvents ¤ò»ØÄꤷ¤Æ unsigned long ·¿¤ÎÊÑ¿ô fevent ¤ò³ÊǼÀè¤Î¥Ð¥Ã¥Õ¥¡¤È¤·¤Æ»ØÄꤷ¤Æ¤¤¤Þ¤¹¡£

    ¥¨¥é¡¼¤¬È¯À¸¤·¤Ê¤«¤Ã¤¿¾ì¹ç¡¢XGetICValues() ¤ÏÊÖ¤êÃͤȤ·¤Æ NULL ¤òÊÖ¤·¤Þ¤¹¡£²¿¤é¤«¤Î¥¨¥é ¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ë¤Ï¡¢ÀßÄê¤Ç¤­¤Ê¤«¤Ã¤¿ºÇ½é¤Î°ú¿ô¤Î̾Á°¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£

  • 81 ¡Á 101 ¹ÔÌÜ ( xim_setlocale() )

    LECTURE 11 ¤ÇÀâÌÀ¤·¤¿¥í¥±¡¼¥ë´ØÏ¢¤Î½èÍý¤Ë²Ã¤¨¤Æ¡¢ XSetLocaleModifiers() ¤È¤¤¤¦´Ø¿ô¤ò¼Â¹Ô¤·¤Æ¤¤¤Þ¤¹¡£

      char* XSetLocaleModifiers( char* modifier_list );
      modifier_list : ¥â¥Ç¥£¥Õ¥¡¥¤¥¢¤ò»ØÄê
    
    

    °ú¿ô¤ò "" ¤È¤¹¤ë¤³¤È¤Ç¡¢´Ä¶­ÊÑ¿ô XMODIFIERS ¤Ë "@im=kinput2" ¤Î¤è¤¦¤ËÀßÄꤵ¤ì¤¿ IM ¤Î »ØÄê¤òÆɤ߹þ¤à¤³¤È¤¬¤Ç¤­¤Þ¤¹ ( kinput2 ¤ò»ÈÍѤ¹¤ë¾ì¹ç )¡£"@im=kinput2" ¤È¤¤¤¦É½¸½¤Ë¤Ä ¤¤¤Æ¤Ï¡¢XOpenIM() ¤ÎÀâÌÀ¤ÎºÝ¤ËºÆÅÙ¤Õ¤ì¤Þ¤¹¡£

  • 116 ¡Á 141 ¹ÔÌÜ ( xim_create_fontset() )

    LECTURE 11 ¤ÇÀâÌÀ¤·¤¿¥Õ¥©¥ó¥ÈºîÀ®½èÍý¤Ë²Ã¤¨¡¢ XExtentsOfFontSet() ¤ò»È¤Ã¤Æ¥Õ¥©¥ó¥ÈÉý¤Ê¤É¤Î¥Õ¥©¥ó¥È¾ðÊó¤ò¼èÆÀ¤·¤Æ¤¤¤Þ¤¹¡£»ØÄꤷ¤¿¥Õ¥© ¥ó¥È¥»¥Ã¥È¤ÇÉÁ²è¤µ¤ì¤ëʸ»ú¤Î¤¦¤Á¡¢ºÇÂç¤ÎÎΰè¤òÀê¤á¤ëʸ»ú¤Ë¤Ä¤¤¤Æ¤Î¾ðÊó¤ò XFontSetExtents ·¿¹½Â¤ÂÎÊÑ¿ô¤È¤·¤ÆÊÖ¤·¤Þ¤¹¡£

      XFontSetExtents* XExtentsOfFontSet( XFontSet font_set );
    
      typedef struct {
          XRectangle max_ink_extent;
          XRectangle max_logical_extent;
      } XFontSetExtents;
    
    

    max_logical_extent ¤ÎÊý¤Ï¡¢ÉÁ²è¤·¤¿Ê¸»ú¤¬´°Á´¤Ë°Ï¤Þ¤ì¤ëĹÊý·ÁÎΰè¤Î¾ðÊ󤬳ÊǼ¤µ¤ì¤Þ¤¹¡£ max_locical_extent.x ¤ª¤è¤Ó max_logical_extent.y ¤Ë¤Ï¡¢¤½¤ì¤¾¤ìÉÁ²èʸ»ú¤ÎÉÁ²è¸¶ÅÀ¤«¤é ¸«¤¿º¸¾å³Ñ¤Î°ÌÃÖ¤¬³ÊǼ¤µ¤ì¤Þ¤¹¡£

    ¤³¤ì¤é¤ò»È¤Ã¤Æ¡¢¥Õ¥©¥ó¥ÈÉý¤ª¤è¤Ó¹â¤µ¤ò¼èÆÀ¤·¤Æ¤¤¤Þ¤¹¡£¤Þ¤¿¡¢ ( - max_logical_extent.y ) ¤¬ ascent ( ²èÌ̾åÊý¸þ¤¬ y ¼´¤ÎÀµÊý¸þ¤Ç¤¢¤ë¤¿¤á)¡¢ font_h - ascent ¤¬ descent ¤È¤Ê¤ê¤Þ¤¹¡£ºÇ¸å¤Ë ¥Õ¥©¥ó¥ÈÉý¡¢¹â¤µ¤Èʸ»úɽ¼¨¿ô¤ò»È¤Ã¤Æ¥¦¥£ ¥ó¥É¥¦¤Î¥µ¥¤¥º¤ò·èÄꤷ¤Æ¤¤¤Þ¤¹¡£

  • 156 ¡Á 181 ¹ÔÌÜ ( xim_init_inputmethod() )

    IM ¤ÎÄÌ¿®¤¹¤ë¤¿¤á¤Î½é´ü½èÍý¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£IM ¤Ë¤è¤Ã¤Æ¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤òÆþÎϤ¹¤ë¾ì ¹ç¤Ë¤Ï¡¢¤Þ¤º IM ¤ËÀܳ¤·¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£¤³¤ì¤Ë¤Ï XOpenIM() ¤ò»È¤¤¤Þ¤¹¡£

      XIM XOpenIM( Display* dpy, XrmDatabase db, char* res_name, char* res_class );
    
      db        : IM ¤¬¥ê¥½¡¼¥¹¤Î¸¡º÷¤Ë»È¤¦¥ê¥½¡¼¥¹¥Ç¡¼¥¿¥Ù¡¼¥¹
      res_name  : ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î´°Á´¤Ê¥ê¥½¡¼¥¹Ì¾
      res_class : ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î´°Á´¤Ê¥¯¥é¥¹Ì¾
    
    

    ¤³¤Î´Ø¿ô¤ò¼Â¹Ô¤¹¤ë¤È¡¢¸½ºß¤Î¥í¥±¡¼¥ë¤ËŬ¤¹¤ë IM ¤È¤ÎÀܳ¤¬³ÎΩ¤µ¤ì¤½¤ÎÀܳ¤Î¥Ï¥ó¥É¥ë ¤È¤·¤Æ XIM ·¿¤ÎÊÑ¿ô¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£IM ¤È¤ÎÀܳ¤Ë¼ºÇÔ¤·¤¿¾ì¹ç¤Ï¡¢NULL ¤¬ÊÖ¤ê¤Þ¤¹¡£¤Ê¤ª¡¢ XIM ·¿¤ÎÆâÍƤϸø³«¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£°ú¿ô¤Ï IM ¤¬¥ê¥½¡¼¥¹¤ò¸¡º÷¤¹¤ëºÝ¤Ë»ÈÍѤ¹¤ë¤¿¤á¤Î¤â ¤Î¤Ç¤¹¤¬¡¢xim_root.c ¤Ç¤ÏÁ´¤Æ NULL ¤È¤·¤Æ¤¤¤Þ¤¹( ÊÙ¶¯ÉÔ­¤Î¤¿¤á¡¢NULL ¤À¤È¤É¤¦¤Ê¤ë¤Î ¤«¡¢¤É¤¦¤¤¤¦¾ì¹ç¤Ë NULL °Ê³°¤ò»ØÄꤹ¤ë¤Î¤«¤Ë¤Ä¤¤¤Æ¤Ï¤Þ¤ÀËͤÏʬ¤«¤Ã¤Æ¤Þ¤»¤óm(__)m )¡£

    XOpenIM() ¤¬¥ª¡¼¥×¥ó¤¹¤ë¥Ç¥Õ¥©¥ë¥È¤Î IM ¤Ï¥í¥±¡¼¥ë¤Ç·èÄꤵ¤ì¤Þ¤¹¤¬¡¢³Æ¥í¥±¡¼¥ë¤ËÂФ· ¤ÆÊ£¿ô¤ÎÆþÎϥ᥽¥Ã¥É¤¬¤¢¤ë¤³¤È¤â¹Í¤¨¤é¤ì¤Þ¤¹¡£¤³¤Î¤¿¤á¡¢¥Ç¥Õ¥©¥ë¥È¤Î IM ¤òÀßÄꤹ¤ë¤¿ ¤á¤Ë "im" ¤È¤¤¤¦Ì¾Á°¤Î¥í¥±¡¼¥ë¥â¥Ç¥£¥Õ¥¡¥¤¥¢¤¬ÍÑ°Õ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£Á°½Ò¤Î¤è¤¦¤Ë´Ä¶­ÊÑ¿ô XMODIFIERS ¤Ë "@im=input_method_name" ¤ÈÀßÄꤹ¤ë¤³¤È¤Ç¡¢´õ˾¤ÎÆþÎϥ᥽¥Ã¥É¤¬»ÈÍѤµ¤ì ¤Þ¤¹¡£

    XOpenIM() ¤Ë¤è¤Ã¤Æ IM ¤È¤ÎÀܳ¤¬³ÎΩ¤µ¤ì¤Þ¤·¤¿¤¬¡¢IM ¤ËÂФ¹¤ëÎΰè¤äÂÐÏ÷Á¼°¤ÎÀßÄê¡¢¤ª ¤è¤Ó¥Æ¥­¥¹¥ÈÆþ½ÐÎϤ½¤Î¤â¤Î¤ò¹Ô¤¦¤Ë¤Ï¡¢IM ¤Î¥ª¡¼¥×¥ó¤Ë°ú¤­Â³¤¤¤ÆÆþÎÏ¥³¥ó¥Æ¥­¥¹¥È( IC ) ¤òºîÀ®¤·¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£IC ¤Ï¡¢GC ¤¬ÉÁ²è¤Ë´Ø¤¹¤ë°À­¾ðÊó¤ò´ÉÍý¤·¤Æ¤¤¤ë¤Î¤ÈƱÍÍ¤Ë ¹ñºÝ²½¥Æ¥­¥¹¥È¤ÎÆþ½ÐÎϤ˴ؤ¹¤ë°À­¾ðÊó¤ò´ÉÍý¤·¤Æ¤¤¤Þ¤¹¡£IC ¤Î°À­¤Ë¤è¤Ã¤Æ IM ¤ÎµóÆ°¤ä ³°´Ñ¤¬·èÄꤵ¤ì¤Þ¤¹¡£

    X ÆþÎÏ¥³¥ó¥Æ¥­¥¹¥È ( XIC ) ¤òºîÀ®¤¹¤ë¤Ë¤Ï XCreateIC() ¤ò»È¤¤¤Þ¤¹¡£ºîÀ®¤Ë¼ºÇÔ¤·¤¿¾ì¹ç ¤Ï NULL ¤¬ÊÖ¤ê¤Þ¤¹¡£

      XIC XCreateIC( XIM im, ... );
    
      im  : XOpenIM ¤Ë¤è¤Ã¤ÆÀܳ¤¬³ÎΩ¤µ¤ì¤¿ IM ¤Î¥Ï¥ó¥É¥é
      ... : XIC ¤Î°À­¤òÀßÄꤹ¤ë¤¿¤á¤Î²ÄÊÑĹ°ú¿ô¥ê¥¹¥È
    
    

    ²ÄÊÑĹ°ú¿ô¥ê¥¹¥È¤Ë¤Ï°À­Ì¾¤È°À­ÃͤÎÁȤòÀßÄꤷ¡¢¥ê¥¹¥È¤ÎºÇ¸å¤Ë¤Ï NULL ¤òÀßÄꤷ¤Þ¤¹¡£ xim_root.c ¤Ç¤Ï¡¢XNInputStyle ¤È¤¤¤¦Â°À­¤ËÂФ·¤Æ XIMPreeditNothing ¤ª¤è¤Ó XIMStatusNothing ¤È¤¤¤¦Â°À­Ãͤò¡¢XNClientWindow ¤È¤¤¤¦Â°À­¤ËÂФ·¤Æɽ¼¨¤Î¥¦¥£¥ó¥É¥¦¤ò »ØÄꤷ¤Æ¤¤¤ë¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£

    ¤³¤³¤Ë»ØÄê¤Ç¤­¤ë°À­Ì¾¤ª¤è¤Ó¤½¤ÎÆâÍƤˤĤ¤¤Æ¡¢¤¤¤¯¤Ä¤«²¼É½¤Ë¼¨¤·¤Þ¤¹¡£

    Äê¿ô̾ ÀâÌÀ
    XNInputStyle ÆþÎÏ¥³¥ó¥Æ¥­¥¹¥È¤ËÂФ·¤ÆÆþÎϥ᥽¥Ã¥É¤¬»ÈÍѤ¹¤ëÂÐÏ÷¿¤ò»ØÄꤹ¤ë ( XIMStyle )¡£ ¤³¤³¤Ë XIMPreeditNothing ¤ª¤è¤Ó XIMStatusNothing ¤ò»ØÄꤹ¤ë¤È¥ë¡¼¥È¥¦¥£¥ó¥É¥¦·¿¤ÎÂÐÏ÷Á¼°¤È¤Ê¤ë¡£
    XNFontSet ÆþÎϥ᥽¥Ã¥É¤¬Á°ÊÔ½¸¤ä¾õÂÖɽ¼¨¥¦¥£¥ó¥É¥¦¤Ç¤Îʸ»úÎóÉÁ²è¤Ë»ÈÍѤ¹¤ë ¥Õ¥©¥ó¥È¥»¥Ã¥È¤ò»ØÄꤹ¤ë ( XFontSet )¡£
    XNClientWindow ÆþÎϥ᥽¥Ã¥É¤¬Á°ÊÔ½¸Îΰ褪¤è¤Ó¾õÂÖɽ¼¨Îΰè¤È¤·¤Æ»ÈÍѤ¹¤ë¥¦¥£¥ó¥É¥¦¤ò»ØÄꤹ¤ë ( Window )¡£
    XNForeground ÆþÎϥ᥽¥Ã¥É¤¬»ÈÍѤ¹¤ëÁ°·Ê¥Ô¥¯¥»¥ëÃͤò»ØÄꤹ¤ë( unsigned long )
    XNBackground ÆþÎϥ᥽¥Ã¥É¤¬»ÈÍѤ¹¤ëÇØ·Ê¥Ô¥¯¥»¥ëÃͤò»ØÄꤹ¤ë( unsigned long )

  • 184 ¡Á 223 ¹ÔÌÜ ( xim_event_loop() )

    ¼ç½èÍý¤ò¹Ô¤¦¥¤¥Ù¥ó¥È¥ë¡¼¥×¤Ç¤¹¡£XNextEvent() ¤ò»È¤Ã¤Æ¥¤¥Ù¥ó¥È¤òÆɤ߹þ¤ó¤À¸å¡¢¥¤¥Ù¥ó ¥È¤Î¼ïÎà¤Ë¤è¤Ã¤Æ½èÍý¤ò¿¶¤êʬ¤±¤ëÁ°¤Ë XFilterEvent() ¤È¤¤¤¦´Ø¿ô¤ò¼Â¹Ô¤·¤Æ¤¤¤Þ¤¹¡£

      Bool XFilterEvent( XEvent* event, Window win );
    
      event : ¥Õ¥£¥ë¥¿¤¹¤ë¥¤¥Ù¥ó¥È¤ò»ØÄê
      win   : ¥Õ¥£¥ë¥¿¤¬Å¬ÍѤµ¤ì¤ë¥¦¥£¥ó¥É¥¦¤ò»ØÄê
    
    

    IM ¤Ï¥­¡¼¥¹¥È¥í¡¼¥¯°Ê³°¤Î X ¥¤¥Ù¥ó¥È¤ò¼õ¤±¼è¤ëɬÍפ¬¤¢¤ê¤Þ¤¹( Îΰè¤Î½ñ¤­´¹¤¨¤Î¤¿¤á¤Ê ¤É¿§¡¹)¡£¤½¤Î¤¿¤á¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¦¤Ç½èÍý¤¹¤ëÁ°¤ËÁ´¤Æ¤Î¥¤¥Ù¥ó¥È¤ò IM ¤ËÅϤµ¤Ê¤±¤ì¤Ð ¤Ê¤ê¤Þ¤»¤ó¡£¤³¤Î¤¿¤á¤Ë XFilterEvent() ¤ò»È¤¤¤Þ¤¹¡£

    ¤³¤Î´Ø¿ô¤¬ True ¤òÊÖ¤·¤¿¾ì¹ç¡¢¥¤¥Ù¥ó¥È¤Ï IM ¤Ë¤è¤Ã¤Æ½èÍý¤µ¤ì¤¿¤Î¤Ç¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¦ ¤Ç¤Ï¤³¤Î¥¤¥Ù¥ó¥È¤Î½èÍý¤ò¹Ô¤Ã¤Æ¤Ï¤¤¤±¤Þ¤»¤ó¡£False ¤òÊÖ¤·¤¿¾ì¹ç¤Ë¸Â¤Ã¤Æ¡¢¥¤¥Ù¥ó¥È¤Î¼ï Îà¤Ë¤è¤Ã¤Æ½èÍý¤ò¿¶¤êʬ¤±¤Þ¤¹¡£

    • KeyPress ¥¤¥Ù¥ó¥È»þ

      226 ¡Á 280 ¹ÔÌܤΠxim_draw() ¤Ç¡¢ÆþÎÏʸ»ú¤ÎÉÁ²è½èÍý¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£

      KeyPress ¥¤¥Ù¥ó¥È¤ò¼õ¤±¼è¤Ã¤¿¾ì¹ç¡¢²¿¤Î¥­¡¼¤¬²¡¤µ¤ì¤¿¤Î¤«¤òȽÄꤹ¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ ±Ñ¿ô»ú¤Î¾ì¹ç¤Ï XLookupString() ¤ò»È¤¤¤Þ¤¹¤¬¡¢ÆüËܸì¤Î¤è¤¦¤Ê¥Þ¥ë¥Á¥Ð¥¤¥ÈÆþÎϤξì¹ç¤Ï XmbLookupString() ¤ò»È¤¤¤Þ¤¹¡£

          int XmbLookupString( XIC              ic, 
                               XKeyPressedEvent event, 
                               char*            buffer_return, 
                               int              bytes_buffer, 
                               KeySym*          keysym_return, 
                               Status* status_return 
                             );
      
          buffer_return : IM ¤«¤é¡¢¹½À®¤µ¤ì¤¿(ÊÑ´¹¸å¤Î)¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤¬ÊÖ¤µ¤ì¤ë
          bytes_buffer  : ¥ê¥¿¡¼¥ó¥Ð¥Ã¥Õ¥¡¤ÎÍÆÎ̤ò»ØÄê
          keysym_return : NULL ¤Ç¤Ê¤¤¾ì¹ç¤Ï¡¢¥¤¥Ù¥ó¥È¤«¤é·×»»¤µ¤ì¤¿ KeySym ¤¬ÊÖ¤µ¤ì¤ë
          status_return : ÊֵѾðÊó¤Î¼ïÎà¤ò¼¨¤¹Ãͤ¬ÊÖ¤µ¤ì¤ë
      
      

      buffer_return ¤Ë³ÊǼ¤µ¤ì¤¿Ê¸»úÎó¤Î¥Ð¥¤¥È¿ô¤¬ÊÖ¤ê¤Þ¤¹¡£¤Ê¤ª¡¢status_return ¤Ë³ÊǼ¤µ ¤ì¤ëÃͤϲ¼É½¤ÎÄ̤ê¤Ç¤¹¡£

      Äê¿ô̾ ÀâÌÀ
      XLookupBothKeySym ¤Èʸ»úÎó¤ÎξÊý¤¬ÊÖ¤µ¤ì¤¿
      XLookupCharsÆþÎϥ᥽¥Ã¥É¤Ë¤è¤êÆþÎÏʸ»úÎ󤬹½À®¤µ¤ì¤Æ¤¤¤ë
      XLookupKeySymʸ»úÎó¤Ç¤Ï¤Ê¤¯ KeySym ¤¬ÊÖ¤µ¤ì¤Æ¤¤¤ë
      XLookupNoneÀµ¤·¤¤ÆþÎϤ¬º£¤Î¤È¤³¤í¹½À®¤µ¤ì¤Æ¤¤¤Ê¤¤
      XBufferOverflowÊÖ¤µ¤ì¤ë¤Ù¤­ÆþÎÏʸ»úÎ󤬥Хåե¡¤ÎÂ礭¤µ¤è¤ê¤âŤ¤¡£ ¤³¤Î¾ì¹ç¡¢´Ø¿ô¤ÎÊÖ¤êÃͤ¬É¬ÍפʥХ¤¥È¿ô¤È¤Ê¤ë¤Î¤Ç¡¢ ¤½¤ÎÂ礭¤µ¤Î¥Ð¥Ã¥Õ¥¡¤ò³ÎÊݤ·¤ÆºÆÆɤ߹þ¤ß¤ò¹Ô¤¦

      xim_root.c ¤Ç¤Ï¡¢²þ¹Ô¤¬ÆþÎϤµ¤ì¤¿¾ì¹ç ( XK_Return ¤È¤¤¤¦ KeySym ¤È²þ¹Ôʸ»ú¤¬ÊÖ¤µ¤ì ¤ë¤¿¤á¡¢status_return ¤Ï XLookupBoth ¤È¤Ê¤ë ) ¤Ë¤Ïʸ»úÎó¤Îɽ¼¨°ÌÃÖ¤ò²¼¤Ë¤º¤é¤·¤Æ¤½ ¤Î¹Ô¤òÇØ·Ê¿§¤Ç¥¯¥ê¥¢ ( XClearArea() ) ¤·¤Æ¤¤¤Þ¤¹¡£¤Þ¤¿¡¢È¾³Ñ±Ñ¿ô»ú¤¬ÆþÎϤµ¤ì¤¿¾ì¹ç ( status_return ¤Ï XLookupBoth ) ¤ä¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤¬ÆþÎϤµ¤ì¤¿¾ì¹ç( status_return ¤Ï XLookupChars ) ¤Ë¤Ï¡¢¸½ºß¤Îɽ¼¨°ÌÃÖ¤ò·×»»¤·¤Æ XmbDrawString() ¤ò»È¤Ã¤Æʸ»úÎó¤òÉÁ ²è¤·¤Æ¤¤¤Þ¤¹¡£

      ¤Ê¤ª¡¢xim_root.c ¤Ç¤Ï status_return ¤¬ XBufferOverflow ¤Ç¤¢¤ë¾ì¹ç¤ò°·¤Ã¤Æ¤¤¤Þ¤»¤ó ¤¬¡¢¤³¤Î¾ì¹ç¤ÏÍÑ°Õ¤·¤¿¥Ð¥Ã¥Õ¥¡¤Ëʸ»úÎó¤ò³ÊǼ¤·¤­¤ì¤Ê¤«¤Ã¤¿¤È¤¤¤¦¤³¤È¤Ê¤Î¤Ç¡¢½¼Ê¬¤Ê ¥Ð¥Ã¥Õ¥¡¤òÍÑ°Õ¤·¤¿¾å¤ÇºÆÅÙ XmbLookupString() ¤ò¼Â¹Ô¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£

    • FocusIn / FocusOut ¥¤¥Ù¥ó¥È»þ

      FocusIn / FocusOut ¥¤¥Ù¥ó¥È¤Ë¤è¤Ã¤Æ¥¦¥£¥ó¥É¥¦¤Î¥Õ¥©¡¼¥«¥¹¾õÂÖ¤òÆÀ¤¿¤é¡¢¤½¤ì¤Ë¹ç¤ï¤» ¤Æ IC ¤Î¥Õ¥©¡¼¥«¥¹¤òÀßÄꤹ¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£¤½¤¦¤¹¤ë¤³¤È¤Ç¡¢IM ¤¬¥Õ¥©¡¼¥«¥¹¾õÂ֤˱þ ¤¸¤¿ÊÔ½¸Îΰè¤ÎÉÁ²è¤Ê¤É¤ò¹Ô¤¦¤³¤È¤¬²Äǽ¤È¤Ê¤ë¤«¤é¤Ç¤¹¡£

      IC ¤Î¥Õ¥©¡¼¥«¥¹¾õÂÖ¤Ï XSetICFocus() / XUnsetICFocus() ¤ò»È¤¤¤Þ¤¹¡£

          void XSetICFocus( XIC ic );
          void XUnsetICFocus( XIC ic );
      
      

    • ClientMesage ¥¤¥Ù¥ó¥È»þ

      LECTURE 13 ¤ÇÀâÌÀ¤·¤Þ¤¹¤¬¡¢¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¤«¤é ¥¦¥£¥ó¥É¥¦Ç˲õÍ×µá¤ò¼õ¤±¼è¤Ã¤¿¾ì¹ç¤Ï¡¢½ªÎ»½èÍý¤ò¹Ô¤¤¤Þ¤¹¡£

  • 283 ¡Á 293 ¹ÔÌÜ ( xim_close() )

    ½ªÎ»½èÍý¤ò¹Ô¤¤¤Þ¤¹¡£IC ¤Î²òÊü½èÍýÍѤΠXDestroyIC()¡¢IM ¤Î²òÊü½èÍýÍѤΠXCloseIM() ¤¬ ¿·¤·¤¯½Ð¤Æ¤­¤Æ¤¤¤Þ¤¹¡£

      XDestroyIC( XIC ic );
      XCloseIM( XIM im );
    
    

°Ê¾å¤Ç¥ë¡¼¥È¥¦¥£¥ó¥É¥¦·¿¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ÎÀâÌÀ¤Ï½ª¤ê¤Ç¤¹¡£

¡û ¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à ( off-the-spot ·¿ )

¥ë¡¼¥È¥¦¥£¥ó¥É¥¦·¿¤Î¥³¡¼¥É¤Î°ìÉô¤ò½ñ¤­´¹¤¨¤ë¤À¤±¤Ç¡¢´Êñ¤Ë off-the-spot ·¿¤Î¥³¡¼¥É¤¬ÆÀ¤é¤ì¤Þ¤¹¡£xim_root.c ¤ò½ñ¤­´¹¤¨¤Æ off-the-spot ·¿¤Ë¤·¤¿ xim_offspot.c ¤Ë¤Ä¤¤¤Æ¡¢½ñ¤­´¹¤¨¤é¤ì¤¿´Ø¿ô ( xim_create_font_set()¡¢xim_init_inputmethod() ) ¤Î¤ß¤ò¼¨¤·¤Þ¤¹¡£

off-the-spot ·¿¤Î¾ì¹ç¡¢²¾Ì¾´Á»úÊÑ´¹ÆþÎÏÎΰ褬¥¯¥é¥¤¥¢¥ó¥È¥¦¥£¥ó¥É¥¦¤Î°ìÉô¤Ë³ÎÊݤµ¤ì¤Þ¤¹¡£

012xim_offspot.jpg

--- xim_offspot.c ( °ìÉô ) ---

...

static void 
xim_create_fontset( void )
{
    XFontSetExtents*  fs_extents;
    int    missing_count;
    char** missing_list;
    char*  def_string;

    fs = XCreateFontSet( dpy, "-*-fixed-medium-r-normal--14-*-*-*", 
                 &missing_list, &missing_count, &def_string );

    XFreeStringList( missing_list );   

    /* ¥Õ¥©¥ó¥È¾ðÊó¤Î¼èÆÀ */
    fs_extents = XExtentsOfFontSet(fs);

    font_w  = fs_extents->max_logical_extent.width;
    font_h  = fs_extents->max_logical_extent.height;
    ascent  = - fs_extents->max_logical_extent.y;
    descent = fs_extents->max_logical_extent.height - ascent;

    /* 
     * ¥¦¥£¥ó¥É¥¦Éý¤È¹â¤µ¤òÀßÄê 
     * IM ¤Î¾õÂÖÎΰ褪¤è¤ÓÁ°ÊÔ½¸Îΰè¤ò³ÎÊݤ¹¤ë¤¿¤á¡¢
     * xim_root.c ¤è¤ê 2 ¹Ôʬ¹â¤µ¤ò¹­¤²¤ë 
     */
    win_w = font_w * COL;
    win_h = font_h * ( ROW + 2 );
}

...

static int 
xim_init_inputmethod( void )
{
    /* Á°ÊÔ½¸Îΰ褪¤è¤Ó¾õÂÖÎΰè¤ò»Ø¤¹¶ë·Á */
    XRectangle    preedit_rect, status_rect;

    /* Á°ÊÔ½¸Îΰ褪¤è¤Ó¾õÂÖÎΰè¤Î°À­¤ò»ØÄꤹ¤ë¤¿¤á¤Î¥ê¥¹¥È */
    XVaNestedList preedit_attr, status_attr;

    /* ¥¤¥ó¥×¥Ã¥È¥á¥½¥Ã¥É¤ò¥ª¡¼¥×¥ó¤¹¤ë */
    if ( ( im = XOpenIM( dpy, NULL, NULL, NULL ) ) == NULL ) {
        printf( "Couldn't open input method.\n" );
        return -1;
    }

    /* Á°ÊÔ½¸Îΰè°À­¤ÎÀßÄê */
    preedit_rect.x      = 0;
    preedit_rect.y      = font_h * ROW;
    preedit_rect.width  = win_w;
    preedit_rect.height = font_h;

    preedit_attr  = XVaCreateNestedList( 
        ( int )NULL, XNArea, &preedit_rect, XNFontSet, fs, NULL );

    status_rect.x       = 0;
    status_rect.y       = font_h * ( ROW + 1 );
    status_rect.width   = win_w;
    status_rect.height  = font_h;

    status_attr = XVaCreateNestedList( 
        ( int )NULL, XNArea, &status_rect, XNFontSet, fs, NULL );

    /* ¥¤¥ó¥×¥Ã¥È¥³¥ó¥Æ¥­¥¹¥È¤ÎºîÀ® */
    ic = XCreateIC( im,
            XNInputStyle,        
            XIMPreeditArea | XIMStatusArea,
            XNClientWindow,      
            win,
            XNPreeditAttributes, 
            preedit_attr,
            XNStatusAttributes,  
            status_attr,
            NULL );

    XFree( preedit_attr );
    XFree( status_attr );

    if ( ic == NULL ) {
        printf( "Couldn't create input context.\n" );
        XCloseIM( im );
        return -1;
    }

    return 0;
}
...

¡û off-the-spot ·¿¤Î¥ë¡¼¥È¥¦¥£¥ó¥É¥¦·¿¤È¤Î°ã¤¤

off-the-spot ·¿¤Î¼ÂÁõ¤¬¥ë¡¼¥È¥¦¥£¥ó¥É¥¦·¿¤È°Û¤Ê¤ëÅÀ¤Ï¡¢Á°ÊÔ½¸Îΰ褪¤è¤Ó¾õÂÖÎΰè¤Ë¤Ä¤¤¤Æ¤Î¾ðÊó¤òÀßÄꤹ¤ë¤³¤È¡¢¤Þ¤¿¤½¤Î 2 ¤Ä¤ÎÎΰè¤ò¹Íθ¤·¤Æ¥¦¥£¥ó¥É¥¦¤Î¥µ¥¤¥º¤ò·èÄꤷ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤È¤¤¤¦¤³¤È¤Ç¤¹¡£

¤Þ¤º xim_create_window() ¤Î¥¦¥£¥ó¥É¥¦¥µ¥¤¥º¤ò·×»»¤·¤Æ¤¤¤ëÉôʬ¤Ç¡¢¹â¤µ¤ò 2 ¹ÔʬÂ礭¤¯¤·¤Æ¤¤¤Þ¤¹¡£¤³¤ì¤Ï¡¢Á°ÊÔ½¸Îΰ褪¤è¤Ó¾õÂÖÎΰè¤Î 2 ¹Ôʬ¤òÁý¤ä¤·¤¿¤³¤È¤ËÁêÅö¤·¤Þ¤¹¡£¼¡¤Ë xim_init_inputmethod() ¤Ë¤ª¤¤¤Æ¡¢Á°ÊÔ½¸Îΰ褪¤è¤Ó¾õÂÖÎΰ褬¥¦¥£¥ó¥É¥¦¤Î¤É¤ÎÎΰè¤ò»ÈÍѤ¹¤ë¤«¤ò XRectangle ·¿ÊÑ¿ô¤ËÀßÄꤷ¤¿¸å¤Ë¡¢XVaCreateNestedList() ¤ò»È¤Ã¤Æ°À­¥ê¥¹¥È¤òºîÀ®¤·¤Æ¤¤¤Þ¤¹¡£

XVaNestedList XVaCreateNestedList( int dummy, ... );

dummy : ¼ÂºÝ¤Ë¤Ï»ÈÍѤµ¤ì¤Ê¤¤¥À¥ß¡¼¤Î°ú¿ô¤ò»ØÄê
...   : ²ÄÊÑĹ°ú¿ô¥ê¥¹¥È¤Î»ØÄê

(*)XVaNestedList ¤Ë´Ø¤·¤Æ¤Ï
   typedef void* XVaNestedList;
   ¤È¤·¤ÆÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£

²ÄÊÑĹ¥ê¥¹¥È¤ò»ÈÍѤ·¤Æ¡¢Îΰè¤òÀßÄꤷ¤¿ XRectangle ·¿ÊÑ¿ô¤ò XNArea °À­¤Ë¡¢ºîÀ®¤·¤¿¥Õ¥©¥ó¥È¥»¥Ã¥È¤ò XNFontSet °À­¤ËÀßÄꤷ¤Æ¤¤¤Þ¤¹¡£

¤Þ¤¿ XCreateIC ¤ò»È¤Ã¤Æ IC ¤òºîÀ®¤¹¤ë¤ËºÝ¤·¤Æ¡¢XNInputStyle °À­¤Ë XIMPreeditArea ¤ª¤è¤Ó XIMStatusArea ¤ÎÏÀÍýϤòÀßÄꤷ¤Þ¤¹¡£¤½¤·¤Æ¿·¤·¤¯½Ð¤Æ¤­¤¿ XNPreeditAttributes ¤ª¤è¤Ó XNStatusAttributes °À­¤Ë¡¢XVaCreateNestedList ¤ò»È¤Ã¤Æºî¤Ã¤¿Â°À­¥ê¥¹¥È¤ò¤½¤ì¤¾¤ìÀßÄꤷ¤Þ¤¹¡£¤Ê¤ª¡¢ÉÔÍפˤʤä¿Â°À­¥ê¥¹¥È¤Ï XFree() ¤ò»È¤Ã¤Æ²òÊü¤·¤Þ¤¹¡£

XFree( void* data );

°Ê¾å¤Î¼ê³¤­¤ò¹Ô¤¦¤À¤±¤Ç¡¢¥ë¡¼¥È¥¦¥£¥ó¥É¥¦·¿¤«¤é´Êñ¤Ë off-the-spot ·¿¤òºîÀ®¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£