Move mouse location code to graphics context.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4381 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1999-06-09 08:54:08 +00:00
parent 3709177081
commit 3006900f91
7 changed files with 61 additions and 35 deletions

View file

@ -1,5 +1,11 @@
Wed Jun 9 8:35:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Headers/AppKit/DPSOperators.h: Add DPSmouselocation()
* Headers/AppKit/PSOperators.h: Add PSmouselocation()
* Headers/AppKit/NSGraphicsContext.h: Add ([-DPSmouselocation::])
* Headers/AppKit/GSMethodTable.h: Add ([-DPSmouselocation::])
* Source/NSWindow.m: Use DPSmouselocation()
* Source/NSGraphicsContext.m: Add ([-DPSmouselocation::])
* Source/NSApplication.m: Fix retain/release problems introduced by
event system changes.

View file

@ -1931,4 +1931,11 @@ DPSPostEvent(GSCTXT *ctxt, NSEvent* anEvent, BOOL atStart)
(ctxt, @selector(DPSPostEvent:atStart:), anEvent, atStart);
}
static inline void
DPSmouselocation(GSCTXT *ctxt, float *x, float *y)
{
(ctxt->methods->DPSmouselocation__)
(ctxt, @selector(DPSmouselocation::), x, y);
}
#endif

View file

@ -405,6 +405,8 @@ typedef struct {
(NSGraphicsContext*, SEL, unsigned, NSEvent*);
void (*DPSPostEvent_atStart_)
(NSGraphicsContext*, SEL, NSEvent*, BOOL);
void (*DPSmouselocation__)
(NSGraphicsContext*, SEL, float*, float*);
} gsMethodTable;

View file

@ -356,6 +356,7 @@ NSGraphicsContext *GSCurrentContext();
- (void) DPSDiscardEventsMatchingMask: (unsigned)mask
beforeEvent: (NSEvent*)limit;
- (void) DPSPostEvent: (NSEvent*)anEvent atStart: (BOOL)flag;
- (void) DPSmouselocation: (float*)x : (float*)y;
@end
#endif /* _NSGraphicsContext_h_INCLUDE */

View file

@ -1767,4 +1767,10 @@ PSPostEvent(NSEvent* anEvent, BOOL atStart)
DPSPostEvent(DEFCTXT, anEvent, atStart);
}
static inline void
PSmouselocation(float *x, float *y)
{
DPSmouselocation(DEFCTXT, x, y);
}
#endif

View file

@ -657,6 +657,8 @@ struct NSWindow_struct
GET_IMP(@selector(DPSDiscardEventsMatchingMask:beforeEvent:));
methodTable.DPSPostEvent_atStart_ =
GET_IMP(@selector(DPSPostEvent:atStart:));
methodTable.DPSmouselocation__ =
GET_IMP(@selector(DPSmouselocation::));
mptr = NSZoneMalloc(_globalGSZone, sizeof(gsMethodTable));
memcpy(mptr, &methodTable, sizeof(gsMethodTable));
@ -1825,4 +1827,8 @@ struct NSWindow_struct
[event_queue addObject: anEvent];
}
- (void) DPSmouselocation: (float*)x : (float*)y
{
[self subclassResponsibility: _cmd];
}
@end

View file

@ -50,6 +50,7 @@
#include <AppKit/NSScreen.h>
#include <AppKit/NSView.h>
#include <AppKit/NSCursor.h>
#include <AppKit/PSOperators.h>
@interface GSWindowView : NSView
@ -207,12 +208,11 @@ static Class responderClass;
defer: (BOOL)flag
screen: (NSScreen*)aScreen
{
NSApplication *theApp = [NSApplication sharedApplication];
NSRect r = [[NSScreen mainScreen] frame];
NSRect cframe;
NSDebugLog(@"NSWindow default initializer\n");
if (!theApp)
if (!NSApp)
NSLog(@"No application!\n");
NSDebugLog(@"NSWindow start of init\n");
@ -226,7 +226,7 @@ static Class responderClass;
minimum_size = NSZeroSize;
maximum_size = r.size;
// Next responder is the
[self setNextResponder: theApp]; // application
[self setNextResponder: NSApp]; // application
cursor_rects_enabled = YES; // Cursor management
cursor_rects_valid = NO;
@ -311,7 +311,7 @@ static Class responderClass;
&& ((represented_filename != nil && old == nil)
|| (represented_filename == nil && old != nil)))
{
[[NSApplication sharedApplication] updateWindowsItem: self];
[NSApp updateWindowsItem: self];
}
}
@ -403,9 +403,9 @@ static Class responderClass;
if ([title isEqual: represented_filename])
isDoc = YES;
if (menu_exclude == NO)
[[NSApplication sharedApplication] changeWindowsItem: self
title: title
filename: isDoc];
[NSApp changeWindowsItem: self
title: title
filename: isDoc];
}
//
@ -508,22 +508,18 @@ static Class responderClass;
- (void) makeKeyWindow
{
NSApplication *theApp = [NSApplication sharedApplication];
if (![self canBecomeKeyWindow])
return;
[[theApp keyWindow] resignKeyWindow];
[[NSApp keyWindow] resignKeyWindow];
[self becomeKeyWindow];
}
- (void) makeMainWindow
{
NSApplication *theApp = [NSApplication sharedApplication];
if (![self canBecomeMainWindow])
return;
[[theApp mainWindow] resignMainWindow];
[[NSApp mainWindow] resignMainWindow];
[self becomeMainWindow];
}
@ -761,7 +757,7 @@ static Class responderClass;
- (void) setViewsNeedDisplay: (BOOL)flag
{
needs_display = flag;
[[NSApplication sharedApplication] setWindowsNeedUpdate: YES];
[NSApp setWindowsNeedUpdate: YES];
}
- (BOOL) viewsNeedDisplay
@ -896,7 +892,6 @@ static Class responderClass;
- (void) close
{
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NSApplication *theApp = [NSApplication sharedApplication];
/*
* If 'is_released_when_closed' then the window will be removed from the
@ -908,7 +903,7 @@ static Class responderClass;
RETAIN(self);
[nc postNotificationName: NSWindowWillCloseNotification object: self];
[theApp removeWindowsItem: self];
[NSApp removeWindowsItem: self];
[self orderOut: self];
if (is_released_when_closed)
@ -1009,7 +1004,7 @@ static Class responderClass;
is_edited = flag;
if (menu_exclude == NO)
{
[[NSApplication sharedApplication] updateWindowsItem: self];
[NSApp updateWindowsItem: self];
}
}
}
@ -1029,15 +1024,13 @@ static Class responderClass;
- (NSEvent *) currentEvent
{
return [[NSApplication sharedApplication] currentEvent];
return [NSApp currentEvent];
}
- (void) discardEventsMatchingMask: (unsigned int)mask
beforeEvent: (NSEvent *)lastEvent
{
NSApplication *theApp = [NSApplication sharedApplication];
[theApp discardEventsMatchingMask: mask beforeEvent: lastEvent];
[NSApp discardEventsMatchingMask: mask beforeEvent: lastEvent];
}
- (NSResponder*) firstResponder
@ -1072,18 +1065,24 @@ static Class responderClass;
}
/* Return mouse location in reciever's base coord system, ignores event
* loop status (backend) */
* loop status */
- (NSPoint) mouseLocationOutsideOfEventStream
{
return NSZeroPoint;
float x;
float y;
DPSmouselocation(GSCurrentContext(), &x, &y);
x -= frame.origin.x;
y -= frame.origin.y;
return NSMakePoint(x, y);
}
- (NSEvent *) nextEventMatchingMask: (unsigned int)mask
{
return [[NSApplication sharedApplication] nextEventMatchingMask: mask
untilDate: nil
inMode: NSEventTrackingRunLoopMode
dequeue: YES];
return [NSApp nextEventMatchingMask: mask
untilDate: nil
inMode: NSEventTrackingRunLoopMode
dequeue: YES];
}
- (NSEvent *) nextEventMatchingMask: (unsigned int)mask
@ -1091,15 +1090,15 @@ static Class responderClass;
inMode: (NSString *)mode
dequeue: (BOOL)deqFlag
{
return [[NSApplication sharedApplication] nextEventMatchingMask: mask
untilDate: expiration
inMode: mode
dequeue: deqFlag];
return [NSApp nextEventMatchingMask: mask
untilDate: expiration
inMode: mode
dequeue: deqFlag];
}
- (void) postEvent: (NSEvent *)event atStart: (BOOL)flag
{
[[NSApplication sharedApplication] postEvent: event atStart: flag];
[NSApp postEvent: event atStart: flag];
}
- (void) setAcceptsMouseMovedEvents: (BOOL)flag
@ -1486,9 +1485,8 @@ static Class responderClass;
returnType: returnType];
if (result == nil)
result = [[NSApplication sharedApplication]
validRequestorForSendType: sendType
returnType: returnType];
result = [NSApp validRequestorForSendType: sendType
returnType: returnType];
return result;
}