Correction to cleaning targets and remove additional temporary files.

Initial implementation of view focusing.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@1633 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
GNUstep Maintainer 1996-06-03 15:03:43 +00:00
parent ba314b3ad0
commit 31d363516e
3 changed files with 92 additions and 6 deletions

View file

@ -312,6 +312,7 @@ clean:
rm -f *~
rm -f *$(oext)
rm -f $(MAIN_FILE)$(libext)
rm -f $(INIT_FILE).c
distclean: clean
rm -f Makefile
maintainer-clean: distclean

View file

@ -135,20 +135,27 @@ BOOL GNU_CONTEXT_SYNCHRONIZED;
+ (NSDPSContext *)currentContext
{
NSThread *current_thread = [NSThread currentThread];
NSDPSContext *current_context;
NSDPSContext *current_context = nil;
NSLog(@"NSDPSContext: +currentContext\n");
// Get current context for current thread
[GNU_CONTEXT_LOCK lock];
NSLog(@"NSDPSContext: enter critical section\n");
current_context = [GNU_CONTEXT_THREAD_DICT objectForKey: current_thread];
NSLog(@"NSDPSContext: Looked in context dictionary\n");
// If not in dictionary then create one
if (!current_context)
{
NSLog(@"NSDPSContext: Did not find context so create it\n");
current_context = [[NSDPSContext alloc] init];
NSLog(@"NSDPSContext: set the context\n");
[self setCurrentContext: current_context];
}
[GNU_CONTEXT_LOCK unlock];
NSLog(@"NSDPSContext: exit critical section\n");
NSLog(@"NSDPSContext: return from +currentContext\n");
return current_context;
}
@ -156,16 +163,26 @@ BOOL GNU_CONTEXT_SYNCHRONIZED;
{
NSThread *current_thread = [NSThread currentThread];
NSLog(@"NSDPSContext: +setCurrentContext\n");
[GNU_CONTEXT_LOCK lock];
NSLog(@"NSDPSContext: enter critical section\n");
// If no context then remove from dictionary
if (!context)
[GNU_CONTEXT_THREAD_DICT removeObjectForKey: current_thread];
{
NSLog(@"NSDPSContext: remove from dictionary\n");
[GNU_CONTEXT_THREAD_DICT removeObjectForKey: current_thread];
}
else
[GNU_CONTEXT_THREAD_DICT setObject: context
forKey: current_thread];
{
NSLog(@"NSDPSContext: add to dictionary\n");
[GNU_CONTEXT_THREAD_DICT setObject: context
forKey: current_thread];
}
[GNU_CONTEXT_LOCK unlock];
NSLog(@"NSDPSContext: exit critical section\n");
NSLog(@"NSDPSContext: return from +setCurrentContext\n");
}
- (NSDPSContext *)DPSContext

View file

@ -31,6 +31,15 @@
#include <gnustep/gui/NSView.h>
#include <gnustep/gui/NSWindow.h>
#include <gnustep/base/NSCoder.h>
#include <gnustep/base/NSDictionary.h>
#include <gnustep/base/NSThread.h>
#include <gnustep/base/NSLock.h>
//
// Class variables
//
NSMutableDictionary *gnustep_gui_nsview_thread_dict;
NSRecursiveLock *gnustep_gui_nsview_lock;
// NSView notifications
NSString *NSViewFrameChangedNotification;
@ -52,15 +61,72 @@ NSString *NSViewFocusChangedNotification;
// Initial version
[self setVersion:1];
// Allocate dictionary for maintaining
// mapping of threads to focused views
gnustep_gui_nsview_thread_dict = [NSMutableDictionary dictionary];
// Create lock for serializing access to dictionary
gnustep_gui_nsview_lock = [[NSRecursiveLock alloc] init];
}
}
//
// Focusing
//
// +++ Really each thread should have a stack!
//
+ (void)pushFocusView:(NSView *)focusView
{
NSThread *current_thread = [NSThread currentThread];
NSLog(@"NSView: +pushFocusView\n");
[gnustep_gui_nsview_lock lock];
NSLog(@"NSView: enter critical section\n");
// If no context then remove from dictionary
if (!focusView)
{
NSLog(@"NSView: remove from dictionary\n");
[gnustep_gui_nsview_thread_dict removeObjectForKey: current_thread];
}
else
{
NSLog(@"NSView: add to dictionary\n");
[gnustep_gui_nsview_thread_dict setObject: focusView
forKey: current_thread];
}
[gnustep_gui_nsview_lock unlock];
NSLog(@"NSView: exit critical section\n");
NSLog(@"NSView: return from +pushFocusView\n");
}
+ (NSView *)popFocusView
{}
+ (NSView *)focusView
{
return nil;
NSThread *current_thread = [NSThread currentThread];
NSView *current_view = nil;
NSLog(@"NSView: +focusView\n");
// Get focused view for current thread
[gnustep_gui_nsview_lock lock];
NSLog(@"NSView: enter critical section\n");
current_view = [gnustep_gui_nsview_thread_dict objectForKey: current_thread];
NSLog(@"NSView: Looked in view dictionary\n");
// If not in dictionary then no focused view
if (!current_view)
NSLog(@"NSView: Did not find a view\n");
else
NSLog(@"NSView: Found a view\n");
[gnustep_gui_nsview_lock unlock];
NSLog(@"NSView: exit critical section\n");
NSLog(@"NSView: return from +focusView\n");
return current_view;
}
//
@ -151,7 +217,7 @@ NSString *NSViewFocusChangedNotification;
- (void)addSubview:(NSView *)aView
positioned:(NSWindowOrderingMode)place
relativeTo:(NSView *)otherView
relativeTo:(NSView *)otherView
{
// Not a NSView --then forget it
if (![aView isKindOfClass:[NSView class]]) return;
@ -520,10 +586,12 @@ relativeTo:(NSView *)otherView
//
- (void)lockFocus
{
[[self class] pushFocusView: self];
}
- (void)unlockFocus
{
[[self class] popFocusView];
}
//