1 /* # skkinput (Simple Kana-Kanji Input)
2  *
3  * This file is part of skkinput.
4  * Copyright (C) 2002
5  * Takashi SAKAMOTO (PXG01715@nifty.ne.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 "AfxWin.h"
22 #include <X11/Xproto.h>
23 #include "dispatch.h"
24 
25 static	Widget		swgToplevel			= NULL ;
26 
27 Boolean
AfxWinInitialize(register Widget wgToplevel)28 AfxWinInitialize (
29 	register Widget		wgToplevel)
30 {
31 	swgToplevel	= wgToplevel ;
32 	return	True ;
33 }
34 
35 Display*
AfxGetDisplay(void)36 AfxGetDisplay (void)
37 {
38 	return	XtDisplay (swgToplevel) ;
39 }
40 
41 Widget
AfxGetToplevelWidget(void)42 AfxGetToplevelWidget (void)
43 {
44 	return	swgToplevel ;
45 }
46 
47 int
AfxHandleXError(register Display * pDisplay,register XErrorEvent * pErrorEvent)48 AfxHandleXError (
49 	register Display*		pDisplay,
50 	register XErrorEvent*	pErrorEvent)
51 {
52 #if defined (DEBUG)
53 	static	const char*	const rstrRequest []	= {
54 		"X_CreateWindow", 			"X_ChangeWindowAttributes",
55 		"X_GetWindowAttributes",	"X_DestroyWindow",
56 		"X_DestroySubwindows",		"X_ChangeSaveSet",
57 		"X_ReparentWindow",			"X_MapWindow",
58 		"X_MapSubwindows",			"X_UnmapWindow",
59 		"X_UnmapSubwindows",		"X_ConfigureWindow",
60 		"X_CirculateWindow",		"X_GetGeometry",
61 		"X_QueryTree",				"X_InternAtom",
62 		"X_GetAtomName",			"X_ChangeProperty",
63 		"X_DeleteProperty",			"X_GetProperty",
64 		"X_ListProperties",			"X_SetSelectionOwner",
65 		"X_GetSelectionOwner",		"X_ConvertSelection",
66 		"X_SendEvent",				"X_GrabPointer",
67 		"X_UngrabPointer",			"X_GrabButton",
68 		"X_UngrabButton",			"X_ChangeActivePointerGrab",
69 		"X_GrabKeyboard",			"X_UngrabKeyboard",
70 		"X_GrabKey",				"X_UngrabKey",
71 		"X_AllowEvents",			"X_GrabServer",
72 		"X_UngrabServer",			"X_QueryPointer",
73 		"X_GetMotionEvents",		"X_TranslateCoords",
74 		"X_WarpPointer",			"X_SetInputFocus",
75 		"X_GetInputFocus",			"X_QueryKeymap",
76 		"X_OpenFont",				"X_CloseFont",
77 		"X_QueryFont",				"X_QueryTextExtents",
78 		"X_ListFonts",				"X_ListFontsWithInfo",
79 		"X_SetFontPath",			"X_GetFontPath",
80 		"X_CreatePixmap",			"X_FreePixmap",
81 		"X_CreateGC",				"X_ChangeGC",
82 		"X_CopyGC",					"X_SetDashes",
83 		"X_SetClipRectangles",		"X_FreeGC",
84 		"X_ClearArea",				"X_CopyArea",
85 		"X_CopyPlane",				"X_PolyPoint",
86 		"X_PolyLine",				"X_PolySegment",
87 		"X_PolyRectangle",			"X_PolyArc",
88 		"X_FillPoly",				"X_PolyFillRectangle",
89 		"X_PolyFillArc",			"X_PutImage",
90 		"X_GetImage",				"X_PolyText8",
91 		"X_PolyText16",				"X_ImageText8",
92 		"X_ImageText16",			"X_CreateColormap",
93 		"X_FreeColormap",			"X_CopyColormapAndFree",
94 		"X_InstallColormap",		"X_UninstallColormap",
95 		"X_ListInstalledColormaps",	"X_AllocColor",
96 		"X_AllocNamedColor",		"X_AllocColorCells",
97 		"X_AllocColorPlanes",		"X_FreeColors",
98 		"X_StoreColors",			"X_StoreNamedColor",
99 		"X_QueryColors",			"X_LookupColor",
100 		"X_CreateCursor",			"X_CreateGlyphCursor",
101 		"X_FreeCursor",				"X_RecolorCursor",
102 		"X_QueryBestSize",			"X_QueryExtension",
103 		"X_ListExtensions",			"X_ChangeKeyboardMapping",
104 		"X_GetKeyboardMapping",		"X_ChangeKeyboardControl",
105 		"X_GetKeyboardControl",		"X_Bell",
106 		"X_ChangePointerControl",	"X_GetPointerControl",
107 		"X_SetScreenSaver",			"X_GetScreenSaver",
108 		"X_ChangeHosts",			"X_ListHosts",
109 		"X_SetAccessControl",		"X_SetCloseDownMode",
110 		"X_KillClient",				"X_RotateProperties",
111 		"X_ForceScreenSaver",		"X_SetPointerMapping",
112 		"X_GetPointerMapping",		"X_SetModifierMapping",
113 		"X_GetModifierMapping",		NULL, /* 120 */
114 		NULL,						NULL,
115 		NULL,						NULL,
116 		NULL,						NULL,
117 		"X_NoOperation",
118 	} ;
119 	char	rchBuffer [256] ;
120 
121 	XGetErrorText (pDisplay, pErrorEvent->error_code, rchBuffer, NELEMENTS (rchBuffer) - 1) ;
122 	rchBuffer [NELEMENTS (rchBuffer) - 1]	= '\0' ;
123 	fprintf (stderr, "XErrorEvent: \"%s\"\n", rchBuffer) ;
124 	fprintf (stderr, "Display  (%p)\n",  pErrorEvent->display) ;
125 	fprintf (stderr, "Serial   (%ld)\n", pErrorEvent->serial) ;
126 	fprintf (stderr, "Request  (") ;
127 	if (X_CreateWindow <= pErrorEvent->request_code &&
128 		pErrorEvent->request_code <= X_NoOperation  &&
129 		rstrRequest [pErrorEvent->request_code - X_CreateWindow] != NULL) {
130 		fprintf (stderr, "%s", rstrRequest [pErrorEvent->request_code - X_CreateWindow]) ;
131 	} else {
132 		fprintf (stderr, "%d", pErrorEvent->request_code) ;
133 	}
134 	fprintf (stderr, ")\n") ;
135 	fprintf (stderr, "minor    (%d)\n",  pErrorEvent->minor_code) ;
136 	fprintf (stderr, "resource (%lx)\n", pErrorEvent->resourceid) ;
137 #endif
138 	return	0 ;
139 }
140 
141 
142