Screen handling

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@13524 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 2002-04-22 15:45:10 +00:00
parent 9e70c5edd8
commit 309e040ca5
6 changed files with 93 additions and 24 deletions

View file

@ -1,3 +1,21 @@
2002-04-22 Adam Fedor <fedor@gnu.org>
* Headers/gnustep/gui/GSDisplayServer.h: Add attribute strings.
New window::: method.
* Headers/gnustep/gui/NSWindow.h: Add screen ivar plus some extra
reserved ivars.
* Source/GSDisplayServer.m: Add attribute strings.
(window::::): New
(window:::): Implement in terms of window::::
* Source/NSWindow.m: (defaultDepthLimit): Implement.
(dealloc): Release _screen.
(_initBackendWindow:): Interface change: pass frame rect to
window server window creation (not content rect). Pass screen number.
(initWithContentRect:...): Save screen, depthLimit;
(canStoreColor): Check depthLimit correctly.
(deepestScreen): Return screen.
(screen): Idem.
Sun Apr 21 12:57:36 2002 Nicola Pero <n.pero@mi.flashnet.it>
* Model/GMAppKit.m ([NSWindow -encodeWithModelArchiver:]): If not

View file

@ -13,9 +13,7 @@ prindex for protocols, and clindex for classes.
@ifinfo
@format
START-INFO-DIR-ENTRY
* gstep-gui:: The GNUstep GUI Library
END-INFO-DIR-ENTRY
@end format
@end ifinfo

View file

@ -37,7 +37,7 @@
#include <AppKit/NSGraphicsContext.h>
@class NSArray;
@class NSDictionary;
@class NSMutableDictionary;
@class NSEvent;
@class NSImage;
@class NSMutableArray;
@ -48,9 +48,14 @@
APPKIT_DECLARE GSDisplayServer * GSServerForWindow(NSWindow *window);
APPKIT_DECLARE GSDisplayServer * GSCurrentServer(void);
/* Display attributes */
APPKIT_DECLARE NSString * GSDisplayName;
APPKIT_DECLARE NSString * GSDisplayNumber;
APPKIT_DECLARE NSString * GSScreenNumber;
@interface GSDisplayServer : NSObject
{
NSDictionary *server_info;
NSMutableDictionary *server_info;
NSMutableArray *event_queue;
NSMapTable *drag_types;
}
@ -90,6 +95,8 @@ APPKIT_DECLARE GSDisplayServer * GSCurrentServer(void);
@interface GSDisplayServer (WindowOps)
- (void) _setWindowOwnedByServer: (int)win;
- (int) window: (NSRect)frame : (NSBackingStoreType)type : (unsigned int)style;
- (int) window: (NSRect)frame : (NSBackingStoreType)type : (unsigned int)style
: (int)screen;
- (void) termwindow: (int) win;
- (void) stylewindow: (int) style : (int) win;
- (void) windowbacking: (NSBackingStoreType)type : (int) win;

View file

@ -118,6 +118,8 @@ APPKIT_EXPORT NSSize NSTokenSize;
int _lastDragOperationMask;
int _windowNum;
int _gstate;
void *_reserved_s;
NSScreen *_screen;
NSColor *_backgroundColor;
NSString *_representedFilename;
NSString *_miniaturizedTitle;
@ -168,6 +170,8 @@ APPKIT_EXPORT NSSize NSTokenSize;
} _f;
id _defaultButtonCell;
void *_reserved_1;
void *_reserved_2;
}
/*

View file

@ -36,6 +36,11 @@
#include <AppKit/NSWindow.h>
#include <AppKit/GSDisplayServer.h>
/* Display attributes */
NSString * GSDisplayName = @"DisplayName";
NSString * GSDisplayNumber = @"DisplayNumber";
NSString * GSScreenNumber = @"ScreenNumber";
/* The memory zone where all server objects are allocated from (Contexts
are also allocated from this zone) */
static NSZone *_globalGSZone = NULL;
@ -135,9 +140,22 @@ GSCurrentServer(void)
<p>Create a window server with attributes, which contains key/value
pairs which describe the specifics of how the window server is to
be initialized. Typically these values are specific to the
concrete implementation. Currently there are no standard set of
attributes defined for GSDisplayServer.</p>
concrete implementation. The current set of attributes that can be
used with GSDisplayServer is.
<list>
<item>GSDisplayName</item>,
<item>GSDisplayNumber</item>,
<item>GSScreenNumber</item>,
</list>
GSDisplayName is window server specific and shouldn't be used when
creating a GSDisplayServer (although you can retrieve the value with
the -attributes method). On X-Windows the value might be set to something
like "host:d.s" where host is the host name, d is the display number and
s is the screen number. GSDisplayNumber indicates the number of the
display to open. GSScreenNumber indicates the number of the screen to
display on. If not explicitly set, these attributes may be taked from
environment variables or from other operating specific information.
</p>
<p>In almost all applications one would only create a
single instance of a window server. Although it is possible, it is
unlikely that you would need more than one window server (and you
@ -189,7 +207,7 @@ GSCurrentServer(void)
{
[super init];
ASSIGN(server_info, attributes);
server_info = [attributes mutableCopy];
event_queue = [[NSMutableArray allocWithZone: [self zone]]
initWithCapacity: 32];
drag_types = NSCreateMapTable(NSIntMapKeyCallBacks,
@ -377,10 +395,11 @@ GSCurrentServer(void)
/**
Returns an array of NSNumbers, where each number describes a screen
that is available on this display.
that is available on this display. The default screen is listed first.
*/
- (NSArray *) screenList
{
[self subclassResponsibility: _cmd];
return nil;
}
@ -422,8 +441,23 @@ GSCurrentServer(void)
/** Creates a window whose location and size is described by frame and
whose backing store is described by type. This window is not
mapped to the screen by this call */
mapped to the screen by this call. Note that frame includes the title
bar and all other window decorations. In many cases the window
manager controls these aspects of the window. The actual drawable
area of the window may vary depending on the window manager involved.
Use -styleoffsets::::: to determine the extent of the window decorations.
*/
- (int) window: (NSRect)frame : (NSBackingStoreType)type : (unsigned int)style
{
int sn = [[server_info objectForKey: GSScreenNumber] intValue];
return [self window: frame : type : style : sn];
}
/** Like window::: only there is an additional argument to specify which
screen the window will display on */
- (int) window: (NSRect)frame : (NSBackingStoreType)type : (unsigned int)style
: (int)screen
{
[self subclassResponsibility: _cmd];
return 0;
@ -471,8 +505,8 @@ GSCurrentServer(void)
}
/** Sets the window drawable for the current NSGraphicsContext,
typically by calling [NSGraphicsContext -DPSsetgcdrawable::::],
/** Sets the window device information for the current NSGraphicsContext,
typically by calling [NSGraphicsContext -GSSetDevice:::],
although depending on the concrete implmentation, more information
than this may need to be exchanged. */
- (void) windowdevice: (int) win

View file

@ -552,8 +552,7 @@ static NSNotificationCenter *nc = nil;
/* default Screen and window depth */
+ (NSWindowDepth) defaultDepthLimit
{
// FIXME: This should come from the server
return 8;
return [[NSScreen deepestScreen] depth];
}
+ (void)menuChanged: (NSMenu*)aMenu
@ -623,6 +622,7 @@ static NSNotificationCenter *nc = nil;
TEST_RELEASE(_rectsBeingDrawn);
TEST_RELEASE(_initialFirstResponder);
TEST_RELEASE(_defaultButtonCell);
RELEASE(_screen);
/*
* FIXME This should not be necessary - the views should have removed
@ -646,6 +646,7 @@ static NSNotificationCenter *nc = nil;
- (void) _initBackendWindow: (NSRect)frame
{
int screenNumber;
id dragTypes;
NSGraphicsContext *context = GSCurrentContext();
GSDisplayServer *srv = GSCurrentServer();
@ -662,9 +663,9 @@ static NSNotificationCenter *nc = nil;
[srv removeDragTypes: dragTypes fromWindow: self];
}
frame = [NSWindow contentRectForFrameRect: frame styleMask: _styleMask];
_windowNum = [srv window: frame : _backingType : _styleMask];
screenNumber = [[[_screen deviceDescription] objectForKey: @"NSScreenNumber"]
intValue];
_windowNum = [srv window: frame : _backingType : _styleMask : screenNumber];
[srv setwindowlevel: [self level] : _windowNum];
// Set window in new _gstate
@ -674,6 +675,7 @@ static NSNotificationCenter *nc = nil;
DPSgrestore(context);
NSMapInsert (windowmaps, (void*)_windowNum, self);
frame = [NSWindow contentRectForFrameRect: frame styleMask: _styleMask];
if (NSIsEmptyRect([_wv frame]))
{
frame.origin = NSZeroPoint;
@ -766,7 +768,7 @@ static NSNotificationCenter *nc = nil;
defer: (BOOL)flag
screen: (NSScreen*)aScreen
{
NSRect cframe;
NSRect cframe;
if (!NSApp)
NSLog(@"No application!\n");
@ -782,6 +784,10 @@ static NSNotificationCenter *nc = nil;
_backingType = bufferingType;
_styleMask = aStyle;
if (aScreen == nil)
aScreen = [NSScreen mainScreen];
ASSIGN(_screen, aScreen);
_depthLimit = [_screen depth];
_frame = [NSWindow frameRectForContentRect: contentRect styleMask: aStyle];
_minimumSize = NSMakeSize(_frame.size.width - contentRect.size.width + 1,
@ -1890,7 +1896,7 @@ static NSNotificationCenter *nc = nil;
- (BOOL) canStoreColor
{
if (_depthLimit > 1)
if (NSNumberOfColorComponents(NSColorSpaceFromDepth(_depthLimit)) > 1)
{
return YES;
}
@ -1900,10 +1906,12 @@ static NSNotificationCenter *nc = nil;
}
}
/** Returns the screen the window is on. Unlike (apparently) OpenStep
and MacOSX, GNUstep does not support windows being split across
multiple screens */
- (NSScreen *) deepestScreen
{
// FIXME: We must check the screens the window is on
return [NSScreen deepestScreen];
return [self screen];
}
- (NSWindowDepth) depthLimit
@ -1916,10 +1924,10 @@ static NSNotificationCenter *nc = nil;
return _f.dynamic_depth_limit;
}
/** Returns the screen the window is on. */
- (NSScreen *) screen
{
// FIXME: Works only if there is only one screen
return [NSScreen mainScreen];
return _screen;
}
- (void) setDepthLimit: (NSWindowDepth)limit
@ -3909,7 +3917,7 @@ resetCursorRectsForView(NSView *theView)
_lastPoint = NSZeroPoint;
_windowLevel = NSNormalWindowLevel;
_depthLimit = 8;
_depthLimit = NSDefaultDepth;
_disableFlushWindow = 0;
_alphaValue = 0.0;