added hw/darwin/apple directory, which contains source and data files to build

a version of the X11.app shipped with Mac OS X, using the X.org server.
This commit is contained in:
Ben Byer 2007-02-26 17:06:53 -08:00
parent a16360733e
commit fa06e11f97
19 changed files with 4292 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,65 @@
8
dir
29110
svn+ssh://src.apple.com/svn/BSD/X11server/trunk/darwin/apple/English.lproj/main.nib
svn+ssh://src.apple.com/svn/BSD
2007-02-03T03:06:20.842932Z
28761
bbyer
svn:special svn:externals svn:needs-lock
e92bca22-270c-0410-9cea-e3f1106b6a1c
info.nib
file
2007-02-27T01:00:07.000000Z
456347804c516786b1d1339ce2ef50a2
2007-02-03T03:06:20.842932Z
28761
bbyer
keyedobjects.nib
file
2007-02-27T01:00:07.000000Z
eb3010372b09768c846df0d996cfdd8d
2007-02-03T03:06:20.842932Z
28761
bbyer
has-props
classes.nib
file
2007-02-27T01:00:07.000000Z
0ae2660c3afabbd5aa02fc34712c96e6
2007-02-03T03:06:20.842932Z
28761
bbyer

View File

@ -0,0 +1 @@
8

View File

@ -0,0 +1,5 @@
K 13
svn:mime-type
V 24
application/octet-stream
END

View File

@ -0,0 +1,318 @@
<?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>IBClasses</key>
<array>
<dict>
<key>CLASS</key>
<string>IBLibraryObjectTemplate</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>draggedView</key>
<string>NSView</string>
<key>representedObject</key>
<string>NSObject</string>
</dict>
<key>SUPERCLASS</key>
<string>NSView</string>
</dict>
<dict>
<key>CLASS</key>
<string>IBInspector</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>inspectorView</key>
<string>NSView</string>
</dict>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSDateFormatter</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSFormatter</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>apps_table_cancel</key>
<string>id</string>
<key>apps_table_delete</key>
<string>id</string>
<key>apps_table_done</key>
<string>id</string>
<key>apps_table_duplicate</key>
<string>id</string>
<key>apps_table_new</key>
<string>id</string>
<key>apps_table_show</key>
<string>id</string>
<key>bring_to_front</key>
<string>id</string>
<key>close_window</key>
<string>id</string>
<key>enable_fullscreen_changed</key>
<string>id</string>
<key>minimize_window</key>
<string>id</string>
<key>next_window</key>
<string>id</string>
<key>prefs_changed</key>
<string>id</string>
<key>prefs_show</key>
<string>id</string>
<key>previous_window</key>
<string>id</string>
<key>toggle_fullscreen</key>
<string>id</string>
<key>x11_help</key>
<string>id</string>
<key>zoom_window</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>X11Controller</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>apps_separator</key>
<string>id</string>
<key>apps_table</key>
<string>id</string>
<key>depth</key>
<string>id</string>
<key>dock_apps_menu</key>
<string>id</string>
<key>dock_menu</key>
<string>id</string>
<key>dock_window_separator</key>
<string>id</string>
<key>enable_auth</key>
<string>id</string>
<key>enable_fullscreen</key>
<string>id</string>
<key>enable_keyequivs</key>
<string>id</string>
<key>enable_tcp</key>
<string>id</string>
<key>fake_buttons</key>
<string>id</string>
<key>prefs_panel</key>
<string>id</string>
<key>sync_keymap</key>
<string>id</string>
<key>toggle_fullscreen_item</key>
<string>id</string>
<key>use_sysbeep</key>
<string>id</string>
<key>window_separator</key>
<string>id</string>
<key>x11_about_item</key>
<string>id</string>
</dict>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSNumberFormatter</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSFormatter</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSFormatter</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>alignCenter:</key>
<string>id</string>
<key>alignJustified:</key>
<string>id</string>
<key>alignLeft:</key>
<string>id</string>
<key>alignRight:</key>
<string>id</string>
<key>arrangeInFront:</key>
<string>id</string>
<key>centerSelectionInVisibleArea:</key>
<string>id</string>
<key>changeFont:</key>
<string>id</string>
<key>checkSpelling:</key>
<string>id</string>
<key>clear:</key>
<string>id</string>
<key>clearRecentDocuments:</key>
<string>id</string>
<key>complete:</key>
<string>id</string>
<key>copy:</key>
<string>id</string>
<key>copyFont:</key>
<string>id</string>
<key>copyRuler:</key>
<string>id</string>
<key>cut:</key>
<string>id</string>
<key>delete:</key>
<string>id</string>
<key>deminiaturize:</key>
<string>id</string>
<key>fax:</key>
<string>id</string>
<key>hide:</key>
<string>id</string>
<key>hideOtherApplications:</key>
<string>id</string>
<key>loosenKerning:</key>
<string>id</string>
<key>lowerBaseline:</key>
<string>id</string>
<key>makeKeyAndOrderFront:</key>
<string>id</string>
<key>miniaturize:</key>
<string>id</string>
<key>newDocument:</key>
<string>id</string>
<key>openDocument:</key>
<string>id</string>
<key>orderBack:</key>
<string>id</string>
<key>orderFront:</key>
<string>id</string>
<key>orderFrontColorPanel:</key>
<string>id</string>
<key>orderFrontHelpPanel:</key>
<string>id</string>
<key>orderOut:</key>
<string>id</string>
<key>outline:</key>
<string>id</string>
<key>paste:</key>
<string>id</string>
<key>pasteAsPlainText:</key>
<string>id</string>
<key>pasteAsRichText:</key>
<string>id</string>
<key>pasteFont:</key>
<string>id</string>
<key>pasteRuler:</key>
<string>id</string>
<key>pause:</key>
<string>id</string>
<key>performClose:</key>
<string>id</string>
<key>performFindPanelAction:</key>
<string>id</string>
<key>performMiniaturize:</key>
<string>id</string>
<key>performZoom:</key>
<string>id</string>
<key>play:</key>
<string>id</string>
<key>print:</key>
<string>id</string>
<key>printDocument:</key>
<string>id</string>
<key>raiseBaseline:</key>
<string>id</string>
<key>record:</key>
<string>id</string>
<key>redo:</key>
<string>id</string>
<key>resume:</key>
<string>id</string>
<key>revertDocumentToSaved:</key>
<string>id</string>
<key>run:</key>
<string>id</string>
<key>runPageLayout:</key>
<string>id</string>
<key>runToolbarCustomizationPalette:</key>
<string>id</string>
<key>saveAllDocuments:</key>
<string>id</string>
<key>saveDocument:</key>
<string>id</string>
<key>saveDocumentAs:</key>
<string>id</string>
<key>saveDocumentTo:</key>
<string>id</string>
<key>selectAll:</key>
<string>id</string>
<key>selectText:</key>
<string>id</string>
<key>showGuessPanel:</key>
<string>id</string>
<key>showHelp:</key>
<string>id</string>
<key>start:</key>
<string>id</string>
<key>startSpeaking:</key>
<string>id</string>
<key>stop:</key>
<string>id</string>
<key>stopSpeaking:</key>
<string>id</string>
<key>subscript:</key>
<string>id</string>
<key>superscript:</key>
<string>id</string>
<key>terminate:</key>
<string>id</string>
<key>tightenKerning:</key>
<string>id</string>
<key>toggleContinuousSpellChecking:</key>
<string>id</string>
<key>toggleRuler:</key>
<string>id</string>
<key>toggleToolbarShown:</key>
<string>id</string>
<key>turnOffKerning:</key>
<string>id</string>
<key>turnOffLigatures:</key>
<string>id</string>
<key>underline:</key>
<string>id</string>
<key>undo:</key>
<string>id</string>
<key>unhideAllApplications:</key>
<string>id</string>
<key>unscript:</key>
<string>id</string>
<key>useAllLigatures:</key>
<string>id</string>
<key>useStandardKerning:</key>
<string>id</string>
<key>useStandardLigatures:</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>FirstResponder</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
</array>
<key>IBVersion</key>
<integer>1</integer>
</dict>
</plist>

View File

@ -0,0 +1,18 @@
<?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>IBFramework Version</key>
<string>588</string>
<key>IBOpenObjects</key>
<array>
<integer>244</integer>
<integer>29</integer>
<integer>423</integer>
</array>
<key>IBSystem Version</key>
<string>9A356</string>
<key>targetFramework</key>
<string>IBCocoaFramework</string>
</dict>
</plist>

View File

@ -0,0 +1,318 @@
<?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>IBClasses</key>
<array>
<dict>
<key>CLASS</key>
<string>IBLibraryObjectTemplate</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>draggedView</key>
<string>NSView</string>
<key>representedObject</key>
<string>NSObject</string>
</dict>
<key>SUPERCLASS</key>
<string>NSView</string>
</dict>
<dict>
<key>CLASS</key>
<string>IBInspector</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>inspectorView</key>
<string>NSView</string>
</dict>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSDateFormatter</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSFormatter</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>apps_table_cancel</key>
<string>id</string>
<key>apps_table_delete</key>
<string>id</string>
<key>apps_table_done</key>
<string>id</string>
<key>apps_table_duplicate</key>
<string>id</string>
<key>apps_table_new</key>
<string>id</string>
<key>apps_table_show</key>
<string>id</string>
<key>bring_to_front</key>
<string>id</string>
<key>close_window</key>
<string>id</string>
<key>enable_fullscreen_changed</key>
<string>id</string>
<key>minimize_window</key>
<string>id</string>
<key>next_window</key>
<string>id</string>
<key>prefs_changed</key>
<string>id</string>
<key>prefs_show</key>
<string>id</string>
<key>previous_window</key>
<string>id</string>
<key>toggle_fullscreen</key>
<string>id</string>
<key>x11_help</key>
<string>id</string>
<key>zoom_window</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>X11Controller</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>apps_separator</key>
<string>id</string>
<key>apps_table</key>
<string>id</string>
<key>depth</key>
<string>id</string>
<key>dock_apps_menu</key>
<string>id</string>
<key>dock_menu</key>
<string>id</string>
<key>dock_window_separator</key>
<string>id</string>
<key>enable_auth</key>
<string>id</string>
<key>enable_fullscreen</key>
<string>id</string>
<key>enable_keyequivs</key>
<string>id</string>
<key>enable_tcp</key>
<string>id</string>
<key>fake_buttons</key>
<string>id</string>
<key>prefs_panel</key>
<string>id</string>
<key>sync_keymap</key>
<string>id</string>
<key>toggle_fullscreen_item</key>
<string>id</string>
<key>use_sysbeep</key>
<string>id</string>
<key>window_separator</key>
<string>id</string>
<key>x11_about_item</key>
<string>id</string>
</dict>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSNumberFormatter</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSFormatter</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSFormatter</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>alignCenter:</key>
<string>id</string>
<key>alignJustified:</key>
<string>id</string>
<key>alignLeft:</key>
<string>id</string>
<key>alignRight:</key>
<string>id</string>
<key>arrangeInFront:</key>
<string>id</string>
<key>centerSelectionInVisibleArea:</key>
<string>id</string>
<key>changeFont:</key>
<string>id</string>
<key>checkSpelling:</key>
<string>id</string>
<key>clear:</key>
<string>id</string>
<key>clearRecentDocuments:</key>
<string>id</string>
<key>complete:</key>
<string>id</string>
<key>copy:</key>
<string>id</string>
<key>copyFont:</key>
<string>id</string>
<key>copyRuler:</key>
<string>id</string>
<key>cut:</key>
<string>id</string>
<key>delete:</key>
<string>id</string>
<key>deminiaturize:</key>
<string>id</string>
<key>fax:</key>
<string>id</string>
<key>hide:</key>
<string>id</string>
<key>hideOtherApplications:</key>
<string>id</string>
<key>loosenKerning:</key>
<string>id</string>
<key>lowerBaseline:</key>
<string>id</string>
<key>makeKeyAndOrderFront:</key>
<string>id</string>
<key>miniaturize:</key>
<string>id</string>
<key>newDocument:</key>
<string>id</string>
<key>openDocument:</key>
<string>id</string>
<key>orderBack:</key>
<string>id</string>
<key>orderFront:</key>
<string>id</string>
<key>orderFrontColorPanel:</key>
<string>id</string>
<key>orderFrontHelpPanel:</key>
<string>id</string>
<key>orderOut:</key>
<string>id</string>
<key>outline:</key>
<string>id</string>
<key>paste:</key>
<string>id</string>
<key>pasteAsPlainText:</key>
<string>id</string>
<key>pasteAsRichText:</key>
<string>id</string>
<key>pasteFont:</key>
<string>id</string>
<key>pasteRuler:</key>
<string>id</string>
<key>pause:</key>
<string>id</string>
<key>performClose:</key>
<string>id</string>
<key>performFindPanelAction:</key>
<string>id</string>
<key>performMiniaturize:</key>
<string>id</string>
<key>performZoom:</key>
<string>id</string>
<key>play:</key>
<string>id</string>
<key>print:</key>
<string>id</string>
<key>printDocument:</key>
<string>id</string>
<key>raiseBaseline:</key>
<string>id</string>
<key>record:</key>
<string>id</string>
<key>redo:</key>
<string>id</string>
<key>resume:</key>
<string>id</string>
<key>revertDocumentToSaved:</key>
<string>id</string>
<key>run:</key>
<string>id</string>
<key>runPageLayout:</key>
<string>id</string>
<key>runToolbarCustomizationPalette:</key>
<string>id</string>
<key>saveAllDocuments:</key>
<string>id</string>
<key>saveDocument:</key>
<string>id</string>
<key>saveDocumentAs:</key>
<string>id</string>
<key>saveDocumentTo:</key>
<string>id</string>
<key>selectAll:</key>
<string>id</string>
<key>selectText:</key>
<string>id</string>
<key>showGuessPanel:</key>
<string>id</string>
<key>showHelp:</key>
<string>id</string>
<key>start:</key>
<string>id</string>
<key>startSpeaking:</key>
<string>id</string>
<key>stop:</key>
<string>id</string>
<key>stopSpeaking:</key>
<string>id</string>
<key>subscript:</key>
<string>id</string>
<key>superscript:</key>
<string>id</string>
<key>terminate:</key>
<string>id</string>
<key>tightenKerning:</key>
<string>id</string>
<key>toggleContinuousSpellChecking:</key>
<string>id</string>
<key>toggleRuler:</key>
<string>id</string>
<key>toggleToolbarShown:</key>
<string>id</string>
<key>turnOffKerning:</key>
<string>id</string>
<key>turnOffLigatures:</key>
<string>id</string>
<key>underline:</key>
<string>id</string>
<key>undo:</key>
<string>id</string>
<key>unhideAllApplications:</key>
<string>id</string>
<key>unscript:</key>
<string>id</string>
<key>useAllLigatures:</key>
<string>id</string>
<key>useStandardKerning:</key>
<string>id</string>
<key>useStandardLigatures:</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>FirstResponder</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
</array>
<key>IBVersion</key>
<integer>1</integer>
</dict>
</plist>

View File

@ -0,0 +1,18 @@
<?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>IBFramework Version</key>
<string>588</string>
<key>IBOpenObjects</key>
<array>
<integer>244</integer>
<integer>29</integer>
<integer>423</integer>
</array>
<key>IBSystem Version</key>
<string>9A356</string>
<key>targetFramework</key>
<string>IBCocoaFramework</string>
</dict>
</plist>

Binary file not shown.

View File

@ -0,0 +1,71 @@
<?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>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>x11app</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>X11.icns</string>
<key>CFBundleTypeName</key>
<string>X11 Application</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>****</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSIsAppleDefaultForType</key>
<true/>
</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>X11</string>
<key>CFBundleGetInfoString</key>
<string>X11</string>
<key>CFBundleIconFile</key>
<string>X11.icns</string>
<key>CFBundleIdentifier</key>
<string>org.x.X11</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>X11</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2003-2007, Apple Inc.
Copyright © 2003, XFree86 Project, Inc.</string>
<key>NSMainNibFile</key>
<string>main</string>
<key>NSPrincipalClass</key>
<string>X11Application</string>
</dict>
</plist>

BIN
hw/darwin/apple/X11.icns Normal file

Binary file not shown.

View File

@ -0,0 +1,329 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 42;
objects = {
/* Begin PBXBuildFile section */
527F24190B5D938C007840A7 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */; };
527F241A0B5D938C007840A7 /* main.nib in Resources */ = {isa = PBXBuildFile; fileRef = 02345980000FD03B11CA0E72 /* main.nib */; };
527F241B0B5D938C007840A7 /* X11.icns in Resources */ = {isa = PBXBuildFile; fileRef = 50459C5F038587C60ECA21EC /* X11.icns */; };
527F241D0B5D938C007840A7 /* bundle-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 50EE2AB703849F0B0ECA21EC /* bundle-main.c */; };
527F241F0B5D938C007840A7 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */; };
527F24200B5D938C007840A7 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 570C5748047186C400ACF82F /* SystemConfiguration.framework */; };
527F24370B5D9D89007840A7 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 527F24260B5D938C007840A7 /* Info.plist */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
0867D6ABFE840B52C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
1870340FFE93FCAF11CA0CD7 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/main.nib; sourceTree = "<group>"; };
50459C5F038587C60ECA21EC /* X11.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = X11.icns; sourceTree = "<group>"; };
50EE2AB703849F0B0ECA21EC /* bundle-main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = "bundle-main.c"; sourceTree = "<group>"; };
50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
527F24260B5D938C007840A7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Info.plist; sourceTree = "<group>"; };
527F24270B5D938C007840A7 /* X11.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = X11.app; sourceTree = BUILT_PRODUCTS_DIR; };
570C5748047186C400ACF82F /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = /System/Library/Frameworks/SystemConfiguration.framework; sourceTree = "<absolute>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
527F241E0B5D938C007840A7 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
527F241F0B5D938C007840A7 /* CoreFoundation.framework in Frameworks */,
527F24200B5D938C007840A7 /* SystemConfiguration.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
195DF8CFFE9D517E11CA2CBB /* Products */ = {
isa = PBXGroup;
children = (
527F24270B5D938C007840A7 /* X11.app */,
);
name = Products;
sourceTree = "<group>";
};
20286C29FDCF999611CA2CEA /* X11 */ = {
isa = PBXGroup;
children = (
20286C2AFDCF999611CA2CEA /* Sources */,
20286C2CFDCF999611CA2CEA /* Resources */,
20286C32FDCF999611CA2CEA /* External Frameworks and Libraries */,
195DF8CFFE9D517E11CA2CBB /* Products */,
527F24260B5D938C007840A7 /* Info.plist */,
);
name = X11;
sourceTree = "<group>";
};
20286C2AFDCF999611CA2CEA /* Sources */ = {
isa = PBXGroup;
children = (
50EE2AB703849F0B0ECA21EC /* bundle-main.c */,
);
name = Sources;
sourceTree = "<group>";
};
20286C2CFDCF999611CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
50459C5F038587C60ECA21EC /* X11.icns */,
0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */,
02345980000FD03B11CA0E72 /* main.nib */,
);
name = Resources;
sourceTree = "<group>";
};
20286C32FDCF999611CA2CEA /* External Frameworks and Libraries */ = {
isa = PBXGroup;
children = (
50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */,
570C5748047186C400ACF82F /* SystemConfiguration.framework */,
);
name = "External Frameworks and Libraries";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
527F24170B5D938C007840A7 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
527F24160B5D938C007840A7 /* X11 */ = {
isa = PBXNativeTarget;
buildConfigurationList = 527F24220B5D938C007840A7 /* Build configuration list for PBXNativeTarget "X11" */;
buildPhases = (
527F24170B5D938C007840A7 /* Headers */,
527F24180B5D938C007840A7 /* Resources */,
527F241C0B5D938C007840A7 /* Sources */,
527F241E0B5D938C007840A7 /* Frameworks */,
527F24210B5D938C007840A7 /* Rez */,
);
buildRules = (
);
dependencies = (
);
name = X11;
productName = X11;
productReference = 527F24270B5D938C007840A7 /* X11.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
20286C28FDCF999611CA2CEA /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 527F24080B5D8FFC007840A7 /* Build configuration list for PBXProject "X11" */;
compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
mainGroup = 20286C29FDCF999611CA2CEA /* X11 */;
projectDirPath = "";
projectRoot = "";
shouldCheckCompatibility = 1;
targets = (
527F24160B5D938C007840A7 /* X11 */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
527F24180B5D938C007840A7 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
527F24370B5D9D89007840A7 /* Info.plist in Resources */,
527F24190B5D938C007840A7 /* InfoPlist.strings in Resources */,
527F241A0B5D938C007840A7 /* main.nib in Resources */,
527F241B0B5D938C007840A7 /* X11.icns in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXRezBuildPhase section */
527F24210B5D938C007840A7 /* Rez */ = {
isa = PBXRezBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXRezBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
527F241C0B5D938C007840A7 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
527F241D0B5D938C007840A7 /* bundle-main.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
02345980000FD03B11CA0E72 /* main.nib */ = {
isa = PBXVariantGroup;
children = (
1870340FFE93FCAF11CA0CD7 /* English */,
);
name = main.nib;
sourceTree = "<group>";
};
0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
0867D6ABFE840B52C02AAC07 /* English */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
527F24090B5D8FFC007840A7 /* Development */ = {
isa = XCBuildConfiguration;
buildSettings = {
DSTROOT = "$(DSTROOT)";
SKIP_INSTALL = YES;
};
name = Development;
};
527F240A0B5D8FFC007840A7 /* Deployment */ = {
isa = XCBuildConfiguration;
buildSettings = {
DSTROOT = "$(DSTROOT)";
SKIP_INSTALL = YES;
};
name = Deployment;
};
527F240B0B5D8FFC007840A7 /* Default */ = {
isa = XCBuildConfiguration;
buildSettings = {
DSTROOT = "$(DSTROOT)";
SKIP_INSTALL = YES;
};
name = Default;
};
527F24230B5D938C007840A7 /* Development */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(NATIVE_ARCH_32_BIT)";
COPY_PHASE_STRIP = NO;
DSTROOT = "$(DSTROOT)";
FRAMEWORK_SEARCH_PATHS = "";
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
HEADER_SEARCH_PATHS = /usr/X11/include;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = $DSTROOT/Applications/Utilties;
LIBRARY_SEARCH_PATHS = /usr/X11/lib;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = (
"-lXau",
"-lX11",
);
OTHER_REZFLAGS = "";
PRODUCT_NAME = X11;
SECTORDER_FLAGS = "";
WARNING_CFLAGS = (
"-Wmost",
"-Wno-four-char-constants",
"-Wno-unknown-pragmas",
);
WRAPPER_EXTENSION = app;
};
name = Development;
};
527F24240B5D938C007840A7 /* Deployment */ = {
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = YES;
DSTROOT = "$(DSTROOT)";
FRAMEWORK_SEARCH_PATHS = "";
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
HEADER_SEARCH_PATHS = /usr/X11/include;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = $DSTROOT/Applications/Utilties;
LIBRARY_SEARCH_PATHS = /usr/X11/lib;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = (
"-lXau",
"-lX11",
);
OTHER_REZFLAGS = "";
PRODUCT_NAME = X11;
SECTORDER_FLAGS = "";
WARNING_CFLAGS = (
"-Wmost",
"-Wno-four-char-constants",
"-Wno-unknown-pragmas",
);
WRAPPER_EXTENSION = app;
};
name = Deployment;
};
527F24250B5D938C007840A7 /* Default */ = {
isa = XCBuildConfiguration;
buildSettings = {
DSTROOT = "$(DSTROOT)";
FRAMEWORK_SEARCH_PATHS = "";
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
HEADER_SEARCH_PATHS = /usr/X11/include;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = $DSTROOT/Applications/Utilties;
LIBRARY_SEARCH_PATHS = /usr/X11/lib;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = (
"-lXau",
"-lX11",
);
OTHER_REZFLAGS = "";
PRODUCT_NAME = X11;
SECTORDER_FLAGS = "";
WARNING_CFLAGS = (
"-Wmost",
"-Wno-four-char-constants",
"-Wno-unknown-pragmas",
);
WRAPPER_EXTENSION = app;
};
name = Default;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
527F24080B5D8FFC007840A7 /* Build configuration list for PBXProject "X11" */ = {
isa = XCConfigurationList;
buildConfigurations = (
527F24090B5D8FFC007840A7 /* Development */,
527F240A0B5D8FFC007840A7 /* Deployment */,
527F240B0B5D8FFC007840A7 /* Default */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Default;
};
527F24220B5D938C007840A7 /* Build configuration list for PBXNativeTarget "X11" */ = {
isa = XCConfigurationList;
buildConfigurations = (
527F24230B5D938C007840A7 /* Development */,
527F24240B5D938C007840A7 /* Deployment */,
527F24250B5D938C007840A7 /* Default */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Default;
};
/* End XCConfigurationList section */
};
rootObject = 20286C28FDCF999611CA2CEA /* Project object */;
}

View File

@ -0,0 +1,104 @@
/* X11Application.h -- subclass of NSApplication to multiplex events
$Id: X11Application.h,v 1.26 2003/08/08 19:16:13 jharper Exp $
Copyright (c) 2002-2007 Apple Inc. 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. */
#ifndef X11APPLICATION_H
#define X11APPLICATION_H 1
#if __OBJC__
#import <Cocoa/Cocoa.h>
#import "X11Controller.h"
@interface X11Application : NSApplication {
X11Controller *_controller;
unsigned int _x_active :1;
}
- (void) set_controller:controller;
- (void) set_window_menu:(NSArray *)list;
- (int) prefs_get_integer:(NSString *)key default:(int)def;
- (const char *) prefs_get_string:(NSString *)key default:(const char *)def;
- (float) prefs_get_float:(NSString *)key default:(float)def;
- (int) prefs_get_boolean:(NSString *)key default:(int)def;
- (NSArray *) prefs_get_array:(NSString *)key;
- (void) prefs_set_integer:(NSString *)key value:(int)value;
- (void) prefs_set_float:(NSString *)key value:(float)value;
- (void) prefs_set_boolean:(NSString *)key value:(int)value;
- (void) prefs_set_array:(NSString *)key value:(NSArray *)value;
- (void) prefs_set_string:(NSString *)key value:(NSString *)value;
- (void) prefs_synchronize;
- (BOOL) x_active;
@end
extern X11Application *X11App;
#endif /* __OBJC__ */
extern void X11ApplicationSetWindowMenu (int nitems, const char **items,
const char *shortcuts);
extern void X11ApplicationSetWindowMenuCheck (int idx);
extern void X11ApplicationSetFrontProcess (void);
extern void X11ApplicationSetCanQuit (int state);
extern void X11ApplicationServerReady (void);
extern void X11ApplicationShowHideMenubar (int state);
extern void X11ApplicationMain (int argc, const char *argv[],
void (*server_thread) (void *),
void *server_arg);
extern int X11EnableKeyEquivalents;
extern int quartzHasRoot, quartzEnableRootless;
#define APP_PREFS "com.apple.x11"
#define PREFS_APPSMENU "apps_menu"
#define PREFS_FAKEBUTTONS "enable_fake_buttons"
#define PREFS_SYSBEEP "enable_system_beep"
#define PREFS_KEYEQUIVS "enable_key_equivalents"
#define PREFS_KEYMAP_FILE "keymap_file"
#define PREFS_SYNC_KEYMAP "sync_keymap"
#define PREFS_DEPTH "depth"
#define PREFS_NO_AUTH "no_auth"
#define PREFS_NO_TCP "nolisten_tcp"
#define PREFS_DONE_XINIT_CHECK "done_xinit_check"
#define PREFS_NO_QUIT_ALERT "no_quit_alert"
#define PREFS_FAKE_BUTTON2 "fake_button2"
#define PREFS_FAKE_BUTTON3 "fake_button3"
#define PREFS_ROOTLESS "rootless"
#define PREFS_FULLSCREEN_HOTKEYS "fullscreen_hotkeys"
#define PREFS_SWAP_ALT_META "swap_alt_meta"
#define PREFS_XP_OPTIONS "xp_options"
#define PREFS_ENABLE_STEREO "enable_stereo"
#endif /* X11APPLICATION_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,86 @@
/* X11Controller.h -- connect the IB ui
$Id: X11Controller.h,v 1.21 2003/07/24 17:52:29 jharper Exp $
Copyright (c) 2002 Apple Computer, Inc. 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. */
#ifndef X11CONTROLLER_H
#define X11CONTROLLER_H 1
#if __OBJC__
#import <Cocoa/Cocoa.h>
#include "../quartz/xpr/x-list.h"
@interface X11Controller : NSObject
{
NSPanel *prefs_panel;
NSButton *fake_buttons;
NSButton *enable_fullscreen;
NSButton *use_sysbeep;
NSButton *enable_keyequivs;
NSButton *sync_keymap;
NSButton *enable_auth;
NSButton *enable_tcp;
NSPopUpButton *depth;
NSMenuItem *x11_about_item;
NSMenuItem *window_separator;
NSMenuItem *dock_window_separator;
NSMenuItem *apps_separator;
NSMenuItem *toggle_fullscreen_item;
NSMenu *dock_apps_menu;
NSTableView *apps_table;
NSArray *apps;
NSMutableArray *table_apps;
NSMenu *dock_menu;
int checked_window_item;
x_list *pending_apps;
BOOL finished_launching;
BOOL can_quit;
}
- (void) set_window_menu:(NSArray *)list;
- (void) set_window_menu_check:(NSNumber *)n;
- (void) set_apps_menu:(NSArray *)list;
- (void) set_can_quit:(BOOL)state;
- (void) server_ready;
@end
#endif /* __OBJC__ */
extern void X11ControllerMain (int argc, const char *argv[],
void (*server_thread) (void *),
void *server_arg);
#endif /* X11CONTROLLER_H */

View File

@ -0,0 +1,752 @@
/* X11Controller.m -- connect the IB ui, also the NSApp delegate
$Id: X11Controller.m,v 1.40 2006/09/06 21:19:32 jharper Exp $
Copyright (c) 2002-2007 Apple Inc. 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. */
#define DEFAULT_PATH "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11/bin"
#include "../quartz/quartzCommon.h"
#import "X11Controller.h"
#import "X11Application.h"
#import <Carbon/Carbon.h>
/* ouch! */
#define BOOL X_BOOL
//# include "Xproto.h"
#include "opaque.h"
# include "darwin.h"
# include "../quartz/quartz.h"
# define _APPLEWM_SERVER_
# include "X11/extensions/applewm.h"
# include "../quartz/applewmExt.h"
//# include "X.h"
#undef BOOL
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/wait.h>
#define TRACE() fprintf (stderr, "%s\n", __FUNCTION__)
@implementation X11Controller
- (void) awakeFromNib
{
X11Application *xapp = NSApp;
NSArray *array;
/* Point X11Application at ourself. */
[xapp set_controller:self];
array = [xapp prefs_get_array:@PREFS_APPSMENU];
if (array != nil)
{
int count;
/* convert from [TITLE1 COMMAND1 TITLE2 COMMAND2 ...]
to [[TITLE1 COMMAND1] [TITLE2 COMMAND2] ...] format. */
count = [array count];
if (count > 0
&& ![[array objectAtIndex:0] isKindOfClass:[NSArray class]])
{
int i;
NSMutableArray *copy, *sub;
copy = [NSMutableArray arrayWithCapacity:(count / 2)];
for (i = 0; i < count / 2; i++)
{
sub = [[NSMutableArray alloc] initWithCapacity:3];
[sub addObject:[array objectAtIndex:i*2]];
[sub addObject:[array objectAtIndex:i*2+1]];
[sub addObject:@""];
[copy addObject:sub];
[sub release];
}
array = copy;
}
[self set_apps_menu:array];
}
}
- (void) item_selected:sender
{
[NSApp activateIgnoringOtherApps:YES];
QuartzMessageServerThread (kXDarwinControllerNotify, 2,
AppleWMWindowMenuItem, [sender tag]);
}
- (void) remove_window_menu
{
NSMenu *menu;
int first, count, i;
/* Work backwards so we don't mess up the indices */
menu = [window_separator menu];
first = [menu indexOfItem:window_separator] + 1;
count = [menu numberOfItems];
for (i = count - 1; i >= first; i--)
[menu removeItemAtIndex:i];
menu = [dock_window_separator menu];
count = [menu indexOfItem:dock_window_separator];
for (i = 0; i < count; i++)
[dock_menu removeItemAtIndex:0];
}
- (void) install_window_menu:(NSArray *)list
{
NSMenu *menu;
NSMenuItem *item;
int first, count, i;
menu = [window_separator menu];
first = [menu indexOfItem:window_separator] + 1;
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 *) [menu addItemWithTitle:name action:@selector
(item_selected:) keyEquivalent:shortcut];
[item setTarget:self];
[item setTag:i];
[item setEnabled:YES];
item = (NSMenuItem *) [dock_menu insertItemWithTitle:name
action:@selector
(item_selected:) keyEquivalent:shortcut
atIndex:i];
[item setTarget:self];
[item setTag:i];
[item setEnabled:YES];
}
if (checked_window_item >= 0 && checked_window_item < count)
{
item = (NSMenuItem *) [menu itemAtIndex:first + checked_window_item];
[item setState:NSOnState];
item = (NSMenuItem *) [dock_menu itemAtIndex:checked_window_item];
[item setState:NSOnState];
}
}
- (void) remove_apps_menu
{
NSMenu *menu;
NSMenuItem *item;
int i;
if (apps == nil || apps_separator == nil) return;
menu = [apps_separator menu];
if (menu != nil)
{
for (i = [menu numberOfItems] - 1; i >= 0; i--)
{
item = (NSMenuItem *) [menu itemAtIndex:i];
if ([item tag] != 0)
[menu removeItemAtIndex:i];
}
}
if (dock_apps_menu != nil)
{
for (i = [dock_apps_menu numberOfItems] - 1; i >= 0; i--)
{
item = (NSMenuItem *) [dock_apps_menu itemAtIndex:i];
if ([item tag] != 0)
[dock_apps_menu removeItemAtIndex:i];
}
}
[apps release];
apps = nil;
}
- (void) prepend_apps_item:(NSArray *)list index:(int)i menu:(NSMenu *)menu
{
NSString *title, *shortcut = @"";
NSArray *group;
NSMenuItem *item;
group = [list objectAtIndex:i];
title = [group objectAtIndex:0];
if ([group count] >= 3)
shortcut = [group objectAtIndex:2];
if ([title length] != 0)
{
item = (NSMenuItem *) [menu insertItemWithTitle:title
action:@selector (app_selected:)
keyEquivalent:shortcut atIndex:0];
[item setTarget:self];
[item setEnabled:YES];
}
else
{
item = (NSMenuItem *) [NSMenuItem separatorItem];
[menu insertItem:item atIndex:0];
}
[item setTag:i+1]; /* can't be zero, so add one */
}
- (void) install_apps_menu:(NSArray *)list
{
NSMenu *menu;
int i, count;
count = [list count];
if (count == 0 || apps_separator == nil) return;
menu = [apps_separator menu];
for (i = count - 1; i >= 0; i--)
{
if (menu != nil)
[self prepend_apps_item:list index:i menu:menu];
if (dock_apps_menu != nil)
[self prepend_apps_item:list index:i menu:dock_apps_menu];
}
apps = [list retain];
}
- (void) set_window_menu:(NSArray *)list
{
[self remove_window_menu];
[self install_window_menu:list];
QuartzMessageServerThread (kXDarwinControllerNotify, 1,
AppleWMWindowMenuNotify);
}
- (void) set_window_menu_check:(NSNumber *)nn
{
NSMenu *menu;
NSMenuItem *item;
int first, count;
int n = [nn intValue];
menu = [window_separator menu];
first = [menu indexOfItem:window_separator] + 1;
count = [menu numberOfItems] - first;
if (checked_window_item >= 0 && checked_window_item < count)
{
item = (NSMenuItem *) [menu itemAtIndex:first + checked_window_item];
[item setState:NSOffState];
item = (NSMenuItem *) [dock_menu itemAtIndex:checked_window_item];
[item setState:NSOffState];
}
if (n >= 0 && n < count)
{
item = (NSMenuItem *) [menu itemAtIndex:first + n];
[item setState:NSOnState];
item = (NSMenuItem *) [dock_menu itemAtIndex:n];
[item setState:NSOnState];
}
checked_window_item = n;
}
- (void) set_apps_menu:(NSArray *)list
{
[self remove_apps_menu];
[self install_apps_menu:list];
}
- (void) launch_client:(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";
argv[0] = shell;
argv[1] = "-l";
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], *temp;
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);
/* Setup environment */
temp = getenv("DISPLAY");
if (temp == NULL || temp[0] == 0) {
snprintf(buf, sizeof(buf), ":%s", display);
setenv("DISPLAY", buf, TRUE);
}
temp = getenv("PATH");
if (temp == NULL || temp[0] == 0)
setenv ("PATH", DEFAULT_PATH, TRUE);
else if (strnstr(temp, "/usr/X11/bin", sizeof(temp)) == NULL) {
snprintf(buf, sizeof(buf), "%s:/usr/X11/bin", temp);
setenv("PATH", buf, TRUE);
}
/* cd $HOME */
temp = getenv("HOME");
if (temp != NULL && temp[0]!=0) chdir(temp);
execvp(argv[0], (char **const) argv);
_exit(2);
default: /* parent (child1) */
_exit(0);
}
break;
default: /* parent */
waitpid(child1, &status, 0);
}
}
- (void) app_selected:sender
{
int tag;
NSString *item;
tag = [sender tag] - 1;
if (apps == nil || tag < 0 || tag >= [apps count])
return;
item = [[apps objectAtIndex:tag] objectAtIndex:1];
[self launch_client:item];
}
- (IBAction) apps_table_show:sender
{
NSArray *columns;
if (table_apps == nil) {
table_apps = [[NSMutableArray alloc] initWithCapacity:1];
if (apps != nil)[table_apps addObjectsFromArray:apps];
}
columns = [apps_table tableColumns];
[[columns objectAtIndex:0] setIdentifier:@"0"];
[[columns objectAtIndex:1] setIdentifier:@"1"];
[[columns objectAtIndex:2] setIdentifier:@"2"];
[apps_table setDataSource:self];
[apps_table selectRow:0 byExtendingSelection:NO];
[[apps_table window] makeKeyAndOrderFront:sender];
}
- (IBAction) apps_table_cancel:sender
{
[[apps_table window] orderOut:sender];
[apps_table reloadData];
[table_apps release];
table_apps = nil;
}
- (IBAction) apps_table_done:sender
{
[apps_table deselectAll:sender]; /* flush edits? */
[self remove_apps_menu];
[self install_apps_menu:table_apps];
[NSApp prefs_set_array:@PREFS_APPSMENU value:table_apps];
[NSApp prefs_synchronize];
[[apps_table window] orderOut:sender];
[table_apps release];
table_apps = nil;
}
- (IBAction) apps_table_new:sender
{
NSMutableArray *item;
int row = [apps_table selectedRow], i;
if (row < 0) row = 0;
else row = row + 1;
i = row;
if (i > [table_apps count])
return; /* avoid exceptions */
[apps_table deselectAll:sender];
item = [[NSMutableArray alloc] initWithCapacity:3];
[item addObject:@""];
[item addObject:@""];
[item addObject:@""];
[table_apps insertObject:item atIndex:i];
[item release];
[apps_table reloadData];
[apps_table selectRow:row byExtendingSelection:NO];
}
- (IBAction) apps_table_duplicate:sender
{
int row = [apps_table selectedRow], i;
NSObject *item;
if (row < 0) {
[self apps_table_new:sender];
return;
}
i = row;
if (i > [table_apps count] - 1) return; /* avoid exceptions */
[apps_table deselectAll:sender];
item = [[table_apps objectAtIndex:i] mutableCopy];
[table_apps insertObject:item atIndex:i];
[item release];
[apps_table reloadData];
[apps_table selectRow:row+1 byExtendingSelection:NO];
}
- (IBAction) apps_table_delete:sender
{
int row = [apps_table selectedRow];
if (row >= 0)
{
int i = row;
if (i > [table_apps count] - 1) return; /* avoid exceptions */
[apps_table deselectAll:sender];
[table_apps removeObjectAtIndex:i];
}
[apps_table reloadData];
row = MIN (row, [table_apps count] - 1);
if (row >= 0)
[apps_table selectRow:row byExtendingSelection:NO];
}
- (int) numberOfRowsInTableView:(NSTableView *)tableView
{
if (table_apps == nil) return 0;
return [table_apps count];
}
- (id) tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
{
NSArray *item;
int col;
if (table_apps == nil) return nil;
col = [[tableColumn identifier] intValue];
item = [table_apps objectAtIndex:row];
if ([item count] > col)
return [item objectAtIndex:col];
else
return @"";
}
- (void) tableView:(NSTableView *)tableView setObjectValue:(id)object
forTableColumn:(NSTableColumn *)tableColumn row:(int)row
{
NSMutableArray *item;
int col;
if (table_apps == nil) return;
col = [[tableColumn identifier] intValue];
item = [table_apps objectAtIndex:row];
[item replaceObjectAtIndex:col withObject:object];
}
- (void) hide_window:sender
{
if ([X11App x_active])
QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMHideWindow);
else
NSBeep (); /* FIXME: something here */
}
- (IBAction)bring_to_front:sender
{
QuartzMessageServerThread(kXDarwinControllerNotify, 1, AppleWMBringAllToFront);
}
- (IBAction)close_window:sender
{
if ([X11App x_active])
QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMCloseWindow);
else
[[NSApp keyWindow] performClose:sender];
}
- (IBAction)minimize_window:sender
{
if ([X11App x_active])
QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMMinimizeWindow);
else
[[NSApp keyWindow] performMiniaturize:sender];
}
- (IBAction)zoom_window:sender
{
if ([X11App x_active])
QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMZoomWindow);
else
[[NSApp keyWindow] performZoom:sender];
}
- (IBAction) next_window:sender
{
QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMNextWindow);
}
- (IBAction) previous_window:sender
{
QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMPreviousWindow);
}
- (IBAction) enable_fullscreen_changed:sender
{
int value = ![enable_fullscreen intValue];
#ifdef DARWIN_DDX_MISSING
QuartzMessageServerThread (kXDarwinSetRootless, 1, value);
#endif
[NSApp prefs_set_boolean:@PREFS_ROOTLESS value:value];
[NSApp prefs_synchronize];
}
- (IBAction) toggle_fullscreen:sender
{
#ifdef DARWIN_DDX_MISSING
QuartzMessageServerThread (kXDarwinToggleFullscreen, 0);
#endif
}
- (void) set_can_quit:(BOOL)state
{
can_quit = state;
}
- (IBAction)prefs_changed:sender
{
darwinFakeButtons = [fake_buttons intValue];
quartzUseSysBeep = [use_sysbeep intValue];
X11EnableKeyEquivalents = [enable_keyequivs intValue];
darwinSyncKeymap = [sync_keymap intValue];
/* after adding prefs here, also add to [X11Application read_defaults]
and below */
[NSApp prefs_set_boolean:@PREFS_FAKEBUTTONS value:darwinFakeButtons];
[NSApp prefs_set_boolean:@PREFS_SYSBEEP value:quartzUseSysBeep];
[NSApp prefs_set_boolean:@PREFS_KEYEQUIVS value:X11EnableKeyEquivalents];
[NSApp prefs_set_boolean:@PREFS_SYNC_KEYMAP value:darwinSyncKeymap];
[NSApp prefs_set_boolean:@PREFS_NO_AUTH value:![enable_auth intValue]];
[NSApp prefs_set_boolean:@PREFS_NO_TCP value:![enable_tcp intValue]];
[NSApp prefs_set_integer:@PREFS_DEPTH value:[depth selectedTag]];
[NSApp prefs_synchronize];
}
- (IBAction) prefs_show:sender
{
[fake_buttons setIntValue:darwinFakeButtons];
[use_sysbeep setIntValue:quartzUseSysBeep];
[enable_keyequivs setIntValue:X11EnableKeyEquivalents];
[sync_keymap setIntValue:darwinSyncKeymap];
[sync_keymap setEnabled:darwinKeymapFile == NULL];
[enable_auth setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_AUTH default:NO]];
[enable_tcp setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_TCP default:NO]];
[depth selectItemAtIndex:[depth indexOfItemWithTag:[NSApp prefs_get_integer:@PREFS_DEPTH default:-1]]];
[enable_fullscreen setIntValue:!quartzEnableRootless];
[prefs_panel makeKeyAndOrderFront:sender];
}
- (IBAction) quit:sender
{
QuartzMessageServerThread (kXDarwinQuit, 0);
}
- (IBAction) x11_help:sender
{
AHLookupAnchor (CFSTR ("Mac Help"), CFSTR ("mchlp2276"));
}
- (BOOL) validateMenuItem:(NSMenuItem *)item
{
NSMenu *menu = [item menu];
if (item == toggle_fullscreen_item)
return !quartzEnableRootless;
else if (menu == [window_separator menu] || menu == dock_menu
|| (menu == [x11_about_item menu] && [item tag] == 42))
return (AppleWMSelectedEvents () & AppleWMControllerNotifyMask) != 0;
else
return TRUE;
}
- (void) applicationDidHide:(NSNotification *)notify
{
QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMHideAll);
}
- (void) applicationDidUnhide:(NSNotification *)notify
{
QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMShowAll);
}
- (NSApplicationTerminateReply) applicationShouldTerminate:sender
{
NSString *msg;
if (can_quit || [X11App prefs_get_boolean:@PREFS_NO_QUIT_ALERT default:NO])
return NSTerminateNow;
/* Make sure we're frontmost. */
[NSApp activateIgnoringOtherApps:YES];
msg = NSLocalizedString (@"Are you sure you want to quit X11?\n\nIf you quit X11, any X11 applications you are running will stop immediately and you will lose any changes you have not saved.", @"Dialog when quitting");
/* FIXME: safe to run the alert in here? Or should we return Later
and then run the alert on a timer? It seems to work here, so.. */
return (NSRunAlertPanel (nil, msg, NSLocalizedString (@"Quit", @""),
NSLocalizedString (@"Cancel", @""), nil)
== NSAlertDefaultReturn) ? NSTerminateNow : NSTerminateCancel;
}
- (void) applicationWillTerminate:(NSNotification *)aNotification
{
[X11App prefs_synchronize];
/* shutdown the X server, it will exit () for us. */
QuartzMessageServerThread (kXDarwinQuit, 0);
/* In case it doesn't, exit anyway after a while. */
while (sleep (10) != 0) ;
exit (1);
}
- (void) server_ready
{
x_list *node;
finished_launching = YES;
for (node = pending_apps; node != NULL; node = node->next)
{
NSString *filename = node->data;
[self launch_client:filename];
[filename release];
}
x_list_free (pending_apps);
pending_apps = NULL;
}
- (BOOL) application:(NSApplication *)app openFile:(NSString *)filename
{
const char *name = [filename UTF8String];
if (finished_launching)
[self launch_client:filename];
else if (name[0] != ':') /* ignore display names */
pending_apps = x_list_prepend (pending_apps, [filename retain]);
/* FIXME: report failures. */
return YES;
}
@end
void X11ControllerMain (int argc, const char *argv[],
void (*server_thread) (void *), void *server_arg)
{
X11ApplicationMain (argc, argv, server_thread, server_arg);
}

158
hw/darwin/apple/Xquartz.man Normal file
View File

@ -0,0 +1,158 @@
.\" $XFree86: xc/programs/Xserver/hw/darwin/XDarwin.man,v 1.4 2002/01/09 18:01:58 torrey Exp $
.\"
.TH XQUARTZ 1 __vendorversion__
.SH NAME
Xquartz \- X window system server for Quartz operating system
.SH SYNOPSIS
.B Xquartz
[ options ] ...
.SH DESCRIPTION
.I Xquartz
is the X window server for Mac OS X provided by Apple.
.I Xquartz
runs in parallel with Aqua in rootless mode. In rootless mode, the X
window system and Mac OS X share your display. The root window of the
X11 display is the size of the screen and contains all the other
windows. The X11 root window is not displayed in rootless mode as Mac
OS X handles the desktop background.
.SH OPTIONS
.PP
In addition to the normal server options described in the \fIXserver(1)\fP
manual page, \fIXquartz\fP accepts the following command line switches:
.TP 8
.B \-fakebuttons
Emulates a 3 button mouse using modifier keys. By default, the Command modifier
is used to emulate button 2 and Option is used for button 3. Thus, clicking the
first mouse button while holding down Command will act like clicking
button 2. Holding down Option will simulate button 3.
.TP 8
.B \-nofakebuttons
Do not emulate a 3 button mouse. This is the default.
.TP 8
.B "\-fakemouse2 \fImodifiers\fP"
Change the modifier keys used to emulate the second mouse button. By default,
Command is used to emulate the second button. Any combination of the following
modifier names may be used: Shift, Option, Control, Command, Fn. For example,
.B \-fakemouse2 """Option,Shift""
will set holding Option, Shift and clicking on button one as equivalent to
clicking the second mouse button.
.TP 8
.B "\-fakemouse3 \fImodifiers\fP"
Change the modifier keys used to emulate the third mouse button. By default,
Option is used to emulate the third button. Any combination of the following
modifier names may be used: Shift, Option, Control, Command, Fn. For example,
.B \-fakemouse3 """Control,Shift""
will set holding Control, Shift and clicking on button one as equivalent to
clicking the third mouse button.
.TP 8
.B "\-swapAltMeta"
Swaps the meaning of the Alt and Meta modifier keys.
.TP 8
.B "\-keymap \fIfile\fP"
On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap.
The default is to read this keymapping from USA.keymapping. With this option
the keymapping will be read from \fIfile\fP instead. If the file's path is
not specified, it will be searched for in Library/Keyboards/ underneath the
following directories (in order): ~, /, /Network, /System.
.TP 8
.B \-nokeymap
On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap.
With this option \fIXquartz\fP queries the kernel for the current keymapping
instead of reading it from a file. This will often fail on newer kernels.
.TP 8
.B "\-depth \fIdepth\fP"
Specifies the color bit depth to use. Currently only 15, and 24 color
bits per pixel are supported. If not specified, defaults to the depth
of the main display.
.SH CUSTOMIZATION
\fIXquartz\fP can also be customized using the defaults(1) command. The available options are:
.TP 8
.B defaults write com.apple.x11 enable_fake_buttons -boolean true
Equivalent to the \fB-fakebuttons\fP command line option.
.TP 8
.B defaults write com.apple.x11 fake_button2 \fImodifiers\fP
Equivalent to the \fB-fakemouse2\fP option.
.TP 8
.B defaults write com.apple.x11 fake_button3 \fImodifiers\fP
Equivalent to the \fB-fakemouse3\fP option.
.TP 8
.B defaults write com.apple.x11 swap_alt_meta -boolean true
Equivalent to the \fB-swapAltMeta\fP option.
.TP 8
.B defaults write com.apple.x11 keymap_file \fIfilename\fP
Equivalent to the \fB-keymap\fP option.
.TP 8
.B defaults write com.apple.x11 no_quit_alert -boolean true
Disables the alert dialog displayed when attempting to quit X11.
.TP 8
.B defaults write com.apple.x11 no_auth -boolean true
Stops the X server requiring that clients authenticate themselves when
connecting. See Xsecurity(__miscmansuffix__).
.TP 8
.B defaults write com.apple.x11 nolisten_tcp -boolean true
Prevents the X server accepting remote connections.
.TP 8
.B defaults write com.apple.x11 xinit_kills_server -boolean false
Stops the X server exiting when the xinitrc script terminates.
.TP 8
.B defaults write com.apple.x11 fullscreen_hotkeys -boolean false
Allows system hotkeys to be handled while in X11 fullscreen mode.
.TP 8
.B defaults write com.apple.x11 enable_system_beep -boolean false
Don't use the standard system beep effect for X11 alerts.
.TP 8
.B defaults write com.apple.x11 enable_key_equivalents -boolean false
Disable menu keyboard equivalents while X11 windows are focused.
.TP 8
.B defaults write com.apple.x11 depth \fIdepth\fP
Equivalent to the \fB-depth\fP option.
.SH "SEE ALSO"
.PP
X(__miscmansuffix__), XFree86(1), Xserver(1), xdm(1), xinit(1)
.PP
.SH AUTHORS
XFree86 was originally ported to Mac OS X Server by John Carmack. Dave
Zarzycki used this as the basis of his port of XFree86 4.0 to Darwin 1.0.
Torrey T. Lyons improved and integrated this code into the XFree86
Project's mainline for the 4.0.2 release.
.PP
The following members of the XonX Team contributed to the following
releases (in alphabetical order):
.TP 4
XFree86 4.1.0:
.br
Rob Braun - Darwin x86 support
.br
Torrey T. Lyons - Project Lead
.br
Andreas Monitzer - Cocoa version of XDarwin front end
.br
Gregory Robert Parker - Original Quartz implementation
.br
Christoph Pfisterer - Dynamic shared X libraries
.br
Toshimitsu Tanaka - Japanese localization
.TP 4
XFree86 4.2.0:
.br
Rob Braun - Darwin x86 support
.br
Pablo Di Noto - Spanish localization
.br
Paul Edens - Dutch localization
.br
Kyunghwan Kim - Korean localization
.br
Mario Klebsch - Non-US keyboard support
.br
Torrey T. Lyons - Project Lead
.br
Andreas Monitzer - German localization
.br
Patrik Montgomery - Swedish localization
.br
Greg Parker - Rootless support
.br
Toshimitsu Tanaka - Japanese localization
.br
Olivier Verdier - French localization

View File

@ -0,0 +1,911 @@
/* bundle-main.c -- X server launcher
$Id: bundle-main.c,v 1.17 2003/09/11 00:17:10 jharper Exp $
Copyright (c) 2002-2007 Apple Inc. 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.
Parts of this file are derived from xdm, which has this copyright:
Copyright 1988, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software
and its documentation for any purpose is hereby granted without fee,
provided that the above copyright notice appear in all copies and
that both that copyright notice and this permission notice appear in
supporting documentation.
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 OPEN GROUP 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 of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group. */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/socket.h>
#include <sys/utsname.h>
#include <ifaddrs.h>
#include <netdb.h>
#include <netinet/in.h>
#include <time.h>
#include <sys/wait.h>
#include <setjmp.h>
#include <sys/ioctl.h>
#include <X11/Xlib.h>
#include <X11/Xauth.h>
#include <CoreFoundation/CoreFoundation.h>
#include <SystemConfiguration/SystemConfiguration.h>
#define X_SERVER "/usr/X11/bin/Xquartz"
#define XTERM_PATH "/usr/X11/bin/xterm"
#define WM_PATH "/usr/X11/bin/quartz-wm"
#define DEFAULT_XINITRC "/etc/X11/xinit/xinitrc"
#define DEFAULT_PATH "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11/bin"
/* what xinit does */
#ifndef SHELL
# define SHELL "sh"
#endif
#undef FALSE
#define FALSE 0
#undef TRUE
#define TRUE 1
#define MAX_DISPLAYS 64
static int server_pid = -1, client_pid = -1;
static int xinit_kills_server = FALSE;
static jmp_buf exit_continuation;
static const char *server_name = NULL;
static Display *server_dpy;
static char *auth_file;
typedef struct addr_list_struct addr_list;
struct addr_list_struct {
addr_list *next;
Xauth auth;
};
static addr_list *addresses;
/* Utility functions. */
/* Return the current host name. Matches what Xlib does. */
static char *
host_name (void)
{
#ifdef NEED_UTSNAME
static struct utsname name;
uname(&name);
return name.nodename;
#else
static char buf[100];
gethostname(buf, sizeof(buf));
return buf;
#endif
}
static int
read_boolean_pref (CFStringRef name, int default_)
{
int value;
Boolean ok;
value = CFPreferencesGetAppBooleanValue (name,
CFSTR ("com.apple.x11"), &ok);
return ok ? value : default_;
}
static inline int
binary_equal (const void *a, const void *b, int length)
{
return memcmp (a, b, length) == 0;
}
static inline void *
binary_dup (const void *a, int length)
{
void *b = malloc (length);
if (b != NULL)
memcpy (b, a, length);
return b;
}
static inline void
binary_free (void *data, int length)
{
if (data != NULL)
free (data);
}
/* Functions for managing the authentication entries. */
/* Returns true if something matching AUTH is in our list of auth items */
static int
check_auth_item (Xauth *auth)
{
addr_list *a;
for (a = addresses; a != NULL; a = a->next)
{
if (a->auth.family == auth->family
&& a->auth.address_length == auth->address_length
&& binary_equal (a->auth.address, auth->address, auth->address_length)
&& a->auth.number_length == auth->number_length
&& binary_equal (a->auth.number, auth->number, auth->number_length)
&& a->auth.name_length == auth->name_length
&& binary_equal (a->auth.name, auth->name, auth->name_length))
{
return TRUE;
}
}
return FALSE;
}
/* Add one item to our list of auth items. */
static void
add_auth_item (Xauth *auth)
{
addr_list *a = malloc (sizeof (addr_list));
a->auth.family = auth->family;
a->auth.address_length = auth->address_length;
a->auth.address = binary_dup (auth->address, auth->address_length);
a->auth.number_length = auth->number_length;
a->auth.number = binary_dup (auth->number, auth->number_length);
a->auth.name_length = auth->name_length;
a->auth.name = binary_dup (auth->name, auth->name_length);
a->auth.data_length = auth->data_length;
a->auth.data = binary_dup (auth->data, auth->data_length);
a->next = addresses;
addresses = a;
}
/* Free all allocated auth items. */
static void
free_auth_items (void)
{
addr_list *a;
while ((a = addresses) != NULL)
{
addresses = a->next;
binary_free (a->auth.address, a->auth.address_length);
binary_free (a->auth.number, a->auth.number_length);
binary_free (a->auth.name, a->auth.name_length);
binary_free (a->auth.data, a->auth.data_length);
free (a);
}
}
/* Add the unix domain auth item. */
static void
define_local (Xauth *auth)
{
char *host = host_name ();
#ifdef DEBUG
fprintf (stderr, "x11: hostname is %s\n", host);
#endif
auth->family = FamilyLocal;
auth->address_length = strlen (host);
auth->address = host;
add_auth_item (auth);
}
/* Add the tcp auth item. */
static void
define_named (Xauth *auth, const char *name)
{
struct ifaddrs *addrs, *ptr;
if (getifaddrs (&addrs) != 0)
return;
for (ptr = addrs; ptr != NULL; ptr = ptr->ifa_next)
{
if (ptr->ifa_addr->sa_family != AF_INET)
continue;
auth->family = FamilyInternet;
auth->address_length = sizeof (struct in_addr);
auth->address = (char *) &(((struct sockaddr_in *) ptr->ifa_addr)->sin_addr);
#ifdef DEBUG
fprintf (stderr, "x11: ipaddr is %d.%d.%d.%d\n",
(unsigned char) auth->address[0],
(unsigned char) auth->address[1],
(unsigned char) auth->address[2],
(unsigned char) auth->address[3]);
#endif
add_auth_item (auth);
}
freeifaddrs (addrs);
}
/* Parse the display number from NAME and add it to AUTH. */
static void
set_auth_number (Xauth *auth, const char *name)
{
char *colon;
char *dot, *number;
colon = strrchr(name, ':');
if (colon != NULL)
{
colon++;
dot = strchr(colon, '.');
if (dot != NULL)
auth->number_length = dot - colon;
else
auth->number_length = strlen (colon);
number = malloc (auth->number_length + 1);
if (number != NULL)
{
strncpy (number, colon, auth->number_length);
number[auth->number_length] = '\0';
}
else
{
auth->number_length = 0;
}
auth->number = number;
}
}
/* Put 128 bits of random data into DATA. If possible, it will be "high
quality" */
static int
generate_mit_magic_cookie (char data[16])
{
int fd, ret, i;
long *ldata = (long *) data;
fd = open ("/dev/random", O_RDONLY);
if (fd > 0) {
ret = read (fd, data, 16);
close (fd);
if (ret == 16) return TRUE;
}
/* fall back to the usual crappy rng */
srand48 (getpid () ^ time (NULL));
for (i = 0; i < 4; i++)
ldata[i] = lrand48 ();
return TRUE;
}
/* Create the keys we'll be using for the display named NAME. */
static int
make_auth_keys (const char *name)
{
Xauth auth;
char key[16];
if (auth_file == NULL)
return FALSE;
auth.name = "MIT-MAGIC-COOKIE-1";
auth.name_length = strlen (auth.name);
if (!generate_mit_magic_cookie (key))
{
auth_file = NULL;
return FALSE;
}
auth.data = key;
auth.data_length = 16;
set_auth_number (&auth, name);
define_named (&auth, host_name ());
define_local (&auth);
free (auth.number);
return TRUE;
}
/* If ADD-ENTRIES is true, merge our auth entries into the existing
Xauthority file. If ADD-ENTRIES is false, remove our entries. */
static int
write_auth_file (int add_entries)
{
char *home, newname[1024];
int fd, ret;
FILE *new_fh, *old_fh;
addr_list *addr;
Xauth *auth;
if (auth_file == NULL)
return FALSE;
home = getenv ("HOME");
if (home == NULL)
{
auth_file = NULL;
return FALSE;
}
snprintf (newname, sizeof (newname), "%s/.XauthorityXXXXXX", home);
mktemp (newname);
if (XauLockAuth (auth_file, 1, 2, 10) != LOCK_SUCCESS)
{
/* FIXME: do something here? */
auth_file = NULL;
return FALSE;
}
fd = open (newname, O_WRONLY | O_CREAT | O_TRUNC, 0600);
if (fd >= 0)
{
new_fh = fdopen (fd, "w");
if (new_fh != NULL)
{
if (add_entries)
{
for (addr = addresses; addr != NULL; addr = addr->next)
{
XauWriteAuth (new_fh, &addr->auth);
}
}
old_fh = fopen (auth_file, "r");
if (old_fh != NULL)
{
while ((auth = XauReadAuth (old_fh)) != NULL)
{
if (!check_auth_item (auth))
XauWriteAuth (new_fh, auth);
XauDisposeAuth (auth);
}
fclose (old_fh);
}
fclose (new_fh);
unlink (auth_file);
ret = rename (newname, auth_file);
if (ret != 0)
auth_file = NULL;
XauUnlockAuth (auth_file);
return ret == 0;
}
close (fd);
}
XauUnlockAuth (auth_file);
auth_file = NULL;
return FALSE;
}
/* Subprocess management functions. */
static int
start_server (char **xargv)
{
int child;
child = fork ();
switch (child)
{
case -1: /* error */
perror ("fork");
return FALSE;
case 0: /* child */
execv (X_SERVER, xargv);
perror ("Couldn't exec " X_SERVER);
_exit (1);
default: /* parent */
server_pid = child;
return TRUE;
}
}
static int
wait_for_server (void)
{
int count = 100;
while (count-- > 0)
{
int status;
server_dpy = XOpenDisplay (server_name);
if (server_dpy != NULL)
return TRUE;
if (waitpid (server_pid, &status, WNOHANG) == server_pid)
return FALSE;
sleep (1);
}
return FALSE;
}
static int
start_client (void)
{
int child;
child = fork();
switch (child) {
char *temp, buf[1024];
case -1: /* error */
perror("fork");
return FALSE;
case 0: /* child */
/* Setup environment */
temp = getenv("DISPLAY");
if (temp != NULL && temp[0] != 0)
setenv("DISPLAY", server_name, TRUE);
temp = getenv("PATH");
if (temp == NULL || temp[0] == 0)
setenv ("PATH", DEFAULT_PATH, TRUE);
else if (strnstr(temp, "/usr/X11/bin", sizeof(temp)) == NULL) {
snprintf(buf, sizeof(buf), "%s:/usr/X11/bin", temp);
setenv("PATH", buf, TRUE);
}
/* First try value of $XINITRC, if set. */
temp = getenv("XINITRC");
if (temp != NULL && temp[0] != 0 && access(temp, R_OK) == 0)
execlp (SHELL, SHELL, temp, NULL);
/* Then look for .xinitrc in user's home directory. */
temp = getenv("HOME");
if (temp != NULL && temp[0] != 0) {
chdir(temp);
snprintf (buf, sizeof (buf), "%s/.xinitrc", temp);
if (access(buf, R_OK) == 0)
execlp(SHELL, SHELL, buf, NULL);
}
/* Then try the default xinitrc in the lib directory. */
if (access(DEFAULT_XINITRC, R_OK) == 0)
execlp(SHELL, SHELL, DEFAULT_XINITRC, NULL);
/* Then fallback to hardcoding an xterm and the window manager. */
// system(XTERM_PATH " &");
execl(WM_PATH, WM_PATH, NULL);
perror("exec");
_exit(1);
default: /* parent */
client_pid = child;
return TRUE;
}
}
static void
sigchld_handler (int sig)
{
int pid, status;
again:
pid = waitpid (WAIT_ANY, &status, WNOHANG);
if (pid > 0)
{
if (pid == server_pid)
{
server_pid = -1;
if (client_pid >= 0)
kill (client_pid, SIGTERM);
}
else if (pid == client_pid)
{
client_pid = -1;
if (server_pid >= 0 && xinit_kills_server)
kill (server_pid, SIGTERM);
}
goto again;
}
if (server_pid == -1 && client_pid == -1)
longjmp (exit_continuation, 1);
signal (SIGCHLD, sigchld_handler);
}
/* Server utilities. */
static Boolean
display_exists_p (int number)
{
char buf[64];
void *conn;
char *fullname = NULL;
int idisplay, iscreen;
char *conn_auth_name, *conn_auth_data;
int conn_auth_namelen, conn_auth_datalen;
extern void *_X11TransConnectDisplay ();
extern void _XDisconnectDisplay ();
/* Since connecting to the display waits for a few seconds if the
display doesn't exist, check for trivial non-existence - if the
socket in /tmp exists or not.. (note: if the socket exists, the
server may still not, so we need to try to connect in that case..) */
sprintf (buf, "/tmp/.X11-unix/X%d", number);
if (access (buf, F_OK) != 0)
return FALSE;
/* This is a private function that we shouldn't really be calling,
but it's the best way to see if the server exists (without
needing to hold the necessary authentication to use it) */
sprintf (buf, ":%d", number);
conn = _X11TransConnectDisplay (buf, &fullname, &idisplay, &iscreen,
&conn_auth_name, &conn_auth_namelen,
&conn_auth_data, &conn_auth_datalen);
if (conn == NULL)
return FALSE;
_XDisconnectDisplay (conn);
return TRUE;
}
/* Monitoring when the system's ip addresses change. */
static Boolean pending_timer;
static void
timer_callback (CFRunLoopTimerRef timer, void *info)
{
pending_timer = FALSE;
/* Update authentication names. Need to write .Xauthority file first
without the existing entries, then again with the new entries.. */
write_auth_file (FALSE);
free_auth_items ();
make_auth_keys (server_name);
write_auth_file (TRUE);
}
/* This function is called when the system's ip addresses may have changed. */
static void
ipaddr_callback (SCDynamicStoreRef store, CFArrayRef changed_keys, void *info)
{
#if DEBUG
if (changed_keys != NULL) {
fprintf (stderr, "x11: changed sc keys: ");
CFShow (changed_keys);
}
#endif
if (auth_file != NULL && !pending_timer)
{
CFRunLoopTimerRef timer;
timer = CFRunLoopTimerCreate (NULL, CFAbsoluteTimeGetCurrent () + 1.0,
0.0, 0, 0, timer_callback, NULL);
CFRunLoopAddTimer (CFRunLoopGetCurrent (), timer,
kCFRunLoopDefaultMode);
CFRelease (timer);
pending_timer = TRUE;
}
}
/* This code adapted from "Living in a Dynamic TCP/IP Environment" technote. */
static Boolean
install_ipaddr_source (void)
{
CFRunLoopSourceRef source = NULL;
SCDynamicStoreContext context = {0};
SCDynamicStoreRef ref;
ref = SCDynamicStoreCreate (NULL,
CFSTR ("AddIPAddressListChangeCallbackSCF"),
ipaddr_callback, &context);
if (ref != NULL)
{
const void *keys[4], *patterns[2];
int i;
keys[0] = SCDynamicStoreKeyCreateNetworkGlobalEntity (NULL, kSCDynamicStoreDomainState, kSCEntNetIPv4);
keys[1] = SCDynamicStoreKeyCreateNetworkGlobalEntity (NULL, kSCDynamicStoreDomainState, kSCEntNetIPv6);
keys[2] = SCDynamicStoreKeyCreateComputerName (NULL);
keys[3] = SCDynamicStoreKeyCreateHostNames (NULL);
patterns[0] = SCDynamicStoreKeyCreateNetworkInterfaceEntity (NULL, kSCDynamicStoreDomainState, kSCCompAnyRegex, kSCEntNetIPv4);
patterns[1] = SCDynamicStoreKeyCreateNetworkInterfaceEntity (NULL, kSCDynamicStoreDomainState, kSCCompAnyRegex, kSCEntNetIPv6);
if (keys[0] != NULL && keys[1] != NULL && keys[2] != NULL
&& keys[3] != NULL && patterns[0] != NULL && patterns[1] != NULL)
{
CFArrayRef key_array, pattern_array;
key_array = CFArrayCreate (NULL, keys, 4, &kCFTypeArrayCallBacks);
pattern_array = CFArrayCreate (NULL, patterns, 2, &kCFTypeArrayCallBacks);
if (key_array != NULL || pattern_array != NULL)
{
SCDynamicStoreSetNotificationKeys (ref, key_array, pattern_array);
source = SCDynamicStoreCreateRunLoopSource (NULL, ref, 0);
}
if (key_array != NULL)
CFRelease (key_array);
if (pattern_array != NULL)
CFRelease (pattern_array);
}
for (i = 0; i < 4; i++)
if (keys[i] != NULL)
CFRelease (keys[i]);
for (i = 0; i < 2; i++)
if (patterns[i] != NULL)
CFRelease (patterns[i]);
CFRelease (ref);
}
if (source != NULL)
{
CFRunLoopAddSource (CFRunLoopGetCurrent (),
source, kCFRunLoopDefaultMode);
CFRelease (source);
}
return source != NULL;
}
/* Entrypoint. */
void
termination_signal_handler (int unused_sig)
{
signal (SIGTERM, SIG_DFL);
signal (SIGHUP, SIG_DFL);
signal (SIGINT, SIG_DFL);
signal (SIGQUIT, SIG_DFL);
longjmp (exit_continuation, 1);
}
int
main (int argc, char **argv)
{
char **xargv;
int i, j;
int fd;
xargv = alloca (sizeof (char *) * (argc + 32));
if (!read_boolean_pref (CFSTR ("no_auth"), FALSE))
auth_file = XauFileName ();
/* The standard X11 behaviour is for the server to quit when the first
client exits. But it can be useful for debugging (and to mimic our
behaviour in the beta releases) to not do that. */
xinit_kills_server = read_boolean_pref (CFSTR ("xinit_kills_server"), TRUE);
for (i = 1; i < argc; i++)
{
if (argv[i][0] == ':')
server_name = argv[i];
}
if (server_name == NULL)
{
static char name[8];
/* No display number specified, so search for the first unused.
There's a big old race condition here if two servers start at
the same time, but that's fairly unlikely. We could create
lockfiles or something, but that's seems more likely to cause
problems than the race condition itself.. */
for (i = 0; i < MAX_DISPLAYS; i++)
{
if (!display_exists_p (i))
break;
}
if (i == MAX_DISPLAYS)
{
fprintf (stderr, "%s: couldn't allocate a display number", argv[0]);
exit (1);
}
sprintf (name, ":%d", i);
server_name = name;
}
if (auth_file != NULL)
{
/* Create new Xauth keys and add them to the .Xauthority file */
make_auth_keys (server_name);
write_auth_file (TRUE);
}
/* Construct our new argv */
i = j = 0;
xargv[i++] = argv[j++];
if (auth_file != NULL)
{
xargv[i++] = "-auth";
xargv[i++] = auth_file;
}
/* By default, don't listen on tcp sockets if Xauth is disabled. */
if (read_boolean_pref (CFSTR ("nolisten_tcp"), auth_file == NULL))
{
xargv[i++] = "-nolisten";
xargv[i++] = "tcp";
}
while (j < argc)
{
if (argv[j++][0] != ':')
xargv[i++] = argv[j-1];
}
xargv[i++] = (char *) server_name;
xargv[i++] = NULL;
/* Detach from any controlling terminal and connect stdin to /dev/null */
#ifdef TIOCNOTTY
fd = open ("/dev/tty", O_RDONLY);
if (fd != -1)
{
ioctl (fd, TIOCNOTTY, 0);
close (fd);
}
#endif
fd = open ("/dev/null", O_RDWR, 0);
if (fd >= 0)
{
dup2 (fd, 0);
if (fd > 0)
close (fd);
}
if (!start_server (xargv))
return 1;
if (!wait_for_server ())
{
kill (server_pid, SIGTERM);
return 1;
}
if (!start_client ())
{
kill (server_pid, SIGTERM);
return 1;
}
signal (SIGCHLD, sigchld_handler);
signal (SIGTERM, termination_signal_handler);
signal (SIGHUP, termination_signal_handler);
signal (SIGINT, termination_signal_handler);
signal (SIGQUIT, termination_signal_handler);
if (setjmp (exit_continuation) == 0)
{
if (install_ipaddr_source ())
CFRunLoopRun ();
else
while (1) pause ();
}
signal (SIGCHLD, SIG_IGN);
if (client_pid >= 0) kill (client_pid, SIGTERM);
if (server_pid >= 0) kill (server_pid, SIGTERM);
if (auth_file != NULL)
{
/* Remove our Xauth keys */
write_auth_file (FALSE);
}
free_auth_items ();
return 0;
}