LECTURE 9 ¥Þ¥¦¥¹ÆþÎϽèÍý¤ÎÊýË¡

¡û ¤Ï¤¸¤á¤Ë

¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤òºîÀ®¤¹¤ë¾ì¹ç¡¢¥æ¡¼¥¶¤«¤é¤ÎÆþÎϤò¼õ¤±¼è¤Ã¤Æ½èÍý¤ò¹Ô¤¤¤¿¤¤¤³¤È¤¬Îɤ¯¤¢¤ê¤Þ¤¹¡£¤³¤³¤Ç¤Ï¥Þ¥¦¥¹¤Ç¥¯¥ê¥Ã¥¯¤¹¤ë¤Ê¤É¤Î¡¢¥Þ¥¦¥¹ÆþÎϤòÆɤߤȤ뤿¤á¤ÎÊýË¡¤È¡¢¤½¤ì¤Ë´ØÏ¢¤·¤¿ Tips ¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Þ¤¹¡£

¥Þ¥¦¥¹ÆþÎϤ˴ؤ¹¤ë¥¤¥Ù¥ó¥È¤Ë¤Ï¡¢¥æ¡¼¥¶¤¬¥Þ¥¦¥¹¥Ü¥¿¥ó¤ò²¡¤·¤¿¾ì¹ç( ButtonPress ¥¤¥Ù¥ó¥È)¡¢Î¥¤·¤¿¾ì¹ç( ButtonRelease ¥¤¥Ù¥ó¥È)¡¢¥Þ¥¦¥¹¤òÆ°¤«¤·¤¿¾ì¹ç( MotionNotify ¥¤¥Ù¥ó¥È)¤Î 3 ¼ïÎब¤¢¤ê¤Þ¤¹¡£¤½¤Î¾¤Ë¡¢¥Þ¥¦¥¹¤¬¥¦¥£¥ó¥É¥¦¤«¤é½Ð¤¿¾ì¹ç¤ËȯÀ¸¤¹¤ë LeaveNotify ¥¤¥Ù¥ó¥È¡¢¥¦¥£¥ó¥É¥¦¤ËÆþ¤Ã¤Æ¤­¤¿¾ì¹ç¤ËȯÀ¸¤¹¤ë EnterNotify ¥¤¥Ù¥ó¥È¤¬¤¢¤ê¤Þ¤¹¡£

LeaveNotify / EnterNotify ¤Ë¤Ä¤¤¤Æ¤ÏÂбþ¤¹¤ë¥¤¥Ù¥ó¥È¥Þ¥¹¥¯¤òÀßÄꤷ¤Æ¥¤¥Ù¥ó¥È¤ò¸¡½Ð¤¹¤ë¤À¤±¤Ê¤Î¤Ç¡¢¤³¤³¤Ç¤Ï¥Þ¥¦¥¹ÆþÎϤ˴ؤ¹¤ë 3 ¤Ä¤Î¥¤¥Ù¥ó¥È

¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Þ¤¹¡£¤Þ¤¿¡¢¥¤¥Ù¥ó¥È¤È¤Ï´Ø·¸¤¢¤ê¤Þ¤»¤ó¤¬

¤Ë¤Ä¤¤¤Æ¤âÀâÌÀ¤·¤Þ¤¹¡£

¡û ButtonPress / ButtonRelease ¥¤¥Ù¥ó¥È

¥æ¡¼¥¶¤¬¥Þ¥¦¥¹¥Ü¥¿¥ó¤ò²¡¤¹¤È ButtonPress ¥¤¥Ù¥ó¥È¤¬¡¢Î¥¤¹¤È ButtonRelease ¥¤¥Ù¥ó¥È¤¬È¯À¸¤·¤Þ¤¹¡£¤³¤ì¤é¤Î¥¤¥Ù¥ó¥È¤Ï¥Ü¥¿¥ó¥¤¥Ù¥ó¥È¤È¸Æ¤Ð¤ì¤Þ¤¹¡£X ¥µ¡¼¥Ð¤«¤éÁ÷¤é¤ì¤ÆÍè¤ë¥Ü¥¿¥ó¥¤¥Ù¥ó¥È¾ðÊó¤Ï²¼¿Þ¤Î¤è¤¦¤Ê¹½Â¤ÂΤηÁ¼°¤ÇÁ÷¤é¤ì¤ÆÍè¤Þ¤¹¡£

typedef struct
{
  int           type;           /* ¥¤¥Ù¥ó¥È¤Î¼ïÎà */
  unsigned long serial;         /* ¥µ¡¼¥Ð¤¬½èÍý¤·¤¿ºÇ¸å¤Î¥ê¥¯¥¨¥¹¥È¤ÎÈÖ¹æ */
  Bool          send_event;     /* ¥¯¥é¥¤¥¢¥ó¥È¤«¤éÁ÷¤é¤ì¤¿¥¤¥Ù¥ó¥È¤Ê¤éTrue */
  Display*      display;        /* ¥¤¥Ù¥ó¥È¤¬Æɤ߹þ¤Þ¤ì¤¿display */
  Window        window;         /* ¥¤¥Ù¥ó¥È¤¬È¯À¸¤·¤¿¥¦¥£¥ó¥É¥¦¤ÎID */
  Window        root;           /* ¥¤¥Ù¥ó¥È¤¬µ¯¤³¤Ã¤¿¥¦¥£¥ó¥É¥¦¤ÎID */
  Window        subwindow;      /* window¤Î»Ò¥¦¥£¥ó¥É¥¦ID */
  Time          time;           /* ¥¤¥Ù¥ó¥ÈȯÀ¸»þ¹ï */
  int           x, y;           /* ¥¤¥Ù¥ó¥È¤¬µ¯¤³¤Ã¤¿ºÂɸ(windowÆâ) */
  int           x_root, y_root; /* ¥¤¥Ù¥ó¥È¤¬µ¯¤³¤Ã¤¿ºÂɸ(rootÆâ) */
  unsigned int  state;          /* ²¡¤µ¤ì¤Æ¤¤¤¿¥Ü¥¿¥ó¤ä½¤¾þ¥­¡¼ */
  unsigned int  button;         /* press¤¢¤ë¤¤¤Ïrelease¤µ¤ì¤¿¥Ü¥¿¥ó */
  Bool          same_screen;    /* ¥Þ¥¦¥¹¥«¡¼¥½¥ë¤¬window¤ÈƱ¥¹¥¯¥ê¡¼¥ó¤Ë¤¢¤ì¤ÐTrue */
} XButtonEvent;

typedef XButtonEvent XButtonPressedEvent;
typedef XButtonEvent XButtonReleaseEvent;

type ¤Ë¤Ï¥¤¥Ù¥ó¥È¤Î¼ïÎà( ButtonPress¡¢ButtonRelease )¤¬Æþ¤ê¡¢x¡¢y¤Ë¤Ï¥¤¥Ù¥ó¥È¤¬È¯À¸¤·¤¿¤È¤­¤Î¥Þ¥¦¥¹¥«¡¼¥½¥ë¤ÎºÂɸ¡¢x_root, y_root ¤Ë¤Ï¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤«¤é¸«¤¿¾ì¹ç¤Î¥Þ¥¦¥¹¥«¡¼¥½¥ë¤ÎºÂɸ¡¢window ¤Ë¤Ï¥¤¥Ù¥ó¥È¤¬È¯À¸¤·¤¿¥¦¥£¥ó¥É¥¦ ID ¤¬Æþ¤ê¤Þ¤¹¡£¤Þ¤¿¡¢button ¤Ë¤Ï¥Þ¥¦¥¹¥Ü¥¿¥ó¤ËÂбþ¤·¤¿Äê¿ô¤¬Æþ¤ê¤Þ¤¹(²¼É½»²¾È¡¢Ä̾ï¤Ï¤³¤ÎÄ̤ê¤Ç¤¹¤¬¡¢X ¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¤ÎÀßÄê¤Ë¤è¤Ã¤Æ³ä¤êÅö¤Æ¤òÊѹ¹¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹)¡£

º¸¥Ü¥¿¥ó¿¿Ãæ¥Ü¥¿¥ó±¦¥Ü¥¿¥ó
Button1 Button2 Button3

state ¤Ë¤Ï¡¢¥Ü¥¿¥ó¥¤¥Ù¥ó¥È¤¬È¯À¸¤·¤¿¤È¤­¤ËƱ»þ¤Ë²¡¤µ¤ì¤Æ¤¤¤ë¥â¥Ç¥£¥Õ¥¡¥¤¥¢¥­¡¼ ( Shift ¤ä Ctrl ¤Ê¤É¤Î¥­¡¼ )¤È¥Þ¥¦¥¹¥Ü¥¿¥ó¤Î¥Þ¥¹¥¯¤¬ÏÀÍýϤdzÊǼ¤µ¤ì¤Þ¤¹(²¼É½»²¾È¡¢¤Ê¤ª²¼É½¤¬Á´¤Æ¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó)¡£

¥â¥Ç¥£¥Õ¥¡¥¤¥¢¥­¡¼¤Þ¤¿¤Ï¥Ü¥¿¥ó¥Þ¥¹¥¯
¥·¥Õ¥È¥­¡¼ ShiftMask
¥í¥Ã¥¯¥­¡¼ LockMask
¥³¥ó¥È¥í¡¼¥ë¥­¡¼ ControlMask
¥á¥¿¥­¡¼ Mod1Mask
º¸¥Ü¥¿¥ó Button1Mask
¿¿Ãæ¥Ü¥¿¥ó Button2Mask
±¦¥Ü¥¿¥ó Button3Mask

¡û MotionNotify ¥¤¥Ù¥ó¥È

¥Þ¥¦¥¹¤¬°ÜÆ°¤·¤¿»þ¤Ë¤Ï MotionNotify ¥¤¥Ù¥ó¥È¤¬Á÷¤é¤ì¤ÆÍè¤Þ¤¹¡£XSelectInput() ¤Î°ú¿ô¤ËÍ¿¤¨¤ë¥¤¥Ù¥ó¥È¥Þ¥¹¥¯¤Ë PointerMotionMask ¤ä Button1MotionMask ¤Ê¤É¤Î MotionMask ¤òÀßÄꤷ¤Æ¤ª¤¯¤È¡¢¥Þ¥¦¥¹¤¬°ÜÆ°¤¹¤ë¤¿¤Ó¤Ë¥¤¥Ù¥ó¥È¤¬Á÷¤é¤ì¤ÆÍè¤Þ¤¹¡£

ÁÛÁü¤Ç¤­¤ë¤è¤¦¤Ë¡¢MotionNotify ¥¤¥Ù¥ó¥È¤ÏÂçÎ̤Υ¤¥Ù¥ó¥È¤òȯÀ¸¤·¤Þ¤¹¡£Æ°¤¤¤Æ¤¤¤ë¤È¤¤¤¦¤³¤È¤¬Ê¬¤«¤ì¤Ð½¼Ê¬¤Ç¤¢¤Ã¤Æ¡¢Á´¤Æ¤Î°ÜÆ°¤òÃΤ뤳¤È¤¬É¬¤º¤·¤âɬÍפʤ櫓¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£¤³¤Î¤è¤¦¤Ê¾ì¹ç¤Ë¤Ï¡¢¥¤¥Ù¥ó¥È¥Þ¥¹¥¯¤Ë MotionMask ¤È PointerMotionHintMask ¤ÎÏÀÍýϤò»ØÄꤹ¤ë¤È¡¢MotionNotify ¥¤¥Ù¥ó¥È¤¬°µ½Ì¤µ¤ì¤ÆϢ³¤·¤¿¥Þ¥¦¥¹¥«¡¼¥½¥ë¤ÎÆ°¤­¤ËÂФ·¤Æ 1 ¸Ä¤Î MotionNotify ¥¤¥Ù¥ó¥È¤¬Á÷¤é¤ì¤ÆÍè¤Þ¤¹¡£¤³¤Î°µ½Ì¤µ¤ì¤¿¥¤¥Ù¥ó¥È¤ò¥Ò¥ó¥È¥¤¥Ù¥ó¥È¤È¤¤¤¤¤Þ¤¹¡£

Á÷¤é¤ì¤Æ¤­¤¿ MotionNotify ¥¤¥Ù¥ó¥È¤¬¥Ò¥ó¥È¥¤¥Ù¥ó¥È¤«¤É¤¦¤«¤òÃΤꤿ¤¤»þ¤Ë¤Ï¡¢MotionNotify ¥¤¥Ù¥ó¥È¹½Â¤ÂΤΠis_hint ¥á¥ó¥Ð¤òÄ´¤Ù¤Þ¤¹¡£°µ½Ì¤µ¤ì¤¿¥Ò¥ó¥È¥¤¥Ù¥ó¥È¤Î¾ì¹ç¤Ë¤Ï¡¢is_hint ¥á¥ó¥Ð¤Ë NotifyHint ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Þ¤¹(°µ½Ì¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï NotifyNormal )¡£¤Ê¤ª¡¢¥Ò¥ó¥È¥¤¥Ù¥ó¥È¤ò¼õ¤±¼è¤Ã¤¿¾ì¹ç¤Ï ¸½ºß¤Î¥Þ¥¦¥¹¥«¡¼¥½¥ë¤ÎºÂɸ¤ò¼«Ê¬¤ÇÄ´¤Ù¤ëɬÍפ¬¤¢¤ê¤Þ¤¹(¤É¤Î°ÌÃ֤ξì¹ç¤Î¥¤¥Ù¥ó¥È¤¬Í褿¤«Ê¬¤«¤é¤Ê¤¤¤«¤é)¤¬¡¢¤³¤ì¤Ë¤Ï XQueryPointer() ¤ò»È¤¤¤Þ¤¹¡£

Bool XQueryPointer( Display*      display,
                    Window        w, 
                    Window*       root_return, 
                    Window*       child_return, 
                    Window*       root_x_return, 
                    Window*       root_y_return, 
                    int*          win_x_return, 
                    int*          win_y_return, 
                    unsigned int* mask_return 
                  );

root_return                 : ¥Þ¥¦¥¹¥«¡¼¥½¥ë¤ò´Þ¤à¥ë¡¼¥È¥¦¥£¥ó¥É¥¦
child_return                : ¥Þ¥¦¥¹¥«¡¼¥½¥ë¤ò´Þ¤à»Ò¥¦¥£¥ó¥É¥¦
root_x_return,root_y_return : ¥ë¡¼¥È¥¦¥£¥ó¥É¥¦ºÂɸ·Ï¤Ç¤Î¥Þ¥¦¥¹¤Î°ÌÃÖ
win_x_return, win_y_return  : »ØÄꥦ¥£¥ó¥É¥¦ºÂɸ·Ï¤Ç¤Î¥Þ¥¦¥¹¤Î°ÌÃÖ
mask_return                 : ¥â¥Ç¥£¥Õ¥¡¥¤¥¢¥­¡¼¤È¥Þ¥¦¥¹¥Ü¥¿¥ó¤Î¸½ºß¾õÂÖ

»ØÄꤷ¤¿¥¦¥£¥ó¥É¥¦ win ¤ÈƱ¤¸¥¹¥¯¥ê¡¼¥ó¤Ë¥Þ¥¦¥¹¥«¡¼¥½¥ë¤¬Ìµ¤¤¾ì¹ç¤Ë¡¢XQueryPointer() ¤Ï False ¤òÊÖ¤·¤Þ¤¹¡£

PointerMotionHintMask ¤Ç¤Ï¤Ê¤¯ Button1MotionMask ¡Á Button5MotionMask ¤ò»È¤¦¤È¡¢Âбþ¤¹¤ë¥Þ¥¦¥¹¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Î¤ß MotionNotify ¥¤¥Ù¥ó¥È¤¬Á÷¤é¤ì¤ÆÍè¤Þ¤¹¡£

¡û ¥Þ¥¦¥¹¥«¡¼¥½¥ë¤Î¥°¥é¥Ö

Ä̾¥Þ¥¦¥¹¤Ë´Ø¤¹¤ë¥¤¥Ù¥ó¥È¤Ï¥Þ¥¦¥¹¥«¡¼¥½¥ë¤¬¤¢¤ë¥¦¥£¥ó¥É¥¦¤ËÁ÷¤é¤ì¤Þ¤¹¡£¥Ü¥¿¥ó¥¤¥Ù¥ó¥È¤Î¤ß¤ò°·¤¦¾ì¹ç¤Ç¤¢¤ì¤ÐÆäËÌäÂꤢ¤ê¤Þ¤»¤ó¤¬¡¢¥Þ¥¦¥¹¥Ü¥¿¥ó¤ò²¡¤·¤¿¤Þ¤Þ¤Î MotionNotify ¥¤¥Ù¥ó¥È¤ò°·¤¦¤è¤¦¤Ê¾ì¹ç¤Ë¤ÏÌäÂ꤬À¸¤¸¤ë¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¡£

Î㤨¤Ð¡¢¥Þ¥¦¥¹¥Ü¥¿¥ó¤ò²¡¤¹¤È¥á¥Ë¥å¡¼¥¦¥£¥ó¥É¥¦¤¬É½¼¨¤µ¤ì¡¢²¡¤·¤¿¤Þ¤Þ¥á¥Ë¥å¡¼¹àÌܤòÁªÂò¤·¤ÆÎ¥¤¹¤È¤½¤Î¹àÌܤ¬ÁªÂò¤µ¤ì¤ë¡¢¤È¤¤¤¦ UI ¤ò¹Í¤¨¤Þ¤¹¡£¤³¤Î¾ì¹ç¡¢¥Þ¥¦¥¹¥Ü¥¿¥ó¤ò²¡¤·¤¿¤Þ¤Þ¥á¥Ë¥å¡¼¥¦¥£¥ó¥É¥¦¤Î³°¤Ë¥Þ¥¦¥¹¤ò°ÜÆ°¤·¤Æ¥Ü¥¿¥ó¤òÎ¥¤¹¤È¡¢ButtonRelease ¥¤¥Ù¥ó¥È¤¬¥á¥Ë¥å¡¼¥¦¥£¥ó¥É¥¦¤ËÁ÷¤é¤ì¤º¤Ë¥á¥Ë¥å¡¼¹àÌܤ¬ÁªÂò¤µ¤ì¤Ê¤¤¤Ð¤«¤ê¤«¥Þ¥¦¥¹¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤Þ¤Þ¤È¤¤¤¦¾õÂÖ¤ÎÉÔÀ°¹ç¤¬µ¯¤³¤Ã¤Æ¤·¤Þ¤¤¤Þ¤¹( LeaveNotify ¥¤¥Ù¥ó¥È¤ò»È¤Ã¤Æ¡¢¥¦¥£¥ó¥É¥¦¤«¤é¥Þ¥¦¥¹¥«¡¼¥½¥ë¤¬½Ð¤¿½Ö´Ö¤Ë¥á¥Ë¥å¡¼¥¦¥£¥ó¥É¥¦¤òÊĤ¸¤ë¤È¤¤¤¦ UI ¤Ë¤¹¤ì¤ÐÌäÂê̵¤µ¤½¤¦¤Ç¤¹¤±¤É¤Í)¡£

¤³¤Î¤è¤¦¤Ê¾ì¹ç¡¢¥Þ¥¦¥¹¥«¡¼¥½¥ë¤¬¤É¤³¤Ë¤¢¤Ã¤Æ¤â¤½¤Î¥¤¥Ù¥ó¥È¤¬ÆÃÄê¤Î¥¦¥£¥ó¥É¥¦¤ËÁ÷¤é¤ì¤ë¤è¤¦¤Ë¡¢X ¥µ¡¼¥Ð¤ËÍ׵᤹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¤³¤ì¤ò¥°¥é¥Ö¤¹¤ë¤È¤¤¤¤¤Þ¤¹¡£¤¿¤À¤·¡¢¥°¥é¥Ö¤ÏÆÃÄê¤Î¥¦¥£¥ó¥É¥¦¤¬¥¤¥Ù¥ó¥È¤òÀêÍ­¤¹¤ë¤¿¤á¡¢É¬ÍפʤȤ­¤Ë¥°¥é¥Ö¤ò³«»Ï¤·¡¢½èÍý¤¬½ª¤Ã¤¿¤é®¤ä¤«¤Ë²ò½ü¤·¤Ê¤¯¤Æ¤Ï¤Ê¤ê¤Þ¤»¤ó¡£

¥°¥é¥Ö¤ò³«»Ï¤¹¤ë¤Ë¤Ï XGrabPointer() ¤ò»È¤¤¤Þ¤¹¡£

int XGrabPointer( Display*     display, 
                  Window       grab_window, 
                  Bool         owner_events, 
                  unsigned int event_mask,
                  int          pointer_mode, 
                  int          keyboard_mode, 
                  Window       confine_to, 
                  Cursor       cursor, 
                  Time         time 
                );

grab_window   : ¥°¥é¥ÖÃ楤¥Ù¥ó¥È¤¬ÄÌÃΤµ¤ì¤ë¥¦¥£¥ó¥É¥¦
owner_events  : ¥°¥é¥ÖÃæ¤ËɬÍפΤʤ¤¥¤¥Ù¥ó¥È¤Î°·¤¤
event_mask    : ¥°¥é¥ÖÃæ¤ËÄÌÃΤ¹¤ë¥¤¥Ù¥ó¥È
pointer_mode  : ¥°¥é¥Ö¸å¤Î¥Ý¥¤¥ó¥¿¥¤¥Ù¥ó¥È¤ÎÀ©¸æ
keyboard_mode : ¥°¥é¥Ö¸å¤Î¥­¡¼¥Ü¡¼¥É¥¤¥Ù¥ó¥È¤ÎÀ©¸æ 
confine_to    : ¥Þ¥¦¥¹¥«¡¼¥½¥ë¤ò¤½¤ÎÃæ¤ËÀ©¸Â¤·¤¿¤¤¥¦¥£¥ó¥É¥¦
cursor        : ¥°¥é¥ÖÃæ¤Ëɽ¼¨¤¹¤ë¥Þ¥¦¥¹¥«¡¼¥½¥ë
time          : ¥¿¥¤¥à¥¹¥¿¥ó¥×

cursor ¤Ë¤Ï¥°¥é¥ÖÃæ¤Ë»ÈÍѤ¹¤ë¥Þ¥¦¥¹¥«¡¼¥½¥ë¤ò¥ê¥½¡¼¥¹ ID ¤Ç»ØÄꤷ¤Þ¤¹¡£¤³¤ì¤Ë¤Ä¤¤¤Æ¤Ï¡¢¼¡¤Î¥Õ¥©¥ó¥È¥«¡¼¥½¥ë¤Î»ÈÍÑË¡¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£time ¤Ï¥°¥é¥Ö¤ò³«»Ï¤·¤¿»þ¹ï¤ò»ØÄꤷ¤Þ¤¹¡£¸½ºß¤Î»þ¹ï¤ò»ØÄꤷ¤¿¤¤¾ì¹ç¤Ë¤Ï¡¢Äê¿ô¤Î CurrentTime ¤ò»ØÄꤷ¤Þ¤¹¡£confine_to ¤Ï¡¢¥Þ¥¦¥¹¥«¡¼¥½¥ë¤ò¤¢¤ëÆÃÄê¤Î¥¦¥£¥ó¥É¥¦¤«¤é³°¤Ë½Ð¤·¤¿¤¯¤Ê¤¤¾ì¹ç¤Ë¤½¤Î¥¦¥£¥ó¥É¥¦ID ¤ò»ØÄꤷ¤Þ¤¹¡£pointer_mode ¤È keyboard_mode ¤Ï¥°¥é¥ÖÃæ¤Î¥Þ¥¦¥¹¥¤¥Ù¥ó¥È¤ä¥­¡¼¥Ü¡¼¥É¤Î½èÍý¤òÀ©¸æ¤·¤Þ¤¹¡£Ä̾ï¤Ï GrabModeAsync ¤ò»ØÄꤷ¤Þ¤¹¡£¤³¤ì¤Ï¥°¥é¥ÖÃæ¤Ë¥Þ¥¦¥¹¥¤¥Ù¥ó¥È¤ä¥­¡¼¥Ü¡¼¥É¥¤¥Ù¥ó¥È¤òÀµ¾ï¤Ë½èÍý¤¹¤ë¤³¤È¤ò°ÕÌ£¤·¤Æ¤¤¤Þ¤¹¡£owner_events ¤Ë¤Ï False ¤« True ¤ò»ØÄꤷ¤Þ¤¹¡£False ¤ò»ØÄꤹ¤ë¤È¥Þ¥¦¥¹¥¤¥Ù¥ó¥È¤ÎÄÌÃÎ¤Ï grab_window ¤Ë´Ø¤·¤Æ¤·¤«¹Ô¤ï¤ì¤Þ¤»¤ó¡£True ¤ò»ØÄꤹ¤ë¤È¡¢´û¤Ë¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ÇÁªÂò¤·¤Æ¤¤¤¿¥¤¥Ù¥ó¥È¤Ï¥°¥é¥Ö¤Î±Æ¶Á¤ò¼õ¤±¤º¤ËÄÌÃΤµ¤ì¤Þ¤¹¡£

¥°¥é¥Ö¤ËÀ®¸ù¤·¤¿¾ì¹ç¡¢GrabSuccess ¤¬ÊÖ¤ê¤Þ¤¹¡£

¥°¥é¥Ö¤ÎɬÍפ¬¤Ê¤¯¤Ê¤Ã¤¿¤é®¤ä¤«¤Ë¥°¥é¥Ö¤ò²ò½ü¤·¤Þ¤¹¡£¼¡¤Î¤¤¤º¤ì¤«¤ò¹Ô¤¦¤³¤È¤Ë¤è¤Ã¤Æ¥°¥é¥Ö¤Ï²ò½ü¤µ¤ì¤Þ¤¹¡£

  1. grab_window ¤« confine_window ¤ò¥¢¥ó¥Þ¥Ã¥×¤¹¤ë
  2. XUngrabPointer() ¤ò¼Â¹Ô¤¹¤ë
XUngrabPointer( Display* display, Time time );
time; /* ¥¿¥¤¥à¥¹¥¿¥ó¥× */

¥°¥é¥ÖÁàºî¤Ë¤Ï¡¢¥Þ¥¦¥¹¥«¡¼¥½¥ë°Ê³°¤Ë¤â¥Þ¥¦¥¹¥Ü¥¿¥ó¤ò¥°¥é¥Ö¤¹¤ë XGrabButton()¡¢¥­¡¼¥Ü¡¼¥É¤ò¥°¥é¥Ö¤¹¤ë XGrabKeyboard()¡¢ÆÃÄê¤Î¥­¡¼¤ò¥°¥é¥Ö¤¹¤ë XGrabKey() ¤¬¤¢¤ê¤Þ¤¹¡£

¡û ¥Õ¥©¥ó¥È¥«¡¼¥½¥ë¤Î»ÈÍÑË¡

Xlib ¤Ç¤Ï¥Õ¥©¥ó¥È¥«¡¼¥½¥ë¤È¤¤¤¦¤â¤Î¤¬É¸½à¤Ç¿¿ôÍÑ°Õ¤µ¤ì¤Æ¤¤¤Æ¡¢¥Þ¥¦¥¹¥«¡¼¥½¥ë¤Ë¤³¤Î¥Õ¥©¥ó¥È¥«¡¼¥½¥ë¤Î·Á¾õ¤òÀßÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¥Õ¥©¥ó¥È¥«¡¼¥½¥ë¤Ï <X11/cursorfont.h> ¤Ë¤ª¤¤¤ÆÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤¹(Àµ³Î¤Ë¤Ï¡¢¥Õ¥©¥ó¥È¥«¡¼¥½¥ë¤ò»ØÄꤹ¤ë¤¿¤á¤ÎÄê¿ô¤¬ÄêµÁ¤µ¤ì¤Æ¤ª¤ê¡¢¥Õ¥©¥ó¥È¥«¡¼¥½¥ë¤ÎËÜÂΤÏÊ̤ËÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤¹)¡£

¤³¤Î¥Õ¥©¥ó¥È¥«¡¼¥½¥ë¤ò¥Þ¥¦¥¹¥«¡¼¥½¥ë¤ËÀßÄꤹ¤ë¤Ë¤Ï¡¢¤Þ¤º¥Õ¥©¥ó¥È¥«¡¼¥½¥ë¤ò¥í¡¼¥É¤·¤Æ Cursor ·¿¤Î¥ê¥½¡¼¥¹¤ËÊÑ´¹¤·¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£¤³¤ì¤Ë¤Ï XCreateFontCursor() ¤ò»È¤¤¤Þ¤¹¡£

Cursor XCreateFontCursor( Display* display, unsigned int shape );
shape : <X11/cursorfont.h> Æâ¤ËÄêµÁ¤µ¤ì¤¿¥«¡¼¥½¥ë·Á¾õ̾¤ò»ØÄꤹ¤ë

(Îã)
  Cursor cursor;
  cursor = XCreateFontCursor( dpy, XC_arrow );

¤³¤Î¤è¤¦¤Ë¤·¤ÆºîÀ®¤·¤¿ Cursor ¤ò¥¦¥£¥ó¥É¥¦¤ËŬÍѤ¹¤ë¤Ë¤Ï¡¢XDefineCursor() ¤ò»È¤¤¤Þ¤¹¡£¤Þ¤¿¡¢¤½¤ì¤ò²ò½ü¤¹¤ë¤Ë¤Ï XUndefineCursor() ¤ò»È¤¤¤Þ¤¹¡£XUndefineCursor() ¤ò¼Â¹Ô¤¹¤ë¤È¡¢°Ê¸å¤Ï¿Æ¥¦¥£¥ó¥É¥¦¤Î¥«¡¼¥½¥ë¤¬»ÈÍѤµ¤ì¤Þ¤¹¡£

XDefineCursor( Display* display, Window w, Cursor cursor );
XUndefineCursor( Display* display, Window w );

¤Ê¤ª¡¢Á°½Ò¤Î XGrabPointer() ¤Î°ú¿ô¤Ç¤¢¤ë cursor ¤Ë¤³¤Î¤è¤¦¤Ë¤·¤ÆºîÀ®¤·¤¿ Cursor ¤ò»ØÄꤹ¤ì¤Ð¡¢¥°¥é¥Ö»þ¤Ë¤Ï¤³¤Î¥Þ¥¦¥¹¥«¡¼¥½¥ë¤¬»ÈÍѤµ¤ì¤Þ¤¹¡£