summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2017-03-06 23:09:12 (GMT)
committerfvogel <fvogelnew1@free.fr>2017-03-06 23:09:12 (GMT)
commit7bbe7bbdc8405dd7b5a98b9399ed599fd12d3aaa (patch)
treebbe130f0a845fa7fe7033b241089e66847a10591
parentf802dd59b9fdec91f7178bfb7bcaa2ab2818739c (diff)
parent8701bf597e98498ab4d757caa5a2bb9dd46a0554 (diff)
downloadtk-7bbe7bbdc8405dd7b5a98b9399ed599fd12d3aaa.zip
tk-7bbe7bbdc8405dd7b5a98b9399ed599fd12d3aaa.tar.gz
tk-7bbe7bbdc8405dd7b5a98b9399ed599fd12d3aaa.tar.bz2
merge core-8-6-branch
-rw-r--r--generic/tk.h3
-rw-r--r--generic/tkEvent.c13
-rw-r--r--generic/tkImgPNG.c4
-rw-r--r--generic/tkInt.h6
-rw-r--r--generic/tkTextDisp.c2
-rw-r--r--generic/tkWindow.c9
-rw-r--r--library/ttk/altTheme.tcl3
-rw-r--r--library/ttk/clamTheme.tcl2
-rw-r--r--library/ttk/defaults.tcl3
-rw-r--r--tests/focusTcl.test8
-rw-r--r--tests/pack.test4
-rw-r--r--tests/text.test30
-rw-r--r--tests/textDisp.test16
-rw-r--r--tests/textIndex.test6
-rw-r--r--tests/textMark.test2
-rw-r--r--tests/textTag.test2
-rw-r--r--tests/textWind.test2
-rw-r--r--unix/tkUnixEvent.c46
18 files changed, 117 insertions, 44 deletions
diff --git a/generic/tk.h b/generic/tk.h
index 69a0858..29c6fb9 100644
--- a/generic/tk.h
+++ b/generic/tk.h
@@ -814,6 +814,9 @@ typedef struct Tk_FakeWin {
int minReqWidth;
int minReqHeight;
char *dummy20; /* geometryMaster */
+#ifdef TK_USE_INPUT_METHODS
+ int dummy21;
+#endif /* TK_USE_INPUT_METHODS */
} Tk_FakeWin;
/*
diff --git a/generic/tkEvent.c b/generic/tkEvent.c
index 95aeda1..d058e7c 100644
--- a/generic/tkEvent.c
+++ b/generic/tkEvent.c
@@ -356,6 +356,7 @@ CreateXIC(
/* XCreateIC failed. */
return;
}
+ winPtr->ximGeneration = dispPtr->ximGeneration;
/*
* Adjust the window's event mask if the IM requires it.
@@ -1288,6 +1289,14 @@ Tk_HandleEvent(
*/
#ifdef TK_USE_INPUT_METHODS
+ /*
+ * If the XIC has been invalidated, it must be recreated.
+ */
+ if (winPtr->dispPtr->ximGeneration != winPtr->ximGeneration) {
+ winPtr->flags &= ~TK_CHECKED_IC;
+ winPtr->inputContext = NULL;
+ }
+
if ((winPtr->dispPtr->flags & TK_DISPLAY_USE_IM)) {
if (!(winPtr->flags & (TK_CHECKED_IC|TK_ALREADY_DEAD))) {
winPtr->flags |= TK_CHECKED_IC;
@@ -1295,7 +1304,9 @@ Tk_HandleEvent(
CreateXIC(winPtr);
}
}
- if (eventPtr->type == FocusIn && winPtr->inputContext != NULL) {
+ if ((eventPtr->type == FocusIn) &&
+ (winPtr->dispPtr->inputMethod != NULL) &&
+ (winPtr->inputContext != NULL)) {
XSetICFocus(winPtr->inputContext);
}
}
diff --git a/generic/tkImgPNG.c b/generic/tkImgPNG.c
index c6e3029..6e64afa 100644
--- a/generic/tkImgPNG.c
+++ b/generic/tkImgPNG.c
@@ -2245,10 +2245,10 @@ ApplyAlpha(
p += offset;
if (16 == pngPtr->bitDepth) {
- register int channel;
+ register unsigned int channel;
while (p < endPtr) {
- channel = (unsigned char)
+ channel = (unsigned int)
(((p[0] << 8) | p[1]) * pngPtr->alpha);
*p++ = (unsigned char) (channel >> 8);
diff --git a/generic/tkInt.h b/generic/tkInt.h
index 1615a81..f00d833 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -508,6 +508,9 @@ typedef struct TkDisplay {
int iconDataSize; /* Size of default iconphoto image data. */
unsigned char *iconDataPtr; /* Default iconphoto image data, if set. */
+#ifdef TK_USE_INPUT_METHODS
+ int ximGeneration; /* Used to invalidate XIC */
+#endif /* TK_USE_INPUT_METHODS */
} TkDisplay;
/*
@@ -809,6 +812,9 @@ typedef struct TkWindow {
int minReqWidth; /* Minimum requested width. */
int minReqHeight; /* Minimum requested height. */
char *geometryMaster;
+#ifdef TK_USE_INPUT_METHODS
+ int ximGeneration; /* Used to invalidate XIC */
+#endif /* TK_USE_INPUT_METHODS */
} TkWindow;
/*
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index 095bb5e..371e910 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -8793,7 +8793,7 @@ FinalizeBaseChunk(
#if TK_DRAW_IN_CONTEXT
newwidth = 0;
CharChunkMeasureChars(chunkPtr, NULL, 0, 0, -1, 0, -1, 0, &newwidth);
- if (newwidth != chunkPtr->width) {
+ if (newwidth < chunkPtr->width) {
widthAdjust += newwidth - chunkPtr->width;
chunkPtr->width = newwidth;
}
diff --git a/generic/tkWindow.c b/generic/tkWindow.c
index 20b4f20..690a841 100644
--- a/generic/tkWindow.c
+++ b/generic/tkWindow.c
@@ -355,6 +355,9 @@ CreateTopLevelWindow(
* Set the flags specified in the call.
*/
+#ifdef TK_USE_INPUT_METHODS
+ winPtr->ximGeneration = 0;
+#endif /*TK_USE_INPUT_METHODS*/
winPtr->flags |= flags;
/*
@@ -650,6 +653,7 @@ TkAllocWindow(
winPtr->flags = 0;
winPtr->handlerList = NULL;
#ifdef TK_USE_INPUT_METHODS
+ winPtr->ximGeneration = 0;
winPtr->inputContext = NULL;
#endif /* TK_USE_INPUT_METHODS */
winPtr->tagPtr = NULL;
@@ -1442,10 +1446,11 @@ Tk_DestroyWindow(
UnlinkWindow(winPtr);
TkEventDeadWindow(winPtr);
#ifdef TK_USE_INPUT_METHODS
- if (winPtr->inputContext != NULL) {
+ if (winPtr->inputContext != NULL &&
+ winPtr->ximGeneration == winPtr->dispPtr->ximGeneration) {
XDestroyIC(winPtr->inputContext);
- winPtr->inputContext = NULL;
}
+ winPtr->inputContext = NULL;
#endif /* TK_USE_INPUT_METHODS */
if (winPtr->tagPtr != NULL) {
TkFreeBindingTags(winPtr);
diff --git a/library/ttk/altTheme.tcl b/library/ttk/altTheme.tcl
index e792539..5630e6c 100644
--- a/library/ttk/altTheme.tcl
+++ b/library/ttk/altTheme.tcl
@@ -63,7 +63,8 @@ namespace eval ttk::theme::alt {
[list readonly $colors(-frame) disabled $colors(-frame)]
ttk::style configure TCombobox -padding 1
ttk::style map TCombobox -fieldbackground \
- [list readonly $colors(-frame) disabled $colors(-frame)]
+ [list readonly $colors(-frame) disabled $colors(-frame)] \
+ -arrowcolor [list disabled $colors(-disabledfg)]
ttk::style configure ComboboxPopdownFrame \
-relief solid -borderwidth 1
diff --git a/library/ttk/clamTheme.tcl b/library/ttk/clamTheme.tcl
index f4ad43b..808c365 100644
--- a/library/ttk/clamTheme.tcl
+++ b/library/ttk/clamTheme.tcl
@@ -110,7 +110,7 @@ namespace eval ttk::theme::clam {
-fieldbackground [list {readonly focus} $colors(-selectbg) \
readonly $colors(-frame)] \
-foreground [list {readonly focus} $colors(-selectfg)] \
- ;
+ -arrowcolor [list disabled $colors(-disabledfg)]
ttk::style configure ComboboxPopdownFrame \
-relief solid -borderwidth 1
diff --git a/library/ttk/defaults.tcl b/library/ttk/defaults.tcl
index 853ed20..56e2176 100644
--- a/library/ttk/defaults.tcl
+++ b/library/ttk/defaults.tcl
@@ -77,7 +77,8 @@ namespace eval ttk::theme::default {
ttk::style configure TCombobox -arrowsize 12 -padding 1
ttk::style map TCombobox -fieldbackground \
- [list readonly $colors(-frame) disabled $colors(-frame)]
+ [list readonly $colors(-frame) disabled $colors(-frame)] \
+ -arrowcolor [list disabled $colors(-disabledfg)]
ttk::style configure TSpinbox -arrowsize 10 -padding {2 0 10 0}
ttk::style map TSpinbox -fieldbackground \
diff --git a/tests/focusTcl.test b/tests/focusTcl.test
index ef848bb..0e457a6 100644
--- a/tests/focusTcl.test
+++ b/tests/focusTcl.test
@@ -402,7 +402,7 @@ test focusTcl-5.4 {tkFocusOK procedure, -takefocus ""} -body {
test focusTcl-5.5 {tkFocusOK procedure, -takefocus "", not mapped} -body {
setup1 .
.b.x configure -takefocus ""
- pack unpack .b.x
+ pack forget .b.x
update
tk_focusNext .b
} -cleanup {
@@ -413,7 +413,7 @@ test focusTcl-5.6 {tkFocusOK procedure, -takefocus "", not mapped} -body {
foreach w {.b.x .b.y .b.z} {
$w configure -takefocus ""
}
- pack unpack .b
+ pack forget .b
update
tk_focusNext .b
} -cleanup {
@@ -422,7 +422,7 @@ test focusTcl-5.6 {tkFocusOK procedure, -takefocus "", not mapped} -body {
test focusTcl-5.7 {tkFocusOK procedure, -takefocus "", not mapped} -body {
setup1 .
.b.y configure -takefocus 1
- pack unpack .b.y
+ pack forget .b.y
update
tk_focusNext .b.x
} -cleanup {
@@ -432,7 +432,7 @@ test focusTcl-5.8 {tkFocusOK procedure, -takefocus "", not mapped} -body {
proc always args {return 1}
setup1 .
.b.y configure -takefocus always
- pack unpack .b.y
+ pack forget .b.y
update
tk_focusNext .b.x
} -cleanup {
diff --git a/tests/pack.test b/tests/pack.test
index eac1562..efb262b 100644
--- a/tests/pack.test
+++ b/tests/pack.test
@@ -1403,7 +1403,7 @@ test pack-15.1 {managing geometry with -in option} -setup {
pack .pack.b -in .pack.f.f2
update
set result [winfo geom .pack.b]
- pack unpack .pack.a
+ pack forget .pack.a
update
lappend result [winfo geom .pack.b]
} -cleanup {
@@ -1441,7 +1441,7 @@ test pack-15.3 {managing geometry with -in option} -setup {
pack .pack.b -in .pack.f.f2
update
set result [winfo ismapped .pack.b]
- pack unpack .pack.f
+ pack forget .pack.f
update
lappend result [winfo ismapped .pack.b]
} -cleanup {
diff --git a/tests/text.test b/tests/text.test
index 6812855..edd2a6e 100644
--- a/tests/text.test
+++ b/tests/text.test
@@ -2631,7 +2631,7 @@ test text-10.37 {TextWidgetCmd procedure, "count" option} -setup {
} -result {3}
test text-10.38 {TextWidgetCmd procedure, "count" option} -setup {
text .t -font {Courier -12} -borderwidth 2 -highlightthickness 2
- pack append . .t {top expand fill}
+ pack .t -expand 1 -fill both
} -body {
.t configure -width 20 -height 10
update
@@ -2727,7 +2727,7 @@ test text-9.2.47 {TextWidgetCmd procedure, "count" option} -setup {
test text-11.1 {counting with tag priority eliding} -setup {
text .t -font {Courier -12} -borderwidth 2 -highlightthickness 2
- pack append . .t {top expand fill}
+ pack .t -expand 1 -fill both
} -body {
.t insert end "hello"
.t configure -wrap none
@@ -2744,7 +2744,7 @@ test text-11.1 {counting with tag priority eliding} -setup {
} -result {0 1 2 3 4 5 5 6}
test text-11.2 {counting with tag priority eliding} -setup {
text .t -font {Courier -12} -borderwidth 2 -highlightthickness 2
- pack append . .t {top expand fill}
+ pack .t -expand 1 -fill both
} -body {
.t insert end "hello"
.t tag configure elide1 -elide 0
@@ -2856,7 +2856,7 @@ test text-11.7 {counting with tag priority eliding} -setup {
} -result {5 5}
test text-11.8 {counting with tag priority eliding} -setup {
text .t -font {Courier -12} -borderwidth 2 -highlightthickness 2
- pack append . .t {top expand fill}
+ pack .t -expand 1 -fill both
set res {}
} -body {
.t insert end "hello"
@@ -2882,7 +2882,7 @@ test text-11.8 {counting with tag priority eliding} -setup {
} -result {0 0 0 0 3 2 1 1}
test text-11.9 {counting with tag priority eliding} -setup {
text .t -font {Courier -12} -borderwidth 2 -highlightthickness 2
- pack append . .t {top expand fill}
+ pack .t -expand 1 -fill both
set res {}
} -body {
.t tag configure WELCOME -elide 1
@@ -3432,7 +3432,7 @@ test text-14.18 {ConfigureText procedure} -constraints fonts -setup {
text .top.t -font {Courier -12} -borderwidth 2 -highlightthickness 2
} -body {
.top.t configure -width 20 -height 10
- pack append .top .top.t top
+ pack .top.t
update
set geom [wm geometry .top]
set x [string range $geom 0 [string first + $geom]]
@@ -3449,7 +3449,7 @@ test text-14.19 {ConfigureText procedure} -setup {
} -body {
.top.t configure -width 20 -height 10 -setgrid 1
wm overrideredirect .top 1
- pack append .top .top.t top
+ pack .top.t
wm geometry .top +0+0
update
wm geometry .top
@@ -3466,7 +3466,7 @@ test text-14.20 {ConfigureText procedure} -setup {
} -body {
.top.t configure -width 20 -height 10 -setgrid 1
wm overrideredirect .top 1
- pack append .top .top.t top
+ pack .top.t
wm geometry .top +0+0
update
set result [wm geometry .top]
@@ -3756,7 +3756,7 @@ Line 4
test text-19.11 {DeleteChars procedure} -body {
toplevel .top
text .top.t -width 20 -height 5
- pack append .top .top.t top
+ pack .top.t
wm geometry .top +0+0
.top.t insert 1.0 "abc\n123\nx\ny\nz\nq\nr\ns"
update
@@ -3768,7 +3768,7 @@ test text-19.11 {DeleteChars procedure} -body {
test text-19.12 {DeleteChars procedure} -body {
toplevel .top
text .top.t -width 20 -height 5
- pack append .top .top.t top
+ pack .top.t
wm geometry .top +0+0
.top.t insert 1.0 "abc\n123\nx\ny\nz\nq\nr\ns"
.top.t yview 3.0
@@ -3841,7 +3841,7 @@ test text-19.16 {DeleteChars procedure, updates affecting topIndex} -setup {
test text-20.1 {TextFetchSelection procedure} -setup {
text .t -width 20 -height 10
- pack append . .t {top expand fill}
+ pack .t -expand 1 -fill both
update
} -body {
foreach i {a b c d e f g h i j k l m n o p q r s t u v w x y z} {
@@ -3856,7 +3856,7 @@ b.0b.1b.2b.3b.4
c.0c}
test text-20.2 {TextFetchSelection procedure} -setup {
text .t -width 20 -height 10
- pack append . .t {top expand fill}
+ pack .t -expand 1 -fill both
update
} -body {
foreach i {a b c d e f g h i j k l m n o p q r s t u v w x y z} {
@@ -3876,7 +3876,7 @@ b.0b.1b.2b.3b.4
c.0c}
test text-20.3 {TextFetchSelection procedure} -setup {
text .t -width 20 -height 10
- pack append . .t {top expand fill}
+ pack .t -expand 1 -fill both
update
} -body {
foreach i {a b c d e f g h i j k l m n o p q r s t u v w x y z} {
@@ -3890,7 +3890,7 @@ test text-20.3 {TextFetchSelection procedure} -setup {
} -result {m}
test text-20.4 {TextFetchSelection procedure} -setup {
text .t -width 20 -height 10
- pack append . .t {top expand fill}
+ pack .t -expand 1 -fill both
update
} -body {
foreach i {a b c d e f g h i j k l m n o p q r s t u v w x y z} {
@@ -3910,7 +3910,7 @@ test text-20.4 {TextFetchSelection procedure} -setup {
cj.0j.1j.2j.3j.4m}
test text-20.5 {TextFetchSelection procedure, long selections} -setup {
text .t -width 20 -height 10
- pack append . .t {top expand fill}
+ pack .t -expand 1 -fill both
update
set x ""
} -body {
diff --git a/tests/textDisp.test b/tests/textDisp.test
index 8342c46..216f767 100644
--- a/tests/textDisp.test
+++ b/tests/textDisp.test
@@ -39,7 +39,7 @@ option add *Text.highlightThickness $twht
catch {destroy .f .t}
frame .f -width 100 -height 20
-pack append . .f left
+pack .f -side left
set fixedFont {Courier -12}
# 15 on XP, 13 on Solaris 8
@@ -65,7 +65,7 @@ set bigAscent [font metrics $bigFont -ascent]
set ascentDiff [expr {$bigAscent - $fixedAscent}]
text .t -font $fixedFont -width 20 -height 10 -yscrollcommand scroll
-pack append . .t {top expand fill}
+pack .t -expand 1 -fill both
.t tag configure big -font $bigFont
.t debug on
wm geometry . {}
@@ -599,7 +599,7 @@ test textDisp-4.6 {UpdateDisplayInfo, tiny window} {
wm overrideredirect . 1
}
frame .f2 -width 20 -height 100
- pack before .f .f2 top
+ pack .f2 -before .f
wm geom . 103x103
update
.t configure -wrap none -borderwidth 2
@@ -2873,28 +2873,28 @@ for {set i 2} {$i <= 200} {incr i} {
.t configure -wrap word
.t delete 50.0 51.0
.t insert 50.0 "This is a long line, one that will wrap around twice.\n"
-test textDisp-20.1 {FindDLine} {textfonts} {
+test textDisp-20.1 {FindDLine} {
.t yview 48.0
list [.t dlineinfo 46.0] [.t dlineinfo 47.0] [.t dlineinfo 49.0] \
[.t dlineinfo 58.0]
} [list {} {} [list 3 [expr {$fixedDiff + 16}] 49 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}]
-test textDisp-20.2 {FindDLine} {textfonts} {
+test textDisp-20.2 {FindDLine} {
.t yview 100.0
.t yview -pickplace 53.0
list [.t dlineinfo 50.0] [.t dlineinfo 50.14] [.t dlineinfo 50.21]
} [list [list 3 [expr {-1 - $fixedDiff/2}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {-1 - $fixedDiff/2}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {12 + $fixedDiff/2}] 133 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]]]
-test textDisp-20.3 {FindDLine} {textfonts} {
+test textDisp-20.3 {FindDLine} {
.t yview 100.0
.t yview 49.0
list [.t dlineinfo 50.0] [.t dlineinfo 50.24] [.t dlineinfo 57.0]
} [list [list 3 [expr {$fixedDiff + 16}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {2*$fixedDiff + 29}] 133 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}]
-test textDisp-20.4 {FindDLine} {textfonts} {
+test textDisp-20.4 {FindDLine} {
.t yview 100.0
.t yview 42.0
list [.t dlineinfo 50.0] [.t dlineinfo 50.24] [.t dlineinfo 50.40]
} [list [list 3 [expr {8*$fixedDiff + 107}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {9*$fixedDiff + 120}] 133 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}]
.t config -wrap none
-test textDisp-20.5 {FindDLine} {textfonts} {
+test textDisp-20.5 {FindDLine} {
.t yview 100.0
.t yview 48.0
list [.t dlineinfo 50.0] [.t dlineinfo 50.20] [.t dlineinfo 50.40]
diff --git a/tests/textIndex.test b/tests/textIndex.test
index 83a249e..7d44516 100644
--- a/tests/textIndex.test
+++ b/tests/textIndex.test
@@ -13,7 +13,7 @@ namespace import -force tcltest::test
catch {destroy .t}
text .t -font {Courier -12} -width 20 -height 10
-pack append . .t {top expand fill}
+pack .t -expand 1 -fill both
update
.t debug on
wm geometry . {}
@@ -714,7 +714,7 @@ test textIndex-18.1 {Object indices don't cache mark names} {
} {3.4 3.0 1.0}
frame .f -width 100 -height 20
-pack append . .f left
+pack .f -side left
set fixedFont {Courier -12}
set fixedHeight [font metrics $fixedFont -linespace]
@@ -724,7 +724,7 @@ set varFont {Times -14}
set bigFont {Helvetica -24}
destroy .t
text .t -font $fixedFont -width 20 -height 10 -wrap char
-pack append . .t {top expand fill}
+pack .t -expand 1 -fill both
.t tag configure big -font $bigFont
.t debug on
wm geometry . {}
diff --git a/tests/textMark.test b/tests/textMark.test
index edd0e92..bbf226e 100644
--- a/tests/textMark.test
+++ b/tests/textMark.test
@@ -13,7 +13,7 @@ tcltest::loadTestedCommands
destroy .t
text .t -width 20 -height 10
-pack append . .t {top expand fill}
+pack .t -expand 1 -fill both
update
.t debug on
wm geometry . {}
diff --git a/tests/textTag.test b/tests/textTag.test
index 88081d0..ddbaa3b 100644
--- a/tests/textTag.test
+++ b/tests/textTag.test
@@ -17,7 +17,7 @@ testConstraint haveCourier12 [expr {[catch {
.t configure -font {Courier 12}
}] == 0}]
-pack append . .t {top expand fill}
+pack .t -expand 1 -fill both
update
.t debug on
diff --git a/tests/textWind.test b/tests/textWind.test
index 27b7309..fd29e19 100644
--- a/tests/textWind.test
+++ b/tests/textWind.test
@@ -22,7 +22,7 @@ option add *Text.font {Courier -12}
deleteWindows
# Widget used in tests 1.* - 16.*
text .t -width 30 -height 6 -bd 2 -highlightthickness 2
-pack append . .t {top expand fill}
+pack .t -expand 1 -fill both
update
.t debug on
diff --git a/unix/tkUnixEvent.c b/unix/tkUnixEvent.c
index f3beb16..111d430 100644
--- a/unix/tkUnixEvent.c
+++ b/unix/tkUnixEvent.c
@@ -38,6 +38,8 @@ static void DisplayFileProc(ClientData clientData, int flags);
static void DisplaySetupProc(ClientData clientData, int flags);
static void TransferXEventsToTcl(Display *display);
#ifdef TK_USE_INPUT_METHODS
+static void InstantiateIMCallback(Display *, XPointer client_data, XPointer call_data);
+static void DestroyIMCallback(XIM im, XPointer client_data, XPointer call_data);
static void OpenIM(TkDisplay *dispPtr);
#endif
@@ -179,6 +181,8 @@ TkpOpenDisplay(
dispPtr->flags |= use_xkb;
#ifdef TK_USE_INPUT_METHODS
OpenIM(dispPtr);
+ XRegisterIMInstantiateCallback(dispPtr->display, NULL, NULL, NULL,
+ InstantiateIMCallback, (XPointer) dispPtr);
#endif
Tcl_CreateFileHandler(ConnectionNumber(display), TCL_READABLE,
DisplayFileProc, dispPtr);
@@ -664,6 +668,35 @@ TkpSync(
}
#ifdef TK_USE_INPUT_METHODS
+static void
+InstantiateIMCallback(
+ Display *display,
+ XPointer client_data,
+ XPointer call_data)
+{
+ TkDisplay *dispPtr;
+
+ dispPtr = (TkDisplay *) client_data;
+ OpenIM(dispPtr);
+ XUnregisterIMInstantiateCallback(dispPtr->display, NULL, NULL, NULL,
+ InstantiateIMCallback, (XPointer) dispPtr);
+}
+
+static void
+DestroyIMCallback(
+ XIM im,
+ XPointer client_data,
+ XPointer call_data)
+{
+ TkDisplay *dispPtr;
+
+ dispPtr = (TkDisplay *) client_data;
+ dispPtr->inputMethod = NULL;
+ ++dispPtr->ximGeneration;
+ XRegisterIMInstantiateCallback(dispPtr->display, NULL, NULL, NULL,
+ InstantiateIMCallback, (XPointer) dispPtr);
+}
+
/*
*--------------------------------------------------------------
*
@@ -693,11 +726,23 @@ OpenIM(
return;
}
+ ++dispPtr->ximGeneration;
dispPtr->inputMethod = XOpenIM(dispPtr->display, NULL, NULL, NULL);
if (dispPtr->inputMethod == NULL) {
return;
}
+ /* Require X11R6 */
+ {
+ XIMCallback destroy_cb;
+
+ destroy_cb.callback = DestroyIMCallback;
+ destroy_cb.client_data = (XPointer) dispPtr;
+ if (XSetIMValues(dispPtr->inputMethod, XNDestroyCallback,
+ &destroy_cb, NULL))
+ goto error;
+ }
+
if ((XGetIMValues(dispPtr->inputMethod, XNQueryInputStyle, &stylePtr,
NULL) != NULL) || (stylePtr == NULL)) {
goto error;
@@ -744,6 +789,7 @@ error:
if (dispPtr->inputMethod) {
XCloseIM(dispPtr->inputMethod);
dispPtr->inputMethod = NULL;
+ ++dispPtr->ximGeneration;
}
}
#endif /* TK_USE_INPUT_METHODS */