Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Desktop
User Name
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.


  Search this Thread
Old 02-22-2007, 11:57 PM   #1
LQ Newbie
Registered: Nov 2006
Posts: 4

Rep: Reputation: 0
problem with x11 on AMD64 and XFlush

I am trying to get the following program running on my AMD64 box. It runs the first time fine, putting up a window with a line and 2 pixels. the second time I run it, it puts up the window, but no line and pixels. Also, when I run it from gdb, it runs correctly every time.

The program is x.c, this is how I'm compiling it:
gcc x.c -L/usr/X11R6/lib64 -lX11

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

int main()
// Open the display
Display *dpy = XOpenDisplay(NULL);

// Get some colors
unsigned long blackColor = BlackPixel(dpy, DefaultScreen(dpy));
unsigned long whiteColor = WhitePixel(dpy, DefaultScreen(dpy));

// Create the window
Window w = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, 256, 256,
0, blackColor, whiteColor);

// We want to get MapNotify events
XSelectInput(dpy, w, StructureNotifyMask);

// "Map" the window (that is, make it appear on the screen)
XMapWindow(dpy, w);

// Create a "Graphics Context"
GC gc = XCreateGC(dpy, w, 0, NULL);

// Tell the GC we draw using the white color
XSetForeground(dpy, gc, blackColor);

// Wait for the MapNotify event
XEvent e;
XNextEvent(dpy, &e);
if (e.type == MapNotify)

// Draw the line
XDrawLine(dpy, w, gc, 10, 60, 180, 20);
XDrawPoint(dpy, w, gc, 20, 20);
XDrawPoint(dpy, w, gc, 30, 30);

// Send the "DrawLine" request to the server

// Wait for 10 seconds

XFreeGC(dpy, gc);



amd64, x11, x8664, xlib

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Boot problem with almost every live cd, X11 problem Armagedoom Linux - Software 6 11-23-2006 09:33 AM
problem installing on amd64 tsunami_imcool Fedora 3 09-13-2006 08:37 AM
amd64 clock problem pippo Linux - General 5 10-12-2005 01:46 PM
Core 4 - X11-devel complains about X11-libs which are installed Ephracis Fedora 3 09-05-2005 09:32 AM
Roaming X11/Xfree86, X11 proxy zapp Linux - Software 1 09-12-2003 08:06 AM

All times are GMT -5. The time now is 07:57 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration