mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 12:00:52 +00:00
Tracking rect fixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3980 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a250c74c59
commit
2b273903c4
7 changed files with 399 additions and 362 deletions
|
@ -33,32 +33,36 @@
|
|||
|
||||
@interface GSTrackingRect : NSObject <NSCoding>
|
||||
{
|
||||
// Attributes
|
||||
NSRect rectangle;
|
||||
NSTrackingRectTag tag;
|
||||
id owner;
|
||||
void *user_data;
|
||||
BOOL inside;
|
||||
// Attributes
|
||||
NSRect rectangle;
|
||||
NSTrackingRectTag tag;
|
||||
id owner;
|
||||
void *user_data;
|
||||
BOOL inside;
|
||||
BOOL isValid;
|
||||
}
|
||||
|
||||
// Instance methods
|
||||
- initWithRect:(NSRect)aRect
|
||||
tag:(NSTrackingRectTag)aTag
|
||||
owner:anObject
|
||||
userData:(void *)theData
|
||||
inside:(BOOL)flag;
|
||||
- initWithRect: (NSRect)aRect
|
||||
tag: (NSTrackingRectTag)aTag
|
||||
owner: anObject
|
||||
userData: (void *)theData
|
||||
inside: (BOOL)flag;
|
||||
|
||||
- (NSRect)rectangle;
|
||||
- (NSTrackingRectTag)tag;
|
||||
- (NSRect) rectangle;
|
||||
- (NSTrackingRectTag) tag;
|
||||
- owner;
|
||||
- (void *)userData;
|
||||
- (BOOL)inside;
|
||||
- (void*) userData;
|
||||
- (BOOL) inside;
|
||||
|
||||
- (BOOL) isValid;
|
||||
- (void) invalidate;
|
||||
|
||||
//
|
||||
// NSCoding protocol
|
||||
//
|
||||
- (void)encodeWithCoder:aCoder;
|
||||
- initWithCoder:aDecoder;
|
||||
- (void) encodeWithCoder: aCoder;
|
||||
- initWithCoder: aDecoder;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ extern NSString *NSEventTrackingRunLoopMode;
|
|||
BOOL app_should_quit;
|
||||
BOOL app_is_active;
|
||||
BOOL app_is_hidden;
|
||||
BOOL unhide_on_activation;
|
||||
BOOL windows_need_update;
|
||||
NSImage *app_icon;
|
||||
|
||||
|
|
|
@ -34,13 +34,12 @@
|
|||
//
|
||||
// Class methods
|
||||
//
|
||||
+ (void)initialize
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [GSTrackingRect class])
|
||||
{
|
||||
// Initial version
|
||||
[self setVersion:1];
|
||||
}
|
||||
if (self == [GSTrackingRect class])
|
||||
{
|
||||
[self setVersion: 1];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -49,19 +48,20 @@
|
|||
//
|
||||
// Initialization
|
||||
//
|
||||
- initWithRect:(NSRect)aRect
|
||||
tag:(NSTrackingRectTag)aTag
|
||||
owner:anObject
|
||||
userData:(void *)theData
|
||||
inside:(BOOL)flag
|
||||
- initWithRect: (NSRect)aRect
|
||||
tag: (NSTrackingRectTag)aTag
|
||||
owner: anObject
|
||||
userData: (void *)theData
|
||||
inside: (BOOL)flag
|
||||
{
|
||||
rectangle = aRect;
|
||||
tag = aTag;
|
||||
owner = anObject;
|
||||
[owner retain];
|
||||
user_data = theData;
|
||||
inside = flag;
|
||||
return self;
|
||||
rectangle = aRect;
|
||||
tag = aTag;
|
||||
owner = anObject;
|
||||
[owner retain];
|
||||
user_data = theData;
|
||||
inside = flag;
|
||||
isValid = YES;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
|
@ -75,24 +75,39 @@
|
|||
return rectangle;
|
||||
}
|
||||
|
||||
- (NSTrackingRectTag)tag
|
||||
- (NSTrackingRectTag) tag
|
||||
{
|
||||
return tag;
|
||||
}
|
||||
|
||||
- owner
|
||||
{
|
||||
return owner;
|
||||
return owner;
|
||||
}
|
||||
|
||||
- (void *)userData
|
||||
- (void *) userData
|
||||
{
|
||||
return user_data;
|
||||
return user_data;
|
||||
}
|
||||
|
||||
- (BOOL)inside
|
||||
- (BOOL) inside
|
||||
{
|
||||
return inside;
|
||||
return inside;
|
||||
}
|
||||
|
||||
- (BOOL) isValid
|
||||
{
|
||||
return isValid;
|
||||
}
|
||||
|
||||
- (void) invalidate
|
||||
{
|
||||
if (isValid)
|
||||
{
|
||||
isValid = NO;
|
||||
[owner release];
|
||||
owner = nil;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -238,6 +238,9 @@ NSString* mainModelFile;
|
|||
|
||||
app_is_active = YES;
|
||||
|
||||
if (unhide_on_activation)
|
||||
[self unhide: nil];
|
||||
|
||||
[nc postNotificationName: NSApplicationDidBecomeActiveNotification
|
||||
object: self];
|
||||
}
|
||||
|
@ -256,6 +259,7 @@ NSString* mainModelFile;
|
|||
[nc postNotificationName: NSApplicationWillResignActiveNotification
|
||||
object: self];
|
||||
|
||||
unhide_on_activation = NO;
|
||||
app_is_active = NO;
|
||||
|
||||
[nc postNotificationName: NSApplicationDidResignActiveNotification
|
||||
|
@ -289,6 +293,8 @@ NSString* mainModelFile;
|
|||
|
||||
app_is_running = YES;
|
||||
|
||||
[listener updateServicesMenu];
|
||||
[main_menu update];
|
||||
while (app_should_quit == NO)
|
||||
{
|
||||
pool = [arpClass new];
|
||||
|
@ -300,13 +306,11 @@ NSString* mainModelFile;
|
|||
if (e)
|
||||
[self sendEvent: e];
|
||||
|
||||
// update (en/disable) the
|
||||
// services menu's items
|
||||
// update (en/disable) the services menu's items
|
||||
[listener updateServicesMenu];
|
||||
[main_menu update];
|
||||
|
||||
// send an update message
|
||||
// to all visible windows
|
||||
// send an update message to all visible windows
|
||||
if (windows_need_update)
|
||||
[self updateWindows];
|
||||
|
||||
|
@ -1041,15 +1045,16 @@ BOOL done = NO;
|
|||
}
|
||||
}
|
||||
app_is_hidden = YES;
|
||||
|
||||
[nc postNotificationName: NSApplicationDidHideNotification
|
||||
object: self];
|
||||
|
||||
/*
|
||||
* On hiding we also deactivate the application which will make the menus
|
||||
* go away too.
|
||||
*/
|
||||
[self deactivate];
|
||||
unhide_on_activation = YES;
|
||||
|
||||
|
||||
[nc postNotificationName: NSApplicationDidHideNotification
|
||||
object: self];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1077,6 +1082,7 @@ BOOL done = NO;
|
|||
{
|
||||
if (app_is_hidden == YES)
|
||||
{
|
||||
NSWindow *key = [self keyWindow];
|
||||
NSMenu *menu;
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
|
@ -1096,9 +1102,9 @@ BOOL done = NO;
|
|||
{
|
||||
id win = [[itemArray objectAtIndex: i] target];
|
||||
|
||||
if ([win isKindOfClass: [NSWindow class]])
|
||||
if (win != key && [win isKindOfClass: [NSWindow class]])
|
||||
{
|
||||
[win orderBack: self];
|
||||
[win orderFront: self];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1107,6 +1113,8 @@ BOOL done = NO;
|
|||
[nc postNotificationName: NSApplicationDidUnhideNotification
|
||||
object: self];
|
||||
|
||||
if ([self keyWindow] != key)
|
||||
[key orderFront: self];
|
||||
[[self keyWindow] makeKeyAndOrderFront: self];
|
||||
}
|
||||
}
|
||||
|
|
611
Source/NSEvent.m
611
Source/NSEvent.m
|
@ -1,23 +1,23 @@
|
|||
/*
|
||||
/*
|
||||
NSEvent.m
|
||||
|
||||
The event class
|
||||
|
||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
|
||||
Author: Scott Christley <scottc@net-community.com>
|
||||
Author: Ovidiu Predescu <ovidiu@net-community.com>
|
||||
Author: Scott Christley <scottc@net-community.com>
|
||||
Author: Ovidiu Predescu <ovidiu@net-community.com>
|
||||
Date: 1996
|
||||
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
||||
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
||||
Date: Sept 1998
|
||||
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
|
@ -27,7 +27,7 @@
|
|||
License along with this library; see the file COPYING.LIB.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
*/
|
||||
|
||||
#include <gnustep/gui/config.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
|
@ -51,234 +51,237 @@ static NSString *timerKey = @"NSEventTimersKey";
|
|||
//
|
||||
// Class methods
|
||||
//
|
||||
+ (void)initialize
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [NSEvent class])
|
||||
{
|
||||
NSDebugLog(@"Initialize NSEvent class\n");
|
||||
[self setVersion:1]; // Initial version
|
||||
}
|
||||
if (self == [NSEvent class])
|
||||
{
|
||||
NSDebugLog(@"Initialize NSEvent class\n");
|
||||
[self setVersion: 1];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Creating NSEvent objects
|
||||
//
|
||||
+ (NSEvent*) enterExitEventWithType: (NSEventType)type
|
||||
+ (NSEvent*) enterExitEventWithType: (NSEventType)type
|
||||
location: (NSPoint)location
|
||||
modifierFlags: (unsigned int)flags
|
||||
timestamp: (NSTimeInterval)time
|
||||
windowNumber: (int)windowNum
|
||||
context: (NSGraphicsContext*)context
|
||||
context: (NSGraphicsContext*)context
|
||||
eventNumber: (int)eventNum
|
||||
trackingNumber: (int)trackingNum
|
||||
userData: (void *)userData
|
||||
{
|
||||
NSEvent *e = [[[NSEvent alloc] init] autorelease];
|
||||
// do nothing if
|
||||
if ((type != NSMouseEntered) && (type != NSMouseExited) // event is not of
|
||||
&& (type != NSCursorUpdate)) // a desired type
|
||||
return nil;
|
||||
NSEvent *e = [[[NSEvent alloc] init] autorelease];
|
||||
|
||||
e->event_type = type; // Set the event's
|
||||
e->location_point = location; // fields
|
||||
e->modifier_flags = flags;
|
||||
e->event_time = time;
|
||||
e->window_num = windowNum;
|
||||
e->event_context = context;
|
||||
e->event_data.tracking.event_num = eventNum;
|
||||
e->event_data.tracking.tracking_num = trackingNum;
|
||||
e->event_data.tracking.user_data = userData;
|
||||
if (type == NSCursorUpdate)
|
||||
[(id)userData retain];
|
||||
else if ((type != NSMouseEntered) && (type != NSMouseExited))
|
||||
return nil;
|
||||
|
||||
return e;
|
||||
e->event_type = type;
|
||||
|
||||
e->location_point = location;
|
||||
e->modifier_flags = flags;
|
||||
e->event_time = time;
|
||||
e->window_num = windowNum;
|
||||
e->event_context = context;
|
||||
e->event_data.tracking.event_num = eventNum;
|
||||
e->event_data.tracking.tracking_num = trackingNum;
|
||||
e->event_data.tracking.user_data = userData;
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
+ (NSEvent *)keyEventWithType:(NSEventType)type
|
||||
location:(NSPoint)location
|
||||
modifierFlags:(unsigned int)flags
|
||||
timestamp:(NSTimeInterval)time
|
||||
windowNumber:(int)windowNum
|
||||
context:(NSGraphicsContext *)context
|
||||
characters:(NSString *)keys
|
||||
charactersIgnoringModifiers:(NSString *)ukeys
|
||||
isARepeat:(BOOL)repeatKey
|
||||
keyCode:(unsigned short)code
|
||||
+ (NSEvent*) keyEventWithType: (NSEventType)type
|
||||
location: (NSPoint)location
|
||||
modifierFlags: (unsigned int)flags
|
||||
timestamp: (NSTimeInterval)time
|
||||
windowNumber: (int)windowNum
|
||||
context: (NSGraphicsContext *)context
|
||||
characters: (NSString *)keys
|
||||
charactersIgnoringModifiers: (NSString *)ukeys
|
||||
isARepeat: (BOOL)repeatKey
|
||||
keyCode: (unsigned short)code
|
||||
{
|
||||
NSEvent *e = [[[NSEvent alloc] init] autorelease];
|
||||
// do nothing if
|
||||
if ((type != NSKeyDown) && (type != NSKeyUp)) // event is not of
|
||||
return nil; // a desired type
|
||||
NSEvent *e = [[[NSEvent alloc] init] autorelease];
|
||||
|
||||
e->event_type = type; // Set the event's
|
||||
e->location_point = location; // fields
|
||||
e->modifier_flags = flags;
|
||||
e->event_time = time;
|
||||
e->window_num = windowNum;
|
||||
e->event_context = context;
|
||||
[keys retain];
|
||||
e->event_data.key.char_keys = keys;
|
||||
[ukeys retain];
|
||||
e->event_data.key.unmodified_keys = ukeys;
|
||||
e->event_data.key.repeat = repeatKey;
|
||||
e->event_data.key.key_code = code;
|
||||
if ((type != NSKeyDown) && (type != NSKeyUp))
|
||||
return nil;
|
||||
|
||||
return e;
|
||||
e->event_type = type;
|
||||
e->location_point = location;
|
||||
e->modifier_flags = flags;
|
||||
e->event_time = time;
|
||||
e->window_num = windowNum;
|
||||
e->event_context = context;
|
||||
[keys retain];
|
||||
e->event_data.key.char_keys = keys;
|
||||
[ukeys retain];
|
||||
e->event_data.key.unmodified_keys = ukeys;
|
||||
e->event_data.key.repeat = repeatKey;
|
||||
e->event_data.key.key_code = code;
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
+ (NSEvent *)mouseEventWithType:(NSEventType)type
|
||||
location:(NSPoint)location
|
||||
modifierFlags:(unsigned int)flags
|
||||
timestamp:(NSTimeInterval)time
|
||||
windowNumber:(int)windowNum
|
||||
context:(NSGraphicsContext*)context
|
||||
eventNumber:(int)eventNum
|
||||
clickCount:(int)clickNum
|
||||
pressure:(float)pressureValue
|
||||
+ (NSEvent*) mouseEventWithType: (NSEventType)type
|
||||
location: (NSPoint)location
|
||||
modifierFlags: (unsigned int)flags
|
||||
timestamp: (NSTimeInterval)time
|
||||
windowNumber: (int)windowNum
|
||||
context: (NSGraphicsContext*)context
|
||||
eventNumber: (int)eventNum
|
||||
clickCount: (int)clickNum
|
||||
pressure: (float)pressureValue
|
||||
{
|
||||
NSEvent *e = [[[NSEvent alloc] init] autorelease]; // do nothing if
|
||||
// event is not of
|
||||
if ((type != NSMouseMoved) && (type != NSLeftMouseUp) // a desired type
|
||||
&& (type != NSLeftMouseDown) && (type != NSRightMouseDown)
|
||||
&& (type != NSRightMouseUp) && (type != NSLeftMouseDragged)
|
||||
&& (type != NSRightMouseDragged))
|
||||
return nil;
|
||||
NSEvent *e = [[[NSEvent alloc] init] autorelease];
|
||||
|
||||
e->event_type = type; // Set the event's
|
||||
e->location_point = location; // fields
|
||||
e->modifier_flags = flags;
|
||||
e->event_time = time;
|
||||
e->window_num = windowNum;
|
||||
e->event_context = context;
|
||||
e->event_data.mouse.event_num = eventNum;
|
||||
e->event_data.mouse.click = clickNum;
|
||||
e->event_data.mouse.pressure = pressureValue;
|
||||
if ((type != NSMouseMoved) && (type != NSLeftMouseUp)
|
||||
&& (type != NSLeftMouseDown) && (type != NSRightMouseDown)
|
||||
&& (type != NSRightMouseUp) && (type != NSLeftMouseDragged)
|
||||
&& (type != NSRightMouseDragged))
|
||||
return nil;
|
||||
|
||||
return e;
|
||||
e->event_type = type;
|
||||
e->location_point = location;
|
||||
e->modifier_flags = flags;
|
||||
e->event_time = time;
|
||||
e->window_num = windowNum;
|
||||
e->event_context = context;
|
||||
e->event_data.mouse.event_num = eventNum;
|
||||
e->event_data.mouse.click = clickNum;
|
||||
e->event_data.mouse.pressure = pressureValue;
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
+ (NSEvent *)otherEventWithType:(NSEventType)type
|
||||
location:(NSPoint)location
|
||||
modifierFlags:(unsigned int)flags
|
||||
timestamp:(NSTimeInterval)time
|
||||
windowNumber:(int)windowNum
|
||||
context:(NSGraphicsContext*)context
|
||||
subtype:(short)subType
|
||||
data1:(int)data1
|
||||
data2:(int)data2
|
||||
+ (NSEvent*) otherEventWithType: (NSEventType)type
|
||||
location: (NSPoint)location
|
||||
modifierFlags: (unsigned int)flags
|
||||
timestamp: (NSTimeInterval)time
|
||||
windowNumber: (int)windowNum
|
||||
context: (NSGraphicsContext*)context
|
||||
subtype: (short)subType
|
||||
data1: (int)data1
|
||||
data2: (int)data2
|
||||
{
|
||||
NSEvent *e = [[[NSEvent alloc] init] autorelease];
|
||||
// do nothing if
|
||||
if ((type != NSFlagsChanged) && (type != NSPeriodic)) // event is not of
|
||||
return nil; // a desired type
|
||||
|
||||
e->event_type = type; // Set the event's
|
||||
e->location_point = location; // fields
|
||||
e->modifier_flags = flags;
|
||||
e->event_time = time;
|
||||
e->window_num = windowNum;
|
||||
e->event_context = context;
|
||||
e->event_data.misc.sub_type = subType;
|
||||
e->event_data.misc.data1 = data1;
|
||||
e->event_data.misc.data2 = data2;
|
||||
NSEvent *e = [[[NSEvent alloc] init] autorelease];
|
||||
|
||||
return e;
|
||||
if ((type != NSFlagsChanged) && (type != NSPeriodic))
|
||||
return nil;
|
||||
|
||||
e->event_type = type;
|
||||
e->location_point = location;
|
||||
e->modifier_flags = flags;
|
||||
e->event_time = time;
|
||||
e->window_num = windowNum;
|
||||
e->event_context = context;
|
||||
e->event_data.misc.sub_type = subType;
|
||||
e->event_data.misc.data1 = data1;
|
||||
e->event_data.misc.data2 = data2;
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
//
|
||||
// Requesting Periodic Events
|
||||
//
|
||||
+ (void)startPeriodicEventsAfterDelay:(NSTimeInterval)delaySeconds
|
||||
withPeriod:(NSTimeInterval)periodSeconds
|
||||
+ (void) startPeriodicEventsAfterDelay: (NSTimeInterval)delaySeconds
|
||||
withPeriod: (NSTimeInterval)periodSeconds
|
||||
{
|
||||
NSTimer* timer;
|
||||
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
||||
NSTimer *timer;
|
||||
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
||||
|
||||
NSDebugLog (@"startPeriodicEventsAfterDelay:withPeriod:");
|
||||
// Check this thread
|
||||
if ([dict objectForKey: timerKey]) // for a pending timer
|
||||
[NSException raise:NSInternalInconsistencyException
|
||||
format:@"Periodic events are already being generated for "
|
||||
@"this thread %x", [NSThread currentThread]];
|
||||
// If the delay time is 0 then register
|
||||
// a timer immediately. Otherwise
|
||||
// register a timer with no repeat that
|
||||
if (!delaySeconds) // when fired registers the real timer
|
||||
timer = [NSTimer timerWithTimeInterval:periodSeconds // register an
|
||||
target:self // immediate
|
||||
selector:@selector(_timerFired:) // timer
|
||||
userInfo:nil
|
||||
repeats:YES];
|
||||
else // register a one
|
||||
timer = [NSTimer timerWithTimeInterval:delaySeconds // shot timer to
|
||||
target:self // register a timer
|
||||
selector:@selector(_registerRealTimer:)
|
||||
userInfo:[NSNumber numberWithDouble:periodSeconds]
|
||||
repeats:NO];
|
||||
NSDebugLog (@"startPeriodicEventsAfterDelay: withPeriod: ");
|
||||
|
||||
[[NSRunLoop currentRunLoop] addTimer: timer
|
||||
forMode: NSEventTrackingRunLoopMode];
|
||||
[dict setObject: timer forKey: timerKey];
|
||||
if ([dict objectForKey: timerKey])
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Periodic events are already being generated for "
|
||||
@"this thread %x", [NSThread currentThread]];
|
||||
|
||||
// If the delay time is 0 then register a timer immediately. Otherwise
|
||||
// register a timer with no repeat that when fired registers the real timer
|
||||
if (!delaySeconds)
|
||||
timer = [NSTimer timerWithTimeInterval: periodSeconds
|
||||
target: self
|
||||
selector: @selector(_timerFired:)
|
||||
userInfo: nil
|
||||
repeats: YES];
|
||||
else
|
||||
timer = [NSTimer timerWithTimeInterval: delaySeconds
|
||||
target: self
|
||||
selector: @selector(_registerRealTimer:)
|
||||
userInfo: [NSNumber numberWithDouble: periodSeconds]
|
||||
repeats: NO];
|
||||
|
||||
[[NSRunLoop currentRunLoop] addTimer: timer
|
||||
forMode: NSEventTrackingRunLoopMode];
|
||||
[dict setObject: timer forKey: timerKey];
|
||||
}
|
||||
|
||||
+ (void)_timerFired:(NSTimer*)timer
|
||||
+ (void) _timerFired: (NSTimer*)timer
|
||||
{
|
||||
NSTimeInterval timeInterval = [[NSDate date] timeIntervalSinceReferenceDate];
|
||||
NSApplication *theApp = [NSApplication sharedApplication];
|
||||
NSEvent* periodicEvent = [self otherEventWithType:NSPeriodic
|
||||
location:NSZeroPoint
|
||||
modifierFlags:0
|
||||
timestamp:timeInterval
|
||||
windowNumber:0
|
||||
context:[theApp context]
|
||||
subtype:0
|
||||
data1:0
|
||||
data2:0];
|
||||
NSTimeInterval timeInterval = [[NSDate date] timeIntervalSinceReferenceDate];
|
||||
NSApplication *theApp = [NSApplication sharedApplication];
|
||||
NSEvent* periodicEvent = [self otherEventWithType: NSPeriodic
|
||||
location: NSZeroPoint
|
||||
modifierFlags: 0
|
||||
timestamp: timeInterval
|
||||
windowNumber: 0
|
||||
context: [theApp context]
|
||||
subtype: 0
|
||||
data1: 0
|
||||
data2: 0];
|
||||
|
||||
NSDebugLog (@"_timerFired:");
|
||||
[theApp postEvent:periodicEvent atStart:NO]; // place a periodic
|
||||
} // event in the queue
|
||||
|
||||
+ (void)_registerRealTimer:(NSTimer*)timer // this method provides a
|
||||
{ // means of delaying the
|
||||
NSTimer* realTimer; // start of periodic events
|
||||
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
||||
|
||||
NSDebugLog (@"_registerRealTimer:");
|
||||
|
||||
realTimer = [NSTimer timerWithTimeInterval:[[timer userInfo] doubleValue]
|
||||
target:self
|
||||
selector:@selector(_timerFired:)
|
||||
userInfo:nil
|
||||
repeats:YES]; // Add the real timer to the timers
|
||||
// dictionary and to the run loop
|
||||
[dict setObject: realTimer forKey: timerKey];
|
||||
[[NSRunLoop currentRunLoop] addTimer: realTimer
|
||||
forMode: NSEventTrackingRunLoopMode];
|
||||
NSDebugLog (@"_timerFired: ");
|
||||
[theApp postEvent: periodicEvent atStart: NO];
|
||||
}
|
||||
|
||||
+ (void)stopPeriodicEvents
|
||||
// this method provides a means of delaying the start of periodic events
|
||||
+ (void) _registerRealTimer: (NSTimer*)timer
|
||||
{
|
||||
NSTimer* timer;
|
||||
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
||||
NSTimer* realTimer;
|
||||
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
||||
|
||||
NSDebugLog (@"stopPeriodicEvents");
|
||||
// Remove any existing
|
||||
timer = [dict objectForKey: timerKey]; // timer for this thread
|
||||
[timer invalidate];
|
||||
[dict removeObjectForKey: timerKey];
|
||||
NSDebugLog (@"_registerRealTimer: ");
|
||||
|
||||
realTimer = [NSTimer timerWithTimeInterval: [[timer userInfo] doubleValue]
|
||||
target: self
|
||||
selector: @selector(_timerFired:)
|
||||
userInfo: nil
|
||||
repeats: YES];
|
||||
[dict setObject: realTimer forKey: timerKey];
|
||||
[[NSRunLoop currentRunLoop] addTimer: realTimer
|
||||
forMode: NSEventTrackingRunLoopMode];
|
||||
}
|
||||
|
||||
+ (void) stopPeriodicEvents
|
||||
{
|
||||
NSTimer* timer;
|
||||
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
||||
|
||||
NSDebugLog (@"stopPeriodicEvents");
|
||||
timer = [dict objectForKey: timerKey];
|
||||
[timer invalidate];
|
||||
[dict removeObjectForKey: timerKey];
|
||||
}
|
||||
|
||||
//
|
||||
// Instance methods
|
||||
//
|
||||
- (void)dealloc
|
||||
- (void) dealloc
|
||||
{
|
||||
if ((event_type == NSKeyUp) || (event_type == NSKeyDown))
|
||||
{
|
||||
[event_data.key.char_keys release];
|
||||
[event_data.key.unmodified_keys release];
|
||||
}
|
||||
if ((event_type == NSKeyUp) || (event_type == NSKeyDown))
|
||||
{
|
||||
[event_data.key.char_keys release];
|
||||
[event_data.key.unmodified_keys release];
|
||||
}
|
||||
else if (event_type == NSCursorUpdate)
|
||||
[(id)event_data.tracking.user_data release];
|
||||
|
||||
[super dealloc];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -289,110 +292,110 @@ NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
|||
return event_context;
|
||||
}
|
||||
|
||||
- (NSPoint)locationInWindow
|
||||
- (NSPoint) locationInWindow
|
||||
{
|
||||
return location_point;
|
||||
return location_point;
|
||||
}
|
||||
|
||||
- (unsigned int)modifierFlags
|
||||
- (unsigned int) modifierFlags
|
||||
{
|
||||
return modifier_flags;
|
||||
return modifier_flags;
|
||||
}
|
||||
|
||||
- (NSTimeInterval)timestamp
|
||||
- (NSTimeInterval) timestamp
|
||||
{
|
||||
return event_time;
|
||||
return event_time;
|
||||
}
|
||||
|
||||
- (NSEventType)type
|
||||
- (NSEventType) type
|
||||
{
|
||||
return event_type;
|
||||
return event_type;
|
||||
}
|
||||
|
||||
- (NSWindow *)window
|
||||
- (NSWindow *) window
|
||||
{
|
||||
return [NSWindow _windowWithTag:window_num];
|
||||
return [NSWindow _windowWithTag: window_num];
|
||||
}
|
||||
|
||||
- (int)windowNumber
|
||||
- (int) windowNumber
|
||||
{
|
||||
return window_num;
|
||||
return window_num;
|
||||
}
|
||||
|
||||
//
|
||||
// Getting Key Event Information
|
||||
//
|
||||
- (NSString *)characters
|
||||
- (NSString *) characters
|
||||
{
|
||||
if ((event_type != NSKeyUp) && (event_type != NSKeyDown))
|
||||
return nil;
|
||||
if ((event_type != NSKeyUp) && (event_type != NSKeyDown))
|
||||
return nil;
|
||||
|
||||
return event_data.key.char_keys;
|
||||
return event_data.key.char_keys;
|
||||
}
|
||||
|
||||
- (NSString *)charactersIgnoringModifiers
|
||||
- (NSString *) charactersIgnoringModifiers
|
||||
{
|
||||
if ((event_type != NSKeyUp) && (event_type != NSKeyDown))
|
||||
return nil;
|
||||
if ((event_type != NSKeyUp) && (event_type != NSKeyDown))
|
||||
return nil;
|
||||
|
||||
return event_data.key.unmodified_keys;
|
||||
return event_data.key.unmodified_keys;
|
||||
}
|
||||
|
||||
- (BOOL)isARepeat
|
||||
- (BOOL) isARepeat
|
||||
{
|
||||
if ((event_type != NSKeyUp) && (event_type != NSKeyDown))
|
||||
return NO;
|
||||
if ((event_type != NSKeyUp) && (event_type != NSKeyDown))
|
||||
return NO;
|
||||
|
||||
return event_data.key.repeat;
|
||||
return event_data.key.repeat;
|
||||
}
|
||||
|
||||
- (unsigned short)keyCode
|
||||
- (unsigned short) keyCode
|
||||
{
|
||||
if ((event_type != NSKeyUp) && (event_type != NSKeyDown))
|
||||
return 0;
|
||||
if ((event_type != NSKeyUp) && (event_type != NSKeyDown))
|
||||
return 0;
|
||||
|
||||
return event_data.key.key_code;
|
||||
return event_data.key.key_code;
|
||||
}
|
||||
|
||||
//
|
||||
// Getting Mouse Event Information
|
||||
//
|
||||
- (int)clickCount
|
||||
- (int) clickCount
|
||||
{
|
||||
// Make sure it is one of the right event types
|
||||
if ((event_type != NSLeftMouseDown) && (event_type != NSLeftMouseUp) &&
|
||||
(event_type != NSRightMouseDown) && (event_type != NSRightMouseUp) &&
|
||||
(event_type != NSLeftMouseDragged) && (event_type != NSRightMouseDragged) &&
|
||||
(event_type != NSMouseMoved))
|
||||
return 0;
|
||||
if ((event_type != NSLeftMouseDown) && (event_type != NSLeftMouseUp)
|
||||
&& (event_type != NSRightMouseDown) && (event_type != NSRightMouseUp)
|
||||
&& (event_type != NSLeftMouseDragged) && (event_type != NSRightMouseDragged)
|
||||
&& (event_type != NSMouseMoved))
|
||||
return 0;
|
||||
|
||||
return event_data.mouse.click;
|
||||
}
|
||||
|
||||
- (int)eventNumber
|
||||
- (int) eventNumber
|
||||
{
|
||||
// Make sure it is one of the right event types
|
||||
if ((event_type != NSLeftMouseDown) && (event_type != NSLeftMouseUp) &&
|
||||
(event_type != NSRightMouseDown) && (event_type != NSRightMouseUp) &&
|
||||
(event_type != NSLeftMouseDragged) && (event_type != NSRightMouseDragged)
|
||||
&& (event_type != NSMouseMoved) && (event_type != NSMouseEntered) &&
|
||||
(event_type != NSMouseExited))
|
||||
return 0;
|
||||
if ((event_type != NSLeftMouseDown) && (event_type != NSLeftMouseUp)
|
||||
&& (event_type != NSRightMouseDown) && (event_type != NSRightMouseUp)
|
||||
&& (event_type != NSLeftMouseDragged) && (event_type != NSRightMouseDragged)
|
||||
&& (event_type != NSMouseMoved) && (event_type != NSMouseEntered)
|
||||
&& (event_type != NSMouseExited))
|
||||
return 0;
|
||||
|
||||
if ((event_type == NSMouseEntered) || (event_type == NSMouseExited))
|
||||
return event_data.tracking.event_num;
|
||||
return event_data.tracking.event_num;
|
||||
else
|
||||
return event_data.mouse.event_num;
|
||||
return event_data.mouse.event_num;
|
||||
}
|
||||
|
||||
- (float)pressure
|
||||
- (float) pressure
|
||||
{
|
||||
// Make sure it is one of the right event types
|
||||
if ((event_type != NSLeftMouseDown) && (event_type != NSLeftMouseUp) &&
|
||||
(event_type != NSRightMouseDown) && (event_type != NSRightMouseUp) &&
|
||||
(event_type != NSLeftMouseDragged) && (event_type != NSRightMouseDragged)
|
||||
&& (event_type != NSMouseMoved))
|
||||
return 0;
|
||||
if ((event_type != NSLeftMouseDown) && (event_type != NSLeftMouseUp)
|
||||
&& (event_type != NSRightMouseDown) && (event_type != NSRightMouseUp)
|
||||
&& (event_type != NSLeftMouseDragged) && (event_type != NSRightMouseDragged)
|
||||
&& (event_type != NSMouseMoved))
|
||||
return 0;
|
||||
|
||||
return event_data.mouse.pressure;
|
||||
}
|
||||
|
@ -400,20 +403,20 @@ NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
|||
//
|
||||
// Getting Tracking Event Information
|
||||
//
|
||||
- (int)trackingNumber
|
||||
- (int) trackingNumber
|
||||
{
|
||||
if ((event_type != NSMouseEntered) && (event_type != NSMouseExited)
|
||||
&& (event_type != NSCursorUpdate))
|
||||
return 0;
|
||||
&& (event_type != NSCursorUpdate))
|
||||
return 0;
|
||||
|
||||
return event_data.tracking.tracking_num;
|
||||
}
|
||||
|
||||
- (void *)userData
|
||||
- (void *) userData
|
||||
{
|
||||
if ((event_type != NSMouseEntered) && (event_type != NSMouseExited)
|
||||
&& (event_type != NSCursorUpdate))
|
||||
return NULL;
|
||||
&& (event_type != NSCursorUpdate))
|
||||
return NULL;
|
||||
|
||||
return event_data.tracking.user_data;
|
||||
}
|
||||
|
@ -421,29 +424,29 @@ NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
|||
//
|
||||
// Getting Information about Specially Defined Events
|
||||
//
|
||||
- (int)data1
|
||||
- (int) data1
|
||||
{
|
||||
// Make sure it is one of the right event types
|
||||
if ((event_type != NSFlagsChanged) && (event_type != NSPeriodic))
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
return event_data.misc.data1;
|
||||
}
|
||||
|
||||
- (int)data2
|
||||
- (int) data2
|
||||
{
|
||||
// Make sure it is one of the right event types
|
||||
if ((event_type != NSFlagsChanged) && (event_type != NSPeriodic))
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
return event_data.misc.data2;
|
||||
}
|
||||
|
||||
- (short)subtype
|
||||
- (short) subtype
|
||||
{
|
||||
// Make sure it is one of the right event types
|
||||
if ((event_type != NSFlagsChanged) && (event_type != NSPeriodic))
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
return event_data.misc.sub_type;;
|
||||
}
|
||||
|
@ -486,7 +489,8 @@ NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
|||
|
||||
case NSKeyDown:
|
||||
case NSKeyUp:
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &event_data.key.repeat];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL)
|
||||
at: &event_data.key.repeat];
|
||||
[aCoder encodeObject: event_data.key.char_keys];
|
||||
[aCoder encodeObject: event_data.key.unmodified_keys];
|
||||
[aCoder encodeValueOfObjCType: "S" at: &event_data.key.key_code];
|
||||
|
@ -532,7 +536,7 @@ NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
|||
|
||||
case NSKeyDown:
|
||||
case NSKeyUp:
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL)
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL)
|
||||
at: &event_data.key.repeat];
|
||||
event_data.key.char_keys = [aDecoder decodeObject];
|
||||
event_data.key.unmodified_keys = [aDecoder decodeObject];
|
||||
|
@ -549,71 +553,72 @@ NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
|||
return self;
|
||||
}
|
||||
|
||||
- (NSString*)description
|
||||
- (NSString*) description
|
||||
{
|
||||
const char* eventTypes[] = { "leftMouseDown", "leftMouseUp",
|
||||
"rightMouseDown", "rightMouseUp", "mouseMoved", "leftMouseDragged",
|
||||
"rightMouseDragged", "mouseEntered", "mouseExited", "keyDown", "keyUp",
|
||||
"flagsChanged", "periodic", "cursorUpdate"
|
||||
"rightMouseDown", "rightMouseUp", "mouseMoved", "leftMouseDragged",
|
||||
"rightMouseDragged", "mouseEntered", "mouseExited", "keyDown", "keyUp",
|
||||
"flagsChanged", "periodic", "cursorUpdate"
|
||||
};
|
||||
|
||||
switch (event_type) {
|
||||
case NSLeftMouseDown:
|
||||
case NSLeftMouseUp:
|
||||
case NSRightMouseDown:
|
||||
case NSRightMouseUp:
|
||||
case NSMouseMoved:
|
||||
case NSLeftMouseDragged:
|
||||
case NSRightMouseDragged:
|
||||
return [NSString stringWithFormat:
|
||||
@"NSEvent: eventType = %s, point = { %f, %f }, modifiers = %u,"
|
||||
@" time = %f, window = %d, dpsContext = %p,"
|
||||
@" event number = %d, click = %d, pressure = %f",
|
||||
eventTypes[event_type], location_point.x, location_point.y,
|
||||
modifier_flags, event_time, window_num, event_context,
|
||||
event_data.mouse.event_num, event_data.mouse.click,
|
||||
event_data.mouse.pressure];
|
||||
break;
|
||||
switch (event_type)
|
||||
{
|
||||
case NSLeftMouseDown:
|
||||
case NSLeftMouseUp:
|
||||
case NSRightMouseDown:
|
||||
case NSRightMouseUp:
|
||||
case NSMouseMoved:
|
||||
case NSLeftMouseDragged:
|
||||
case NSRightMouseDragged:
|
||||
return [NSString stringWithFormat:
|
||||
@"NSEvent: eventType = %s, point = { %f, %f }, modifiers = %u,"
|
||||
@" time = %f, window = %d, dpsContext = %p,"
|
||||
@" event number = %d, click = %d, pressure = %f",
|
||||
eventTypes[event_type], location_point.x, location_point.y,
|
||||
modifier_flags, event_time, window_num, event_context,
|
||||
event_data.mouse.event_num, event_data.mouse.click,
|
||||
event_data.mouse.pressure];
|
||||
break;
|
||||
|
||||
case NSMouseEntered:
|
||||
case NSMouseExited:
|
||||
return [NSString stringWithFormat:
|
||||
@"NSEvent: eventType = %s, point = { %f, %f }, modifiers = %u,"
|
||||
@" time = %f, window = %d, dpsContext = %p, "
|
||||
@" event number = %d, tracking number = %d, user data = %p",
|
||||
eventTypes[event_type], location_point.x, location_point.y,
|
||||
modifier_flags, event_time, window_num, event_context,
|
||||
event_data.tracking.event_num,
|
||||
event_data.tracking.tracking_num,
|
||||
event_data.tracking.user_data];
|
||||
break;
|
||||
case NSMouseEntered:
|
||||
case NSMouseExited:
|
||||
return [NSString stringWithFormat:
|
||||
@"NSEvent: eventType = %s, point = { %f, %f }, modifiers = %u,"
|
||||
@" time = %f, window = %d, dpsContext = %p, "
|
||||
@" event number = %d, tracking number = %d, user data = %p",
|
||||
eventTypes[event_type], location_point.x, location_point.y,
|
||||
modifier_flags, event_time, window_num, event_context,
|
||||
event_data.tracking.event_num,
|
||||
event_data.tracking.tracking_num,
|
||||
event_data.tracking.user_data];
|
||||
break;
|
||||
|
||||
case NSKeyDown:
|
||||
case NSKeyUp:
|
||||
return [NSString stringWithFormat:
|
||||
@"NSEvent: eventType = %s, point = { %f, %f }, modifiers = %u,"
|
||||
@" time = %f, window = %d, dpsContext = %p, "
|
||||
@" repeat = %s, keys = %@, ukeys = %@, keyCode = 0x%x",
|
||||
eventTypes[event_type], location_point.x, location_point.y,
|
||||
modifier_flags, event_time, window_num, event_context,
|
||||
(event_data.key.repeat ? "YES" : "NO"),
|
||||
event_data.key.char_keys, event_data.key.unmodified_keys,
|
||||
event_data.key.key_code];
|
||||
break;
|
||||
case NSKeyDown:
|
||||
case NSKeyUp:
|
||||
return [NSString stringWithFormat:
|
||||
@"NSEvent: eventType = %s, point = { %f, %f }, modifiers = %u,"
|
||||
@" time = %f, window = %d, dpsContext = %p, "
|
||||
@" repeat = %s, keys = %@, ukeys = %@, keyCode = 0x%x",
|
||||
eventTypes[event_type], location_point.x, location_point.y,
|
||||
modifier_flags, event_time, window_num, event_context,
|
||||
(event_data.key.repeat ? "YES" : "NO"),
|
||||
event_data.key.char_keys, event_data.key.unmodified_keys,
|
||||
event_data.key.key_code];
|
||||
break;
|
||||
|
||||
case NSFlagsChanged:
|
||||
case NSPeriodic:
|
||||
case NSCursorUpdate:
|
||||
return [NSString stringWithFormat:
|
||||
@"NSEvent: eventType = %s, point = { %f, %f }, modifiers = %u,"
|
||||
@" time = %f, window = %d, dpsContext = %p, "
|
||||
@" subtype = %d, data1 = %p, data2 = %p",
|
||||
eventTypes[event_type], location_point.x, location_point.y,
|
||||
modifier_flags, event_time, window_num, event_context,
|
||||
event_data.misc.sub_type, event_data.misc.data1,
|
||||
event_data.misc.data2];
|
||||
break;
|
||||
}
|
||||
case NSFlagsChanged:
|
||||
case NSPeriodic:
|
||||
case NSCursorUpdate:
|
||||
return [NSString stringWithFormat:
|
||||
@"NSEvent: eventType = %s, point = { %f, %f }, modifiers = %u,"
|
||||
@" time = %f, window = %d, dpsContext = %p, "
|
||||
@" subtype = %d, data1 = %p, data2 = %p",
|
||||
eventTypes[event_type], location_point.x, location_point.y,
|
||||
modifier_flags, event_time, window_num, event_context,
|
||||
event_data.misc.sub_type, event_data.misc.data1,
|
||||
event_data.misc.data2];
|
||||
break;
|
||||
}
|
||||
|
||||
return [super description];
|
||||
}
|
||||
|
|
|
@ -1377,16 +1377,19 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
|
|||
{
|
||||
GSTrackingRect *m;
|
||||
|
||||
m = [[[GSTrackingRect alloc] initWithRect: aRect
|
||||
tag: 0
|
||||
owner: anObject
|
||||
userData: NULL
|
||||
inside: YES] autorelease];
|
||||
m = [GSTrackingRect allocWithZone: NSDefaultMallocZone()];
|
||||
m = [m initWithRect: aRect
|
||||
tag: 0
|
||||
owner: anObject
|
||||
userData: NULL
|
||||
inside: YES];
|
||||
[cursor_rects addObject: m];
|
||||
[m release];
|
||||
}
|
||||
|
||||
- (void) discardCursorRects
|
||||
{
|
||||
[cursor_rects makeObjectsPerformSelector: @selector(invalidate)];
|
||||
[cursor_rects removeAllObjects];
|
||||
}
|
||||
|
||||
|
@ -1402,6 +1405,7 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
|
|||
c = [o owner];
|
||||
if (c == anObject)
|
||||
{
|
||||
[o invalidate];
|
||||
[cursor_rects removeObject: o];
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -630,7 +630,6 @@
|
|||
|
||||
- (void) display
|
||||
{
|
||||
visible = YES;
|
||||
needs_display = NO; // inform first responder
|
||||
// of it's status so it can
|
||||
[first_responder becomeFirstResponder]; // set the focus to itself
|
||||
|
@ -839,7 +838,6 @@
|
|||
[nc postNotificationName: NSWindowWillCloseNotification object: self];
|
||||
[theApp removeWindowsItem: self];
|
||||
[self orderOut: self];
|
||||
visible = NO;
|
||||
|
||||
if (is_released_when_closed)
|
||||
[self release];
|
||||
|
@ -850,7 +848,6 @@
|
|||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
is_miniaturized = NO;
|
||||
visible = YES;
|
||||
|
||||
[self performDeminiaturize: self];
|
||||
[nc postNotificationName: NSWindowDidDeminiaturizeNotification object: self];
|
||||
|
@ -1097,6 +1094,8 @@
|
|||
{
|
||||
r = (GSTrackingRect *)[tr objectAtIndex: i];
|
||||
|
||||
if ([r isValid] == NO)
|
||||
continue;
|
||||
lastPointConverted = [theView convertPoint: last_point fromView: nil];
|
||||
locationConverted = [theView convertPoint: loc fromView: nil];
|
||||
|
||||
|
@ -1250,6 +1249,7 @@
|
|||
GSTrackingRect *r =(GSTrackingRect *)[theEvent userData];
|
||||
NSCursor *c = (NSCursor *)[r owner];
|
||||
|
||||
c = (NSCursor *)[r owner];
|
||||
if ([theEvent trackingNumber]) // It's a mouse entered
|
||||
{
|
||||
if (c && [c isSetOnMouseEntered])
|
||||
|
|
Loading…
Reference in a new issue