mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-20 22:06:42 +00:00
Deferred window fixups
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@7646 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
77c74a324e
commit
358af35b5f
5 changed files with 86 additions and 38 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2000-09-28 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Source/NSGraphicsContext.m (-_addDragTypes:toWindow:): Change to
|
||||
take window object, since window number may not exist for deferred win.
|
||||
(-_removeDragTypes:fromWindow:):Likewise.
|
||||
(-_dragTypesForWindow:): Likewise.
|
||||
* Source/NSView.m: Change calling of above methods.
|
||||
* Source/NSWindow.m (-_initBackendWindow:): Reset the drag types
|
||||
if the window was deferred. Also reset title, min/max size, etc.
|
||||
(-setTitle:): Set only if we have a windowNum
|
||||
(-setMinimumSize:): Likewise.
|
||||
(-setMaximumSize:): Likewise.
|
||||
|
||||
2000-09-27 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Implementation of deferred windows (with the help of
|
||||
|
|
|
@ -148,9 +148,9 @@ NSGraphicsContext *GSCurrentContext();
|
|||
/*
|
||||
* Drag and drop support
|
||||
*/
|
||||
- (BOOL) _addDragTypes: (NSArray*)types toWindow: (int)winNum;
|
||||
- (BOOL) _removeDragTypes: (NSArray*)types fromWindow: (int)winNum;
|
||||
- (NSCountedSet*) _dragTypesForWindow: (int)winNum;
|
||||
- (BOOL) _addDragTypes: (NSArray*)types toWindow: (NSWindow *)win;
|
||||
- (BOOL) _removeDragTypes: (NSArray*)types fromWindow: (NSWindow *)win;
|
||||
- (NSCountedSet*) _dragTypesForWindow: (NSWindow *)win;
|
||||
- (id <NSDraggingInfo>)_dragInfo;
|
||||
- (void) _postExternalEvent: (NSEvent*)event;
|
||||
|
||||
|
|
|
@ -254,11 +254,12 @@ NSGraphicsContext *GSCurrentContext()
|
|||
* Subclasses should override this method, call 'super' and take
|
||||
* appropriate action if the method returns 'YES'.
|
||||
*/
|
||||
- (BOOL) _addDragTypes: (NSArray*)types toWindow: (int)winNum
|
||||
- (BOOL) _addDragTypes: (NSArray*)types toWindow: (NSWindow *)win
|
||||
{
|
||||
NSCountedSet *old = (NSCountedSet*)NSMapGet(drag_types, (void*)winNum);
|
||||
NSCountedSet *old = (NSCountedSet*)NSMapGet(drag_types, (void*)win);
|
||||
NSEnumerator *drag_enum = [types objectEnumerator];
|
||||
id type;
|
||||
unsigned originalCount;
|
||||
unsigned i = [types count];
|
||||
|
||||
/*
|
||||
* Make sure the set exists.
|
||||
|
@ -266,16 +267,14 @@ NSGraphicsContext *GSCurrentContext()
|
|||
if (old == nil)
|
||||
{
|
||||
old = [NSCountedSet new];
|
||||
NSMapInsert(drag_types, (void*)winNum, (void*)(gsaddr)old);
|
||||
NSMapInsert(drag_types, (void*)win, (void*)(gsaddr)old);
|
||||
RELEASE(old);
|
||||
}
|
||||
originalCount = [old count];
|
||||
|
||||
while (i-- > 0)
|
||||
while ((type = [drag_enum nextObject]))
|
||||
{
|
||||
id o = [types objectAtIndex: i];
|
||||
|
||||
[old addObject: o];
|
||||
[old addObject: type];
|
||||
}
|
||||
if ([old count] == originalCount)
|
||||
return NO;
|
||||
|
@ -290,15 +289,16 @@ NSGraphicsContext *GSCurrentContext()
|
|||
* Subclasses should override this method, call 'super' and take
|
||||
* appropriate action if the method returns 'YES'.
|
||||
*/
|
||||
- (BOOL) _removeDragTypes: (NSArray*)types fromWindow: (int)winNum
|
||||
- (BOOL) _removeDragTypes: (NSArray*)types fromWindow: (NSWindow *)win
|
||||
{
|
||||
NSCountedSet *old = (NSCountedSet*)NSMapGet(drag_types, (void*)winNum);
|
||||
NSCountedSet *old = (NSCountedSet*)NSMapGet(drag_types, (void*)win);
|
||||
NSEnumerator *drag_enum = [types objectEnumerator];
|
||||
|
||||
if (types == nil)
|
||||
{
|
||||
if (old == nil)
|
||||
return NO;
|
||||
NSMapRemove(drag_types, (void*)winNum);
|
||||
NSMapRemove(drag_types, (void*)win);
|
||||
return YES;
|
||||
}
|
||||
else if (old == nil)
|
||||
|
@ -308,12 +308,10 @@ NSGraphicsContext *GSCurrentContext()
|
|||
else
|
||||
{
|
||||
unsigned originalCount = [old count];
|
||||
unsigned i = [types count];
|
||||
id o;
|
||||
|
||||
while (i-- > 0)
|
||||
while ((o = [drag_enum nextObject]))
|
||||
{
|
||||
id o = [types objectAtIndex: i];
|
||||
|
||||
[old removeObject: o];
|
||||
}
|
||||
if ([old count] == originalCount)
|
||||
|
@ -322,9 +320,9 @@ NSGraphicsContext *GSCurrentContext()
|
|||
}
|
||||
}
|
||||
|
||||
- (NSCountedSet*) _dragTypesForWindow: (int)winNum
|
||||
- (NSCountedSet*) _dragTypesForWindow: (NSWindow *)win
|
||||
{
|
||||
return (NSCountedSet*)NSMapGet(drag_types, (void*)winNum);
|
||||
return (NSCountedSet*)NSMapGet(drag_types, (void *)win);
|
||||
}
|
||||
|
||||
- (id <NSDraggingInfo>)_dragInfo
|
||||
|
|
|
@ -532,11 +532,11 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
|||
|
||||
if (_window != nil)
|
||||
{
|
||||
[ctxt _removeDragTypes: t fromWindow: [_window windowNumber]];
|
||||
[ctxt _removeDragTypes: t fromWindow: _window];
|
||||
}
|
||||
if (newWindow != nil)
|
||||
{
|
||||
[ctxt _addDragTypes: t toWindow: [newWindow windowNumber]];
|
||||
[ctxt _addDragTypes: t toWindow: newWindow];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2307,10 +2307,10 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
|||
{
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
|
||||
[ctxt _addDragTypes: t toWindow: [_window windowNumber]];
|
||||
[ctxt _addDragTypes: t toWindow: _window];
|
||||
if (o != nil)
|
||||
{
|
||||
[ctxt _removeDragTypes: o fromWindow: [_window windowNumber]];
|
||||
[ctxt _removeDragTypes: o fromWindow: _window];
|
||||
}
|
||||
}
|
||||
TEST_RELEASE(o);
|
||||
|
@ -2325,7 +2325,7 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
|||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
NSArray *t = GSGetDragTypes(self);
|
||||
|
||||
[ctxt _removeDragTypes: t fromWindow: [_window windowNumber]];
|
||||
[ctxt _removeDragTypes: t fromWindow: _window];
|
||||
}
|
||||
GSRemoveDragTypes(self);
|
||||
_rFlags.has_draginfo = 0;
|
||||
|
|
|
@ -551,7 +551,7 @@ static NSMapTable* windowmaps = NULL;
|
|||
* FIXME This should not be necessary - the views should have removed
|
||||
* their drag types, so we should already have been removed.
|
||||
*/
|
||||
[context _removeDragTypes: nil fromWindow: _windowNum];
|
||||
[context _removeDragTypes: nil fromWindow: self];
|
||||
|
||||
if (_gstate)
|
||||
DPSundefineuserobject(context, _gstate);
|
||||
|
@ -562,8 +562,18 @@ static NSMapTable* windowmaps = NULL;
|
|||
|
||||
- (void) _initBackendWindow: (NSRect)frame
|
||||
{
|
||||
id dragTypes;
|
||||
NSGraphicsContext *context = GSCurrentContext();
|
||||
|
||||
/* If we were deferred or one shot, out drag types may not have
|
||||
been registered properly in the backend. Remove them then re-add
|
||||
them when we create the window */
|
||||
dragTypes = [context _dragTypesForWindow: self];
|
||||
if (dragTypes)
|
||||
{
|
||||
[context _removeDragTypes: dragTypes fromWindow: self];
|
||||
}
|
||||
|
||||
frame = [NSWindow contentRectForFrameRect: frame styleMask: _styleMask];
|
||||
DPSwindow(context, NSMinX(frame), NSMinY(frame),
|
||||
NSWidth(frame), NSHeight(frame),
|
||||
|
@ -585,6 +595,24 @@ static NSMapTable* windowmaps = NULL;
|
|||
[_wv setFrame: frame];
|
||||
[_wv setNeedsDisplay: YES];
|
||||
}
|
||||
|
||||
/* Ok, now add the drag types back */
|
||||
if (dragTypes)
|
||||
{
|
||||
NSDebugLLog(@"NSWindow", @"Resetting drag types for window");
|
||||
[context _addDragTypes: dragTypes toWindow: self];
|
||||
}
|
||||
|
||||
/* Other stuff we need to do for deferred windows */
|
||||
if (_windowTitle != nil)
|
||||
DPStitlewindow(GSCurrentContext(), [_windowTitle cString], _windowNum);
|
||||
if (!NSEqualSizes(_minimumSize, NSZeroSize))
|
||||
[self setMinSize: _minimumSize];
|
||||
if (!NSEqualSizes(_maximumSize, NSZeroSize))
|
||||
[self setMaxSize: _maximumSize];
|
||||
if (!NSEqualSizes(_increments, NSZeroSize))
|
||||
[self setResizeIncrements: _increments];
|
||||
|
||||
NSDebugLLog(@"NSWindow", @"Created NSWindow frame %@",
|
||||
NSStringFromRect(_frame));
|
||||
}
|
||||
|
@ -731,7 +759,8 @@ static NSMapTable* windowmaps = NULL;
|
|||
{
|
||||
ASSIGN(_windowTitle, aString);
|
||||
[self setMiniwindowTitle: aString];
|
||||
DPStitlewindow(GSCurrentContext(), [aString cString], _windowNum);
|
||||
if (_windowNum > 0)
|
||||
DPStitlewindow(GSCurrentContext(), [aString cString], _windowNum);
|
||||
if (_f.menu_exclude == NO && _f.has_opened == YES)
|
||||
{
|
||||
[NSApp changeWindowsItem: self
|
||||
|
@ -751,7 +780,8 @@ static NSMapTable* windowmaps = NULL;
|
|||
{
|
||||
ASSIGN(_windowTitle, aString);
|
||||
[self setMiniwindowTitle: aString];
|
||||
DPStitlewindow(GSCurrentContext(), [aString cString], _windowNum);
|
||||
if (_windowNum > 0)
|
||||
DPStitlewindow(GSCurrentContext(), [aString cString], _windowNum);
|
||||
if (_f.menu_exclude == NO && _f.has_opened == YES)
|
||||
{
|
||||
[NSApp changeWindowsItem: self
|
||||
|
@ -786,6 +816,8 @@ static NSMapTable* windowmaps = NULL;
|
|||
|
||||
- (int) gState
|
||||
{
|
||||
if (_gstate <= 0)
|
||||
NSDebugLLog(@"NSWindow", @"gState called on deferred window");
|
||||
return _gstate;
|
||||
}
|
||||
|
||||
|
@ -806,6 +838,8 @@ static NSMapTable* windowmaps = NULL;
|
|||
|
||||
- (int) windowNumber
|
||||
{
|
||||
if (_windowNum <= 0)
|
||||
NSDebugLLog(@"NSWindow", @"windowNumber called on deferred window");
|
||||
return _windowNum;
|
||||
}
|
||||
|
||||
|
@ -1195,7 +1229,8 @@ static NSMapTable* windowmaps = NULL;
|
|||
NSGraphicsContext *context = GSCurrentContext();
|
||||
|
||||
_windowLevel = newLevel;
|
||||
DPSsetwindowlevel(context, _windowLevel, _windowNum);
|
||||
if (_windowNum > 0)
|
||||
DPSsetwindowlevel(context, _windowLevel, _windowNum);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1310,9 +1345,9 @@ static NSMapTable* windowmaps = NULL;
|
|||
* Now we can tell the graphics context to do the actual resizing.
|
||||
* We will recieve an event to tell us when the resize is done.
|
||||
*/
|
||||
if(_gstate)
|
||||
DPSplacewindow(GSCurrentContext(), frameRect.origin.x, frameRect.origin.y,
|
||||
frameRect.size.width, frameRect.size.height, _windowNum);
|
||||
if(_windowNum)
|
||||
DPSplacewindow(GSCurrentContext(), frameRect.origin.x, frameRect.origin.y,
|
||||
frameRect.size.width, frameRect.size.height, _windowNum);
|
||||
else
|
||||
_frame = frameRect;
|
||||
|
||||
|
@ -1344,7 +1379,8 @@ static NSMapTable* windowmaps = NULL;
|
|||
if (aSize.height < 1)
|
||||
aSize.height = 1;
|
||||
_minimumSize = aSize;
|
||||
DPSsetminsize(GSCurrentContext(), aSize.width, aSize.height, _windowNum);
|
||||
if (_windowNum > 0)
|
||||
DPSsetminsize(GSCurrentContext(), aSize.width, aSize.height, _windowNum);
|
||||
}
|
||||
|
||||
- (void) setMaxSize: (NSSize)aSize
|
||||
|
@ -1357,7 +1393,8 @@ static NSMapTable* windowmaps = NULL;
|
|||
if (aSize.height > 10000)
|
||||
aSize.height = 10000;
|
||||
_maximumSize = aSize;
|
||||
DPSsetmaxsize(GSCurrentContext(), aSize.width, aSize.height, _windowNum);
|
||||
if (_windowNum > 0)
|
||||
DPSsetmaxsize(GSCurrentContext(), aSize.width, aSize.height, _windowNum);
|
||||
}
|
||||
|
||||
- (NSSize) resizeIncrements
|
||||
|
@ -1368,8 +1405,9 @@ static NSMapTable* windowmaps = NULL;
|
|||
- (void) setResizeIncrements: (NSSize)aSize
|
||||
{
|
||||
_increments = aSize;
|
||||
DPSsetresizeincrements(GSCurrentContext(), aSize.width, aSize.height,
|
||||
_windowNum);
|
||||
if (_windowNum > 0)
|
||||
DPSsetresizeincrements(GSCurrentContext(), aSize.width, aSize.height,
|
||||
_windowNum);
|
||||
}
|
||||
|
||||
- (NSSize) aspectRatio
|
||||
|
@ -2314,8 +2352,7 @@ resetCursorRectsForView(NSView *theView)
|
|||
|
||||
- (void) _processResizeEvent
|
||||
{
|
||||
|
||||
if (_gstate)
|
||||
if (_windowNum && _gstate)
|
||||
{
|
||||
NSGraphicsContext *context = GSCurrentContext();
|
||||
DPSgsave(context);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue