jerryl@is.Morgan.COM (Jerry Liebelson) (05/08/91)
Hi - 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? I'm running Motif 1.1, X11R4 patchlevel 18, SunOS 4.11. Thanks. -- |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| | Jerry Liebelson | EMAIL: jerryl@is.morgan.com | | Information Systems | uunet!is.morgan.com!jerryl | | Morgan Stanley, Inc. | VOICE: (212) 703-2409 | | 1633 Broadway 36th Floor | FAX: (212) 703-2371 | | New York, NY 10019 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
wwang@osf.org ("Weidong Wang from OSF") (05/08/91)
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
wwang@osf.org ("Weidong Wang from OSF") (05/08/91)
I sent out some code segment showing how to check the window state, how to iconify/deiconify a window, Actually, X11R4 has a new function XIconifyWindow() to iconify a window, and you can simply use XMapWindow() to deiconify. Weidong Wang
toml@marvin.Solbourne.COM (Tom LaStrange) (05/08/91)
|> 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; |> } This is not a safe thing to do and the ICCCM kind of frowns on it. Section 4.1.3.1 WM_STATE "In general, clients should not need to examine the contents of this property; it is intended for communication between window and session managers." What if the window changes state between the time you you get the property and return it? You should watch for and keep track of MapNotify and UnmapNotify events if you want to track your current state. -- (I kid you not)Tom LaStrange toml@Solbourne.COM
wwang@osf.org ("Weidong Wang from OSF") (05/10/91)
toml@Solbourne.COM(Tom LaStrange) wrote: > > What if the window changes state between the time you you get the property > and return it? You get another PropertyNotify event. > You should watch for and keep track of MapNotify and > UnmapNotify events if you want to track your current state. > Not true. A window can have three states: Normal, Iconic, and Withdrawn. When you unmap a window (you will get a UnmapNotify event), the window state changes from Normal/Iconic to WithDrawn, not Iconic. You can use MapNotify event to know that the window state has changed from Iconic/WithDrawn to Normal.