FVWM: Iconisation issue

From: Matt H <mathatwork_at_hotmail.com>
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 majordomo_at_fvwm.org.
To report problems, send mail to fvwm-owner_at_fvwm.org.
Received on Mon Feb 26 2001 - 04:05:29 GMT

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:37:51 BST