From 650e19c98ffa1384bee8bf2237a85cd524532ea1 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 22 Oct 2019 16:08:31 +0000 Subject: Fix [39de9677aa]: incorrect IME behavior --- macosx/tkMacOSXKeyEvent.c | 186 +++++++++++++++++++++++++++++++++------------- macosx/tkMacOSXKeyboard.c | 2 +- macosx/tkMacOSXPrivate.h | 7 +- 3 files changed, 142 insertions(+), 53 deletions(-) diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index 0fb1d53..a3ab2d3 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -31,13 +31,11 @@ static NSWindow *keyboardGrabNSWindow = nil; * window. */ static NSModalSession modalSession = nil; static BOOL processingCompose = NO; -static BOOL finishedCompose = NO; static int caret_x = 0, caret_y = 0, caret_height = 0; -static void setupXEvent(XEvent *xEvent, NSWindow *w, - unsigned int state); -static unsigned isFunctionKey(unsigned int code); +static unsigned short releaseCode; -unsigned short releaseCode; +static void setupXEvent(XEvent *xEvent, NSWindow *w, unsigned int state); +static unsigned isFunctionKey(unsigned int code); #pragma mark TKApplication(TKKeyEvent) @@ -203,15 +201,19 @@ unsigned short releaseCode; } /* - * For command key, take input manager's word so things like - * dvorak / qwerty layout work. + * For the command key, take the input manager's word so things + * like dvorak / qwerty layout work. */ if ((modifiers & NSCommandKeyMask) == NSCommandKeyMask && (modifiers & NSAlternateKeyMask) != NSAlternateKeyMask && len > 0 && !isFunctionKey(code)) { - // head off keycode-based translation in tkMacOSXKeyboard.c - xEvent.xkey.nbytes = [characters length]; //len + + /* + * Prevent keycode-based translation in tkMacOSXKeyboard.c + */ + + xEvent.xkey.nbytes = [characters length]; } if ([characters length] > 0) { @@ -235,7 +237,7 @@ unsigned short releaseCode; Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); savedModifiers = modifiers; return theEvent; - } /* if send straight to TK */ + } /* if this is a function key or has modifiers */ } /* if not processing compose */ if (type == NSKeyDown) { @@ -243,12 +245,29 @@ unsigned short releaseCode; TKLog(@"keyDown: %s compose sequence.\n", processingCompose == YES ? "Continue" : "Begin"); } - processingCompose = YES; - [nsEvArray addObject: theEvent]; - [[w contentView] interpretKeyEvents: nsEvArray]; - [nsEvArray removeObject: theEvent]; - } + /* + * Call the interpretKeyEvents method to interpret composition key + * strokes. When it detects a complete composition sequence it will + * call our implementation of insertText: replacementRange, which + * generates a key down XEvent with the appropriate character. In IME + * when multiple characters have the same composition sequence and the + * chosen character is not the default it may be necessary to hit the + * enter key multiple times before the character is accepted and + * rendered. We send enter key events until inputText has cleared + * the processingCompose flag. + */ + + processingCompose = YES; + while(processingCompose) { + [nsEvArray addObject: theEvent]; + [[w contentView] interpretKeyEvents: nsEvArray]; + [nsEvArray removeObject: theEvent]; + if ([theEvent keyCode] != 36) { + break; + } + } + } savedModifiers = modifiers; return theEvent; } @@ -265,58 +284,108 @@ unsigned short releaseCode; return self; } -/* implementation (called through interpretKeyEvents:]). */ +/* + * Implementation of the NSTextInputClient protocol. + */ -/* : called when done composing; - NOTE: also called when we delete over working text, followed immed. - by doCommandBySelector: deleteBackward: */ +/* [NSTextInputClient inputText: replacementRange:] is called by + * interpretKeyEvents when a composition sequence is complete. It is also + * called when we delete over working text. In that case the call is followed + * immediately by doCommandBySelector: deleteBackward: + */ - (void)insertText: (id)aString + replacementRange: (NSRange)repRange { int i, len = [(NSString *) aString length]; XEvent xEvent; - + if (NS_KEYLOG) { TKLog(@"insertText '%@'\tlen = %d", aString, len); } processingCompose = NO; - finishedCompose = YES; /* - * First, clear any working text. + * Insert the string as a sequence of keystrokes. */ - if (privateWorkingText != nil) { - [self deleteWorkingText]; - } + setupXEvent(&xEvent, [self window], 0); + xEvent.xany.type = KeyPress; /* - * Now insert the string as keystrokes. + * NSString represents a non-BMP character as a string of length 2 where + * the first character is the high surrogate and the second character is + * the low surrogate. We could record this in the XEvent by setting the + * keycode to the unicode code point and setting the trans_chars to the + * 4-byte UTF-8 string. However, that will not help as long as TCL_UTF_MAX + * is set to 3. Until that changes, we just replace non-BMP characters by + * the "replacement character" U+FFFD. */ - setupXEvent(&xEvent, [self window], 0); - xEvent.xany.type = KeyPress; - - for (i =0; i: inserts display of composing characters */ -- (void)setMarkedText: (id)aString selectedRange: (NSRange)selRange +- (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)theRange + actualRange:(NSRangePointer)thePointer { - NSString *str = [aString respondsToSelector: @selector (string)] ? + return nil; +} + +/* + * This method is supposed to insert (or replace selected text with) the string + * argument. If the argument is an NSString, it should be displayed with a + * distinguishing appearance, e.g underlined. + */ + +- (void)setMarkedText: (id)aString + selectedRange: (NSRange)selRange + replacementRange: (NSRange)repRange +{ + Tk_Window tkwin = (Tk_Window) TkMacOSXGetTkWindow([self window]); + NSString *temp; + NSString *str = [aString respondsToSelector:@selector (string)] ? [aString string] : aString; + printf("Setting marked text for %s to %s\n", Tk_PathName(tkwin), + [str length] ? str.UTF8String : "None"); if (NS_KEYLOG) { TKLog(@"setMarkedText '%@' len =%lu range %lu from %lu", str, (unsigned long) [str length], (unsigned long) selRange.length, @@ -324,16 +393,30 @@ unsigned short releaseCode; } if (privateWorkingText != nil) { + unsigned long length = [privateWorkingText length]; [self deleteWorkingText]; + } if ([str length] == 0) { return; } - processingCompose = YES; - privateWorkingText = [str copy]; + /* + * Warn the widget that we are going to insert the marked text + * so it can erase the old marked text and display the new. + */ + + TkSendVirtualEvent(tkwin, "TkStartIMEMarkedText", NULL); - //PENDING: insert workingText underlined + /* + * Use our insertText method to display the marked text. + */ + + temp = [str copy]; + [self insertText: temp replacementRange:repRange]; + privateWorkingText = temp; + processingCompose = YES; + TkSendVirtualEvent(tkwin, "TkEndIMEMarkedText", NULL); } @@ -366,12 +449,15 @@ unsigned short releaseCode; } -/* used to position char selection windows, etc. */ +/* + * Called by the system to get a position for popup character selection windows + * such as a Character Palette, or a selection menu for IME. + */ - (NSRect)firstRectForCharacterRange: (NSRange)theRange + actualRange: (NSRangePointer)thePointer { NSRect rect; NSPoint pt; - pt.x = caret_x; pt.y = caret_y; @@ -380,7 +466,7 @@ unsigned short releaseCode; pt.y -= caret_height; rect.origin = pt; - rect.size.width = caret_height; + rect.size.width = 0; rect.size.height = caret_height; return rect; } @@ -391,7 +477,6 @@ unsigned short releaseCode; return (NSInteger) self; } - - (void)doCommandBySelector: (SEL)aSelector { if (NS_KEYLOG) { @@ -416,7 +501,6 @@ unsigned short releaseCode; } } - - (NSArray *)validAttributesForMarkedText { static NSArray *arr = nil; @@ -428,7 +512,6 @@ unsigned short releaseCode; return arr; } - - (NSRange)selectedRange { if (NS_KEYLOG) { @@ -437,7 +520,6 @@ unsigned short releaseCode; return NSMakeRange(NSNotFound, 0); } - - (NSUInteger)characterIndexForPoint: (NSPoint)thePoint { if (NS_KEYLOG) { @@ -446,7 +528,6 @@ unsigned short releaseCode; return 0; } - - (NSAttributedString *)attributedSubstringFromRange: (NSRange)theRange { static NSAttributedString *str = nil; @@ -458,7 +539,7 @@ unsigned short releaseCode; } return str; } -/* End impl. */ +/* End of NSTextInputClient implementation. */ @synthesize needsRedisplay = _needsRedisplay; @end @@ -469,12 +550,15 @@ unsigned short releaseCode; - (void)deleteWorkingText { if (privateWorkingText == nil) { + printf("No working text to delete\n"); return; } if (NS_KEYLOG) { TKLog(@"deleteWorkingText len = %lu\n", (unsigned long)[privateWorkingText length]); } + printf("deleteWorkingText %s\n", [privateWorkingText length] ? + privateWorkingText.UTF8String : "none"); [privateWorkingText release]; privateWorkingText = nil; processingCompose = NO; diff --git a/macosx/tkMacOSXKeyboard.c b/macosx/tkMacOSXKeyboard.c index 5899064..a64f81e 100644 --- a/macosx/tkMacOSXKeyboard.c +++ b/macosx/tkMacOSXKeyboard.c @@ -803,7 +803,7 @@ TkpGetKeySym( /* If nbytes has been set, it's not a function key, but a regular key that has been translated in tkMacOSXKeyEvent.c; just use that. */ if (eventPtr->xkey.nbytes) { - return eventPtr->xkey.keycode & 0xFFFF; + return eventPtr->xkey.keycode; } /* diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 8335095..0f1fbca 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -340,7 +340,12 @@ VISIBILITY_HIDDEN @end VISIBILITY_HIDDEN -@interface TKContentView : NSView +/* + * Subclass TKContentView from NSTextInputClient to enable composition and + * input from the Character Palette. + */ + +@interface TKContentView : NSView { @private NSString *privateWorkingText; -- cgit v0.12 From 76d7a3ad202d462c9cf40f18dc8da60a17bcf9d3 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 22 Oct 2019 17:48:49 +0000 Subject: Fix [0854c99473]: macOS key events during a local grab are not handled correctly. --- macosx/tkMacOSXKeyEvent.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index 0fb1d53..f67460b 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -137,9 +137,9 @@ unsigned short releaseCode; } /* - * Events are only received for the front Window on the Macintosh. So + * Key events are only received for the front Window on the Macintosh. So * to build an XEvent we look up the Tk window associated to the Front - * window. If a different window has a local grab we ignore the event. + * window. */ TkWindow *winPtr = TkMacOSXGetTkWindow(w); @@ -148,11 +148,18 @@ unsigned short releaseCode; if (tkwin) { TkWindow *grabWinPtr = winPtr->dispPtr->grabWinPtr; - if (grabWinPtr - && grabWinPtr != winPtr - && !winPtr->dispPtr->grabFlags /* this means the grab is local. */ - && grabWinPtr->mainPtr == winPtr->mainPtr) { - return theEvent; + /* + * If a local grab is in effect, key events for windows in the + * grabber's application are redirected to the grabber. Key events + * for other applications are delivered normally. If a global + * grab is in effect all key events are redirected to the grabber. + */ + + if (grabWinPtr) { + if (winPtr->dispPtr->grabFlags || /* global grab */ + grabWinPtr->mainPtr == winPtr->mainPtr){ /* same appl. */ + tkwin = (Tk_Window) winPtr->dispPtr->focusPtr; + } } } else { tkwin = (Tk_Window) winPtr->dispPtr->focusPtr; -- cgit v0.12 From 700099a55b64bc25128a2287a8cdd7f9655f89af Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 22 Oct 2019 23:17:56 +0000 Subject: More progress on implementing IME --- library/entry.tcl | 12 ++++++++++ library/text.tcl | 13 ++++++++++ library/tk.tcl | 3 +++ macosx/tkMacOSXKeyEvent.c | 61 ++++++++++++++++++++++------------------------- 4 files changed, 56 insertions(+), 33 deletions(-) diff --git a/library/entry.tcl b/library/entry.tcl index 0cc9ffb..8d1b1b3 100644 --- a/library/entry.tcl +++ b/library/entry.tcl @@ -277,6 +277,18 @@ bind Entry { } } +# Bindings for IME text input. + +bind Entry <> { + dict set ::tk::Priv(IMETextMark) "%W" [%W index insert] +} +bind Entry <> { + %W selection range [dict get $::tk::Priv(IMETextMark) "%W"] insert +} +bind Entry <> { + %W delete [dict get $::tk::Priv(IMETextMark) "%W"] [%W index insert] +} + # A few additional bindings of my own. bind Entry <2> { diff --git a/library/text.tcl b/library/text.tcl index f43366b..7525588 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -397,6 +397,19 @@ bind Text { } } +# Bindings for IME text input. + +bind Text <> { + dict set ::tk::Priv(IMETextMark) "%W" [%W index insert] +} +bind Text <> { + %W tag add IMEmarkedtext [dict get $::tk::Priv(IMETextMark) "%W"] insert + %W tag configure IMEmarkedtext -underline on +} +bind Text <> { + %W delete IMEmarkedtext.first IMEmarkedtext.last +} + # Macintosh only bindings: if {[tk windowingsystem] eq "aqua"} { diff --git a/library/tk.tcl b/library/tk.tcl index 35433e8..572c1f0 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -701,7 +701,10 @@ if {[tk windowingsystem] eq "aqua"} { } } +# Create a dictionary to store the starting index of the IME marked +# text in an Entry or Text widget. +set ::tk::Priv(IMETextMark) [dict create] # Run the Ttk themed widget set initialization if {$::ttk::library ne ""} { diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index a3ab2d3..ce9a452 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -306,6 +306,14 @@ static unsigned isFunctionKey(unsigned int code); processingCompose = NO; /* + * Clear any working text. + */ + + if (privateWorkingText != nil) { + [self deleteWorkingText]; + } + + /* * Insert the string as a sequence of keystrokes. */ @@ -349,14 +357,6 @@ static unsigned isFunctionKey(unsigned int code); Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); } - /* - * Clear any working text. - */ - - if (privateWorkingText != nil) { - [self deleteWorkingText]; - } - releaseCode = (UInt16) [aString characterAtIndex: 0]; } @@ -380,12 +380,13 @@ static unsigned isFunctionKey(unsigned int code); selectedRange: (NSRange)selRange replacementRange: (NSRange)repRange { - Tk_Window tkwin = (Tk_Window) TkMacOSXGetTkWindow([self window]); + TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); + Tk_Window tkwin = (Tk_Window) winPtr; + Tk_Window focusWin = (Tk_Window) winPtr->dispPtr->focusPtr; NSString *temp; NSString *str = [aString respondsToSelector:@selector (string)] ? [aString string] : aString; - printf("Setting marked text for %s to %s\n", Tk_PathName(tkwin), - [str length] ? str.UTF8String : "None"); + if (NS_KEYLOG) { TKLog(@"setMarkedText '%@' len =%lu range %lu from %lu", str, (unsigned long) [str length], (unsigned long) selRange.length, @@ -393,30 +394,23 @@ static unsigned isFunctionKey(unsigned int code); } if (privateWorkingText != nil) { - unsigned long length = [privateWorkingText length]; [self deleteWorkingText]; - } + if ([str length] == 0) { return; } /* - * Warn the widget that we are going to insert the marked text - * so it can erase the old marked text and display the new. - */ - - TkSendVirtualEvent(tkwin, "TkStartIMEMarkedText", NULL); - - /* * Use our insertText method to display the marked text. */ + TkSendVirtualEvent(focusWin, "TkStartIMEMarkedText", NULL); temp = [str copy]; [self insertText: temp replacementRange:repRange]; privateWorkingText = temp; processingCompose = YES; - TkSendVirtualEvent(tkwin, "TkEndIMEMarkedText", NULL); + TkSendVirtualEvent(focusWin, "TkEndIMEMarkedText", NULL); } @@ -550,20 +544,21 @@ static unsigned isFunctionKey(unsigned int code); - (void)deleteWorkingText { if (privateWorkingText == nil) { - printf("No working text to delete\n"); return; - } - if (NS_KEYLOG) { - TKLog(@"deleteWorkingText len = %lu\n", - (unsigned long)[privateWorkingText length]); - } - printf("deleteWorkingText %s\n", [privateWorkingText length] ? - privateWorkingText.UTF8String : "none"); - [privateWorkingText release]; - privateWorkingText = nil; - processingCompose = NO; + } else { + TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); + Tk_Window focusWin = (Tk_Window) winPtr->dispPtr->focusPtr; - //PENDING: delete working text + if (NS_KEYLOG) { + TKLog(@"deleteWorkingText len = %lu\n", + (unsigned long)[privateWorkingText length]); + } + + [privateWorkingText release]; + privateWorkingText = nil; + processingCompose = NO; + TkSendVirtualEvent(focusWin, "TkClearIMEMarkedText", NULL); + } } @end -- cgit v0.12 From e766ee74b4cc2341eb5799f74958467d1792c310 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 23 Oct 2019 01:20:04 +0000 Subject: Add IME bindings for ttk::entry. --- library/ttk/entry.tcl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/library/ttk/entry.tcl b/library/ttk/entry.tcl index 383eebd..8f21ecc 100644 --- a/library/ttk/entry.tcl +++ b/library/ttk/entry.tcl @@ -152,6 +152,18 @@ bind TEntry { ttk::entry::Delete %W } bind TEntry { ttk::entry::Backspace %W } bind TEntry { %W delete insert end } +# Bindings for IME text input. + +bind TEntry <> { + dict set ::tk::Priv(IMETextMark) "%W" [%W index insert] +} +bind TEntry <> { + %W selection range [dict get $::tk::Priv(IMETextMark) "%W"] insert +} +bind TEntry <> { + %W delete [dict get $::tk::Priv(IMETextMark) "%W"] [%W index insert] +} + ### Clipboard procedures. # -- cgit v0.12 From e52422e60cb9265936b53ae27a0ee159416221db Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 23 Oct 2019 03:43:42 +0000 Subject: Add update idletasks for the text. Replace non-BMP characters by 0xfffd when pasting. --- library/text.tcl | 7 ++++--- macosx/tkMacOSXClipboard.c | 23 ++++++++++++++++++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/library/text.tcl b/library/text.tcl index 7525588..c4e3388 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -403,11 +403,13 @@ bind Text <> { dict set ::tk::Priv(IMETextMark) "%W" [%W index insert] } bind Text <> { - %W tag add IMEmarkedtext [dict get $::tk::Priv(IMETextMark) "%W"] insert + %W tag add IMEmarkedtext [dict get $::tk::Priv(IMETextMark) "%W"] insert %W tag configure IMEmarkedtext -underline on + update idletasks } bind Text <> { - %W delete IMEmarkedtext.first IMEmarkedtext.last + %W delete IMEmarkedtext.first IMEmarkedtext.last + update idletasks } # Macintosh only bindings: @@ -1226,4 +1228,3 @@ proc ::tk::TextScanDrag {w x y} { $w scan dragto $x $y } } - diff --git a/macosx/tkMacOSXClipboard.c b/macosx/tkMacOSXClipboard.c index 6cbcdf6..116525f 100644 --- a/macosx/tkMacOSXClipboard.c +++ b/macosx/tkMacOSXClipboard.c @@ -130,6 +130,7 @@ TkSelGetSelection( && selection == dispPtr->clipboardAtom && (target == XA_STRING || target == dispPtr->utf8Atom)) { NSString *string = nil; + NSString *clean; NSPasteboard *pb = [NSPasteboard generalPasteboard]; NSString *type = [pb availableTypeFromArray:[NSArray arrayWithObject: NSStringPboardType]]; @@ -137,7 +138,27 @@ TkSelGetSelection( if (type) { string = [pb stringForType:type]; } - result = proc(clientData, interp, string ? [string UTF8String] : ""); + if (string) { + /* + * Replace all non-BMP characters by the replacement character 0xfffd. + * This is a workaround until Tcl supports TCL_UTF_MAX > 3. + */ + int i, j, len = [string length]; + CFRange all = CFRangeMake(0, len); + UniChar *buffer = ckalloc(len*sizeof(UniChar)); + CFStringGetCharacters((CFStringRef) string, all, buffer); + for (i = 0, j = 0 ; j < len ; i++, j++) { + if (CFStringIsSurrogateHighCharacter(buffer[j])) { + buffer[i] = 0xfffd; + j++; + } else { + buffer[i] = buffer[j]; + } + } + clean = (NSString *)CFStringCreateWithCharacters(NULL, buffer, i); + ckfree(buffer); + } + result = proc(clientData, interp, [clean UTF8String]); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s selection doesn't exist or form \"%s\" not defined", -- cgit v0.12 From 0eeeca231986aeb7bc60b138b6a9da092cc63add Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 23 Oct 2019 20:39:37 +0000 Subject: re-add an update in canvImg-11.3. [d0ddf1ac] made the test fail on Windows --- tests/canvImg.test | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/canvImg.test b/tests/canvImg.test index c0b91f8..bd9edb5 100644 --- a/tests/canvImg.test +++ b/tests/canvImg.test @@ -803,6 +803,7 @@ test canvImg-11.3 {ImageChangedProc procedure} -constraints { foo2 changed 0 0 0 0 80 60 .c create image 50 100 -image foo -tags image -anchor nw .c create image 70 110 -image foo2 -anchor nw + update set z {} set timer [after 500 {lappend z "timed out"}] image create test foo -variable x -- cgit v0.12 From ff1084424205d441c9aa41014da76bb7b9a92350 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 23 Oct 2019 20:40:47 +0000 Subject: re-add an update in canvImg-11.3. [d0ddf1ac] made the test fail on Windows --- tests/canvImg.test | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/canvImg.test b/tests/canvImg.test index 459a761..a5e8e10 100644 --- a/tests/canvImg.test +++ b/tests/canvImg.test @@ -803,6 +803,7 @@ test canvImg-11.3 {ImageChangedProc procedure} -constraints { foo2 changed 0 0 0 0 80 60 .c create image 50 100 -image foo -tags image -anchor nw .c create image 70 110 -image foo2 -anchor nw + update set z {} set timer [after 500 {lappend z "timed out"}] image create test foo -variable x -- cgit v0.12 From 08fe0c62213c3897a4afcf8ee9c2de44d61f1442 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 23 Oct 2019 21:52:37 +0000 Subject: Rework and simplify services so the TkService object won't interfere with IME. It didn't need to be a subclass of NSView, or be in the Responder chain. --- library/entry.tcl | 5 -- library/text.tcl | 6 --- library/tk.tcl | 5 -- library/ttk/entry.tcl | 7 --- macosx/tkMacOSXInit.c | 6 +-- macosx/tkMacOSXKeyEvent.c | 1 - macosx/tkMacOSXServices.c | 126 +++++++------------------------------------ macosx/tkMacOSXWindowEvent.c | 18 +++++-- 8 files changed, 35 insertions(+), 139 deletions(-) diff --git a/library/entry.tcl b/library/entry.tcl index 8d1b1b3..36c331d 100644 --- a/library/entry.tcl +++ b/library/entry.tcl @@ -74,11 +74,6 @@ bind Entry <> { # Standard Motif bindings: -bind Entry { - if {[tk windowingsystem] eq "aqua"} { - ::tk::RegisterServiceWidget %W - } -} bind Entry <1> { tk::EntryButton1 %W %x %W selection clear diff --git a/library/text.tcl b/library/text.tcl index c4e3388..0530cf5 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -42,12 +42,6 @@ # Standard Motif bindings: -bind Text { - if {[tk windowingsystem] eq "aqua"} { - ::tk::RegisterServiceWidget %W - } -} - bind Text <1> { tk::TextButton1 %W %x %y %W tag remove sel 0.0 end diff --git a/library/tk.tcl b/library/tk.tcl index 572c1f0..60107cf 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -687,11 +687,6 @@ if {[tk windowingsystem] eq "aqua"} { if {[tk windowingsystem] eq "aqua"} { - #register to send data to macOS Services - proc ::tk::RegisterServiceWidget {w} { - ::tk::mac::registerServiceWidget $w - } - #stub procedures to respond to "do script" Apple Events proc ::tk::mac::DoScriptFile {file} { source $file diff --git a/library/ttk/entry.tcl b/library/ttk/entry.tcl index 8f21ecc..6a34488 100644 --- a/library/ttk/entry.tcl +++ b/library/ttk/entry.tcl @@ -58,13 +58,6 @@ option add *TEntry.cursor [ttk::cursor text] widgetDefault # and I'll put it back. # -##Bindings to register with macOS Services API. -bind T.Entry { - if {[tk windowingsystem] eq "aqua"} { - ::tk::RegisterServiceWidget %W - } -} - ## Clipboard events: # bind TEntry <> { ttk::entry::Cut %W } diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index 2ba4d28..e3ea481 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -406,8 +406,7 @@ TkpInit( /* * Initialize the NSServices object here. Apple's docs say to do this * in applicationDidFinishLaunching, but the Tcl interpreter is not - * initialized until this function call. Only the main interpreter - * is allowed to provide services. + * initialized until this function call. */ TkMacOSXServices_Init(interp); @@ -427,9 +426,6 @@ TkpInit( Tcl_CreateObjCommand(interp, "::tk::mac::iconBitmap", TkMacOSXIconBitmapObjCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "::tk::mac::GetAppPath", TkMacOSXGetAppPath, NULL, NULL); - Tcl_CreateObjCommand(interp, "::tk::mac::registerServiceWidget", - TkMacOSXRegisterServiceWidgetObjCmd, NULL, NULL); - return TCL_OK; } diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index ce9a452..e3a4193 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -381,7 +381,6 @@ static unsigned isFunctionKey(unsigned int code); replacementRange: (NSRange)repRange { TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); - Tk_Window tkwin = (Tk_Window) winPtr; Tk_Window focusWin = (Tk_Window) winPtr->dispPtr->focusPtr; NSString *temp; NSString *str = [aString respondsToSelector:@selector (string)] ? diff --git a/macosx/tkMacOSXServices.c b/macosx/tkMacOSXServices.c index 02c0fda..914ef53 100644 --- a/macosx/tkMacOSXServices.c +++ b/macosx/tkMacOSXServices.c @@ -10,14 +10,11 @@ * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ -#include #include #include -static Tcl_Interp *ServicesInterp; - /* - * Event proc which calls the PerformService procedure + * Event proc which calls the PerformService procedure. */ static int @@ -25,21 +22,24 @@ ServicesEventProc( Tcl_Event *event, int flags) { - Tcl_GlobalEval(ServicesInterp, "::tk::mac::PerformService"); + TkMainInfo *info = TkGetMainInfoList(); + Tcl_GlobalEval(info->interp, "::tk::mac::PerformService"); return 1; } /* - * Class declarations for TkService class. + * The Wish application can send the current selection in the Tk clipboard + * to other applications which accept messages of type NSString. The TkService + * object provides this service via its provideService method. (The method + * must be specified in the application's Info.plist file for this to work.) */ -@interface TkService : NSView { +@interface TkService : NSObject { } + (void) initialize; -- (void)provideService:(NSPasteboard *)pboard userData:(NSString *)data error:(NSString **)error; -- (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType; +- (void) provideService:(NSPasteboard *)pboard userData:(NSString *)data error:(NSString **)error; - (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard types:(NSArray *)types; @end @@ -57,32 +57,8 @@ ServicesEventProc( return; } - -- (id)validRequestorForSendType:(NSString *)sendType - returnType:(NSString *)returnType -{ - if ([sendType isEqualToString:@"NSStringPboardType"] || - [sendType isEqualToString:@"NSPasteboardTypeString"]) { - return self; - } - return [super validRequestorForSendType:sendType returnType:returnType]; -} - /* - * Make sure the view accepts events. - */ - -- (BOOL)acceptsFirstResponder -{ - return YES; -} -- (BOOL)becomeFirstResponder -{ - return YES; -} - -/* - * Get selected text, copy to pasteboard. + * Get the current selection and copy it to the sysstem pasteboard. */ - (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard @@ -90,6 +66,7 @@ ServicesEventProc( { NSArray *typesDeclared = nil; NSString *pboardType = nil; + TkMainInfo *info = TkGetMainInfoList(); for (NSString *typeString in types) { if ([typeString isEqualToString:@"NSStringPboardType"] || @@ -102,9 +79,9 @@ ServicesEventProc( if (!typesDeclared) { return NO; } - Tcl_Eval(ServicesInterp, "selection get"); + Tcl_Eval(info->interp, "selection get"); - char *copystring = Tcl_GetString(Tcl_GetObjResult(ServicesInterp)); + char *copystring = Tcl_GetString(Tcl_GetObjResult(info->interp)); NSString *writestring = [NSString stringWithUTF8String:copystring]; [pboard declareTypes:typesDeclared owner:nil]; @@ -112,8 +89,8 @@ ServicesEventProc( } /* - * This is the method that actually calls the Tk service; this is the method - * that must be defined in info.plist. + * This is the method that actually calls the Tk service; it must be specified + * in Info.plist. */ - (void)provideService:(NSPasteboard *)pboard @@ -125,8 +102,8 @@ ServicesEventProc( Tcl_Event *event; /* - * Get string from private pasteboard, write to general pasteboard to make - * available to Tcl service. + * Get a string from the private pasteboard and copy it to the general + * pasteboard to make it available to other applications. */ for (NSString *typeString in types) { @@ -150,69 +127,8 @@ ServicesEventProc( @end /* - * Register a specific widget to access the Services menu. - */ - -int -TkMacOSXRegisterServiceWidgetObjCmd( - ClientData cd, - Tcl_Interp *ip, - int objc, - Tcl_Obj *const objv[]) -{ - /* - * Need proper number of args. - */ - - if (objc != 2) { - Tcl_WrongNumArgs(ip, 1, objv, "path?"); - return TCL_ERROR; - } - - /* - * Get the object that holds this Tk Window... - */ - - Rect bounds; - NSRect frame; - Tk_Window path = - Tk_NameToWindow(ip, Tcl_GetString(objv[1]), Tk_MainWindow(ip)); - - if (path == NULL) { - return TCL_ERROR; - } - - Tk_MakeWindowExist(path); - Tk_MapWindow(path); - Drawable d = Tk_WindowId(path); - - /* - * Get NSView from Tk window and add subview. - */ - - TkService *serviceview = [[TkService alloc] init]; - NSView *view = TkMacOSXGetRootControl(d); - - if ([serviceview superview] != view) { - [view addSubview:serviceview]; - } - TkMacOSXWinBounds((TkWindow*)path, &bounds); - - /* - * Hack to make sure subview is set to take up entire geometry of window. - */ - - frame = NSMakeRect(bounds.left, bounds.top, 100000, 100000); - frame.origin.y = 0; - if (!NSEqualRects(frame, [serviceview frame])) { - [serviceview setFrame:frame]; - } - [serviceview release]; - return TCL_OK; -} - -/* - * Initalize the package in the Tcl interpreter, create Tcl commands. + * Instiantiate a TkService object and register it with the NSApplication. + * This is called (once only) from TkpInit. */ int @@ -220,12 +136,10 @@ TkMacOSXServices_Init( Tcl_Interp *interp) { /* - * Initialize instance of TclServices to provide service functionality. + * Initialize an instance of TkService and register it with the NSApp. */ TkService *service = [[TkService alloc] init]; - - ServicesInterp = interp; [NSApp setServicesProvider:service]; return TCL_OK; } diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 833df8c..c7b1c6a 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -1186,11 +1186,21 @@ RedisplayView( return YES; } -- (void) keyDown: (NSEvent *) theEvent +/* + * When the services menu is opened this is called for each Responder in + * the Responder chain until a service provider is found. The TkContentView + * should be the first (and generally only) Responder in the chain. We + * return the TkServices object that was created in TkpInit. + */ + +- (id)validRequestorForSendType:(NSString *)sendType + returnType:(NSString *)returnType { -#ifdef TK_MAC_DEBUG_EVENTS - TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent); -#endif + if ([sendType isEqualToString:@"NSStringPboardType"] || + [sendType isEqualToString:@"NSPasteboardTypeString"]) { + return [NSApp servicesProvider]; + } + return [super validRequestorForSendType:sendType returnType:returnType]; } @end -- cgit v0.12 From 9e15ca1a5e2f462d294bdaab89914e5ebfeb1328 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 23 Oct 2019 22:03:30 +0000 Subject: Address compiler warnings. --- macosx/tkMacOSXClipboard.c | 2 +- macosx/tkMacOSXPrivate.h | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/macosx/tkMacOSXClipboard.c b/macosx/tkMacOSXClipboard.c index 116525f..696b70e 100644 --- a/macosx/tkMacOSXClipboard.c +++ b/macosx/tkMacOSXClipboard.c @@ -157,8 +157,8 @@ TkSelGetSelection( } clean = (NSString *)CFStringCreateWithCharacters(NULL, buffer, i); ckfree(buffer); + result = proc(clientData, interp, [clean UTF8String]); } - result = proc(clientData, interp, [clean UTF8String]); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s selection doesn't exist or form \"%s\" not defined", diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 0f1fbca..68bad41 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -359,13 +359,8 @@ VISIBILITY_HIDDEN @end @interface TKContentView(TKWindowEvent) -- (void) drawRect: (NSRect) rect; - (void) generateExposeEvents: (HIShapeRef) shape; - (void) tkToolbarButton: (id) sender; -- (BOOL) isOpaque; -- (BOOL) wantsDefaultClipping; -- (BOOL) acceptsFirstResponder; -- (void) keyDown: (NSEvent *) theEvent; @end @interface NSWindow(TKWm) -- cgit v0.12 From f42842d83e17bea792315d12d4f6a169d46274ad Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 24 Oct 2019 03:54:04 +0000 Subject: Restore the no-op keyDown method to keep the mac from beeping every time a key is pressed. --- macosx/tkMacOSXWindowEvent.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index c7b1c6a..6c0f335 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -1187,6 +1187,18 @@ RedisplayView( } /* + * This keyDown method does nothing, which is a huge improvement over the + * default keyDown method which beeps every time a key is pressed. + */ + +- (void) keyDown: (NSEvent *) theEvent +{ +#ifdef TK_MAC_DEBUG_EVENTS + TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent); +#endif +} + +/* * When the services menu is opened this is called for each Responder in * the Responder chain until a service provider is found. The TkContentView * should be the first (and generally only) Responder in the chain. We -- cgit v0.12 From b88700de5981455ad9071568ce05d1706143b269 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 24 Oct 2019 03:57:43 +0000 Subject: Remove the calls to update idletasks which were not needed. --- library/text.tcl | 2 -- 1 file changed, 2 deletions(-) diff --git a/library/text.tcl b/library/text.tcl index 0530cf5..24f8428 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -399,11 +399,9 @@ bind Text <> { bind Text <> { %W tag add IMEmarkedtext [dict get $::tk::Priv(IMETextMark) "%W"] insert %W tag configure IMEmarkedtext -underline on - update idletasks } bind Text <> { %W delete IMEmarkedtext.first IMEmarkedtext.last - update idletasks } # Macintosh only bindings: -- cgit v0.12 From 885548ee95c2cfc0627d04b2fa22ad51117b9b55 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 24 Oct 2019 14:14:47 +0000 Subject: Aqua: Fix arithmetic error in ttk::scrollbar display. --- macosx/ttkMacOSXTheme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index 4f9c044..952aa20 100644 --- a/macosx/ttkMacOSXTheme.c +++ b/macosx/ttkMacOSXTheme.c @@ -2095,7 +2095,7 @@ static void TrackElementDraw( Tcl_GetDoubleFromObj(NULL, elem->fromObj, &from); Tcl_GetDoubleFromObj(NULL, elem->toObj, &to); Tcl_GetDoubleFromObj(NULL, elem->valueObj, &value); - factor = RangeToFactor(to - from); + factor = RangeToFactor(to); HIThemeTrackDrawInfo info = { .version = 0, -- cgit v0.12 From 2b66c3ae4d05b4f4c64b795fb6e276c24c44f37e Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 24 Oct 2019 15:38:23 +0000 Subject: Prevent a crash which could occur if the window were defocussed during IME composition. --- macosx/tkMacOSXKeyEvent.c | 27 ++++++++++++++++++++++----- macosx/tkMacOSXServices.c | 14 +++++++++----- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index e3a4193..19be7cf 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -7,7 +7,7 @@ * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen * Copyright (c) 2012 Adrian Robert. - * Copyright 2015 Marc Culler. + * Copyright 2015-2019 Marc Culler. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -31,6 +31,7 @@ static NSWindow *keyboardGrabNSWindow = nil; * window. */ static NSModalSession modalSession = nil; static BOOL processingCompose = NO; +static Tk_Window composeWin = NULL; static int caret_x = 0, caret_y = 0, caret_height = 0; static unsigned short releaseCode; @@ -386,6 +387,17 @@ static unsigned isFunctionKey(unsigned int code); NSString *str = [aString respondsToSelector:@selector (string)] ? [aString string] : aString; + if (focusWin) { + + /* + * Remember the widget where the composition is happening, in case it + * gets defocussed during the composition. + */ + + composeWin = focusWin; + } else { + return; + } if (NS_KEYLOG) { TKLog(@"setMarkedText '%@' len =%lu range %lu from %lu", str, (unsigned long) [str length], (unsigned long) selRange.length, @@ -539,14 +551,17 @@ static unsigned isFunctionKey(unsigned int code); @implementation TKContentView(TKKeyEvent) -/* delete display of composing characters [not in ] */ + +/* + * Tell the widget to erase the displayed composing characters. This + * is not part of the NSTextInputClient protocol. + */ + - (void)deleteWorkingText { if (privateWorkingText == nil) { return; } else { - TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); - Tk_Window focusWin = (Tk_Window) winPtr->dispPtr->focusPtr; if (NS_KEYLOG) { TKLog(@"deleteWorkingText len = %lu\n", @@ -556,7 +571,9 @@ static unsigned isFunctionKey(unsigned int code); [privateWorkingText release]; privateWorkingText = nil; processingCompose = NO; - TkSendVirtualEvent(focusWin, "TkClearIMEMarkedText", NULL); + if (composeWin) { + TkSendVirtualEvent(composeWin, "TkClearIMEMarkedText", NULL); + } } } @end diff --git a/macosx/tkMacOSXServices.c b/macosx/tkMacOSXServices.c index 914ef53..0434f10 100644 --- a/macosx/tkMacOSXServices.c +++ b/macosx/tkMacOSXServices.c @@ -4,6 +4,7 @@ * This file allows the integration of Tk and the Cocoa NSServices API. * * Copyright (c) 2010-2019 Kevin Walzer/WordTech Communications LLC. + * Copyright (c) 2019 Marc Culler. * Copyright (c) 2010 Adrian Robert. * * See the file "license.terms" for information on usage and redistribution @@ -39,8 +40,11 @@ ServicesEventProc( } + (void) initialize; -- (void) provideService:(NSPasteboard *)pboard userData:(NSString *)data error:(NSString **)error; -- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard types:(NSArray *)types; +- (void) provideService:(NSPasteboard *)pboard + userData:(NSString *)data + error:(NSString **)error; +- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard + types:(NSArray *)types; @end @@ -58,7 +62,7 @@ ServicesEventProc( } /* - * Get the current selection and copy it to the sysstem pasteboard. + * Get the current Tk selection and copy it to the system pasteboard. */ - (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard @@ -127,8 +131,8 @@ ServicesEventProc( @end /* - * Instiantiate a TkService object and register it with the NSApplication. - * This is called (once only) from TkpInit. + * Instantiate a TkService object and register it with the NSApplication. + * This is called exactly one time from TkpInit. */ int -- cgit v0.12 From c3e50c2a97a47cd421f3765d93517058d08c0494 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 24 Oct 2019 17:47:59 +0000 Subject: Fix [6b763e9480]: wrong selected text background in ttk::entry. --- library/ttk/aquaTheme.tcl | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/library/ttk/aquaTheme.tcl b/library/ttk/aquaTheme.tcl index 83fa16f..e8009be 100644 --- a/library/ttk/aquaTheme.tcl +++ b/library/ttk/aquaTheme.tcl @@ -9,8 +9,8 @@ namespace eval ttk::theme::aqua { -font TkDefaultFont \ -background systemWindowBackgroundColor \ -foreground systemLabelColor \ - -selectbackground systemHighlight \ - -selectforeground systemLabelColor \ + -selectbackground systemSelectedTextBackgroundColor \ + -selectforeground systemSelectedTextColor \ -selectborderwidth 0 \ -insertwidth 1 @@ -38,7 +38,18 @@ namespace eval ttk::theme::aqua { # Entry ttk::style configure TEntry \ -foreground systemTextColor \ - -background systemTextBackgroundColor \ + -background systemTextBackgroundColor + ttk::style map TEntry \ + -foreground { + disabled systemDisabledControlTextColor + } \ + -selectforeground { + background systemTextColor + } \ + -selectbackground { + background systemTextBackgroundColor + } + # Workaround for #1100117: # Actually, on Aqua we probably shouldn't stipple images in @@ -59,20 +70,16 @@ namespace eval ttk::theme::aqua { # Combobox: ttk::style configure TCombobox \ -foreground systemTextColor \ - -background systemTransparent \ - -selectforeground systemSelectedTextColor \ - -selectbackground systemSelectedTextBackgroundColor + -background systemTransparent ttk::style map TCombobox \ -foreground { disabled systemDisabledControlTextColor } \ -selectforeground { - !active systemTextColor + background systemTextColor } \ -selectbackground { - !active systemTextBackgroundColor - !focus systemTextBackgroundColor - focus systemSelectedTextBackgroundColor + background systemTransparent } # Spinbox -- cgit v0.12 From c9c3c73d09cd696f710a5c6bfd731d9cdb243276 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 24 Oct 2019 23:56:43 +0000 Subject: Make Apple's press-and-hold accent menu work with Tk entry and text widgets. --- library/entry.tcl | 5 ++- library/text.tcl | 3 ++ library/ttk/entry.tcl | 3 ++ macosx/tkMacOSXKeyEvent.c | 86 ++++++++++++++++++++++++++++------------------- 4 files changed, 62 insertions(+), 35 deletions(-) diff --git a/library/entry.tcl b/library/entry.tcl index 36c331d..2c72fee 100644 --- a/library/entry.tcl +++ b/library/entry.tcl @@ -272,7 +272,7 @@ bind Entry { } } -# Bindings for IME text input. +# Bindings for IME text input and accents. bind Entry <> { dict set ::tk::Priv(IMETextMark) "%W" [%W index insert] @@ -283,6 +283,9 @@ bind Entry <> { bind Entry <> { %W delete [dict get $::tk::Priv(IMETextMark) "%W"] [%W index insert] } +bind Entry <> { + tk::EntryBackspace %W +} # A few additional bindings of my own. diff --git a/library/text.tcl b/library/text.tcl index 24f8428..e1130a4 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -403,6 +403,9 @@ bind Text <> { bind Text <> { %W delete IMEmarkedtext.first IMEmarkedtext.last } +bind Text <> { + %W delete insert-1c +} # Macintosh only bindings: diff --git a/library/ttk/entry.tcl b/library/ttk/entry.tcl index 6a34488..7bca47f 100644 --- a/library/ttk/entry.tcl +++ b/library/ttk/entry.tcl @@ -156,6 +156,9 @@ bind TEntry <> { bind TEntry <> { %W delete [dict get $::tk::Priv(IMETextMark) "%W"] [%W index insert] } +bind Entry <> { + tk::EntryBackspace %W +} ### Clipboard procedures. # diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index 19be7cf..09abb01 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -285,7 +285,7 @@ static unsigned isFunctionKey(unsigned int code); return self; } -/* +/* * Implementation of the NSTextInputClient protocol. */ @@ -297,9 +297,14 @@ static unsigned isFunctionKey(unsigned int code); - (void)insertText: (id)aString replacementRange: (NSRange)repRange { - int i, len = [(NSString *) aString length]; + int i, len; XEvent xEvent; - + NSString *str; + + str = ([aString isKindOfClass: [NSAttributedString class]]) ? + str = [aString string] : aString; + len = [str length]; + if (NS_KEYLOG) { TKLog(@"insertText '%@'\tlen = %d", aString, len); } @@ -322,6 +327,19 @@ static unsigned isFunctionKey(unsigned int code); xEvent.xany.type = KeyPress; /* + * Apple evidently sets location to 0 to signal that an accented letter has + * been selected from the accent menu. An unaccented letter has already + * been displayed and we need to erase it before displaying the accented + * letter. + */ + + if (repRange.location == 0) { + TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); + Tk_Window focusWin = (Tk_Window) winPtr->dispPtr->focusPtr; + TkSendVirtualEvent(focusWin, "TkAccentBackspace", NULL); + } + + /* * NSString represents a non-BMP character as a string of length 2 where * the first character is the high surrogate and the second character is * the low surrogate. We could record this in the XEvent by setting the @@ -332,10 +350,10 @@ static unsigned isFunctionKey(unsigned int code); */ for (i = 0; i < len; i++) { - UniChar nextChar = [aString characterAtIndex: i]; + UniChar nextChar = [str characterAtIndex: i]; if (CFStringIsSurrogateHighCharacter(nextChar)) { #if 0 - UniChar lowChar = [aString characterAtIndex: ++i]; + UniChar lowChar = [str characterAtIndex: ++i]; xEvent.xkey.keycode = CFStringGetLongCharacterForSurrogatePair( nextChar, lowChar); xEvent.xkey.nbytes = TkUniCharToUtf(xEvent.xkey.keycode, @@ -348,7 +366,7 @@ static unsigned isFunctionKey(unsigned int code); #endif } else { xEvent.xkey.keycode = (int) nextChar; - [[aString substringWithRange: NSMakeRange(i,1)] + [[str substringWithRange: NSMakeRange(i,1)] getCString: xEvent.xkey.trans_chars maxLength: XMaxTransChars encoding: NSUTF8StringEncoding]; xEvent.xkey.nbytes = strlen(xEvent.xkey.trans_chars); @@ -358,20 +376,20 @@ static unsigned isFunctionKey(unsigned int code); Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); } - releaseCode = (UInt16) [aString characterAtIndex: 0]; + releaseCode = (UInt16) [str characterAtIndex: 0]; } /* * This required method is allowed to return nil. */ -- (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)theRange +- (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)theRange actualRange:(NSRangePointer)thePointer { return nil; } -/* +/* * This method is supposed to insert (or replace selected text with) the string * argument. If the argument is an NSString, it should be displayed with a * distinguishing appearance, e.g underlined. @@ -384,11 +402,13 @@ static unsigned isFunctionKey(unsigned int code); TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); Tk_Window focusWin = (Tk_Window) winPtr->dispPtr->focusPtr; NSString *temp; - NSString *str = [aString respondsToSelector:@selector (string)] ? - [aString string] : aString; + NSString *str; + + str = ([aString isKindOfClass: [NSAttributedString class]]) ? + str = [aString string] : aString; if (focusWin) { - + /* * Remember the widget where the composition is happening, in case it * gets defocussed during the composition. @@ -415,7 +435,7 @@ static unsigned isFunctionKey(unsigned int code); /* * Use our insertText method to display the marked text. */ - + TkSendVirtualEvent(focusWin, "TkStartIMEMarkedText", NULL); temp = [str copy]; [self insertText: temp replacementRange:repRange]; @@ -424,7 +444,6 @@ static unsigned isFunctionKey(unsigned int code); TkSendVirtualEvent(focusWin, "TkEndIMEMarkedText", NULL); } - - (BOOL)hasMarkedText { return privateWorkingText != nil; @@ -443,11 +462,19 @@ static unsigned isFunctionKey(unsigned int code); return rng; } +- (void)cancelComposingText +{ + if (NS_KEYLOG) { + TKLog(@"cancelComposingText"); + } + [self deleteWorkingText]; + processingCompose = NO; +} - (void)unmarkText { if (NS_KEYLOG) { - TKLog(@"unmark (accept) text"); + TKLog(@"unmarkText"); } [self deleteWorkingText]; processingCompose = NO; @@ -489,31 +516,22 @@ static unsigned isFunctionKey(unsigned int code); } processingCompose = NO; if (aSelector == @selector (deleteBackward:)) { - /* - * Happens when user backspaces over an ongoing composition: - * throw a 'delete' into the event queue. - */ - - XEvent xEvent; - - setupXEvent(&xEvent, [self window], 0); - xEvent.xany.type = KeyPress; - xEvent.xkey.nbytes = 1; - xEvent.xkey.keycode = (0x33 << 16) | 0x7F; - xEvent.xkey.trans_chars[0] = 0x7F; - xEvent.xkey.trans_chars[1] = 0x0; - Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); + TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); + Tk_Window focusWin = (Tk_Window) winPtr->dispPtr->focusPtr; + TkSendVirtualEvent(focusWin, "TkAccentBackspace", NULL); } } - (NSArray *)validAttributesForMarkedText { static NSArray *arr = nil; - if (arr == nil) { - arr = [NSArray new]; + arr = [[NSArray alloc] initWithObjects: + NSUnderlineStyleAttributeName, + NSUnderlineColorAttributeName, + nil]; + [arr retain]; } - /* [[NSArray arrayWithObject: NSUnderlineStyleAttributeName] retain]; */ return arr; } @@ -522,7 +540,7 @@ static unsigned isFunctionKey(unsigned int code); if (NS_KEYLOG) { TKLog(@"selectedRange request"); } - return NSMakeRange(NSNotFound, 0); + return NSMakeRange(0, 0); } - (NSUInteger)characterIndexForPoint: (NSPoint)thePoint @@ -530,7 +548,7 @@ static unsigned isFunctionKey(unsigned int code); if (NS_KEYLOG) { TKLog(@"characterIndexForPoint request"); } - return 0; + return NSNotFound; } - (NSAttributedString *)attributedSubstringFromRange: (NSRange)theRange -- cgit v0.12 From 78e5c73c2979582c40a5cf0d8cd78e92d3767d11 Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 25 Oct 2019 01:15:39 +0000 Subject: Fix [b82bd4872b]: tk::style configure -compound does not work. --- generic/ttk/ttkButton.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/generic/ttk/ttkButton.c b/generic/ttk/ttkButton.c index 68a6293..72e9815 100644 --- a/generic/ttk/ttkButton.c +++ b/generic/ttk/ttkButton.c @@ -82,7 +82,8 @@ static Tk_OptionSpec BaseOptionSpecs[] = */ {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", "none", Tk_Offset(Base,base.compoundObj), -1, - 0,(ClientData)ttkCompoundStrings,GEOMETRY_CHANGED }, + TK_OPTION_DONT_SET_DEFAULT,(ClientData)ttkCompoundStrings, + GEOMETRY_CHANGED }, {TK_OPTION_STRING, "-padding", "padding", "Pad", NULL, Tk_Offset(Base,base.paddingObj), -1, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED}, -- cgit v0.12 From 86e70bdd43b53d05c78b4709c42753e464bb3fec Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 25 Oct 2019 03:12:39 +0000 Subject: Add some protections against Tcl errors during IME text entry. --- library/entry.tcl | 6 +++++- library/text.tcl | 8 ++++++-- library/ttk/entry.tcl | 6 +++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/library/entry.tcl b/library/entry.tcl index 2c72fee..2aab934 100644 --- a/library/entry.tcl +++ b/library/entry.tcl @@ -278,7 +278,11 @@ bind Entry <> { dict set ::tk::Priv(IMETextMark) "%W" [%W index insert] } bind Entry <> { - %W selection range [dict get $::tk::Priv(IMETextMark) "%W"] insert + if { [catch {dict get $::tk::Priv(IMETextMark) "%W"} mark] } { + bell + } else { + %W selection range $mark insert + } } bind Entry <> { %W delete [dict get $::tk::Priv(IMETextMark) "%W"] [%W index insert] diff --git a/library/text.tcl b/library/text.tcl index e1130a4..bdfb78e 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -397,8 +397,12 @@ bind Text <> { dict set ::tk::Priv(IMETextMark) "%W" [%W index insert] } bind Text <> { - %W tag add IMEmarkedtext [dict get $::tk::Priv(IMETextMark) "%W"] insert - %W tag configure IMEmarkedtext -underline on + if { [catch {dict get $::tk::Priv(IMETextMark) "%W"} mark] } { + bell + } else { + %W tag add IMEmarkedtext $mark insert + %W tag configure IMEmarkedtext -underline on + } } bind Text <> { %W delete IMEmarkedtext.first IMEmarkedtext.last diff --git a/library/ttk/entry.tcl b/library/ttk/entry.tcl index 7bca47f..0a61ffa 100644 --- a/library/ttk/entry.tcl +++ b/library/ttk/entry.tcl @@ -151,7 +151,11 @@ bind TEntry <> { dict set ::tk::Priv(IMETextMark) "%W" [%W index insert] } bind TEntry <> { - %W selection range [dict get $::tk::Priv(IMETextMark) "%W"] insert + if { [catch {dict get $::tk::Priv(IMETextMark) "%W"} mark] } { + bell + } else { + %W selection range $mark insert + } } bind TEntry <> { %W delete [dict get $::tk::Priv(IMETextMark) "%W"] [%W index insert] -- cgit v0.12 From 173044a997e63b17bca3a35be5e4b8a70f997945 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 25 Oct 2019 21:28:59 +0000 Subject: Some end-of-line exess spacing --- macosx/tkMacOSXMenus.c | 2 +- macosx/tkMacOSXTest.c | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/macosx/tkMacOSXMenus.c b/macosx/tkMacOSXMenus.c index d47f8df..1c033a4 100644 --- a/macosx/tkMacOSXMenus.c +++ b/macosx/tkMacOSXMenus.c @@ -70,7 +70,7 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp); [NSMenuItem itemWithTitle: [NSString stringWithFormat:@"About %@", aboutName] action:@selector(orderFrontStandardAboutPanel:)] atIndex:0]; - _defaultFileMenuItems = + _defaultFileMenuItems = [[NSArray arrayWithObjects: [NSMenuItem itemWithTitle: [NSString stringWithFormat:@"Source%C", 0x2026] diff --git a/macosx/tkMacOSXTest.c b/macosx/tkMacOSXTest.c index 09736e6..c353efe 100644 --- a/macosx/tkMacOSXTest.c +++ b/macosx/tkMacOSXTest.c @@ -161,7 +161,7 @@ PressButtonObjCmd( if (screens && [screens count]) { ScreenHeight = [[screens objectAtIndex:0] frame].size.height; } - + if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "x y"); return TCL_ERROR; @@ -186,34 +186,34 @@ PressButtonObjCmd( loc.y = ScreenHeight - y; wNum = 0; CGWarpMouseCursorPosition(pt); - motion = [NSEvent mouseEventWithType:NSMouseMoved + motion = [NSEvent mouseEventWithType:NSMouseMoved location:loc - modifierFlags:0 - timestamp:GetCurrentEventTime() + modifierFlags:0 + timestamp:GetCurrentEventTime() windowNumber:wNum - context:nil + context:nil eventNumber:0 - clickCount:1 + clickCount:1 pressure:0.0]; [NSApp postEvent:motion atStart:NO]; - press = [NSEvent mouseEventWithType:NSLeftMouseDown + press = [NSEvent mouseEventWithType:NSLeftMouseDown location:loc - modifierFlags:0 - timestamp:GetCurrentEventTime() + modifierFlags:0 + timestamp:GetCurrentEventTime() windowNumber:wNum - context:nil + context:nil eventNumber:1 - clickCount:1 + clickCount:1 pressure:0.0]; [NSApp postEvent:press atStart:NO]; release = [NSEvent mouseEventWithType:NSLeftMouseUp location:loc - modifierFlags:0 - timestamp:GetCurrentEventTime() + modifierFlags:0 + timestamp:GetCurrentEventTime() windowNumber:wNum - context:nil + context:nil eventNumber:2 - clickCount:1 + clickCount:1 pressure:0.0]; [NSApp postEvent:release atStart:NO]; return TCL_OK; -- cgit v0.12 From 8939b39b95cc8320f202ec15a413c786ea692ff9 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 25 Oct 2019 21:30:52 +0000 Subject: Fix bug in TkpGetString() for MacOSX. Maybe this is why MacOSX barfs when we put a 4-byte UTF-8 character in trans_chars ... --- macosx/tkMacOSXKeyboard.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/macosx/tkMacOSXKeyboard.c b/macosx/tkMacOSXKeyboard.c index a64f81e..78bda9e 100644 --- a/macosx/tkMacOSXKeyboard.c +++ b/macosx/tkMacOSXKeyboard.c @@ -443,8 +443,11 @@ TkpGetString( * result. */ { (void) winPtr; /*unused*/ + int ch; + Tcl_DStringInit(dsPtr); - return Tcl_DStringAppend(dsPtr, eventPtr->xkey.trans_chars, -1); + return Tcl_DStringAppend(dsPtr, eventPtr->xkey.trans_chars, + TkUtfToUniChar(eventPtr->xkey.trans_chars, &ch)); } /* -- cgit v0.12 From 67c03eb3637104e2ae1595b548e6c21043f93c64 Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 26 Oct 2019 14:00:59 +0000 Subject: Fix [f7a4f75d1c]: focus -force fails for embedded toplevels --- generic/tkFocus.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/generic/tkFocus.c b/generic/tkFocus.c index 7a4bdbc..7b5acfb 100644 --- a/generic/tkFocus.c +++ b/generic/tkFocus.c @@ -629,7 +629,8 @@ TkSetFocusWin( } tlFocusPtr->focusWinPtr = winPtr; - if (topLevelPtr->flags & TK_EMBEDDED) { + if (topLevelPtr->flags & TK_EMBEDDED && + (displayFocusPtr->focusWinPtr == NULL)) { /* * We are assigning focus to an embedded toplevel. The platform -- cgit v0.12 From cd2e85da01cbcc264954b6b36912b49b5a17bbcd Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 26 Oct 2019 14:41:37 +0000 Subject: Add a regression test for this bug. --- tests/unixEmbed.test | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/unixEmbed.test b/tests/unixEmbed.test index 7d26fbf..d46818a 100644 --- a/tests/unixEmbed.test +++ b/tests/unixEmbed.test @@ -1263,6 +1263,24 @@ test unixEmbed-10.2 {geometry propagation in tkUnixWm.c/UpdateGeometryInfo} -con deleteWindows } -result {70x300+0+0} +test unixEmbed-11.1 {focus -force works for embedded toplevels} -constraints { + unix +} -setup { + deleteWindows +} -body { + toplevel .t + pack [frame .t.f -container 1 -width 200 -height 200] -fill both + update idletasks + toplevel .embed -use [winfo id .t.f] -bg green + update idletasks + focus -force .t + focus -force .embed + focus + } -cleanup { + deleteWindows +} -result .embed + + # cleanup deleteWindows cleanupbg -- cgit v0.12 From 00e7fe2e99c51592ac427010b501d4d9bb6f7a66 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 27 Oct 2019 10:58:53 +0000 Subject: Cherrypick [82b1d286] (Fix [cc6c711c1e]: treeview layout issues (patch from Brad Lanam)) --- generic/ttk/ttkTreeview.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index 5e52f01..e9abbc8 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -1232,9 +1232,10 @@ static int ConfigureColumn( if (mask & GEOMETRY_CHANGED) { if (!Tk_IsMapped(tv->core.tkwin)) { TtkResizeWidget(&tv->core); - } - RecomputeSlack(tv); - ResizeColumns(tv, TreeWidth(tv)); + } else { + RecomputeSlack(tv); + ResizeColumns(tv, TreeWidth(tv)); + } } TtkRedisplayWidget(&tv->core); -- cgit v0.12 From bca8adc60104d63e7d58c2ba7b257378e83c3a10 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 27 Oct 2019 11:03:04 +0000 Subject: Backout [82b1d286] and [0e9cbdba] that fixed [cc6c711c1e] and [ce470f20fd] since they created issues reported in [caacf1f082] --- doc/ttk_treeview.n | 26 ++++++-------- generic/ttk/ttkTreeview.c | 53 ++++++---------------------- library/ttk/treeview.tcl | 2 +- tests/ttk/treeview.test | 88 ----------------------------------------------- 4 files changed, 23 insertions(+), 146 deletions(-) diff --git a/doc/ttk_treeview.n b/doc/ttk_treeview.n index 125cc78..5fd5e6d 100644 --- a/doc/ttk_treeview.n +++ b/doc/ttk_treeview.n @@ -133,29 +133,25 @@ The column name. This is a read-only option. For example, [\fI$pathname \fBcolumn #\fIn \fB\-id\fR] returns the data column associated with display column #\fIn\fR. .TP -\fB\-anchor \fIanchor\fR +\fB\-anchor\fR Specifies how the text in this column should be aligned -with respect to the cell. \fIAnchor\fR is one of +with respect to the cell. One of \fBn\fR, \fBne\fR, \fBe\fR, \fBse\fR, \fBs\fR, \fBsw\fR, \fBw\fR, \fBnw\fR, or \fBcenter\fR. .TP -\fB\-minwidth \fIminwidth\fR +\fB\-minwidth\fR The minimum width of the column in pixels. The treeview widget will not make the column any smaller than \fB\-minwidth\fR when the widget is resized or the user drags a -column separator. Default is 20 pixels. -.TP -\fB\-stretch \fIboolean\fR -Specifies whether or not the column width should be adjusted -when the widget is resized or the user drags a column separator. -\fIBoolean\fR may have any of the forms accepted by \fBTcl_GetBoolean\fR. -By default columns are stretchable. -.TP -\fB\-width \fIwidth\fR -The width of the column in pixels. Default is 200 pixels. The specified -column width may be changed by Tk in order to honor \fB\-stretch\fR -and/or \fB\-minwidth\fR, or when the widget is resized or the user drags a column separator. +.TP +\fB\-stretch\fR +Specifies whether or not the column's width should be adjusted +when the widget is resized. +.TP +\fB\-width \fIw\fR +The width of the column in pixels. Default is something reasonable, +probably 200 or so. .PP Use \fIpathname column #0\fR to configure the tree column. .RE diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index fcd807c..492961d 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -282,7 +282,7 @@ static Tk_OptionSpec ColumnOptionSpecs[] = { 0,0,0 }, {TK_OPTION_BOOLEAN, "-stretch", "stretch", "Stretch", "1", -1, Tk_Offset(TreeColumn,stretch), - 0,0,GEOMETRY_CHANGED }, + 0,0,0 }, {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", "w", Tk_Offset(TreeColumn,anchorObj), -1, /* <> */ 0,0,0 }, @@ -1232,13 +1232,13 @@ static int ConfigureColumn( if (mask & GEOMETRY_CHANGED) { if (!Tk_IsMapped(tv->core.tkwin)) { TtkResizeWidget(&tv->core); - } else { - RecomputeSlack(tv); - ResizeColumns(tv, TreeWidth(tv)); - } + } + RecomputeSlack(tv); } TtkRedisplayWidget(&tv->core); + /* ASSERT: SLACKINVARIANT */ + Tk_FreeSavedOptions(&savedOptions); return TCL_OK; @@ -1615,10 +1615,13 @@ static void TreeviewDoLayout(void *clientData) Treeview *tv = clientData; int visibleRows; + /* ASSERT: SLACKINVARIANT */ + Ttk_PlaceLayout(tv->core.layout,tv->core.state,Ttk_WinBox(tv->core.tkwin)); tv->tree.treeArea = Ttk_ClientRegion(tv->core.layout, "treearea"); ResizeColumns(tv, tv->tree.treeArea.width); + /* ASSERT: SLACKINVARIANT */ TtkScrolled(tv->tree.xscrollHandle, tv->tree.xscroll.first, @@ -2888,28 +2891,9 @@ static int TreeviewDragCommand( TreeColumn *c = tv->tree.displayColumns[i]; int right = left + c->width; if (c == column) { - /* The limit not to exceed at the right is given by the tree width - minus the sum of the min widths of the columns at the right of - the one being resized (and don't forget possible x scrolling!). - For stretchable columns, this min width really is the minWidth, - for non-stretchable columns, this is the column width. - */ - int newxRightLimit = tv->tree.treeArea.x - tv->tree.xscroll.first - + tv->tree.treeArea.width; - int j = i + 1; - while (j < tv->tree.nDisplayColumns) { - TreeColumn *cr = tv->tree.displayColumns[j]; - if (cr->stretch) { - newxRightLimit -= cr->minWidth; - } else { - newxRightLimit -= cr->width; - } - ++j; - } - if (newx <= newxRightLimit) { - DragColumn(tv, i, newx - right); - TtkRedisplayWidget(&tv->core); - } + DragColumn(tv, i, newx - right); + /* ASSERT: SLACKINVARIANT */ + TtkRedisplayWidget(&tv->core); return TCL_OK; } left = right; @@ -2921,20 +2905,6 @@ static int TreeviewDragCommand( return TCL_ERROR; } -static int TreeviewDropCommand( - void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) -{ - Treeview *tv = recordPtr; - - if (objc != 2) { - Tcl_WrongNumArgs(interp, 1, objv, "drop"); - return TCL_ERROR; - } - ResizeColumns(tv, TreeWidth(tv)); - TtkRedisplayWidget(&tv->core); - return TCL_OK; -} - /*------------------------------------------------------------------------ * +++ Widget commands -- focus and selection */ @@ -3284,7 +3254,6 @@ static const Ttk_Ensemble TreeviewCommands[] = { { "delete", TreeviewDeleteCommand,0 }, { "detach", TreeviewDetachCommand,0 }, { "drag", TreeviewDragCommand,0 }, - { "drop", TreeviewDropCommand,0 }, { "exists", TreeviewExistsCommand,0 }, { "focus", TreeviewFocusCommand,0 }, { "heading", TreeviewHeadingCommand,0 }, diff --git a/library/ttk/treeview.tcl b/library/ttk/treeview.tcl index 0b5d953..6a6f5d4 100644 --- a/library/ttk/treeview.tcl +++ b/library/ttk/treeview.tcl @@ -205,7 +205,7 @@ proc ttk::treeview::resize.drag {w x} { } proc ttk::treeview::resize.release {w x} { - $w drop + # no-op } ### Heading activation. diff --git a/tests/ttk/treeview.test b/tests/ttk/treeview.test index 43a6527..4e92601 100644 --- a/tests/ttk/treeview.test +++ b/tests/ttk/treeview.test @@ -692,92 +692,4 @@ test treeview-368fa4561e "indicators cannot be clicked on leafs" -setup { destroy .tv } -result {0 0 0} -test treeview-ce470f20fd-1 "dragging further than the right edge of the treeview is forbidden" -setup { - pack [ttk::treeview .tv] - .tv heading #0 -text "Drag my right edge -->" - update -} -body { - set res [.tv column #0 -width] - .tv drag #0 400 - lappend res [expr {[.tv column #0 -width] > $res}] -} -cleanup { - destroy .tv -} -result {200 0} - -proc nostretch {tv} { - foreach col [$tv cget -columns] { - $tv column $col -stretch 0 - } - $tv column #0 -stretch 0 - update idletasks ; # redisplay $tv -} - -test treeview-ce470f20fd-2 "changing -stretch resizes columns" -setup { - pack [ttk::treeview .tv -columns {bar colA colB colC foo}] - foreach col [.tv cget -columns] { - .tv heading $col -text $col - } - nostretch .tv - .tv column colA -width 50 ; .tv column colB -width 50 ; # slack created - update idletasks ; # redisplay treeview -} -body { - # when no column is stretchable and one of them becomes stretchable - # the stretchable column takes the slack and the widget is redisplayed - # automatically at idle time - set res [.tv column colA -width] - .tv column colA -stretch 1 - update idletasks ; # no slack anymore, widget redisplayed - lappend res [expr {[.tv column colA -width] > $res}] -} -cleanup { - destroy .tv -} -result {50 1} - -test treeview-ce470f20fd-3 "changing -stretch resizes columns" -setup { - pack [ttk::treeview .tv -columns {bar colA colB colC foo}] - foreach col [.tv cget -columns] { - .tv heading $col -text $col - } - .tv configure -displaycolumns {colB colA colC} - nostretch .tv - .tv column colA -width 50 ; .tv column colB -width 50 ; # slack created - update idletasks ; # redisplay treeview -} -body { - # only some columns are displayed (and in a different order than declared - # in -columns), a displayed column becomes stretchable --> the stretchable - # column expands - set res [.tv column colA -width] - .tv column colA -stretch 1 - update idletasks ; # no slack anymore, widget redisplayed - lappend res [expr {[.tv column colA -width] > $res}] -} -cleanup { - destroy .tv -} -result {50 1} - -test treeview-ce470f20fd-4 "changing -stretch resizes columns" -setup { - pack [ttk::treeview .tv -columns {bar colA colB colC foo}] - foreach col [.tv cget -columns] { - .tv heading $col -text $col - } - .tv configure -displaycolumns {colB colA colC} - nostretch .tv - .tv column colA -width 50 ; .tv column bar -width 60 ; # slack created - update idletasks ; # redisplay treeview -} -body { - # only some columns are displayed (and in a different order than declared - # in -columns), a non-displayed column becomes stretchable --> nothing - # happens - set origTreeWidth [winfo width .tv] - set res [list [.tv column bar -width] [.tv column colA -width]] - .tv column bar -stretch 1 - update idletasks ; # no change, widget redisplayed - lappend res [.tv column bar -width] [.tv column colA -width] - # this column becomes visible --> widget resizes - .tv configure -displaycolumns {bar colC colA colB} - update idletasks ; # no slack anymore because the widget resizes (shrinks) - lappend res [.tv column bar -width] [.tv column colA -width] \ - [expr {[winfo width .tv] < $origTreeWidth}] -} -cleanup { - destroy .tv -} -result {60 50 60 50 60 50 1} - tcltest::cleanupTests -- cgit v0.12 From af18ad2b6212e9d9eac4972e9ae2c1592cc15aa4 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 27 Oct 2019 13:22:04 +0000 Subject: Fix [caacf1f082]: treeview column resizing not possible in some conditions. This problem was created by my fixing of [ce470f20fd] (ttk::treeview allows dragging the right edge of the rightmost heading). While some of the commits aiming at fixing [ce470f20fd] were correct, some other were not and in fact I believe the right edge of the rightmost heading really should be draggable. This is also how tablelist behaves. --- generic/ttk/ttkTreeview.c | 24 ++---------------------- tests/ttk/treeview.test | 4 ++-- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index fcd807c..ccc5e2e 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -2888,28 +2888,8 @@ static int TreeviewDragCommand( TreeColumn *c = tv->tree.displayColumns[i]; int right = left + c->width; if (c == column) { - /* The limit not to exceed at the right is given by the tree width - minus the sum of the min widths of the columns at the right of - the one being resized (and don't forget possible x scrolling!). - For stretchable columns, this min width really is the minWidth, - for non-stretchable columns, this is the column width. - */ - int newxRightLimit = tv->tree.treeArea.x - tv->tree.xscroll.first - + tv->tree.treeArea.width; - int j = i + 1; - while (j < tv->tree.nDisplayColumns) { - TreeColumn *cr = tv->tree.displayColumns[j]; - if (cr->stretch) { - newxRightLimit -= cr->minWidth; - } else { - newxRightLimit -= cr->width; - } - ++j; - } - if (newx <= newxRightLimit) { - DragColumn(tv, i, newx - right); - TtkRedisplayWidget(&tv->core); - } + DragColumn(tv, i, newx - right); + TtkRedisplayWidget(&tv->core); return TCL_OK; } left = right; diff --git a/tests/ttk/treeview.test b/tests/ttk/treeview.test index 43a6527..c9dcf52 100644 --- a/tests/ttk/treeview.test +++ b/tests/ttk/treeview.test @@ -692,7 +692,7 @@ test treeview-368fa4561e "indicators cannot be clicked on leafs" -setup { destroy .tv } -result {0 0 0} -test treeview-ce470f20fd-1 "dragging further than the right edge of the treeview is forbidden" -setup { +test treeview-ce470f20fd-1 "dragging further than the right edge of the treeview is allowed" -setup { pack [ttk::treeview .tv] .tv heading #0 -text "Drag my right edge -->" update @@ -702,7 +702,7 @@ test treeview-ce470f20fd-1 "dragging further than the right edge of the treeview lappend res [expr {[.tv column #0 -width] > $res}] } -cleanup { destroy .tv -} -result {200 0} +} -result {200 1} proc nostretch {tv} { foreach col [$tv cget -columns] { -- cgit v0.12 From 28b4049594f63e14d18c71b1dfc7229c8f04c75c Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 27 Oct 2019 14:23:41 +0000 Subject: Help tests bind-34.1 and bind-34.2 to always pass on Win10. See today's comment posted in ticket [69b48f427e] --- tests/bind.test | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/bind.test b/tests/bind.test index e7b3db3..240a07e 100644 --- a/tests/bind.test +++ b/tests/bind.test @@ -6636,11 +6636,13 @@ test bind-34.1 {-warp works relatively to a window} -setup { update event generate .top -x 20 -y 20 -warp 1 update idletasks ; # DoWarp is an idle callback + after 50 ; # Win specific - wait for SendInput to be executed set pointerPos1 [winfo pointerxy .t] wm geometry .top +600+600 update event generate .top -x 20 -y 20 -warp 1 update idletasks ; # DoWarp is an idle callback + after 50 ; # Win specific - wait for SendInput to be executed set pointerPos2 [winfo pointerxy .t] # from the first warped position to the second one, the mouse # pointer should have moved the same amount as the window moved @@ -6659,9 +6661,11 @@ test bind-34.2 {-warp works relatively to the screen} -setup { # Contrary to bind-34.1, we're directly checking screen coordinates event generate {} -x 20 -y 20 -warp 1 update idletasks ; # DoWarp is an idle callback + after 50 ; # Win specific - wait for SendInput to be executed set res [winfo pointerxy .] event generate {} -x 200 -y 200 -warp 1 update idletasks ; # DoWarp is an idle callback + after 50 ; # Win specific - wait for SendInput to be executed lappend res {*}[winfo pointerxy .] } -cleanup { } -result {20 20 200 200} -- cgit v0.12 From d64da8633706ecf6d9162e794e767f6c5b15acd2 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 27 Oct 2019 14:26:44 +0000 Subject: Cherrypick [e9becf44ab]: Help tests bind-34.1 and bind-34.2 to always pass on Win10. See today's comment posted in ticket [69b48f427e] --- tests/bind.test | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/bind.test b/tests/bind.test index 24bf1d0..557d38e 100644 --- a/tests/bind.test +++ b/tests/bind.test @@ -6608,11 +6608,13 @@ test bind-34.1 {-warp works relatively to a window} -setup { update event generate .top -x 20 -y 20 -warp 1 update idletasks ; # DoWarp is an idle callback + after 50 ; # Win specific - wait for SendInput to be executed set pointerPos1 [winfo pointerxy .t] wm geometry .top +600+600 update event generate .top -x 20 -y 20 -warp 1 update idletasks ; # DoWarp is an idle callback + after 50 ; # Win specific - wait for SendInput to be executed set pointerPos2 [winfo pointerxy .t] # from the first warped position to the second one, the mouse # pointer should have moved the same amount as the window moved @@ -6631,9 +6633,11 @@ test bind-34.2 {-warp works relatively to the screen} -setup { # Contrary to bind-34.1, we're directly checking screen coordinates event generate {} -x 20 -y 20 -warp 1 update idletasks ; # DoWarp is an idle callback + after 50 ; # Win specific - wait for SendInput to be executed set res [winfo pointerxy .] event generate {} -x 200 -y 200 -warp 1 update idletasks ; # DoWarp is an idle callback + after 50 ; # Win specific - wait for SendInput to be executed lappend res {*}[winfo pointerxy .] } -cleanup { } -result {20 20 200 200} -- cgit v0.12 From d95d56ad6573cbc56ab366dab366b18150f0e811 Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 27 Oct 2019 19:21:13 +0000 Subject: For Aqua, fix computation of local.x and local.y in the case of an embedded toplevel. --- macosx/tkMacOSXMouseEvent.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index 56c6431..4af80b6 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -130,7 +130,8 @@ enum { } /* - * Make sure tkwin is the toplevel which should receive the event. + * If we still don't have a window, try using the toplevel that + * manages the NSWindow. */ if (!tkwin) { @@ -138,10 +139,15 @@ enum { tkwin = (Tk_Window) winPtr; } if (!tkwin) { + + /* + * We can't find a window for this event. We have to ignore it. + */ + #ifdef TK_MAC_DEBUG_EVENTS TkMacOSXDbgMsg("tkwin == NULL"); #endif - return theEvent; /* Give up. No window for this event. */ + return theEvent; } /* @@ -174,8 +180,20 @@ enum { * coordinates. */ - local.x -= winPtr->wmInfoPtr->xInParent; - local.y -= winPtr->wmInfoPtr->yInParent; + if (Tk_IsEmbedded(winPtr)) { + TkWindow *contPtr = TkpGetOtherWindow(winPtr); + if (Tk_IsTopLevel(contPtr)) { + local.x -= contPtr->wmInfoPtr->xInParent; + local.y -= contPtr->wmInfoPtr->yInParent; + } else { + TkWindow *topPtr = TkMacOSXGetHostToplevel(winPtr)->winPtr; + local.x -= (topPtr->wmInfoPtr->xInParent + contPtr->changes.x); + local.y -= (topPtr->wmInfoPtr->yInParent + contPtr->changes.y); + } + } else { + local.x -= winPtr->wmInfoPtr->xInParent; + local.y -= winPtr->wmInfoPtr->yInParent; + } /* * Find the containing Tk window, and convert local into the coordinates -- cgit v0.12 From b2dd0a10365c974b7d3f0601c83bb1d4ee6faa66 Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 27 Oct 2019 19:30:22 +0000 Subject: Edit a comment --- macosx/tkMacOSXMouseEvent.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index 4af80b6..0ad8492 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -196,9 +196,9 @@ enum { } /* - * Find the containing Tk window, and convert local into the coordinates - * of the Tk window. (The converted local coordinates are only needed - * for scrollwheel events.) + * Use the toplevel coordinates to find the containing Tk window. Then + * convert local into the coordinates of that window. (The converted + * local coordinates are only needed for scrollwheel events.) */ int win_x, win_y; -- cgit v0.12 From 994168db27369739039f976a737abd04145de0a4 Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 27 Oct 2019 20:35:50 +0000 Subject: Add a regression test for computing local mouse coordinates in embedded windows in Aqua. --- tests/unixEmbed.test | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/tests/unixEmbed.test b/tests/unixEmbed.test index d46818a..2ebf9c2 100644 --- a/tests/unixEmbed.test +++ b/tests/unixEmbed.test @@ -85,6 +85,8 @@ proc colorsFree {w {red 31} {green 245} {blue 192}} { && ([lindex $vals 2]/256 == $blue) } +testConstraint pressbutton [llength [info commands pressbutton]] + test unixEmbed-1.1 {TkpUseWindow procedure, bad window identifier} -constraints { unix } -setup { @@ -1276,9 +1278,41 @@ test unixEmbed-11.1 {focus -force works for embedded toplevels} -constraints { focus -force .t focus -force .embed focus - } -cleanup { - deleteWindows +} -cleanup { + deleteWindows } -result .embed +test unixEmbed-11.2 {mouse coordinates in embedded toplevels} -constraints { + unix pressbutton +} -setup { + deleteWindows +} -body { + toplevel .main + set result {} + pack [button .main.b -text "Main Button" \ + -command {lappend result ".main.b"}] -padx 30 -pady 30 + pack [frame .main.f -container 1 -width 200 -height 200] -fill both + update idletasks + toplevel .embed -use [winfo id .main.f] -bg green + pack [button .embed.b -text "Emb Button" \ + -command {lappend result ".embed.b"}] -padx 30 -pady 30 + wm geometry .main 200x400+100+100 + update idletasks + focus -force .main + set x [expr {[winfo x .main ] + [winfo x .main.b] + 40}] + set y [expr {[winfo y .main ] + [winfo y .main.b] + 38}] + lappend result [winfo containing $x $y] + after 200 + pressbutton $x $y + update + set y [expr {$y + 80}] + lappend result [winfo containing $x $y] + after 200 + pressbutton $x $y + update + set result +} -cleanup { + deleteWindows +} -result {.main.b .main.b .embed.b .embed.b} # cleanup -- cgit v0.12 From e9a1e3c613316cca80d5f527791041e62f53a9ca Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 27 Oct 2019 21:12:48 +0000 Subject: Fix 'Column ... out of range' error reported in [caacf1f082] --- library/ttk/treeview.tcl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/ttk/treeview.tcl b/library/ttk/treeview.tcl index 0b5d953..4158739 100644 --- a/library/ttk/treeview.tcl +++ b/library/ttk/treeview.tcl @@ -120,7 +120,8 @@ proc ttk::treeview::ActivateHeading {w heading} { variable State if {$w != $State(activeWidget) || $heading != $State(activeHeading)} { - if {[winfo exists $State(activeWidget)] && $State(activeHeading) != {}} { + if {[winfo exists $State(activeWidget)] && $State(activeHeading) != {} + && $State(activeHeading) in [$State(activeWidget) cget -displaycolumns]} { $State(activeWidget) heading $State(activeHeading) state !active } if {$heading != {}} { -- cgit v0.12 From 6af97014d232e4b9ae065090afaa2a2201662c5f Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 28 Oct 2019 03:25:09 +0000 Subject: Apply patch from Kevin Walzer to restore functionality of Cut/Copy/Paste keyboard shortcuts on Aqua. --- macosx/tkMacOSXKeyEvent.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index c689f6d..7ce8fc8 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -208,22 +208,6 @@ static unsigned isFunctionKey(unsigned int code); xEvent.xany.type = KeyPress; } - /* - * For the command key, take the input manager's word so things - * like dvorak / qwerty layout work. - */ - - if ((modifiers & NSCommandKeyMask) == NSCommandKeyMask - && (modifiers & NSAlternateKeyMask) != NSAlternateKeyMask - && len > 0 && !isFunctionKey(code)) { - - /* - * Prevent keycode-based translation in tkMacOSXKeyboard.c - */ - - xEvent.xkey.nbytes = [characters length]; - } - if ([characters length] > 0) { xEvent.xkey.keycode = (keyCode << 16) | (UInt16) [characters characterAtIndex:0]; @@ -492,6 +476,7 @@ static unsigned isFunctionKey(unsigned int code); * Called by the system to get a position for popup character selection windows * such as a Character Palette, or a selection menu for IME. */ + - (NSRect)firstRectForCharacterRange: (NSRange)theRange actualRange: (NSRangePointer)thePointer { @@ -510,7 +495,6 @@ static unsigned isFunctionKey(unsigned int code); return rect; } - - (NSInteger)conversationIdentifier { return (NSInteger) self; @@ -606,6 +590,7 @@ static unsigned isFunctionKey(unsigned int code); /* * Set up basic fields in xevent for keyboard input. */ + static void setupXEvent(XEvent *xEvent, NSWindow *w, unsigned int state) { -- cgit v0.12 From b6d2f8f64850a21a5f9baf4dea1628cf59f75ec8 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 28 Oct 2019 09:04:36 +0000 Subject: Sync tcl.m4 with Tcl version (also change README accordingly). Re-generate configure script for UNIX --- macosx/README | 6 +++--- unix/configure | 1 - unix/tcl.m4 | 2 -- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/macosx/README b/macosx/README index 1decd54..c21d445 100644 --- a/macosx/README +++ b/macosx/README @@ -49,8 +49,8 @@ brings up the Tk console window at startup. This is the case when double clicking Wish in the Finder (or using 'open Wish.app' from the Terminal). - Tcl extensions can be installed in any of: - $HOME/Library/Tcl /Library/Tcl /System/Library/Tcl - $HOME/Library/Frameworks /Library/Frameworks /System/Library/Frameworks + $HOME/Library/Tcl /Library/Tcl + $HOME/Library/Frameworks /Library/Frameworks (searched in that order). Given a potential package directory $pkg, Tcl on OSX checks for the file $pkg/Resources/Scripts/pkgIndex.tcl as well as the usual $pkg/pkgIndex.tcl. @@ -65,7 +65,7 @@ No nroff manpages are installed by default by the GNUmakefile. - The Tcl and Tk frameworks can be installed in any of the system's standard framework directories: - $HOME/Library/Frameworks /Library/Frameworks /System/Library/Frameworks + $HOME/Library/Frameworks /Library/Frameworks - ${prefix}/bin/wish8.x is a script that calls a copy of 'Wish' contained in Tk.framework/Resources diff --git a/unix/configure b/unix/configure index bb18ea9..e906c58 100755 --- a/unix/configure +++ b/unix/configure @@ -1415,7 +1415,6 @@ echo "$as_me: error: ${with_tclconfig} directory doesn't contain tclConfig.sh" > for i in `ls -d ~/Library/Frameworks 2>/dev/null` \ `ls -d /Library/Frameworks 2>/dev/null` \ `ls -d /Network/Library/Frameworks 2>/dev/null` \ - `ls -d /System/Library/Frameworks 2>/dev/null` \ ; do if test -f "$i/Tcl.framework/tclConfig.sh" ; then ac_cv_c_tclconfig="`(cd $i/Tcl.framework; pwd)`" diff --git a/unix/tcl.m4 b/unix/tcl.m4 index f451d0e..3150973 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -77,7 +77,6 @@ AC_DEFUN([SC_PATH_TCLCONFIG], [ for i in `ls -d ~/Library/Frameworks 2>/dev/null` \ `ls -d /Library/Frameworks 2>/dev/null` \ `ls -d /Network/Library/Frameworks 2>/dev/null` \ - `ls -d /System/Library/Frameworks 2>/dev/null` \ ; do if test -f "$i/Tcl.framework/tclConfig.sh" ; then ac_cv_c_tclconfig="`(cd $i/Tcl.framework; pwd)`" @@ -210,7 +209,6 @@ AC_DEFUN([SC_PATH_TKCONFIG], [ for i in `ls -d ~/Library/Frameworks 2>/dev/null` \ `ls -d /Library/Frameworks 2>/dev/null` \ `ls -d /Network/Library/Frameworks 2>/dev/null` \ - `ls -d /System/Library/Frameworks 2>/dev/null` \ ; do if test -f "$i/Tk.framework/tkConfig.sh" ; then ac_cv_c_tkconfig="`(cd $i/Tk.framework; pwd)`" -- cgit v0.12 From 946660a5304fa11d00983930250de71b71771a59 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 30 Oct 2019 14:31:28 +0000 Subject: Alternative fix to [de579935a9] - just allow weird looking thumbs. --- macosx/tkMacOSXScrlbr.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index a189646..ce7ac58 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -214,12 +214,20 @@ static void drawMacScrollbar( CGContextStrokeLineSegments(context, outer, 2); /* - * Do not display the thumb unless scrolling is possible. + * Do not display the thumb unless scrolling is possible, in accordance + * with macOS behavior. + * + * Native scrollbars and Ttk scrollbars are always 15 pixels wide, but we + * allow Tk scrollbars to have any width, even if it looks bad. To prevent + * sporadic assertion errors when drawing skinny thumbs we must make sure + * the radius is at most half the width. */ if (scrollPtr->firstFraction > 0.0 || scrollPtr->lastFraction < 1.0) { CGRect thumbBounds = {thumbOrigin, thumbSize}; - path = CGPathCreateWithRoundedRect(thumbBounds, 4, 4, NULL); + int width = scrollPtr->vertical ? thumbSize.width : thumbSize.height; + int radius = width >= 8 ? 4 : width >> 1; + path = CGPathCreateWithRoundedRect(thumbBounds, radius, radius, NULL); CGContextBeginPath(context); CGContextAddPath(context, path); if (msPtr->info.trackInfo.scrollbar.pressState != 0) { -- cgit v0.12 From 9f79252321f5466fa985cae48515e2b21c883bbf Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 30 Oct 2019 15:30:20 +0000 Subject: Fix [8793e78bf0]: High CPU usage due to unnecessary redraws of the entire window. --- macosx/tkMacOSXDraw.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 314ca35..5714bf4 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1632,16 +1632,27 @@ TkMacOSXSetupDrawingContext( * a view's drawRect or setFrame methods. The isDrawing attribute * tells us whether we are being called from one of those methods. * - * If the CGContext is not valid, or belongs to a different View, then - * we mark our view as needing display and return failure. It should - * get drawn in a later call to drawRect. + * If the CGContext is not valid then we mark our view as needing + * display in the bounding rectangle of the clipping region and + * return failure. That rectangle should get drawn in a later call + * to drawRect. */ - - if (view != [NSView focusView]) { - [view setNeedsDisplay:YES]; + + if (![NSApp isDrawing] || view != [NSView focusView]) { + NSRect bounds = [view bounds]; + NSRect dirtyNS = bounds; + CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0, + .ty = dirtyNS.size.height}; + if (dc.clipRgn) { + CGRect dirtyCG = NSRectToCGRect(dirtyNS); + HIShapeGetBounds(dc.clipRgn, &dirtyCG); + dirtyNS = NSRectToCGRect(CGRectApplyAffineTransform(dirtyCG, t)); + } + [view setNeedsDisplayInRect:dirtyNS]; canDraw = false; goto end; } + dc.view = view; dc.context = GET_CGCONTEXT; dc.portBounds = NSRectToCGRect([view bounds]); -- cgit v0.12 From d9676d4c9d5c419d507bcc44981758a405ee3aa1 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 31 Oct 2019 08:51:58 +0000 Subject: Add test for in configure script. Not used by Tk yet. --- library/ttk/aquaTheme.tcl | 2 +- tests/ttk/treeview.test | 4 ++-- unix/configure | 9 +++++++++ unix/tcl.m4 | 4 +++- win/configure | 9 +++++++++ win/makefile.vc | 2 +- win/tcl.m4 | 2 ++ 7 files changed, 27 insertions(+), 5 deletions(-) diff --git a/library/ttk/aquaTheme.tcl b/library/ttk/aquaTheme.tcl index 4871a07..8bba226 100644 --- a/library/ttk/aquaTheme.tcl +++ b/library/ttk/aquaTheme.tcl @@ -49,7 +49,7 @@ namespace eval ttk::theme::aqua { -selectbackground { background systemTextBackgroundColor } - + # Workaround for #1100117: # Actually, on Aqua we probably shouldn't stipple images in diff --git a/tests/ttk/treeview.test b/tests/ttk/treeview.test index 1b0f998..65ae55e 100644 --- a/tests/ttk/treeview.test +++ b/tests/ttk/treeview.test @@ -694,7 +694,7 @@ test treeview-368fa4561e "indicators cannot be clicked on leafs" -setup { test treeview-ce470f20fd-1 "dragging further than the right edge of the treeview is allowed" -setup { pack [ttk::treeview .tv] - .tv heading #0 -text "Drag my right edge -->" + .tv heading #0 -text "Drag my right edge -->" update } -body { set res [.tv column #0 -width] @@ -764,7 +764,7 @@ test treeview-ce470f20fd-4 "changing -stretch resizes columns" -setup { update idletasks ; # redisplay treeview } -body { # only some columns are displayed (and in a different order than declared - # in -columns), a non-displayed column becomes stretchable --> nothing + # in -columns), a non-displayed column becomes stretchable --> nothing # happens set origTreeWidth [winfo width .tv] set res [list [.tv column bar -width] [.tv column colA -width]] diff --git a/unix/configure b/unix/configure index 487eeba..2454341 100755 --- a/unix/configure +++ b/unix/configure @@ -5881,6 +5881,15 @@ $as_echo "#define HAVE_CAST_TO_UNION 1" >>confdefs.h fi + ac_fn_c_check_header_mongrel "$LINENO" "stdbool.h" "ac_cv_header_stdbool_h" "$ac_includes_default" +if test "x$ac_cv_header_stdbool_h" = xyes; then : + +$as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h + +fi + + + # FIXME: This subst was left in only because the TCL_DL_LIBS # entry in tclConfig.sh uses it. It is not clear why someone # would use TCL_DL_LIBS instead of TCL_LIBS. diff --git a/unix/tcl.m4 b/unix/tcl.m4 index 30d8de6..8753d4d 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -1868,6 +1868,8 @@ dnl # preprocessing tests use only CPPFLAGS. [Defined when compiler supports casting to union type.]) fi + AC_CHECK_HEADER(stdbool.h, [AC_DEFINE(HAVE_STDBOOL_H, 1, [Do we have ?])],) + # FIXME: This subst was left in only because the TCL_DL_LIBS # entry in tclConfig.sh uses it. It is not clear why someone # would use TCL_DL_LIBS instead of TCL_LIBS. @@ -1928,7 +1930,7 @@ dnl # preprocessing tests use only CPPFLAGS. # NO_SYS_WAIT_H # NO_DLFCN_H # HAVE_SYS_PARAM_H -# +# HAVE_STDBOOL_H # HAVE_STRING_H ? # #-------------------------------------------------------------------- diff --git a/win/configure b/win/configure index 7e63a81..3bb8570 100755 --- a/win/configure +++ b/win/configure @@ -4664,6 +4664,15 @@ $as_echo "#define HAVE_WINNT_IGNORE_VOID 1" >>confdefs.h fi + ac_fn_c_check_header_mongrel "$LINENO" "stdbool.h" "ac_cv_header_stdbool_h" "$ac_includes_default" +if test "x$ac_cv_header_stdbool_h" = xyes; then : + +$as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h + +fi + + + # See if the compiler supports casting to a union type. # This is used to stop gcc from printing a compiler # warning when initializing a union member. diff --git a/win/makefile.vc b/win/makefile.vc index 99aa6c1..311be18 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -316,7 +316,7 @@ PRJ_INCLUDES = -I"$(BITMAPDIR)" -I"$(XLIBDIR)" CONFIG_DEFS =/DSTDC_HEADERS=1 /DHAVE_SYS_TYPES_H=1 /DHAVE_SYS_STAT_H=1 \ /DHAVE_STRING_H=1 /DHAVE_MEMORY_H=1 \ - /DHAVE_STRINGS_H=1 /DHAVE_INTTYPES_H=1 /DHAVE_STDINT_H=1 \ + /DHAVE_STRINGS_H=1 /DHAVE_INTTYPES_H=1 \ /DSUPPORT_CONFIG_EMBEDDED /DUNICODE /D_UNICODE \ !if $(HAVE_UXTHEME_H) /DHAVE_UXTHEME_H=1 \ diff --git a/win/tcl.m4 b/win/tcl.m4 index c0dd539..d3d94ef 100644 --- a/win/tcl.m4 +++ b/win/tcl.m4 @@ -948,6 +948,8 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ [Defined when cygwin/mingw ignores VOID define in winnt.h]) fi + AC_CHECK_HEADER(stdbool.h, [AC_DEFINE(HAVE_STDBOOL_H, 1, [Do we have ?])],) + # See if the compiler supports casting to a union type. # This is used to stop gcc from printing a compiler # warning when initializing a union member. -- cgit v0.12 From 879c2a77024c6f7599ee7b438d236d2828cf5dc2 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 31 Oct 2019 09:49:31 +0000 Subject: Fix [056f9e85dc]: debian patches Don't define HAVE_STDINT_H in win/makefile.vc: Most (older) Visual Studio versions still don't have stdint.h, and it isn't used by Tk. --- unix/configure | 10 +++++++--- unix/configure.in | 6 +++--- unix/installManPage | 10 +++++++++- unix/tcl.m4 | 5 +++++ win/makefile.vc | 2 +- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/unix/configure b/unix/configure index 15e5a56..acac5f6 100755 --- a/unix/configure +++ b/unix/configure @@ -1432,6 +1432,7 @@ echo "$as_me: error: ${with_tclconfig} directory doesn't contain tclConfig.sh" > `ls -d /usr/local/lib 2>/dev/null` \ `ls -d /usr/contrib/lib 2>/dev/null` \ `ls -d /usr/pkg/lib 2>/dev/null` \ + `ls -d /usr/lib/tcl8.5 2>/dev/null` \ `ls -d /usr/lib 2>/dev/null` \ `ls -d /usr/lib64 2>/dev/null` \ `ls -d /usr/local/lib/tcl8.5 2>/dev/null` \ @@ -4746,6 +4747,9 @@ echo "$as_me: WARNING: can't find uname command" >&2;} if test "`uname -s`" = "AIX" ; then tcl_cv_sys_version=AIX-`uname -v`.`uname -r` fi + if test "`uname -s`" = "NetBSD" -a -f /etc/debian_version ; then + tcl_cv_sys_version=NetBSD-Debian + fi fi fi @@ -10627,8 +10631,8 @@ echo "${ECHO_T}$enable_xft" >&6 XFT_LIBS=`xft-config --libs 2>/dev/null` || found_xft="no" if test "$found_xft" = "no" ; then found_xft=yes - XFT_CFLAGS=`pkg-config --cflags xft 2>/dev/null` || found_xft="no" - XFT_LIBS=`pkg-config --libs xft 2>/dev/null` || found_xft="no" + XFT_CFLAGS=`pkg-config --cflags xft fontconfig 2>/dev/null` || found_xft="no" + XFT_LIBS=`pkg-config --libs xft fontconfig 2>/dev/null` || found_xft="no" fi echo "$as_me:$LINENO: result: $found_xft" >&5 echo "${ECHO_T}$found_xft" >&6 @@ -11479,7 +11483,7 @@ if test "${SHARED_BUILD}" = "1" -a "${SHLIB_SUFFIX}" != ""; then TCL_STUB_FLAGS="-DUSE_TCL_STUBS" fi -TK_LIBRARY='$(prefix)/lib/tk$(VERSION)' +test -z "$TK_LIBRARY" && TK_LIBRARY='$(prefix)/lib/tk$(VERSION)' PRIVATE_INCLUDE_DIR='$(includedir)' HTML_DIR='$(DISTDIR)/html' TK_PKG_DIR='tk$(VERSION)' diff --git a/unix/configure.in b/unix/configure.in index d4a8c28..4b1f992 100644 --- a/unix/configure.in +++ b/unix/configure.in @@ -481,8 +481,8 @@ if test $tk_aqua = no; then XFT_LIBS=`xft-config --libs 2>/dev/null` || found_xft="no" if test "$found_xft" = "no" ; then found_xft=yes - XFT_CFLAGS=`pkg-config --cflags xft 2>/dev/null` || found_xft="no" - XFT_LIBS=`pkg-config --libs xft 2>/dev/null` || found_xft="no" + XFT_CFLAGS=`pkg-config --cflags xft fontconfig 2>/dev/null` || found_xft="no" + XFT_LIBS=`pkg-config --libs xft fontconfig 2>/dev/null` || found_xft="no" fi AC_MSG_RESULT([$found_xft]) dnl make sure that compiling against Xft header file doesn't bomb @@ -653,7 +653,7 @@ if test "${SHARED_BUILD}" = "1" -a "${SHLIB_SUFFIX}" != ""; then TCL_STUB_FLAGS="-DUSE_TCL_STUBS" fi -TK_LIBRARY='$(prefix)/lib/tk$(VERSION)' +test -z "$TK_LIBRARY" && TK_LIBRARY='$(prefix)/lib/tk$(VERSION)' PRIVATE_INCLUDE_DIR='$(includedir)' HTML_DIR='$(DISTDIR)/html' TK_PKG_DIR='tk$(VERSION)' diff --git a/unix/installManPage b/unix/installManPage index 6bdccf0..2293a20 100755 --- a/unix/installManPage +++ b/unix/installManPage @@ -91,12 +91,20 @@ case $ManPage in exit 2 ;; esac +Name=`basename $ManPage .$Section` SrcDir=`dirname $ManPage` ######################################################################## ### Process Page to Create Target Pages ### +Specials="FindPhoto FontId MeasureChar" +for n in $Specials; do + if [ "$Name" = "$n" ] ; then + Names="$n $Names" + fi +done + First="" for Target in $Names; do Target=$Target.$Section$Suffix @@ -105,7 +113,7 @@ for Target in $Names; do First=$Target sed -e "/man\.macros/r $SrcDir/man.macros" -e "/man\.macros/d" \ $ManPage > $Dir/$First - chmod 444 $Dir/$First + chmod 644 $Dir/$First $Gzip $Dir/$First else ln $SymOrLoc$First$Gz $Dir/$Target$Gz diff --git a/unix/tcl.m4 b/unix/tcl.m4 index 0c15ac0..95915e8 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -94,6 +94,7 @@ AC_DEFUN([SC_PATH_TCLCONFIG], [ `ls -d /usr/local/lib 2>/dev/null` \ `ls -d /usr/contrib/lib 2>/dev/null` \ `ls -d /usr/pkg/lib 2>/dev/null` \ + `ls -d /usr/lib/tcl8.5 2>/dev/null` \ `ls -d /usr/lib 2>/dev/null` \ `ls -d /usr/lib64 2>/dev/null` \ `ls -d /usr/local/lib/tcl8.5 2>/dev/null` \ @@ -227,6 +228,7 @@ AC_DEFUN([SC_PATH_TKCONFIG], [ `ls -d /usr/local/lib 2>/dev/null` \ `ls -d /usr/contrib/lib 2>/dev/null` \ `ls -d /usr/pkg/lib 2>/dev/null` \ + `ls -d /usr/lib/tk8.5 2>/dev/null` \ `ls -d /usr/lib 2>/dev/null` \ `ls -d /usr/lib64 2>/dev/null` \ `ls -d /usr/local/lib/tk8.5 2>/dev/null` \ @@ -965,6 +967,9 @@ AC_DEFUN([SC_CONFIG_SYSTEM], [ if test "`uname -s`" = "AIX" ; then tcl_cv_sys_version=AIX-`uname -v`.`uname -r` fi + if test "`uname -s`" = "NetBSD" -a -f /etc/debian_version ; then + tcl_cv_sys_version=NetBSD-Debian + fi fi fi ]) diff --git a/win/makefile.vc b/win/makefile.vc index bec8607..3d47f55 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -419,7 +419,7 @@ TK_INCLUDES = -I"$(WIN_DIR)" -I"$(GENERICDIR)" -I"$(BITMAPDIR)" -I"$(XLIBDIR)" \ CONFIG_DEFS =-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 \ -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 \ - -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 \ + -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 \ -DSUPPORT_CONFIG_EMBEDDED \ !if $(HAVE_UXTHEME_H) -DHAVE_UXTHEME_H=1 \ -- cgit v0.12 From c1921c6eef90ee6e058c465fa2a61c2b9439454e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 31 Oct 2019 10:07:01 +0000 Subject: 8.5 -> 8.6 --- unix/configure | 2 +- unix/tcl.m4 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/unix/configure b/unix/configure index 6bcf65c..a6d053f 100755 --- a/unix/configure +++ b/unix/configure @@ -1431,7 +1431,7 @@ echo "$as_me: error: ${with_tclconfig} directory doesn't contain tclConfig.sh" > `ls -d /usr/local/lib 2>/dev/null` \ `ls -d /usr/contrib/lib 2>/dev/null` \ `ls -d /usr/pkg/lib 2>/dev/null` \ - `ls -d /usr/lib/tcl8.5 2>/dev/null` \ + `ls -d /usr/lib/tcl8.6 2>/dev/null` \ `ls -d /usr/lib 2>/dev/null` \ `ls -d /usr/lib64 2>/dev/null` \ `ls -d /usr/local/lib/tcl8.6 2>/dev/null` \ diff --git a/unix/tcl.m4 b/unix/tcl.m4 index 28f3887..0e146e4 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -93,7 +93,7 @@ AC_DEFUN([SC_PATH_TCLCONFIG], [ `ls -d /usr/local/lib 2>/dev/null` \ `ls -d /usr/contrib/lib 2>/dev/null` \ `ls -d /usr/pkg/lib 2>/dev/null` \ - `ls -d /usr/lib/tcl8.5 2>/dev/null` \ + `ls -d /usr/lib/tcl8.6 2>/dev/null` \ `ls -d /usr/lib 2>/dev/null` \ `ls -d /usr/lib64 2>/dev/null` \ `ls -d /usr/local/lib/tcl8.6 2>/dev/null` \ @@ -226,7 +226,7 @@ AC_DEFUN([SC_PATH_TKCONFIG], [ `ls -d /usr/local/lib 2>/dev/null` \ `ls -d /usr/contrib/lib 2>/dev/null` \ `ls -d /usr/pkg/lib 2>/dev/null` \ - `ls -d /usr/lib/tk8.5 2>/dev/null` \ + `ls -d /usr/lib/tk8.6 2>/dev/null` \ `ls -d /usr/lib 2>/dev/null` \ `ls -d /usr/lib64 2>/dev/null` \ `ls -d /usr/local/lib/tk8.6 2>/dev/null` \ -- cgit v0.12 From ebd274ca0936d0950eeda871695f3da8aab41a78 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 1 Nov 2019 09:58:24 +0000 Subject: Better fix for [b82bd4872b]: ttk::style configure -compound does not work --- generic/ttk/ttkButton.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/ttk/ttkButton.c b/generic/ttk/ttkButton.c index 72e9815..1be7ee6 100644 --- a/generic/ttk/ttkButton.c +++ b/generic/ttk/ttkButton.c @@ -81,8 +81,8 @@ static Tk_OptionSpec BaseOptionSpecs[] = * Compound base/image options */ {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", - "none", Tk_Offset(Base,base.compoundObj), -1, - TK_OPTION_DONT_SET_DEFAULT,(ClientData)ttkCompoundStrings, + NULL, Tk_Offset(Base,base.compoundObj), -1, + TK_OPTION_NULL_OK,(ClientData)ttkCompoundStrings, GEOMETRY_CHANGED }, {TK_OPTION_STRING, "-padding", "padding", "Pad", NULL, Tk_Offset(Base,base.paddingObj), -1, -- cgit v0.12 From c5948f27b9d3486c54b9b4e95255251b9f477fb5 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 1 Nov 2019 10:19:36 +0000 Subject: Document that ttk::label and ttk::*button now support styling -compound --- doc/ttk_button.n | 2 ++ doc/ttk_checkbutton.n | 2 ++ doc/ttk_label.n | 2 ++ doc/ttk_menubutton.n | 2 ++ doc/ttk_radiobutton.n | 2 ++ 5 files changed, 10 insertions(+) diff --git a/doc/ttk_button.n b/doc/ttk_button.n index cf47a1a..cf42e28 100644 --- a/doc/ttk_button.n +++ b/doc/ttk_button.n @@ -72,6 +72,8 @@ are: .br \fB\-bordercolor\fP \fIcolor\fP .br +\fB\-compound\fP \fIcompound\fP +.br \fB\-darkcolor\fP \fIcolor\fP .br \fB\-foreground\fP \fIcolor\fP diff --git a/doc/ttk_checkbutton.n b/doc/ttk_checkbutton.n index a18a886..c78dc0e 100644 --- a/doc/ttk_checkbutton.n +++ b/doc/ttk_checkbutton.n @@ -80,6 +80,8 @@ are: .PP \fB\-background\fP \fIcolor\fP .br +\fB\-compound\fP \fIcompound\fP +.br \fB\-foreground\fP \fIcolor\fP .br \fB\-indicatorbackground\fP \fIcolor\fP diff --git a/doc/ttk_label.n b/doc/ttk_label.n index 1e30592..871fab7 100644 --- a/doc/ttk_label.n +++ b/doc/ttk_label.n @@ -71,6 +71,8 @@ are: .PP \fB\-background\fP \fIcolor\fP .br +\fB\-compound\fP \fIcompound\fP +.br \fB\-foreground\fP \fIcolor\fP .br \fB\-font\fP \fIfont\fP diff --git a/doc/ttk_menubutton.n b/doc/ttk_menubutton.n index 76d3829..0d80c1e 100644 --- a/doc/ttk_menubutton.n +++ b/doc/ttk_menubutton.n @@ -58,6 +58,8 @@ are: .br \fB\-background\fP \fIcolor\fP .br +\fB\-compound\fP \fIcompound\fP +.br \fB\-foreground\fP \fIcolor\fP .br \fB\-font\fP \fIfont\fP diff --git a/doc/ttk_radiobutton.n b/doc/ttk_radiobutton.n index 1344ae2..2dc84be 100644 --- a/doc/ttk_radiobutton.n +++ b/doc/ttk_radiobutton.n @@ -77,6 +77,8 @@ are: .PP \fB\-background\fP \fIcolor\fP .br +\fB\-compound\fP \fIcompound\fP +.br \fB\-foreground\fP \fIcolor\fP .br \fB\-indicatorbackground\fP \fIcolor\fP -- cgit v0.12 From 993fec89923aed373f173dbeecc3d8e41d5778fe Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 1 Nov 2019 10:23:45 +0000 Subject: Propagate the previous two commits to the tabs of a ttk::notebook, which can now style -compound --- doc/ttk_notebook.n | 2 ++ generic/ttk/ttkNotebook.c | 4 ++-- tests/ttk/notebook.test | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/ttk_notebook.n b/doc/ttk_notebook.n index 19416b5..ae32a44 100644 --- a/doc/ttk_notebook.n +++ b/doc/ttk_notebook.n @@ -242,6 +242,8 @@ are: .br \fB\-bordercolor\fP \fIcolor\fP .br +\fB\-compound\fP \fIcompound\fP +.br \fB\-expand\fP \fIpadding\fP .RS Defines how much the tab grows in size. Usually used with the diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index 56439a6..39ed6aa 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -69,8 +69,8 @@ static Tk_OptionSpec TabOptionSpecs[] = {TK_OPTION_STRING, "-image", "image", "Image", NULL/*default*/, Tk_Offset(Tab,imageObj), -1, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", - "none", Tk_Offset(Tab,compoundObj), -1, - 0,(ClientData)ttkCompoundStrings,GEOMETRY_CHANGED }, + NULL, Tk_Offset(Tab,compoundObj), -1, + TK_OPTION_NULL_OK,(ClientData)ttkCompoundStrings,GEOMETRY_CHANGED }, {TK_OPTION_INT, "-underline", "underline", "Underline", "-1", Tk_Offset(Tab,underlineObj), -1, 0,0,GEOMETRY_CHANGED }, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0 } diff --git a/tests/ttk/notebook.test b/tests/ttk/notebook.test index 3a2a6ff..ac63088 100644 --- a/tests/ttk/notebook.test +++ b/tests/ttk/notebook.test @@ -69,7 +69,7 @@ test notebook-2.5 "tab - get all options" -body { .nb tab .nb.foo } -result [list \ -padding 0 -sticky nsew \ - -state normal -text "Changed Foo" -image "" -compound none -underline -1] + -state normal -text "Changed Foo" -image "" -compound {} -underline -1] test notebook-4.1 "Test .nb index end" -body { .nb index end -- cgit v0.12 From d6a967c9d8c6cc6dc8d5792070e2c2349f6ce3d8 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 1 Nov 2019 11:03:25 +0000 Subject: Somewhat more progress on [a179564826]: Tk 8.6: prevent issues when encountering non-BMP Unicode characters. Increase XMaxTransChars from 4 to 7, at the same time reducing the nbytes field from int to unsigned char. This makes more room to NULL-terminate the trans_chars array in the XEvent, even when it's 4 bytes in length. (fully binary compatible, since the nbytes field is not supposed to be accessed externally) --- macosx/tkMacOSXKeyEvent.c | 6 ++---- macosx/tkMacOSXKeyboard.c | 2 +- unix/tkUnixFont.c | 2 +- unix/tkUnixKey.c | 2 +- win/tkWinFont.c | 2 +- win/tkWinKey.c | 2 +- xlib/X11/Xlib.h | 6 +++--- 7 files changed, 10 insertions(+), 12 deletions(-) diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index 7ce8fc8..677f77e 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -603,17 +603,15 @@ setupXEvent(XEvent *xEvent, NSWindow *w, unsigned int state) memset(xEvent, 0, sizeof(XEvent)); xEvent->xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); - xEvent->xany.send_event = false; xEvent->xany.display = Tk_Display(tkwin); xEvent->xany.window = Tk_WindowId(tkwin); xEvent->xkey.root = XRootWindow(Tk_Display(tkwin), 0); - xEvent->xkey.subwindow = None; xEvent->xkey.time = TkpGetMS(); xEvent->xkey.state = state; xEvent->xkey.same_screen = true; - xEvent->xkey.trans_chars[0] = 0; - xEvent->xkey.nbytes = 0; + /* No need to initialize other fields implicitly here, + * because of the memset() above. */ } #pragma mark - diff --git a/macosx/tkMacOSXKeyboard.c b/macosx/tkMacOSXKeyboard.c index 78bda9e..b2c78d3 100644 --- a/macosx/tkMacOSXKeyboard.c +++ b/macosx/tkMacOSXKeyboard.c @@ -720,7 +720,7 @@ TkpSetKeycodeAndState( } if (keysym <= LATIN1_MAX) { - int done = Tcl_UniCharToUtf(keysym, eventPtr->xkey.trans_chars); + int done = TkUniCharToUtf(keysym, eventPtr->xkey.trans_chars); eventPtr->xkey.trans_chars[done] = 0; } else { diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index 1e80231..96b6195 100644 --- a/unix/tkUnixFont.c +++ b/unix/tkUnixFont.c @@ -520,7 +520,7 @@ Ucs2beToUtfProc( * UCS-2BE. We know this is an LE->BE swap. */ - dst += Tcl_UniCharToUtf(htons(*((short *)src)), dst); + dst += TkUniCharToUtf(htons(*((short *)src)), dst); src += 2 /* sizeof(UCS-2) */; } diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c index 6d4d0cf..75d5f6c 100644 --- a/unix/tkUnixKey.c +++ b/unix/tkUnixKey.c @@ -208,7 +208,7 @@ TkpGetString( Tcl_DStringValue(&buf)[len] = '\0'; if (len == 1) { - len = Tcl_UniCharToUtf((unsigned char) Tcl_DStringValue(&buf)[0], + len = TkUniCharToUtf((unsigned char) Tcl_DStringValue(&buf)[0], Tcl_DStringValue(dsPtr)); Tcl_DStringSetLength(dsPtr, len); } else { diff --git a/win/tkWinFont.c b/win/tkWinFont.c index 321ecc4..604a667 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -2225,7 +2225,7 @@ FontMapLoadPage( end = (row + 1) << FONTMAP_SHIFT; for (i = row << FONTMAP_SHIFT; i < end; i++) { if (Tcl_UtfToExternal(NULL, encoding, src, - Tcl_UniCharToUtf(i, src), TCL_ENCODING_STOPONERROR, NULL, + TkUniCharToUtf(i, src), TCL_ENCODING_STOPONERROR, NULL, buf, sizeof(buf), NULL, NULL, NULL) != TCL_OK) { continue; } diff --git a/win/tkWinKey.c b/win/tkWinKey.c index 234a158..4130579 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -122,7 +122,7 @@ TkpGetString( if (((keysym != NoSymbol) && (keysym > 0) && (keysym < 256)) || (keysym == XK_Return) || (keysym == XK_Tab)) { - len = Tcl_UniCharToUtf(keysym & 255, buf); + len = TkUniCharToUtf(keysym & 255, buf); Tcl_DStringAppend(dsPtr, buf, len); } } diff --git a/xlib/X11/Xlib.h b/xlib/X11/Xlib.h index 8d8ec68..e8940d9 100644 --- a/xlib/X11/Xlib.h +++ b/xlib/X11/Xlib.h @@ -530,7 +530,7 @@ typedef struct _XDisplay { #endif #ifndef _XEVENT_ -#define XMaxTransChars 4 +#define XMaxTransChars 7 /* * Definitions of specific events. @@ -549,9 +549,9 @@ typedef struct { unsigned int state; /* key or button mask */ unsigned int keycode; /* detail */ Bool same_screen; /* same screen flag */ - char trans_chars[XMaxTransChars]; + char trans_chars[XMaxTransChars]; /* translated characters */ - int nbytes; + unsigned char nbytes; } XKeyEvent; typedef XKeyEvent XKeyPressedEvent; typedef XKeyEvent XKeyReleasedEvent; -- cgit v0.12 From d815697b8593d92960f651b6b69e3ac18561bd00 Mon Sep 17 00:00:00 2001 From: marc_culler Date: Fri, 1 Nov 2019 18:44:14 +0000 Subject: Work around a bug in [NSFont familyName] which Apple introduced in macOS 10.15.1 --- macosx/tkMacOSXFont.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index fb71e85..a0da3a9 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -128,11 +128,24 @@ GetTkFontAttributesForNSFont( { NSFontTraitMask traits = [[NSFontManager sharedFontManager] traitsOfFont:nsFont]; + char *family = [[nsFont familyName] UTF8String]; + + /* + * Workaround for a bug in Catalina 15.1. The familyName method can prefix + * the font name with ".SF " and the font manager will refuse to accept + * that name when searching for the font. As a workaround, if the name + * starts with ".SF " we remove that prefix. + */ - faPtr->family = Tk_GetUid([[nsFont familyName] UTF8String]); + if (strncmp(family, ".SF ", 4) == 0) { + faPtr->family = Tk_GetUid(family + 4); + } else { + faPtr->family = Tk_GetUid([[nsFont familyName] UTF8String]); + } faPtr->size = [nsFont pointSize]; faPtr->weight = (traits & NSBoldFontMask ? TK_FW_BOLD : TK_FW_NORMAL); faPtr->slant = (traits & NSItalicFontMask ? TK_FS_ITALIC : TK_FS_ROMAN); + } /* -- cgit v0.12 From aa42e365e10d36a627c74dd41c016fa92a1e36b6 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 1 Nov 2019 20:54:55 +0000 Subject: The previous commit [65bb96b4] was wrong: it did not take into account the specifics of -displaycolumns or the fact column #0 (the tree) is special. This introduced a regression in the headings activation: they did not de-activate properly when the mouse left the headings. Fix this and document in the code why catching is (much) easier than writing an explicit proc. --- library/ttk/treeview.tcl | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/library/ttk/treeview.tcl b/library/ttk/treeview.tcl index 4158739..df188b7 100644 --- a/library/ttk/treeview.tcl +++ b/library/ttk/treeview.tcl @@ -120,9 +120,18 @@ proc ttk::treeview::ActivateHeading {w heading} { variable State if {$w != $State(activeWidget) || $heading != $State(activeHeading)} { - if {[winfo exists $State(activeWidget)] && $State(activeHeading) != {} - && $State(activeHeading) in [$State(activeWidget) cget -displaycolumns]} { - $State(activeWidget) heading $State(activeHeading) state !active + if {[winfo exists $State(activeWidget)] && $State(activeHeading) != {}} { + # It may happen that $State(activeHeading) no longer corresponds + # to an existing display column. This happens for instance when + # changing -displaycolumns in a bound script when this change + # triggers a event. A proc checking if the display column + # $State(activeHeading) is really still present or not could be + # written but it would need to check several special cases: + # a. -displaycolumns "#all" or being an explicit columns list + # b. column #0 display is not governed by the -displaycolumn + # list but by the value of the -show option + # --> Let's rather catch the following line. + catch {$State(activeWidget) heading $State(activeHeading) state !active} } if {$heading != {}} { $w heading $heading state active -- cgit v0.12 From 26f2d48f04f5a959c2ccb61f0e978c2d96203e6b Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 1 Nov 2019 21:15:07 +0000 Subject: Fix [f002bac209]: 'treeview identify column' returns _display_ columns identifiers whereas the man page tells about data columns identifiers --- doc/ttk_treeview.n | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ttk_treeview.n b/doc/ttk_treeview.n index 125cc78..2deb5b5 100644 --- a/doc/ttk_treeview.n +++ b/doc/ttk_treeview.n @@ -235,7 +235,7 @@ A data cell. Returns the item ID of the item at position \fIy\fR. .TP \fIpathname \fBidentify column \fIx y\fR -Returns the data column identifier of the cell at position \fIx\fR. +Returns the display column identifier of the cell at position \fIx\fR. The tree column has ID \fB#0\fR. .TP \fIpathname \fBidentify element \fIx y\fR -- cgit v0.12 From 09fe4a9aaf45f55440dcd7af939040cc492c8acc Mon Sep 17 00:00:00 2001 From: marc_culler Date: Sun, 3 Nov 2019 23:02:04 +0000 Subject: Use [NSFont userFixedPitchFontOfSize:11] instead of CTFontCreateUIFontForLanguage(fixedPitch, 11, NULL) to get a valid fixed pitch font. --- macosx/tkMacOSXFont.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index a0da3a9..b11794a 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -128,20 +128,7 @@ GetTkFontAttributesForNSFont( { NSFontTraitMask traits = [[NSFontManager sharedFontManager] traitsOfFont:nsFont]; - char *family = [[nsFont familyName] UTF8String]; - - /* - * Workaround for a bug in Catalina 15.1. The familyName method can prefix - * the font name with ".SF " and the font manager will refuse to accept - * that name when searching for the font. As a workaround, if the name - * starts with ".SF " we remove that prefix. - */ - - if (strncmp(family, ".SF ", 4) == 0) { - faPtr->family = Tk_GetUid(family + 4); - } else { - faPtr->family = Tk_GetUid([[nsFont familyName] UTF8String]); - } + faPtr->family = Tk_GetUid([[nsFont familyName] UTF8String]); faPtr->size = [nsFont pointSize]; faPtr->weight = (traits & NSBoldFontMask ? TK_FW_BOLD : TK_FW_NORMAL); faPtr->slant = (traits & NSItalicFontMask ? TK_FS_ITALIC : TK_FS_ROMAN); @@ -407,7 +394,17 @@ TkpFontPkgInit( systemFont++; } TkInitFontAttributes(&fa); +#if 0 + /* + * In macOS 10.15.1 a bug was introduced which caused the call below to + * return a font with the invalid familyName ".SF NS Mono" instead of the + * valid familyName "NS Mono". Calling [NSFont userFixedPitchFontOfSize:11] + * returns a font in the "Menlo" family which has a valid familyName. + */ nsFont = (NSFont*) CTFontCreateUIFontForLanguage(fixedPitch, 11, NULL); +#else + nsFont = [NSFont userFixedPitchFontOfSize:11]; +#endif if (nsFont) { GetTkFontAttributesForNSFont(nsFont, &fa); CFRelease(nsFont); -- cgit v0.12 From d6ff843f2a143394e4c24f8502d9b1fdc17e6ebb Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 4 Nov 2019 16:09:33 +0000 Subject: But we shouldn't call CFRelease on the font returned by [NSFont userFixedPitchFontOfSize:11] --- macosx/tkMacOSXFont.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index 23a3cb8..bc1edff 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -407,7 +407,9 @@ TkpFontPkgInit( #endif if (nsFont) { GetTkFontAttributesForNSFont(nsFont, &fa); +#if 0 CFRelease(nsFont); +#endif } else { fa.family = Tk_GetUid("Monaco"); fa.size = 11; -- cgit v0.12 From 36766607d76fdb1ffc103c4f6e0f0527a7e840bd Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 4 Nov 2019 16:21:40 +0000 Subject: Edit a comment. --- macosx/tkMacOSXFont.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index bc1edff..d6429ed 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -396,9 +396,9 @@ TkpFontPkgInit( TkInitFontAttributes(&fa); #if 0 /* - * In macOS 10.15.1 a bug was introduced which caused the call below to - * return a font with the invalid familyName ".SF NS Mono" instead of the - * valid familyName "NS Mono". Calling [NSFont userFixedPitchFontOfSize:11] + * In macOS 10.15.1 Apple introduced a bug which caused the call below to + * return a font with the invalid familyName ".SF NSMono" instead of the + * valid familyName "NSMono". Calling [NSFont userFixedPitchFontOfSize:11] * returns a font in the "Menlo" family which has a valid familyName. */ nsFont = (NSFont*) CTFontCreateUIFontForLanguage(fixedPitch, 11, NULL); -- cgit v0.12 From 8f788bba9065216a2ff2c7e9c6d5cbdd2b622b51 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 4 Nov 2019 20:42:10 +0000 Subject: Fix a paste error in ttk/entry.tcl that broke the accent menu for ttk::entry widgets. --- library/ttk/entry.tcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/ttk/entry.tcl b/library/ttk/entry.tcl index 0a61ffa..45e3506 100644 --- a/library/ttk/entry.tcl +++ b/library/ttk/entry.tcl @@ -160,8 +160,8 @@ bind TEntry <> { bind TEntry <> { %W delete [dict get $::tk::Priv(IMETextMark) "%W"] [%W index insert] } -bind Entry <> { - tk::EntryBackspace %W +bind TEntry <> { + ttk::entry::Backspace %W } ### Clipboard procedures. -- cgit v0.12 From 5f06b1ef2f60034c966d8b55c20c63b795d18f1c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 6 Nov 2019 16:35:20 +0000 Subject: Fix [edf4fd2613]: iconlist.tcl: errors in mouse wheel bindings. Thanks to nemethi for reporting this bug! --- library/iconlist.tcl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/iconlist.tcl b/library/iconlist.tcl index 521ec37..eed7476 100644 --- a/library/iconlist.tcl +++ b/library/iconlist.tcl @@ -447,10 +447,10 @@ package require Tk 8.6 bind $canvas [namespace code {my ShiftMotion1 %x %y}] if {[tk windowingsystem] eq "aqua"} { - bind $canvas [namespace code {my MouseWheel [expr {40 * (%W)}]}] - bind $canvas [namespace code {my MouseWheel [expr {400 * (%W)}]}] + bind $canvas [namespace code {my MouseWheel [expr {40 * (%D)}]}] + bind $canvas [namespace code {my MouseWheel [expr {400 * (%D)}]}] } else { - bind $canvas [namespace code {my MouseWheel %W}] + bind $canvas [namespace code {my MouseWheel %D}] } if {[tk windowingsystem] eq "x11"} { bind $canvas [namespace code {my MouseWheel 120}] -- cgit v0.12 From f51d73def011d920a123d35863c79a9c0e253016 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 6 Nov 2019 16:46:17 +0000 Subject: Fix [12c8dfaa98] and [7e174a300e]: listbox.tcl/scrlbar.tcl: missing improved units computation in mouse wheel bindings --- library/listbox.tcl | 12 ++++++++++-- library/scrlbar.tcl | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/library/listbox.tcl b/library/listbox.tcl index 2149e10..a094883 100644 --- a/library/listbox.tcl +++ b/library/listbox.tcl @@ -195,10 +195,18 @@ if {[tk windowingsystem] eq "aqua"} { } } else { bind Listbox { - %W yview scroll [expr {-(%D/30)}] units + if {%D >= 0} { + %W yview scroll [expr {-%D/30}] units + } else { + %W yview scroll [expr {(29-%D)/30}] units + } } bind Listbox { - %W xview scroll [expr {-(%D/30)}] units + if {%D >= 0} { + %W xview scroll [expr {-%D/30}] units + } else { + %W xview scroll [expr {(29-%D)/30}] units + } } } diff --git a/library/scrlbar.tcl b/library/scrlbar.tcl index 65f29ee..a1c4398 100644 --- a/library/scrlbar.tcl +++ b/library/scrlbar.tcl @@ -144,10 +144,18 @@ if {[tk windowingsystem] eq "aqua"} { } } else { bind Scrollbar { - tk::ScrollByUnits %W v [expr {-(%D / 30)}] + if {%D >= 0} { + tk::ScrollByUnits %W v [expr {-%D/30}] + } else { + tk::ScrollByUnits %W v [expr {(29-%D)/30}] + } } bind Scrollbar { - tk::ScrollByUnits %W h [expr {-(%D / 30)}] + if {%D >= 0} { + tk::ScrollByUnits %W h [expr {-%D/30}] + } else { + tk::ScrollByUnits %W h [expr {(29-%D)/30}] + } } } -- cgit v0.12 From 5a3617067387db921c9984395fbe013d68dc1d24 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 7 Nov 2019 23:22:34 +0000 Subject: Fix [c4abd2b0f3]: Tcl Panic in TkWmStackorderToplevel (for Aqua) --- macosx/tkMacOSXWm.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index c2b67f6..dda6c19 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -3309,18 +3309,18 @@ WmStackorderCmd( if (objc == 3) { windows = TkWmStackorderToplevel(winPtr); - if (windows == NULL) { - Tcl_Panic("TkWmStackorderToplevel failed"); - } - - resultObj = Tcl_NewObj(); - for (windowPtr = windows; *windowPtr ; windowPtr++) { - Tcl_ListObjAppendElement(NULL, resultObj, + if (windows != NULL) { + resultObj = Tcl_NewObj(); + for (windowPtr = windows; *windowPtr ; windowPtr++) { + Tcl_ListObjAppendElement(NULL, resultObj, TkNewWindowObj((Tk_Window) *windowPtr)); + } + Tcl_SetObjResult(interp, resultObj); + ckfree(windows); + return TCL_OK; + } else { + return TCL_ERROR; } - Tcl_SetObjResult(interp, resultObj); - ckfree(windows); - return TCL_OK; } else { TkWindow *winPtr2; int index1 = -1, index2 = -1, result; @@ -6701,10 +6701,6 @@ TkWmStackorderToplevel( *windowPtr-- = childWinPtr; } } - if (windowPtr != windows-1) { - Tcl_Panic("num matched toplevel windows does not equal num " - "children"); - } } done: -- cgit v0.12 From 26733057747b9f7db38abe7f8c3a75132a8881f6 Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 8 Nov 2019 06:51:55 +0000 Subject: Reimplement TkWmStackorderToplevel to make it straightforward and shorter and behave the same on macOS as on unix and Windows. --- macosx/tkMacOSXWm.c | 56 +++++++++++++---------------------------------------- tests/wm.test | 14 ++------------ 2 files changed, 15 insertions(+), 55 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index dda6c19..dfe3a26 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -6621,7 +6621,7 @@ WmStackorderToplevelWrapperMap( Tcl_HashEntry *hPtr; int newEntry; - if (Tk_IsMapped(winPtr) && Tk_IsTopLevel(winPtr) + if (Tk_IsMapped(winPtr) && Tk_IsTopLevel(winPtr) && !Tk_IsEmbedded(winPtr) && (winPtr->display == display)) { hPtr = Tcl_CreateHashEntry(table, (char*) TkMacOSXDrawableWindow(winPtr->window), &newEntry); @@ -6642,8 +6642,8 @@ WmStackorderToplevelWrapperMap( * This procedure returns the stack order of toplevel windows. * * Results: - * An array of pointers to tk window objects in stacking order or else - * NULL if there was an error. + * A NULL terminated array of pointers to tk window objects in stacking + * order or else NULL if there was an error. * * Side effects: * None. @@ -6658,52 +6658,22 @@ TkWmStackorderToplevel( TkWindow *childWinPtr, **windows, **windowPtr; Tcl_HashTable table; Tcl_HashEntry *hPtr; - Tcl_HashSearch search; - - /* - * Map mac windows to a TkWindow of the wrapped toplevel. - */ + NSArray *macWindows = [NSApp orderedWindows]; + NSArray* backToFront = [[macWindows reverseObjectEnumerator] allObjects]; + NSInteger windowCount = [macWindows count]; + windows = windowPtr = ckalloc((windowCount + 1) * sizeof(TkWindow *)); Tcl_InitHashTable(&table, TCL_ONE_WORD_KEYS); WmStackorderToplevelWrapperMap(parentPtr, parentPtr->display, &table); - windows = ckalloc((table.numEntries+1) * sizeof(TkWindow *)); - - /* - * Special cases: If zero or one toplevels were mapped there is no need to - * enumerate Windows. - */ - - switch (table.numEntries) { - case 0: - windows[0] = NULL; - goto done; - case 1: - hPtr = Tcl_FirstHashEntry(&table, &search); - windows[0] = Tcl_GetHashValue(hPtr); - windows[1] = NULL; - goto done; - } - - NSArray *macWindows = [NSApp orderedWindows]; - NSInteger windowCount = [macWindows count]; - - if (!windowCount) { - ckfree(windows); - windows = NULL; - } else { - windowPtr = windows + table.numEntries; - *windowPtr-- = NULL; - for (NSWindow *w in macWindows) { - hPtr = Tcl_FindHashEntry(&table, (char*) w); - if (hPtr != NULL) { - childWinPtr = Tcl_GetHashValue(hPtr); - *windowPtr-- = childWinPtr; - } + for (NSWindow *w in backToFront) { + hPtr = Tcl_FindHashEntry(&table, (char*) w); + if (hPtr != NULL) { + childWinPtr = Tcl_GetHashValue(hPtr); + *windowPtr++ = childWinPtr; } } - - done: + *windowPtr = NULL; Tcl_DeleteHashTable(&table); return windows; } diff --git a/tests/wm.test b/tests/wm.test index c2bc385..1dbc372 100644 --- a/tests/wm.test +++ b/tests/wm.test @@ -1553,8 +1553,8 @@ test wm-stackorder-5.3 {An overrideredirect window\ destroy .t } -result 1 -test wm-stackorder-6.1 {An embedded toplevel does not\ - appear in the stacking order on unix or win} -constraints notAqua -body { +test wm-stackorder-6.1 {An embedded toplevel does not appear in the \ + stacking order} -body { toplevel .real -container 1 toplevel .embd -bg blue -use [winfo id .real] update @@ -1562,16 +1562,6 @@ test wm-stackorder-6.1 {An embedded toplevel does not\ } -cleanup { deleteWindows } -result {. .real} -test wm-stackorder-6.1.1 {An embedded toplevel does\ - appear in the stacking order on macOS} -constraints aqua -body { - toplevel .real -container 1 - toplevel .embd -bg blue -use [winfo id .real] - update - wm stackorder . -} -cleanup { - deleteWindows -} -result {. .embd} - stdWindow -- cgit v0.12 From bcb9c70e081e441f93428e84241226919588dc13 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 9 Nov 2019 10:18:10 +0000 Subject: Propagate previous Mac fix to the Windows platform --- win/tkWinWm.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 117b539..7df5dcf 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -5195,18 +5195,18 @@ WmStackorderCmd( if (objc == 3) { windows = TkWmStackorderToplevel(winPtr); - if (windows == NULL) { - Tcl_Panic("TkWmStackorderToplevel failed"); - } - - resultObj = Tcl_NewObj(); - for (windowPtr = windows; *windowPtr ; windowPtr++) { - Tcl_ListObjAppendElement(NULL, resultObj, - TkNewWindowObj((Tk_Window) *windowPtr)); + if (windows != NULL) { + resultObj = Tcl_NewObj(); + for (windowPtr = windows; *windowPtr ; windowPtr++) { + Tcl_ListObjAppendElement(NULL, resultObj, + TkNewWindowObj((Tk_Window) *windowPtr)); + } + Tcl_SetObjResult(interp, resultObj); + ckfree(windows); + return TCL_OK; + } else { + return TCL_ERROR; } - Tcl_SetObjResult(interp, resultObj); - ckfree(windows); - return TCL_OK; } else { TkWindow *winPtr2, **winPtr2Ptr = &winPtr2; int index1 = -1, index2 = -1, result; @@ -6812,8 +6812,6 @@ TkWmStackorderToplevel( (LPARAM) &pair) == 0) { ckfree(windows); windows = NULL; - } else if (pair.windowPtr != (windows-1)) { - Tcl_Panic("num matched toplevel windows does not equal num children"); } done: -- cgit v0.12 From 62caa9e27341a3355e8067480fd2a0fe5d942281 Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 9 Nov 2019 13:12:24 +0000 Subject: make TkWmStackorderToplevel return NULL if ckalloc fails. --- macosx/tkMacOSXWm.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index dfe3a26..53bb400 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -6663,18 +6663,19 @@ TkWmStackorderToplevel( NSInteger windowCount = [macWindows count]; windows = windowPtr = ckalloc((windowCount + 1) * sizeof(TkWindow *)); - Tcl_InitHashTable(&table, TCL_ONE_WORD_KEYS); - WmStackorderToplevelWrapperMap(parentPtr, parentPtr->display, &table); - - for (NSWindow *w in backToFront) { - hPtr = Tcl_FindHashEntry(&table, (char*) w); - if (hPtr != NULL) { - childWinPtr = Tcl_GetHashValue(hPtr); - *windowPtr++ = childWinPtr; + if (windows != NULL) { + Tcl_InitHashTable(&table, TCL_ONE_WORD_KEYS); + WmStackorderToplevelWrapperMap(parentPtr, parentPtr->display, &table); + for (NSWindow *w in backToFront) { + hPtr = Tcl_FindHashEntry(&table, (char*) w); + if (hPtr != NULL) { + childWinPtr = Tcl_GetHashValue(hPtr); + *windowPtr++ = childWinPtr; + } } + *windowPtr = NULL; + Tcl_DeleteHashTable(&table); } - *windowPtr = NULL; - Tcl_DeleteHashTable(&table); return windows; } -- cgit v0.12 From 1ba2cee840613a4386f80189fce4169061cc6f40 Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 9 Nov 2019 14:49:43 +0000 Subject: Fix [53d28027e3]: Generate an error instead of a crash if wm iconphoto receives an invalid photo image. --- macosx/tkMacOSXDraw.c | 7 +++++-- macosx/tkMacOSXWm.c | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 5714bf4..3f7ca0a 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -501,9 +501,12 @@ TkMacOSXGetNSImageWithTkImage( int width, int height) { - Pixmap pixmap = Tk_GetPixmap(display, None, width, height, 0); + Pixmap pixmap; NSImage *nsImage; - + if (width == 0 | height == 0) { + return NULL; + } + pixmap = Tk_GetPixmap(display, None, width, height, 0); Tk_RedrawImage(image, 0, 0, width, height, pixmap, 0, 0); nsImage = CreateNSImageWithPixmap(pixmap, width, height); Tk_FreePixmap(display, pixmap); diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index c2b67f6..40fca11 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -2569,6 +2569,10 @@ WmIconphotoCmd( width, height); Tk_FreeImage(tk_icon); if (newIcon == NULL) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "Failed to create an NSImage from \"%s\".", + icon)); + Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "PHOTO", NULL); return TCL_ERROR; } [NSApp setApplicationIconImage: newIcon]; -- cgit v0.12 From c6c3908ad15bb2ad9eb39b2b5177f601fe692d61 Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 10 Nov 2019 18:13:49 +0000 Subject: Make all platforms check if an iconphoto image is valid and provide the same error message if not. --- macosx/tkMacOSXWm.c | 7 +++---- unix/tkUnixWm.c | 4 ++++ win/tkWinWm.c | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 40fca11..086746b 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -2569,10 +2569,9 @@ WmIconphotoCmd( width, height); Tk_FreeImage(tk_icon); if (newIcon == NULL) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "Failed to create an NSImage from \"%s\".", - icon)); - Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "PHOTO", NULL); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "failed to create an iconphoto with image \"%s\"", icon)); + Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "IMAGE", NULL); return TCL_ERROR; } [NSApp setApplicationIconImage: newIcon]; diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index bc7f1cb..b284622 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -2447,6 +2447,10 @@ WmIconphotoCmd( photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i])); if (photo == NULL) { ckfree((char *) iconPropertyData); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "failed to create an iconphoto with image \"%s\"", + Tcl_GetString(objv[i]))); + Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "PHOTO", NULL); return TCL_ERROR; } Tk_PhotoGetSize(photo, &width, &height); diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 117b539..d30152f 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -4384,9 +4384,9 @@ WmIconphotoCmd( if (!iconInfo.hbmColor) { ckfree(lpIR); Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "failed to create color bitmap for \"%s\"", + "failed to create an iconphoto with image \"%s\"", Tcl_GetString(objv[i]))); - Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "BITMAP", NULL); + Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "IMAGE", NULL); return TCL_ERROR; } -- cgit v0.12 From 7f952ce8386b3060408ee6f672760bc55606080d Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 10 Nov 2019 18:35:46 +0000 Subject: On unix, make the wm stackorder command return an error if TkWmStackorderToplevel fails. --- unix/tkUnixWm.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index bc7f1cb..0ebd4ac 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -3268,6 +3268,8 @@ WmStackorderCmd( ckfree(windows); Tcl_SetObjResult(interp, resultObj); return TCL_OK; + } else { + return TCL_ERROR; } } else { Tk_Window relWin; @@ -6432,6 +6434,9 @@ TkWmStackorderToplevel( TkWmStackorderToplevelWrapperMap(parentPtr, parentPtr->display, &table); window_ptr = windows = ckalloc((table.numEntries+1) * sizeof(TkWindow *)); + if (windows == NULL) { + return NULL; + } /* * Special cases: If zero or one toplevels were mapped there is no need to -- cgit v0.12 From 2d08ff857a9a0a9afc14825e7d33208a115e38dd Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 10 Nov 2019 20:03:21 +0000 Subject: Add platform-independent test wm-iconphoto-1.5 --- tests/wm.test | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/wm.test b/tests/wm.test index c2bc385..b5ef92a 100644 --- a/tests/wm.test +++ b/tests/wm.test @@ -873,6 +873,9 @@ test wm-iconphoto-1.4 {usage} -returnCodes error -body { # we currently have no return info wm iconphoto . -default } -result {wrong # args: should be "wm iconphoto window ?-default? image1 ?image2 ...?"} +test wm-iconphoto-1.5 {usage} -returnCodes error -body { + wm iconphoto . -default [image create photo -file {}] +} -result {failed to create an iconphoto with image "image1"} # All other iconphoto tests are platform specific -- cgit v0.12 From c1711a576e24c000190039b0476642171a00736b Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 10 Nov 2019 20:09:08 +0000 Subject: Homogenize still further among platforms --- unix/tkUnixWm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index b284622..e81aa58 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -2450,7 +2450,7 @@ WmIconphotoCmd( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "failed to create an iconphoto with image \"%s\"", Tcl_GetString(objv[i]))); - Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "PHOTO", NULL); + Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "IMAGE", NULL); return TCL_ERROR; } Tk_PhotoGetSize(photo, &width, &height); -- cgit v0.12 From 00979fc3e90f332ebbdbea41c9efce20f422136e Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 10 Nov 2019 21:11:10 +0000 Subject: The new test wm-iconphoto-1.5 must not depend on previous tests and how many images were created so far in the testing process --- tests/wm.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/wm.test b/tests/wm.test index b5ef92a..e290b8c 100644 --- a/tests/wm.test +++ b/tests/wm.test @@ -875,7 +875,7 @@ test wm-iconphoto-1.4 {usage} -returnCodes error -body { } -result {wrong # args: should be "wm iconphoto window ?-default? image1 ?image2 ...?"} test wm-iconphoto-1.5 {usage} -returnCodes error -body { wm iconphoto . -default [image create photo -file {}] -} -result {failed to create an iconphoto with image "image1"} +} -match {glob} -result {failed to create an iconphoto with image *} # All other iconphoto tests are platform specific -- cgit v0.12 From 9b325ebbd06b8857fffffe9107c87e993ca550a8 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 10 Nov 2019 22:30:12 +0000 Subject: Split wm-iconphoto-1.5 into the Win and Mac case on one hand (an error triggers), and the Linux case on the other hand (no error is produced, the image is valid and can be used as an iconphoto even if its size is 0x0) --- tests/wm.test | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/wm.test b/tests/wm.test index e290b8c..22cd2ea 100644 --- a/tests/wm.test +++ b/tests/wm.test @@ -873,9 +873,12 @@ test wm-iconphoto-1.4 {usage} -returnCodes error -body { # we currently have no return info wm iconphoto . -default } -result {wrong # args: should be "wm iconphoto window ?-default? image1 ?image2 ...?"} -test wm-iconphoto-1.5 {usage} -returnCodes error -body { +test wm-iconphoto-1.5.1 {usage} -constraints aquaOrWin32 -returnCodes error -body { wm iconphoto . -default [image create photo -file {}] } -match {glob} -result {failed to create an iconphoto with image *} +test wm-iconphoto-1.5.2 {usage} -constraints x11 -body { + wm iconphoto . -default [image create photo -file {}] +} -result {} # All other iconphoto tests are platform specific -- cgit v0.12 From 770d3ab7c71b257d3aee36fbd5346a71be5df6dd Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 11 Nov 2019 01:45:54 +0000 Subject: Allow creating 0x0 NSImages, which work e.g. in labels, just don't allow using them as iconphoto images. --- macosx/tkMacOSXDraw.c | 2 +- macosx/tkMacOSXWm.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 3f7ca0a..fb6a8a0 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -504,7 +504,7 @@ TkMacOSXGetNSImageWithTkImage( Pixmap pixmap; NSImage *nsImage; if (width == 0 | height == 0) { - return NULL; + return nsImage = [[NSImage alloc] initWithSize:NSMakeSize(0,0)]; } pixmap = Tk_GetPixmap(display, None, width, height, 0); Tk_RedrawImage(image, 0, 0, width, height, pixmap, 0, 0); diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 086746b..0d49d74 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -2518,6 +2518,7 @@ WmIconphotoCmd( { Tk_Image tk_icon; int width, height, isDefault = 0; + NSImage *newIcon = NULL; if (objc < 4) { Tcl_WrongNumArgs(interp, 2, objv, @@ -2563,10 +2564,11 @@ WmIconphotoCmd( return TCL_ERROR; } - NSImage *newIcon; Tk_SizeOfImage(tk_icon, &width, &height); - newIcon = TkMacOSXGetNSImageWithTkImage(winPtr->display, tk_icon, - width, height); + if (width != 0 && height != 0) { + newIcon = TkMacOSXGetNSImageWithTkImage(winPtr->display, tk_icon, + width, height); + } Tk_FreeImage(tk_icon); if (newIcon == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( -- cgit v0.12 From 3f4576aa127cab633b5c71369606afc548f26a8d Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 11 Nov 2019 14:36:29 +0000 Subject: Tweak the fix to [8793e78bf0] to avoid scrollbar artifacts. --- macosx/tkMacOSXDraw.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 5714bf4..f4c0107 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1636,23 +1636,32 @@ TkMacOSXSetupDrawingContext( * display in the bounding rectangle of the clipping region and * return failure. That rectangle should get drawn in a later call * to drawRect. + * + * As an exception to the above, if mouse buttons are pressed at the + * moment when we fail to obtain a valid context we schedule the entire + * view for a redraw rather than just the clipping region. The purpose + * of this is to make sure that scrollbars get updated correctly. */ - + if (![NSApp isDrawing] || view != [NSView focusView]) { NSRect bounds = [view bounds]; NSRect dirtyNS = bounds; - CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0, - .ty = dirtyNS.size.height}; - if (dc.clipRgn) { - CGRect dirtyCG = NSRectToCGRect(dirtyNS); - HIShapeGetBounds(dc.clipRgn, &dirtyCG); - dirtyNS = NSRectToCGRect(CGRectApplyAffineTransform(dirtyCG, t)); + if ([NSEvent pressedMouseButtons]) { + [view setNeedsDisplay:YES]; + } else { + CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0, + .ty = dirtyNS.size.height}; + if (dc.clipRgn) { + CGRect dirtyCG = NSRectToCGRect(dirtyNS); + HIShapeGetBounds(dc.clipRgn, &dirtyCG); + dirtyNS = NSRectToCGRect(CGRectApplyAffineTransform(dirtyCG, t)); + } + [view setNeedsDisplayInRect:dirtyNS]; } - [view setNeedsDisplayInRect:dirtyNS]; canDraw = false; goto end; } - + dc.view = view; dc.context = GET_CGCONTEXT; dc.portBounds = NSRectToCGRect([view bounds]); -- cgit v0.12 From 00f8f17c40f5adbf52733a4c57ef74d62564f47d Mon Sep 17 00:00:00 2001 From: oehhar Date: Tue, 12 Nov 2019 19:10:39 +0000 Subject: tksvg crash on style usage due to different malloc and free types on some systems. Issue #2 of tksvg. --- generic/nanosvg.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/generic/nanosvg.h b/generic/nanosvg.h index b449dc2..5377ae0 100755 --- a/generic/nanosvg.h +++ b/generic/nanosvg.h @@ -704,10 +704,10 @@ static void nsvg__deleteStyles(NSVGstyles* style) { while (style) { NSVGstyles *next = style->next; if (style->name!= NULL) - free(style->name); + NANOSVG_free(style->name); if (style->description != NULL) - free(style->description); - free(style); + NANOSVG_free(style->description); + NANOSVG_free(style); style = next; } } @@ -2843,7 +2843,7 @@ static void nsvg__content(void* ud, const char* s) if (state == 1) { NSVGstyles* next = p->styles; - p->styles = (NSVGstyles*)malloc(sizeof(NSVGstyles)); + p->styles = (NSVGstyles*)NANOSVG_malloc(sizeof(NSVGstyles)); p->styles->next = next; p->styles->name = nsvg__strndup(start, (size_t)(s - start)); start = s + 1; -- cgit v0.12 From e312cb85dff0db0346f922c5c5ecc0c61f31fd8c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 13 Nov 2019 15:25:19 +0000 Subject: Add support for 4 keycodes on Windows (Mail, AudioMedia, Launch0 and Launch1), which some keyboards might have. Add more header-files, with available keycodes on various platforms, and add some missing keysyms to ks_names.h (adapted from X11R6). This improves compatibility for Windows/MacOSX compared to X11R6. --- generic/ks_names.h | 181 ++++++++++++++++++++++++++++++++++++++- macosx/tkMacOSXFont.c | 2 +- win/tkWinKey.c | 74 ++++++++-------- xlib/X11/DECkeysym.h | 65 ++++++++++++++ xlib/X11/HPkeysym.h | 164 +++++++++++++++++++++++++++++++++++ xlib/X11/Sunkeysym.h | 106 +++++++++++++++++++++++ xlib/X11/XF86keysym.h | 230 ++++++++++++++++++++++++++++++++++++++++++++++++++ xlib/X11/ap_keysym.h | 51 +++++++++++ 8 files changed, 835 insertions(+), 38 deletions(-) create mode 100644 xlib/X11/DECkeysym.h create mode 100644 xlib/X11/HPkeysym.h create mode 100644 xlib/X11/Sunkeysym.h create mode 100755 xlib/X11/XF86keysym.h create mode 100644 xlib/X11/ap_keysym.h diff --git a/generic/ks_names.h b/generic/ks_names.h index 3386ec0..3577390 100644 --- a/generic/ks_names.h +++ b/generic/ks_names.h @@ -426,9 +426,9 @@ { "nacute", 0x1F1 }, { "ncaron", 0x1F2 }, { "odoubleacute", 0x1F5 }, -{ "udoubleacute", 0x1FB }, { "rcaron", 0x1F8 }, { "uring", 0x1F9 }, +{ "udoubleacute", 0x1FB }, { "tcedilla", 0x1FE }, { "abovedot", 0x1FF }, { "Hstroke", 0x2A1 }, @@ -628,6 +628,7 @@ { "Serbian_nje", 0x6AA }, { "Serbian_tshe", 0x6AB }, { "Macedonia_kje", 0x6AC }, +{ "Ukrainian_ghe_with_upturn", 0x6AD }, { "Byelorussian_shortu", 0x6AE }, { "Cyrillic_dzhe", 0x6AF }, { "Serbian_dze", 0x6AF }, @@ -650,6 +651,7 @@ { "Serbian_NJE", 0x6BA }, { "Serbian_TSHE", 0x6BB }, { "Macedonia_KJE", 0x6BC }, +{ "Ukrainian_GHE_WITH_UPTURN", 0x6BD }, { "Byelorussian_SHORTU", 0x6BE }, { "Cyrillic_DZHE", 0x6BF }, { "Serbian_DZE", 0x6BF }, @@ -910,6 +912,7 @@ { "leftdoublequotemark", 0xAD2 }, { "rightdoublequotemark", 0xAD3 }, { "prescription", 0xAD4 }, +{ "permille", 0xAD5 }, { "minutes", 0xAD6 }, { "seconds", 0xAD7 }, { "latincross", 0xAD9 }, @@ -1009,6 +1012,14 @@ { "hebrew_taw", 0xCFA }, { "hebrew_taf", 0xCFA }, { "Hebrew_switch", 0xFF7E }, +{ "XF86ModeLock", 0x1008FF01 }, +{ "XF86MonBrightnessUp", 0x1008FF02 }, +{ "XF86MonBrightnessDown", 0x1008FF03 }, +{ "XF86KbdLightOnOff", 0x1008FF04 }, +{ "XF86KbdBrightnessUp", 0x1008FF05 }, +{ "XF86KbdBrightnessDown", 0x1008FF06 }, +{ "XF86MonBrightnessCycle", 0x1008FF07 }, +{ "XF86Standby", 0x1008FF10 }, { "XF86AudioLowerVolume", 0x1008FF11 }, { "XF86AudioMute", 0x1008FF12 }, { "XF86AudioRaiseVolume", 0x1008FF13 }, @@ -1016,3 +1027,171 @@ { "XF86AudioStop", 0x1008FF15 }, { "XF86AudioPrev", 0x1008FF16 }, { "XF86AudioNext", 0x1008FF17 }, +{ "XF86HomePage", 0x1008FF18 }, +{ "XF86Mail", 0x1008FF19 }, +{ "XF86Start", 0x1008FF1A }, +{ "XF86Search", 0x1008FF1B }, +{ "XF86AudioRecord", 0x1008FF1C }, +{ "XF86Calculator", 0x1008FF1D }, +{ "XF86Memo", 0x1008FF1E }, +{ "XF86ToDoList", 0x1008FF1F }, +{ "XF86Calendar", 0x1008FF20 }, +{ "XF86PowerDown", 0x1008FF21 }, +{ "XF86ContrastAdjust", 0x1008FF22 }, +{ "XF86RockerUp", 0x1008FF23 }, +{ "XF86RockerDown", 0x1008FF24 }, +{ "XF86RockerEnter", 0x1008FF25 }, +{ "XF86Back", 0x1008FF26 }, +{ "XF86Forward", 0x1008FF27 }, +{ "XF86Stop", 0x1008FF28 }, +{ "XF86Refresh", 0x1008FF29 }, +{ "XF86PowerOff", 0x1008FF2A }, +{ "XF86WakeUp", 0x1008FF2B }, +{ "XF86Eject", 0x1008FF2C }, +{ "XF86ScreenSaver", 0x1008FF2D }, +{ "XF86WWW", 0x1008FF2E }, +{ "XF86Sleep", 0x1008FF2F }, +{ "XF86Favorites", 0x1008FF30 }, +{ "XF86AudioPause", 0x1008FF31 }, +{ "XF86AudioMedia", 0x1008FF32 }, +{ "XF86MyComputer", 0x1008FF33 }, +{ "XF86VendorHome", 0x1008FF34 }, +{ "XF86LightBulb", 0x1008FF35 }, +{ "XF86Shop", 0x1008FF36 }, +{ "XF86History", 0x1008FF37 }, +{ "XF86OpenURL", 0x1008FF38 }, +{ "XF86AddFavorite", 0x1008FF39 }, +{ "XF86HotLinks", 0x1008FF3A }, +{ "XF86BrightnessAdjust", 0x1008FF3B }, +{ "XF86Finance", 0x1008FF3C }, +{ "XF86Community", 0x1008FF3D }, +{ "XF86AudioRewind", 0x1008FF3E }, +{ "XF86BackForward", 0x1008FF3F }, +{ "XF86Launch0", 0x1008FF40 }, +{ "XF86Launch1", 0x1008FF41 }, +{ "XF86Launch2", 0x1008FF42 }, +{ "XF86Launch3", 0x1008FF43 }, +{ "XF86Launch4", 0x1008FF44 }, +{ "XF86Launch5", 0x1008FF45 }, +{ "XF86Launch6", 0x1008FF46 }, +{ "XF86Launch7", 0x1008FF47 }, +{ "XF86Launch8", 0x1008FF48 }, +{ "XF86Launch9", 0x1008FF49 }, +{ "XF86LaunchA", 0x1008FF4A }, +{ "XF86LaunchB", 0x1008FF4B }, +{ "XF86LaunchC", 0x1008FF4C }, +{ "XF86LaunchD", 0x1008FF4D }, +{ "XF86LaunchE", 0x1008FF4E }, +{ "XF86LaunchF", 0x1008FF4F }, +{ "XF86ApplicationLeft", 0x1008FF50 }, +{ "XF86ApplicationRight", 0x1008FF51 }, +{ "XF86Book", 0x1008FF52 }, +{ "XF86CD", 0x1008FF53 }, +{ "XF86Calculater", 0x1008FF54 }, +{ "XF86Clear", 0x1008FF55 }, +{ "XF86Close", 0x1008FF56 }, +{ "XF86Copy", 0x1008FF57 }, +{ "XF86Cut", 0x1008FF58 }, +{ "XF86Display", 0x1008FF59 }, +{ "XF86DOS", 0x1008FF5A }, +{ "XF86Documents", 0x1008FF5B }, +{ "XF86Excel", 0x1008FF5C }, +{ "XF86Explorer", 0x1008FF5D }, +{ "XF86Game", 0x1008FF5E }, +{ "XF86Go", 0x1008FF5F }, +{ "XF86iTouch", 0x1008FF60 }, +{ "XF86LogOff", 0x1008FF61 }, +{ "XF86Market", 0x1008FF62 }, +{ "XF86Meeting", 0x1008FF63 }, +{ "XF86MenuKB", 0x1008FF65 }, +{ "XF86MenuPB", 0x1008FF66 }, +{ "XF86MySites", 0x1008FF67 }, +{ "XF86New", 0x1008FF68 }, +{ "XF86News", 0x1008FF69 }, +{ "XF86OfficeHome", 0x1008FF6A }, +{ "XF86Open", 0x1008FF6B }, +{ "XF86Option", 0x1008FF6C }, +{ "XF86Paste", 0x1008FF6D }, +{ "XF86Phone", 0x1008FF6E }, +{ "XF86Q", 0x1008FF70 }, +{ "XF86Reply", 0x1008FF72 }, +{ "XF86Reload", 0x1008FF73 }, +{ "XF86RotateWindows", 0x1008FF74 }, +{ "XF86RotationPB", 0x1008FF75 }, +{ "XF86RotationKB", 0x1008FF76 }, +{ "XF86Save", 0x1008FF77 }, +{ "XF86ScrollUp", 0x1008FF78 }, +{ "XF86ScrollDown", 0x1008FF79 }, +{ "XF86ScrollClick", 0x1008FF7A }, +{ "XF86Send", 0x1008FF7B }, +{ "XF86Spell", 0x1008FF7C }, +{ "XF86SplitScreen", 0x1008FF7D }, +{ "XF86Support", 0x1008FF7E }, +{ "XF86TaskPane", 0x1008FF7F }, +{ "XF86Terminal", 0x1008FF80 }, +{ "XF86Tools", 0x1008FF81 }, +{ "XF86Travel", 0x1008FF82 }, +{ "XF86UserPB", 0x1008FF84 }, +{ "XF86User1KB", 0x1008FF85 }, +{ "XF86User2KB", 0x1008FF86 }, +{ "XF86Video", 0x1008FF87 }, +{ "XF86WheelButton", 0x1008FF88 }, +{ "XF86Word", 0x1008FF89 }, +{ "XF86Xfer", 0x1008FF8A }, +{ "XF86ZoomIn", 0x1008FF8B }, +{ "XF86ZoomOut", 0x1008FF8C }, +{ "XF86Away", 0x1008FF8D }, +{ "XF86Messenger", 0x1008FF8E }, +{ "XF86WebCam", 0x1008FF8F }, +{ "XF86MailForward", 0x1008FF90 }, +{ "XF86Pictures", 0x1008FF91 }, +{ "XF86Music", 0x1008FF92 }, +{ "XF86Battery", 0x1008FF93 }, +{ "XF86Bluetooth", 0x1008FF94 }, +{ "XF86WLAN", 0x1008FF95 }, +{ "XF86UWB", 0x1008FF96 }, +{ "XF86AudioForward", 0x1008FF97 }, +{ "XF86AudioRepeat", 0x1008FF98 }, +{ "XF86AudioRandomPlay", 0x1008FF99 }, +{ "XF86Subtitle", 0x1008FF9A }, +{ "XF86AudioCycleTrack", 0x1008FF9B }, +{ "XF86CycleAngle", 0x1008FF9C }, +{ "XF86FrameBack", 0x1008FF9D }, +{ "XF86FrameForward", 0x1008FF9E }, +{ "XF86Time", 0x1008FF9F }, +{ "XF86Select", 0x1008FFA0 }, +{ "XF86View", 0x1008FFA1 }, +{ "XF86TopMenu", 0x1008FFA2 }, +{ "XF86Red", 0x1008FFA3 }, +{ "XF86Green", 0x1008FFA4 }, +{ "XF86Yellow", 0x1008FFA5 }, +{ "XF86Blue", 0x1008FFA6 }, +{ "XF86Suspend", 0x1008FFA7 }, +{ "XF86Hibernate", 0x1008FFA8 }, +{ "XF86TouchpadToggle", 0x1008FFA9 }, +{ "XF86TouchpadOn", 0x1008FFB0 }, +{ "XF86TouchpadOff", 0x1008FFB1 }, +{ "XF86AudioMicMute", 0x1008FFB2 }, +{ "XF86Keyboard", 0x1008FFB3 }, +{ "XF86WWAN", 0x1008FFB4 }, +{ "XF86RFKill", 0x1008FFB5 }, +{ "XF86AudioPreset", 0x1008FFB6 }, +{ "XF86RotationLockToggle", 0x1008FFB7 }, +{ "XF86Switch_VT_1", 0x1008FE01 }, +{ "XF86Switch_VT_2", 0x1008FE02 }, +{ "XF86Switch_VT_3", 0x1008FE03 }, +{ "XF86Switch_VT_4", 0x1008FE04 }, +{ "XF86Switch_VT_5", 0x1008FE05 }, +{ "XF86Switch_VT_6", 0x1008FE06 }, +{ "XF86Switch_VT_7", 0x1008FE07 }, +{ "XF86Switch_VT_8", 0x1008FE08 }, +{ "XF86Switch_VT_9", 0x1008FE09 }, +{ "XF86Switch_VT_10", 0x1008FE0A }, +{ "XF86Switch_VT_11", 0x1008FE0B }, +{ "XF86Switch_VT_12", 0x1008FE0C }, +{ "XF86Ungrab", 0x1008FE20 }, +{ "XF86ClearGrab", 0x1008FE21 }, +{ "XF86Next_VMode", 0x1008FE22 }, +{ "XF86Prev_VMode", 0x1008FE23 }, +{ "XF86LogWindowTree", 0x1008FE24 }, +{ "XF86LogGrabInfo", 0x1008FE25 }, diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index d6429ed..153ce3b 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -400,7 +400,7 @@ TkpFontPkgInit( * return a font with the invalid familyName ".SF NSMono" instead of the * valid familyName "NSMono". Calling [NSFont userFixedPitchFontOfSize:11] * returns a font in the "Menlo" family which has a valid familyName. - */ + */ nsFont = (NSFont*) CTFontCreateUIFontForLanguage(fixedPitch, 11, NULL); #else nsFont = [NSFont userFixedPitchFontOfSize:11]; diff --git a/win/tkWinKey.c b/win/tkWinKey.c index 4130579..8a83874 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -11,6 +11,7 @@ */ #include "tkWinInt.h" +#include "X11/XF86keysym.h" /* * The keymap table holds mappings of Windows keycodes to X keysyms. If @@ -21,46 +22,47 @@ * like a worthwhile improvement to use the table. */ -#define MAX_KEYCODE 179 /* VK_MEDIA_PLAY_PAUSE is the last entry in our table below */ +#define MAX_KEYCODE 183 /* VK_LAUNCH_APP2 is the last entry in our table below */ /* cf. https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx */ static const KeySym keymap[] = { - NoSymbol, NoSymbol, NoSymbol, XK_Cancel, NoSymbol, - NoSymbol, NoSymbol, NoSymbol, XK_BackSpace, XK_Tab, - NoSymbol, NoSymbol, XK_Clear, XK_Return, NoSymbol, - NoSymbol, XK_Shift_L, XK_Control_L, XK_Alt_L, XK_Pause, - XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, NoSymbol, - NoSymbol, NoSymbol, XK_Escape, NoSymbol, NoSymbol, - NoSymbol, NoSymbol, XK_space, XK_Prior, XK_Next, - XK_End, XK_Home, XK_Left, XK_Up, XK_Right, - XK_Down, XK_Select, XK_Print, XK_Execute, NoSymbol, - XK_Insert, XK_Delete, XK_Help, NoSymbol, NoSymbol, - NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, - NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, - NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, - NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, - NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, - NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, - NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, - NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, - NoSymbol, XK_Win_L, XK_Win_R, XK_App, NoSymbol, - NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, - NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, - NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, - NoSymbol, NoSymbol, XK_F1, XK_F2, XK_F3, - XK_F4, XK_F5, XK_F6, XK_F7, XK_F8, - XK_F9, XK_F10, XK_F11, XK_F12, XK_F13, - XK_F14, XK_F15, XK_F16, XK_F17, XK_F18, - XK_F19, XK_F20, XK_F21, XK_F22, XK_F23, - XK_F24, NoSymbol, NoSymbol, NoSymbol, NoSymbol, - NoSymbol, NoSymbol, NoSymbol, NoSymbol, XK_Num_Lock, - XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, XK_Cancel, NoSymbol, /*0 0x0*/ + NoSymbol, NoSymbol, NoSymbol, XK_BackSpace, XK_Tab, /*5 0x5*/ + NoSymbol, NoSymbol, XK_Clear, XK_Return, NoSymbol, /*10 0xA*/ + NoSymbol, XK_Shift_L, XK_Control_L, XK_Alt_L, XK_Pause, /*15 0xE*/ + XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*20 0x14*/ + NoSymbol, NoSymbol, XK_Escape, NoSymbol, NoSymbol, /*25 0x19*/ + NoSymbol, NoSymbol, XK_space, XK_Prior, XK_Next, /*30 0x1E*/ + XK_End, XK_Home, XK_Left, XK_Up, XK_Right, /*35 0x23*/ + XK_Down, XK_Select, XK_Print, XK_Execute, NoSymbol, /*40 0x28*/ + XK_Insert, XK_Delete, XK_Help, NoSymbol, NoSymbol, /*45 0x2D*/ + NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*50 0x32*/ + NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*55 0x37*/ + NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*60 0x3C*/ + NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*65 0x41*/ + NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*70 0x46*/ + NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*75 0x4B*/ + NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*80 0x50*/ + NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*85 0x55*/ + NoSymbol, XK_Win_L, XK_Win_R, XK_App, NoSymbol, /*90 0x5A*/ + NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*95 0x5F*/ + NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*100 0x64*/ + NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*105 0x69*/ + NoSymbol, NoSymbol, XK_F1, XK_F2, XK_F3, /*110 0x6E*/ + XK_F4, XK_F5, XK_F6, XK_F7, XK_F8, /*115 0x73*/ + XK_F9, XK_F10, XK_F11, XK_F12, XK_F13, /*120 0x78*/ + XK_F14, XK_F15, XK_F16, XK_F17, XK_F18, /*125 0x7D*/ + XK_F19, XK_F20, XK_F21, XK_F22, XK_F23, /*130 0x82*/ + XK_F24, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*135 0x87*/ + NoSymbol, NoSymbol, NoSymbol, NoSymbol, XK_Num_Lock, /*140 0x8C*/ + XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*145 0x91*/ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*150 0x96*/ - NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*155 0x9b*/ - NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*160 0xa0*/ - NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*165 0xa5*/ - NoSymbol, NoSymbol, NoSymbol, XK_XF86AudioMute, XK_XF86AudioLowerVolume, /*170 0xaa*/ - XK_XF86AudioRaiseVolume, XK_XF86AudioNext, XK_XF86AudioPrev, XK_XF86AudioStop, XK_XF86AudioPlay /*175 0xaf*/ + NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*155 0x9B*/ + NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*160 0xA0*/ + NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*165 0xA5*/ + NoSymbol, NoSymbol, NoSymbol, XF86XK_AudioMute, XF86XK_AudioLowerVolume, /*170 0xAA*/ + XF86XK_AudioRaiseVolume, XF86XK_AudioNext, XF86XK_AudioPrev, XF86XK_AudioStop, XF86XK_AudioPlay, /*175 0xAF*/ + XF86XK_Mail, XF86XK_AudioMedia, XF86XK_Launch0, XF86XK_Launch1 /*180 0xB4*/ }; /* diff --git a/xlib/X11/DECkeysym.h b/xlib/X11/DECkeysym.h new file mode 100644 index 0000000..d9e23c4 --- /dev/null +++ b/xlib/X11/DECkeysym.h @@ -0,0 +1,65 @@ +/*********************************************************** + +Copyright 1988, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + + +Copyright 1988 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +/* + * DEC private keysyms + * (29th bit set) + */ + +/* two-key compose sequence initiators, chosen to map to Latin1 characters */ + +#define DXK_ring_accent 0x1000FEB0 +#define DXK_circumflex_accent 0x1000FE5E +#define DXK_cedilla_accent 0x1000FE2C +#define DXK_acute_accent 0x1000FE27 +#define DXK_grave_accent 0x1000FE60 +#define DXK_tilde 0x1000FE7E +#define DXK_diaeresis 0x1000FE22 + +/* special keysym for LK2** "Remove" key on editing keypad */ + +#define DXK_Remove 0x1000FF00 /* Remove */ diff --git a/xlib/X11/HPkeysym.h b/xlib/X11/HPkeysym.h new file mode 100644 index 0000000..4a0655a --- /dev/null +++ b/xlib/X11/HPkeysym.h @@ -0,0 +1,164 @@ +/* + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts, + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the names of Hewlett Packard +or Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD +TO THIS SOFWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. Hewlett-Packard shall not be liable for errors +contained herein or direct, indirect, special, incidental or +consequential damages in connection with the furnishing, +performance, or use of this material. + +*/ + +#ifndef _HPKEYSYM_H + +#define _HPKEYSYM_H + +#define hpXK_ClearLine 0x1000FF6F +#define hpXK_InsertLine 0x1000FF70 +#define hpXK_DeleteLine 0x1000FF71 +#define hpXK_InsertChar 0x1000FF72 +#define hpXK_DeleteChar 0x1000FF73 +#define hpXK_BackTab 0x1000FF74 +#define hpXK_KP_BackTab 0x1000FF75 +#define hpXK_Modelock1 0x1000FF48 +#define hpXK_Modelock2 0x1000FF49 +#define hpXK_Reset 0x1000FF6C +#define hpXK_System 0x1000FF6D +#define hpXK_User 0x1000FF6E +#define hpXK_mute_acute 0x100000A8 +#define hpXK_mute_grave 0x100000A9 +#define hpXK_mute_asciicircum 0x100000AA +#define hpXK_mute_diaeresis 0x100000AB +#define hpXK_mute_asciitilde 0x100000AC +#define hpXK_lira 0x100000AF +#define hpXK_guilder 0x100000BE +#define hpXK_Ydiaeresis 0x100000EE +#define hpXK_IO 0x100000EE +#define hpXK_longminus 0x100000F6 +#define hpXK_block 0x100000FC + + +#ifndef _OSF_Keysyms +#define _OSF_Keysyms + +#define osfXK_Copy 0x1004FF02 +#define osfXK_Cut 0x1004FF03 +#define osfXK_Paste 0x1004FF04 +#define osfXK_BackTab 0x1004FF07 +#define osfXK_BackSpace 0x1004FF08 +#define osfXK_Clear 0x1004FF0B +#define osfXK_Escape 0x1004FF1B +#define osfXK_AddMode 0x1004FF31 +#define osfXK_PrimaryPaste 0x1004FF32 +#define osfXK_QuickPaste 0x1004FF33 +#define osfXK_PageLeft 0x1004FF40 +#define osfXK_PageUp 0x1004FF41 +#define osfXK_PageDown 0x1004FF42 +#define osfXK_PageRight 0x1004FF43 +#define osfXK_Activate 0x1004FF44 +#define osfXK_MenuBar 0x1004FF45 +#define osfXK_Left 0x1004FF51 +#define osfXK_Up 0x1004FF52 +#define osfXK_Right 0x1004FF53 +#define osfXK_Down 0x1004FF54 +#define osfXK_EndLine 0x1004FF57 +#define osfXK_BeginLine 0x1004FF58 +#define osfXK_EndData 0x1004FF59 +#define osfXK_BeginData 0x1004FF5A +#define osfXK_PrevMenu 0x1004FF5B +#define osfXK_NextMenu 0x1004FF5C +#define osfXK_PrevField 0x1004FF5D +#define osfXK_NextField 0x1004FF5E +#define osfXK_Select 0x1004FF60 +#define osfXK_Insert 0x1004FF63 +#define osfXK_Undo 0x1004FF65 +#define osfXK_Menu 0x1004FF67 +#define osfXK_Cancel 0x1004FF69 +#define osfXK_Help 0x1004FF6A +#define osfXK_SelectAll 0x1004FF71 +#define osfXK_DeselectAll 0x1004FF72 +#define osfXK_Reselect 0x1004FF73 +#define osfXK_Extend 0x1004FF74 +#define osfXK_Restore 0x1004FF78 +#define osfXK_Delete 0x1004FFFF + +#endif /* _OSF_Keysyms */ + + +/************************************************************** + * The use of the following macros is deprecated. + * They are listed below only for backwards compatibility. + */ +#define XK_Reset 0x1000FF6C +#define XK_System 0x1000FF6D +#define XK_User 0x1000FF6E +#define XK_ClearLine 0x1000FF6F +#define XK_InsertLine 0x1000FF70 +#define XK_DeleteLine 0x1000FF71 +#define XK_InsertChar 0x1000FF72 +#define XK_DeleteChar 0x1000FF73 +#define XK_BackTab 0x1000FF74 +#define XK_KP_BackTab 0x1000FF75 +#define XK_Ext16bit_L 0x1000FF76 +#define XK_Ext16bit_R 0x1000FF77 +#define XK_mute_acute 0x100000a8 +#define XK_mute_grave 0x100000a9 +#define XK_mute_asciicircum 0x100000aa +#define XK_mute_diaeresis 0x100000ab +#define XK_mute_asciitilde 0x100000ac +#define XK_lira 0x100000af +#define XK_guilder 0x100000be +#ifndef XK_Ydiaeresis +#define XK_Ydiaeresis 0x100000ee +#endif +#define XK_IO 0x100000ee +#define XK_longminus 0x100000f6 +#define XK_block 0x100000fc + +#endif /* _HPKEYSYM_H */ diff --git a/xlib/X11/Sunkeysym.h b/xlib/X11/Sunkeysym.h new file mode 100644 index 0000000..78d1286 --- /dev/null +++ b/xlib/X11/Sunkeysym.h @@ -0,0 +1,106 @@ +/* + * Copyright (c) 1991, Oracle and/or its affiliates. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/************************************************************ + +Copyright 1991, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +***********************************************************/ + +/* + * Floating Accent + */ + +#define SunXK_FA_Grave 0x1005FF00 +#define SunXK_FA_Circum 0x1005FF01 +#define SunXK_FA_Tilde 0x1005FF02 +#define SunXK_FA_Acute 0x1005FF03 +#define SunXK_FA_Diaeresis 0x1005FF04 +#define SunXK_FA_Cedilla 0x1005FF05 + +/* + * Miscellaneous Functions + */ + +#define SunXK_F36 0x1005FF10 /* Labeled F11 */ +#define SunXK_F37 0x1005FF11 /* Labeled F12 */ + +#define SunXK_Sys_Req 0x1005FF60 +#define SunXK_Print_Screen 0x0000FF61 /* Same as XK_Print */ + +/* + * International & Multi-Key Character Composition + */ + +#define SunXK_Compose 0x0000FF20 /* Same as XK_Multi_key */ +#define SunXK_AltGraph 0x0000FF7E /* Same as XK_Mode_switch */ + +/* + * Cursor Control + */ + +#define SunXK_PageUp 0x0000FF55 /* Same as XK_Prior */ +#define SunXK_PageDown 0x0000FF56 /* Same as XK_Next */ + +/* + * Open Look Functions + */ + +#define SunXK_Undo 0x0000FF65 /* Same as XK_Undo */ +#define SunXK_Again 0x0000FF66 /* Same as XK_Redo */ +#define SunXK_Find 0x0000FF68 /* Same as XK_Find */ +#define SunXK_Stop 0x0000FF69 /* Same as XK_Cancel */ +#define SunXK_Props 0x1005FF70 +#define SunXK_Front 0x1005FF71 +#define SunXK_Copy 0x1005FF72 +#define SunXK_Open 0x1005FF73 +#define SunXK_Paste 0x1005FF74 +#define SunXK_Cut 0x1005FF75 + +#define SunXK_PowerSwitch 0x1005FF76 +#define SunXK_AudioLowerVolume 0x1005FF77 +#define SunXK_AudioMute 0x1005FF78 +#define SunXK_AudioRaiseVolume 0x1005FF79 +#define SunXK_VideoDegauss 0x1005FF7A +#define SunXK_VideoLowerBrightness 0x1005FF7B +#define SunXK_VideoRaiseBrightness 0x1005FF7C +#define SunXK_PowerSwitchShift 0x1005FF7D diff --git a/xlib/X11/XF86keysym.h b/xlib/X11/XF86keysym.h new file mode 100755 index 0000000..dd287e2 --- /dev/null +++ b/xlib/X11/XF86keysym.h @@ -0,0 +1,230 @@ +/* + * XFree86 vendor specific keysyms. + * + * The XFree86 keysym range is 0x10080001 - 0x1008FFFF. + * + * X.Org will not be adding to the XF86 set of keysyms, though they have + * been adopted and are considered a "standard" part of X keysym definitions. + * XFree86 never properly commented these keysyms, so we have done our + * best to explain the semantic meaning of these keys. + * + * XFree86 has removed their mail archives of the period, that might have + * shed more light on some of these definitions. Until/unless we resurrect + * these archives, these are from memory and usage. + */ + +/* + * ModeLock + * + * This one is old, and not really used any more since XKB offers this + * functionality. + */ + +#define XF86XK_ModeLock 0x1008FF01 /* Mode Switch Lock */ + +/* Backlight controls. */ +#define XF86XK_MonBrightnessUp 0x1008FF02 /* Monitor/panel brightness */ +#define XF86XK_MonBrightnessDown 0x1008FF03 /* Monitor/panel brightness */ +#define XF86XK_KbdLightOnOff 0x1008FF04 /* Keyboards may be lit */ +#define XF86XK_KbdBrightnessUp 0x1008FF05 /* Keyboards may be lit */ +#define XF86XK_KbdBrightnessDown 0x1008FF06 /* Keyboards may be lit */ +#define XF86XK_MonBrightnessCycle 0x1008FF07 /* Monitor/panel brightness */ + +/* + * Keys found on some "Internet" keyboards. + */ +#define XF86XK_Standby 0x1008FF10 /* System into standby mode */ +#define XF86XK_AudioLowerVolume 0x1008FF11 /* Volume control down */ +#define XF86XK_AudioMute 0x1008FF12 /* Mute sound from the system */ +#define XF86XK_AudioRaiseVolume 0x1008FF13 /* Volume control up */ +#define XF86XK_AudioPlay 0x1008FF14 /* Start playing of audio > */ +#define XF86XK_AudioStop 0x1008FF15 /* Stop playing audio */ +#define XF86XK_AudioPrev 0x1008FF16 /* Previous track */ +#define XF86XK_AudioNext 0x1008FF17 /* Next track */ +#define XF86XK_HomePage 0x1008FF18 /* Display user's home page */ +#define XF86XK_Mail 0x1008FF19 /* Invoke user's mail program */ +#define XF86XK_Start 0x1008FF1A /* Start application */ +#define XF86XK_Search 0x1008FF1B /* Search */ +#define XF86XK_AudioRecord 0x1008FF1C /* Record audio application */ + +/* These are sometimes found on PDA's (e.g. Palm, PocketPC or elsewhere) */ +#define XF86XK_Calculator 0x1008FF1D /* Invoke calculator program */ +#define XF86XK_Memo 0x1008FF1E /* Invoke Memo taking program */ +#define XF86XK_ToDoList 0x1008FF1F /* Invoke To Do List program */ +#define XF86XK_Calendar 0x1008FF20 /* Invoke Calendar program */ +#define XF86XK_PowerDown 0x1008FF21 /* Deep sleep the system */ +#define XF86XK_ContrastAdjust 0x1008FF22 /* Adjust screen contrast */ +#define XF86XK_RockerUp 0x1008FF23 /* Rocker switches exist up */ +#define XF86XK_RockerDown 0x1008FF24 /* and down */ +#define XF86XK_RockerEnter 0x1008FF25 /* and let you press them */ + +/* Some more "Internet" keyboard symbols */ +#define XF86XK_Back 0x1008FF26 /* Like back on a browser */ +#define XF86XK_Forward 0x1008FF27 /* Like forward on a browser */ +#define XF86XK_Stop 0x1008FF28 /* Stop current operation */ +#define XF86XK_Refresh 0x1008FF29 /* Refresh the page */ +#define XF86XK_PowerOff 0x1008FF2A /* Power off system entirely */ +#define XF86XK_WakeUp 0x1008FF2B /* Wake up system from sleep */ +#define XF86XK_Eject 0x1008FF2C /* Eject device (e.g. DVD) */ +#define XF86XK_ScreenSaver 0x1008FF2D /* Invoke screensaver */ +#define XF86XK_WWW 0x1008FF2E /* Invoke web browser */ +#define XF86XK_Sleep 0x1008FF2F /* Put system to sleep */ +#define XF86XK_Favorites 0x1008FF30 /* Show favorite locations */ +#define XF86XK_AudioPause 0x1008FF31 /* Pause audio playing */ +#define XF86XK_AudioMedia 0x1008FF32 /* Launch media collection app */ +#define XF86XK_MyComputer 0x1008FF33 /* Display "My Computer" window */ +#define XF86XK_VendorHome 0x1008FF34 /* Display vendor home web site */ +#define XF86XK_LightBulb 0x1008FF35 /* Light bulb keys exist */ +#define XF86XK_Shop 0x1008FF36 /* Display shopping web site */ +#define XF86XK_History 0x1008FF37 /* Show history of web surfing */ +#define XF86XK_OpenURL 0x1008FF38 /* Open selected URL */ +#define XF86XK_AddFavorite 0x1008FF39 /* Add URL to favorites list */ +#define XF86XK_HotLinks 0x1008FF3A /* Show "hot" links */ +#define XF86XK_BrightnessAdjust 0x1008FF3B /* Invoke brightness adj. UI */ +#define XF86XK_Finance 0x1008FF3C /* Display financial site */ +#define XF86XK_Community 0x1008FF3D /* Display user's community */ +#define XF86XK_AudioRewind 0x1008FF3E /* "rewind" audio track */ +#define XF86XK_BackForward 0x1008FF3F /* ??? */ +#define XF86XK_Launch0 0x1008FF40 /* Launch Application */ +#define XF86XK_Launch1 0x1008FF41 /* Launch Application */ +#define XF86XK_Launch2 0x1008FF42 /* Launch Application */ +#define XF86XK_Launch3 0x1008FF43 /* Launch Application */ +#define XF86XK_Launch4 0x1008FF44 /* Launch Application */ +#define XF86XK_Launch5 0x1008FF45 /* Launch Application */ +#define XF86XK_Launch6 0x1008FF46 /* Launch Application */ +#define XF86XK_Launch7 0x1008FF47 /* Launch Application */ +#define XF86XK_Launch8 0x1008FF48 /* Launch Application */ +#define XF86XK_Launch9 0x1008FF49 /* Launch Application */ +#define XF86XK_LaunchA 0x1008FF4A /* Launch Application */ +#define XF86XK_LaunchB 0x1008FF4B /* Launch Application */ +#define XF86XK_LaunchC 0x1008FF4C /* Launch Application */ +#define XF86XK_LaunchD 0x1008FF4D /* Launch Application */ +#define XF86XK_LaunchE 0x1008FF4E /* Launch Application */ +#define XF86XK_LaunchF 0x1008FF4F /* Launch Application */ + +#define XF86XK_ApplicationLeft 0x1008FF50 /* switch to application, left */ +#define XF86XK_ApplicationRight 0x1008FF51 /* switch to application, right*/ +#define XF86XK_Book 0x1008FF52 /* Launch bookreader */ +#define XF86XK_CD 0x1008FF53 /* Launch CD/DVD player */ +#define XF86XK_Calculater 0x1008FF54 /* Launch Calculater */ +#define XF86XK_Clear 0x1008FF55 /* Clear window, screen */ +#define XF86XK_Close 0x1008FF56 /* Close window */ +#define XF86XK_Copy 0x1008FF57 /* Copy selection */ +#define XF86XK_Cut 0x1008FF58 /* Cut selection */ +#define XF86XK_Display 0x1008FF59 /* Output switch key */ +#define XF86XK_DOS 0x1008FF5A /* Launch DOS (emulation) */ +#define XF86XK_Documents 0x1008FF5B /* Open documents window */ +#define XF86XK_Excel 0x1008FF5C /* Launch spread sheet */ +#define XF86XK_Explorer 0x1008FF5D /* Launch file explorer */ +#define XF86XK_Game 0x1008FF5E /* Launch game */ +#define XF86XK_Go 0x1008FF5F /* Go to URL */ +#define XF86XK_iTouch 0x1008FF60 /* Logitech iTouch- don't use */ +#define XF86XK_LogOff 0x1008FF61 /* Log off system */ +#define XF86XK_Market 0x1008FF62 /* ?? */ +#define XF86XK_Meeting 0x1008FF63 /* enter meeting in calendar */ +#define XF86XK_MenuKB 0x1008FF65 /* distinguish keyboard from PB */ +#define XF86XK_MenuPB 0x1008FF66 /* distinguish PB from keyboard */ +#define XF86XK_MySites 0x1008FF67 /* Favourites */ +#define XF86XK_New 0x1008FF68 /* New (folder, document... */ +#define XF86XK_News 0x1008FF69 /* News */ +#define XF86XK_OfficeHome 0x1008FF6A /* Office home (old Staroffice)*/ +#define XF86XK_Open 0x1008FF6B /* Open */ +#define XF86XK_Option 0x1008FF6C /* ?? */ +#define XF86XK_Paste 0x1008FF6D /* Paste */ +#define XF86XK_Phone 0x1008FF6E /* Launch phone; dial number */ +#define XF86XK_Q 0x1008FF70 /* Compaq's Q - don't use */ +#define XF86XK_Reply 0x1008FF72 /* Reply e.g., mail */ +#define XF86XK_Reload 0x1008FF73 /* Reload web page, file, etc. */ +#define XF86XK_RotateWindows 0x1008FF74 /* Rotate windows e.g. xrandr */ +#define XF86XK_RotationPB 0x1008FF75 /* don't use */ +#define XF86XK_RotationKB 0x1008FF76 /* don't use */ +#define XF86XK_Save 0x1008FF77 /* Save (file, document, state */ +#define XF86XK_ScrollUp 0x1008FF78 /* Scroll window/contents up */ +#define XF86XK_ScrollDown 0x1008FF79 /* Scrool window/contentd down */ +#define XF86XK_ScrollClick 0x1008FF7A /* Use XKB mousekeys instead */ +#define XF86XK_Send 0x1008FF7B /* Send mail, file, object */ +#define XF86XK_Spell 0x1008FF7C /* Spell checker */ +#define XF86XK_SplitScreen 0x1008FF7D /* Split window or screen */ +#define XF86XK_Support 0x1008FF7E /* Get support (??) */ +#define XF86XK_TaskPane 0x1008FF7F /* Show tasks */ +#define XF86XK_Terminal 0x1008FF80 /* Launch terminal emulator */ +#define XF86XK_Tools 0x1008FF81 /* toolbox of desktop/app. */ +#define XF86XK_Travel 0x1008FF82 /* ?? */ +#define XF86XK_UserPB 0x1008FF84 /* ?? */ +#define XF86XK_User1KB 0x1008FF85 /* ?? */ +#define XF86XK_User2KB 0x1008FF86 /* ?? */ +#define XF86XK_Video 0x1008FF87 /* Launch video player */ +#define XF86XK_WheelButton 0x1008FF88 /* button from a mouse wheel */ +#define XF86XK_Word 0x1008FF89 /* Launch word processor */ +#define XF86XK_Xfer 0x1008FF8A +#define XF86XK_ZoomIn 0x1008FF8B /* zoom in view, map, etc. */ +#define XF86XK_ZoomOut 0x1008FF8C /* zoom out view, map, etc. */ + +#define XF86XK_Away 0x1008FF8D /* mark yourself as away */ +#define XF86XK_Messenger 0x1008FF8E /* as in instant messaging */ +#define XF86XK_WebCam 0x1008FF8F /* Launch web camera app. */ +#define XF86XK_MailForward 0x1008FF90 /* Forward in mail */ +#define XF86XK_Pictures 0x1008FF91 /* Show pictures */ +#define XF86XK_Music 0x1008FF92 /* Launch music application */ + +#define XF86XK_Battery 0x1008FF93 /* Display battery information */ +#define XF86XK_Bluetooth 0x1008FF94 /* Enable/disable Bluetooth */ +#define XF86XK_WLAN 0x1008FF95 /* Enable/disable WLAN */ +#define XF86XK_UWB 0x1008FF96 /* Enable/disable UWB */ + +#define XF86XK_AudioForward 0x1008FF97 /* fast-forward audio track */ +#define XF86XK_AudioRepeat 0x1008FF98 /* toggle repeat mode */ +#define XF86XK_AudioRandomPlay 0x1008FF99 /* toggle shuffle mode */ +#define XF86XK_Subtitle 0x1008FF9A /* cycle through subtitle */ +#define XF86XK_AudioCycleTrack 0x1008FF9B /* cycle through audio tracks */ +#define XF86XK_CycleAngle 0x1008FF9C /* cycle through angles */ +#define XF86XK_FrameBack 0x1008FF9D /* video: go one frame back */ +#define XF86XK_FrameForward 0x1008FF9E /* video: go one frame forward */ +#define XF86XK_Time 0x1008FF9F /* display, or shows an entry for time seeking */ +#define XF86XK_Select 0x1008FFA0 /* Select button on joypads and remotes */ +#define XF86XK_View 0x1008FFA1 /* Show a view options/properties */ +#define XF86XK_TopMenu 0x1008FFA2 /* Go to a top-level menu in a video */ + +#define XF86XK_Red 0x1008FFA3 /* Red button */ +#define XF86XK_Green 0x1008FFA4 /* Green button */ +#define XF86XK_Yellow 0x1008FFA5 /* Yellow button */ +#define XF86XK_Blue 0x1008FFA6 /* Blue button */ + +#define XF86XK_Suspend 0x1008FFA7 /* Sleep to RAM */ +#define XF86XK_Hibernate 0x1008FFA8 /* Sleep to disk */ +#define XF86XK_TouchpadToggle 0x1008FFA9 /* Toggle between touchpad/trackstick */ +#define XF86XK_TouchpadOn 0x1008FFB0 /* The touchpad got switched on */ +#define XF86XK_TouchpadOff 0x1008FFB1 /* The touchpad got switched off */ + +#define XF86XK_AudioMicMute 0x1008FFB2 /* Mute the Mic from the system */ + +#define XF86XK_Keyboard 0x1008FFB3 /* User defined keyboard related action */ + +#define XF86XK_WWAN 0x1008FFB4 /* Toggle WWAN (LTE, UMTS, etc.) radio */ +#define XF86XK_RFKill 0x1008FFB5 /* Toggle radios on/off */ + +#define XF86XK_AudioPreset 0x1008FFB6 /* Select equalizer preset, e.g. theatre-mode */ + +#define XF86XK_RotationLockToggle 0x1008FFB7 /* Toggle screen rotation lock on/off */ + +/* Keys for special action keys (hot keys) */ +/* Virtual terminals on some operating systems */ +#define XF86XK_Switch_VT_1 0x1008FE01 +#define XF86XK_Switch_VT_2 0x1008FE02 +#define XF86XK_Switch_VT_3 0x1008FE03 +#define XF86XK_Switch_VT_4 0x1008FE04 +#define XF86XK_Switch_VT_5 0x1008FE05 +#define XF86XK_Switch_VT_6 0x1008FE06 +#define XF86XK_Switch_VT_7 0x1008FE07 +#define XF86XK_Switch_VT_8 0x1008FE08 +#define XF86XK_Switch_VT_9 0x1008FE09 +#define XF86XK_Switch_VT_10 0x1008FE0A +#define XF86XK_Switch_VT_11 0x1008FE0B +#define XF86XK_Switch_VT_12 0x1008FE0C + +#define XF86XK_Ungrab 0x1008FE20 /* force ungrab */ +#define XF86XK_ClearGrab 0x1008FE21 /* kill application with grab */ +#define XF86XK_Next_VMode 0x1008FE22 /* next video mode available */ +#define XF86XK_Prev_VMode 0x1008FE23 /* prev. video mode available */ +#define XF86XK_LogWindowTree 0x1008FE24 /* print window tree to log */ +#define XF86XK_LogGrabInfo 0x1008FE25 /* print all active grabs to log */ diff --git a/xlib/X11/ap_keysym.h b/xlib/X11/ap_keysym.h new file mode 100644 index 0000000..76cbde2 --- /dev/null +++ b/xlib/X11/ap_keysym.h @@ -0,0 +1,51 @@ +/****************************************************************** +Copyright 1987 by Apollo Computer Inc., Chelmsford, Massachusetts. +Copyright 1989 by Hewlett-Packard Company. + + All Rights Reserved + +Permission to use, duplicate, change, and distribute this software and +its documentation for any purpose and without fee is granted, provided +that the above copyright notice appear in such copy and that this +copyright notice appear in all supporting documentation, and that the +names of Apollo Computer Inc., the Hewlett-Packard Company, or the X +Consortium not be used in advertising or publicity pertaining to +distribution of the software without written prior permission. + +HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD +TO THIS SOFWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. Hewlett-Packard shall not be liable for errors +contained herein or direct, indirect, special, incidental or +consequential damages in connection with the furnishing, +performance, or use of this material. + +This software is not subject to any license of the American +Telephone and Telegraph Company or of the Regents of the +University of California. +******************************************************************/ + +#define apXK_LineDel 0x1000FF00 +#define apXK_CharDel 0x1000FF01 +#define apXK_Copy 0x1000FF02 +#define apXK_Cut 0x1000FF03 +#define apXK_Paste 0x1000FF04 +#define apXK_Move 0x1000FF05 +#define apXK_Grow 0x1000FF06 +#define apXK_Cmd 0x1000FF07 +#define apXK_Shell 0x1000FF08 +#define apXK_LeftBar 0x1000FF09 +#define apXK_RightBar 0x1000FF0A +#define apXK_LeftBox 0x1000FF0B +#define apXK_RightBox 0x1000FF0C +#define apXK_UpBox 0x1000FF0D +#define apXK_DownBox 0x1000FF0E +#define apXK_Pop 0x1000FF0F +#define apXK_Read 0x1000FF10 +#define apXK_Edit 0x1000FF11 +#define apXK_Save 0x1000FF12 +#define apXK_Exit 0x1000FF13 +#define apXK_Repeat 0x1000FF14 + +#define apXK_KP_parenleft 0x1000FFA8 +#define apXK_KP_parenright 0x1000FFA9 -- cgit v0.12 From 48a077dfdb3571e63dc917e03a4429b21609810c Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 14 Nov 2019 23:32:01 +0000 Subject: remove debug printf code --- win/tkWinPointer.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/win/tkWinPointer.c b/win/tkWinPointer.c index 726f663..2b8656b 100644 --- a/win/tkWinPointer.c +++ b/win/tkWinPointer.c @@ -364,13 +364,10 @@ void TkSetCursorPos( INPUT input; unsigned xscreen = (GetSystemMetrics(SM_CXSCREEN) - 1); unsigned yscreen = (GetSystemMetrics(SM_CYSCREEN) - 1); -printf("x = %d, y = %d\n",x,y); -printf("xscreen = %d, yscreen = %d\n",xscreen,yscreen); input.type = INPUT_MOUSE; input.mi.dx = (x * 65535 + xscreen/2) / xscreen; input.mi.dy = (y * 65535 + yscreen/2) / yscreen; -printf("input.mi.dx = %d, input.mi.dy = %d\n",input.mi.dx,input.mi.dy); input.mi.mouseData = 0; input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE; input.mi.time = 0; -- cgit v0.12 From fa4d52dc5b517526f33d2ea80f12a405a7a24328 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 14 Nov 2019 23:32:53 +0000 Subject: Fix again integer arithmetics in TkSetCursorPos(), see [69b48f427e] --- win/tkWinPointer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/win/tkWinPointer.c b/win/tkWinPointer.c index 2b8656b..e7e041f 100644 --- a/win/tkWinPointer.c +++ b/win/tkWinPointer.c @@ -362,8 +362,8 @@ void TkSetCursorPos( int y) { INPUT input; - unsigned xscreen = (GetSystemMetrics(SM_CXSCREEN) - 1); - unsigned yscreen = (GetSystemMetrics(SM_CYSCREEN) - 1); + int xscreen = (int)(GetSystemMetrics(SM_CXSCREEN) - 1); + int yscreen = (int)(GetSystemMetrics(SM_CYSCREEN) - 1); input.type = INPUT_MOUSE; input.mi.dx = (x * 65535 + xscreen/2) / xscreen; -- cgit v0.12 From cdca750ab797e44fcabca5f2c4f4f61b5a8db6a6 Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 15 Nov 2019 20:48:48 +0000 Subject: Fix [90d555e088]: In Catalina Apple's NSFontManager creates fonts with unwanted traits --- macosx/tkMacOSXFont.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index 153ce3b..37a9a98 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -176,6 +176,18 @@ FindNSFont( size = [defaultFont pointSize]; } nsFont = [fm fontWithFamily:family traits:traits weight:weight size:size]; + + /* + * A second bug in NSFontManager that Apple created for the Catalina OS + * causes requests as above to sometimes return fonts with additional + * traits that were not requested, even though fonts without those unwanted + * traits exist on the system. See bug [90d555e088]. As a workaround + * we ask the font manager to remove any unrequested traits. + */ + + if (nsFont) { + nsFont = [fm convertFont:nsFont toNotHaveTrait:~traits]; + } if (!nsFont) { NSArray *availableFamilies = [fm availableFontFamilies]; NSString *caseFamily = nil; @@ -395,12 +407,15 @@ TkpFontPkgInit( } TkInitFontAttributes(&fa); #if 0 + /* - * In macOS 10.15.1 Apple introduced a bug which caused the call below to - * return a font with the invalid familyName ".SF NSMono" instead of the - * valid familyName "NSMono". Calling [NSFont userFixedPitchFontOfSize:11] - * returns a font in the "Menlo" family which has a valid familyName. + * In macOS 10.15.1 Apple introduced a bug in NSFontManager which caused + * it to not recognize the familyName ".SF NSMono" which is the familyName + * of the default fixed pitch system fault on that system. See bug [855049e799]. + * As a workaround we call [NSFont userFixedPitchFontOfSize:11] instead. + * This returns a user font in the "Menlo" family. */ + nsFont = (NSFont*) CTFontCreateUIFontForLanguage(fixedPitch, 11, NULL); #else nsFont = [NSFont userFixedPitchFontOfSize:11]; -- cgit v0.12 From 7d9ab4e8bbc99150a6c6e1bba9913da381c45ddc Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 15 Nov 2019 21:52:17 +0000 Subject: Let's add some Emoji to the widget demo, but encoded in UTF-16 so Tcl 8.6.10 can handle it. Works at least on Windows. --- library/demos/unicodeout.tcl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/demos/unicodeout.tcl b/library/demos/unicodeout.tcl index faa9f90..a8b5bbb 100644 --- a/library/demos/unicodeout.tcl +++ b/library/demos/unicodeout.tcl @@ -131,6 +131,8 @@ addSample $w Japanese \ addSample $w Korean "\uB300\uD55C\uBBFC\uAD6D\uC758 \uD55C\uAE00" addSample $w Russian \ "\u0420\u0443\u0441\u0441\u043A\u0438\u0439 \u044F\u0437\u044B\u043A" +addSample $w Emoji \ + "\uD83D\uDE00\uD83D\uDCA9\uD83D\uDC4D\uD83C\uDDF3\uD83C\uDDF1" ## We're done processing, so change things back to normal running... destroy $w.wait -- cgit v0.12 From c500b0d754741b94324deccd875cc8f2d71f8bdf Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 16 Nov 2019 16:58:36 +0000 Subject: On macOS make DrawCharsInContext accept byte sequences which contain UTF-16 surrogates encoded as 3-byte UTF-8-ish subsequences, so the Emoji demo works. --- macosx/tkMacOSXFont.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index 153ce3b..5f3ea54 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -1112,7 +1112,28 @@ DrawCharsInContext( string = [[NSString alloc] initWithBytesNoCopy:(void*)source length:numBytes encoding:NSUTF8StringEncoding freeWhenDone:NO]; if (!string) { - return; + + /* + * The decoding might have failed because we got a fake UTF-8 byte + * array in which UTF-16 surrogates had been encoded using the UTF-8 + * algorithm, even though UTF-8 does not allow encoding surrogates. + * (When Tcl is compiled with TCL_UTF_MAX = 3 Tk uses this encoding + * internally.) We can attempt to decode the source using this + * encoding and see if Apple accepts the result as UTF-16. + */ + + const unichar *characters = ckalloc(numBytes*sizeof(unichar)); + const char *in = source; + unichar *out = (unichar *) characters; + while (in < source + numBytes) { + in += Tcl_UtfToUniChar(in, out++); + } + string = [[NSString alloc] initWithCharacters:characters + length:(out - characters)]; + ckfree(characters); + if (!string) { + return; + } } context = drawingContext.context; -- cgit v0.12 From 48cd8747a366cb72f8622bb65e6579499c6bf5a3 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 18 Nov 2019 00:31:48 +0000 Subject: Implement non-BMP unicode for macOS when TCL_UTF_MAX = 3 by encoding surrogates as 3-byte UTF-8-ish sequences. --- macosx/tkMacOSXClipboard.c | 35 ++++------ macosx/tkMacOSXFont.c | 156 +++++++++++++++++++++++++++++++++++++-------- macosx/tkMacOSXKeyEvent.c | 52 ++++++--------- macosx/tkMacOSXPrivate.h | 4 ++ 4 files changed, 166 insertions(+), 81 deletions(-) diff --git a/macosx/tkMacOSXClipboard.c b/macosx/tkMacOSXClipboard.c index 696b70e..a5f0ba1 100644 --- a/macosx/tkMacOSXClipboard.c +++ b/macosx/tkMacOSXClipboard.c @@ -35,10 +35,7 @@ static Tk_Window clipboardOwner = NULL; targetPtr->type == dispPtr->utf8Atom) { for (TkClipboardBuffer *cbPtr = targetPtr->firstBufferPtr; cbPtr; cbPtr = cbPtr->nextPtr) { - NSString *s = [[NSString alloc] initWithBytesNoCopy: - cbPtr->buffer length:cbPtr->length - encoding:NSUTF8StringEncoding freeWhenDone:NO]; - + NSString *s = TclUniToNSString(cbPtr->buffer, cbPtr->length); [string appendString:s]; [s release]; } @@ -126,11 +123,11 @@ TkSelGetSelection( int haveExternalClip = ([[NSPasteboard generalPasteboard] changeCount] != changeCount); + printf("TkSelGetSelection\n"); if (dispPtr && (haveExternalClip || dispPtr->clipboardActive) && selection == dispPtr->clipboardAtom && (target == XA_STRING || target == dispPtr->utf8Atom)) { NSString *string = nil; - NSString *clean; NSPasteboard *pb = [NSPasteboard generalPasteboard]; NSString *type = [pb availableTypeFromArray:[NSArray arrayWithObject: NSStringPboardType]]; @@ -139,25 +136,19 @@ TkSelGetSelection( string = [pb stringForType:type]; } if (string) { + int utfSize; + char *tclUni = NSStringToTclUni(string, &utfSize); + /* - * Replace all non-BMP characters by the replacement character 0xfffd. - * This is a workaround until Tcl supports TCL_UTF_MAX > 3. + * Re-encode the string using the encoding which is used in Tcl + * when TCL_UTF_MAX = 3. This replaces each UTF-16 surrogate with + * a 3-byte sequence generated using the UTF-8 algorithm. (Even + * though UTF-8 does not allow encoding surrogates, the algorithm + * does produce a 3-byte sequence.) */ - int i, j, len = [string length]; - CFRange all = CFRangeMake(0, len); - UniChar *buffer = ckalloc(len*sizeof(UniChar)); - CFStringGetCharacters((CFStringRef) string, all, buffer); - for (i = 0, j = 0 ; j < len ; i++, j++) { - if (CFStringIsSurrogateHighCharacter(buffer[j])) { - buffer[i] = 0xfffd; - j++; - } else { - buffer[i] = buffer[j]; - } - } - clean = (NSString *)CFStringCreateWithCharacters(NULL, buffer, i); - ckfree(buffer); - result = proc(clientData, interp, [clean UTF8String]); + + result = proc(clientData, interp, tclUni); + ckfree(tclUni); } } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index df7f770..8350908 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -101,6 +101,132 @@ static void DrawCharsInContext(Display *display, Drawable drawable, #pragma mark - #pragma mark Font Helpers: +/* + *--------------------------------------------------------------------------- + * + * NSStringFromTclUTF -- + * + * When Tcl is compiled with TCL_UTF_MAX = 3 (the default for 8.6) it cannot + * deal directly with UTF-8 encoded non-BMP characters, since their UTF-8 + * encoding requires 4 bytes. + * + * As a workaround, these versions of Tcl encode non-BMP characters as a string + * of length 6 in which the high and low UTF-16 surrogates have been encoded + * using the UTF-8 algorithm. The UTF-8 encoding does not allow encoding + * surrogates, so these 6-byte strings are not valid UTF-8, and hence Apple's + * NString class will refuse to instantiate an NSString from the 6-byte + * encoding. This function allows creating an NSString from a C-string which + * has been encoded using this scheme. + * + * Results: + * An NSString, which may be nil. + * + * Side effects: + * None. + *--------------------------------------------------------------------------- + */ + +MODULE_SCOPE NSString* +TclUniToNSString( + const char *source, + int numBytes) +{ + NSString *string = [[NSString alloc] initWithBytesNoCopy:(void *)source + length:numBytes + encoding:NSUTF8StringEncoding + freeWhenDone:NO]; + if (!string) { + const unichar *characters = ckalloc(numBytes*sizeof(unichar)); + const char *in = source; + unichar *out = (unichar *) characters; + while (in < source + numBytes) { + in += Tcl_UtfToUniChar(in, out++); + } + string = [[NSString alloc] initWithCharacters:characters + length:(out - characters)]; + ckfree(characters); + } + return string; +} + +/* + *--------------------------------------------------------------------------- + * + * TclUniAtIndex -- + * + * Write a sequence of bytes up to length 6 which is an encoding of a UTF-16 + * character in an NSString. Also record the unicode code point of the character. + * this may be a non-BMP character constructed by reading two surrogates from + * the NSString. + * + * Results: + * Returns the number of bytes written. + * + * Side effects: + * Bytes are written to the address uni and the unicode code point is written + * to the integer at address code. + * + */ + +MODULE_SCOPE int +TclUniAtIndex( + NSString *string, + int index, + char *uni, + unsigned int *code) +{ + char *ptr = uni; + UniChar uniChar = [string characterAtIndex: index]; + if (CFStringIsSurrogateHighCharacter(uniChar)) { + UniChar lowChar = [string characterAtIndex: ++index]; + *code = CFStringGetLongCharacterForSurrogatePair( + uniChar, lowChar); + ptr += Tcl_UniCharToUtf(uniChar, ptr); + ptr += Tcl_UniCharToUtf(lowChar, ptr); + return ptr - uni; + } else { + *code = (int) uniChar; + [[string substringWithRange: NSMakeRange(index, 1)] + getCString: uni + maxLength: XMaxTransChars + encoding: NSUTF8StringEncoding]; + return strlen(uni); + } +} + +/* + *--------------------------------------------------------------------------- + * + * NSStringToTclUni -- + * + * Encodes the unicode string represented by an NSString object using the + * special internal Tcl encoding used when TCL_UTF_MAX = 3. This encoding + * is similar to UTF-8 except that non-BMP characters are encoded as two + * successive 3-byte sequences which are constructed from UTF-16 surrogates + * by applying the UTF-8 algorithm. Even though the UTF-8 encoding does not + * allow encoding surrogates, the algorithm does produce a well-defined + * 3-byte sequence. + * + */ + +MODULE_SCOPE char* +NSStringToTclUni( + NSString *string, + int *numBytes) +{ + unsigned int code; + int i, length = [string length]; + char *ptr, *result = ckalloc(6*length + 1); + for (i = 0, ptr = result; i < length; i++) { + ptr += TclUniAtIndex(string, i, ptr, &code); + if (code > 0xffff){ + i++; + } + } + *ptr = '\0'; + return result; +} + #define GetNSFontTraitsFromTkFontAttributes(faPtr) \ ((faPtr)->weight == TK_FW_BOLD ? NSBoldFontMask : NSUnboldFontMask) | \ ((faPtr)->slant == TK_FS_ITALIC ? NSItalicFontMask : NSUnitalicFontMask) @@ -844,8 +970,7 @@ TkpMeasureCharsInContext( if (maxLength > 32767) { maxLength = 32767; } - string = [[NSString alloc] initWithBytesNoCopy:(void*)source - length:numBytes encoding:NSUTF8StringEncoding freeWhenDone:NO]; + string = TclUniToNSString((const char *)source, numBytes); if (!string) { length = 0; fit = rangeLength; @@ -1124,33 +1249,10 @@ DrawCharsInContext( !TkMacOSXSetupDrawingContext(drawable, gc, 1, &drawingContext)) { return; } - string = [[NSString alloc] initWithBytesNoCopy:(void*)source - length:numBytes encoding:NSUTF8StringEncoding freeWhenDone:NO]; + string = TclUniToNSString((const char *)source, numBytes); if (!string) { - - /* - * The decoding might have failed because we got a fake UTF-8 byte - * array in which UTF-16 surrogates had been encoded using the UTF-8 - * algorithm, even though UTF-8 does not allow encoding surrogates. - * (When Tcl is compiled with TCL_UTF_MAX = 3 Tk uses this encoding - * internally.) We can attempt to decode the source using this - * encoding and see if Apple accepts the result as UTF-16. - */ - - const unichar *characters = ckalloc(numBytes*sizeof(unichar)); - const char *in = source; - unichar *out = (unichar *) characters; - while (in < source + numBytes) { - in += Tcl_UtfToUniChar(in, out++); - } - string = [[NSString alloc] initWithCharacters:characters - length:(out - characters)]; - ckfree(characters); - if (!string) { - return; - } + return; } - context = drawingContext.context; fg = TkMacOSXCreateCGColor(gc, gc->foreground); attributes = [fontPtr->nsAttributes mutableCopy]; diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index 677f77e..025cccb 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -14,7 +14,7 @@ */ #include "tkMacOSXPrivate.h" -#include "tkMacOSXEvent.h" +#include "tkMacOSXInt.h" #include "tkMacOSXConstants.h" /* @@ -331,42 +331,30 @@ static unsigned isFunctionKey(unsigned int code); } /* - * NSString represents a non-BMP character as a string of length 2 where - * the first character is the high surrogate and the second character is - * the low surrogate. We could record this in the XEvent by setting the - * keycode to the unicode code point and setting the trans_chars to the - * 4-byte UTF-8 string. However, that will not help as long as TCL_UTF_MAX - * is set to 3. Until that changes, we just replace non-BMP characters by - * the "replacement character" U+FFFD. + * Next we generate an XEvent for each unicode character in our string. + * + * NSString uses UTF-16 internally, which means that a non-BMP character is + * represented by a sequence of two 16-bit "surrogates". In principle we + * could record this in the XEvent by setting the keycode to the 32-bit + * unicode code point and setting the trans_chars string to the 4-byte + * UTF-8 string for the non-BMP character. However, that will not work + * when TCL_UTF_MAX is set to 3, as is the case for Tcl 8.6. A workaround + * used internally by Tcl 8.6 is to encode each surrogate as a 3-byte + * sequence using the UTF-8 algorithm (ignoring the fact that the UTF-8 + * encoding specification does not allow encoding UTF-16 surrogates). + * This gives a 6-byte encoding of the non-BMP character which we write into + * the trans_chars field of the XEvent. */ for (i = 0; i < len; i++) { - UniChar nextChar = [str characterAtIndex: i]; - if (CFStringIsSurrogateHighCharacter(nextChar)) { -#if 0 - UniChar lowChar = [str characterAtIndex: ++i]; - xEvent.xkey.keycode = CFStringGetLongCharacterForSurrogatePair( - nextChar, lowChar); - xEvent.xkey.nbytes = TkUniCharToUtf(xEvent.xkey.keycode, - &xEvent.xkey.trans_chars); -#else + xEvent.xkey.nbytes = TclUniAtIndex(str, i, xEvent.xkey.trans_chars, + &xEvent.xkey.keycode); + if (xEvent.xkey.keycode > 0xffff){ i++; - xEvent.xkey.keycode = 0xfffd; - strcpy(xEvent.xkey.trans_chars, "\xef\xbf\xbd"); - xEvent.xkey.nbytes = strlen(xEvent.xkey.trans_chars); -#endif - } else { - xEvent.xkey.keycode = (int) nextChar; - [[str substringWithRange: NSMakeRange(i,1)] - getCString: xEvent.xkey.trans_chars - maxLength: XMaxTransChars encoding: NSUTF8StringEncoding]; - xEvent.xkey.nbytes = strlen(xEvent.xkey.trans_chars); } - xEvent.xany.type = KeyPress; - releaseCode = (UInt16) nextChar; - Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); + xEvent.xany.type = KeyPress; + Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); } - releaseCode = (UInt16) [str characterAtIndex: 0]; } @@ -642,7 +630,7 @@ XGrabKeyboard( Time time) { keyboardGrabWinPtr = Tk_IdToWindow(display, grab_window); - TkWindow *captureWinPtr = (TkWindow *) TkMacOSXGetCapture(); + TkWindow *captureWinPtr = (TkWindow *) TkpGetCapture(); if (keyboardGrabWinPtr && captureWinPtr) { NSWindow *w = TkMacOSXDrawableWindow(grab_window); diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 68bad41..a285bba 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -239,6 +239,10 @@ MODULE_SCOPE int TkMacOSXServices_Init(Tcl_Interp *interp); MODULE_SCOPE int TkMacOSXRegisterServiceWidgetObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); +MODULE_SCOPE int TclUniAtIndex(NSString *string, int index, char *uni, + unsigned int *code); +MODULE_SCOPE NSString* TclUniToNSString(const char *source, int numBytes); +MODULE_SCOPE char* NSStringToTclUni(NSString *string, int *numBytes); #pragma mark Private Objective-C Classes -- cgit v0.12 From 7035421b1ebd6767e98f5052a626955bee5d761a Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 18 Nov 2019 08:14:47 +0000 Subject: remove printf("TkSelGetSelection\n"); --- macosx/tkMacOSXClipboard.c | 3 +-- macosx/tkMacOSXFont.c | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/macosx/tkMacOSXClipboard.c b/macosx/tkMacOSXClipboard.c index a5f0ba1..bdcccf9 100644 --- a/macosx/tkMacOSXClipboard.c +++ b/macosx/tkMacOSXClipboard.c @@ -123,7 +123,6 @@ TkSelGetSelection( int haveExternalClip = ([[NSPasteboard generalPasteboard] changeCount] != changeCount); - printf("TkSelGetSelection\n"); if (dispPtr && (haveExternalClip || dispPtr->clipboardActive) && selection == dispPtr->clipboardAtom && (target == XA_STRING || target == dispPtr->utf8Atom)) { @@ -138,7 +137,7 @@ TkSelGetSelection( if (string) { int utfSize; char *tclUni = NSStringToTclUni(string, &utfSize); - + /* * Re-encode the string using the encoding which is used in Tcl * when TCL_UTF_MAX = 3. This replaces each UTF-16 surrogate with diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index 8350908..aeb90f8 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -109,7 +109,7 @@ static void DrawCharsInContext(Display *display, Drawable drawable, * When Tcl is compiled with TCL_UTF_MAX = 3 (the default for 8.6) it cannot * deal directly with UTF-8 encoded non-BMP characters, since their UTF-8 * encoding requires 4 bytes. - * + * * As a workaround, these versions of Tcl encode non-BMP characters as a string * of length 6 in which the high and low UTF-16 surrogates have been encoded * using the UTF-8 algorithm. The UTF-8 encoding does not allow encoding @@ -117,7 +117,7 @@ static void DrawCharsInContext(Display *display, Drawable drawable, * NString class will refuse to instantiate an NSString from the 6-byte * encoding. This function allows creating an NSString from a C-string which * has been encoded using this scheme. - * + * * Results: * An NSString, which may be nil. * @@ -302,7 +302,7 @@ FindNSFont( size = [defaultFont pointSize]; } nsFont = [fm fontWithFamily:family traits:traits weight:weight size:size]; - + /* * A second bug in NSFontManager that Apple created for the Catalina OS * causes requests as above to sometimes return fonts with additional -- cgit v0.12 From 6e5b062650d937a3a1c7af3bf112fe61d54d6a78 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 18 Nov 2019 15:05:55 +0000 Subject: Edit comments, add tests for NULL pointers. --- macosx/tkMacOSXClipboard.c | 11 ++++++----- macosx/tkMacOSXFont.c | 42 +++++++++++++++++++++++++++++------------- macosx/tkMacOSXPrivate.h | 2 +- 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/macosx/tkMacOSXClipboard.c b/macosx/tkMacOSXClipboard.c index bdcccf9..db45428 100644 --- a/macosx/tkMacOSXClipboard.c +++ b/macosx/tkMacOSXClipboard.c @@ -135,19 +135,20 @@ TkSelGetSelection( string = [pb stringForType:type]; } if (string) { - int utfSize; - char *tclUni = NSStringToTclUni(string, &utfSize); /* - * Re-encode the string using the encoding which is used in Tcl + * Encode the string using the encoding which is used in Tcl * when TCL_UTF_MAX = 3. This replaces each UTF-16 surrogate with * a 3-byte sequence generated using the UTF-8 algorithm. (Even * though UTF-8 does not allow encoding surrogates, the algorithm * does produce a 3-byte sequence.) */ - result = proc(clientData, interp, tclUni); - ckfree(tclUni); + char *bytes = NSStringToTclUni(string, NULL); + result = proc(clientData, interp, bytes); + if (bytes) { + ckfree(bytes); + } } } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index aeb90f8..9b2d11c 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -104,7 +104,7 @@ static void DrawCharsInContext(Display *display, Drawable drawable, /* *--------------------------------------------------------------------------- * - * NSStringFromTclUTF -- + * TclUniToNSString -- * * When Tcl is compiled with TCL_UTF_MAX = 3 (the default for 8.6) it cannot * deal directly with UTF-8 encoded non-BMP characters, since their UTF-8 @@ -163,8 +163,9 @@ TclUniToNSString( * Returns the number of bytes written. * * Side effects: - * Bytes are written to the address uni and the unicode code point is written - * to the integer at address code. + * Bytes are written to the char array referenced by the pointer uni and + * the unicode code point is written to the integer referenced by the + * pointer code. * */ @@ -199,14 +200,22 @@ TclUniAtIndex( * * NSStringToTclUni -- * - * Encodes the unicode string represented by an NSString object using the - * special internal Tcl encoding used when TCL_UTF_MAX = 3. This encoding + * Encodes the unicode string represented by an NSString object with the + * internal encoding that Tcl uses when TCL_UTF_MAX = 3. This encoding * is similar to UTF-8 except that non-BMP characters are encoded as two * successive 3-byte sequences which are constructed from UTF-16 surrogates * by applying the UTF-8 algorithm. Even though the UTF-8 encoding does not * allow encoding surrogates, the algorithm does produce a well-defined * 3-byte sequence. * + * Results: + * Returns a pointer to a null-terminated byte array which encodes the + * NSString. + * + * Side effects: + * Memory is allocated to hold the byte array, which must be freed with + * ckalloc. If the pointer numBytes is not NULL the number of non-null + * bytes written to the array is stored in the integer it references. */ MODULE_SCOPE char* @@ -215,16 +224,23 @@ NSStringToTclUni( int *numBytes) { unsigned int code; - int i, length = [string length]; - char *ptr, *result = ckalloc(6*length + 1); - for (i = 0, ptr = result; i < length; i++) { - ptr += TclUniAtIndex(string, i, ptr, &code); - if (code > 0xffff){ - i++; + int i; + char *ptr, *bytes = ckalloc(6*[string length] + 1); + + ptr = bytes; + if (ptr) { + for (i = 0; i < [string length]; i++) { + ptr += TclUniAtIndex(string, i, ptr, &code); + if (code > 0xffff){ + i++; + } } + *ptr = '\0'; + } + if (numBytes) { + *numBytes = ptr - bytes; } - *ptr = '\0'; - return result; + return bytes; } #define GetNSFontTraitsFromTkFontAttributes(faPtr) \ diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index a285bba..9417b62 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -239,9 +239,9 @@ MODULE_SCOPE int TkMacOSXServices_Init(Tcl_Interp *interp); MODULE_SCOPE int TkMacOSXRegisterServiceWidgetObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); +MODULE_SCOPE NSString* TclUniToNSString(const char *source, int numBytes); MODULE_SCOPE int TclUniAtIndex(NSString *string, int index, char *uni, unsigned int *code); -MODULE_SCOPE NSString* TclUniToNSString(const char *source, int numBytes); MODULE_SCOPE char* NSStringToTclUni(NSString *string, int *numBytes); #pragma mark Private Objective-C Classes -- cgit v0.12 From f3e045cc474203fdfb1a77892eadfba33275509c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 18 Nov 2019 19:48:33 +0000 Subject: Restrict Emoji in demo for win32 platform only, since on other platforms it's not guaranteed to work yet --- library/demos/unicodeout.tcl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/demos/unicodeout.tcl b/library/demos/unicodeout.tcl index a8b5bbb..836d59d 100644 --- a/library/demos/unicodeout.tcl +++ b/library/demos/unicodeout.tcl @@ -131,8 +131,10 @@ addSample $w Japanese \ addSample $w Korean "\uB300\uD55C\uBBFC\uAD6D\uC758 \uD55C\uAE00" addSample $w Russian \ "\u0420\u0443\u0441\u0441\u043A\u0438\u0439 \u044F\u0437\u044B\u043A" -addSample $w Emoji \ - "\uD83D\uDE00\uD83D\uDCA9\uD83D\uDC4D\uD83C\uDDF3\uD83C\uDDF1" +if {[tk windowingsystem] eq "win32"} { + addSample $w Emoji \ + "\uD83D\uDE00\uD83D\uDCA9\uD83D\uDC4D\uD83C\uDDF3\uD83C\uDDF1" +} ## We're done processing, so change things back to normal running... destroy $w.wait -- cgit v0.12 From 8974b47b859c48701323a72dab851fe81a8cb0d6 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 19 Nov 2019 00:46:50 +0000 Subject: Correct some errors revealed by building on macOS 10.6 --- macosx/tkMacOSXDraw.c | 2 +- macosx/tkMacOSXKeyEvent.c | 4 ++-- macosx/ttkMacOSXTheme.c | 17 +++++++++-------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index f19198d..1bf2572 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -503,7 +503,7 @@ TkMacOSXGetNSImageWithTkImage( { Pixmap pixmap; NSImage *nsImage; - if (width == 0 | height == 0) { + if (width == 0 || height == 0) { return nsImage = [[NSImage alloc] initWithSize:NSMakeSize(0,0)]; } pixmap = Tk_GetPixmap(display, None, width, height, 0); diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index 677f77e..1aa9b73 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -293,7 +293,7 @@ static unsigned isFunctionKey(unsigned int code); NSString *str; str = ([aString isKindOfClass: [NSAttributedString class]]) ? - str = [aString string] : aString; + [aString string] : aString; len = [str length]; if (NS_KEYLOG) { @@ -396,7 +396,7 @@ static unsigned isFunctionKey(unsigned int code); NSString *str; str = ([aString isKindOfClass: [NSAttributedString class]]) ? - str = [aString string] : aString; + [aString string] : aString; if (focusWin) { diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index 952aa20..7e8377e 100644 --- a/macosx/ttkMacOSXTheme.c +++ b/macosx/ttkMacOSXTheme.c @@ -1409,8 +1409,10 @@ static void ButtonElementDraw( } else if (info.kind == kThemePushButton && (state & TTK_STATE_PRESSED)) { bounds.size.height += 2; - GradientFillRoundedRectangle(dc.context, bounds, 4, - pressedPushButtonGradient, 2); + if ([NSApp macMinorVersion] > 8) { + GradientFillRoundedRectangle(dc.context, bounds, 4, + pressedPushButtonGradient, 2); + } } else { /* @@ -1859,18 +1861,17 @@ static void ComboboxElementDraw( BEGIN_DRAWING(d) bounds.origin.y += 1; if (TkMacOSXInDarkMode(tkwin)) { - bounds.size.height += 1; + bounds.size.height += 1; DrawDarkButton(bounds, info.kind, state, dc.context); - } else if ([NSApp macMinorVersion] > 8) { - if ((state & TTK_STATE_BACKGROUND) && - !(state & TTK_STATE_DISABLED)) { + } else if ([NSApp macMinorVersion] > 8) { + if ((state & TTK_STATE_BACKGROUND) && + !(state & TTK_STATE_DISABLED)) { NSColor *background = [NSColor textBackgroundColor]; CGRect innerBounds = CGRectInset(bounds, 1, 2); SolidFillRoundedRectangle(dc.context, innerBounds, 4, background); } - ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, - NULL); } + ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL); END_DRAWING } -- cgit v0.12 From 40d3397c7c92aa2d658346d57d8c0195cb06f1c8 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 19 Nov 2019 04:30:26 +0000 Subject: Prevent crashes on macOS caused by calling TheWorldHasChanged from inside [NSView drawRect] --- generic/tkFont.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/generic/tkFont.c b/generic/tkFont.c index 86fdd87..156ebf3 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -13,7 +13,9 @@ #include "tkInt.h" #include "tkFont.h" - +#if defined(MAC_OSX_TK) +#include "tkMacOSXInt.h" +#endif /* * The following structure is used to keep track of all the fonts that exist * in the current application. It must be stored in the TkMainInfo for the @@ -872,7 +874,18 @@ TheWorldHasChanged( ClientData clientData) /* Info about application's fonts. */ { TkFontInfo *fiPtr = clientData; +#if defined(MAC_OSX_TK) + /* + * On macOS it is catastrophic to recompute all widgets while the + * [NSView drawRect] method is drawing. The best that we can do in + * that situation is to abort the recomputation and hope for the best. + */ + + if (TkpAppIsDrawing()) { + return; + } +#endif fiPtr->updatePending = 0; RecomputeWidgets(fiPtr->mainPtr->winPtr); } -- cgit v0.12 From ac36024031479affd0b2b5ada200d04659b61bdc Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 19 Nov 2019 10:35:52 +0000 Subject: Use correct Emoji representation when running with Tcl 8.7. Works on X11 then! --- library/demos/unicodeout.tcl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/demos/unicodeout.tcl b/library/demos/unicodeout.tcl index 811d210..f7dfc77 100644 --- a/library/demos/unicodeout.tcl +++ b/library/demos/unicodeout.tcl @@ -131,7 +131,10 @@ addSample $w Japanese \ addSample $w Korean "\uB300\uD55C\uBBFC\uAD6D\uC758 \uD55C\uAE00" addSample $w Russian \ "\u0420\u0443\u0441\u0441\u043A\u0438\u0439 \u044F\u0437\u044B\u043A" -if {[tk windowingsystem] ne "x11"} { +if {[package vsatisfies [package provide Tcl] 8.7-]} { + addSample $w Emoji \ + "\U1F600\U1F4A9\U1F44D\U1F1F3\U1F1F1" +} elseif {[tk windowingsystem] ne "x11"} { addSample $w Emoji \ "\uD83D\uDE00\uD83D\uDCA9\uD83D\uDC4D\uD83C\uDDF3\uD83C\uDDF1" } -- cgit v0.12 From b0c0fd5b5c9aa88e74e5a954d9f86423b434d606 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 19 Nov 2019 15:31:13 +0000 Subject: Experiment: See if this is enough to make Emoji work with Xft on X11 --- unix/tkUnixRFont.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index 10e5aca..31b28c5 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -65,6 +65,14 @@ static Tcl_ThreadDataKey dataKey; #define TCL_CFGVAL_ENCODING "ascii" #endif +static int utf8ToUcs4(const char *source, FcChar32 *c, int numBytes) +{ + if (numBytes >= 6) { + return TkUtfToUniChar(source, (int *)c); + } + return FcUtf8ToUcs4((const FcChar8 *)source, c, numBytes); +} + void TkpFontPkgInit( TkMainInfo *mainPtr) /* The application being created. */ @@ -894,7 +902,7 @@ Tk_DrawChars( XftFont *ftFont; FcChar32 c; - clen = FcUtf8ToUcs4((FcChar8 *) source, &c, numBytes); + clen = utf8ToUcs4(source, &c, numBytes); if (clen <= 0) { /* * This should not happen, but it can. @@ -1034,7 +1042,7 @@ TkDrawAngledChars( XftFont *ftFont; FcChar32 c; - clen = FcUtf8ToUcs4((FcChar8 *) source, &c, numBytes); + clen = utf8ToUcs4(source, &c, numBytes); if (clen <= 0) { /* * This should not happen, but it can. @@ -1138,7 +1146,7 @@ TkDrawAngledChars( XftFont *ftFont, *ft0Font; FcChar32 c; - clen = FcUtf8ToUcs4((FcChar8 *) source, &c, numBytes); + clen = utf8ToUcs4(source, &c, numBytes); if (clen <= 0) { /* * This should not happen, but it can. -- cgit v0.12 From 9971a2a45b94e84f02ff3f66e707986254ff08df Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 19 Nov 2019 15:52:10 +0000 Subject: Specific test for xft in widget demo --- library/demos/unicodeout.tcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/demos/unicodeout.tcl b/library/demos/unicodeout.tcl index f7dfc77..b3c5fd0 100644 --- a/library/demos/unicodeout.tcl +++ b/library/demos/unicodeout.tcl @@ -134,7 +134,7 @@ addSample $w Russian \ if {[package vsatisfies [package provide Tcl] 8.7-]} { addSample $w Emoji \ "\U1F600\U1F4A9\U1F44D\U1F1F3\U1F1F1" -} elseif {[tk windowingsystem] ne "x11"} { +} elseif {([tk windowingsystem] ne "x11") || (![catch {tk::pkgconfig get fontsystem} fs] && ($fs eq "xft"))} { addSample $w Emoji \ "\uD83D\uDE00\uD83D\uDCA9\uD83D\uDC4D\uD83C\uDDF3\uD83C\uDDF1" } -- cgit v0.12 From db72a5fae465ad42ecec38478453a70cb8817215 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 22 Nov 2019 08:39:41 +0000 Subject: Update rules.vc to latest version --- win/rules.vc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/win/rules.vc b/win/rules.vc index cf80c91..2061e9b 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -24,7 +24,7 @@ _RULES_VC = 1 # For modifications that are not backward-compatible, you *must* change # the major version. RULES_VERSION_MAJOR = 1 -RULES_VERSION_MINOR = 4 +RULES_VERSION_MINOR = 5 # The PROJECT macro must be defined by parent makefile. !if "$(PROJECT)" == "" @@ -985,6 +985,19 @@ VERSION = $(DOTVERSION:.=) !endif # $(DOING_TCL) ... etc. +# Windows RC files have 3 version components. Ensure this irrespective +# of how many components the package has specified. Basically, ensure +# minimum 4 components by appending 4 0's and then pick out the first 4. +# Also take care of the fact that DOTVERSION may have "a" or "b" instead +# of "." separating the version components. +DOTSEPARATED=$(DOTVERSION:a=.) +DOTSEPARATED=$(DOTSEPARATED:b=.) +!if [echo RCCOMMAVERSION = \> versions.vc] \ + || [for /f "tokens=1,2,3,4,5* delims=." %a in ("$(DOTSEPARATED).0.0.0.0") do echo %a,%b,%c,%d >> versions.vc] +!error *** Could not generate RCCOMMAVERSION *** +!endif +!include versions.vc + ################################################################ # 10. Construct output directory and file paths # Figure-out how to name our intermediate and output directories. @@ -1508,7 +1521,7 @@ GUIEXECMD = $(link32) $(guilflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs) RESCMD = $(rc32) -fo $@ -r -i "$(GENERICDIR)" -i "$(TMP_DIR)" \ $(TCL_INCLUDES) \ /DDEBUG=$(DEBUG) -d UNCHECKED=$(UNCHECKED) \ - /DCOMMAVERSION=$(DOTVERSION:.=,),0 \ + /DCOMMAVERSION=$(RCCOMMAVERSION) \ /DDOTVERSION=\"$(DOTVERSION)\" \ /DVERSION=\"$(VERSION)\" \ /DSUFX=\"$(SUFX)\" \ -- cgit v0.12 From d81b8c045e4acc732a1a1370c8bc7b8c2bfcfc46 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 22 Nov 2019 08:41:14 +0000 Subject: Update rules.vc --- win/rules.vc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/win/rules.vc b/win/rules.vc index 2b11b01..50911d4 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -24,7 +24,7 @@ _RULES_VC = 1 # For modifications that are not backward-compatible, you *must* change # the major version. RULES_VERSION_MAJOR = 1 -RULES_VERSION_MINOR = 4 +RULES_VERSION_MINOR = 5 # The PROJECT macro must be defined by parent makefile. !if "$(PROJECT)" == "" @@ -976,6 +976,19 @@ VERSION = $(DOTVERSION:.=) !endif # $(DOING_TCL) ... etc. +# Windows RC files have 3 version components. Ensure this irrespective +# of how many components the package has specified. Basically, ensure +# minimum 4 components by appending 4 0's and then pick out the first 4. +# Also take care of the fact that DOTVERSION may have "a" or "b" instead +# of "." separating the version components. +DOTSEPARATED=$(DOTVERSION:a=.) +DOTSEPARATED=$(DOTSEPARATED:b=.) +!if [echo RCCOMMAVERSION = \> versions.vc] \ + || [for /f "tokens=1,2,3,4,5* delims=." %a in ("$(DOTSEPARATED).0.0.0.0") do echo %a,%b,%c,%d >> versions.vc] +!error *** Could not generate RCCOMMAVERSION *** +!endif +!include versions.vc + ################################################################ # 10. Construct output directory and file paths # Figure-out how to name our intermediate and output directories. @@ -1490,7 +1503,7 @@ GUIEXECMD = $(link32) $(guilflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs) RESCMD = $(rc32) -fo $@ -r -i "$(GENERICDIR)" -i "$(TMP_DIR)" \ $(TCL_INCLUDES) \ /DDEBUG=$(DEBUG) -d UNCHECKED=$(UNCHECKED) \ - /DCOMMAVERSION=$(DOTVERSION:.=,),0 \ + /DCOMMAVERSION=$(RCCOMMAVERSION) \ /DDOTVERSION=\"$(DOTVERSION)\" \ /DVERSION=\"$(VERSION)\" \ /DSUFX=\"$(SUFX:t=)\" \ -- cgit v0.12