Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / lib / DtTerm / TermPrim / TermPrimWMProtocols.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 #ifndef lint
24 #ifdef  VERBOSE_REV_INFO
25 static char rcs_id[] = "$XConsortium: TermPrimWMProtocols.c /main/1 1996/04/21 19:20:04 drk $";
26 #endif  /* VERBOSE_REV_INFO */
27 #endif  /* lint */
28 /*                                                                      *
29  * (c) Copyright 1993, 1994, 1996 Hewlett-Packard Company               *
30  * (c) Copyright 1993, 1994, 1996 International Business Machines Corp. *
31  * (c) Copyright 1993, 1994, 1996 Sun Microsystems, Inc.                *
32  * (c) Copyright 1993, 1994, 1996 Novell, Inc.                          *
33  * (c) Copyright 1996 Digital Equipment Corporation.                    *
34  * (c) Copyright 1996 FUJITSU LIMITED.                                  *
35  * (c) Copyright 1996 Hitachi.                                          *
36  */
37
38 #include "TermHeader.h"
39 #include "TermPrimDebug.h"
40 #include <Xm/Xm.h>
41 #include <Xm/Protocols.h>
42
43 static Atom xa_WM_DELETE_WINDOW;
44 static Atom xa_WM_SAVE_YOURSELF;
45 static Boolean initialized = False;
46
47 static void
48 protocolsInitialize(Widget topLevel)
49 {
50     if (!initialized) {
51         xa_WM_DELETE_WINDOW = XInternAtom(XtDisplay(topLevel),
52                 "WM_DELETE_WINDOW", False);
53         xa_WM_SAVE_YOURSELF = XInternAtom(XtDisplay(topLevel),
54                 "WM_SAVE_YOURSELF", False);
55         initialized = True;
56     }
57 }
58
59 void
60 _DtTermPrimAddDeleteWindowCallback(Widget topLevel, XtCallbackProc callback,
61         XtPointer client_data)
62 {
63     /* initialize things... */
64     _DtTermProcessLock();
65     if (!initialized)
66         (void) protocolsInitialize(topLevel);
67     _DtTermProcessUnlock();
68     (void) XmAddWMProtocols(topLevel, &xa_WM_DELETE_WINDOW, 1);
69     (void) XmAddWMProtocolCallback(topLevel, xa_WM_DELETE_WINDOW, callback,
70             client_data);
71 }
72
73 void
74 _DtTermPrimAddSaveYourselfCallback(Widget topLevel, XtCallbackProc callback,
75         XtPointer client_data)
76 {
77     /* initialize things... */
78     _DtTermProcessLock();
79     if (!initialized)
80         (void) protocolsInitialize(topLevel);
81     _DtTermProcessUnlock();
82     (void) XmAddWMProtocols(topLevel, &xa_WM_SAVE_YOURSELF, 1);
83     (void) XmAddWMProtocolCallback(topLevel, xa_WM_SAVE_YOURSELF, callback,
84             client_data);
85 }