Help for beginner. XCreatePixmap

mike flame-mike at zeelandnet.nl
Mon Oct 22 05:02:14 PDT 2007


is this a bug?

here is may xorg.conf

# xorg.conf (xorg X Window System server configuration file)
#
# This file was generated by dexconf, the Debian X Configuration tool, using
# values from the debconf database.
#
# Edit this file with caution, and see the xorg.conf manual page.
# (Type "man xorg.conf" at the shell prompt.)
#
# This file is automatically updated on xserver-xorg package upgrades *only*
# if it has not been modified since the last upgrade of the xserver-xorg
# package.
#
# If you have edited this file but would like it to be automatically updated
# again, run the following command:
#   sudo dpkg-reconfigure -phigh xserver-xorg

Section "Files"
EndSection

Section "InputDevice"
    Identifier    "Generic Keyboard"
    Driver        "kbd"
    Option        "CoreKeyboard"
    Option        "XkbRules"    "xorg"
    Option        "XkbModel"    "pc104"
    Option        "XkbLayout"    "us"
EndSection

Section "InputDevice"
    Identifier    "Configured Mouse"
    Driver        "mouse"
    Option        "CorePointer"
    Option        "Device"        "/dev/input/mice"
    Option        "Protocol"        "ImPS/2"
    Option        "ZAxisMapping"        "4 5"
    Option        "Emulate3Buttons"    "true"
EndSection

Section "InputDevice"
    Driver        "wacom"
    Identifier    "stylus"
    Option        "Device"    "/dev/input/wacom"
    Option        "Type"        "stylus"
    Option        "ForceDevice"    "ISDV4"        # Tablet PC ONLY
EndSection

Section "InputDevice"
    Driver        "wacom"
    Identifier    "eraser"
    Option        "Device"    "/dev/input/wacom"
    Option        "Type"        "eraser"
    Option        "ForceDevice"    "ISDV4"        # Tablet PC ONLY
EndSection

Section "InputDevice"
    Driver        "wacom"
    Identifier    "cursor"
    Option        "Device"    "/dev/input/wacom"
    Option        "Type"        "cursor"
    Option        "ForceDevice"    "ISDV4"        # Tablet PC ONLY
EndSection

Section "Device"
    Identifier    "Silicon Integrated Systems [SiS] 661/741/760 PCI/AGP
or 662/761Gx PCIE VGA Display Adapter"
    Driver        "sis"
    BusID        "PCI:1:0:0"
    Option        "UseFBDev"        "true"
EndSection

Section "Monitor"
    Identifier    "AL1707 A"
    Option        "DPMS"
    HorizSync    30-70
    VertRefresh    50-160
EndSection

Section "Module"
        Disable "dri"
        Disable "glx"
EndSection

Section "Screen"
    Identifier    "Default Screen"
    Device        "Silicon Integrated Systems [SiS] 661/741/760 PCI/AGP
or 662/761Gx PCIE VGA Display Adapter"
    Monitor        "AL1707 A"
    DefaultDepth    16
    SubSection "Display"
        Modes        "1280x1024" "1024x768" "800x600" "640x480"
    EndSubSection
EndSection

Section "ServerLayout"
    Identifier    "Default Layout"
    Screen        "Default Screen"
    InputDevice    "Generic Keyboard"
    InputDevice    "Configured Mouse"

# Uncomment if you have a wacom tablet
#    InputDevice     "stylus"    "SendCoreEvents"
#    InputDevice     "cursor"    "SendCoreEvents"
#    InputDevice     "eraser"    "SendCoreEvents"
EndSection



mike wrote:
> Hi, all.
>
> When I create a lot of pixmaps I can't  freed memory,
> Wat I doe wrong?
>
> Before start program.
>
> mike at mike-desktop:~$ ps aux | grep /X11/X
> root      3708  6.0  2.0  12672  9152 tty7     Ss+  11:19   0:01
> /usr/bin/X11/X -dpi 100 -nolisten tcp -ld 0 -ls 0 -lf 0 -bs -su -br
> -maxbigreqsize 1
>
> After
> mike at mike-desktop:~$ ps aux | grep /X11/X
> root      3708  1.1  2.9  51984 13324 tty7     Ss+  11:19   0:02
> /usr/bin/X11/X -dpi 100 -nolisten tcp -ld 0 -ls 0 -lf 0 -bs -su -br
> -maxbigreqsize 1
>
>
>
>
> #include  <X11/cursorfont.h>
> #include <stdio.h>
> #include <X11/Xlib.h>
> #include <stdio.h>
>
>       Display *display;
>       Window  win1;
>       XSetWindowAttributes attributes;
>       XFontStruct *fontinfo;
>       GC gr_context1;
>       XArc arcs[10];
>       Pixmap pixmap, pix[1024];       
>       Visual *visual;
>       int screen;
>       int depth;
>       int i;
>  main (argc, argv)
>  char   *argv[];
>  int     argc;
>  {
>       XGCValues gr_values;
>       XEvent event;
>  
>       setbuf (stdout, NULL);
>       setbuf (stderr, NULL);
>       display = XOpenDisplay(NULL);
>       screen = DefaultScreen(display);
>       visual = DefaultVisual(display,screen);
>       depth  = DefaultDepth(display,screen);
>       attributes.background_pixel      = XWhitePixel(display,screen);
>       attributes.border_pixel          = XBlackPixel(display,screen);
>       attributes.override_redirect     = 0;
>  
>       for(i=0;i<10;i++){
>              arcs[i].x = 100;arcs[i].y = 50;
>            arcs[i].width = 100;arcs[i].height = 50;
>       }
>       for(i=0;i<5;i++){
>            arcs[i].angle1 = 72*64*i;
>            arcs[i].angle2 = 35*64;
>       }
>       for(i=5;i<10;i++){
>            arcs[i].angle1 = 72*64*i + 36*64;
>            arcs[i].angle2 = 35*64;
>       }
>  
>       win1= XCreateWindow(display, XRootWindow(display,screen),
>                    200,200, 300,200,5, depth, InputOutput, visual,
>                    CWBackPixel | CWBorderPixel |
> CWOverrideRedirect,&attributes);
>  
>       XSelectInput(display,win1,ExposureMask | ButtonPressMask |
> KeyPressMask);
>       FILE *test;
>       test = fopen("test.pix", "w");
>       pixmap = XCreatePixmap(display,win1,200,100,depth);    
>       for (i=0; i<1024; i++){
>          pix[i] = XCreatePixmap(display,win1,200,100,depth);   
>          fprintf(test, "%lu\n", pix[i]);
>       }   
>       fclose(test);
>       fontinfo = XLoadQueryFont(display,"6x10");
>       gr_values.font =   fontinfo->fid;
>       gr_values.function =   GXcopy;
>       gr_values.plane_mask = AllPlanes;
>       gr_values.foreground = BlackPixel(display,screen);
>       gr_values.background = WhitePixel(display,screen);
>       gr_context1=XCreateGC(display,win1,
>               GCFont | GCFunction | GCPlaneMask | GCForeground |
> GCBackground,
>               &gr_values);
>  
>       XDefineCursor(display,win1,XCreateFontCursor(display,XC_heart));
>       XMapWindow(display,win1);
>  
>       do{
>         XNextEvent(display,&event);
>         if (event.type == Expose){
>               draw_ellipse();
>               XCopyArea(display,win1,pixmap,gr_context1,50,25,200,100,0,0);
>               XSetFunction(display,gr_context1,GXinvert);
>              
> XDrawImageString(display,pixmap,gr_context1,80,45,"pixmap",6);
>               XDrawImageString(display,pixmap,gr_context1,90,60,"copy",4);
>               XSetFunction(display,gr_context1,GXcopy);
>               XDrawString(display,win1,gr_context1,10,20,
>                   "Press a key in this window",26);
>         }
>       }while  (event.type !=KeyPress);
>  
>       XCopyArea(display,pixmap,win1,gr_context1,0,0,200,100,100,125);
>       XDrawString(display,win1,gr_context1,10,32,
>                   "Now press a key to exit",23);
>       XFlush(display);
>  
>       do{
>         XNextEvent(display,&event);
>       }while  (event.type !=KeyPress);
>  
>       printf("closing display\n");
>       for (i=0; i<1024; i++) XFreePixmap(display, pix[i]);
>       XFreePixmap(display, pixmap);
>       XCloseDisplay(display);
>  }
>  
>  draw_ellipse()
>  {
>       XSetArcMode(display,gr_context1,ArcPieSlice);
>       XFillArcs(display,win1,gr_context1,arcs,5);
>       XSetArcMode(display,gr_context1,ArcChord);
>       XFillArcs(display,win1,gr_context1,arcs+5,5);
>  }
>
>
> _______________________________________________
> xorg mailing list
> xorg at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xorg
>
>   




More information about the xorg mailing list