aboutsummaryrefslogtreecommitdiff
path: root/chinese/xcin25/files/patch-af
blob: e7cd753ebdbe86153ca3dce089078b213daa4c22 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
--- src/include/gui.h.orig	Wed Feb 23 09:47:57 2000
+++ src/include/gui.h	Thu Feb 24 01:55:36 2000
@@ -30,6 +30,7 @@
  */
 #define WIN_CHANGE_IM_CONTENT   0x0001
 #define WIN_CHANGE_IM           0x00ff
+#define WIN_CHANGE_FOCUS	0x0100
 
 /*
  *  Window Identifier.
--- src/include/xcin_core.h.orig	Wed Feb 23 09:47:57 2000
+++ src/include/xcin_core.h	Thu Feb 24 01:55:36 2000
@@ -88,7 +88,7 @@
 
     /* XIM & Input Method configuration. */
     XIMS ims;
-    IC *ic;
+    IC *ic, *icp;
     xmode_t xcin_mode;
     inp_state_t default_im;
     inp_state_t default_im_sinmd;
--- src/gui.c.orig	Wed Feb 23 09:47:57 2000
+++ src/gui.c	Thu Feb 24 01:55:36 2000
@@ -191,31 +191,19 @@
 	return;
 
     if (state) {
-	if (! win->winmap) {
+	if (win->winmap == (ubyte_t)0) {
 	    XMapWindow(gui->display, win->window);
 	    win->winmap = (byte_t)1;
 	}
     }
     else {
-	if (win->winmap) {
+	if (win->winmap == (ubyte_t)1) {
 	    XUnmapWindow(gui->display, win->window);
 	    win->winmap = (byte_t)0;
 	}
     }
 }
 
-void 
-gui_greq_winmap_change(gui_t *gui, greq_win_t *greqw, int state)
-{
-    winlist_t *w;
-    int i;
-
-    for (i=0; i<greqw->n_greq; i++) {
-	w = (winlist_t *)(greqw->win[i]);
-	gui_winmap_change(gui, w, state);
-    }
-}
-
 void
 gui_greq_win_destroy(greq_win_t *greqw)
 {
@@ -229,22 +217,6 @@
 }
 
 void
-gui_overspot_winmap_change(gui_t *gui, int imid, int state)
-{
-    winlist_t *w = xccore->win;
-
-    while (w) {
-	if (w->imid == imid && w->wid == WID_OVERSPOT) {
-	    gui_winmap_change(gui, w, state);
-	    if (state == 1)
-		XRaiseWindow(gui->display, w->window);
-	    break;
-	}
-	w = w->next;
-    }
-}
-
-void
 gui_overspot_destroy(int imid)
 {
     winlist_t *w = xccore->win;
@@ -351,6 +323,20 @@
     return win;
 }
 
+static void 
+gui_greq_windraw(gui_t *gui, greq_win_t *greqw, int state)
+{
+    winlist_t *w;
+    int i;
+
+    for (i=0; i<greqw->n_greq; i++) {
+	w = (winlist_t *)(greqw->win[i]);
+	gui_winmap_change(gui, w, state);
+	if (state)
+	    w->win_draw_func(&(xccore->gui), w);
+    }
+}
+
 static void
 update_gui_request(void)
 {
@@ -360,6 +346,13 @@
     greq_win_t gw_handling;
     int i, j;
 
+    if ((xccore->gui.winchange & WIN_CHANGE_FOCUS) && xccore->icp) {
+	greq_win_t *greqw = &(xccore->icp->imc->gwin);
+	for (i=0; i<greqw->n_greq; i++) {
+	    win = (winlist_t *)(greqw->win[i]);
+	    gui_winmap_change(&(xccore->gui), win, 0);
+	}
+    }
     if (! greqd && imc->gwin.n_greq == 0)
 	return;
     
@@ -384,14 +377,11 @@
 	    gw_handling.win[gw_handling.n_greq] = imc->gwin.win[i];
 	    (gw_handling.n_greq) ++;
 
-	    if ((win = search_winlist(xccore->win, WID_GUIREQ, 
-				imc->id, greqd->reqid)))
-		win->win_draw_func(&(xccore->gui), win);
-	    else {
-		if ((win=gui_request_init(imc, greqd))) {
-		    xccore->win_end->next = win;
-		    xccore->win_end = win;
-		}
+	    if (! search_winlist(xccore->win, 
+			WID_GUIREQ, imc->id, greqd->reqid) &&
+		(win=gui_request_init(imc, greqd))) {
+		xccore->win_end->next = win;
+		xccore->win_end = win;
 	    }
 	}
 	greqd = greqd->next;
@@ -407,15 +397,13 @@
     }
     memcpy(&(imc->gwin), &(gw_handling), sizeof(greq_win_t));
 
-    if ((xccore->xcin_mode & XCIN_SINGLE_IMC)) {
+//    if ((xccore->xcin_mode & XCIN_SINGLE_IMC)) {
 	if (! xccore->ic || !(xccore->ic->imc->inp_state & IM_CINPUT) ||
-			    !(xccore->ic->imc->inp_state & IM_XIMFOCUS)) {
-	    gui_greq_winmap_change(&(xccore->gui), &(imc->gwin), 0);
-	    return;
-	}
+			    !(xccore->ic->imc->inp_state & IM_XIMFOCUS))
+	    gui_greq_windraw(&(xccore->gui), &(imc->gwin), 0);
 	else
-	    gui_greq_winmap_change(&(xccore->gui), &(imc->gwin), 1);
-    }
+	    gui_greq_windraw(&(xccore->gui), &(imc->gwin), 1);
+//    }
 }
 
 /*--------------------------------------------------------------------------*/
@@ -425,16 +413,17 @@
 update_gui_overspot(void)
 {
     winlist_t *win;
-    IC *ic = xccore->ic;
+    IC *ic = xccore->ic, *icp = xccore->icp;
 
-    if (ic->imc->pre_attr == NULL)
-	ic->imc->pre_attr = &(ic->pre_attr);
-    if (ic->imc->sts_attr == NULL)
-	ic->imc->sts_attr = &(ic->sts_attr);
+    if ((xccore->gui.winchange & WIN_CHANGE_FOCUS) && icp &&
+	(win = search_winlist(xccore->win, WID_OVERSPOT, icp->imc->id, 0)))
+	gui_winmap_change(&(xccore->gui), win, 0);
 
     if ((win = search_winlist(xccore->win, WID_OVERSPOT, ic->imc->id, 0)))
 	win->win_draw_func(&(xccore->gui), win);
     else {
+	ic->imc->pre_attr = &(ic->pre_attr);
+	ic->imc->sts_attr = &(ic->sts_attr);
 	win = gui_overspot_init(&(xccore->gui), xccore->main_win, ic->imc);
 	xccore->win_end->next = win;
 	xccore->win_end = win;
--- src/gui_menusel.c.orig	Wed Feb 23 09:47:57 2000
+++ src/gui_menusel.c	Thu Feb 24 01:55:36 2000
@@ -246,18 +246,21 @@
     XSetWMProtocols(gui->display, win->window, &(gui->wm_del_win), 1);
 
 /*  Setup GC  */
-    msw.gc = XCreateGC(gui->display, win->window, 0, NULL);
-    XSetForeground(gui->display, msw.gc, gui->fg_color);
-    XSetBackground(gui->display, msw.gc, gui->bg_color);
-
-    msw.gcm = XCreateGC(gui->display, win->window, 0, NULL);
-    XSetForeground(gui->display, msw.gcm, gui->fg_color);
-    XSetBackground(gui->display, msw.gcm, gui->mbg_color);
-
-    msw.gcline = XCreateGC(gui->display, win->window, 0, NULL);
-    XSetForeground(gui->display, msw.gcline, gui->grid_color);
-    XSetBackground(gui->display, msw.gcline, gui->bg_color);
-
+    if (msw.gc == (GC)0) {
+	msw.gc = XCreateGC(gui->display, win->window, 0, NULL);
+	XSetForeground(gui->display, msw.gc, gui->fg_color);
+	XSetBackground(gui->display, msw.gc, gui->bg_color);
+    }
+    if (msw.gcm == (GC)0) {
+	msw.gcm = XCreateGC(gui->display, win->window, 0, NULL);
+	XSetForeground(gui->display, msw.gcm, gui->fg_color);
+	XSetBackground(gui->display, msw.gcm, gui->mbg_color);
+    }
+    if (msw.gcline == (GC)0) {
+	msw.gcline = XCreateGC(gui->display, win->window, 0, NULL);
+	XSetForeground(gui->display, msw.gcline, gui->grid_color);
+	XSetBackground(gui->display, msw.gcline, gui->bg_color);
+    }
     gui_winmap_change(gui, win, 1);
     gui_menusel_draw(gui, win);
     return win;
--- src/gui_overspot.c.orig	Wed Feb 23 09:47:57 2000
+++ src/gui_overspot.c	Thu Feb 24 01:55:36 2000
@@ -175,8 +175,7 @@
     if ((imc->inp_state & IM_XIMFOCUS) && (imc->inp_state & IM_CINPUT) && 
 	(imc->inpinfo.n_mcch > 0 || 
 	 (imc->inpinfo.s_keystroke && imc->inpinfo.s_keystroke[0].wch))) {
-	if (! win->winmap)
-	    XRaiseWindow(gui->display, win->window);
+	XRaiseWindow(gui->display, win->window);
 	overspot_win_location(gui, win, imc);
 	gui_winmap_change(gui, win, 1);
 	overspot_win_draw(gui, win, imc);
@@ -225,18 +224,21 @@
     XSelectInput(gui->display, win->window, (ExposureMask|StructureNotifyMask));
 
 /*  Setup GC  */
-    osw.gc = XCreateGC(gui->display, win->window, 0, NULL);
-    XSetForeground(gui->display, osw.gc, gui->fg_color);
-    XSetBackground(gui->display, osw.gc, gui->bg_color);
-
-    osw.gcs = XCreateGC(gui->display, win->window, 0, NULL);
-    XSetForeground(gui->display, osw.gcs, gui->fg_color);
-    XSetBackground(gui->display, osw.gcs, gui->mbg_color);
-
-    osw.gcm = XCreateGC(gui->display, win->window, 0, NULL);
-    XSetForeground(gui->display, osw.gcm, gui->mfg_color);
-    XSetBackground(gui->display, osw.gcm, gui->mbg_color);
-
+    if (osw.gc == (GC)0) {
+	osw.gc = XCreateGC(gui->display, win->window, 0, NULL);
+	XSetForeground(gui->display, osw.gc, gui->fg_color);
+	XSetBackground(gui->display, osw.gc, gui->bg_color);
+    }
+    if (osw.gcs == (GC)0) {
+	osw.gcs = XCreateGC(gui->display, win->window, 0, NULL);
+	XSetForeground(gui->display, osw.gcs, gui->fg_color);
+	XSetBackground(gui->display, osw.gcs, gui->mbg_color);
+    }
+    if (osw.gcm == (GC)0) {
+	osw.gcm = XCreateGC(gui->display, win->window, 0, NULL);
+	XSetForeground(gui->display, osw.gcm, gui->mfg_color);
+	XSetBackground(gui->display, osw.gcm, gui->mbg_color);
+    }
     gui_overspot_draw(gui, win);
     return win;
 }
--- src/xim.c.orig	Wed Feb 23 09:47:57 2000
+++ src/xim.c	Thu Feb 24 01:55:36 2000
@@ -165,12 +165,11 @@
 
     if (imc->icid != ic->id)
 	return;
-    xccore->ic = ic;
     if ((imc->inp_state & IM_CINPUT)) {
 	imc->inp_state |= IM_XIMFOCUS;
 	xccore->gui.winchange |= WIN_CHANGE_IM;
     }
-    else if (imc->inp_state & IM_2BYTES)
+    else if ((imc->inp_state & IM_2BYTES))
 	xccore->gui.winchange |= WIN_CHANGE_IM;
 }
 
@@ -460,6 +459,7 @@
     ic->imc->icid = ic->id;
     call_switch_in(ic);
     ic->ic_state |= IC_FOCUS;
+    xccore->ic = ic;
 
     if ((ic->ic_state & IC_NEWIC)) {
 	if ((xccore->xcin_mode & XCIN_RUN_IM_FOCUS) ||
@@ -484,23 +484,8 @@
 	    ic->imc->sts_attr = &(ic->sts_attr);
 	}
     }
-    else {
-/*
- *  For XCIN_SINGLE_IMC off, we should change the GUI-request windows' mapping
- *  state everytime when changing the IC focus, since the focus status in this
- *  mode is definite, and each IC is completely independent to the others, so
- *  we should handle them independently.
- *
- *  But for XCIN_SINGLE_IMC mode, the focus state of IMC might be ambiguous,
- *  as described on the above, so we will change the GUI-request windows'
- *  mapping state after all the focus status are determined, i.e., in the
- *  update_gui_request() in gui.c. This way can also improve the graphical
- *  performance.
- */
-	gui_greq_winmap_change(&(xccore->gui), &(ic->imc->gwin), 1);
-	if (ic->input_style == XIMSTY_OverSpot)
-	    gui_overspot_winmap_change(&(xccore->gui), ic->imc->id, 1);
-    }
+    else
+	xccore->gui.winchange |= WIN_CHANGE_FOCUS;
     return True;
 }
 
@@ -517,12 +502,10 @@
 	return False;
 
     call_switch_out(ic);
+    xccore->icp = ic;
     ic->ic_state &= ~(IC_FOCUS);
-    if (! (xccore->xcin_mode & XCIN_SINGLE_IMC)) {
-	gui_greq_winmap_change(&(xccore->gui), &(ic->imc->gwin), 0);
-	if (ic->input_style == XIMSTY_OverSpot)
-	    gui_overspot_winmap_change(&(xccore->gui), ic->imc->id, 0);
-    }
+    if (! (xccore->xcin_mode & XCIN_SINGLE_IMC))
+	xccore->gui.winchange |= WIN_CHANGE_FOCUS;
     return True;
 }
 
@@ -962,12 +945,15 @@
 {
     IMSyncXlibStruct pass_data;
 
-    xim_disconnect(xccore->ic);
     xccore->xcin_mode |= (XCIN_RUN_EXIT | XCIN_ICCHECK_OFF);
-
-    pass_data.major_code = XIM_SYNC;
-    pass_data.minor_code = 0;
-    pass_data.connect_id = xccore->ic->connect_id;
-    pass_data.icid = xccore->ic->id;
-    IMSyncXlib(xccore->ims, (XPointer)&pass_data);
+    if (xccore->ic) {
+	xim_disconnect(xccore->ic);
+	pass_data.major_code = XIM_SYNC;
+	pass_data.minor_code = 0;
+	pass_data.connect_id = xccore->ic->connect_id;
+	pass_data.icid = xccore->ic->id;
+	IMSyncXlib(xccore->ims, (XPointer)&pass_data);
+    }
+    else
+	exit(0);
 }
--- doc/Changes.orig	Wed Feb 23 09:47:57 2000
+++ doc/Changes	Thu Feb 24 01:55:36 2000
@@ -1,3 +1,14 @@
+xcin-2.5.2-pre3:  2000/03/
+------------------------------
+1. Fix the bug of multiply creating GC in gui_overspot & gui_menusel.
+   Thanks to Peter Hung <peter@phantom.wahoo.com.tw>
+
+2. Fix bugs when xcin is going to exit and xccore->ic = NULL case;
+
+3. Change the mechanism of IMC windows' map change during IC focus changes.
+   Add a gui->winchange flag: WIN_CHANGE_FOCUS.
+
+
 xcin-2.5.2-pre2:  2000/02/23
 ------------------------------
 1. Register a WM protocol into testprog such that it can be terminated by WM.