1 /* # skkinput (Simple Kana-Kanji Input)
2 * WmcloseShell.c --- Define Window Manager Close Shell Widget Class
3 * This file is part of skkinput.
4 * Copyright (C) 1997
5 * Takashi SAKAMOTO (sakamoto@yajima.kuis.kyoto-u.ac.jp)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with skkinput; see the file COPYING. If not, write to
19 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21 #include <stdio.h>
22 #include <X11/Xos.h>
23 #include <X11/Xlib.h>
24 #include <X11/Xutil.h>
25 #include <X11/Xatom.h>
26 #include <X11/IntrinsicP.h>
27 #include <X11/StringDefs.h>
28 #include <X11/Shell.h>
29
30 #include "WmcloseShellP.h"
31
32 /*
33 * �ץ�ȥ����������
34 */
35 static void WMCS_Initialize
36 ( Widget greq, Widget gnew, ArgList args, Cardinal *num_args ) ;
37 static void WMCS_Realize
38 ( Widget gw, XtValueMask *valuemask, XSetWindowAttributes *attr ) ;
39 static Boolean WMCS_SetValues
40 ( Widget current, Widget request, Widget new,
41 ArgList args, Cardinal *num_args ) ;
42 static void WMCS_Close
43 ( Widget gw, XEvent *xevent, String *params, Cardinal *num_params ) ;
44 static void WMCS_Destroy( Widget gw ) ;
45
46 extern int IsWindowExist( Display *disp, Window win ) ;
47
48
49 #define offset(field) XtOffsetOf( WmcloseShellRec, wmclose.field)
50 #define goffset(field) XtOffsetOf( WidgetRec, shell.field )
51
52 static XtResource WMCS_resources[] = {
53 { XtNwmcloseNotify, XtCCallback, XtRCallback, sizeof( caddr_t ),
54 offset( wmclosecallback ), XtRCallback, ( caddr_t )NULL },
55 { XtNdestroyNotify, XtCCallback, XtRCallback, sizeof( caddr_t ),
56 offset( destroycallback ), XtRCallback, ( caddr_t )NULL },
57 } ;
58
59 #undef offset
60 #undef goffset
61
62 static XtActionsRec wmcloseActionsTbl [] = {
63 { "WMMessageHandler", WMCS_Close },
64 };
65
66 static char defaultWmcloseTranslations[] =
67 "<Message>WM_PROTOCOLS: WMMessageHandler()\n" ;
68
69 WmcloseShellClassRec wmcloseShellClassRec = {
70 { /* core fields */
71 /* superclass */ (WidgetClass) &transientShellClassRec,
72 /* class_name */ "WmcloseShell",
73 /* widget_size */ sizeof( WmcloseShellRec ),
74 /* class_initialize */ NULL,
75 /* class_part_initialize */ NULL,
76 /* class_inited */ FALSE,
77 /* initialize */ WMCS_Initialize,
78 /* initialize_hook */ NULL,
79 /* realize */ WMCS_Realize,
80 /* actions */ wmcloseActionsTbl,
81 /* num_actions */ XtNumber( wmcloseActionsTbl ),
82 /* resources */ WMCS_resources,
83 /* num_resources */ XtNumber( WMCS_resources ),
84 /* xrm_class */ NULLQUARK,
85 /* compress_motion */ TRUE,
86 /* compress_exposure */ TRUE,
87 /* compress_enterleave */ TRUE,
88 /* visible_interest */ FALSE,
89 /* destroy */ WMCS_Destroy,
90 /* resize */ XtInheritResize,
91 /* expose */ XtInheritExpose,
92 /* set_values */ WMCS_SetValues,
93 /* set_values_hook */ NULL,
94 /* set_values_almost */ XtInheritSetValuesAlmost,
95 /* get_values_hook */ NULL,
96 /* accept_focus */ NULL,
97 /* version */ XtVersion,
98 /* callback_private */ NULL,
99 /* tm_table */ defaultWmcloseTranslations,
100 /* query_geometry */ XtInheritQueryGeometry,
101 /* display_accelerator */ XtInheritDisplayAccelerator,
102 /* extension */ NULL
103 },
104 { /* Composite */
105 /* geometry_manager */ XtInheritGeometryManager,
106 /* change_managed */ XtInheritChangeManaged,
107 /* insert_child */ XtInheritInsertChild,
108 /* delete_child */ XtInheritDeleteChild,
109 /* extension */ NULL
110 },
111 { /* shell fields */
112 /* extension */ NULL
113 },
114 { /* Window Manager Shell fields */
115 /* extension */ NULL
116 },
117 { /* Vendor Shell fields */
118 /* extension */ NULL
119 },
120 { /* transientShell fields */
121 /* extension */ NULL
122 },
123 { /* WmcloseShell fields */
124 /* empty */ 0
125 }
126 };
127
128 WidgetClass wmcloseShellWidgetClass =
129 ( WidgetClass )&wmcloseShellClassRec ;
130
WMCS_Initialize(Widget greq,Widget gnew,ArgList args,Cardinal * num_args)131 static void WMCS_Initialize
132 ( Widget greq, Widget gnew, ArgList args, Cardinal *num_args )
133 {
134 /* �äˤ��뤳�Ȥ�̵���ä��ꤹ�뤢���꤬�ʤ��ʤ���*/
135 return ;
136 }
137
WMCS_Realize(Widget gw,XtValueMask * valuemask,XSetWindowAttributes * attr)138 static void WMCS_Realize
139 ( Widget gw, XtValueMask *valuemask, XSetWindowAttributes *attr )
140 {
141 /* WM_PROTOCOL ������뤿���ɬ�פ� ATOM */
142 static Atom wm_delete_window = None ;
143
144 /* ��Ȥ�Ȥ� realize �ؿ������Ѥ��Ƶ�������*/
145 ( *wmcloseShellWidgetClass->core_class.superclass->core_class.realize)
146 (gw, valuemask, attr) ;
147
148 if( wm_delete_window == None ){
149 /* Window Manager �� delete message ���������褦�� atom ���롣*/
150 wm_delete_window = XInternAtom
151 ( XtDisplay( gw ), "WM_DELETE_WINDOW", False ) ;
152 }
153 (void) XSetWMProtocols
154 ( XtDisplay( gw ), XtWindow( gw ), &wm_delete_window, 1 ) ;
155 return ;
156 }
157
158 /*
159 *
160 */
WMCS_SetValues(Widget current,Widget request,Widget new,ArgList args,Cardinal * num_args)161 static Boolean WMCS_SetValues
162 ( Widget current, Widget request, Widget new,
163 ArgList args, Cardinal *num_args )
164 {
165 return FALSE ;
166 }
167
WMCS_Close(Widget gw,XEvent * xevent,String * params,Cardinal * num_params)168 static void WMCS_Close
169 ( Widget gw, XEvent *xevent, String *params, Cardinal *num_params )
170 {
171 /* Window Manager �����Ĥ���褦���������ä����Ȥ�롣*/
172 XtCallCallbacks( gw, XtNwmcloseNotify, NULL ) ;
173 return ;
174 }
175
WMCS_Destroy(Widget gw)176 static void WMCS_Destroy( Widget gw )
177 {
178 /* Window Manager �����Ĥ���褦���������ä����Ȥ�롣*/
179 XtCallCallbacks( gw, XtNdestroyNotify, NULL ) ;
180 return ;
181 }
182
183