mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-21 00:11:11 +00:00
Updated for dps event functions
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4338 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d49691dc88
commit
58512c20c4
5 changed files with 160 additions and 454 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Wed Jun 2 19:22:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
|
* Headers/gnustep/gui/DPSOperators.h: Fixed error in event functions.
|
||||||
|
* Headers/gnustep/gui/PSOperators.h: Fixed error in event functions.
|
||||||
|
* Headers/gnustep/gui/NSApplication.h: Removed unused event queue.
|
||||||
|
* Source/NSApplication.m: Rewrote all event handling.
|
||||||
|
* Source/NSGraphicsContext.m: initialise dps event functions.
|
||||||
|
|
||||||
Wed Jun 2 8:34:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
Wed Jun 2 8:34:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
* Tools/make_services.m: Updated to use the GNUSTEP_PATHPREFIX_LIST
|
* Tools/make_services.m: Updated to use the GNUSTEP_PATHPREFIX_LIST
|
||||||
|
|
|
@ -1906,7 +1906,7 @@ DPSGetEvent(GSCTXT *ctxt, unsigned mask, NSDate* limit, NSString *mode)
|
||||||
{
|
{
|
||||||
return (ctxt->methods->DPSGetEventMatchingMask_beforeDate_inMode_dequeue_)
|
return (ctxt->methods->DPSGetEventMatchingMask_beforeDate_inMode_dequeue_)
|
||||||
(ctxt, @selector(DPSGetEventMatchingMask:beforeDate:inMode:dequeue:),
|
(ctxt, @selector(DPSGetEventMatchingMask:beforeDate:inMode:dequeue:),
|
||||||
mask, limit, mode, NO);
|
mask, limit, mode, YES);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline NSEvent*
|
static inline NSEvent*
|
||||||
|
@ -1914,7 +1914,7 @@ DPSPeekEvent(GSCTXT *ctxt, unsigned mask, NSDate* limit, NSString *mode)
|
||||||
{
|
{
|
||||||
return (ctxt->methods->DPSGetEventMatchingMask_beforeDate_inMode_dequeue_)
|
return (ctxt->methods->DPSGetEventMatchingMask_beforeDate_inMode_dequeue_)
|
||||||
(ctxt, @selector(DPSGetEventMatchingMask:beforeDate:inMode:dequeue:),
|
(ctxt, @selector(DPSGetEventMatchingMask:beforeDate:inMode:dequeue:),
|
||||||
mask, limit, mode, YES);
|
mask, limit, mode, NO);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
|
|
@ -61,7 +61,6 @@ extern NSString *NSEventTrackingRunLoopMode;
|
||||||
@interface NSApplication : NSResponder <NSCoding>
|
@interface NSApplication : NSResponder <NSCoding>
|
||||||
{
|
{
|
||||||
// Attributes
|
// Attributes
|
||||||
NSMutableArray *event_queue;
|
|
||||||
NSEvent *current_event;
|
NSEvent *current_event;
|
||||||
NSModalSession session;
|
NSModalSession session;
|
||||||
id key_window;
|
id key_window;
|
||||||
|
@ -262,19 +261,6 @@ extern NSString *NSEventTrackingRunLoopMode;
|
||||||
- (void)encodeWithCoder:aCoder;
|
- (void)encodeWithCoder:aCoder;
|
||||||
- initWithCoder:aDecoder;
|
- initWithCoder:aDecoder;
|
||||||
|
|
||||||
//
|
|
||||||
// Backend methods
|
|
||||||
//
|
|
||||||
|
|
||||||
// the null event
|
|
||||||
+ (void)setNullEvent:(NSEvent *)e;
|
|
||||||
+ (NSEvent *)getNullEvent;
|
|
||||||
|
|
||||||
/* Private methods */
|
|
||||||
|
|
||||||
// Get next event
|
|
||||||
- (void)_nextEvent;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -62,23 +62,7 @@
|
||||||
#include <AppKit/NSCursor.h>
|
#include <AppKit/NSCursor.h>
|
||||||
#include <AppKit/GSServicesManager.h>
|
#include <AppKit/GSServicesManager.h>
|
||||||
#include <AppKit/IMLoading.h>
|
#include <AppKit/IMLoading.h>
|
||||||
|
#include <AppKit/DPSOperators.h>
|
||||||
#ifndef ASSIGN
|
|
||||||
#define ASSIGN(object,value) ({\
|
|
||||||
if (value != object) \
|
|
||||||
{ \
|
|
||||||
if (value) \
|
|
||||||
{ \
|
|
||||||
[value retain]; \
|
|
||||||
} \
|
|
||||||
if (object) \
|
|
||||||
{ \
|
|
||||||
[object release]; \
|
|
||||||
} \
|
|
||||||
object = value; \
|
|
||||||
} \
|
|
||||||
})
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Types
|
// Types
|
||||||
|
@ -144,7 +128,7 @@ NSApplication *NSApp = nil;
|
||||||
{
|
{
|
||||||
if (NSApp != self)
|
if (NSApp != self)
|
||||||
{
|
{
|
||||||
[self release];
|
RELEASE(self);
|
||||||
return [NSApplication sharedApplication];
|
return [NSApplication sharedApplication];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,19 +141,11 @@ NSApplication *NSApp = nil;
|
||||||
main_menu = nil;
|
main_menu = nil;
|
||||||
windows_need_update = YES;
|
windows_need_update = YES;
|
||||||
|
|
||||||
event_queue = [NSMutableArray new]; // allocate event queue
|
|
||||||
current_event = [NSEvent new]; // no current event
|
current_event = [NSEvent new]; // no current event
|
||||||
null_event = [NSEvent new]; // create dummy event
|
null_event = [NSEvent new]; // create dummy event
|
||||||
|
|
||||||
[self setNextResponder: nil]; // We are the end of
|
/* We are the end of responder chain */
|
||||||
// the responder chain
|
[self setNextResponder: nil];
|
||||||
|
|
||||||
// Set up the run loop object for the current thread
|
|
||||||
[self setupRunLoopInputSourcesForMode: NSDefaultRunLoopMode];
|
|
||||||
[self setupRunLoopInputSourcesForMode: NSConnectionReplyMode];
|
|
||||||
[self setupRunLoopInputSourcesForMode: NSModalPanelRunLoopMode];
|
|
||||||
[self setupRunLoopInputSourcesForMode: NSEventTrackingRunLoopMode];
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,9 +210,9 @@ NSApplication *NSApp = nil;
|
||||||
/* Let ourselves know we are within dealloc */
|
/* Let ourselves know we are within dealloc */
|
||||||
gnustep_gui_app_is_in_dealloc = YES;
|
gnustep_gui_app_is_in_dealloc = YES;
|
||||||
|
|
||||||
[listener release];
|
RELEASE(listener);
|
||||||
[event_queue release];
|
RELEASE(null_event);
|
||||||
[current_event release];
|
RELEASE(current_event);
|
||||||
|
|
||||||
/* We may need to tidy up nested modal session structures. */
|
/* We may need to tidy up nested modal session structures. */
|
||||||
while (session != 0)
|
while (session != 0)
|
||||||
|
@ -344,7 +320,7 @@ NSApplication *NSApp = nil;
|
||||||
if (windows_need_update)
|
if (windows_need_update)
|
||||||
[self updateWindows];
|
[self updateWindows];
|
||||||
|
|
||||||
[pool release];
|
RELEASE(pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
NSDebugLog(@"NSApplication end of run loop\n");
|
NSDebugLog(@"NSApplication end of run loop\n");
|
||||||
|
@ -444,10 +420,10 @@ NSApplication *NSApp = nil;
|
||||||
|
|
||||||
- (int) runModalSession: (NSModalSession)theSession
|
- (int) runModalSession: (NSModalSession)theSession
|
||||||
{
|
{
|
||||||
|
NSGraphicsContext *ctxt;
|
||||||
BOOL found = NO;
|
BOOL found = NO;
|
||||||
NSEvent *event;
|
NSEvent *event;
|
||||||
unsigned count;
|
NSDate *limit;
|
||||||
unsigned i;
|
|
||||||
|
|
||||||
if (theSession != session)
|
if (theSession != session)
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
|
@ -457,35 +433,23 @@ NSApplication *NSApp = nil;
|
||||||
[theSession->window display];
|
[theSession->window display];
|
||||||
[theSession->window makeKeyAndOrderFront: self];
|
[theSession->window makeKeyAndOrderFront: self];
|
||||||
|
|
||||||
// First we make sure
|
ctxt = GSCurrentContext();
|
||||||
// that there is an
|
|
||||||
// event.
|
/*
|
||||||
|
* Set a limit date in the distant future so we wait until we get an
|
||||||
|
* event. We discard events that are not for this window. When we
|
||||||
|
* find one for this window, we push it back at the start of the queue.
|
||||||
|
*/
|
||||||
|
limit = [NSDate distantFuture];
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
count = [event_queue count];
|
event = DPSGetEvent(ctxt, NSAnyEventMask, limit, NSDefaultRunLoopMode);
|
||||||
for (i = 0; i < count; i++)
|
if (event != nil && [event window] == theSession->window)
|
||||||
{
|
|
||||||
event = [event_queue objectAtIndex: 0];
|
|
||||||
if ([event window] == theSession->window)
|
|
||||||
{
|
{
|
||||||
|
DPSPostEvent(ctxt, event, YES);
|
||||||
found = YES;
|
found = YES;
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// dump events not for
|
|
||||||
// the modal window
|
|
||||||
[event_queue removeObjectAtIndex: 0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (found == NO)
|
|
||||||
{
|
|
||||||
NSDate *limitDate = [NSDate distantFuture];
|
|
||||||
|
|
||||||
[[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode
|
|
||||||
beforeDate: limitDate];
|
|
||||||
}
|
}
|
||||||
|
RELEASE(event);
|
||||||
}
|
}
|
||||||
while (found == NO && theSession->runState == NSRunContinuesResponse);
|
while (found == NO && theSession->runState == NSRunContinuesResponse);
|
||||||
|
|
||||||
|
@ -496,19 +460,16 @@ NSApplication *NSApp = nil;
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||||
|
|
||||||
found = NO;
|
event = DPSGetEvent(ctxt, NSAnyEventMask, nil, NSDefaultRunLoopMode);
|
||||||
count = [event_queue count];
|
if (event != nil && [event window] == theSession->window)
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
event = [event_queue objectAtIndex: i];
|
|
||||||
if ([event window] == theSession->window)
|
|
||||||
{
|
{
|
||||||
ASSIGN(current_event, event);
|
ASSIGN(current_event, event);
|
||||||
[event_queue removeObjectAtIndex: i];
|
|
||||||
found = YES;
|
found = YES;
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RELEASE(event);
|
||||||
|
found = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found == YES)
|
if (found == YES)
|
||||||
|
@ -530,7 +491,7 @@ NSApplication *NSApp = nil;
|
||||||
[self updateWindows];
|
[self updateWindows];
|
||||||
}
|
}
|
||||||
|
|
||||||
[pool release];
|
RELEASE(pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
NSAssert(session == theSession, @"Session was changed while running");
|
NSAssert(session == theSession, @"Session was changed while running");
|
||||||
|
@ -569,16 +530,16 @@ NSApplication *NSApp = nil;
|
||||||
//
|
//
|
||||||
- (void) sendEvent: (NSEvent *)theEvent
|
- (void) sendEvent: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
if (theEvent == null_event) // Don't send null event
|
if (theEvent == null_event)
|
||||||
{
|
{
|
||||||
NSDebugLog(@"Not sending the Null Event\n");
|
NSDebugLog(@"Not sending the Null Event\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ([theEvent type]) // determine the event type
|
switch ([theEvent type])
|
||||||
{
|
{
|
||||||
case NSPeriodic: // NSApplication traps the
|
case NSPeriodic: /* NSApplication traps the periodic events */
|
||||||
break; // periodic events
|
break;
|
||||||
|
|
||||||
case NSKeyDown:
|
case NSKeyDown:
|
||||||
{
|
{
|
||||||
|
@ -594,7 +555,7 @@ NSApplication *NSApp = nil;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case NSRightMouseDown: // Right mouse down
|
case NSRightMouseDown:
|
||||||
if (main_menu)
|
if (main_menu)
|
||||||
{
|
{
|
||||||
static NSMenu *copyOfMainMenu = nil;
|
static NSMenu *copyOfMainMenu = nil;
|
||||||
|
@ -610,8 +571,8 @@ NSApplication *NSApp = nil;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: // pass all other events to
|
default: /* pass all other events to the event's window */
|
||||||
{ // the event's window
|
{
|
||||||
NSWindow* window = [theEvent window];
|
NSWindow* window = [theEvent window];
|
||||||
|
|
||||||
if (!theEvent)
|
if (!theEvent)
|
||||||
|
@ -634,280 +595,37 @@ NSApplication *NSApp = nil;
|
||||||
- (void) discardEventsMatchingMask: (unsigned int)mask
|
- (void) discardEventsMatchingMask: (unsigned int)mask
|
||||||
beforeEvent: (NSEvent *)lastEvent
|
beforeEvent: (NSEvent *)lastEvent
|
||||||
{
|
{
|
||||||
unsigned i = 0, count, loop;
|
DPSDiscardEvents(GSCurrentContext(), mask, lastEvent);
|
||||||
NSEvent *event = nil;
|
|
||||||
BOOL match;
|
|
||||||
// if queue contains
|
|
||||||
if ((count = [event_queue count])) // events check them
|
|
||||||
{
|
|
||||||
for (loop = 0; ((event != lastEvent) && (loop < count)); loop++)
|
|
||||||
{
|
|
||||||
event = [event_queue objectAtIndex: i]; // Get next event from
|
|
||||||
match = NO; // the events queue
|
|
||||||
|
|
||||||
if (mask == NSAnyEventMask) // the any event mask
|
|
||||||
match = YES; // matches all events
|
|
||||||
else
|
|
||||||
{
|
|
||||||
switch([event type])
|
|
||||||
{
|
|
||||||
case NSLeftMouseDown:
|
|
||||||
if (mask & NSLeftMouseDownMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSLeftMouseUp:
|
|
||||||
if (mask & NSLeftMouseUpMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSRightMouseDown:
|
|
||||||
if (mask & NSRightMouseDownMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSRightMouseUp:
|
|
||||||
if (mask & NSRightMouseUpMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSMouseMoved:
|
|
||||||
if (mask & NSMouseMovedMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSMouseEntered:
|
|
||||||
if (mask & NSMouseEnteredMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSMouseExited:
|
|
||||||
if (mask & NSMouseExitedMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSLeftMouseDragged:
|
|
||||||
if (mask & NSLeftMouseDraggedMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSRightMouseDragged:
|
|
||||||
if (mask & NSRightMouseDraggedMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSKeyDown:
|
|
||||||
if (mask & NSKeyDownMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSKeyUp:
|
|
||||||
if (mask & NSKeyUpMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSFlagsChanged:
|
|
||||||
if (mask & NSFlagsChangedMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSPeriodic:
|
|
||||||
if (mask & NSPeriodicMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSCursorUpdate:
|
|
||||||
if (mask & NSCursorUpdateMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
} } // remove event from
|
|
||||||
// the queue if it
|
|
||||||
if (match) // matched the mask
|
|
||||||
[event_queue removeObjectAtIndex: i];
|
|
||||||
else // inc queue cntr only
|
|
||||||
i++; // if not a match else
|
|
||||||
} // we will run off the
|
|
||||||
} // end of the queue
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSEvent*) _eventMatchingMask: (unsigned int)mask dequeue: (BOOL)flag
|
|
||||||
{
|
|
||||||
NSEvent *event; // return the next
|
|
||||||
unsigned i, count; // event in the queue
|
|
||||||
BOOL match = NO; // which matches mask
|
|
||||||
|
|
||||||
[self _nextEvent];
|
|
||||||
|
|
||||||
if ((count = [event_queue count])) // if queue contains
|
|
||||||
{ // events check them
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{ // Get next event from
|
|
||||||
event = [event_queue objectAtIndex: i]; // the events queue
|
|
||||||
|
|
||||||
if (mask == NSAnyEventMask) // the any event mask
|
|
||||||
match = YES; // matches all events
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (event == null_event) // do not send the null
|
|
||||||
{ // event
|
|
||||||
match = NO;
|
|
||||||
if (flag) // dequeue null event
|
|
||||||
{ // if flag is set
|
|
||||||
[event retain];
|
|
||||||
[event_queue removeObjectAtIndex: i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
switch([event type])
|
|
||||||
{
|
|
||||||
case NSLeftMouseDown:
|
|
||||||
if (mask & NSLeftMouseDownMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSLeftMouseUp:
|
|
||||||
if (mask & NSLeftMouseUpMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSRightMouseDown:
|
|
||||||
if (mask & NSRightMouseDownMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSRightMouseUp:
|
|
||||||
if (mask & NSRightMouseUpMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSMouseMoved:
|
|
||||||
if (mask & NSMouseMovedMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSMouseEntered:
|
|
||||||
if (mask & NSMouseEnteredMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSMouseExited:
|
|
||||||
if (mask & NSMouseExitedMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSLeftMouseDragged:
|
|
||||||
if (mask & NSLeftMouseDraggedMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSRightMouseDragged:
|
|
||||||
if (mask & NSRightMouseDraggedMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSKeyDown:
|
|
||||||
if (mask & NSKeyDownMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSKeyUp:
|
|
||||||
if (mask & NSKeyUpMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSFlagsChanged:
|
|
||||||
if (mask & NSFlagsChangedMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSPeriodic:
|
|
||||||
if (mask & NSPeriodicMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSCursorUpdate:
|
|
||||||
if (mask & NSCursorUpdateMask)
|
|
||||||
match = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
match = NO;
|
|
||||||
break;
|
|
||||||
} } }
|
|
||||||
|
|
||||||
if (match)
|
|
||||||
{
|
|
||||||
if (flag) // dequeue the event if
|
|
||||||
{ // flag is set
|
|
||||||
[event retain];
|
|
||||||
[event_queue removeObjectAtIndex: i];
|
|
||||||
}
|
|
||||||
ASSIGN(current_event, event);
|
|
||||||
|
|
||||||
return event; // return an event from
|
|
||||||
} // the queue which
|
|
||||||
} // matches the mask
|
|
||||||
}
|
|
||||||
// no event in the
|
|
||||||
return nil; // queue matches mask
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSEvent*) nextEventMatchingMask: (unsigned int)mask
|
- (NSEvent*) nextEventMatchingMask: (unsigned int)mask
|
||||||
untilDate: (NSDate *)expiration
|
untilDate: (NSDate*)expiration
|
||||||
inMode: (NSString *)mode
|
inMode: (NSString*)mode
|
||||||
dequeue: (BOOL)flag
|
dequeue: (BOOL)flag
|
||||||
{
|
{
|
||||||
NSEvent *event;
|
NSEvent *event;
|
||||||
BOOL done = NO;
|
|
||||||
|
|
||||||
if (mode == NSEventTrackingRunLoopMode) // temporary hack to
|
|
||||||
inTrackingLoop = YES; // regulate translation
|
|
||||||
else // of X motion events
|
|
||||||
inTrackingLoop = NO; // while not in a
|
|
||||||
// tracking loop
|
|
||||||
if ((event = [self _eventMatchingMask: mask dequeue: flag]))
|
|
||||||
done = YES;
|
|
||||||
else
|
|
||||||
if (!expiration)
|
if (!expiration)
|
||||||
expiration = [NSDate distantFuture];
|
expiration = [NSDate distantFuture];
|
||||||
|
|
||||||
while (!done) // Not in queue so wait
|
if (flag)
|
||||||
{ // for next event
|
event = DPSGetEvent(GSCurrentContext(), mask, expiration, mode);
|
||||||
NSDate *limitDate, *originalLimitDate;
|
|
||||||
NSRunLoop* currentLoop = [NSRunLoop currentRunLoop];
|
|
||||||
// Retain the limitDate so that it doesn't get released
|
|
||||||
// accidentally by runMode: beforeDate: if a timer which
|
|
||||||
// has this date as fire date gets released.
|
|
||||||
limitDate = [[currentLoop limitDateForMode: mode] retain];
|
|
||||||
originalLimitDate = limitDate;
|
|
||||||
|
|
||||||
if ((event = [self _eventMatchingMask: mask dequeue: flag]))
|
|
||||||
{
|
|
||||||
[limitDate release];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (limitDate)
|
|
||||||
limitDate = [expiration earlierDate: limitDate];
|
|
||||||
else
|
else
|
||||||
limitDate = expiration;
|
event = DPSPeekEvent(GSCurrentContext(), mask, expiration, mode);
|
||||||
|
|
||||||
[currentLoop runMode: mode beforeDate: limitDate];
|
if (event)
|
||||||
[originalLimitDate release];
|
|
||||||
|
|
||||||
if ((event = [self _eventMatchingMask: mask dequeue: flag]))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// no need to unhide cursor
|
|
||||||
if (!inTrackingLoop) // while in a tracking loop
|
|
||||||
{
|
{
|
||||||
if ([NSCursor isHiddenUntilMouseMoves]) // do so only if we should
|
NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
|
||||||
{ // unhide when mouse moves
|
/*
|
||||||
NSEventType type = [event type]; // and event is mouse event
|
* If we are not in a tracking loop, we may want to unhide a hidden
|
||||||
|
* because the mouse has been moved.
|
||||||
|
*/
|
||||||
|
if (mode != NSEventTrackingRunLoopMode)
|
||||||
|
{
|
||||||
|
if ([NSCursor isHiddenUntilMouseMoves])
|
||||||
|
{
|
||||||
|
NSEventType type = [event type];
|
||||||
|
|
||||||
if ((type == NSLeftMouseDown) || (type == NSLeftMouseUp)
|
if ((type == NSLeftMouseDown) || (type == NSLeftMouseUp)
|
||||||
|| (type == NSRightMouseDown) || (type == NSRightMouseUp)
|
|| (type == NSRightMouseDown) || (type == NSRightMouseUp)
|
||||||
|| (type == NSMouseMoved))
|
|| (type == NSMouseMoved))
|
||||||
|
@ -917,15 +635,14 @@ NSApplication *NSApp = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ASSIGN(current_event, event);
|
||||||
|
}
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) postEvent: (NSEvent *)event atStart: (BOOL)flag
|
- (void) postEvent: (NSEvent *)event atStart: (BOOL)flag
|
||||||
{
|
{
|
||||||
if (!flag)
|
DPSPostEvent(GSCurrentContext(), event, flag);
|
||||||
[event_queue addObject: event];
|
|
||||||
else
|
|
||||||
[event_queue insertObject: event atIndex: 0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1343,15 +1060,15 @@ NSApplication *NSApp = nil;
|
||||||
NSMenuItem *mc;
|
NSMenuItem *mc;
|
||||||
NSArray *mi;
|
NSArray *mi;
|
||||||
|
|
||||||
[aMenu retain]; // Release old menu and
|
ASSIGN(main_menu, aMenu);
|
||||||
if (main_menu) // retain new
|
|
||||||
[main_menu release];
|
|
||||||
main_menu = aMenu;
|
|
||||||
|
|
||||||
mi = [main_menu itemArray]; // find a menucell with
|
/*
|
||||||
j = [mi count]; // the title Windows
|
* Find a menucell with the title Windows this is the default windows menu
|
||||||
windows_menu = nil; // this is the default
|
*/
|
||||||
for (i = 0; i < j; ++i) // windows menu
|
mi = [main_menu itemArray];
|
||||||
|
j = [mi count];
|
||||||
|
windows_menu = nil;
|
||||||
|
for (i = 0; i < j; ++i)
|
||||||
{
|
{
|
||||||
mc = [mi objectAtIndex: i];
|
mc = [mi objectAtIndex: i];
|
||||||
if ([[mc stringValue] compare: @"Windows"] == NSOrderedSame)
|
if ([[mc stringValue] compare: @"Windows"] == NSOrderedSame)
|
||||||
|
@ -1679,11 +1396,15 @@ NSApplication *NSApp = nil;
|
||||||
- (void) terminate: (id)sender
|
- (void) terminate: (id)sender
|
||||||
{
|
{
|
||||||
if ([self applicationShouldTerminate: self])
|
if ([self applicationShouldTerminate: self])
|
||||||
{ // app should end run loop
|
{
|
||||||
app_should_quit = YES;
|
app_should_quit = YES;
|
||||||
[event_queue addObject: null_event]; // add dummy event to queue
|
/*
|
||||||
} // to assure loop cycles
|
* add dummy event to queue to assure loop cycles
|
||||||
} // at least one more time
|
* at least one more time
|
||||||
|
*/
|
||||||
|
DPSPostEvent(GSCurrentContext(), null_event, NO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (id) delegate // Assigning a delegate
|
- (id) delegate // Assigning a delegate
|
||||||
{
|
{
|
||||||
|
@ -1870,23 +1591,5 @@ NSApplication *NSApp = nil;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void) setNullEvent: (NSEvent *)e
|
|
||||||
{
|
|
||||||
ASSIGN(null_event, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (NSEvent *) getNullEvent;
|
|
||||||
{ // return the class
|
|
||||||
return null_event; // dummy event
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) _nextEvent // get next event
|
|
||||||
{ // implemented in
|
|
||||||
} // backend
|
|
||||||
|
|
||||||
- (void) setupRunLoopInputSourcesForMode: (NSString*)mode
|
|
||||||
{ // implemented in
|
|
||||||
} // backend
|
|
||||||
|
|
||||||
@end /* NSApplication */
|
@end /* NSApplication */
|
||||||
|
|
||||||
|
|
|
@ -634,6 +634,15 @@ struct NSWindow_struct
|
||||||
GET_IMP(@selector(DPSsetalpha:));
|
GET_IMP(@selector(DPSsetalpha:));
|
||||||
methodTable.DPScurrentalpha_ =
|
methodTable.DPScurrentalpha_ =
|
||||||
GET_IMP(@selector(DPScurrentalpha:));
|
GET_IMP(@selector(DPScurrentalpha:));
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
/* GNUstep Event and other I/O extensions */
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
methodTable.DPSGetEventMatchingMask_beforeDate_inMode_dequeue_ =
|
||||||
|
GET_IMP(@selector(DPSGetEventMatchingMask:beforeDate:inMode:dequeue:));
|
||||||
|
methodTable.DPSDiscardEventsMatchingMask_beforeEvent_ =
|
||||||
|
GET_IMP(@selector(DPSDiscardEventsMatchingMask:beforeEvent:));
|
||||||
|
methodTable.DPSPostEvent_atStart_ =
|
||||||
|
GET_IMP(@selector(DPSPostEvent:atStart:));
|
||||||
|
|
||||||
mptr = NSZoneMalloc(_globalGSZone, sizeof(gsMethodTable));
|
mptr = NSZoneMalloc(_globalGSZone, sizeof(gsMethodTable));
|
||||||
memcpy(mptr, &methodTable, sizeof(gsMethodTable));
|
memcpy(mptr, &methodTable, sizeof(gsMethodTable));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue