关于visual的编译

/*
* Simple Xlib application drawing a box in a window.
*/

#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>

//licl2012-05-30
//#include "config.h" 
//#include "fcitx/fcitx.h"   
#include <limits.h> 
#include <unistd.h> 
#include <X11/extensions/Xrender.h> 
#include <X11/Xatom.h>     
//#include "fcitx/module.h" 
//#include "x11stuff.h" 
//#include "fcitx-utils/utils.h" 
//#include "fcitx/instance.h" 
//#include "xerrorhandler.h" 
//#include <fcitx-utils/log.h>
//#include "composite-engine.h"
//#include<GL/glx.h>

 

int main()
{
        struct _XDisplay *d;
        int s;
        Window w;
        XEvent e;
        XVisualInfo  *xvi;//licl2012-05-30
        XVisualInfo  temp;
        int   nvi;//licl2012-05-30
        int   i;//licl2012-05-30
        XRenderPictFormat *format;//licl2012-05-30
        Visual  *visual = NULL;//licl2012-05-30

        /* To open a connection to the X server that controls a display*/
        d = XOpenDisplay(NULL);
        if(d == NULL)
        {
                printf("Cannot open display\n");
                exit(1);
        }
    else {
     printf(" open display  ok\n");
     }
/* Both return the default screen number referenced by the XOpenDisplay() function */
        s = DefaultScreen(d);
        printf(" got the screen\n");

        /* create window */
//licl2012-05-30 
 temp.screen = s;
  temp.depth  = 32;
  temp.class  = TrueColor;     
        if ((xvi = XGetVisualInfo (d,
        VisualScreenMask |
        VisualDepthMask |
        VisualClassMask,
        &temp,
        &nvi)) == NULL)
    //return NULL;
 
  for (i = 0; i < nvi; i++)
    {
      format = XRenderFindVisualFormat (d, xvi[i].visual);
      if (format->type == PictTypeDirect && format->direct.alphaMask)
 {
   visual = xvi[i].visual;
   break;
 }
    }
   
   
        w = XCreateSimpleWindow(d,
                                RootWindow(d, s),
                                10,
                                10,
                                100,
                                100,
                                1,
                                BlackPixel(d, s),
                                WhitePixel(d, s));

        /* select kind of events we are interested in */
        XSelectInput(d, w, ExposureMask | KeyPressMask);

        /* map (show) the window */
        XMapWindow(d, w);

        /* event loop */
        while(1)
        {
                XNextEvent(d, &e);
                /* draw or redraw the window */
                if(e.type == Expose)
                {
                        XFillRectangle(d, w, DefaultGC(d, s), 10, 10, 100, 100);
                }
                /* exit on key press */
                //licl2012-05-30if(e.type == KeyPress)
                //licl2012-05-30        break;
        }

        /* close connection to server */
        XCloseDisplay(d);

        return 0;
}

 代码中有关键词c++的class,所以原来作为testwindow.cpp文件时编译不过,后改成testwindow.c就ok了

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值