mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-21 09:31:01 +00:00
Implementation of deferred windows
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@7623 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
135259b7c2
commit
77c74a324e
5 changed files with 90 additions and 28 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,5 +1,18 @@
|
||||||
2000-09-27 Adam Fedor <fedor@gnu.org>
|
2000-09-27 Adam Fedor <fedor@gnu.org>
|
||||||
|
|
||||||
|
* Implementation of deferred windows (with the help of
|
||||||
|
mirko.viviani@rccr.cremona.it)
|
||||||
|
* Source/NSClipView.m (-setBoundsOrigin:): Make sure window
|
||||||
|
is not deferred before attempting to draw.
|
||||||
|
* Source/NSMenu.m (-init): Defer window.
|
||||||
|
* Source/NSView.m (-lockFocusInRect:): Don't lock if window is
|
||||||
|
deferred.
|
||||||
|
(-unlockFocus): Likewise.
|
||||||
|
* Source/NSWindow.m (_initBackendWindow:): New method.
|
||||||
|
(-initWithContentRect:styleMask:backing:defer:screen:): Use it
|
||||||
|
if not deferring.
|
||||||
|
(-orderWindow:relativeTo:): Create window if deferred.
|
||||||
|
|
||||||
* Source/tiff.m (NSTiffRead): For PHOTOMETRIC_PALETTE, don't free
|
* Source/tiff.m (NSTiffRead): For PHOTOMETRIC_PALETTE, don't free
|
||||||
colormap tables, they are owned by libtiff.
|
colormap tables, they are owned by libtiff.
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@
|
||||||
if (_documentView == nil)
|
if (_documentView == nil)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_copiesOnScroll && _window)
|
if (_copiesOnScroll && _window && [_window gState])
|
||||||
{
|
{
|
||||||
// copy the portion of the view that is common before
|
// copy the portion of the view that is common before
|
||||||
// and after scrolling.
|
// and after scrolling.
|
||||||
|
|
|
@ -1295,7 +1295,7 @@ static NSString *NSMenuLocationsKey = @"NSMenuLocations";
|
||||||
self = [self initWithContentRect: NSZeroRect
|
self = [self initWithContentRect: NSZeroRect
|
||||||
styleMask: NSBorderlessWindowMask
|
styleMask: NSBorderlessWindowMask
|
||||||
backing: NSBackingStoreBuffered
|
backing: NSBackingStoreBuffered
|
||||||
defer: NO];
|
defer: YES];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1259,8 +1259,12 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
||||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||||
struct NSWindow_struct *window_t;
|
struct NSWindow_struct *window_t;
|
||||||
NSRect wrect;
|
NSRect wrect;
|
||||||
|
int window_gstate;
|
||||||
|
|
||||||
NSAssert(_window != nil, NSInternalInconsistencyException);
|
NSAssert(_window != nil, NSInternalInconsistencyException);
|
||||||
|
/* Check for deferred window */
|
||||||
|
if ((window_gstate = [_window gState]) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
[ctxt lockFocusView: self inRect: rect];
|
[ctxt lockFocusView: self inRect: rect];
|
||||||
wrect = [self convertRect: rect toView: nil];
|
wrect = [self convertRect: rect toView: nil];
|
||||||
|
@ -1280,12 +1284,9 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int window_gstate;
|
|
||||||
NSAffineTransform *matrix;
|
NSAffineTransform *matrix;
|
||||||
float x, y, w, h;
|
float x, y, w, h;
|
||||||
|
|
||||||
window_gstate = [_window gState];
|
|
||||||
NSAssert(window_gstate, NSInternalInconsistencyException);
|
|
||||||
DPSsetgstate(ctxt, window_gstate);
|
DPSsetgstate(ctxt, window_gstate);
|
||||||
DPSgsave(ctxt);
|
DPSgsave(ctxt);
|
||||||
matrix = [self _matrixToWindow];
|
matrix = [self _matrixToWindow];
|
||||||
|
@ -1331,6 +1332,9 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
||||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||||
|
|
||||||
NSAssert(_window != nil, NSInternalInconsistencyException);
|
NSAssert(_window != nil, NSInternalInconsistencyException);
|
||||||
|
/* Check for deferred window */
|
||||||
|
if ([_window gState] == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
/* Restore our original gstate */
|
/* Restore our original gstate */
|
||||||
DPSgrestore(ctxt);
|
DPSgrestore(ctxt);
|
||||||
|
|
|
@ -560,6 +560,35 @@ static NSMapTable* windowmaps = NULL;
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) _initBackendWindow: (NSRect)frame
|
||||||
|
{
|
||||||
|
NSGraphicsContext *context = GSCurrentContext();
|
||||||
|
|
||||||
|
frame = [NSWindow contentRectForFrameRect: frame styleMask: _styleMask];
|
||||||
|
DPSwindow(context, NSMinX(frame), NSMinY(frame),
|
||||||
|
NSWidth(frame), NSHeight(frame),
|
||||||
|
_backingType, &_windowNum);
|
||||||
|
DPSstylewindow(context, _styleMask, _windowNum);
|
||||||
|
DPSsetwindowlevel(context, [self level], _windowNum);
|
||||||
|
|
||||||
|
// Set window in new _gstate
|
||||||
|
DPSgsave(context);
|
||||||
|
DPSwindowdevice(context, _windowNum);
|
||||||
|
DPSgstate(context);
|
||||||
|
_gstate = GSWDefineAsUserObj(context);
|
||||||
|
DPSgrestore(context);
|
||||||
|
NSMapInsert (windowmaps, (void*)_windowNum, self);
|
||||||
|
|
||||||
|
if (NSIsEmptyRect([_wv frame]))
|
||||||
|
{
|
||||||
|
frame.origin = NSZeroPoint;
|
||||||
|
[_wv setFrame: frame];
|
||||||
|
[_wv setNeedsDisplay: YES];
|
||||||
|
}
|
||||||
|
NSDebugLLog(@"NSWindow", @"Created NSWindow frame %@",
|
||||||
|
NSStringFromRect(_frame));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initializing and getting a new NSWindow object
|
* Initializing and getting a new NSWindow object
|
||||||
*/
|
*/
|
||||||
|
@ -583,7 +612,6 @@ static NSMapTable* windowmaps = NULL;
|
||||||
defer: (BOOL)flag
|
defer: (BOOL)flag
|
||||||
screen: (NSScreen*)aScreen
|
screen: (NSScreen*)aScreen
|
||||||
{
|
{
|
||||||
NSGraphicsContext *context = GSCurrentContext();
|
|
||||||
NSRect cframe;
|
NSRect cframe;
|
||||||
|
|
||||||
NSDebugLog(@"NSWindow default initializer\n");
|
NSDebugLog(@"NSWindow default initializer\n");
|
||||||
|
@ -628,21 +656,16 @@ static NSMapTable* windowmaps = NULL;
|
||||||
part a view is drawing in, so NSWindow only has to flush that portion */
|
part a view is drawing in, so NSWindow only has to flush that portion */
|
||||||
_rectsBeingDrawn = RETAIN([NSMutableArray arrayWithCapacity: 10]);
|
_rectsBeingDrawn = RETAIN([NSMutableArray arrayWithCapacity: 10]);
|
||||||
|
|
||||||
// FIXME: If flag is YES, the creation of the window should be defered
|
/* Create window (if not deferred) */
|
||||||
DPSwindow(context, NSMinX(contentRect), NSMinY(contentRect),
|
_windowNum = 0;
|
||||||
NSWidth(contentRect), NSHeight(contentRect),
|
_gstate = 0;
|
||||||
bufferingType, &_windowNum);
|
if (flag == NO)
|
||||||
DPSstylewindow(context, aStyle, _windowNum);
|
{
|
||||||
DPSsetwindowlevel(context, [self level], _windowNum);
|
NSDebugLLog(@"NSWindow", @"Creating NSWindow\n");
|
||||||
|
[self _initBackendWindow: _frame];
|
||||||
// Set window in new _gstate
|
}
|
||||||
DPSgsave(context);
|
else
|
||||||
DPSwindowdevice(context, _windowNum);
|
NSDebugLLog(@"NSWindow", @"Defering NSWindow creation\n");
|
||||||
DPSgstate(context);
|
|
||||||
_gstate = GSWDefineAsUserObj(context);
|
|
||||||
DPSgrestore(context);
|
|
||||||
|
|
||||||
NSMapInsert (windowmaps, (void*)_windowNum, self);
|
|
||||||
|
|
||||||
NSDebugLog(@"NSWindow end of init\n");
|
NSDebugLog(@"NSWindow end of init\n");
|
||||||
return self;
|
return self;
|
||||||
|
@ -1037,6 +1060,9 @@ static NSMapTable* windowmaps = NULL;
|
||||||
|
|
||||||
- (void) orderWindow: (NSWindowOrderingMode)place relativeTo: (int)otherWin
|
- (void) orderWindow: (NSWindowOrderingMode)place relativeTo: (int)otherWin
|
||||||
{
|
{
|
||||||
|
NSGraphicsContext *context = GSCurrentContext();
|
||||||
|
BOOL display = NO;
|
||||||
|
|
||||||
if (place == NSWindowOut)
|
if (place == NSWindowOut)
|
||||||
{
|
{
|
||||||
_f.visible = NO;
|
_f.visible = NO;
|
||||||
|
@ -1052,7 +1078,19 @@ static NSMapTable* windowmaps = NULL;
|
||||||
}
|
}
|
||||||
[self _lossOfKeyOrMainWindow];
|
[self _lossOfKeyOrMainWindow];
|
||||||
}
|
}
|
||||||
DPSorderwindow(GSCurrentContext(), place, otherWin, _windowNum);
|
else
|
||||||
|
{
|
||||||
|
// create deferred window
|
||||||
|
if(_windowNum == 0)
|
||||||
|
{
|
||||||
|
[self _initBackendWindow: _frame];
|
||||||
|
display = YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DPSorderwindow(context, place, otherWin, _windowNum);
|
||||||
|
if (display)
|
||||||
|
[self display];
|
||||||
|
|
||||||
if (place != NSWindowOut)
|
if (place != NSWindowOut)
|
||||||
{
|
{
|
||||||
if (_rFlags.needs_display == NO)
|
if (_rFlags.needs_display == NO)
|
||||||
|
@ -1091,8 +1129,8 @@ static NSMapTable* windowmaps = NULL;
|
||||||
}
|
}
|
||||||
if ([self isKeyWindow] == YES)
|
if ([self isKeyWindow] == YES)
|
||||||
{
|
{
|
||||||
DPSsetinputstate(GSCurrentContext(), _windowNum, GSTitleBarKey);
|
DPSsetinputstate(context, _windowNum, GSTitleBarKey);
|
||||||
DPSsetinputfocus(GSCurrentContext(), _windowNum);
|
DPSsetinputfocus(context, _windowNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1272,8 +1310,11 @@ static NSMapTable* windowmaps = NULL;
|
||||||
* Now we can tell the graphics context to do the actual resizing.
|
* 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.
|
* We will recieve an event to tell us when the resize is done.
|
||||||
*/
|
*/
|
||||||
|
if(_gstate)
|
||||||
DPSplacewindow(GSCurrentContext(), frameRect.origin.x, frameRect.origin.y,
|
DPSplacewindow(GSCurrentContext(), frameRect.origin.x, frameRect.origin.y,
|
||||||
frameRect.size.width, frameRect.size.height, _windowNum);
|
frameRect.size.width, frameRect.size.height, _windowNum);
|
||||||
|
else
|
||||||
|
_frame = frameRect;
|
||||||
|
|
||||||
if (flag)
|
if (flag)
|
||||||
[self display];
|
[self display];
|
||||||
|
@ -1381,6 +1422,9 @@ static NSMapTable* windowmaps = NULL;
|
||||||
|
|
||||||
- (void) display
|
- (void) display
|
||||||
{
|
{
|
||||||
|
if (_gstate == 0 || _f.visible == NO)
|
||||||
|
return;
|
||||||
|
|
||||||
_rFlags.needs_display = NO;
|
_rFlags.needs_display = NO;
|
||||||
// FIXME: Is the first responder processing needed here?
|
// FIXME: Is the first responder processing needed here?
|
||||||
if ((!_firstResponder) || (_firstResponder == self))
|
if ((!_firstResponder) || (_firstResponder == self))
|
||||||
|
@ -1472,10 +1516,11 @@ static NSMapTable* windowmaps = NULL;
|
||||||
[[_rectsBeingDrawn objectAtIndex: i] rectValue]);
|
[[_rectsBeingDrawn objectAtIndex: i] rectValue]);
|
||||||
}
|
}
|
||||||
|
|
||||||
DPSflushwindowrect(context,
|
if (_windowNum)
|
||||||
NSMinX(_rectNeedingFlush), NSMinY(_rectNeedingFlush),
|
DPSflushwindowrect(context,
|
||||||
NSWidth(_rectNeedingFlush), NSHeight(_rectNeedingFlush),
|
NSMinX(_rectNeedingFlush), NSMinY(_rectNeedingFlush),
|
||||||
_windowNum);
|
NSWidth(_rectNeedingFlush), NSHeight(_rectNeedingFlush),
|
||||||
|
_windowNum);
|
||||||
_f.needs_flush = NO;
|
_f.needs_flush = NO;
|
||||||
_rectNeedingFlush = NSZeroRect;
|
_rectNeedingFlush = NSZeroRect;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue