🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: slac.users.windows.x
1 messages
1 total messages Started by J. Scott Berg Sun, 09 Feb 1992 19:09
New X programmer doesn't understand...
#1
Author: J. Scott Berg
Date: Sun, 09 Feb 1992 19:09
94 lines
3691 bytes
In the program below, note the commented out delay loop.  If I place
the loop in, my program behaves as expected.  If I remove the loop,
a black window pops up, but the two lines are not drawn.  What the
!@#$% is going on?  It seems that I am missing something fundamental
here...  Any help would be greatly appreciated.  By the way, I am
running X11R5 on under AIX, but the behavior was the same when I
compiled on a sun and put it on my IBM display.  Thanks

				-Scott Berg


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

main() {

  char *display_name;
  Display *Jdisp;
  int Jdepth,Jdispht,Jdispwd,Jwinx0,Jwiny0;
  int x0,y0,x1,y1,i,im;
  double x;
  Screen *Jscreen;
  unsigned int Jwinwd,Jwinht,Jwinbdw;
  unsigned long Jbkpix,Jwtpix,Jwinbdpix,Jwinbkgd,Jgcvb;
  Window Jrootwin,Jwin1;
  GC Jgc;
  XGCValues Jgcv;

  display_name = NULL;
  Jdisp = XOpenDisplay(display_name);
  Jscreen = XDefaultScreenOfDisplay(Jdisp);
  Jbkpix = XBlackPixelOfScreen(Jscreen);
  Jwtpix = XWhitePixelOfScreen(Jscreen);
  Jdepth = XDefaultDepthOfScreen(Jscreen);
  Jrootwin = XRootWindowOfScreen(Jscreen);
  Jdispht = XHeightOfScreen(Jscreen);
  Jdispwd = XWidthOfScreen(Jscreen);

  printf("Black pixel: %d\nWhite pixel: %d\nDepth: %d\nHeight: %d\nWidth: %d\n"
                              ,Jbkpix,Jwtpix,Jdepth,Jdispht,Jdispwd);
  
  Jwinx0 = Jdispwd/10;
  Jwiny0 = Jdispht/10;
  Jwinwd = Jdispwd/2;
  Jwinht = Jdispht/2;
  Jwinbdw = 2;
  Jwinbdpix = Jwtpix;
  Jwinbkgd = Jbkpix;

/*  for (x = 0.0 ; x < 1.0 ; x += 1.0e-6); */
  Jwin1 = XCreateSimpleWindow(Jdisp,Jrootwin,Jwinx0,Jwiny0,Jwinwd,Jwinht,
			      Jwinbdw,Jwinbdpix,Jwinbkgd);
  XMapWindow(Jdisp,Jwin1);
  XFlush(Jdisp);

  Jgcvb = 0L;
  Jgc = XCreateGC(Jdisp,Jwin1,Jgcvb,&Jgcv);

  x0 = Jwinwd/3;
  x1 = 2*Jwinwd/3;
  y0 = Jwinht/4;
  y1 = Jwinwd/2;

  printf("Window width = %d, height = %d\n",Jwinwd,Jwinht);
  printf("x0 = %d, y0 = %d, x1 = %d, y1 = %d\n",x0,y0,x1,y1);

  XSetForeground(Jdisp,Jgc,Jwtpix);
  XSetBackground(Jdisp,Jgc,Jbkpix);

  XDrawLine(Jdisp,Jwin1,Jgc,x0,y0,x1,y1);

  y0 += 100; y1 += 100;

  XDrawLine(Jdisp,Jwin1,Jgc,x0,y0,x1,y1);

  XFlush(Jdisp);

  scanf("%d",&i);

  XCloseDisplay(Jdisp); }


-- 
-------------------------------------------------------------------------------
The opinions expressed here are, of course, my own and nobody else's.
-------------------------------------------------------------------------------
J. Scott Berg
email: alhy@unixhub.slac.stanford.edu
real mail: Varian Physics
           Stanford  CA  94305-4060
phone:	(415) 926-4732
	(415) 497-2998
-------------------------------------------------------------------------------
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads