Iconify.c revision e9fcaa8a
1
2/***********************************************************
3Copyright 1988 by Wyse Technology, Inc., San Jose, Ca.
4
5                        All Rights Reserved
6
7Permission to use, copy, modify, and distribute this software and its
8documentation for any purpose and without fee is hereby granted,
9provided that the above copyright notice appear in all copies and that
10both that copyright notice and this permission notice appear in
11supporting documentation, and that the name Wyse not be
12used in advertising or publicity pertaining to distribution of the
13software without specific, written prior permission.
14
15WYSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
16ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
17DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
18ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
19WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
20ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
21SOFTWARE.
22
23******************************************************************/
24/*
25
26Copyright 1988, 1998  The Open Group
27
28Permission to use, copy, modify, distribute, and sell this software and its
29documentation for any purpose is hereby granted without fee, provided that
30the above copyright notice appear in all copies and that both that
31copyright notice and this permission notice appear in supporting
32documentation.
33
34The above copyright notice and this permission notice shall be included
35in all copies or substantial portions of the Software.
36
37THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
38OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
39MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
40IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
41OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
42ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
43OTHER DEALINGS IN THE SOFTWARE.
44
45Except as contained in this notice, the name of The Open Group shall
46not be used in advertising or otherwise to promote the sale, use or
47other dealings in this Software without prior written authorization
48from The Open Group.
49
50*/
51
52#ifdef HAVE_CONFIG_H
53#include <config.h>
54#endif
55#include <X11/Xlibint.h>
56#include <X11/Xatom.h>
57#include <X11/Xos.h>
58#include <X11/Xutil.h>
59#include <stdio.h>
60
61/*
62 * This function instructs the window manager to change this window from
63 * NormalState to IconicState.
64 */
65Status XIconifyWindow (
66    Display *dpy,
67    Window w,
68    int screen)
69{
70    XClientMessageEvent ev;
71    Window root = RootWindow (dpy, screen);
72    Atom prop;
73
74    prop = XInternAtom (dpy, "WM_CHANGE_STATE", False);
75    if (prop == None) return False;
76
77    ev.type = ClientMessage;
78    ev.window = w;
79    ev.message_type = prop;
80    ev.format = 32;
81    ev.data.l[0] = IconicState;
82    return (XSendEvent (dpy, root, False,
83			SubstructureRedirectMask|SubstructureNotifyMask,
84			(XEvent *)&ev));
85}
86