Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!tut.cis.ohio-state.edu!ucbvax!osf.org!wwang From: wwang@osf.org ("Weidong Wang from OSF") Newsgroups: comp.windows.x.motif Subject: Re: What is the best way to iconify/deiconify? Message-ID: <9105081533.AA19820@osfsun> Date: 8 May 91 08:33:45 GMT References: <9105071922.AA15644@15644> Sender: daemon@ucbvax.BERKELEY.EDU Distribution: inet Organization: The Internet Lines: 79 jerryl@is.Morgan.COM (Jerry Liebelson) wrote: > > 1. Can people send me a code that shows the best (and easiest) way to > iconify and deiconify windows? > > 2. Also, how can I tell at any given moment, whether a given window is > iconified or not? > Jerry: Here are the code segments: /* check the window state, call it when you get a PropertyNotify event */ void checkState(w, cd, event) Widget w; char *cd; XPropertyEvent *event; { Arg args[1]; Boolean iconic; Atom actual_type, atom; int actual_format; unsigned long nitems, bytes_after; unsigned char *data; long *state; atom = XInternAtom(display, "WM_STATE", False); XGetWindowProperty(display, window, atom, 0L, 1L, False, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, &data); printf("actual_type: %s, actual_format: %d, nitems: %d, bytes_after: %d\n", XGetAtomName(dpy, actual_type), actual_format, nitems, bytes_after); state = (long *)data; if (*state == NormalState) printf("NormalState\n"); if (*state == IconicState) printf("IconicState\n"); if (*state == WithdrawnState) printf("WithdrawnState\n"); free(date); return; } } /* to iconfoy a window */ void IconifyShell(w, d1, d2) Widget w; caddr_t d1, d2; { XClientMessageEvent event; Window win; Display *dpy; event.type = ClientMessage; event.send_event = True; dpy = event.display = XtDisplay(w); win = event.window = XtWindow(ApplicationShellWidget); event.message_type = XInternAtom(dpy, "WM_STATE", False); event.format = 32; event.data.l[0] = IconicState; XSendEvent(dpy, DefaultRootWindow(dpy), False, SubstructureRedirectMask | SubstructureNotifyMask, &event); XFlush(dpy); sleep(3); XMapWindow(dpy,win); } I think you can figure out how to deiconify. yes, change the above event.data.l[0] = NormalState; ------------------------------------------------------------- Weidong Wang wwang@osf.org Systems Engineering, OSF uunet!osf.org!wwang