[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | DECWINDOWS 26-JAN-89 to 29-NOV-90 |
Notice: | See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit |
Moderator: | STAR::VATNE |
|
Created: | Mon Oct 30 1989 |
Last Modified: | Mon Dec 31 1990 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 3726 |
Total number of notes: | 19516 |
2993.0. "A DXWM BUG/PROBLEM??" by TAV02::ITAMAR_E () Tue Jun 26 1990 08:11
Hi there,
I have a customer who complains on a bug in dxwm. The customer
asks in his application for resizing of the toplevel window.
The problem is that under dxwm the window changes to the requested
dimensions but the event received by the client is ClientMessage,
with XA_WM_CONFIGURE_DENIED, in other words, the request succeeded, but
the client was notified of failure. The result is that the window
doesn't have the dimentions it thinks it has, with caotic results!!
Under VMS and 'twm' window manager, the event returned is
ConfigureNotify, whose fields correctly indicates the new dimensions of
the window.
Following a code example a little bit long, but it was the mininum code
needed in order to reproduce the problem.
Any Ideas, help, workarounds,etc... is more than welcome!!
THE SAME NOTE WAS ENTERED IN THE X NOTES FILE #895
Thanks in advance,
Itamar.
-------------------------------------------------------------------------
/*
* Test program to illustrate bug in dxwm. Based on 'xev.c' by
* Jim Fulton, MIT X Consortium.
*
* Compile with: cc -g dxwmbug.c -lX -ldnet -o dxwmbug
*
* Usage: dxbug [-bug]
*
* A window is created. Clicking a mouse button in the window causes the
* window to resize. Invoking with the '-bug' option causes XSetWMHints
* to be called, which causes the bug to appear.
*
* The bug is the receipt of a ClientMessage event notifying resize failed,
* WM_CONFIGURE_DENIED, although the resize succeeds.
* This event is caused by the call to XSetWMNormalHints, which is part of
* an old ICCCM convention (O'Reilly Xlib Programming manual, Volume 1,
* Appendix F, page 567) for resizing the toplevel window.
*
* Copyright 1988 Massachusetts Institute of Technology
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
*/
#include <stdio.h>
#include <X11/Xos.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xproto.h>
#include <ctype.h>
#define OUTER_WINDOW_MIN_WIDTH 80
#define OUTER_WINDOW_MIN_HEIGHT 80
#define OUTER_WINDOW_DEF_WIDTH (OUTER_WINDOW_MIN_WIDTH + 100)
#define OUTER_WINDOW_DEF_HEIGHT (OUTER_WINDOW_MIN_HEIGHT + 100)
#define OUTER_WINDOW_DEF_X 100
#define OUTER_WINDOW_DEF_Y 100
char *Yes = "YES";
char *No = "NO";
char *Unknown = "unknown";
char *ProgramName;
Display *dpy;
Window w;
int screen;
void usage ()
{
static char *msg[] = {
" -display displayname X server to contact",
" -geometry geom size and location of window",
" -bw pixels border width in pixels",
" -bug make bug manifest itself",
" -bs {NotUseful,WhenMapped,Always} backingstore attribute",
" -s set save-unders attribute",
"",
NULL};
char **cpp;
fprintf (stderr, "usage: %s [-options ...]\n", ProgramName);
fprintf (stderr, "where options include:\n");
for (cpp = msg; *cpp; cpp++) {
fprintf (stderr, "%s\n", *cpp);
}
exit (1);
}
static int parse_backing_store (s)
char *s;
{
int len = strlen (s);
char *cp;
for (cp = s; *cp; cp++) {
if (isascii (*cp) && isupper (*cp)) *cp = tolower (*cp);
}
if (strncmp (s, "notuseful", len) == 0) return (NotUseful);
if (strncmp (s, "whenmapped", len) == 0) return (WhenMapped);
if (strncmp (s, "always", len) == 0) return (Always);
usage ();
}
main (argc, argv)
int argc;
char **argv;
{
char *displayname = NULL;
char *geom = NULL;
int i;
XSizeHints hints;
int borderwidth = 2;
XSetWindowAttributes attr;
unsigned long mask = 0L;
int done;
XWMHints wmhints;
int bugflag = 0;
ProgramName = argv[0];
for (i = 1; i < argc; i++) {
char *arg = argv[i];
if (arg[0] == '-') {
switch (arg[1]) {
case 'd': /* -display host:dpy */
if (++i >= argc) usage ();
displayname = argv[i];
continue;
case 'g': /* -geometry geom */
if (++i >= argc) usage ();
geom = argv[i];
continue;
case 'b':
switch (arg[2]) {
case 'w': /* -bw pixels */
if (++i >= argc) usage ();
borderwidth = atoi (argv[i]);
continue;
case 's': /* -bs type */
if (++i >= argc) usage ();
attr.backing_store = parse_backing_store (argv[i]);
mask |= CWBackingStore;
continue;
case 'u': /* -bug */
if (arg[3] != 'g') usage();
bugflag = True;
continue;
default:
usage ();
}
case 's': /* -s */
attr.save_under = True;
mask |= CWSaveUnder;
continue;
default:
usage ();
} /* end switch on - */
} else
usage ();
} /* end for over argc */
dpy = XOpenDisplay (displayname);
if (!dpy) {
fprintf (stderr, "%s: unable to open display '%s'\n",
ProgramName, XDisplayName (displayname));
exit (1);
}
set_sizehints (&hints, OUTER_WINDOW_MIN_WIDTH, OUTER_WINDOW_MIN_HEIGHT,
OUTER_WINDOW_DEF_WIDTH, OUTER_WINDOW_DEF_HEIGHT,
OUTER_WINDOW_DEF_X, OUTER_WINDOW_DEF_Y, geom);
screen = DefaultScreen (dpy);
attr.background_pixel = BlackPixel (dpy, screen);
attr.border_pixel = WhitePixel (dpy, screen);
attr.event_mask = ButtonPressMask | ExposureMask |
StructureNotifyMask;
mask |= (CWBackPixel | CWBorderPixel | CWEventMask);
w = XCreateWindow (dpy, RootWindow (dpy, screen), hints.x, hints.y,
hints.width, hints.height, borderwidth, 0, InputOutput,
(Visual *)CopyFromParent,
mask, &attr);
XSetStandardProperties (dpy, w, "Event Tester", NULL, (Pixmap) 0,
argv, argc, &hints);
wmhints.flags = 0;
if (bugflag)
XSetWMHints(dpy,w,&wmhints);
XMapWindow (dpy, w);
for (done = 0; !done; ) {
XEvent event;
XNextEvent (dpy, &event);
switch (event.type) {
case ButtonPress:
prologue (&event, "ButtonPress");
do_ButtonPress (&event);
break;
case CreateNotify:
prologue (&event, "CreateNotify");
do_CreateNotify (&event);
break;
case MapNotify:
prologue (&event, "MapNotify");
do_MapNotify (&event);
break;
case ReparentNotify:
prologue (&event, "ReparentNotify");
do_ReparentNotify (&event);
break;
case ConfigureNotify:
prologue (&event, "ConfigureNotify");
do_ConfigureNotify (&event);
break;
case CirculateNotify:
prologue (&event, "CirculateNotify");
do_CirculateNotify (&event);
break;
case ClientMessage:
prologue (&event, "ClientMessage");
do_ClientMessage (&event);
break;
case MappingNotify:
prologue (&event, "MappingNotify");
do_MappingNotify (&event);
break;
case Expose:
printf("Expose Event.\n");
break;
default:
printf ("Unknown event type %d\n", event.type);
break;
}
}
XCloseDisplay (dpy);
exit (0);
}
prologue (eventp, event_name)
XEvent *eventp;
char *event_name;
{
XAnyEvent *e = (XAnyEvent *) eventp;
printf ("\n%s event, serial %ld, synthetic %s, window 0x%lx,\n",
event_name, e->serial, e->send_event ? Yes : No, e->window);
}
do_ButtonPress (eventp)
XEvent *eventp;
{
XButtonEvent *e = (XButtonEvent *) eventp;
printf (" root 0x%lx, subw 0x%lx, time %lu, (%d,%d), root:(%d,%d),\n",
e->root, e->subwindow, e->time, e->x, e->y, e->x_root, e->y_root);
printf (" state 0x%x, button %u, same_screen %s\n",
e->state, e->button, e->same_screen ? Yes : No);
do_Resize();
}
do_Resize()
{
#define WIDTH1 OUTER_WINDOW_DEF_WIDTH
#define WIDTH2 (OUTER_WINDOW_DEF_WIDTH + 50)
#define HEIGHT1 OUTER_WINDOW_DEF_HEIGHT
#define HEIGHT2 (OUTER_WINDOW_DEF_HEIGHT + 50)
static char flag = False;
static XSizeHints size_hints;
static XWindowChanges values;
static unsigned int mask = CWWidth | CWHeight;
int height, width;
if (flag) {
height = HEIGHT1; width = WIDTH1;
} else {
height = HEIGHT2; width = WIDTH2;
}
flag = !flag;
values.width = width;
values.height = height;
XConfigureWindow(dpy, w, mask, &values);
size_hints.flags = (long)mask;
size_hints.width = width;
size_hints.height = height;
XSetWMNormalHints(dpy, w, &size_hints);
}
do_CreateNotify (eventp)
XEvent *eventp;
{
XCreateWindowEvent *e = (XCreateWindowEvent *) eventp;
printf (" parent 0x%lx, window 0x%lx, (%d,%d), width %d, height %d\n",
e->parent, e->window, e->x, e->y, e->width, e->height);
printf ("border_width %d, override %s\n",
e->border_width, e->override_redirect ? Yes : No);
return;
}
do_MapNotify (eventp)
XEvent *eventp;
{
XMapEvent *e = (XMapEvent *) eventp;
printf (" event 0x%lx, window 0x%lx, override %s\n",
e->event, e->window, e->override_redirect ? Yes : No);
return;
}
do_ReparentNotify (eventp)
XEvent *eventp;
{
XReparentEvent *e = (XReparentEvent *) eventp;
printf (" event 0x%lx, window 0x%lx, parent 0x%lx,\n",
e->event, e->window, e->parent);
printf (" (%d,%d), override %s\n", e->x, e->y,
e->override_redirect ? Yes : No);
return;
}
do_ConfigureNotify (eventp)
XEvent *eventp;
{
XConfigureEvent *e = (XConfigureEvent *) eventp;
printf (" event 0x%lx, window 0x%lx, (%d,%d), width %d, height %d,\n",
e->event, e->window, e->x, e->y, e->width, e->height);
printf (" border_width %d, above 0x%lx, override %s\n",
e->border_width, e->above, e->override_redirect ? Yes : No);
return;
}
do_CirculateNotify (eventp)
XEvent *eventp;
{
XCirculateEvent *e = (XCirculateEvent *) eventp;
char *p;
char pdummy[10];
switch (e->place) {
case PlaceOnTop: p = "PlaceOnTop"; break;
case PlaceOnBottom: p = "PlaceOnBottom"; break;
default: p = pdummy; sprintf (pdummy, "%d", e->place); break;
}
printf (" event 0x%lx, window 0x%lx, place %s\n",
e->event, e->window, p);
return;
}
do_ClientMessage (eventp)
XEvent *eventp;
{
XClientMessageEvent *e = (XClientMessageEvent *) eventp;
char *mname = XGetAtomName (dpy, e->message_type);
printf (" message_type 0x%lx (%s), format %d\n",
e->message_type, mname ? mname : Unknown, e->format);
if (mname) XFree (mname);
return;
}
do_MappingNotify (eventp)
XEvent *eventp;
{
XMappingEvent *e = (XMappingEvent *) eventp;
char *r;
char rdummy[10];
switch (e->request) {
case MappingModifier: r = "MappingModifier"; break;
case MappingKeyboard: r = "MappingKeyboard"; break;
case MappingPointer: r = "MappingPointer"; break;
default: r = rdummy; sprintf (rdummy, "%d", e->request); break;
}
printf (" request %s, first_keycode %d, count %d\n",
r, e->first_keycode, e->count);
return;
}
set_sizehints (hintp, min_width, min_height,
defwidth, defheight, defx, defy, geom)
XSizeHints *hintp;
int min_width, min_height, defwidth, defheight, defx, defy;
char *geom;
{
int geom_result;
/* set the size hints, algorithm from xlib xbiff */
hintp->width = hintp->min_width = min_width;
hintp->height = hintp->min_height = min_height;
hintp->flags = PMinSize;
hintp->x = hintp->y = 0;
geom_result = NoValue;
if (geom != NULL) {
geom_result = XParseGeometry (geom, &hintp->x, &hintp->y,
(unsigned int *)&hintp->width,
(unsigned int *)&hintp->height);
if ((geom_result & WidthValue) && (geom_result & HeightValue)) {
#define max(a,b) ((a) > (b) ? (a) : (b))
hintp->width = max (hintp->width, hintp->min_width);
hintp->height = max (hintp->height, hintp->min_height);
hintp->flags |= USSize;
}
if ((geom_result & XValue) && (geom_result & YValue)) {
hintp->flags += USPosition;
}
}
if (!(hintp->flags & USSize)) {
hintp->width = defwidth;
hintp->height = defheight;
hintp->flags |= PSize;
}
if (geom_result & XNegative) {
hintp->x = DisplayWidth (dpy, DefaultScreen (dpy)) + hintp->x -
hintp->width;
}
if (geom_result & YNegative) {
hintp->y = DisplayHeight (dpy, DefaultScreen (dpy)) + hintp->y -
hintp->height;
}
return;
}
T.R | Title | User | Personal Name | Date | Lines |
---|
2993.1 | No answers?? | TAV02::ITAMAR_E | | Thu Jun 28 1990 03:12 | 3 |
| No answers to this note??
-Itamar
|
2993.2 | | GILROY::klee | | Thu Jun 28 1990 15:53 | 4 |
| dxwm was written before the X11R4 ICCCM. An upgrade to the ICCCM is in
progress. If you find problems, please QAR them.
Ken
|