diff options
Diffstat (limited to 'hw/darwin/quartz')
-rw-r--r-- | hw/darwin/quartz/Preferences.h | 49 | ||||
-rw-r--r-- | hw/darwin/quartz/Preferences.m | 80 | ||||
-rw-r--r-- | hw/darwin/quartz/XDarwin.pbproj/project.pbxproj | 802 | ||||
-rw-r--r-- | hw/darwin/quartz/XDarwinStartup.c | 5 | ||||
-rw-r--r-- | hw/darwin/quartz/XServer.h | 35 | ||||
-rw-r--r-- | hw/darwin/quartz/XServer.m | 537 | ||||
-rw-r--r-- | hw/darwin/quartz/pseudoramiX.c | 4 | ||||
-rw-r--r-- | hw/darwin/quartz/pseudoramiX.h | 3 | ||||
-rw-r--r-- | hw/darwin/quartz/quartz.c | 159 | ||||
-rw-r--r-- | hw/darwin/quartz/quartz.h | 91 | ||||
-rw-r--r-- | hw/darwin/quartz/quartzAudio.c | 6 | ||||
-rw-r--r-- | hw/darwin/quartz/quartzCocoa.m | 11 | ||||
-rw-r--r-- | hw/darwin/quartz/quartzCommon.h | 18 | ||||
-rw-r--r-- | hw/darwin/quartz/quartzStartup.c | 94 |
14 files changed, 1557 insertions, 337 deletions
diff --git a/hw/darwin/quartz/Preferences.h b/hw/darwin/quartz/Preferences.h index 2c0d6756b..22a2f1441 100644 --- a/hw/darwin/quartz/Preferences.h +++ b/hw/darwin/quartz/Preferences.h @@ -1,4 +1,31 @@ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/Preferences.h,v 1.2 2003/01/15 02:34:05 torrey Exp $ */ +/* + * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name(s) of the above copyright + * holders shall not be used in advertising or otherwise to promote the + * sale, use or other dealings in this Software without prior written + * authorization. + */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/Preferences.h,v 1.3 2003/09/16 00:36:12 torrey Exp $ */ #import <Cocoa/Cocoa.h> @@ -35,14 +62,14 @@ - (IBAction)saveChanges:(id)sender; - (IBAction)setKey:(id)sender; -- (BOOL)sendEvent:(NSEvent*)anEvent; +- (BOOL)sendEvent:(NSEvent *)anEvent; - (void)awakeFromNib; - (void)windowWillClose:(NSNotification *)aNotification; + (void)setUseKeymapFile:(BOOL)newUseKeymapFile; -+ (void)setKeymapFile:(NSString*)newFile; -+ (void)setSwitchString:(NSString*)newString; ++ (void)setKeymapFile:(NSString *)newFile; ++ (void)setSwitchString:(NSString *)newString; + (void)setKeyCode:(int)newKeyCode; + (void)setModifiers:(int)newModifiers; + (void)setDisplay:(int)newDisplay; @@ -59,15 +86,16 @@ + (void)setSystemBeep:(BOOL)newSystemBeep; + (void)setXinerama:(BOOL)newXinerama; + (void)setAddToPath:(BOOL)newAddToPath; -+ (void)setAddToPathString:(NSString*)newAddToPathString; ++ (void)setAddToPathString:(NSString *)newAddToPathString; + (void)setUseDefaultShell:(BOOL)newUseDefaultShell; -+ (void)setShellString:(NSString*)newShellString; ++ (void)setShellString:(NSString *)newShellString; + (void)setDepth:(int)newDepth; ++ (void)setDisplayModeBundles:(NSArray *)newBundles; + (void)saveToDisk; + (BOOL)useKeymapFile; -+ (NSString*)keymapFile; -+ (NSString*)switchString; ++ (NSString *)keymapFile; ++ (NSString *)switchString; + (unsigned int)keyCode; + (unsigned int)modifiers; + (int)display; @@ -84,10 +112,11 @@ + (BOOL)systemBeep; + (BOOL)xinerama; + (BOOL)addToPath; -+ (NSString*)addToPathString; ++ (NSString *)addToPathString; + (BOOL)useDefaultShell; -+ (NSString*)shellString; ++ (NSString *)shellString; + (int)depth; ++ (NSArray *)displayModeBundles; @end diff --git a/hw/darwin/quartz/Preferences.m b/hw/darwin/quartz/Preferences.m index 4f8dacbf0..4120b6360 100644 --- a/hw/darwin/quartz/Preferences.m +++ b/hw/darwin/quartz/Preferences.m @@ -3,10 +3,43 @@ // // This class keeps track of the user preferences. // -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/Preferences.m,v 1.2 2003/01/15 02:34:06 torrey Exp $ */ +/* + * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name(s) of the above copyright + * holders shall not be used in advertising or otherwise to promote the + * sale, use or other dealings in this Software without prior written + * authorization. + */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/Preferences.m,v 1.4 2003/09/16 00:36:12 torrey Exp $ */ -#import "Preferences.h" #import "quartzCommon.h" + +#define BOOL xBOOL +#include "darwin.h" +#undef BOOL + +#import "Preferences.h" + #include <IOKit/hidsystem/IOLLEvent.h> // for modifier masks // Macros to build the path name @@ -36,8 +69,8 @@ @"YES", @"ShowStartupHelp", [NSNumber numberWithInt:0], @"SwitchKeyCode", [NSNumber numberWithInt:(NSCommandKeyMask | NSAlternateKeyMask)], - @"SwitchModifiers", @"NO", @"UseSystemBeep", - @"YES", @"DockSwitch", + @"SwitchModifiers", @"NO", @"UseSystemBeep", + @"YES", @"DockSwitch", @"NO", @"AllowMouseAccelChange", [NSNumber numberWithInt:qdCursor_Not8Bit], @"UseQDCursor", @"YES", @"Xinerama", @@ -45,7 +78,13 @@ [NSString stringWithCString:XSTRPATH(XBINDIR)], @"AddToPathString", @"YES", @"UseDefaultShell", @"/bin/tcsh", @"Shell", - [NSNumber numberWithInt:depth_Current], @"Depth", nil]; + [NSNumber numberWithInt:depth_Current], @"Depth", +#ifdef BUILD_XPR + [NSArray arrayWithObjects:@"xpr.bundle", @"cr.bundle", nil], +#else + [NSArray arrayWithObjects:@"cr.bundle", nil], +#endif + @"DisplayModeBundles", nil]; [super initialize]; [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults]; @@ -207,7 +246,7 @@ [switchString setString:@""]; } -- (BOOL)sendEvent:(NSEvent*)anEvent +- (BOOL)sendEvent:(NSEvent *)anEvent { if(isGettingKeyCode) { if([anEvent type]==NSKeyDown) // wait for keyup @@ -240,7 +279,7 @@ return NO; } -+ (void)setKeymapFile:(NSString*)newFile ++ (void)setKeymapFile:(NSString *)newFile { [[NSUserDefaults standardUserDefaults] setObject:newFile forKey:@"KeymappingFile"]; @@ -252,7 +291,7 @@ forKey:@"UseKeymappingFile"]; } -+ (void)setSwitchString:(NSString*)newString ++ (void)setSwitchString:(NSString *)newString { [[NSUserDefaults standardUserDefaults] setObject:newString forKey:@"SwitchString"]; @@ -311,7 +350,7 @@ [[NSUserDefaults standardUserDefaults] setBool:newMouseAccelChange forKey:@"AllowMouseAccelChange"]; // Update the setting used by the X server thread - quartzMouseAccelChange = newMouseAccelChange; + darwinMouseAccelChange = newMouseAccelChange; } + (void)setUseQDCursor:(int)newUseQDCursor @@ -364,7 +403,7 @@ forKey:@"AddToPath"]; } -+ (void)setAddToPathString:(NSString*)newAddToPathString ++ (void)setAddToPathString:(NSString *)newAddToPathString { [[NSUserDefaults standardUserDefaults] setObject:newAddToPathString forKey:@"AddToPathString"]; @@ -376,7 +415,7 @@ forKey:@"UseDefaultShell"]; } -+ (void)setShellString:(NSString*)newShellString ++ (void)setShellString:(NSString *)newShellString { [[NSUserDefaults standardUserDefaults] setObject:newShellString forKey:@"Shell"]; @@ -388,6 +427,12 @@ forKey:@"Depth"]; } ++ (void)setDisplayModeBundles:(NSArray *)newBundles +{ + [[NSUserDefaults standardUserDefaults] setObject:newBundles + forKey:@"DisplayModeBundles"]; +} + + (void)saveToDisk { [[NSUserDefaults standardUserDefaults] synchronize]; @@ -399,13 +444,13 @@ boolForKey:@"UseKeymappingFile"]; } -+ (NSString*)keymapFile ++ (NSString *)keymapFile { return [[NSUserDefaults standardUserDefaults] stringForKey:@"KeymappingFile"]; } -+ (NSString*)switchString ++ (NSString *)switchString { return [[NSUserDefaults standardUserDefaults] stringForKey:@"SwitchString"]; @@ -502,7 +547,7 @@ return [[NSUserDefaults standardUserDefaults] boolForKey:@"AddToPath"]; } -+ (NSString*)addToPathString ++ (NSString *)addToPathString { return [[NSUserDefaults standardUserDefaults] stringForKey:@"AddToPathString"]; @@ -514,7 +559,7 @@ boolForKey:@"UseDefaultShell"]; } -+ (NSString*)shellString ++ (NSString *)shellString { return [[NSUserDefaults standardUserDefaults] stringForKey:@"Shell"]; @@ -526,5 +571,10 @@ integerForKey:@"Depth"]; } ++ (NSArray *)displayModeBundles +{ + return [[NSUserDefaults standardUserDefaults] + objectForKey:@"DisplayModeBundles"]; +} @end diff --git a/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj b/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj index 574ce5f18..3afc9177b 100644 --- a/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj +++ b/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj @@ -23,48 +23,6 @@ path = XApplication.h; refType = 4; }; - 014C68ED00ED6A9D7F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = XView.h; - refType = 4; - }; - 014C68EE00ED6A9D7F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = XView.m; - refType = 4; - }; - 014C68F200ED7AD67F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = fakeBoxRec.h; - refType = 4; - }; - 014C68F300EE5AB97F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootlessCommon.c; - refType = 4; - }; - 014C68F400EE5AB97F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootlessCommon.h; - refType = 4; - }; - 014C68F700EE678F7F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootlessWindow.c; - refType = 4; - }; - 014C68F800EE678F7F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootlessWindow.h; - refType = 4; - }; 015698ED003DF345CE6F79C2 = { isa = PBXFileReference; path = XDarwin.icns; @@ -99,18 +57,6 @@ path = /System/Library/Frameworks/IOKit.framework; refType = 0; }; - 017D6F4400E861FB7F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootlessGC.c; - refType = 4; - }; - 017D6F4500E861FB7F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootlessScreen.c; - refType = 4; - }; 018F40F2003E1902CE6F79C2 = { children = ( 018F40F3003E1916CE6F79C2, @@ -118,6 +64,7 @@ 3E74E03600863F047F000001, F5A94EF10314BAC70100011B, 018F40F6003E1974CE6F79C2, + 6E5F5F0005537A1A008FEAD7, ); isa = PBXGroup; name = "X Server"; @@ -261,22 +208,6 @@ //042 //043 //044 -//060 -//061 -//062 -//063 -//064 - 06EB6C3B004099E7CE6F79C2 = { - fileEncoding = 30; - isa = PBXFileReference; - path = quartzShared.h; - refType = 4; - }; -//060 -//061 -//062 -//063 -//064 //080 //081 //082 @@ -290,8 +221,6 @@ 0127909800074B1A0A000002, 01279092000747AA0A000002, 1C4A3109004D8F24CE6F79C2, - 014C68EE00ED6A9D7F000001, - 014C68ED00ED6A9D7F000001, ); isa = PBXGroup; name = Classes; @@ -356,6 +285,8 @@ dependencies = ( 6EF065C903D4F0CA006877C2, 6EF065C703D4EE19006877C2, + 6E11A986048BDFFB006877C2, + 6E7904110500F33B00EEC080, ); isa = PBXApplicationTarget; name = XDarwin; @@ -368,10 +299,42 @@ <dict> <key>CFBundleDevelopmentRegion</key> <string>English</string> + <key>CFBundleDocumentTypes</key> + <array> + <dict> + <key>CFBundleTypeExtensions</key> + <array> + <string>x11app</string> + </array> + <key>CFBundleTypeName</key> + <string>X11 Application</string> + <key>CFBundleTypeOSTypes</key> + <array> + <string>****</string> + </array> + <key>CFBundleTypeRole</key> + <string>Viewer</string> + </dict> + <dict> + <key>CFBundleTypeExtensions</key> + <array> + <string>tool</string> + <string>*</string> + </array> + <key>CFBundleTypeName</key> + <string>UNIX Application</string> + <key>CFBundleTypeOSTypes</key> + <array> + <string>****</string> + </array> + <key>CFBundleTypeRole</key> + <string>Viewer</string> + </dict> + </array> <key>CFBundleExecutable</key> <string>XDarwin</string> <key>CFBundleGetInfoString</key> - <string>XDarwin 1.2.0, ©2001-2003 XFree86 Project, Inc.</string> + <string>XDarwin 1.3b4, ©2001-2003 XFree86 Project, Inc.</string> <key>CFBundleIconFile</key> <string>XDarwin.icns</string> <key>CFBundleIdentifier</key> @@ -383,7 +346,7 @@ <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> - <string>XDarwin 1.2.0</string> + <string>XDarwin 1.3b4</string> <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> @@ -548,7 +511,7 @@ }; }; 1220774600712D75416877C2 = { - fileEncoding = 30; + fileEncoding = 10; isa = PBXFileReference; name = Japanese; path = Japanese.lproj/Localizable.strings; @@ -579,7 +542,7 @@ ); isa = PBXGroup; name = IOKit; - path = ..; + path = ../iokit; refType = 4; }; //170 @@ -597,6 +560,8 @@ 0A79E19E004499A1CE6F79C2, 6EF7C58703D3BC6D00000104, 6EF065C603D4EE19006877C2, + 6E11A985048BDFEE006877C2, + 6E7904100500F05600EEC080, ); isa = PBXGroup; name = Products; @@ -770,7 +735,9 @@ targets = ( 0A79E19F004499A1CE6F79C2, 6EF7C58603D3BC6D00000104, + 6E11A984048BDFEE006877C2, 6EF065C503D4EE19006877C2, + 6E79040F0500F05600EEC080, ); }; 29B97314FDCFA39411CA2CEA = { @@ -780,7 +747,10 @@ 170DFB0000729C86416877C2, 43B962CE00617089416877C2, F5614B3D025112D901000114, + 6EC4A64C042A9597006877C2, 32FEE13C00E07C3E7F000001, + 6EE1214104968658006877C2, + 6EC4A66D042A97FC006877C2, 29B97315FDCFA39411CA2CEA, 29B97317FDCFA39411CA2CEA, 29B97323FDCFA39411CA2CEA, @@ -875,66 +845,14 @@ //324 32FEE13C00E07C3E7F000001 = { children = ( - F56CBD0D02EB84A801129B8A, - F56CBD0E02EB84A801129B8A, - F56CBD0F02EBDCFC01129B8A, - 014C68F200ED7AD67F000001, F5269C2D01D5BC3501000001, F5269C2E01D5BC3501000001, - 32FEE13E00E07CBE7F000001, - 32FEE13F00E07CBE7F000001, - 32FEE14000E07CBE7F000001, - 32FEE14100E07CBE7F000001, - 32FEE14200E07CBE7F000001, - 014C68F300EE5AB97F000001, - 014C68F400EE5AB97F000001, - 017D6F4400E861FB7F000001, - 017D6F4500E861FB7F000001, - 014C68F700EE678F7F000001, - 014C68F800EE678F7F000001, - 32FEE14900E07D317F000001, ); isa = PBXGroup; - name = Rootless; + name = "Old Cocoa Imp"; path = ""; refType = 4; }; - 32FEE13E00E07CBE7F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootless.h; - refType = 4; - }; - 32FEE13F00E07CBE7F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootlessAqua.h; - refType = 4; - }; - 32FEE14000E07CBE7F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootlessAquaGlue.c; - refType = 4; - }; - 32FEE14100E07CBE7F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootlessAquaImp.h; - refType = 4; - }; - 32FEE14200E07CBE7F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootlessAquaImp.m; - refType = 4; - }; - 32FEE14900E07D317F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootlessValTree.c; - refType = 4; - }; //320 //321 //322 @@ -979,17 +897,19 @@ //434 43B962CE00617089416877C2 = { children = ( + 6EE9B21604E859C200CA7FEA, + 6E97A0F505079F9100B8294C, + 6E5F5F030553815A008FEAD7, + 6E5F5F040553815A008FEAD7, 018F40F8003E1979CE6F79C2, 018F40FA003E197ECE6F79C2, 237A34C10076E37E7F000001, 237A34C40076F4F07F000001, - 3576829A0077B8F17F000001, - 0338412F0083BFE57F000001, - 43B962D000617089416877C2, - 43B962D100617089416877C2, 43B962CF00617089416877C2, F5582948015DAD3B01000001, - 06EB6C3B004099E7CE6F79C2, + 6E5F5F0105537A5F008FEAD7, + 43B962D000617089416877C2, + 43B962D100617089416877C2, 02A1FEA8006D38F0416877C2, ); isa = PBXGroup; @@ -1051,6 +971,536 @@ //6E2 //6E3 //6E4 + 6E11A97F048BDFEE006877C2 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 6E11A980048BDFEE006877C2 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXResourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 6E11A981048BDFEE006877C2 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 6E11A982048BDFEE006877C2 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 6E11A983048BDFEE006877C2 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXRezBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 6E11A984048BDFEE006877C2 = { + buildPhases = ( + 6E11A97F048BDFEE006877C2, + 6E11A980048BDFEE006877C2, + 6E11A981048BDFEE006877C2, + 6E11A982048BDFEE006877C2, + 6E11A983048BDFEE006877C2, + ); + buildSettings = { + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = glxCGL; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + WRAPPER_EXTENSION = bundle; + }; + dependencies = ( + ); + isa = PBXBundleTarget; + name = glxCGL; + productInstallPath = "$(USER_LIBRARY_DIR)/Bundles"; + productName = glxCGL; + productReference = 6E11A985048BDFEE006877C2; + productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> +<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"> +<plist version=\"1.0\"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleExecutable</key> + <string>glxCGL</string> + <key>CFBundleGetInfoString</key> + <string></string> + <key>CFBundleIconFile</key> + <string></string> + <key>CFBundleIdentifier</key> + <string></string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>GLX bundle using Apple's OpenGL</string> + <key>CFBundlePackageType</key> + <string>BNDL</string> + <key>CFBundleShortVersionString</key> + <string>0.1</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>0.1</string> +</dict> +</plist> +"; + }; + 6E11A985048BDFEE006877C2 = { + isa = PBXBundleReference; + path = glxCGL.bundle; + refType = 3; + }; + 6E11A986048BDFFB006877C2 = { + isa = PBXTargetDependency; + target = 6E11A984048BDFEE006877C2; + }; + 6E5F5F0005537A1A008FEAD7 = { + fileEncoding = 30; + isa = PBXFileReference; + path = darwinKeyboard.h; + refType = 4; + }; + 6E5F5F0105537A5F008FEAD7 = { + fileEncoding = 30; + isa = PBXFileReference; + path = quartzKeyboard.c; + refType = 4; + }; + 6E5F5F030553815A008FEAD7 = { + fileEncoding = 30; + isa = PBXFileReference; + path = keysym2ucs.c; + refType = 4; + }; + 6E5F5F040553815A008FEAD7 = { + fileEncoding = 30; + isa = PBXFileReference; + path = keysym2ucs.h; + refType = 4; + }; + 6E6656EC048832CF006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "x-hook.c"; + refType = 4; + }; + 6E6656ED048832CF006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "x-hook.h"; + refType = 4; + }; + 6E6656F0048832EC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = dri.c; + refType = 4; + }; + 6E6656F1048832EC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = dri.h; + refType = 4; + }; + 6E6656F2048832EC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = dristruct.h; + refType = 4; + }; + 6E6656F3048832F9006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = appledri.c; + refType = 4; + }; + 6E79040104FD5ED900EEC080 = { + children = ( + 6E79040204FD5EDA00EEC080, + 6E79040304FD5EDA00EEC080, + 6E79040404FD5EDA00EEC080, + ); + isa = PBXGroup; + name = "Safe Alpha"; + path = safeAlpha; + refType = 4; + }; + 6E79040204FD5EDA00EEC080 = { + fileEncoding = 30; + isa = PBXFileReference; + path = safeAlpha.h; + refType = 4; + }; + 6E79040304FD5EDA00EEC080 = { + fileEncoding = 30; + isa = PBXFileReference; + path = safeAlphaPicture.c; + refType = 4; + }; + 6E79040404FD5EDA00EEC080 = { + fileEncoding = 30; + isa = PBXFileReference; + path = safeAlphaWindow.c; + refType = 4; + }; + 6E79040A0500F05600EEC080 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 6E79040B0500F05600EEC080 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXResourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 6E79040C0500F05600EEC080 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 6E79040D0500F05600EEC080 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 6E79040E0500F05600EEC080 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXRezBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 6E79040F0500F05600EEC080 = { + buildPhases = ( + 6E79040A0500F05600EEC080, + 6E79040B0500F05600EEC080, + 6E79040C0500F05600EEC080, + 6E79040D0500F05600EEC080, + 6E79040E0500F05600EEC080, + ); + buildSettings = { + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = xpr; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + WRAPPER_EXTENSION = bundle; + }; + dependencies = ( + ); + isa = PBXBundleTarget; + name = xpr; + productInstallPath = "$(USER_LIBRARY_DIR)/Bundles"; + productName = xpr; + productReference = 6E7904100500F05600EEC080; + productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> +<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"> +<plist version=\"1.0\"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleExecutable</key> + <string>xpr</string> + <key>CFBundleGetInfoString</key> + <string></string> + <key>CFBundleIconFile</key> + <string></string> + <key>CFBundleIdentifier</key> + <string></string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>Xplugin rootless implementation</string> + <key>CFBundlePackageType</key> + <string>BNDL</string> + <key>CFBundleShortVersionString</key> + <string>0.1</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>0.1</string> +</dict> +</plist> +"; + }; + 6E7904100500F05600EEC080 = { + isa = PBXBundleReference; + path = xpr.bundle; + refType = 3; + }; + 6E7904110500F33B00EEC080 = { + isa = PBXTargetDependency; + target = 6E79040F0500F05600EEC080; + }; + 6E97A0F2050798B100B8294C = { + fileEncoding = 4; + isa = PBXFileReference; + path = xprAppleWM.c; + refType = 4; + }; + 6E97A0F305079B6500B8294C = { + fileEncoding = 4; + isa = PBXFileReference; + path = crAppleWM.m; + refType = 4; + }; + 6E97A0F505079F9100B8294C = { + fileEncoding = 4; + isa = PBXFileReference; + path = applewmExt.h; + refType = 4; + }; + 6EA0B3AF0544A9CC006877C2 = { + children = ( + 6EA0B3B00544A9CC006877C2, + 6EA0B3B10544A9CC006877C2, + 6EA0B3B20544A9CC006877C2, + 6EA0B3B30544A9CC006877C2, + 6EA0B3B40544A9CC006877C2, + 6EA0B3B50544A9CC006877C2, + 6EA0B3B60544A9CC006877C2, + 6EA0B3B70544A9CC006877C2, + ); + isa = PBXGroup; + name = Acceleration; + path = accel; + refType = 4; + }; + 6EA0B3B00544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rlAccel.h; + refType = 4; + }; + 6EA0B3B10544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rlBlt.c; + refType = 4; + }; + 6EA0B3B20544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rlCopy.c; + refType = 4; + }; + 6EA0B3B30544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rlFill.c; + refType = 4; + }; + 6EA0B3B40544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rlFillRect.c; + refType = 4; + }; + 6EA0B3B50544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rlFillSpans.c; + refType = 4; + }; + 6EA0B3B60544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rlGlyph.c; + refType = 4; + }; + 6EA0B3B70544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rlSolid.c; + refType = 4; + }; + 6EA8EEC80445E25C006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rootlessConfig.h; + refType = 4; + }; + 6EC4A64C042A9597006877C2 = { + children = ( + 6EC4A65D042A9654006877C2, + 6EC4A65E042A9654006877C2, + 6EC4A65F042A9654006877C2, + 6EA8EEC80445E25C006877C2, + 6EC4A661042A9654006877C2, + 6EC4A662042A9654006877C2, + 6EC4A660042A9654006877C2, + 6EC4A663042A9654006877C2, + 6EC4A664042A9654006877C2, + 6EA0B3AF0544A9CC006877C2, + 6E79040104FD5ED900EEC080, + ); + isa = PBXGroup; + name = Rootless; + path = ../../../miext/rootless; + refType = 2; + }; + 6EC4A65D042A9654006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rootless.h; + refType = 4; + }; + 6EC4A65E042A9654006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rootlessCommon.c; + refType = 4; + }; + 6EC4A65F042A9654006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rootlessCommon.h; + refType = 4; + }; + 6EC4A660042A9654006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rootlessWindow.h; + refType = 4; + }; + 6EC4A661042A9654006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rootlessScreen.c; + refType = 4; + }; + 6EC4A662042A9654006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rootlessWindow.c; + refType = 4; + }; + 6EC4A663042A9654006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rootlessGC.c; + refType = 4; + }; + 6EC4A664042A9654006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rootlessValTree.c; + refType = 4; + }; + 6EC4A66D042A97FC006877C2 = { + children = ( + 6EF471A004478DE0006877C2, + 6E6656F3048832F9006877C2, + 6E6656F0048832EC006877C2, + 6E6656F1048832EC006877C2, + 6E6656F2048832EC006877C2, + 6ECF218404589E4D006877C2, + 6E97A0F2050798B100B8294C, + 6ECF218604589F40006877C2, + 6EF4719E04478B08006877C2, + 6EDDB2DF04508B2C006877C2, + 6EF471A204479263006877C2, + 6EF471A404479263006877C2, + 6E6656EC048832CF006877C2, + 6E6656ED048832CF006877C2, + 6EF471A504479263006877C2, + 6EF471A304479263006877C2, + ); + isa = PBXGroup; + path = xpr; + refType = 4; + }; + 6ECF218404589E4D006877C2 = { + fileEncoding = 4; + isa = PBXFileReference; + path = xpr.h; + refType = 4; + }; + 6ECF218604589F40006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = xprCursor.c; + refType = 4; + }; + 6EDDB2DF04508B2C006877C2 = { + fileEncoding = 4; + isa = PBXFileReference; + path = xprScreen.c; + refType = 4; + }; + 6EE1214104968658006877C2 = { + children = ( + 6EE1214304968692006877C2, + 6EE1214404968692006877C2, + 6EE1214204968692006877C2, + 6E97A0F305079B6500B8294C, + 6EE1214504968692006877C2, + 6EE1214604968692006877C2, + ); + isa = PBXGroup; + path = cr; + refType = 4; + }; + 6EE1214204968692006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = cr.h; + refType = 4; + }; + 6EE1214304968692006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = XView.m; + refType = 4; + }; + 6EE1214404968692006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = XView.h; + refType = 4; + }; + 6EE1214504968692006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = crFrame.m; + refType = 4; + }; + 6EE1214604968692006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = crScreen.m; + refType = 4; + }; + 6EE9B21604E859C200CA7FEA = { + fileEncoding = 30; + isa = PBXFileReference; + path = applewm.c; + refType = 4; + }; 6EF065C003D4EE19006877C2 = { buildActionMask = 2147483647; files = ( @@ -1153,6 +1603,42 @@ isa = PBXTargetDependency; target = 6EF7C58603D3BC6D00000104; }; + 6EF4719E04478B08006877C2 = { + fileEncoding = 4; + isa = PBXFileReference; + path = xprFrame.c; + refType = 4; + }; + 6EF471A004478DE0006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = Xplugin.h; + refType = 4; + }; + 6EF471A204479263006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "x-hash.c"; + refType = 4; + }; + 6EF471A304479263006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "x-list.h"; + refType = 4; + }; + 6EF471A404479263006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "x-hash.h"; + refType = 4; + }; + 6EF471A504479263006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "x-list.c"; + refType = 4; + }; 6EF7C58103D3BC6D00000104 = { buildActionMask = 2147483647; files = ( @@ -1209,7 +1695,7 @@ ); isa = PBXBundleTarget; name = glxAGL; - productName = glxAqua; + productName = glxAGL; productReference = 6EF7C58703D3BC6D00000104; productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"> @@ -1228,7 +1714,7 @@ <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> - <string>GLX bundle with AGL</string> + <string>GLX bundle using AGL framework</string> <key>CFBundlePackageType</key> <string>BNDL</string> <key>CFBundleShortVersionString</key> @@ -1277,7 +1763,7 @@ refType = 4; }; F51BF62D02026E1C01000001 = { - fileEncoding = 30; + fileEncoding = 10; isa = PBXFileReference; name = Portuguese; path = Portuguese.lproj/Localizable.strings; @@ -1336,7 +1822,7 @@ refType = 4; }; F533213C0193CBC901000001 = { - fileEncoding = 30; + fileEncoding = 10; isa = PBXFileReference; name = German; path = German.lproj/Localizable.strings; @@ -1395,7 +1881,7 @@ refType = 4; }; F533214501A4B42501000001 = { - fileEncoding = 30; + fileEncoding = 10; isa = PBXFileReference; name = Dutch; path = Dutch.lproj/Localizable.strings; @@ -1450,38 +1936,14 @@ path = fullscreen.c; refType = 4; }; - F5614B3C0251124C01000114 = { - fileEncoding = 30; - isa = PBXFileReference; - path = fullscreen.h; - refType = 4; - }; F5614B3D025112D901000114 = { children = ( F5614B3B0251124C01000114, - F5614B3C0251124C01000114, + 3576829A0077B8F17F000001, + 0338412F0083BFE57F000001, ); isa = PBXGroup; - name = "Full Screen"; - path = ""; - refType = 4; - }; - F56CBD0D02EB84A801129B8A = { - fileEncoding = 30; - isa = PBXFileReference; - path = aqua.h; - refType = 4; - }; - F56CBD0E02EB84A801129B8A = { - fileEncoding = 30; - isa = PBXFileReference; - path = aquaPicture.c; - refType = 4; - }; - F56CBD0F02EBDCFC01129B8A = { - fileEncoding = 30; - isa = PBXFileReference; - path = aquaWindow.c; + path = fullscreen; refType = 4; }; F587E16001924C1D01000001 = { @@ -1505,7 +1967,7 @@ refType = 4; }; F587E16301924C5E01000001 = { - fileEncoding = 30; + fileEncoding = 10; isa = PBXFileReference; name = Swedish; path = Swedish.lproj/Localizable.strings; @@ -1552,7 +2014,7 @@ refType = 4; }; F58D65DE018F79A001000001 = { - fileEncoding = 30; + fileEncoding = 10; isa = PBXFileReference; name = French; path = French.lproj/Localizable.strings; @@ -1604,7 +2066,7 @@ refType = 4; }; F5ACD25FC5B5E9AA01000001 = { - fileEncoding = 30; + fileEncoding = 10; isa = PBXFileReference; name = Spanish; path = Spanish.lproj/Localizable.strings; @@ -1651,7 +2113,7 @@ refType = 4; }; F5ACD266C5BE03C501000001 = { - fileEncoding = 30; + fileEncoding = 10; isa = PBXFileReference; name = ko; path = ko.lproj/Localizable.strings; diff --git a/hw/darwin/quartz/XDarwinStartup.c b/hw/darwin/quartz/XDarwinStartup.c index 53343aa1e..7b2c89f38 100644 --- a/hw/darwin/quartz/XDarwinStartup.c +++ b/hw/darwin/quartz/XDarwinStartup.c @@ -38,16 +38,15 @@ * dealings in this Software without prior written authorization from * Torrey T. Lyons. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XDarwinStartup.c,v 1.1 2002/03/28 02:21:18 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XDarwinStartup.c,v 1.2 2003/05/14 05:15:56 torrey Exp $ */ #include <unistd.h> #include <stdio.h> #include <stdlib.h> +#include <errno.h> #include <sys/syslimits.h> #include <ApplicationServices/ApplicationServices.h> -extern int errno; - // Macros to build the path name #ifndef XBINDIR #define XBINDIR /usr/X11R6/bin diff --git a/hw/darwin/quartz/XServer.h b/hw/darwin/quartz/XServer.h index 3eadd650e..58c7ff748 100644 --- a/hw/darwin/quartz/XServer.h +++ b/hw/darwin/quartz/XServer.h @@ -29,7 +29,7 @@ * sale, use or other dealings in this Software without prior written * authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XServer.h,v 1.8 2003/01/23 00:34:26 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XServer.h,v 1.15 2003/11/14 20:27:58 torrey Exp $ */ #define BOOL xBOOL #include "Xproto.h" @@ -41,15 +41,14 @@ // server state int serverState; NSRecursiveLock *serverLock; + NSMutableArray *pendingClients; BOOL serverVisible; BOOL rootlessMenuBarVisible; BOOL queueShowServer; + BOOL quitWithoutQuery; UInt32 mouseState; - Class windowClass; - - // server event queue BOOL sendServerEvents; - int eventWriteFD; + BOOL x11Active; // Aqua interface IBOutlet NSWindow *modeWindow; @@ -59,6 +58,12 @@ IBOutlet NSWindow *helpWindow; IBOutlet NSButton *startupHelpButton; IBOutlet NSPanel *switchWindow; + + // Menu elements setable by Apple-WM extension + IBOutlet NSMenu *windowMenu; + IBOutlet NSMenuItem *windowSeparator; + IBOutlet NSMenu *dockMenu; + int checkedWindowItem; } - (id)init; @@ -68,9 +73,11 @@ + (void)append:(NSString *)value toEnv:(NSString *)name; +- (BOOL)loadDisplayBundle; - (void)startX; - (void)finishStartX; - (BOOL)startXClients; +- (void)runClient:(NSString *)filename; - (void)run; - (void)toggle; - (void)showServer:(BOOL)show; @@ -82,19 +89,36 @@ - (void)sendXEvent:(xEvent *)xe; - (void)sendShowHide:(BOOL)show; - (void)clientProcessDone:(int)clientStatus; +- (void)activateX11:(BOOL)state; +- (void)windowBecameKey:(NSWindow *)window; +- (void)setX11WindowList:(NSArray *)list; +- (void)setX11WindowCheck:(NSNumber *)nn; // Aqua interface actions - (IBAction)startFullScreen:(id)sender; - (IBAction)startRootless:(id)sender; - (IBAction)closeHelpAndShow:(id)sender; +- (IBAction)showSwitchPanel:(id)sender; - (IBAction)showAction:(id)sender; +- (IBAction)itemSelected:(id)sender; +- (IBAction)nextWindow:(id)sender; +- (IBAction)previousWindow:(id)sender; +- (IBAction)performClose:(id)sender; +- (IBAction)performMiniaturize:(id)sender; +- (IBAction)performZoom:(id)sender; +- (IBAction)bringAllToFront:(id)sender; +- (IBAction)copy:(id)sender; // NSApplication delegate - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; +- (void)applicationWillTerminate:(NSNotification *)aNotification; - (void)applicationDidFinishLaunching:(NSNotification *)aNotification; +- (void)applicationDidHide:(NSNotification *)aNotification; +- (void)applicationDidUnhide:(NSNotification *)aNotification; - (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag; - (void)applicationWillResignActive:(NSNotification *)aNotification; - (void)applicationWillBecomeActive:(NSNotification *)aNotification; +- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename; // NSPort delegate - (void)handlePortMessage:(NSPortMessage *)portMessage; @@ -109,4 +133,3 @@ enum { server_Quitting, server_Done }; - diff --git a/hw/darwin/quartz/XServer.m b/hw/darwin/quartz/XServer.m index c57defd53..1be22f82c 100644 --- a/hw/darwin/quartz/XServer.m +++ b/hw/darwin/quartz/XServer.m @@ -34,7 +34,7 @@ * sale, use or other dealings in this Software without prior written * authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.8 2003/01/23 00:34:26 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.17 2003/11/14 20:27:58 torrey Exp $ */ #include "quartzCommon.h" @@ -42,7 +42,12 @@ #include "X.h" #include "Xproto.h" #include "os.h" +#include "opaque.h" #include "darwin.h" +#include "quartz.h" +#define _APPLEWM_SERVER_ +#include "applewm.h" +#include "applewmExt.h" #undef BOOL #import "XServer.h" @@ -64,14 +69,6 @@ #import <IOKit/pwr_mgt/IOPMLib.h> #import <IOKit/IOMessage.h> -#define ENQUEUE(xe) \ -{ \ - char byte = 0; \ - DarwinEQEnqueue(xe); \ - /* signal there is an event ready to handle */ \ - write(eventWriteFD, &byte, 1); \ -} - // Types of shells enum { shell_Unknown, @@ -90,7 +87,7 @@ static shellList_t const shellList[] = { { "sh", shell_Bourne }, // standard Bourne shell { "zsh", shell_Bourne }, // Z shell { "bash", shell_Bourne }, // GNU Bourne again shell - { NULL, shell_Unknown } + { NULL, shell_Unknown } }; extern int argcGlobal; @@ -99,7 +96,6 @@ extern char **envpGlobal; extern int main(int argc, char *argv[], char *envp[]); extern void HideMenuBar(void); extern void ShowMenuBar(void); -extern void QuartzReallySetCursor(); static void childDone(int sig); static void powerDidChange(void *x, io_service_t y, natural_t messageType, void *messageArgument); @@ -122,15 +118,15 @@ static io_connect_t root_port; serverState = server_NotStarted; serverLock = [[NSRecursiveLock alloc] init]; + pendingClients = nil; clientPID = 0; sendServerEvents = NO; + x11Active = YES; serverVisible = NO; rootlessMenuBarVisible = YES; queueShowServer = YES; quartzServerQuitting = NO; mouseState = 0; - eventWriteFD = quartzEventWriteFD; - windowClass = [NSWindow class]; // set up a port to safely send messages to main thread from server thread signalPort = [[NSPort port] retain]; @@ -145,6 +141,11 @@ static io_connect_t root_port; [[NSRunLoop currentRunLoop] addPort:signalPort forMode:NSModalPanelRunLoopMode]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(windowBecameKey:) + name:NSWindowDidBecomeKeyNotification + object:nil]; + return self; } @@ -164,7 +165,7 @@ static io_connect_t root_port; [self showServer:NO]; sendServerEvents = NO; - if (clientPID != 0 || !quartzStartClients) { + if (!quitWithoutQuery && (clientPID != 0 || !quartzStartClients)) { int but; but = NSRunAlertPanel(NSLocalizedString(@"Quit X server?",@""), @@ -270,11 +271,18 @@ static io_connect_t root_port; break; case NSLeftMouseDown: [self getMousePosition:&xe fromEvent:anEvent]; - if (quartzRootless && - ! ([anEvent window] && - [[anEvent window] isKindOfClass:windowClass])) { - // Click in non X window - ignore - return NO; + if (quartzRootless) { + // Check that event is in X11 window + if (!quartzProcs->IsX11Window([anEvent window], + [anEvent windowNumber])) + { + if (x11Active) + [self activateX11:NO]; + return NO; + } else { + if (!x11Active) + [self activateX11:YES]; + } } mouse1Pressed = YES; xe.u.u.type = ButtonPress; @@ -310,6 +318,8 @@ static io_connect_t root_port; break; case NSKeyDown: case NSKeyUp: + if (!x11Active) + return NO; // If the mouse is not on the valid X display area, // we don't send the X server key events. if (![self getMousePosition:&xe fromEvent:nil]) @@ -321,6 +331,8 @@ static io_connect_t root_port; xe.u.u.detail = [anEvent keyCode]; break; case NSFlagsChanged: + if (!x11Active) + return NO; [self getMousePosition:&xe fromEvent:nil]; xe.u.u.type = kXDarwinUpdateModifiers; xe.u.clientMessage.u.l.longs0 = flags; @@ -335,14 +347,13 @@ static io_connect_t root_port; [self sendXEvent:&xe]; - // Rootless: Send first NSLeftMouseDown to windows and views so window - // ordering can be suppressed. + // Rootless: Send first NSLeftMouseDown to Cocoa windows and views so + // window ordering can be suppressed. // Don't pass further events - they (incorrectly?) bring the window // forward no matter what. if (quartzRootless && (type == NSLeftMouseDown || type == NSLeftMouseUp) && - [anEvent clickCount] == 1 && - [[anEvent window] isKindOfClass:windowClass]) + [anEvent clickCount] == 1 && [anEvent window]) { return NO; } @@ -429,6 +440,27 @@ static io_connect_t root_port; } } + +// Load the appropriate display mode bundle +- (BOOL)loadDisplayBundle +{ + if (quartzRootless) { + NSEnumerator *enumerator = [[Preferences displayModeBundles] + objectEnumerator]; + NSString *bundleName; + + while ((bundleName = [enumerator nextObject])) { + if (QuartzLoadDisplayBundle([bundleName cString])) + return YES; + } + + return NO; + } else { + return QuartzLoadDisplayBundle("fullscreen.bundle"); + } +} + + // Start the X server thread and the client process - (void)startX { @@ -455,6 +487,9 @@ static io_connect_t root_port; else NSLog(@"No version"); + if (![self loadDisplayBundle]) + [NSApp terminate:nil]; + // Start the X server thread serverState = server_Starting; [NSThread detachNewThreadSelector:@selector(run) toTarget:self @@ -517,6 +552,19 @@ static io_connect_t root_port; if (quartzServerQuitting) { [self quitServer]; [NSApp replyToApplicationShouldTerminate:YES]; + return; + } + + if (pendingClients) { + NSEnumerator *enumerator = [pendingClients objectEnumerator]; + NSString *filename; + + while ((filename = [enumerator nextObject])) { + [self runClient:filename]; + } + + [pendingClients release]; + pendingClients = nil; } } @@ -666,6 +714,87 @@ static io_connect_t root_port; return YES; } +// Start the specified client in its own task +// FIXME: This should be unified with startXClients +- (void)runClient:(NSString *)filename +{ + const char *command = [filename UTF8String]; + const char *shell; + const char *argv[5]; + int child1, child2 = 0; + int status; + + shell = getenv("SHELL"); + if (shell == NULL) + shell = "/bin/bash"; + + /* At least [ba]sh, [t]csh and zsh all work with this syntax. We + need to use an interactive shell to force it to load the user's + environment. */ + + argv[0] = shell; + argv[1] = "-i"; + argv[2] = "-c"; + argv[3] = command; + argv[4] = NULL; + + /* Do the fork-twice trick to avoid having to reap zombies */ + + child1 = fork(); + + switch (child1) { + case -1: /* error */ + break; + + case 0: /* child1 */ + child2 = fork(); + + switch (child2) { + int max_files, i; + char buf[1024], *tem; + + case -1: /* error */ + _exit(1); + + case 0: /* child2 */ + /* close all open files except for standard streams */ + max_files = sysconf(_SC_OPEN_MAX); + for (i = 3; i < max_files; i++) + close(i); + + /* ensure stdin is on /dev/null */ + close(0); + open("/dev/null", O_RDONLY); + + /* cd $HOME */ + tem = getenv("HOME"); + if (tem != NULL) + chdir(tem); + + /* Setup environment */ + snprintf(buf, sizeof(buf), ":%s", display); + setenv("DISPLAY", buf, TRUE); + tem = getenv("PATH"); + if (tem != NULL && tem[0] != NULL) + snprintf(buf, sizeof(buf), "%s:/usr/X11R6/bin", tem); + else + snprintf(buf, sizeof(buf), "/bin:/usr/bin:/usr/X11R6/bin"); + setenv("PATH", buf, TRUE); + + execvp(argv[0], (char **const) argv); + + _exit(2); + + default: /* parent (child1) */ + _exit(0); + } + break; + + default: /* parent */ + waitpid(child1, &status, 0); + } +} + // Run the X server thread - (void)run { @@ -712,6 +841,12 @@ static io_connect_t root_port; [NSApp activateIgnoringOtherApps:YES]; } +// Show the Aqua-X11 switch panel useful for fullscreen mode +- (IBAction)showSwitchPanel:(id)sender +{ + [switchWindow orderFront:nil]; +} + // Show the X server when sent message from GUI - (IBAction)showAction:(id)sender { @@ -787,11 +922,10 @@ static io_connect_t root_port; if (show) { if (!quartzRootless) { - QuartzFSCapture(); + quartzProcs->CaptureScreens(); HideMenuBar(); } - xe.u.u.type = kXDarwinShow; - [self sendXEvent:&xe]; + [self activateX11:YES]; // the mouse location will have moved; track it xe.u.u.type = MotionNotify; @@ -802,14 +936,19 @@ static io_connect_t root_port; xe.u.clientMessage.u.l.longs0 = [[NSApp currentEvent] modifierFlags]; [self sendXEvent:&xe]; - // put the pasteboard into the X cut buffer - [self readPasteboard]; + // If there is no AppleWM-aware cut and paste manager, do what we can. + if ((AppleWMSelectedEvents() & AppleWMPasteboardNotifyMask) == 0) { + // put the pasteboard into the X cut buffer + [self readPasteboard]; + } } else { - // put the X cut buffer on the pasteboard - [self writePasteboard]; + // If there is no AppleWM-aware cut and paste manager, do what we can. + if ((AppleWMSelectedEvents() & AppleWMPasteboardNotifyMask) == 0) { + // put the X cut buffer on the pasteboard + [self writePasteboard]; + } - xe.u.u.type = kXDarwinHide; - [self sendXEvent:&xe]; + [self activateX11:NO]; } serverVisible = show; @@ -877,7 +1016,7 @@ static io_connect_t root_port; } #endif - ENQUEUE(xe); + DarwinEQEnqueue(xe); } // Handle messages from the X server thread @@ -885,12 +1024,12 @@ static io_connect_t root_port; { unsigned msg = [portMessage msgid]; - switch(msg) { + switch (msg) { case kQuartzServerHidden: // Make sure the X server wasn't queued to be shown again while // the hide was pending. if (!quartzRootless && !serverVisible) { - QuartzFSRelease(); + quartzProcs->ReleaseScreens(); ShowMenuBar(); } break; @@ -908,13 +1047,43 @@ static io_connect_t root_port; break; case kQuartzCursorUpdate: - QuartzReallySetCursor(); + if (quartzProcs->CursorUpdate) + quartzProcs->CursorUpdate(); break; case kQuartzPostEvent: { const xEvent *xe = [[[portMessage components] lastObject] bytes]; - ENQUEUE(xe); + DarwinEQEnqueue(xe); + break; + } + + case kQuartzSetWindowMenu: + { + NSArray *list; + [[[portMessage components] lastObject] getBytes:&list]; + [self setX11WindowList:list]; + [list release]; + break; + } + + case kQuartzSetWindowMenuCheck: + { + int n; + [[[portMessage components] lastObject] getBytes:&n]; + [self setX11WindowCheck:[NSNumber numberWithInt:n]]; + break; + } + + case kQuartzSetFrontProcess: + [NSApp activateIgnoringOtherApps:YES]; + break; + + case kQuartzSetCanQuit: + { + int n; + [[[portMessage components] lastObject] getBytes:&n]; + quitWithoutQuery = (BOOL) n; break; } @@ -939,6 +1108,234 @@ static io_connect_t root_port; } } +// User selected an X11 window from a menu +- (IBAction)itemSelected:(id)sender +{ + xEvent xe; + + [NSApp activateIgnoringOtherApps:YES]; + + // Notify the client of the change through the X server thread + xe.u.u.type = kXDarwinControllerNotify; + xe.u.clientMessage.u.l.longs0 = AppleWMWindowMenuItem; + xe.u.clientMessage.u.l.longs1 = [sender tag]; + [self sendXEvent:&xe]; +} + +// User selected Next from window menu +- (IBAction)nextWindow:(id)sender +{ + QuartzMessageServerThread(kXDarwinControllerNotify, 1, + AppleWMNextWindow); +} + +// User selected Previous from window menu +- (IBAction)previousWindow:(id)sender +{ + QuartzMessageServerThread(kXDarwinControllerNotify, 1, + AppleWMPreviousWindow); +} + +/* + * The XPR implementation handles close, minimize, and zoom actions for X11 + * windows here, while CR handles these in the NSWindow class. + */ + +// Handle Close from window menu for X11 window in XPR implementation +- (IBAction)performClose:(id)sender +{ + QuartzMessageServerThread(kXDarwinControllerNotify, 1, + AppleWMCloseWindow); +} + +// Handle Minimize from window menu for X11 window in XPR implementation +- (IBAction)performMiniaturize:(id)sender +{ + QuartzMessageServerThread(kXDarwinControllerNotify, 1, + AppleWMMinimizeWindow); +} + +// Handle Zoom from window menu for X11 window in XPR implementation +- (IBAction)performZoom:(id)sender +{ + QuartzMessageServerThread(kXDarwinControllerNotify, 1, + AppleWMZoomWindow); +} + +// Handle "Bring All to Front" from window menu +- (IBAction)bringAllToFront:(id)sender +{ + if ((AppleWMSelectedEvents() & AppleWMControllerNotifyMask) != 0) { + QuartzMessageServerThread(kXDarwinControllerNotify, 1, + AppleWMBringAllToFront); + } else { + [NSApp arrangeInFront:nil]; + } +} + +// This ends up at the end of the responder chain. +- (IBAction)copy:(id)sender +{ + QuartzMessageServerThread(kXDarwinPasteboardNotify, 1, + AppleWMCopyToPasteboard); +} + +// Set whether or not X11 is active and should receive all key events +- (void)activateX11:(BOOL)state +{ + if (state) { + QuartzMessageServerThread(kXDarwinActivate, 0); + } + else { + QuartzMessageServerThread(kXDarwinDeactivate, 0); + } + + x11Active = state; +} + +// Some NSWindow became the key window +- (void)windowBecameKey:(NSWindow *)window +{ + if (quartzProcs->IsX11Window(window, [window windowNumber])) { + if (!x11Active) + [self activateX11:YES]; + } else { + if (x11Active) + [self activateX11:NO]; + } +} + +// Set the Apple-WM specifiable part of the window menu +- (void)setX11WindowList:(NSArray *)list +{ + NSMenuItem *item; + int first, count, i; + xEvent xe; + + /* Work backwards so we don't mess up the indices */ + first = [windowMenu indexOfItem:windowSeparator] + 1; + if (first > 0) { + count = [windowMenu numberOfItems]; + for (i = count - 1; i >= first; i--) + [windowMenu removeItemAtIndex:i]; + } else { + windowSeparator = (NSMenuItem *)[windowMenu addItemWithTitle:@"" + action:nil + keyEquivalent:@""]; + } + + count = [dockMenu numberOfItems]; + for (i = 0; i < count; i++) + [dockMenu removeItemAtIndex:0]; + + count = [list count]; + + for (i = 0; i < count; i++) + { + NSString *name, *shortcut; + + name = [[list objectAtIndex:i] objectAtIndex:0]; + shortcut = [[list objectAtIndex:i] objectAtIndex:1]; + + item = (NSMenuItem *)[windowMenu addItemWithTitle:name + action:@selector(itemSelected:) + keyEquivalent:shortcut]; + [item setTarget:self]; + [item setTag:i]; + [item setEnabled:YES]; + + item = (NSMenuItem *)[dockMenu insertItemWithTitle:name + action:@selector(itemSelected:) + keyEquivalent:shortcut atIndex:i]; + [item setTarget:self]; + [item setTag:i]; + [item setEnabled:YES]; + } + + if (checkedWindowItem >= 0 && checkedWindowItem < count) + { + item = (NSMenuItem *)[windowMenu itemAtIndex:first + checkedWindowItem]; + [item setState:NSOnState]; + item = (NSMenuItem *)[dockMenu itemAtIndex:checkedWindowItem]; + [item setState:NSOnState]; + } + + // Notify the client of the change through the X server thread + xe.u.u.type = kXDarwinControllerNotify; + xe.u.clientMessage.u.l.longs0 = AppleWMWindowMenuNotify; + [self sendXEvent:&xe]; +} + +// Set the checked item on the Apple-WM specifiable window menu +- (void)setX11WindowCheck:(NSNumber *)nn +{ + NSMenuItem *item; + int first, count; + int n = [nn intValue]; + + first = [windowMenu indexOfItem:windowSeparator] + 1; + count = [windowMenu numberOfItems] - first; + + if (checkedWindowItem >= 0 && checkedWindowItem < count) + { + item = (NSMenuItem *)[windowMenu itemAtIndex:first + checkedWindowItem]; + [item setState:NSOffState]; + item = (NSMenuItem *)[dockMenu itemAtIndex:checkedWindowItem]; + [item setState:NSOffState]; + } + if (n >= 0 && n < count) + { + item = (NSMenuItem *)[windowMenu itemAtIndex:first + n]; + [item setState:NSOnState]; + item = (NSMenuItem *)[dockMenu itemAtIndex:n]; + [item setState:NSOnState]; + } + checkedWindowItem = n; +} + +// Return whether or not a menu item should be enabled +- (BOOL)validateMenuItem:(NSMenuItem *)item +{ + NSMenu *menu = [item menu]; + + if (menu == windowMenu && [item tag] == 30) { + // Mode switch panel is for fullscreen only + return !quartzRootless; + } + else if ((menu == windowMenu && [item tag] != 40) || menu == dockMenu) { + // The special window and dock menu items should not be active unless + // there is an AppleWM-aware window manager running. + return (AppleWMSelectedEvents() & AppleWMControllerNotifyMask) != 0; + } + else { + return TRUE; + } +} + +/* + * Application Delegate Methods + */ + +- (void)applicationDidHide:(NSNotification *)aNotification +{ + if ((AppleWMSelectedEvents() & AppleWMControllerNotifyMask) != 0) { + QuartzMessageServerThread(kXDarwinControllerNotify, 1, + AppleWMHideAll); + } else { + // FIXME: We need to hide Xplugin windows here + } +} + +- (void)applicationDidUnhide:(NSNotification *)aNotification +{ + if ((AppleWMSelectedEvents() & AppleWMControllerNotifyMask) != 0) { + QuartzMessageServerThread(kXDarwinControllerNotify, 1, + AppleWMShowAll); + } else { + [NSApp arrangeInFront:nil]; + } +} + // Called when the user clicks the application icon, // but not when Cmd-Tab is used. // Rootless: Don't switch until applicationWillBecomeActive. @@ -958,8 +1355,38 @@ static io_connect_t root_port; - (void)applicationWillBecomeActive:(NSNotification *)aNotification { - if (quartzRootless) + if (quartzRootless) { [self showServer:YES]; + + // If there is no AppleWM-aware window manager, we can't allow + // interleaving of Aqua and X11 windows. + if ((AppleWMSelectedEvents() & AppleWMControllerNotifyMask) == 0) { + [NSApp arrangeInFront:nil]; + } + } +} + +// Called when the user opens a document type that we claim (ie. an X11 executable). +- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename +{ + if (serverState == server_Running) { + [self runClient:filename]; + return YES; + } + else if (serverState == server_NotStarted || serverState == server_Starting) { + if ([filename UTF8String][0] != ':') { // Ignore display names + if (!pendingClients) { + pendingClients = [[NSMutableArray alloc] initWithCapacity:1]; + } + [pendingClients addObject:filename]; + return YES; // Assume it will launch successfully + } + return NO; + } + + // If the server is quitting or done, + // its too late to launch new clients this time. + return NO; } @end @@ -970,7 +1397,7 @@ static io_connect_t root_port; // NSPort is not thread safe. void QuartzMessageMainThread(unsigned msg, void *data, unsigned length) { - if (msg == kQuartzPostEvent) { + if (length > 0) { NSData *eventData = [NSData dataWithBytes:data length:length]; NSArray *eventArray = [NSArray arrayWithObject:eventData]; NSPortMessage *newMessage = @@ -986,6 +1413,36 @@ void QuartzMessageMainThread(unsigned msg, void *data, unsigned length) } } +void +QuartzSetWindowMenu(int nitems, const char **items, + const char *shortcuts) +{ + NSMutableArray *array; + int i; + + array = [[NSMutableArray alloc] initWithCapacity:nitems]; + + for (i = 0; i < nitems; i++) { + NSMutableArray *subarray = [NSMutableArray arrayWithCapacity:2]; + NSString *string = [NSString stringWithUTF8String:items[i]]; + + [subarray addObject:string]; + + if (shortcuts[i] != 0) { + NSString *number = [NSString stringWithFormat:@"%d", + shortcuts[i]]; + [subarray addObject:number]; + } else + [subarray addObject:@""]; + + [array addObject:subarray]; + } + + /* Send the array of strings over to the main thread. */ + /* Will be released in main thread. */ + QuartzMessageMainThread(kQuartzSetWindowMenu, &array, sizeof(NSArray *)); +} + // Handle SIGCHLD signals static void childDone(int sig) { @@ -1025,5 +1482,5 @@ static void powerDidChange( } break; } - + } diff --git a/hw/darwin/quartz/pseudoramiX.c b/hw/darwin/quartz/pseudoramiX.c index e55aabd6f..2dd7c3ae5 100644 --- a/hw/darwin/quartz/pseudoramiX.c +++ b/hw/darwin/quartz/pseudoramiX.c @@ -32,7 +32,7 @@ shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from Digital Equipment Corporation. ******************************************************************/ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/pseudoramiX.c,v 1.2 2002/10/16 21:13:33 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/pseudoramiX.c,v 1.3 2003/04/30 23:15:39 torrey Exp $ */ #include "pseudoramiX.h" @@ -111,7 +111,7 @@ void PseudoramiXExtensionInit(int argc, char *argv[]) if (noPseudoramiXExtension) return; - if (pseudoramiXNumScreens == 1 || aquaNumScreens == 1) { + if (pseudoramiXNumScreens == 1) { // Only one screen - disable Xinerama extension. noPseudoramiXExtension = TRUE; return; diff --git a/hw/darwin/quartz/pseudoramiX.h b/hw/darwin/quartz/pseudoramiX.h index d0d596686..23738cfb3 100644 --- a/hw/darwin/quartz/pseudoramiX.h +++ b/hw/darwin/quartz/pseudoramiX.h @@ -1,10 +1,9 @@ /* * Minimal implementation of PanoramiX/Xinerama */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/pseudoramiX.h,v 1.1 2002/03/28 02:21:18 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/pseudoramiX.h,v 1.2 2003/04/30 23:15:39 torrey Exp $ */ extern int noPseudoramiXExtension; -extern int aquaNumScreens; void PseudoramiXAddScreen(int x, int y, int w, int h); void PseudoramiXExtensionInit(int argc, char *argv[]); diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c index 592a0e4a0..4643886f3 100644 --- a/hw/darwin/quartz/quartz.c +++ b/hw/darwin/quartz/quartz.c @@ -29,16 +29,16 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartz.c,v 1.7 2003/01/23 00:34:26 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartz.c,v 1.13 2003/11/12 20:21:51 torrey Exp $ */ #include "quartzCommon.h" #include "quartz.h" #include "darwin.h" #include "quartzAudio.h" -#include "quartzCursor.h" -#include "fullscreen.h" -#include "rootlessAqua.h" #include "pseudoramiX.h" +#define _APPLEWM_SERVER_ +#include "applewm.h" +#include "applewmExt.h" // X headers #include "scrnintstr.h" @@ -61,8 +61,8 @@ int quartzServerQuitting = FALSE; int quartzScreenIndex = 0; int aquaMenuBarHeight = 0; int noPseudoramiXExtension = TRUE; -int aquaNumScreens = 0; - +QuartzModeProcsPtr quartzProcs = NULL; +const char *quartzOpenGLBundle = NULL; /* =========================================================================== @@ -73,10 +73,10 @@ int aquaNumScreens = 0; */ /* - * QuartzAddScreen + * DarwinModeAddScreen * Do mode dependent initialization of each screen for Quartz. */ -Bool QuartzAddScreen( +Bool DarwinModeAddScreen( int index, ScreenPtr pScreen) { @@ -84,34 +84,25 @@ Bool QuartzAddScreen( QuartzScreenPtr displayInfo = xcalloc(sizeof(QuartzScreenRec), 1); QUARTZ_PRIV(pScreen) = displayInfo; - // do full screen or rootless specific initialization - if (quartzRootless) { - return AquaAddScreen(index, pScreen); - } else { - return QuartzFSAddScreen(index, pScreen); - } + // do Quartz mode specific initialization + return quartzProcs->AddScreen(index, pScreen); } /* - * QuartzSetupScreen + * DarwinModeSetupScreen * Finalize mode specific setup of each screen. */ -Bool QuartzSetupScreen( +Bool DarwinModeSetupScreen( int index, ScreenPtr pScreen) { - // do full screen or rootless specific setup - if (quartzRootless) { - if (! AquaSetupScreen(index, pScreen)) - return FALSE; - } else { - if (! QuartzFSSetupScreen(index, pScreen)) - return FALSE; - } + // do Quartz mode specific setup + if (! quartzProcs->SetupScreen(index, pScreen)) + return FALSE; // setup cursor support - if (! QuartzInitCursor(pScreen)) + if (! quartzProcs->InitCursor(pScreen)) return FALSE; return TRUE; @@ -119,10 +110,10 @@ Bool QuartzSetupScreen( /* - * QuartzInitOutput + * DarwinModeInitOutput * Quartz display initialization. */ -void QuartzInitOutput( +void DarwinModeInitOutput( int argc, char **argv ) { @@ -145,13 +136,8 @@ void QuartzInitOutput( FatalError("Could not register block and wakeup handlers."); } - if (quartzRootless) { - ErrorF("Display mode: Rootless Quartz\n"); - AquaDisplayInit(); - } else { - ErrorF("Display mode: Full screen Quartz\n"); - QuartzFSDisplayInit(); - } + // Do display mode specific initialization + quartzProcs->DisplayInit(); // Init PseudoramiX implementation of Xinerama. // This should be in InitExtensions, but that causes link errors @@ -163,21 +149,28 @@ void QuartzInitOutput( /* - * QuartzInitInput + * DarwinModeInitInput * Inform the main thread the X server is ready to handle events. */ -void QuartzInitInput( +void DarwinModeInitInput( int argc, char **argv ) { - QuartzMessageMainThread(kQuartzServerStarted, NULL, 0); + if (serverGeneration == 1) { + QuartzMessageMainThread(kQuartzServerStarted, NULL, 0); + } + + // Do final display mode specific initialization before handling events + if (quartzProcs->InitInput) + quartzProcs->InitInput(argc, argv); } /* * QuartzShow * Show the X server on screen. Does nothing if already shown. - * Restore the X clip regions and the X server cursor state. + * Calls mode specific screen resume to restore the X clip regions + * (if needed) and the X server cursor state. */ static void QuartzShow( int x, // cursor location @@ -189,9 +182,7 @@ static void QuartzShow( quartzServerVisible = TRUE; for (i = 0; i < screenInfo.numScreens; i++) { if (screenInfo.screens[i]) { - QuartzResumeXCursor(screenInfo.screens[i], x, y); - if (!quartzRootless) - xf86SetRootClip(screenInfo.screens[i], TRUE); + quartzProcs->ResumeScreen(screenInfo.screens[i], x, y); } } } @@ -201,8 +192,8 @@ static void QuartzShow( /* * QuartzHide * Remove the X server display from the screen. Does nothing if already - * hidden. Set X clip regions to prevent drawing, and restore the Aqua - * cursor. + * hidden. Calls mode specific screen suspend to set X clip regions to + * prevent drawing (if needed) and restore the Aqua cursor. */ static void QuartzHide(void) { @@ -211,9 +202,7 @@ static void QuartzHide(void) if (quartzServerVisible) { for (i = 0; i < screenInfo.numScreens; i++) { if (screenInfo.screens[i]) { - QuartzSuspendXCursor(screenInfo.screens[i]); - if (!quartzRootless) - xf86SetRootClip(screenInfo.screens[i], FALSE); + quartzProcs->SuspendScreen(screenInfo.screens[i]); } } } @@ -243,20 +232,58 @@ static void QuartzSetRootClip( /* - * QuartzProcessEvent + * QuartzMessageServerThread + * Send the X server thread a message by placing it on the event queue. + */ +void +QuartzMessageServerThread( + int type, + int argc, ...) +{ + xEvent xe; + INT32 *argv; + int i, max_args; + va_list args; + + memset(&xe, 0, sizeof(xe)); + xe.u.u.type = type; + xe.u.clientMessage.u.l.type = type; + + argv = &xe.u.clientMessage.u.l.longs0; + max_args = 4; + + if (argc > 0 && argc <= max_args) { + va_start (args, argc); + for (i = 0; i < argc; i++) + argv[i] = (int) va_arg (args, int); + va_end (args); + } + + DarwinEQEnqueue(&xe); +} + + +/* + * DarwinModeProcessEvent * Process Quartz specific events. */ -void QuartzProcessEvent( +void DarwinModeProcessEvent( xEvent *xe) { switch (xe->u.u.type) { - case kXDarwinShow: + case kXDarwinActivate: QuartzShow(xe->u.keyButtonPointer.rootX, xe->u.keyButtonPointer.rootY); + AppleWMSendEvent(AppleWMActivationNotify, + AppleWMActivationNotifyMask, + AppleWMIsActive, 0); break; - case kXDarwinHide: + case kXDarwinDeactivate: + AppleWMSendEvent(AppleWMActivationNotify, + AppleWMActivationNotifyMask, + AppleWMIsInactive, 0); QuartzHide(); break; @@ -276,18 +303,42 @@ void QuartzProcessEvent( QuartzWritePasteboard(); break; + /* + * AppleWM events + */ + case kXDarwinControllerNotify: + AppleWMSendEvent(AppleWMControllerNotify, + AppleWMControllerNotifyMask, + xe->u.clientMessage.u.l.longs0, + xe->u.clientMessage.u.l.longs1); + break; + + case kXDarwinPasteboardNotify: + AppleWMSendEvent(AppleWMPasteboardNotify, + AppleWMPasteboardNotifyMask, + xe->u.clientMessage.u.l.longs0, + xe->u.clientMessage.u.l.longs1); + break; + + case kXDarwinDisplayChanged: + case kXDarwinWindowState: + case kXDarwinWindowMoved: + // FIXME: Not implemented yet + break; + default: - ErrorF("Unknown application defined event.\n"); + ErrorF("Unknown application defined event type %d.\n", + xe->u.u.type); } } /* - * QuartzGiveUp + * DarwinModeGiveUp * Cleanup before X server shutdown * Release the screen and restore the Aqua cursor. */ -void QuartzGiveUp(void) +void DarwinModeGiveUp(void) { #if 0 // Trying to switch cursors when quitting causes deadlock @@ -301,5 +352,5 @@ void QuartzGiveUp(void) #endif if (!quartzRootless) - QuartzFSRelease(); + quartzProcs->ReleaseScreens(); } diff --git a/hw/darwin/quartz/quartz.h b/hw/darwin/quartz/quartz.h index cd4f732f3..849e10cef 100644 --- a/hw/darwin/quartz/quartz.h +++ b/hw/darwin/quartz/quartz.h @@ -1,11 +1,11 @@ /* * quartz.h * - * External interface of the Quartz modes seen by the generic, mode + * External interface of the Quartz display modes seen by the generic, mode * independent parts of the Darwin X server. */ /* - * Copyright (c) 2001-2002 Greg Parker and Torrey T. Lyons. + * Copyright (c) 2001-2003 Greg Parker and Torrey T. Lyons. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -30,21 +30,88 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartz.h,v 1.4 2002/11/20 23:51:58 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartz.h,v 1.7 2003/11/12 20:21:51 torrey Exp $ */ #ifndef _QUARTZ_H #define _QUARTZ_H -#include "screenint.h" -#include "Xproto.h" #include "quartzPasteboard.h" -int QuartzProcessArgument(int argc, char *argv[], int i); -void QuartzInitOutput(int argc, char **argv); -void QuartzInitInput(int argc, char **argv); -Bool QuartzAddScreen(int index, ScreenPtr pScreen); -Bool QuartzSetupScreen(int index, ScreenPtr pScreen); -void QuartzGiveUp(void); -void QuartzProcessEvent(xEvent *xe); +#include "screenint.h" +#include "window.h" + +/*------------------------------------------ + Quartz display mode function types + ------------------------------------------*/ + +/* + * Display mode initialization + */ +typedef void (*DisplayInitProc)(void); +typedef Bool (*AddScreenProc)(int index, ScreenPtr pScreen); +typedef Bool (*SetupScreenProc)(int index, ScreenPtr pScreen); +typedef void (*InitInputProc)(int argc, char **argv); + +/* + * Cursor functions + */ +typedef Bool (*InitCursorProc)(ScreenPtr pScreen); +typedef void (*CursorUpdateProc)(void); + +/* + * Suspend and resume X11 activity + */ +typedef void (*SuspendScreenProc)(ScreenPtr pScreen); +typedef void (*ResumeScreenProc)(ScreenPtr pScreen, int x, int y); +typedef void (*CaptureScreensProc)(void); +typedef void (*ReleaseScreensProc)(void); + +/* + * Rootless helper functions + */ +typedef Bool (*IsX11WindowProc)(void *nsWindow, int windowNumber); + +/* + * Rootless functions for optional export to GLX layer + */ +typedef void * (*FrameForWindowProc)(WindowPtr pWin, Bool create); +typedef WindowPtr (*TopLevelParentProc)(WindowPtr pWindow); +typedef Bool (*CreateSurfaceProc) + (ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable, + unsigned int client_id, unsigned int *surface_id, + unsigned int key[2], void (*notify) (void *arg, void *data), + void *notify_data); +typedef Bool (*DestroySurfaceProc) + (ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable, + void (*notify) (void *arg, void *data), void *notify_data); + +/* + * Quartz display mode function list + */ +typedef struct _QuartzModeProcs { + DisplayInitProc DisplayInit; + AddScreenProc AddScreen; + SetupScreenProc SetupScreen; + InitInputProc InitInput; + + InitCursorProc InitCursor; + CursorUpdateProc CursorUpdate; // Not used if NULL + + SuspendScreenProc SuspendScreen; + ResumeScreenProc ResumeScreen; + CaptureScreensProc CaptureScreens; // Only called in fullscreen + ReleaseScreensProc ReleaseScreens; // Only called in fullscreen + + IsX11WindowProc IsX11Window; + + FrameForWindowProc FrameForWindow; + TopLevelParentProc TopLevelParent; + CreateSurfaceProc CreateSurface; + DestroySurfaceProc DestroySurface; +} QuartzModeProcsRec, *QuartzModeProcsPtr; + +extern QuartzModeProcsPtr quartzProcs; + +Bool QuartzLoadDisplayBundle(const char *dpyBundleName); #endif diff --git a/hw/darwin/quartz/quartzAudio.c b/hw/darwin/quartz/quartzAudio.c index 2dfb313b7..a3e6af127 100644 --- a/hw/darwin/quartz/quartzAudio.c +++ b/hw/darwin/quartz/quartzAudio.c @@ -35,7 +35,7 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzAudio.c,v 1.1 2002/03/28 02:21:18 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzAudio.c,v 1.2 2003/05/14 05:27:56 torrey Exp $ */ #include "quartzCommon.h" #include "quartzAudio.h" @@ -242,10 +242,10 @@ static void QuartzCoreAudioBell( /* - * QuartzBell + * DarwinModeBell * Ring the bell */ -void QuartzBell( +void DarwinModeBell( int volume, // volume in percent of max DeviceIntPtr pDevice, pointer ctrl, diff --git a/hw/darwin/quartz/quartzCocoa.m b/hw/darwin/quartz/quartzCocoa.m index d6d9bbe32..bba71c041 100644 --- a/hw/darwin/quartz/quartzCocoa.m +++ b/hw/darwin/quartz/quartzCocoa.m @@ -33,12 +33,17 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCocoa.m,v 1.3 2003/01/19 06:52:54 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCocoa.m,v 1.4 2003/05/14 05:27:56 torrey Exp $ */ + +#include "quartzCommon.h" + +#define BOOL xBOOL +#include "darwin.h" +#undef BOOL #include <Cocoa/Cocoa.h> #import "Preferences.h" -#include "quartzCommon.h" #include "pseudoramiX.h" extern void FatalError(const char *, ...); @@ -57,7 +62,7 @@ void QuartzReadPreferences(void) darwinFakeButtons = [Preferences fakeButtons]; darwinFakeMouse2Mask = [Preferences button2Mask]; darwinFakeMouse3Mask = [Preferences button3Mask]; - quartzMouseAccelChange = [Preferences mouseAccelChange]; + darwinMouseAccelChange = [Preferences mouseAccelChange]; quartzUseSysBeep = [Preferences systemBeep]; // quartzRootless has already been set diff --git a/hw/darwin/quartz/quartzCommon.h b/hw/darwin/quartz/quartzCommon.h index 6c375bd04..e3ae4b850 100644 --- a/hw/darwin/quartz/quartzCommon.h +++ b/hw/darwin/quartz/quartzCommon.h @@ -31,7 +31,7 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCommon.h,v 1.8 2003/01/23 00:34:26 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCommon.h,v 1.14 2003/11/12 20:21:51 torrey Exp $ */ #ifndef _QUARTZCOMMON_H #define _QUARTZCOMMON_H @@ -48,8 +48,6 @@ #undef WindowPtr #undef Picture -#include "quartzShared.h" - // Quartz specific per screen storage structure typedef struct { // List of CoreGraphics displays that this X11 screen covers. @@ -78,11 +76,17 @@ extern int quartzServerQuitting; extern int quartzScreenIndex; extern int aquaMenuBarHeight; +// Name of GLX bundle for native OpenGL +extern const char *quartzOpenGLBundle; + void QuartzReadPreferences(void); void QuartzMessageMainThread(unsigned msg, void *data, unsigned length); +void QuartzMessageServerThread(int type, int argc, ...); +void QuartzSetWindowMenu(int nitems, const char **items, + const char *shortcuts); void QuartzFSCapture(void); void QuartzFSRelease(void); -int QuartzFSUseQDCursor(int depth); +int QuartzFSUseQDCursor(int depth); void QuartzBlockHandler(void *blockData, void *pTimeout, void *pReadmask); void QuartzWakeupHandler(void *blockData, int result, void *pReadmask); @@ -92,7 +96,11 @@ enum { kQuartzServerStarted, kQuartzServerDied, kQuartzCursorUpdate, - kQuartzPostEvent + kQuartzPostEvent, + kQuartzSetWindowMenu, + kQuartzSetWindowMenuCheck, + kQuartzSetFrontProcess, + kQuartzSetCanQuit }; #endif /* _QUARTZCOMMON_H */ diff --git a/hw/darwin/quartz/quartzStartup.c b/hw/darwin/quartz/quartzStartup.c index dfa7b8166..bb7c7d214 100644 --- a/hw/darwin/quartz/quartzStartup.c +++ b/hw/darwin/quartz/quartzStartup.c @@ -28,13 +28,14 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzStartup.c,v 1.3 2003/01/19 06:35:13 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzStartup.c,v 1.9 2003/11/15 00:07:09 torrey Exp $ */ #include <fcntl.h> #include <unistd.h> #include <CoreFoundation/CoreFoundation.h> #include "quartzCommon.h" #include "darwin.h" +#include "quartz.h" #include "opaque.h" #include "micmap.h" @@ -50,6 +51,8 @@ static GlxExtensionInitPtr GlxExtensionInit = NULL; typedef void (*GlxWrapInitVisualsPtr)(miInitVisualsProcPtr *); static GlxWrapInitVisualsPtr GlxWrapInitVisuals = NULL; +typedef Bool (*QuartzModeBundleInitPtr)(void); + /* * DarwinHandleGUI @@ -76,19 +79,25 @@ void DarwinHandleGUI( // Make a pipe to pass events assert( pipe(fd) == 0 ); - darwinEventFD = fd[0]; - quartzEventWriteFD = fd[1]; - fcntl(darwinEventFD, F_SETFL, O_NONBLOCK); + darwinEventReadFD = fd[0]; + darwinEventWriteFD = fd[1]; + fcntl(darwinEventReadFD, F_SETFL, O_NONBLOCK); // Store command line arguments to pass back to main() argcGlobal = argc; argvGlobal = argv; envpGlobal = envp; - // Determine if we need to start X clients - // and what display mode to use quartzStartClients = 1; for (i = 1; i < argc; i++) { + // Display version info without starting Mac OS X UI if requested + if (!strcmp( argv[i], "-showconfig" ) || !strcmp( argv[i], "-version" )) { + DarwinPrintBanner(); + exit(0); + } + + // Determine if we need to start X clients + // and what display mode to use if (!strcmp(argv[i], "-nostartx")) { quartzStartClients = 0; } else if (!strcmp( argv[i], "-fullscreen")) { @@ -98,13 +107,70 @@ void DarwinHandleGUI( } } - quartz = TRUE; main_exit = NSApplicationMain(argc, argv); exit(main_exit); } /* + * QuartzLoadDisplayBundle + * Try to load the appropriate bundle containing the back end display code. + */ +Bool QuartzLoadDisplayBundle( + const char *dpyBundleName) +{ + CFBundleRef mainBundle; + CFStringRef bundleName; + CFURLRef bundleURL; + CFBundleRef dpyBundle; + QuartzModeBundleInitPtr bundleInit; + + // Get the main bundle for the application + mainBundle = CFBundleGetMainBundle(); + + // Make CFString from bundle name + bundleName = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, + dpyBundleName, + kCFStringEncodingASCII, + kCFAllocatorNull); + + // Look for the appropriate bundle in the main bundle + bundleURL = CFBundleCopyResourceURL(mainBundle, bundleName, + NULL, NULL); + if (!bundleURL) { + ErrorF("Could not find display mode bundle %s.\n", dpyBundleName); + return FALSE; + } + + // Make a bundle instance using the URLRef + dpyBundle = CFBundleCreate(kCFAllocatorDefault, bundleURL); + + if (!CFBundleLoadExecutable(dpyBundle)) { + ErrorF("Could not load display mode bundle %s.\n", dpyBundleName); + return FALSE; + } + + // Lookup the bundle initialization function + bundleInit = (void *) + CFBundleGetFunctionPointerForName(dpyBundle, + CFSTR("QuartzModeBundleInit")); + if (!bundleInit) { + ErrorF("Could not initialize display mode bundle %s.\n", + dpyBundleName); + return FALSE; + } + if (!bundleInit()) + return FALSE; + + // Release the CF objects + CFRelease(bundleName); + CFRelease(bundleURL); + + return TRUE; +} + + +/* * LoadGlxBundle * The Quartz mode X server needs to dynamically load the appropriate * bundle before initializing GLX. @@ -122,10 +188,14 @@ static void LoadGlxBundle(void) // Choose the bundle to load ErrorF("Loading GLX bundle "); if (quartzUseAGL) { - bundleName = CFSTR("glxAGL.bundle"); - ErrorF("glxAGL.bundle (using Apple's OpenGL)\n"); + bundleName = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, + quartzOpenGLBundle, + kCFStringEncodingASCII, + kCFAllocatorNull); + ErrorF("%s (using Apple's OpenGL)\n", quartzOpenGLBundle); } else { bundleName = CFSTR("glxMesa.bundle"); + CFRetain(bundleName); // so we can release later ErrorF("glxMesa.bundle (using Mesa)\n"); } @@ -155,7 +225,7 @@ static void LoadGlxBundle(void) } // Release the CF objects - CFRelease(mainBundle); + CFRelease(bundleName); CFRelease(bundleURL); } @@ -186,7 +256,7 @@ void DarwinGlxWrapInitVisuals( } -int QuartzProcessArgument( int argc, char *argv[], int i ) +int DarwinModeProcessArgument( int argc, char *argv[], int i ) { // fullscreen: CoreGraphics full-screen mode // rootless: Cocoa rootless mode @@ -208,7 +278,7 @@ int QuartzProcessArgument( int argc, char *argv[], int i ) QUARTZ_SAFETY_DELAY ); #endif return 1; - } + } if ( !strcmp( argv[i], "-quartz" ) ) { ErrorF( "Running in parallel with Mac OS X Quartz window server.\n" ); |