blob: d8d71d74f2fb6d37e1d55030442c12f948383d45 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
/*
* tkMacOSXEvent.c --
*
* This file contains the basic Mac OS X Event handling routines.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* RCS: @(#) $Id: tkMacOSXEvent.c,v 1.27 2009/07/06 20:29:21 dkf Exp $
*/
#include "tkMacOSXPrivate.h"
#include "tkMacOSXEvent.h"
#include "tkMacOSXDebug.h"
#pragma mark TKApplication(TKEvent)
enum {
NSWindowWillMoveEventType = 20
};
@implementation TKApplication(TKEvent)
/* TODO: replace by +[addLocalMonitorForEventsMatchingMask ? */
- (NSEvent *) tkProcessEvent: (NSEvent *) theEvent
{
#ifdef TK_MAC_DEBUG_EVENTS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent);
#endif
NSEvent *processedEvent = theEvent;
NSEventType type = [theEvent type];
NSInteger subtype;
NSUInteger flags;
switch ((NSInteger)type) {
case NSAppKitDefined:
subtype = [theEvent subtype];
switch (subtype) {
case NSApplicationActivatedEventType:
break;
case NSApplicationDeactivatedEventType:
break;
case NSWindowExposedEventType:
case NSScreenChangedEventType:
break;
case NSWindowMovedEventType:
break;
case NSWindowWillMoveEventType:
break;
default:
break;
}
break;
case NSKeyUp:
case NSKeyDown:
case NSFlagsChanged:
flags = [theEvent modifierFlags];
processedEvent = [self tkProcessKeyEvent:theEvent];
break;
case NSLeftMouseDown:
case NSLeftMouseUp:
case NSRightMouseDown:
case NSRightMouseUp:
case NSLeftMouseDragged:
case NSRightMouseDragged:
case NSMouseMoved:
case NSMouseEntered:
case NSMouseExited:
case NSScrollWheel:
case NSOtherMouseDown:
case NSOtherMouseUp:
case NSOtherMouseDragged:
case NSTabletPoint:
case NSTabletProximity:
processedEvent = [self tkProcessMouseEvent:theEvent];
break;
#if 0
case NSSystemDefined:
subtype = [theEvent subtype];
break;
case NSApplicationDefined: {
id win;
win = [theEvent window];
break;
}
case NSCursorUpdate:
break;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
case NSEventTypeGesture:
case NSEventTypeMagnify:
case NSEventTypeRotate:
case NSEventTypeSwipe:
case NSEventTypeBeginGesture:
case NSEventTypeEndGesture:
break;
#endif
#endif
default:
break;
}
return processedEvent;
}
@end
#pragma mark -
/*
*----------------------------------------------------------------------
*
* TkMacOSXFlushWindows --
*
* This routine flushes all the windows of the application. It is
* called by XSync().
*
* Results:
* None.
*
* Side effects:
* Flushes all Carbon windows
*
*----------------------------------------------------------------------
*/
MODULE_SCOPE void
TkMacOSXFlushWindows(void)
{
NSInteger windowCount;
NSInteger *windowNumbers;
NSCountWindows(&windowCount);
if(windowCount) {
windowNumbers = ckalloc(windowCount * sizeof(NSInteger));
NSWindowList(windowCount, windowNumbers);
for (NSInteger index = 0; index < windowCount; index++) {
NSWindow *w = [NSApp windowWithWindowNumber:windowNumbers[index]];
if (TkMacOSXGetXWindow(w)) {
[w flushWindow];
}
}
ckfree(windowNumbers);
}
}
/*
* Local Variables:
* mode: objc
* c-basic-offset: 4
* fill-column: 79
* coding: utf-8
* End:
*/
|