Fix some event, runloop and flushing interaction problems.

Add NSWindowView which is a specialized view that handles drawing a
window's decorations and background color.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@2638 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Scott Christley 1997-11-14 21:32:31 +00:00
parent 0639c42c5f
commit 6d56e48e78
8 changed files with 152 additions and 21 deletions

View file

@ -1,3 +1,22 @@
Fri Nov 14 09:34:45 1997 Scott Christley <scottc@net-community.com>
* Headers/gnustep/gui/NSApplication.h (-getNextEvent): Method
no longer returns a value.
* Headers/gnustep/gui/NSWindowView.h: New file.
* Source/NSWindowView.m: New file.
* Source/NSView.m (-displayRect:): Remove debug code.
* Source/NSWindow.m: Use new class which represents the
view the window uses to draw its frame and title. Many
changes throughout the file to update the window view instead
of the content view.
* Source/GNUmakefile: Don't install the config.h file. Compile
and install NSWindowView.
* Source/NSApplication.m
(-nextEventMatchingMask:untilDate:inMode:dequeue:): Rearrange
code so that that the flushing of windows is done before
runloop's limit date is retrieved.
(-getNextEvent): Method no longer returns a value.
Sat Nov 1 11:30:40 1997 Ovidiu Predescu <ovidiu@net-community.com>
* Source/GNUmakefile: Don't compile NSPasteboard.m if using

View file

@ -271,7 +271,7 @@ extern NSString *NSEventTrackingRunLoopMode;
+ (NSEvent *)getNullEvent;
// Get next event
- (NSEvent *)getNextEvent;
- (void)getNextEvent;
- (NSEvent *)peekNextEvent;
// handle a non-translated event

View file

@ -0,0 +1,41 @@
/*
NSWindowView.h
View which handles drawing the window decorations and filling
the window with the background color.
Copyright (C) 1997 Free Software Foundation, Inc.
Author: Scott Christley <scottc@net-community.com>
Date: November 1997
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _GNUstep_H_NSWindowView
#define _GNUstep_H_NSWindowView
#include <AppKit/NSView.h>
@interface NSWindowView : NSView
{
}
@end
#endif /* _GNUstep_H_NSWindowView */

View file

@ -97,6 +97,7 @@ NSTextField.m \
NSTextFieldCell.m \
NSView.m \
NSWindow.m \
NSWindowView.m \
NSWorkspace.m \
TrackingRectangle.m \
PSMatrix.m \
@ -178,9 +179,9 @@ AppKit/NSTextField.h \
AppKit/NSTextFieldCell.h \
AppKit/NSView.h \
AppKit/NSWindow.h \
AppKit/NSWindowView.h \
AppKit/NSWorkspace.h \
AppKit/TrackingRectangle.h \
AppKit/config.h \
AppKit/nsimage-tiff.h \
AppKit/PSMatrix.h \
DPSClient/NSDPSContext.h \

View file

@ -217,6 +217,7 @@ static id NSApp;
do
{
pool = [NSAutoreleasePool new];
e = [self nextEventMatchingMask:NSAnyEventMask
untilDate:[NSDate distantFuture]
inMode:NSDefaultRunLoopMode dequeue:YES];
@ -392,6 +393,8 @@ static id NSApp;
NSEvent* event;
int i, count;
[self getNextEvent];
/* Get an event from the events queue */
if ((count = [event_queue count])) {
for (i = 0; i < count; i++) {
@ -426,11 +429,17 @@ static id NSApp;
// Not in queue so wait for next event
while (!done) {
NSDate *limitDate, *originalLimitDate;
// flush any windows that need it
[NSWindow _flushWindows];
[self _flushCommunicationChannels];
/* Retain the limitDate so it doesn't get release accidentally by
runMode:beforeDate: if a timer which has this date as fire date gets
released. */
NSDate* limitDate = [[currentLoop limitDateForMode:mode] retain];
NSDate* originalLimitDate = limitDate;
limitDate = [[currentLoop limitDateForMode:mode] retain];
originalLimitDate = limitDate;
event = [self _eventMatchingMask:mask];
if (event) {
@ -443,11 +452,9 @@ static id NSApp;
else
limitDate = expiration;
[NSWindow _flushWindows];
[self _flushCommunicationChannels];
[currentLoop runMode:mode beforeDate:limitDate];
[originalLimitDate release];
event = [self _eventMatchingMask:mask];
if (event)
break;
@ -1088,10 +1095,9 @@ static id NSApp;
}
// Get next event
- (NSEvent *)getNextEvent
- (void)getNextEvent
{
[event_queue addObject:gnustep_gui_null_event];
return gnustep_gui_null_event;
}
- (NSEvent *)peekNextEvent

View file

@ -798,8 +798,6 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
NSLog (@"warning: %@ %p has not have the PS matrices setup!",
NSStringFromClass(isa), self);
// NSLog (@"NSView displayRect:");
needs_display = NO;
[self lockFocus];

View file

@ -45,6 +45,7 @@
#include <AppKit/NSScreen.h>
#include <AppKit/NSCursor.h>
#include <AppKit/PSMatrix.h>
#include <AppKit/NSWindowView.h>
#define ASSIGN(variable, value) \
[value retain]; \
@ -128,6 +129,9 @@ static BOOL _needsFlushWindows = YES;
- (void)dealloc
{
// Release the window view
if (content_view) [[content_view superview] release];
// Release the content view
if (content_view) [content_view release];
@ -212,11 +216,33 @@ static BOOL _needsFlushWindows = YES;
- (void)setContentView:(NSView *)aView
{
NSView *wv;
// Cannot have a nil content view
if (!aView)
aView = [[[NSView alloc] initWithFrame: frame] autorelease];
// If the window view hasn't been created yet
// then create it
if ((!content_view) || ([content_view superview] == nil))
{
wv = [[NSWindowView alloc] initWithFrame: frame];
[wv viewWillMoveToWindow: self];
}
else
wv = [content_view superview];
if (content_view)
[content_view viewWillMoveToWindow:nil];
{
[content_view removeFromSuperview];
[content_view viewWillMoveToWindow:nil];
}
ASSIGN(content_view, aView);
// Add to our window view
[wv addSubview: content_view];
// Tell the view its changing windows
[content_view viewWillMoveToWindow:self];
@ -622,8 +648,8 @@ static BOOL _needsFlushWindows = YES;
/* Temporary disable displaying */
[self disableFlushWindow];
// Draw the content view
[content_view display];
// Draw the window view
[[content_view superview] display];
/* Reenable displaying and flush the window */
[self enableFlushWindow];
@ -632,7 +658,7 @@ static BOOL _needsFlushWindows = YES;
- (void)displayIfNeeded
{
if (needs_display) {
[content_view _displayNeededViews];
[[content_view superview] _displayNeededViews];
needs_display = NO;
}
}
@ -646,7 +672,7 @@ static BOOL _needsFlushWindows = YES;
{
needs_flush = NO;
[_flushRectangles removeAllObjects];
[content_view _recursivelyResetNeedsDisplayInAllViews];
[[content_view superview] _recursivelyResetNeedsDisplayInAllViews];
}
- (void)flushWindowIfNeeded
@ -671,9 +697,10 @@ static BOOL _needsFlushWindows = YES;
originMatrix = [PSMatrix new];
sizeMatrix = [PSMatrix new];
[content_view _collectInvalidatedRectanglesInArray:_flushRectangles
originMatrix:originMatrix
sizeMatrix:sizeMatrix];
[[content_view superview]
_collectInvalidatedRectanglesInArray:_flushRectangles
originMatrix:originMatrix
sizeMatrix:sizeMatrix];
[originMatrix release];
[sizeMatrix release];
@ -787,7 +814,7 @@ static BOOL _needsFlushWindows = YES;
- (void)discardCursorRects
{
[self discardCursorRectsForView: content_view];
[self discardCursorRectsForView: [content_view superview]];
}
- (void)enableCursorRects
@ -819,7 +846,7 @@ static BOOL _needsFlushWindows = YES;
- (void)resetCursorRects
{
// Tell all the views to reset their cursor rects
[self resetCursorRectsForView: content_view];
[self resetCursorRectsForView: [content_view superview]];
// Cursor rects are now valid
cursor_rects_valid = YES;

39
Source/NSWindowView.m Normal file
View file

@ -0,0 +1,39 @@
/*
NSWindowView.m
View which handles drawing the window decorations and filling
the window with the background color.
Copyright (C) 1997 Free Software Foundation, Inc.
Author: Scott Christley <scottc@net-community.com>
Date: November 1997
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <AppKit/NSWindowView.h>
@implementation NSWindowView
//
// The backend will have to fill in the implementation
//
@end