Subject: FVWM: Iconisation issue

From: "Matt H" <[email-masked]>
Date: Mon, 26 Feb 2001 10:05:13 -0000

Hi FVWM people,

There seems to be an issue with using XtSetMappedWhenManaged on a form 
widget in FVWM (not Sawfish, CDE, enlightenment etc.).

If I create an event handler to catch a mapped notify it never occurs.

Could someone give me pointers if I am coding wrong or is there an issue 
with FVWM?

Here is the simple code....thanks in advance, Matt.

#include <Xm/Form.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <stdio.h>
#include <Xm/Xm.h>
#include <X11/Shell.h>

Display *display;
XtAppContext my_appContext;
Widget mainWindow, myshell;
Boolean windowIconic;

static void shellEH(Widget w, XtPointer data, XEvent *event)
{
	switch (event->xany.type) {

		case MapNotify:
			fprintf(stderr, "	Map Notify \n");
			windowIconic = False;
			break;
		case UnmapNotify:
			fprintf(stderr, "	UnMap Notify \n");
			windowIconic = True;
			break;

	}

}

static void setStateHints( Window win, Boolean isIconic )
{
    XWMHints *myHints;
    char *myName;
    XFetchName(display, win, &myName);
    fprintf(stderr, "Setting state hints for Window name: %s\n", myName);
    if (win != NULL) {
        if ((myHints = XGetWMHints(display, win)) != NULL) {
            myHints->flags |= StateHint;
            if (isIconic) {
                fprintf(stderr, "               setting WMHints to Iconic 
state\n");
                myHints->initial_state = IconicState;
            } else {
                fprintf(stderr, "               setting WMHints to Normal 
state\n");
                myHints->initial_state = NormalState;
            }
            XSetWMHints(display, win, myHints);
            XFree(myHints);
        }
    }
}

void button2_pushed (w, client_data, cbs)
Widget w;
XtPointer client_data;
XmPushButtonCallbackStruct *cbs;
{
	fprintf (stderr, "Pushed HIDE\n");
	XtUnmanageChild(mainWindow);
	XtPopdown(myshell);
}

void button_pushed (w, client_data, cbs)
Widget w;
XtPointer client_data;
XmPushButtonCallbackStruct *cbs;
{
	fprintf (stderr, "Pushed SHOW\n");
	XtManageChild(mainWindow);
	XtRealizeWidget(myshell);

	setStateHints(XtWindow(myshell), windowIconic);

	XtSetMappedWhenManaged(myshell, True);
	XtManageChild(mainWindow);
	XtPopup(myshell, XtGrabNone);
	XRaiseWindow(display, XtWindow(myshell));

}
main(argc, argv)
int argc;
char *argv[];
{
#define MAX_ARGC 50

	Arg	args[MAX_ARGC];
	Arg args2[MAX_ARGC];
	Widget toplevelshell, button, button2;
	Widget buttonList[2], controlWindow, controlShell;
	int counter, counter2;

	XtToolkitInitialize();
	my_appContext = XtCreateApplicationContext();
	display = XtOpenDisplay(my_appContext, "", argv[0], "MyView", NULL, 0, 
&argc, argv);

	windowIconic = False;
	counter = 0;
	XtSetArg(args[counter], XmNallowShellResize, TRUE); counter++;
	XtSetArg(args[counter], XmNargc, argc); counter++;
	XtSetArg(args[counter], XmNargv, argv); counter++;
	XtSetArg(args[counter], XmNx, 100); counter++;
	XtSetArg(args[counter], XmNy, 100); counter++;
	XtSetArg(args[counter], XmNwidth, 100); counter++;
	XtSetArg(args[counter], XmNheight, 100); counter++;

	toplevelshell = XtAppCreateShell(	"TopLevelShell",
						"MyView",
						 vendorShellWidgetClass,
						display,
						args,
						counter);
	counter = 3;

	myshell = XtCreatePopupShell(
						"Window!",
						 transientShellWidgetClass,
						toplevelshell,
						args,
						counter);

	XtAddEventHandler(myshell, StructureNotifyMask | FocusChangeMask, FALSE,
		(XtEventHandler)shellEH, NULL);

	controlShell = XtCreatePopupShell(
						"Control window!",
						 transientShellWidgetClass,
						toplevelshell,
						args,
						counter);

	counter2 = 0;
    XtSetArg(args2[counter2], XmNx, 200); counter2++;
    XtSetArg(args2[counter2], XmNy, 200); counter2++;
    XtSetArg(args2[counter2], XmNwidth, 100); counter2++;
    XtSetArg(args2[counter2], XmNheight, 100); counter2++;
    XtSetArg(args2[counter2], XmNmarginWidth, 0); counter2++;
    XtSetArg(args2[counter2], XmNmarginHeight, 0); counter2++;
    XtSetArg(args2[counter2], XmNhorizontalSpacing, 0); counter2++;
    XtSetArg(args2[counter2], XmNverticalSpacing, 0); counter2++;
    XtSetArg(args2[counter2], XmNresizePolicy, XmRESIZE_NONE); counter2++;
    XtSetArg(args2[counter2], XmNautoUnmanage, FALSE); counter2++;

	mainWindow = XmCreateForm(myshell, "Myiew", args2, counter2);
    XtSetArg(args2[0], XmNx, 300);
    XtSetArg(args2[1], XmNy, 300);
	controlWindow = XmCreateForm(controlShell, "MyCiew", args2, counter2);

	counter =0;
	button = XmCreatePushButton (controlWindow,
					"Show Window",
					NULL,
					counter);
	XtSetArg(args[counter],XmNtopAttachment, XmATTACH_FORM); counter++;
	XtSetArg(args[counter],XmNleftAttachment, XmATTACH_FORM); counter++;
	XtSetArg(args[counter],XmNrightAttachment, XmATTACH_FORM); counter++;
	XtSetValues(button, args,counter);
	buttonList[0] = button;
	XtAddCallback(button, XmNactivateCallback, button_pushed, NULL);

	counter =0;
	button2 = XmCreatePushButton (controlWindow,
					"Hide Window",
					NULL,
					counter);
	XtSetArg(args[counter],XmNtopAttachment, XmATTACH_WIDGET); counter++;
	XtSetArg(args[counter],XmNtopWidget, buttonList[0]); counter++;
	XtSetArg(args[counter],XmNleftAttachment, XmATTACH_FORM); counter++;
	XtSetArg(args[counter],XmNrightAttachment, XmATTACH_FORM); counter++;
	XtSetValues(button2, args,counter);

	buttonList[1] = button2;

	XtManageChildren(buttonList, 2);
	XtAddCallback(button2, XmNactivateCallback, button2_pushed, NULL);

	XtSetMappedWhenManaged(myshell, True);
	XtSetMappedWhenManaged(controlShell, True);
	XtSetMappedWhenManaged(mainWindow, True);

	XtManageChild(controlShell);
	XtManageChild(controlWindow);
	XtManageChild(myshell);
	XtManageChild(mainWindow);
	XtPopup(myshell, XtGrabNone);
	XtPopup(controlShell, XtGrabNone);

	XRaiseWindow(display, XtWindow(controlShell));

	XtRealizeWidget(toplevelshell);
	XtAppMainLoop(my_appContext);
}

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Dominik Vogt <[email-masked]>
Date: Mon, 26 Feb 2001 12:39:39 +0100

> widget in FVWM (not Sawfish, CDE, enlightenment etc.).

Please always mention which version you are using.

> Here is the simple code....thanks in advance, Matt.

I have no idea what your problem is at the moment, but your
program exits in line 149 with an X error message for me:

149  mainWindow = XmCreateForm(myshell, "Myiew", args2, counter2);

-->

Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  19 (X_DeleteProperty)
  Resource id in failed request:  0x0
  Serial number of failed request:  89
  Current serial number in output stream:  95

Bye

Dominik ^_^  ^_^

--
Dominik Vogt, [email-masked]
Reply-To: [email-masked]
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].