mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-03 09:00:42 +00:00
* Headers/Additions/GNUstepGUI/GSDisplayServer.h
* Source/GSDisplayServer.m: Add new method -_printEventQueue. * Source/NSWindow.m (-_checkCursorRectangles:forEvent:): Replace hack with proper functions that handle cursor rectangles. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@37026 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
645a552a58
commit
23d7de30cb
4 changed files with 217 additions and 107 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2013-08-30 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Headers/Additions/GNUstepGUI/GSDisplayServer.h
|
||||||
|
* Source/GSDisplayServer.m: Add new method -_printEventQueue.
|
||||||
|
* Source/NSWindow.m (-_checkCursorRectangles:forEvent:): Replace
|
||||||
|
hack with proper functions that handle cursor rectangles.
|
||||||
|
|
||||||
2013-08-27 Fred Kiefer <FredKiefer@gmx.de>
|
2013-08-27 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSCursor.m (-mouseEntered:, -mouseExited:):
|
* Source/NSCursor.m (-mouseEntered:, -mouseExited:):
|
||||||
|
|
|
@ -190,6 +190,7 @@ APPKIT_EXPORT NSString *GSScreenNumber;
|
||||||
- (void) discardEventsMatchingMask: (unsigned)mask
|
- (void) discardEventsMatchingMask: (unsigned)mask
|
||||||
beforeEvent: (NSEvent*)limit;
|
beforeEvent: (NSEvent*)limit;
|
||||||
- (void) postEvent: (NSEvent*)anEvent atStart: (BOOL)flag;
|
- (void) postEvent: (NSEvent*)anEvent atStart: (BOOL)flag;
|
||||||
|
- (void) _printEventQueue;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -331,7 +331,7 @@ GSCurrentServer(void)
|
||||||
NSCountedSet *old = (NSCountedSet*)NSMapGet(drag_types, (void*)win);
|
NSCountedSet *old = (NSCountedSet*)NSMapGet(drag_types, (void*)win);
|
||||||
NSEnumerator *drag_enum = [types objectEnumerator];
|
NSEnumerator *drag_enum = [types objectEnumerator];
|
||||||
id type;
|
id type;
|
||||||
unsigned originalCount;
|
NSUInteger originalCount;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure the set exists.
|
* Make sure the set exists.
|
||||||
|
@ -970,14 +970,14 @@ GSCurrentServer(void)
|
||||||
inMode: (NSString*)mode
|
inMode: (NSString*)mode
|
||||||
dequeue: (BOOL)flag
|
dequeue: (BOOL)flag
|
||||||
{
|
{
|
||||||
unsigned pos = 0; /* Position in queue scanned so far */
|
NSUInteger pos = 0; /* Position in queue scanned so far */
|
||||||
NSRunLoop *loop = nil;
|
NSRunLoop *loop = nil;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
unsigned count = [event_queue count];
|
NSUInteger count = [event_queue count];
|
||||||
NSEvent *event;
|
NSEvent *event;
|
||||||
unsigned i = 0;
|
NSUInteger i = 0;
|
||||||
|
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
{
|
{
|
||||||
|
@ -999,7 +999,7 @@ GSCurrentServer(void)
|
||||||
*/
|
*/
|
||||||
if (count > pos)
|
if (count > pos)
|
||||||
{
|
{
|
||||||
unsigned end = count - pos;
|
NSUInteger end = count - pos;
|
||||||
NSRange r = NSMakeRange(pos, end);
|
NSRange r = NSMakeRange(pos, end);
|
||||||
NSEvent *events[end];
|
NSEvent *events[end];
|
||||||
|
|
||||||
|
@ -1055,7 +1055,7 @@ GSCurrentServer(void)
|
||||||
- (void) discardEventsMatchingMask: (unsigned)mask
|
- (void) discardEventsMatchingMask: (unsigned)mask
|
||||||
beforeEvent: (NSEvent*)limit
|
beforeEvent: (NSEvent*)limit
|
||||||
{
|
{
|
||||||
unsigned index = [event_queue count];
|
NSUInteger index = [event_queue count];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there is a range to use - remove all the matching events in it
|
* If there is a range to use - remove all the matching events in it
|
||||||
|
@ -1096,4 +1096,29 @@ GSCurrentServer(void)
|
||||||
[event_queue addObject: anEvent];
|
[event_queue addObject: anEvent];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) _printEventQueue
|
||||||
|
{
|
||||||
|
NSUInteger index = [event_queue count];
|
||||||
|
|
||||||
|
if (index > 0)
|
||||||
|
{
|
||||||
|
NSEvent *events[index];
|
||||||
|
NSUInteger i;
|
||||||
|
|
||||||
|
NSLog(@"Dumping events from queue");
|
||||||
|
[event_queue getObjects: events];
|
||||||
|
|
||||||
|
for (i = 0; i < index; i++)
|
||||||
|
{
|
||||||
|
NSEvent *event = events[i];
|
||||||
|
|
||||||
|
NSLog(@"index %d %@", i, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSLog(@"Event queue is empty");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -2761,6 +2761,164 @@ resetCursorRectsForView(NSView *theView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
checkCursorRectanglesEntered(NSView *theView, NSEvent *theEvent, NSPoint lastPoint)
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check cursor rectangles for the subviews
|
||||||
|
*/
|
||||||
|
if (theView->_rFlags.has_subviews)
|
||||||
|
{
|
||||||
|
NSArray *sb = theView->_sub_views;
|
||||||
|
NSUInteger count = [sb count];
|
||||||
|
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
NSView *subs[count];
|
||||||
|
NSUInteger i;
|
||||||
|
|
||||||
|
[sb getObjects: subs];
|
||||||
|
for (i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
if (![subs[i] isHidden])
|
||||||
|
{
|
||||||
|
checkCursorRectanglesEntered(subs[i], theEvent, lastPoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (theView->_rFlags.valid_rects)
|
||||||
|
{
|
||||||
|
NSArray *tr = theView->_cursor_rects;
|
||||||
|
NSUInteger count = [tr count];
|
||||||
|
|
||||||
|
// Loop through cursor rectangles
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
GSTrackingRect *rects[count];
|
||||||
|
NSPoint loc = [theEvent locationInWindow];
|
||||||
|
NSUInteger i;
|
||||||
|
|
||||||
|
[tr getObjects: rects];
|
||||||
|
|
||||||
|
for (i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
GSTrackingRect *r = rects[i];
|
||||||
|
BOOL last;
|
||||||
|
BOOL now;
|
||||||
|
|
||||||
|
if ([r isValid] == NO)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check for presence of point in rectangle.
|
||||||
|
*/
|
||||||
|
last = NSMouseInRect(lastPoint, r->rectangle, NO);
|
||||||
|
now = NSMouseInRect(loc, r->rectangle, NO);
|
||||||
|
|
||||||
|
// Mouse entered
|
||||||
|
if ((!last) && (now))
|
||||||
|
{
|
||||||
|
NSEvent *e;
|
||||||
|
|
||||||
|
e = [NSEvent enterExitEventWithType: NSCursorUpdate
|
||||||
|
location: loc
|
||||||
|
modifierFlags: [theEvent modifierFlags]
|
||||||
|
timestamp: 0
|
||||||
|
windowNumber: [theEvent windowNumber]
|
||||||
|
context: [theEvent context]
|
||||||
|
eventNumber: 0
|
||||||
|
trackingNumber: (int)YES
|
||||||
|
userData: (void*)r];
|
||||||
|
[NSApp postEvent: e atStart: YES];
|
||||||
|
//NSLog(@"Add enter event %@ for view %@ rect %@", e, theView, NSStringFromRect(r->rectangle));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
checkCursorRectanglesExited(NSView *theView, NSEvent *theEvent, NSPoint lastPoint)
|
||||||
|
{
|
||||||
|
if (theView->_rFlags.valid_rects)
|
||||||
|
{
|
||||||
|
NSArray *tr = theView->_cursor_rects;
|
||||||
|
NSUInteger count = [tr count];
|
||||||
|
|
||||||
|
// Loop through cursor rectangles
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
GSTrackingRect *rects[count];
|
||||||
|
NSPoint loc = [theEvent locationInWindow];
|
||||||
|
NSUInteger i;
|
||||||
|
|
||||||
|
[tr getObjects: rects];
|
||||||
|
|
||||||
|
for (i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
GSTrackingRect *r = rects[i];
|
||||||
|
BOOL last;
|
||||||
|
BOOL now;
|
||||||
|
|
||||||
|
if ([r isValid] == NO)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check for presence of point in rectangle.
|
||||||
|
*/
|
||||||
|
last = NSMouseInRect(lastPoint, r->rectangle, NO);
|
||||||
|
now = NSMouseInRect(loc, r->rectangle, NO);
|
||||||
|
|
||||||
|
// Mouse exited
|
||||||
|
if ((last) && (!now))
|
||||||
|
{
|
||||||
|
NSEvent *e;
|
||||||
|
|
||||||
|
e = [NSEvent enterExitEventWithType: NSCursorUpdate
|
||||||
|
location: loc
|
||||||
|
modifierFlags: [theEvent modifierFlags]
|
||||||
|
timestamp: 0
|
||||||
|
windowNumber: [theEvent windowNumber]
|
||||||
|
context: [theEvent context]
|
||||||
|
eventNumber: 0
|
||||||
|
trackingNumber: (int)NO
|
||||||
|
userData: (void*)r];
|
||||||
|
[NSApp postEvent: e atStart: YES];
|
||||||
|
//[NSApp postEvent: e atStart: NO];
|
||||||
|
//NSLog(@"Add exit event %@ for view %@ rect %@", e, theView, NSStringFromRect(r->rectangle));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check cursor rectangles for the subviews
|
||||||
|
*/
|
||||||
|
if (theView->_rFlags.has_subviews)
|
||||||
|
{
|
||||||
|
NSArray *sb = theView->_sub_views;
|
||||||
|
NSUInteger count = [sb count];
|
||||||
|
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
NSView *subs[count];
|
||||||
|
NSUInteger i;
|
||||||
|
|
||||||
|
[sb getObjects: subs];
|
||||||
|
for (i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
if (![subs[i] isHidden])
|
||||||
|
{
|
||||||
|
checkCursorRectanglesExited(subs[i], theEvent, lastPoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void) resetCursorRects
|
- (void) resetCursorRects
|
||||||
{
|
{
|
||||||
[self discardCursorRects];
|
[self discardCursorRects];
|
||||||
|
@ -2782,7 +2940,7 @@ resetCursorRectsForView(NSView *theView)
|
||||||
clickCount: 0
|
clickCount: 0
|
||||||
pressure: 0];
|
pressure: 0];
|
||||||
_lastPoint = NSMakePoint(-1,-1);
|
_lastPoint = NSMakePoint(-1,-1);
|
||||||
(*ccImp)(self, ccSel, _wv, e);
|
checkCursorRectanglesEntered(_wv, e, _lastPoint);
|
||||||
_lastPoint = loc;
|
_lastPoint = loc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3598,99 +3756,12 @@ resetCursorRectsForView(NSView *theView)
|
||||||
|
|
||||||
- (void) _checkCursorRectangles: (NSView*)theView forEvent: (NSEvent*)theEvent
|
- (void) _checkCursorRectangles: (NSView*)theView forEvent: (NSEvent*)theEvent
|
||||||
{
|
{
|
||||||
// FIXME: What this method should do is to send exit events before enter events
|
// As we add the events to the front of the queue, we need to add the last
|
||||||
// And all enter events should be sorted from outer to inner. With the current
|
// events first. That is, first the enter evnts from inner to outer and
|
||||||
// hack to post the enter events at the end of the queue this is about correct,
|
// then the exit events
|
||||||
// as long as nothing else is in the event queue :-(
|
checkCursorRectanglesEntered(theView, theEvent, _lastPoint);
|
||||||
// Most likely similar reasoning should be applied to _checkTrackingRectangles:forEvent:
|
checkCursorRectanglesExited(theView, theEvent, _lastPoint);
|
||||||
// the best way to achive this seems to be having to separate loops over the hierarchy.
|
//[GSServerForWindow(self) _printEventQueue];
|
||||||
|
|
||||||
if (theView->_rFlags.valid_rects)
|
|
||||||
{
|
|
||||||
NSArray *tr = theView->_cursor_rects;
|
|
||||||
NSUInteger count = [tr count];
|
|
||||||
|
|
||||||
// Loop through cursor rectangles
|
|
||||||
if (count > 0)
|
|
||||||
{
|
|
||||||
GSTrackingRect *rects[count];
|
|
||||||
NSPoint loc = [theEvent locationInWindow];
|
|
||||||
NSUInteger i;
|
|
||||||
|
|
||||||
[tr getObjects: rects];
|
|
||||||
|
|
||||||
for (i = 0; i < count; ++i)
|
|
||||||
{
|
|
||||||
GSTrackingRect *r = rects[i];
|
|
||||||
BOOL last;
|
|
||||||
BOOL now;
|
|
||||||
|
|
||||||
if ([r isValid] == NO)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check for presence of point in rectangle.
|
|
||||||
*/
|
|
||||||
last = NSMouseInRect(_lastPoint, r->rectangle, NO);
|
|
||||||
now = NSMouseInRect(loc, r->rectangle, NO);
|
|
||||||
|
|
||||||
// Mouse entered
|
|
||||||
if ((!last) && (now))
|
|
||||||
{
|
|
||||||
NSEvent *e;
|
|
||||||
|
|
||||||
e = [NSEvent enterExitEventWithType: NSCursorUpdate
|
|
||||||
location: loc
|
|
||||||
modifierFlags: [theEvent modifierFlags]
|
|
||||||
timestamp: 0
|
|
||||||
windowNumber: [theEvent windowNumber]
|
|
||||||
context: [theEvent context]
|
|
||||||
eventNumber: 0
|
|
||||||
trackingNumber: (int)YES
|
|
||||||
userData: (void*)r];
|
|
||||||
[self postEvent: e atStart: NO];
|
|
||||||
}
|
|
||||||
// Mouse exited
|
|
||||||
if ((last) && (!now))
|
|
||||||
{
|
|
||||||
NSEvent *e;
|
|
||||||
|
|
||||||
e = [NSEvent enterExitEventWithType: NSCursorUpdate
|
|
||||||
location: loc
|
|
||||||
modifierFlags: [theEvent modifierFlags]
|
|
||||||
timestamp: 0
|
|
||||||
windowNumber: [theEvent windowNumber]
|
|
||||||
context: [theEvent context]
|
|
||||||
eventNumber: 0
|
|
||||||
trackingNumber: (int)NO
|
|
||||||
userData: (void*)r];
|
|
||||||
[self postEvent: e atStart: YES];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check cursor rectangles for the subviews
|
|
||||||
*/
|
|
||||||
if (theView->_rFlags.has_subviews)
|
|
||||||
{
|
|
||||||
NSArray *sb = theView->_sub_views;
|
|
||||||
NSUInteger count = [sb count];
|
|
||||||
|
|
||||||
if (count > 0)
|
|
||||||
{
|
|
||||||
NSView *subs[count];
|
|
||||||
NSUInteger i;
|
|
||||||
|
|
||||||
[sb getObjects: subs];
|
|
||||||
for (i = 0; i < count; ++i)
|
|
||||||
{
|
|
||||||
if (![subs[i] isHidden])
|
|
||||||
(*ccImp)(self, ccSel, subs[i], theEvent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _processResizeEvent
|
- (void) _processResizeEvent
|
||||||
|
@ -3934,8 +4005,10 @@ resetCursorRectsForView(NSView *theView)
|
||||||
* cursor update event.
|
* cursor update event.
|
||||||
*/
|
*/
|
||||||
if (_f.cursor_rects_enabled)
|
if (_f.cursor_rects_enabled)
|
||||||
|
{
|
||||||
(*ccImp)(self, ccSel, _wv, theEvent);
|
(*ccImp)(self, ccSel, _wv, theEvent);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_lastPoint = [theEvent locationInWindow];
|
_lastPoint = [theEvent locationInWindow];
|
||||||
break;
|
break;
|
||||||
|
@ -3979,7 +4052,9 @@ resetCursorRectsForView(NSView *theView)
|
||||||
|
|
||||||
// Don't update the cursor if the window isn't the key window.
|
// Don't update the cursor if the window isn't the key window.
|
||||||
if (!_f.is_key)
|
if (!_f.is_key)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if ([theEvent trackingNumber]) // It's a mouse entered
|
if ([theEvent trackingNumber]) // It's a mouse entered
|
||||||
{
|
{
|
||||||
|
@ -4158,7 +4233,9 @@ resetCursorRectsForView(NSView *theView)
|
||||||
* to determine if we should send a cursor update
|
* to determine if we should send a cursor update
|
||||||
* event. */
|
* event. */
|
||||||
if (_f.cursor_rects_enabled)
|
if (_f.cursor_rects_enabled)
|
||||||
(*ccImp)(self, ccSel, _wv, theEvent);
|
{
|
||||||
|
checkCursorRectanglesExited(_wv, theEvent, _lastPoint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_lastPoint = NSMakePoint(-1, -1);
|
_lastPoint = NSMakePoint(-1, -1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue