[comp.windows.x] resizing windows on hp9000

todd%sfsu1.hepnet@LBL.GOV (02/28/89)

                                            
we are using g++ and Xlib to write applications on hp9000 workstations.
windows i have created have done what i wanted usually, but the window
manager (uwm) doesnt seem to know how to resize them... tho ive set all sorts ofhints and things. uwms  acts like its resizing - an outline of a smaller or
larger window appears, and a box with the dimensions of the oyutlined window. But
when the mouse button is released, the window is in its original state ..tho
it sometimes moves, apparently due to bit gravity.

similar windows programmmed in the x10 environment were resized ok.

below is the code for one such x11 application, a utility to display the
color map .
/*****************************************************************************

  File Name: showcolormap.cc
  Author: Jim Todd
  Creation Date:2/8/89
  Modified: 2/16/89
  Purpose: Show the current colors available on screen
           this version is designed for 16 color map, as 320s only support 16
  Compile With: g++ showcolormap.cc -lm -lX11
  Executable is in ~/bin/xcmap
  This version has transparent background 
  Object List:

*****************************************************************************/

#include "Xlib.h"
// #include <X/Xlib.h>

#include <stdio.h>

#define AllEventsMask ~0L
#define COLORSTRIPEWIDTH 18
#define HALF_COLORSTRIPEWIDTH (COLORSTRIPEWIDTH / 2)

int strlen(char *string);

main()
{
  Display  *dpy;
  unsigned long fth, pad; //font size parameters
  unsigned long bd, bg,fg; /*background and border colors, etc*/
  unsigned short center_line; //x location of line 
  Window win; 
  XEvent event;
  XGCValues gcvals;
  GC lgc, fgc; //graphic contexts for lines, fonts
  XFontStruct *fontstruct;
  char numstring[3] ;
  XSetWindowAttributes setat;

// open display
  dpy = XOpenDisplay(0);	


// create window
  bd = WhitePixel(dpy,DefaultScreen(dpy));
  bg = BlackPixel(dpy, DefaultScreen(dpy));	
  fg = bd;
  win =XCreateSimpleWindow(dpy, RootWindow(dpy, 0),
			   50, 50, 320, 55, 1, bd, bg); 

// change the background to be transparent
  setat.background_pixmap = None;
  XChangeWindowAttributes(dpy, win,CWBackPixmap  , &setat);

// load the font to use , other font stuff
  if((fontstruct = XLoadQueryFont(dpy, "vrb-25")) == 0)
    {
      fprintf(stderr, "font unknown");
      exit(1);
    }
  fth = fontstruct->max_bounds.ascent + fontstruct->max_bounds.descent;
  pad = 1;
  gcvals.font = fontstruct->fid; //gc for drawing font
  gcvals.foreground = fg;
  gcvals.background = bg;
  fgc = XCreateGC(dpy, win, (GCForeground | GCBackground), &gcvals);

// select input events to see
  XSelectInput(dpy, win, AllEventsMask);

// set window's name and icon name
  XSetIconName(dpy, win, "color map");
  XStoreName(dpy, win, "color map");



// map window 
  XMapWindow(dpy, win);



//wait for window to be reified (in case the fwm interferes)
// XMaskEvent(dpy, (ExposureMask|EnterWindowMask) , &event);	
//  XMaskEvent(dpy, VisibilityChangeMask  , &event)	;
  XMaskEvent(dpy, (ExposureMask|EnterWindowMask)  , &event)	;


  //initialize invariant part of XGCValues structure
    gcvals.line_width = COLORSTRIPEWIDTH; 

// draw in colors and label
//  drawmap();
 
 
  for(register unsigned short i= 0; i < 16; i++)
    {
      //specify the graphics context of the draw
      gcvals.foreground = i;
      lgc = XCreateGC(dpy, win, (GCLineWidth | GCForeground), &gcvals);
      
      center_line = HALF_COLORSTRIPEWIDTH +i * 20;
      XDrawLine(dpy, win, lgc, center_line, 2 , center_line, 42);
      sprintf(numstring, "%x", i);
      XDrawString(dpy, (Drawable) win, fgc, center_line, 53,
		  numstring , strlen(numstring));
    }
  




// wait for events in window 

  for(;;)
    {
      XNextEvent(dpy, &event);	

      if(event.type == ButtonRelease)break; // leave loop, end execution

      if(event.type == Expose) // redraw contents
	{
	  for(register unsigned short i= 0; i < 16; i++)
	    {
	      //specify the graphics context of the draw
		gcvals.foreground = i;
	      lgc = XCreateGC(dpy, win, (GCLineWidth | GCForeground), &gcvals);
      
	      center_line = HALF_COLORSTRIPEWIDTH +i * 20;
	      XDrawLine(dpy, win, lgc, center_line, 2 , center_line, 42);
	      sprintf(numstring, "%x", i);
	      XDrawString(dpy, (Drawable) win, fgc, center_line, 53,
			  numstring , strlen(numstring));
	    } 


	} //end if exposed

    }//end event loop

}// end main






any suggestions ?
thanks

diamant@hpfclp.SDE.HP.COM (John Diamant) (03/02/89)

> we are using g++ and Xlib to write applications on hp9000 workstations.
> windows i have created have done what i wanted usually, but the window
> manager (uwm) doesnt seem to know how to resize them... tho ive set all sorts ofhints and things. uwms  acts like its resizing - an outline of a smaller or
> larger window appears, and a box with the dimensions of the oyutlined window. But
> when the mouse button is released, the window is in its original state ..tho
> it sometimes moves, apparently due to bit gravity.

Does this happen with all applications running under uwm or only your
application?  If it's only yours, then it may be a complicated problem
of one or the other not following the ICCCM (conventions manual or following
different ones).  However, I suspect it is happening to all applications
running under this window manager.  Check which mouse button you are using
to do the resize.  I haven't used uwm in a while, but I remember it
rubber banding regardless of which button is pressed (once you've asked for
a resize), but only working if you used the correct one (right button I
think).  If you used the wrong button, it had the symptoms you described.
I never understood why it did that so I assume it was just a bug.


John Diamant
Software Engineering Systems Division
Hewlett-Packard Co.		ARPA Internet: diamant@hpfclp.sde.hp.com
Fort Collins, CO		UUCP:  {hplabs,hpfcla}!hpfclp!diamant