Mercurial > kinput2.yaz
comparison lib/AdoptedShe.c @ 0:92745d501b9a
initial import from kinput2-v3.1
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Mon, 08 Mar 2010 04:44:30 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:92745d501b9a |
---|---|
1 #ifndef lint | |
2 static char *rcsid = "$Id: AdoptedShe.c,v 1.6 1991/09/23 04:03:31 ishisone Rel $"; | |
3 #endif | |
4 /* | |
5 * Copyright (c) 1990 Software Research Associates, Inc. | |
6 * | |
7 * Permission to use, copy, modify, and distribute this software and its | |
8 * documentation for any purpose and without fee is hereby granted, provided | |
9 * that the above copyright notice appear in all copies and that both that | |
10 * copyright notice and this permission notice appear in supporting | |
11 * documentation, and that the name of Software Research Associates not be | |
12 * used in advertising or publicity pertaining to distribution of the | |
13 * software without specific, written prior permission. Software Research | |
14 * Associates makes no representations about the suitability of this software | |
15 * for any purpose. It is provided "as is" without express or implied | |
16 * warranty. | |
17 * | |
18 * Author: Makoto Ishisone, Software Research Associates, Inc., Japan | |
19 */ | |
20 | |
21 #include <X11/IntrinsicP.h> | |
22 #include <X11/StringDefs.h> | |
23 #include "AdoptedShP.h" | |
24 | |
25 static XtResource resources[] = { | |
26 #define offset(field) XtOffset(AdoptedShellWidget, adoptedshell.field) | |
27 { XtNparentWindow, XtCParentWindow, XtRWindow, sizeof(Window), | |
28 offset(parent), XtRImmediate, None }, | |
29 { XtNdisableGeometryManagement, XtCDisableGeometryManagement, | |
30 XtRBoolean, sizeof(Boolean), | |
31 offset(disable_geometry), XtRString, "False" }, | |
32 #undef offset | |
33 }; | |
34 | |
35 static void Initialize(); | |
36 static void Realize(); | |
37 static Boolean SetValues(); | |
38 static XtGeometryResult GeometryManager(); | |
39 | |
40 static void GetParentInfo(); | |
41 | |
42 AdoptedShellClassRec adoptedShellClassRec = { | |
43 { /* core fields */ | |
44 /* superclass */ (WidgetClass) &overrideShellClassRec, | |
45 /* class_name */ "AdoptedShell", | |
46 /* widget_size */ sizeof(AdoptedShellRec), | |
47 /* class_initialize */ NULL, | |
48 /* class_part_initialize */ NULL, | |
49 /* class_inited */ FALSE, | |
50 /* initialize */ Initialize, | |
51 /* initialize_hook */ NULL, | |
52 /* realize */ Realize, | |
53 /* actions */ NULL, | |
54 /* num_actions */ 0, | |
55 /* resources */ resources, | |
56 /* num_resources */ XtNumber(resources), | |
57 /* xrm_class */ NULLQUARK, | |
58 /* compress_motion */ TRUE, | |
59 /* compress_exposure */ TRUE, | |
60 /* compress_enterleave */ TRUE, | |
61 /* visible_interest */ FALSE, | |
62 /* destroy */ NULL, | |
63 /* resize */ XtInheritResize, | |
64 /* expose */ XtInheritExpose, | |
65 /* set_values */ SetValues, | |
66 /* set_values_hook */ NULL, | |
67 /* set_values_almost */ XtInheritSetValuesAlmost, | |
68 /* get_values_hook */ NULL, | |
69 /* accept_focus */ NULL, | |
70 /* version */ XtVersion, | |
71 /* callback_private */ NULL, | |
72 /* tm_table */ NULL, | |
73 /* query_geometry */ XtInheritQueryGeometry, | |
74 /* display_accelerator */ XtInheritDisplayAccelerator, | |
75 /* extension */ NULL | |
76 }, | |
77 { /* Composite */ | |
78 /* geometry_manager */ GeometryManager, | |
79 /* change_managed */ XtInheritChangeManaged, | |
80 /* insert_child */ XtInheritInsertChild, | |
81 /* delete_child */ XtInheritDeleteChild, | |
82 /* extension */ NULL | |
83 }, | |
84 { /* shell fields */ | |
85 /* extension */ NULL | |
86 }, | |
87 { /* overrideShell fields */ | |
88 /* extension */ NULL | |
89 }, | |
90 { /* AdoptedShell fields */ | |
91 /* empty */ 0 | |
92 } | |
93 }; | |
94 | |
95 WidgetClass adoptedShellWidgetClass = (WidgetClass)&adoptedShellClassRec; | |
96 | |
97 /* ARGSUSED */ | |
98 static void | |
99 Initialize(req, new, args, num_args) | |
100 Widget req; | |
101 Widget new; | |
102 ArgList args; | |
103 Cardinal *num_args; | |
104 { | |
105 AdoptedShellWidget asw = (AdoptedShellWidget)new; | |
106 Cardinal i; | |
107 | |
108 asw->adoptedshell.colormap_specified = False; | |
109 for (i = 0; i < *num_args; i++) { | |
110 if (!strcmp(args[i].name, XtNcolormap)) { | |
111 asw->adoptedshell.colormap_specified = True; | |
112 break; | |
113 } | |
114 } | |
115 } | |
116 | |
117 static void | |
118 Realize(w, maskp, attr) | |
119 Widget w; | |
120 XtValueMask *maskp; | |
121 XSetWindowAttributes *attr; | |
122 { | |
123 AdoptedShellWidget asw = (AdoptedShellWidget)w; | |
124 Window savedroot; | |
125 | |
126 if (asw->adoptedshell.parent == None) { | |
127 asw->adoptedshell.parent = w->core.screen->root; | |
128 } else { | |
129 GetParentInfo(asw); | |
130 } | |
131 asw->adoptedshell.colormap_specified = False; | |
132 | |
133 /* cheat the super-class's realize function */ | |
134 savedroot = w->core.screen->root; | |
135 w->core.screen->root = asw->adoptedshell.parent; | |
136 | |
137 /* call super class's realize function */ | |
138 (*adoptedShellWidgetClass->core_class.superclass->core_class.realize)(w, maskp, attr); | |
139 | |
140 /* restore savedroot */ | |
141 w->core.screen->root = savedroot; | |
142 } | |
143 | |
144 /* ARGSUSED */ | |
145 static Boolean | |
146 SetValues(cur, req, new, args, num_args) | |
147 Widget cur; | |
148 Widget req; | |
149 Widget new; | |
150 ArgList args; | |
151 Cardinal *num_args; | |
152 { | |
153 AdoptedShellWidget asw = (AdoptedShellWidget)new; | |
154 AdoptedShellWidget old = (AdoptedShellWidget)cur; | |
155 | |
156 if (asw->adoptedshell.parent != old->adoptedshell.parent) { | |
157 if (XtIsRealized(new)) { | |
158 XtAppError(XtWidgetToApplicationContext(new), | |
159 "AdoptedShell: can't change parent window after realization"); | |
160 } | |
161 } | |
162 if (asw->core.colormap != old->core.colormap && !XtIsRealized(new)) { | |
163 asw->adoptedshell.colormap_specified = True; | |
164 } | |
165 return False; | |
166 } | |
167 | |
168 static XtGeometryResult | |
169 GeometryManager(w, reqp, repp) | |
170 Widget w; | |
171 XtWidgetGeometry *reqp; | |
172 XtWidgetGeometry *repp; | |
173 { | |
174 AdoptedShellWidget asw = (AdoptedShellWidget)XtParent(w); | |
175 ShellWidgetClass super; | |
176 | |
177 if (asw->adoptedshell.disable_geometry) return XtGeometryYes; | |
178 | |
179 super = (ShellWidgetClass)(adoptedShellWidgetClass->core_class.superclass); | |
180 return (*super->composite_class.geometry_manager)(w, reqp, repp); | |
181 } | |
182 | |
183 static void | |
184 GetParentInfo(w) | |
185 AdoptedShellWidget w; | |
186 { | |
187 Window parent = w->adoptedshell.parent; | |
188 XWindowAttributes attr; | |
189 | |
190 (void)XGetWindowAttributes(XtDisplay((Widget)w), parent, &attr); | |
191 w->core.screen = attr.screen; | |
192 if (!w->adoptedshell.colormap_specified) w->core.colormap = attr.colormap; | |
193 /* may be I should honor user-specified visual, etc. */ | |
194 w->core.depth = attr.depth; | |
195 w->shell.visual = attr.visual; | |
196 } |