mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-04 05:30:41 +00:00
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:
parent
cc93913f74
commit
ec1a865b4b
3 changed files with 92 additions and 6 deletions
|
@ -312,6 +312,7 @@ clean:
|
||||||
rm -f *~
|
rm -f *~
|
||||||
rm -f *$(oext)
|
rm -f *$(oext)
|
||||||
rm -f $(MAIN_FILE)$(libext)
|
rm -f $(MAIN_FILE)$(libext)
|
||||||
|
rm -f $(INIT_FILE).c
|
||||||
distclean: clean
|
distclean: clean
|
||||||
rm -f Makefile
|
rm -f Makefile
|
||||||
maintainer-clean: distclean
|
maintainer-clean: distclean
|
||||||
|
|
|
@ -135,20 +135,27 @@ BOOL GNU_CONTEXT_SYNCHRONIZED;
|
||||||
+ (NSDPSContext *)currentContext
|
+ (NSDPSContext *)currentContext
|
||||||
{
|
{
|
||||||
NSThread *current_thread = [NSThread currentThread];
|
NSThread *current_thread = [NSThread currentThread];
|
||||||
NSDPSContext *current_context;
|
NSDPSContext *current_context = nil;
|
||||||
|
|
||||||
|
NSLog(@"NSDPSContext: +currentContext\n");
|
||||||
// Get current context for current thread
|
// Get current context for current thread
|
||||||
[GNU_CONTEXT_LOCK lock];
|
[GNU_CONTEXT_LOCK lock];
|
||||||
|
NSLog(@"NSDPSContext: enter critical section\n");
|
||||||
current_context = [GNU_CONTEXT_THREAD_DICT objectForKey: current_thread];
|
current_context = [GNU_CONTEXT_THREAD_DICT objectForKey: current_thread];
|
||||||
|
NSLog(@"NSDPSContext: Looked in context dictionary\n");
|
||||||
|
|
||||||
// If not in dictionary then create one
|
// If not in dictionary then create one
|
||||||
if (!current_context)
|
if (!current_context)
|
||||||
{
|
{
|
||||||
|
NSLog(@"NSDPSContext: Did not find context so create it\n");
|
||||||
current_context = [[NSDPSContext alloc] init];
|
current_context = [[NSDPSContext alloc] init];
|
||||||
|
NSLog(@"NSDPSContext: set the context\n");
|
||||||
[self setCurrentContext: current_context];
|
[self setCurrentContext: current_context];
|
||||||
}
|
}
|
||||||
[GNU_CONTEXT_LOCK unlock];
|
[GNU_CONTEXT_LOCK unlock];
|
||||||
|
NSLog(@"NSDPSContext: exit critical section\n");
|
||||||
|
|
||||||
|
NSLog(@"NSDPSContext: return from +currentContext\n");
|
||||||
return current_context;
|
return current_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,16 +163,26 @@ BOOL GNU_CONTEXT_SYNCHRONIZED;
|
||||||
{
|
{
|
||||||
NSThread *current_thread = [NSThread currentThread];
|
NSThread *current_thread = [NSThread currentThread];
|
||||||
|
|
||||||
|
NSLog(@"NSDPSContext: +setCurrentContext\n");
|
||||||
[GNU_CONTEXT_LOCK lock];
|
[GNU_CONTEXT_LOCK lock];
|
||||||
|
NSLog(@"NSDPSContext: enter critical section\n");
|
||||||
|
|
||||||
// If no context then remove from dictionary
|
// If no context then remove from dictionary
|
||||||
if (!context)
|
if (!context)
|
||||||
|
{
|
||||||
|
NSLog(@"NSDPSContext: remove from dictionary\n");
|
||||||
[GNU_CONTEXT_THREAD_DICT removeObjectForKey: current_thread];
|
[GNU_CONTEXT_THREAD_DICT removeObjectForKey: current_thread];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
NSLog(@"NSDPSContext: add to dictionary\n");
|
||||||
[GNU_CONTEXT_THREAD_DICT setObject: context
|
[GNU_CONTEXT_THREAD_DICT setObject: context
|
||||||
forKey: current_thread];
|
forKey: current_thread];
|
||||||
|
}
|
||||||
|
|
||||||
[GNU_CONTEXT_LOCK unlock];
|
[GNU_CONTEXT_LOCK unlock];
|
||||||
|
NSLog(@"NSDPSContext: exit critical section\n");
|
||||||
|
NSLog(@"NSDPSContext: return from +setCurrentContext\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDPSContext *)DPSContext
|
- (NSDPSContext *)DPSContext
|
||||||
|
|
|
@ -31,6 +31,15 @@
|
||||||
#include <gnustep/gui/NSView.h>
|
#include <gnustep/gui/NSView.h>
|
||||||
#include <gnustep/gui/NSWindow.h>
|
#include <gnustep/gui/NSWindow.h>
|
||||||
#include <gnustep/base/NSCoder.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
|
// NSView notifications
|
||||||
NSString *NSViewFrameChangedNotification;
|
NSString *NSViewFrameChangedNotification;
|
||||||
|
@ -52,15 +61,72 @@ NSString *NSViewFocusChangedNotification;
|
||||||
|
|
||||||
// Initial version
|
// Initial version
|
||||||
[self setVersion:1];
|
[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
|
// 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
|
+ (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;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -520,10 +586,12 @@ relativeTo:(NSView *)otherView
|
||||||
//
|
//
|
||||||
- (void)lockFocus
|
- (void)lockFocus
|
||||||
{
|
{
|
||||||
|
[[self class] pushFocusView: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)unlockFocus
|
- (void)unlockFocus
|
||||||
{
|
{
|
||||||
|
[[self class] popFocusView];
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue