Tk Source Code

Check-in [466c3287]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Test fix for 1ba71a86bb, so key release events fire at the correct point
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | mac-keyrelease-test
Files: files | file ages | folders
SHA3-256:466c328713f22d0fcde6a070b82ab19381fa901e9dafedc16775c5ec74517fcb
User & Date: kevin_walzer 2018-08-13 02:06:48
Context
2018-08-13
02:20
Clean up, remove commented-out code Closed-Leaf check-in: ec81d802 user: kevin_walzer tags: mac-keyrelease-test
02:06
Test fix for 1ba71a86bb, so key release events fire at the correct point check-in: 466c3287 user: kevin_walzer tags: mac-keyrelease-test
2018-08-12
14:54
Merging fix for 1875c1f30f, a84b20edd check-in: 26a029b4 user: kevin_walzer tags: core-8-6-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to macosx/tkMacOSXKeyEvent.c.

37
38
39
40
41
42
43



44
45
46
47
48
49
50
..
64
65
66
67
68
69
70
71
72
73
74
75
76




77
78
79
80
81
82
83
...
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
...
258
259
260
261
262
263
264

265
266
267
268
269
270
271

272
273
274
275
276
277
278
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);





#pragma mark TKApplication(TKKeyEvent)

@implementation TKApplication(TKKeyEvent)

- (NSEvent *) tkProcessKeyEvent: (NSEvent *) theEvent
{
................................................................................
      {
        nsEvArray = [[NSMutableArray alloc] initWithCapacity: 1];
        processingCompose = NO;
      }

    switch (type) {
    case NSKeyUp:
      if (finishedCompose)
        {
          // if we were composing, swallow the last release since we already sent
          finishedCompose = NO;
          return theEvent;
        }




    case NSKeyDown:
	repeat = [theEvent isARepeat];
	characters = [theEvent characters];
	charactersIgnoringModifiers = [theEvent charactersIgnoringModifiers];
        len = [charactersIgnoringModifiers length];
    case NSFlagsChanged:
	modifiers = [theEvent modifierFlags];
................................................................................
              /*
               * Set keycode (which was zero) to the changed modifier
               */

              xEvent.xkey.keycode = (modifiers ^ savedModifiers);
            } else {
              if (type == NSKeyUp || repeat) {
                xEvent.xany.type = KeyRelease;
              } else {
                xEvent.xany.type = KeyPress;
              }

              /* For command key, take input manager's word so things
                 like dvorak / qwerty layout work. */
              if ((modifiers & NSCommandKeyMask) == NSCommandKeyMask
................................................................................
    {
      xEvent.xkey.keycode = (UInt16) [aString characterAtIndex: i];
      [[aString 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;

      Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);

      xEvent.xany.type = KeyRelease;
      xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
      Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
      xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
    }

}


/* <NSTextInput>: inserts display of composing characters */
- (void)setMarkedText: (id)aString selectedRange: (NSRange)selRange
{
  NSString *str = [aString respondsToSelector: @selector (string)] ?







>
>
>







 







|
|
|
|
|
|
>
>
>
>







 







|







 







>


|
|
|
|

>







37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
..
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
...
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
...
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
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);

unsigned short releaseCode;
NSString *releaseChar;


#pragma mark TKApplication(TKKeyEvent)

@implementation TKApplication(TKKeyEvent)

- (NSEvent *) tkProcessKeyEvent: (NSEvent *) theEvent
{
................................................................................
      {
        nsEvArray = [[NSMutableArray alloc] initWithCapacity: 1];
        processingCompose = NO;
      }

    switch (type) {
    case NSKeyUp:
	
	//fix for 1ba71a86bb: key release firing on key press
	w = [theEvent window];       
	XEvent xEvent;
	setupXEvent(&xEvent, w, 0);
	TkWindow *winPtr = TkMacOSXGetTkWindow(w);
	Tk_Window tkwin = (Tk_Window) winPtr;
	xEvent.xany.type = KeyRelease;
	xEvent.xkey.keycode = releaseCode;
	xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
    case NSKeyDown:
	repeat = [theEvent isARepeat];
	characters = [theEvent characters];
	charactersIgnoringModifiers = [theEvent charactersIgnoringModifiers];
        len = [charactersIgnoringModifiers length];
    case NSFlagsChanged:
	modifiers = [theEvent modifierFlags];
................................................................................
              /*
               * Set keycode (which was zero) to the changed modifier
               */

              xEvent.xkey.keycode = (modifiers ^ savedModifiers);
            } else {
              if (type == NSKeyUp || repeat) {
		  xEvent.xany.type = KeyRelease;
              } else {
                xEvent.xany.type = KeyPress;
              }

              /* For command key, take input manager's word so things
                 like dvorak / qwerty layout work. */
              if ((modifiers & NSCommandKeyMask) == NSCommandKeyMask
................................................................................
    {
      xEvent.xkey.keycode = (UInt16) [aString characterAtIndex: i];
      [[aString 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) [aString characterAtIndex: 0];
      Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);

      // xEvent.xany.type = KeyRelease;
      // xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
      // Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
      // xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
    }
    releaseCode =  (UInt16) [aString characterAtIndex: 0];
}


/* <NSTextInput>: inserts display of composing characters */
- (void)setMarkedText: (id)aString selectedRange: (NSRange)selRange
{
  NSString *str = [aString respondsToSelector: @selector (string)] ?