x11 simple-wm-hints

窗口的标识设置样例。

  1. 得到 icon 的图片
    /* load the given bitmap data and create an X pixmap contianing it. */
    icon_pixmap = XCreateBitmapFromData(display,
                                        win,
                                        icon_bitmap_bits,
                                        icon_bitmap_width,
                                        icon_bitmap_height);
    if (!icon_pixmap) {
     
        fprintf(stderr, "XCreateBitmapFromData - error creating pixmap\n");
        exit(1);
    }

  1. 初始化 标识 内存
    /* allocate a WM hints structure. */
    win_hints = XAllocWMHints();
    if (!win_hints) {
     
        fprintf(stderr, "XAllocWMHints - out of memory\n");
        exit(1);
    }
    /* initialize the structure appropriatly. */
    /* first, specify which size hints we want to fill in.  */
    /* in our case - setting the icon's pixmap, setting the */
    /* state hint as well as the icon position hint.        */
    win_hints->flags = IconPixmapHint | StateHint | IconPositionHint;
    /* next, specify the desired ihnts data.           */
    /* in our case - supply the icon's desired pixmap. */
    /* make the window's initial state be iconized,    */
    /* and set the icon position to the top-left part  */
    /* of the screen.                                  */
    win_hints->icon_pixmap = icon_pixmap;
    win_hints->initial_state = IconicState;
    win_hints->icon_x = 0;
    win_hints->icon_y = 0;

  1. 在窗口中设置窗口标识
    /* pass the hints to the window manager. */
    XSetWMHints(display, win, win_hints);
  1. 将标识的内存释放
    /* finally, we can free the WM hints structure. */
    XFree(win_hints);

你可能感兴趣的:(linux,#,x,server)