pastebin - collaborative debugging tool
rovema.kpaste.net RSS


Mini-X11 demo for Ilja Mainz
Posted by Anonymous on Sun 17th Apr 2022 18:16
raw | new post

  1. /* mini X11 drawing demo for Ilja */
  2. #include <X11/Xlib.h>
  3. #include <X11/Xutil.h>
  4. #include <unistd.h>
  5. #include <malloc.h>
  6. #include <stdio.h>
  7.  
  8. int main(int argc,char *argv[])
  9. {
  10.         Display *display = XOpenDisplay(NULL);
  11.         int screen_num = DefaultScreen(display);
  12.         Window root = RootWindow(display,screen_num);
  13.         Visual *visual = DefaultVisual(display,screen_num);
  14.  
  15.  
  16.         Window win = XCreateSimpleWindow(display,root,50,50,456,456,1,0,0);
  17.         XSelectInput(display,win,ExposureMask);
  18.         XMapWindow(display,win);
  19.  
  20.         XGCValues values;                       /* initial values for the GC.   */
  21.         unsigned long valuemask=0;
  22.         GC gc = XCreateGC(display, win, valuemask, &values);
  23.  
  24.         XSetForeground(display, gc, WhitePixel(display, screen_num));
  25.    
  26.         XEvent event;
  27.         while(1)
  28.         {
  29.                 int j=0;
  30.                 XNextEvent(display,&event);
  31.                 if(event.type == Expose)
  32.                 {
  33.                         XDrawLine(display,win,gc, 50, 50, 400, 400);
  34.                         XDrawLine(display,win,gc, 400, 400, 50, 400);
  35.                         XDrawLine(display,win,gc, 50, 400, 50, 50);
  36.                         XFlush(display);
  37.                 }
  38.         }
  39.         sleep(10);
  40.         XCloseDisplay(display);
  41.         return 0;
  42. }

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at