LECTURE 13 ¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¤È¤Î¤ä¤ê¤È¤ê

¡û ¤Ï¤¸¤á¤Ë

¤³¤³¤Þ¤Ç¤Î LECTURE ¤ÇºîÀ®¤·¤¿¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤Î²èÁü¤ò¸«¤ë¤È¡¢¥¿¥¤¥È¥ë¥Ð¡¼¤Ë "Untitled" ¤ÈÉÁ¤«¤ì¤Æ¤¤¤Þ¤¹¡£¼«Ê¬¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤òºî¤Ã¤¿»þ¤Ë¤½¤Î¥¿¥¤¥È¥ë¤¬ "Untitled" ¤Ç¤ÏÈᤷ¤¤¤Ç¤¹¤Í¡£¡£¡£¤È¤³¤í¤Ç¤³¤Î¥¿¥¤¥È¥ë¥Ð¡¼¤Ï¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¤Ë¤è¤Ã¤Æ¤Ä¤±¤é¤ì¤¿¤â¤Î¤Ê¤Î¤Ç¡¢»ØÄꤷ¤¿¥¿¥¤¥È¥ë¤ò¥¿¥¤¥È¥ë¥Ð¡¼¤Ëɽ¼¨¤¹¤ë¤¿¤á¤Ë¤Ï¡¢¥×¥í¥°¥é¥à¤«¤é¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¤ËɬÍפʾðÊó¤ò¶µ¤¨¤Ê¤±¤ì¤Ð¤¤¤±¤Þ¤»¤ó¡£

¤³¤³¤Ç¤Ï¥¿¥¤¥È¥ë¥Ð¡¼¤Ëɽ¼¨¤¹¤ëʸ»úÎó¤Ë¸Â¤é¤º¡¢ÍÍ¡¹¤Ê¾ðÊó¤ò¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¤È¤ä¤ê¤È¤ê¤¹¤ëÊýË¡¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Æ¤¤¤­¤Þ¤¹¡£

¡û ¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à(¥¿¥¤¥È¥ëʸ»úÎó¤Îɽ¼¨¡¢XSetWMProperties() )

¥¿¥¤¥È¥ë¥Ð¡¼¤Ë "Sample Program!" ¤Èɽ¼¨¤¹¤ë¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à xwm.c ¤Ç¤¹¡£²¼¿Þ¤Ë¤ª¤¤¤Æ¡¢»ØÄꤷ¤¿Ê¸»úÎ󤬤Á¤ã¤ó¤È¥¿¥¤¥È¥ë¥Ð¡¼¤Ëɽ¼¨¤µ¤ì¤Æ¤¤¤ë¤³¤È¤¬Ê¬¤«¤ê¤Þ¤¹¡£¤Ï¤¸¤á¤Ë ¤Î¥Ú¡¼¥¸¤«¤é¡¢Á´¤Æ¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ò¸Ç¤á¤¿ tar ¥Ü¡¼¥ë¤ò¥À¥¦¥ó¥í¡¼¥É¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£

013wm.jpg

--- xwm.c ---

    1	#include <X11/Xlib.h> 
    2	#include <X11/Xutil.h>  /* for XTextProperty */
    3	#include <X11/Xatom.h>  /* for XA_STRING     */
    4	#include <string.h>
    5	
    6	
    7	#define WIN_W   400  /* ¥¦¥£¥ó¥É¥¦¤ÎÉý   */
    8	#define WIN_H   300  /* ¥¦¥£¥ó¥É¥¦¤Î¹â¤µ */
    9	#define WIN_X   100  /* ¥¦¥£¥ó¥É¥¦É½¼¨°ÌÃÖ(X) */
   10	#define WIN_Y   100  /* ¥¦¥£¥ó¥É¥¦É½¼¨°ÌÃÖ(Y) */
   11	#define BORDER  2    /* ¥Ü¡¼¥À¤ÎÉý      */
   12	
   13	
   14	int 
   15	main( int argc, char** argv )
   16	{
   17		Display*       dpy;          /* ¥Ç¥£¥¹¥×¥ì¥¤ */
   18		Window         root;         /* ¥ë¡¼¥È¥¦¥£¥ó¥É¥¦ */
   19		Window         win;          /* ɽ¼¨¤¹¤ë¥¦¥£¥ó¥É¥¦ */
   20		int            screen;       /* ¥¹¥¯¥ê¡¼¥ó */
   21		unsigned long  black, white; /* ¹õ¤ÈÇò¤Î¥Ô¥¯¥»¥ëÃÍ */
   22		XEvent         evt;
   23		XTextProperty  w_name;       /* ¥¦¥£¥ó¥É¥¦Ì¾¤Ê¤É¤òÀßÄꤹ¤ë */
   24	
   25		dpy = XOpenDisplay( "" );
   26	
   27		root   = DefaultRootWindow( dpy );
   28		screen = DefaultScreen( dpy );
   29		white  = WhitePixel( dpy, screen );
   30		black  = BlackPixel( dpy, screen );
   31	
   32		win = XCreateSimpleWindow( dpy, root,
   33			   WIN_X, WIN_Y, WIN_W, WIN_H, BORDER, black, white );
   34	
   35		/* ¥¦¥£¥ó¥É¥¦Ì¾¤Î»ØÄê */
   36		w_name.value    = (unsigned char*)"Sample program!";
   37		w_name.encoding = XA_STRING;
   38		w_name.format   = 8;
   39		w_name.nitems   = strlen( "Sample program!" );
   40	
   41		/* ¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¤Ë¾ðÊó¤òÄÌÃΤ¹¤ë */
   42		XSetWMProperties( dpy, win, &w_name, NULL, argv, argc, NULL, NULL, NULL );
   43	
   44		XSelectInput( dpy, win, KeyPressMask );
   45		XMapWindow( dpy, win );
   46	
   47		while( 1 ) {
   48			XNextEvent( dpy, &evt );
   49	      
   50			switch ( evt.type ) {
   51				case KeyPress :
   52					/* ¥ê¥½¡¼¥¹¤Î²òÊü */
   53					XDestroyWindow( dpy, win );
   54					XCloseDisplay( dpy );
   55					return 0;
   56			}
   57		}
   58	}
   59	
   60	/* End of xwm.c */

¡û ¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ÎÀâÌÀ

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

  • 2 ¡Á 3 ¹ÔÌÜ

    ¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¤È¥¿¥¤¥È¥ë̾¤Ê¤É¤ò¤ä¤ê¤È¤ê¤¹¤ëºÝ¤Ë»ÈÍѤ¹¤ë XTextProperty ¹½Â¤ÂΤȡ¢ XTextProperty ¹½Â¤ÂΤΥá¥ó¥Ð¤ËÀßÄꤹ¤ëÄê¿ô¤ÎÄêµÁ¤ò»²¾È¤¹¤ë¤¿¤á¤Î¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤ò¥¤¥ó¥¯ ¥ë¡¼¥É¤·¤Æ¤¤¤Þ¤¹¡£

  • 23 ¹ÔÌÜ

    XTextProperty ¹½Â¤ÂΤÎÊÑ¿ô¤òÀë¸À¤·¤Æ¤¤¤Þ¤¹¡£¤³¤ÎÊÑ¿ô¤ËɬÍפʾðÊó¤òÀßÄꤷ¤Æ¡¢¥¦¥£¥ó¥É¥¦ ¥Þ¥Í¡¼¥¸¥ã¤ËÄÌÃΤ·¤Þ¤¹¡£

  • 35 ¡Á 39 ¹ÔÌÜ

    ¤Þ¤º¡¢XTextProperty ¹½Â¤ÂÎÊÑ¿ô¤Î w_name ¤ËÃͤòÀßÄꤷ¤Æ¤¤¤Þ¤¹¡£XTextProperty ¹½Â¤ÂΤϡ¢ ¼¡¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£

      typedef struct {
        unsigned char* value;    /* ʸ»úÎó */
        Atom           encoding; /* XA_STRING ¤ò»ØÄê */
        int            format;   /* Ⱦ³Ñ±Ñ¿ô»ú¤òÀßÄꤹ¤ë¾ì¹ç¡¢8 ¤ò»ØÄê
                                   ( 8 ¥Ó¥Ã¥È¤Î¥Ç¡¼¥¿ÇÛÎó¤È¤·¤Æ°·¤¦ ) */
        unsigned long  nitems;   /* value ¤Îʸ»ú¿ô */
      } XTextProperty;
    
    

    ¾å¤ÎÆâÍƤ˽¾¤Ã¤Æ¡¢"Sample program!" ¤È¤¤¤¦Ê¸»úÎó¤Ë¤Ä¤¤¤Æ¤Î¾ðÊó¤òÀßÄꤷ¤Æ¤¤¤Þ¤¹¡£

    ÀßÄꤷ¤¿Ãͤò¥¦¥£¥ó¥É¥¦¤Î¥¿¥¤¥È¥ë¥Ð¡¼¤Ëɽ¼¨¤·¤Æ¤â¤é¤¦¤¿¤á¤Ë¡¢¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¤ËÄÌÃÎ ¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¤¬¡¢¤³¤ì¤Ë¤Ï XSetWMProperties() ¤ò»È¤Ã¤Æ¤¤¤Þ¤¹¡£

      void XSetWMProperties( Display*       dpy,
                             Window         w,
                             XTextProperty* window_name,
                             XTextProperty* icon_name,
                             char**         argv,
                             int            argc,
                             XSizeHints*    notmal_hints,
                             XWMHints*      wm_hints,
                             XClassHint*    class_hints
                           );
    
      window_name  : ¥¦¥£¥ó¥É¥¦Ì¾
      icon_name    : ¥¢¥¤¥³¥ó̾
      argv         : ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î°ú¿ô
      argc         : °ú¿ô¤Î¸Ä¿ô
      normal_hints : ¥¦¥£¥ó¥É¥¦¤ÎÂ礭¤µ
      wm_hints     : WM¥Ò¥ó¥È
      class_hints  : ¥¯¥é¥¹¥Ò¥ó¥È
    
    

    ¾å¤Î³Æ°ú¿ô¤Ë¤Ä¤¤¤Æ¡¢¤É¤Î¤è¤¦¤Ê¾ðÊó¤òÍ¿¤¨¤ë¤³¤È¤¬¤Ç¤­¤ë¤Î¤«¤ò°Ê²¼¤Ë¼¨¤·¤Þ¤¹¡£

    • window_name

      ¥¦¥£¥ó¥É¥¦Ì¾(¥¿¥¤¥È¥ë¥Ð¡¼¤Ëɽ¼¨¤¹¤ëʸ»úÎó)¤ò»ØÄꤷ¤Þ¤¹¡£ÀßÄê¤ÎÊýË¡¤Ï¡¢¥µ¥ó¥×¥ë¥×¥í¥° ¥é¥à¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£

    • icon_name

      ¥¢¥¤¥³¥ó²½¤µ¤ì¤¿¾ì¹ç¤Ë»ÈÍѤ¹¤ë̾Á°¤ò¡¢window_name ¤ÈƱÍͤÎÊýË¡¤Ç»ØÄꤷ¤Þ¤¹¡£

    • argc, argv

      main( argc, argv ) ¤Ç»ØÄꤵ¤ì¤¿¤â¤Î¤ò¤½¤Î¤Þ¤ÞÅϤ·¤Þ¤¹¡£

    • normal_hints

      ¥¦¥£¥ó¥É¥¦¤ÎÂ礭¤µ¡¢°ÌÃÖ¡¢¥ê¥µ¥¤¥º¤Îñ°Ì¡¢¥¦¥£¥ó¥É¥¦¤Î½Ä²£Èæ¤È¤¤¤Ã¤¿¾ðÊó¤ò¥Î¡¼¥Þ¥ë¥Ò ¥ó¥È¤È¤¤¤¤¤Þ¤¹¡£¥Î¡¼¥Þ¥ë¥Ò¥ó¥È¤Ï XSizeHints ¹½Â¤ÂΤò»È¤Ã¤ÆÀßÄꤷ¤Þ¤¹¡£

          #include <X11/Xutil.h> /* XSizeHints */
      
          typedef struct
          {
            long   flags;                 /* ¤É¤Î¥á¥ó¥Ð¤ËÃͤò»ØÄꤷ¤¿¤« */
            int    x, y;                  /* ¥¦¥£¥ó¥É¥¦¤Î°ÌÃÖ */
            int    width, height;         /* ¥¦¥£¥ó¥É¥¦¤ÎÉý¤È¹â¤µ */
            int    min_width, min_height; /* ºÇ¾®¥µ¥¤¥º */
            int    max_width, max_height; /* ºÇÂ祵¥¤¥º */
            int    width_inc, height_inc; /* ¥ê¥µ¥¤¥º»þ¤ÎÁýʬ */
      
            struct
            {
              int x; /* ¥¦¥£¥ó¥É¥¦¤ÎºÇ¾®(Âç)¤Î½Ä²£Èæ(x:y) */
              int y;
            }min_aspect, max_aspect;
          } XSizeHints;  
      
      

      flags ¤Ë¤Ï¤É¤Î¥á¥ó¥Ð¤ËÃͤòÀßÄꤷ¤¿¤«¤òÀßÄꤷ¤Þ¤¹¡£flags ¤ËÀßÄꤹ¤ëÃͤȥá¥ó¥Ð¤ÎÂбþ¤Ï °Ê²¼¤ÎÄ̤ê¤Ç¤¹¡£

      ¹½Â¤ÂΤΥá¥ó¥Ð flags
      x, y USPosition ¤Þ¤¿¤Ï PPosition
      width, height USSize ¤Þ¤¿¤Ï PSize
      min_width, min_height PMinSize
      max_width, max_height PMaxSize
      width_inc, height_inc PResizeInc
      min_aspect, max_aspect PAspect

    • wm_hints

      ¥¯¥é¥¤¥¢¥ó¥È¤Î¥­¡¼¥Ü¡¼¥É¥Õ¥©¡¼¥«¥¹¥â¥Ç¥ë¡¢½é´üÆ°ºî¾õÂÖ(ɸ½à¡¢¤â¤·¤¯¤Ï¥¢¥¤¥³¥ó) ¡¢ ¥¢¥¤¥³¥ó¤Ë»È¤¦¥Ô¥¯¥¹¥Þ¥Ã¥×¤ä¥¦¥£¥ó¥É¥¦¡¢¥¢¥¤¥³¥ó¤Î½é´ü°ÌÃ֤ʤɤòÀßÄꤷ¤Þ¤¹¡£ ÀßÄê¤Ï XWMHints ¹½Â¤ÂΤò»È¤Ã¤Æ¹Ô¤¤¤Þ¤¹¡£

          #include <X11/Xutil.h> /* XWMHints */
      
          typedef struct
          {
            long   flags;            /* ¤É¤Î¥á¥ó¥Ð¤ËÃͤò»ØÄꤷ¤¿¤« */
            Bool   input;            /* ¥¯¥é¥¤¥¢¥ó¥È¤¬»ÈÍѤ¹¤ë¥­¡¼¥Ü¡¼¥É¥Õ¥©¡¼¥«¥¹¥â¥Ç¥ë */
            int    initial_state;    /* ½é´ü¾õÂÖ¤¬É¸½à¤«¥¢¥¤¥³¥ó¤« */
            Pixmap icon_pixmap;      /* ¥¢¥¤¥³¥ó¤Ë»È¤ï¤ì¤ë¥Ô¥¯¥¹¥Þ¥Ã¥× */
            Window icon_window;      /* ¥¢¥¤¥³¥ó¤Ë»È¤ï¤ì¤ë¥¦¥£¥ó¥É¥¦ */
            int    icon_x, icon_y;   /* ¥¢¥¤¥³¥ó¤Î½é´üɽ¼¨°ÌÃÖ */
            Pixmap icon_mask;        /* icon_pixmap ¤ËÂФ¹¤ë¥Þ¥¹¥¯ */
            XID    window_group;     /* ¥¦¥£¥ó¥É¥¦¥°¥ë¡¼¥×¤Ë´Ø·¸¤¹¤ë ID */
          } XWMHints;  
      
      

      flags ¤Ë¤Ï¤É¤Î¥á¥ó¥Ð¤ËÃͤòÀßÄꤷ¤¿¤«¤òÀßÄꤷ¤Þ¤¹¡£flags ¤ËÀßÄꤹ¤ëÃͤȥá¥ó¥Ð¤ÎÂбþ¤Ï ²¼É½¤ÎÄ̤ê¤Ç¤¹¡£

      ¹½Â¤ÂΤΥá¥ó¥Ðflags
      input InputHint
      initial_state StateHint
      icon_pixmap IconPixmapHint
      icon_window IconWindowHint
      icon_x, icon_yIconPositionHint
      icon_mask IconMaskHint
      window_group WindowGroupHint
      Á´¤Æ AllHint

      input ¤Ë¤Ï¡¢¥¯¥é¥¤¥¢¥ó¥È¤¬»ÈÍѤ¹¤ë¥­¡¼¥Ü¡¼¥É¥Õ¥©¡¼¥«¥¹¥â¥Ç¥ë¤ò»ØÄꤷ¤Þ¤¹¡£ °Ê²¼¤Î¤¤¤º¤ì¤«¤ò»ØÄꤷ¤Þ¤¹¡£

      input ÃÍ ¥Õ¥©¡¼¥«¥¹¥â¥Ç¥ë ÀâÌÀ
      True Passive Input ¥­¡¼¥Ü¡¼¥É¥Õ¥©¡¼¥«¥¹¤ÏÀßÄꤷ¤Ê¤¤¤¬¥­¡¼¥Ü¡¼¥ÉÆþÎϤÏɬÍ×
      True Locally Active Input ¥­¡¼¥Ü¡¼¥ÉÆþÎϤ¬É¬Íפ«¤Ä¥¯¥é¥¤¥¢¥ó¥È¤Î¥¦¥£¥ó¥É¥¦¤Î1¤Ä¤¬´û¤Ë¥Õ¥©¡¼¥«¥¹ ¤ò»ý¤Ã¤Æ¤¤¤ë¤È¤­¤À¤±¥­¡¼¥Ü¡¼¥É¥Õ¥©¡¼¥«¥¹¤òÀßÄꤹ¤ë
      False Globally Active Input ¥­¡¼¥Ü¡¼¥ÉÆþÎϤ¬É¬Íפ«¤Ä¤Û¤«¤Î¥¯¥é¥¤¥¢¥ó¥È¤Î¥¦¥£¥ó¥É¥¦¤Ë¥Õ¥©¡¼¥«¥¹¤¬ ÀßÄꤵ¤ì¤Æ¤¤¤Æ¤â¥­¡¼¥Ü¡¼¥É¥Õ¥©¡¼¥«¥¹¤òÀßÄꤹ¤ë
      False No input ¥­¡¼¥Ü¡¼¥ÉÆþÎϤòɬÍפȤ·¤Ê¤¤

      2008/06/02 Äɵ­¡£¢¬¤Î¥­¡¼¥Ü¡¼¥É¥Õ¥©¡¼¥«¥¹¥â¥Ç¥ë¤Ë±þ¤¸¤¿ input ÃͤÎÀßÄêɽ¤Ç¤¹¤¬¡¢¥­¡¼¥Ü¡¼¥É¥Õ¥©¡¼¥«¥¹¥â¥Ç¥ë¤ÎÀâÌÀ¤À¤±½ñ¤¤¤Æ¤¤¤Æ¡¢´Î¿´¤ÎÀßÄêÃͤò½ñ¤¤¤Æ¤¤¤Ê¤¤¤³¤È¤Ëº£¹¹µ¤¤Å¤­¤Þ¤·¤¿¡£¤´ÌÂÏǤò¤ª¤«¤±¤·¤Þ¤·¤¿¡Ä

      initial_state ¤Ë¤Ï¡¢½é´ü¾õÂÖ¤¬É¸½à(¥¦¥£¥ó¥É¥¦)¤Ê¤Î¤«¥¢¥¤¥³¥ó¤Ê¤Î¤«¤ò»ØÄꤷ¤Þ¤¹¡£

      Äê¿ô̾¾õÂÖ
      WithdrawnState¤¹¤ß¤Þ¤»¤ó¡¢¤É¤¦¤¤¤¦¾õÂÖ¤«¤è¤¯Ê¬¤ê¤Þ¤»¤ó
      IconicState¥¢¥¤¥³¥ó¾õÂÖ
      NomalState ɸ½à¾õÂÖ

      icon_pixmap ¤Ï¥¢¥¤¥³¥ó¤Ë»È¤¦¥Ô¥¯¥¹¥Þ¥Ã¥×¤ò»ØÄꤷ¤Þ¤¹¡£¤³¤Î¥Ô¥¯¥¹¥Þ¥Ã¥×¤Ï¿¼¤µ¤¬ 1 ¤Ç¤Ê ¤±¤ì¤Ð¤¤¤±¤Þ¤»¤ó¡£icon_mask ¤Ï icon_pixmap ¤Î¤É¤Î¥Ô¥¯¥»¥ë¤òɽ¼¨¤¹¤ë¤«¤ò·è¤á¤ë¥Ó¥Ã¥È¥Þ ¥Ã¥×¤Ç¤¹¡£icon_window ¤Ë¤Ï¡¢¼«Ê¬¤Î¥¢¥¤¥³¥ó¤Î ID ¤òɬÍפȤ·¤¿¤ê¡¢¤è¤êÊ£»¨¤Ê¥Ó¥Ã¥È¥Þ¥Ã ¥×¤òÀßÄꤷ¤è¤¦¤È¤¹¤ë¾ì¹ç¤Ë¡¢¼«Ê¬¤¬À¸À®¤·¤¿¥¦¥£¥ó¥É¥¦¤ò»ØÄꤷ¤Þ¤¹¡£

      window_group ¤Ï¡¢1 ¤Ä¤Î¥¯¥é¥¤¥¢¥ó¥È¤¬Ê£¿ô¤ÎºÇ¾å°Ì¥¦¥£¥ó¥É¥¦¤ò»ý¤Ä¾ì¹ç¤Ë»È¤¤¤Þ¤¹¡£¤³¤ì ¤Ë¤è¤êÊ£¿ô¤ÎºÇ¾å°Ì¥¦¥£¥ó¥É¥¦¤ò¥°¥ë¡¼¥×²½¤·¤Æ¡¢¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¤¬¥¢¥¤¥³¥ó²½¤Ê¤É¤ò ¹Ô¤¦ºÝ¤Ë¥°¥ë¡¼¥×¤È¤·¤Æ°·¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ºÇ¾å°Ì¥¦¥£¥ó¥É¥¦¤Î 1 ¤Ä¤ò¥°¥ë¡¼¥×¥ê¡¼¥À¤È·è ¤á¡¢¤½¤Î¥¦¥£¥ó¥É¥¦¤Î window_group ¤Ë¤Ï¼«Ê¬¤Î¥¦¥£¥ó¥É¥¦ ID ¤òÀßÄꤷ¤Þ¤¹¡£¤½¤Î¾¤ÎºÇ¾å °Ì¥¦¥£¥ó¥É¥¦¤Ë¤Ï¥°¥ë¡¼¥×¥ê¡¼¥À¤Î ID ¤òÀßÄꤷ¤Þ¤¹¡£

    • class_hints

      ¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¤¬¡¢¥ê¥½¡¼¥¹¥Ç¡¼¥¿¥Ù¡¼¥¹¤«¤é¥¯¥é¥¤¥¢¥ó¥È¤Î¥ê¥½¡¼¥¹¤ò¼è¤ê¤À¤¹¤³¤È ¤¬¤Ç¤­¤ë¤è¤¦¤Ë¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó̾¤È¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥¯¥é¥¹Ì¾¤ò»ØÄꤷ¤Þ¤¹¡£¥¢¥×¥ê¥±¡¼ ¥·¥ç¥ó̾¤Ï¾®Ê¸»ú¤Ç¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥¯¥é¥¹Ì¾¤ÏƬʸ»ú¤òÂçʸ»ú¤Ç»ØÄꤷ¤Þ¤¹(½¬´·)¡£¤¿¤À ¤·ºÇ½é¤¬ x ¤Ç»Ï¤Þ¤ë¾ì¹ç¤Ë¤Ï¤½¤Î¼¡¤Îʸ»ú¤âÂçʸ»ú¤Ë¤·¤Þ¤¹¡£

          #include <X11/Xutil.h> /* XClassHint */
      
          typedef struct
          {
            char* res_name;  /* ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó̾ */
            char* res_class; /* ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó */
          } XClassHint;  
      
      

    °Ê¾å¤Ç¡¢³Æ°ú¿ô¤ÎÀâÌÀ¤Ï½ª¤ê¤Ç¤¹¡£¤¿¤À¤·¤³¤ì¤é¤Î¾ðÊó¤Ï¤¢¤¯¤Þ¤Ç¥Ò¥ó¥È¤Ç¤¢¤Ã¤Æ¡¢¼ÂºÝ¤Ë¤³¤ì ¤é¤Î¾ðÊó¤ò»ÈÍѤ¹¤ë¤«¤É¤¦¤«¤Ï¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¤Ë°Ñ¤Í¤é¤ì¤Þ¤¹¡£

¡û ¥¿¥¤¥È¥ëʸ»úÎó¤ÎÀßÄê¡¿¼èÆÀ

¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤Ç¤Ï¡¢XSetWMProperties ¤ò»È¤Ã¤Æ¥¿¥¤¥È¥ëʸ»úÎó¤òÀßÄꤷ¤Þ¤·¤¿¤¬¡¢°Ê²¼¤Î´Ø¿ô¤Ë¤è¤ëÀßÄê¡¿¼èÆÀ¤â½ÐÍè¤Þ¤¹¡£XSetWMName ¤Ë¤ª¤±¤ë text_prop ¤ÎÀßÄê¤Ï¡¢¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤Ç¤Î XSetWMProperties ¤ÈƱÍͤǤ¹¡£

(ÀßÄê)
void XSetWMName( Display* dpy, Window w, XTextProperty* text_prop );
XStoreName( Display* dpy, Window w, char* window_name );

(¼èÆÀ)
Status XGetWMName( Display* dpy, Window w, XTextProperty* text_prop_return );
XFetchName( Display* dpy, Window w, char** window_name_return );

--- ¥³¡¼¥ÉÎã ---

XTextProperty prop;

prop.value    = ( unsigned char* )"Sample Title";
prop.encoding = XA_STRING;
prop.format   = 8;
prop.nitems   = strlen( "Sample Title" );

XSetWMName( dpy, w, &prop );

if ( XGetWMName( dpy, w, &prop ) ) {
        /* ¼èÆÀÀ®¸ù */
}

¡û ¥¢¥¤¥³¥óɽ¼¨»þ¤Î¥¿¥¤¥È¥ëʸ»úÎó¤ÎÀßÄê¡¿¼èÆÀ

¥¢¥¤¥³¥óɽ¼¨»þ¤Î¥¿¥¤¥È¥ëʸ»úÎó¤ò XSetWMProperties ¤ò»È¤ï¤º¤ËÀßÄê¡¿¼èÆÀ¤¹¤ë¾ì¹ç¤Ï¡¢°Ê²¼¤Î´Ø¿ô¤ò»È¤¤¤Þ¤¹¡£

»È¤¤Êý¤Ï¡¢¥¿¥¤¥È¥ëʸ»úÎó¤ÎÀßÄê¡¿¼èÆÀÍÑ´Ø¿ô¤ÈƱ¤¸¤Ç¤¹¡£

(ÀßÄê)
void XSetWMIconName( Display* dpy, Window w, XTextProperty* text_prop );
XSetIconName( Display* dpy, Window w, char* icon_name );

(¼èÆÀ)
Status XGetWMIconName( Display* dpy, Window w, XTextProperty* text_prop_return );
XGetIconName( Display* dpy, Window w, char** icon_name_return );

¡û ¥Î¡¼¥Þ¥ë¥Ò¥ó¥È( ºÇ¾®¡¿ºÇÂ祵¥¤¥º¡¢½Ä²£Èæ¡¢¥ê¥µ¥¤¥º»þ¤ÎÁýʬ¤Ê¤É ) ¤ÎÀßÄê¡¿¼èÆÀ

¥Î¡¼¥Þ¥ë¥Ò¥ó¥È ( XSetWMProperties ¤Ë»ØÄꤹ¤ë normal_hints¡¢¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ÎÀâÌÀ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤ ) ¤ò XSetWMProperties ¤ò»È¤ï¤º¤ËÀßÄê¡¿¼èÆÀ¤¹¤ë¾ì¹ç¤Ï¡¢°Ê²¼¤Î´Ø¿ô¤ò»È¤¤¤Þ¤¹¡£

#include <X11/Xutil.h> /* XSizeHints */
void XSetWMNormalHints( Display* dpy, Window w, XSizeHints* hints );
Status XGetWMNormalHints( Display* dpy, Window w, 
    XSizeHints* hints_return, long* supplied_return );

supplied_return : ¥æ¡¼¥¶ÀßÄê¤Ë¤è¤ëÃͤò¼¨¤¹¥Ó¥Ã¥È¥Þ¥¹¥¯

--- ¥³¡¼¥ÉÎã ---

#include <X11/Xutil.h> /* XSizeHints */

XSizeHints hints;
long supplied_return;

hints.min_width  = 640;
hints.min_height = 480;
hints.max_width  = 640;
hints.max_height = 480;

hints.flags = PMinSize | PMaxSize;

XSetWMNormalHints( dpy, w, &hints );

if ( XGetWMNormalHints( dpy, w, &hints, &supplied_return ) ) {
        /* ¼èÆÀÀ®¸ù */
}

¡û ¥¯¥é¥¹¥Ò¥ó¥È( ¥ê¥½¡¼¥¹¸¡º÷ÍѤΥ¢¥×¥ê¥±¡¼¥·¥ç¥ó̾¤È¥¯¥é¥¹Ì¾ ) ¤ÎÀßÄê¡¿¼èÆÀ

¥¯¥é¥¹¥Ò¥ó¥È( XSetWMProperties ¤Ë»ØÄꤹ¤ë class_hints¡¢¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ÎÀâÌÀ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤ ) ¤ò XSetWMProperties ¤ò»È¤ï¤º¤ËÀßÄê¡¿¼èÆÀ¤¹¤ë¾ì¹ç¤Ï¡¢°Ê²¼¤Î´Ø¿ô¤ò»È¤¤¤Þ¤¹¡£

#include <X11/Xutil.h> /* XClassHint */
XSetClassHint( Display* dpy, Window w, XClassHint* class_hints );
Status XGetClassHint( Display* dpy, Window w, XClassHint* class_hints_return );

--- ¥³¡¼¥ÉÎã ---

#include <X11/Xutil.h> /* XClassHint */

XClassHint class_hints;

class_hints.res_name  = "sample";
class_hints.res_class = "Sample";

XSetClassHint( dpy, w, &class_hints );

if ( XGetClassHint( dpy, w, &class_hints ) ) {
        /* ¼èÆÀÀ®¸ù */
}

¡û ÆüËܸ쥿¥¤¥È¥ë¤Îɽ¼¨( XmbSetWMProperties() )

XSetWMProperties() ¤Î °ú¿ô¤Ç¤¢¤ë window_name ¤ª¤è¤Ó icon_name ¤Ë¡¢¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤ò»ØÄê¤Ç¤­¤ë¤è¤¦¤Ë¤·¤¿´Ø¿ô¤¬ XmbSetWMProperties() ¤Ç¤¹¡£¤³¤Î´Ø¿ô¤Î°ú¿ô window_name ¤ª¤è¤Ó icon_name ¤Ë¤Ï¡¢XTextProperty ¹½Â¤ÂΤǤϤʤ¯ char ¤ÎÇÛÎó¤òÅϤ·¤Þ¤¹¡£

void XmbSetWMProperties( Display*    dpy, 
                         Window      w, 
                         char*       window_name, 
                         char*       icon_name, 
                         char**      argv, 
                         int         argc, 
                         XSizeHints* normal_hints, 
                         XWMHints*   wm_hints, 
                         XClassHint* class_hints 
                       );

ºÇ¶á(2007/02/23)¤Ë¤Ê¤Ã¤Æµ×¡¹¤Ë Fedora6 ¾å¤Ç»î¤·¤Æ¤ß¤¿¤é¡¢ÆüËܸ줬½Ð¤Þ¤»¤ó¤Ç¤·¤¿¡Ä XmbSetWMProperties() ¤ò¼Â¹Ô¤¹¤ëÁ°¤Ë setlocale() ¤Ç¥í¥±¡¼¥ë¤ò¤­¤Á¤ó¤ÈÀßÄꤷ¤Æ¤«¤é¤À¤È½Ð¤ëÍͤǤ¹¡£¹Í¤¨¤Æ¤ß¤ì¤ÐÅö¤¿¤êÁ°¤Ç¤¹¤¬¡£²¼¤Î¥½¡¼¥¹¥³¡¼¥É¤Ë¤âÄɲ䷤Ƥª¤­¤Þ¤·¤¿¡£

¢­¥½¡¼¥¹¥³¡¼¥É¤Ï xwm_mb.c ¤Ç¤¹¡£¥¤¥Ù¥ó¥È¥ë¡¼¥×¤Ç²¿¤â½èÍý¤·¤Æ¤¤¤Þ¤»¤ó¤Î¤Ç¡¢Ctrl-C ¤Ç½ªÎ»¤µ¤»¤Æ¤¯¤À¤µ¤¤¡£

013wm_mb.jpg

¡û ¥¦¥£¥ó¥É¥¦¥¯¥í¡¼¥º¤òÄÌÃΤ·¤Æ¤â¤é¤¦ ( XSetWMProtocols() )

XSetWMProtocols() ¤Ï¡¢¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¤Î WM_PROTOCOLS ¥×¥í¥Ñ¥Æ¥£¤òÀßÄꤹ¤ë¤¿¤á¤Î´Ø¿ô¤Ç¤¹¡£WM_PROTOCOLS ¥×¥í¥Ñ¥Æ¥£¤Ï¡¢¤¢¤ë¾ò·ï¤¬À®Î©¤·¤¿¤È¤­¤Ë¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¤«¤éÄÌÃΤò¼õ¤±¤¿¤¤¾ì¹ç¤ËÀßÄꤷ¤Þ¤¹¡£

WM_PROTOCOLS ¥×¥í¥Ñ¥Æ¥£¤ËÀßÄê¤Ç¤­¤ë¥×¥í¥Ñ¥Æ¥£¤Ï¤¤¤¯¤Ä¤«¤¢¤ê¤Þ¤¹¤¬¡¢¤³¤³¤Ç¤Ï WM_DELETE_WINDOW ¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Þ¤¹¡£¤³¤ì¤ÏºÇ¾å°Ì¥¦¥£¥ó¥É¥¦¤ÎÇ˲õÍ×µá¤òɽ¤¹¥×¥í¥Ñ¥Æ¥£¤Ç¤¹¡£¤³¤ì¤ò WM_PROTOCOLS ¥×¥í¥Ñ¥Æ¥£¤ËÀßÄꤹ¤ë¤È¡¢¥¯¥é¥¤¥¢¥ó¥È¤ÎºÇ¾å°Ì¥¦¥£¥ó¥É¥¦(Ê£¿ô¤¢¤ë¾ì¹ç¤Ï¤É¤ì¤« 1 ¤Ä¤Ç¤â)¤ò½ªÎ»¤µ¤»¤¿¾ì¹ç¤Ë ClientMessage ¥¤¥Ù¥ó¥È¤ò¼õ¤±¼è¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¤³¤Î¤È¤­ ClientMesage ¥¤¥Ù¥ó¥È¤Î data.l[0] ¤È¤¤¤¦¥á¥ó¥Ð¤Ë WM_DELETE_WINDOW ¤òɽ¤¹¥¢¥È¥à¤¬³ÊǼ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¥¢¥È¥à ( Atom ) ¤È¤Ï¥×¥í¥Ñ¥Æ¥£¤Î¼±Ê̻Ҥȹͤ¨¤Æ¤â¤é¤¨¤ÐÎɤ¤¤Ç¤¹¡£¤³¤Î¥¤¥Ù¥ó¥È¤ò¼õ¤±¼è¤Ã¤¿¾ì¹ç¤ËÄ̾ï¤Î½ªÎ»½èÍý¤ò¹Ô¤¦¤è¤¦¤Ë¤¹¤ë¤³¤È¤Ç¡¢¥æ¡¼¥¶¤¬ÆÍÁ³¥¦¥£¥ó¥É¥¦¤ò½ªÎ»¤·¤¿¾ì¹ç¤Ë¤âÂбþ¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£

¼ÂºÝ¤Î½èÍý¤Îή¤ì¤È¤·¤Æ¤Ï¡¢¤Þ¤º WM_DELETE_WINDOW ¥×¥í¥Ñ¥Æ¥£¤ËÂбþ¤·¤¿¥¢¥È¥à¤ò¼èÆÀ¤·¡¢¤½¤Î¥¢¥È¥à¤ò WM_PROTOCOLS ¤ËÀßÄꤷ¤Þ¤¹¡£

¥¢¥È¥à¤ò¼èÆÀ¤¹¤ë¤Ë¤Ï¡¢XInternAtom() ¤ò»È¤¤¤Þ¤¹¡£

Atom XInternAtom( Display* display, char* atom_name, Bool only_if_exists );

atom_name      : ¥¢¥È¥à¤ò¼èÆÀ¤·¤¿¤¤¥×¥í¥Ñ¥Æ¥£¤Î̾¾Î
only_if_exists : False ¤Ê¤é¤Ð¡¢¥¢¥È¥à¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¤Ë¤Ï¿·¤·¤¯À¸À®¤µ¤ì¤ë

¼èÆÀ¤·¤¿¥¢¥È¥à¤ò WM_PROTOCOLS ¤ËÀßÄꤹ¤ë¤Ë¤Ï¡¢XSetWMProtocols() ¤ò»È¤¤¤Þ¤¹¡£

Status XSetWMProtocols( Display* display, Window w, Atom* protocols, int count );

protocol : ÀßÄꤷ¤¿¤¤¥×¥í¥Ñ¥Æ¥£¤ËÂбþ¤¹¤ë¥¢¥È¥à¤Î¥ê¥¹¥È
count    : ¥ê¥¹¥ÈÃæ¤Î¥¢¥È¥à¤Î¿ô

¤¢¤È¤Ï¥¤¥Ù¥ó¥È¥ë¡¼¥×¤ÎÃæ¤Ç ClientMessage ¥¤¥Ù¥ó¥È¤ò¼õ¤±¼è¤Ã¤Æ½èÍý¤¹¤ë¥³¡¼¥É¤ò½ñ¤¯¤À¤±¤Ç¤¹¡£

Atom atom;
...

atom = XInternAtom( dpy, "WM_DELETE_WINDOW", True );
XSetWMProtocols( dpy, win, &atom, 1 );
...

while( 1 ) {
  XNextEvent( dpy, &event );

  switch ( event.type ) {
  ...

    case ClientMessage :
      if ( event.xclient.data.l[0] == atom ) {
        /* ½ªÎ»(³Îǧ)½èÍý ¤ò¹Ô¤¦ */
      }

      break;
   }
}