diff options
author | Jeremy Huddleston <jeremy@tifa.local> | 2007-11-21 19:51:14 -0800 |
---|---|---|
committer | Jeremy Huddleston <jeremy@tifa.local> | 2007-11-21 19:52:11 -0800 |
commit | bcbaf2a0ce34b6c5e41d2831b8b87dbd0617a89b (patch) | |
tree | 064153d76872e4b9674b38e1fec7163d12a61cce /hw/darwin/apple | |
parent | a55ec1a9f4b62139dc5e5462d79d47b330c27c79 (diff) |
Darwin: Dead code removal, Code cleanup, Added launcher
Imported changes from xorg-server-1.2-apple to make master more current wrt
file layout, build system changes, and dead code removal.
Diffstat (limited to 'hw/darwin/apple')
-rw-r--r-- | hw/darwin/apple/X11.xcodeproj/project.pbxproj | 49 | ||||
-rw-r--r-- | hw/darwin/apple/X11Application.h | 103 | ||||
-rw-r--r-- | hw/darwin/apple/X11Application.m | 915 | ||||
-rw-r--r-- | hw/darwin/apple/X11Controller.h | 85 | ||||
-rw-r--r-- | hw/darwin/apple/X11Controller.m | 747 | ||||
-rw-r--r-- | hw/darwin/apple/Xquartz.man | 158 |
6 files changed, 27 insertions, 2030 deletions
diff --git a/hw/darwin/apple/X11.xcodeproj/project.pbxproj b/hw/darwin/apple/X11.xcodeproj/project.pbxproj index 2fef99ba0..27cab8d06 100644 --- a/hw/darwin/apple/X11.xcodeproj/project.pbxproj +++ b/hw/darwin/apple/X11.xcodeproj/project.pbxproj @@ -195,41 +195,40 @@ 527F24090B5D8FFC007840A7 /* Development */ = { isa = XCBuildConfiguration; buildSettings = { - DSTROOT = "$(DSTROOT)"; - SKIP_INSTALL = YES; + INSTALL_MODE_FLAG = "a+rX"; }; name = Development; }; 527F240A0B5D8FFC007840A7 /* Deployment */ = { isa = XCBuildConfiguration; buildSettings = { - DSTROOT = "$(DSTROOT)"; - SKIP_INSTALL = YES; + INSTALL_MODE_FLAG = "a+rX"; }; name = Deployment; }; 527F240B0B5D8FFC007840A7 /* Default */ = { isa = XCBuildConfiguration; buildSettings = { - DSTROOT = "$(DSTROOT)"; - SKIP_INSTALL = YES; + INSTALL_MODE_FLAG = "a+rX"; }; 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 = ""; INFOPLIST_FILE = Info.plist; - INSTALL_PATH = $DSTROOT/Applications/Utilties; - LIBRARY_SEARCH_PATHS = ""; - OTHER_CFLAGS = "$(CFLAGS)"; - OTHER_LDFLAGS = "$(LDFLAGS)"; + INSTALL_PATH = /usr/X11; + LIBRARY_SEARCH_PATHS = /usr/X11/lib; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ( + "-lXau", + "-lxcb", + "-lX11", + ); OTHER_REZFLAGS = ""; PRODUCT_NAME = X11; SECTORDER_FLAGS = ""; @@ -246,15 +245,18 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - DSTROOT = "$(DSTROOT)"; FRAMEWORK_SEARCH_PATHS = ""; GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = Info.plist; - INSTALL_PATH = $DSTROOT/Applications/Utilties; - LIBRARY_SEARCH_PATHS = ""; - OTHER_CFLAGS = "$(CFLAGS)"; - OTHER_LDFLAGS = "$(LDFLAGS)"; + INSTALL_PATH = /usr/X11; + LIBRARY_SEARCH_PATHS = /usr/X11/lib; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ( + "-lXau", + "-lxcb", + "-lX11", + ); OTHER_REZFLAGS = ""; PRODUCT_NAME = X11; SECTORDER_FLAGS = ""; @@ -270,15 +272,18 @@ 527F24250B5D938C007840A7 /* Default */ = { isa = XCBuildConfiguration; buildSettings = { - DSTROOT = "$(DSTROOT)"; FRAMEWORK_SEARCH_PATHS = ""; GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = Info.plist; - INSTALL_PATH = $DSTROOT/Applications/Utilties; - LIBRARY_SEARCH_PATHS = ""; - OTHER_CFLAGS = "$(CFLAGS)"; - OTHER_LDFLAGS = "$(LDFLAGS)"; + INSTALL_PATH = /usr/X11; + LIBRARY_SEARCH_PATHS = /usr/X11/lib; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ( + "-lXau", + "-lxcb", + "-lX11", + ); OTHER_REZFLAGS = ""; PRODUCT_NAME = X11; SECTORDER_FLAGS = ""; diff --git a/hw/darwin/apple/X11Application.h b/hw/darwin/apple/X11Application.h deleted file mode 100644 index 861565798..000000000 --- a/hw/darwin/apple/X11Application.h +++ /dev/null @@ -1,103 +0,0 @@ -/* X11Application.h -- subclass of NSApplication to multiplex events - - 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 "org.x.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 */ diff --git a/hw/darwin/apple/X11Application.m b/hw/darwin/apple/X11Application.m deleted file mode 100644 index 461ca3926..000000000 --- a/hw/darwin/apple/X11Application.m +++ /dev/null @@ -1,915 +0,0 @@ -/* X11Application.m -- subclass of NSApplication to multiplex events - - Copyright (c) 2002-2007 Apple Inc. - - 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. */ - -#include "../quartz/quartzCommon.h" - -#import "X11Application.h" -#include <Carbon/Carbon.h> - -/* ouch! */ -#define BOOL X_BOOL -# include "darwin.h" -# include "../quartz/quartz.h" -# define _APPLEWM_SERVER_ -# include "X11/extensions/applewm.h" -# include "micmap.h" -#undef BOOL - -#include <mach/mach.h> -#include <unistd.h> -#include <pthread.h> - -#define DEFAULTS_FILE "/usr/X11/lib/X11/xserver/Xquartz.plist" - -int X11EnableKeyEquivalents = TRUE; -int quartzHasRoot = FALSE, quartzEnableRootless = TRUE; - -extern int darwinFakeButtons, input_check_flag; -// extern Bool enable_stereo; -Bool enable_stereo; //<-- this needs to go back to being an extern once glxCGL is fixed - -extern xEvent *darwinEvents; - -X11Application *X11App; - -#define ALL_KEY_MASKS (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask) - -@implementation X11Application - -typedef struct message_struct message; -struct message_struct { - mach_msg_header_t hdr; - SEL selector; - NSObject *arg; -}; - -static mach_port_t _port; - -static void send_nsevent (NSEventType type, NSEvent *e); - -/* Quartz mode initialization routine. This is often dynamically loaded - but is statically linked into this X server. */ -extern Bool QuartzModeBundleInit(void); - -static void init_ports (void) { - kern_return_t r; - NSPort *p; - - if (_port != MACH_PORT_NULL) return; - - r = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, &_port); - if (r != KERN_SUCCESS) return; - - p = [NSMachPort portWithMachPort:_port]; - [p setDelegate:NSApp]; - [p scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; -} - -static void message_kit_thread (SEL selector, NSObject *arg) { - message msg; - kern_return_t r; - - msg.hdr.msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_MAKE_SEND, 0); - msg.hdr.msgh_size = sizeof (msg); - msg.hdr.msgh_remote_port = _port; - msg.hdr.msgh_local_port = MACH_PORT_NULL; - msg.hdr.msgh_reserved = 0; - msg.hdr.msgh_id = 0; - - msg.selector = selector; - msg.arg = [arg retain]; - - r = mach_msg (&msg.hdr, MACH_SEND_MSG, msg.hdr.msgh_size, - 0, MACH_PORT_NULL, 0, MACH_PORT_NULL); - if (r != KERN_SUCCESS) - ErrorF("%s: mach_msg failed: %x\n", __FUNCTION__, r); -} - -- (void) handleMachMessage:(void *)_msg { - message *msg = _msg; - - [self performSelector:msg->selector withObject:msg->arg]; - [msg->arg release]; -} - -- (void) set_controller:obj { - if (_controller == nil) _controller = [obj retain]; -} - -- (void) dealloc { - if (_controller != nil) [_controller release]; - - if (_port != MACH_PORT_NULL) - mach_port_deallocate (mach_task_self (), _port); - - [super dealloc]; -} - -- (void) orderFrontStandardAboutPanel: (id) sender { - NSMutableDictionary *dict; - NSDictionary *infoDict; - NSString *tem; - - dict = [NSMutableDictionary dictionaryWithCapacity:2]; - infoDict = [[NSBundle mainBundle] infoDictionary]; - - [dict setObject: NSLocalizedString (@"The X Window System", @"About panel") - forKey:@"ApplicationName"]; - - tem = [infoDict objectForKey:@"CFBundleShortVersionString"]; - - [dict setObject:[NSString stringWithFormat:@"X11.app %@ - X.org X11R7.3", tem] - forKey:@"ApplicationVersion"]; - - [self orderFrontStandardAboutPanelWithOptions: dict]; -} - -- (void) activateX:(BOOL)state { - /* Create a TSM document that supports full Unicode input, and - have it activated while X is active (unless using the old - keymapping files) */ - static TSMDocumentID x11_document; - - if (state) { - QuartzMessageServerThread (kXDarwinActivate, 0); - - if (!_x_active) { - if (x11_document == 0 && darwinKeymapFile == NULL) { - OSType types[1]; - types[0] = kUnicodeDocument; - NewTSMDocument (1, types, &x11_document, 0); - } - - if (x11_document != 0) ActivateTSMDocument (x11_document); - } - } else { - QuartzMessageServerThread (kXDarwinDeactivate, 0); - - if (_x_active && x11_document != 0) - DeactivateTSMDocument (x11_document); - } - - _x_active = state; -} - -- (void) became_key:(NSWindow *)win { - [self activateX:NO]; -} - -- (void) sendEvent:(NSEvent *)e { - NSEventType type; - BOOL for_appkit, for_x; - - type = [e type]; - - /* By default pass down the responder chain and to X. */ - for_appkit = YES; - for_x = YES; - - switch (type) { - case NSLeftMouseDown: case NSRightMouseDown: case NSOtherMouseDown: - case NSLeftMouseUp: case NSRightMouseUp: case NSOtherMouseUp: - if ([e window] != nil) { - /* Pointer event has an (AppKit) window. Probably something for the kit. */ - for_x = NO; - if (_x_active) [self activateX:NO]; - } else if ([self modalWindow] == nil) { - /* Must be an X window. Tell appkit it doesn't have focus. */ - WindowPtr pWin = xprGetXWindowFromAppKit([e windowNumber]); - if (pWin) RootlessReorderWindow(pWin); - for_appkit = NO; - - if ([self isActive]) { - [self deactivate]; - - if (!_x_active && quartzProcs->IsX11Window([e window], - [e windowNumber])) - [self activateX:YES]; - } - } - break; - - case NSKeyDown: case NSKeyUp: - if (_x_active) { - static int swallow_up; - - /* No kit window is focused, so send it to X. */ - for_appkit = NO; - if (type == NSKeyDown) { - /* Before that though, see if there are any global - shortcuts bound to it. */ - - if (X11EnableKeyEquivalents - && [[self mainMenu] performKeyEquivalent:e]) { - swallow_up = [e keyCode]; - for_x = NO; - } else if (!quartzEnableRootless - && ([e modifierFlags] & ALL_KEY_MASKS) - == (NSCommandKeyMask | NSAlternateKeyMask) - && ([e keyCode] == 0 /*a*/ - || [e keyCode] == 53 /*Esc*/)) { - swallow_up = 0; - for_x = NO; -#ifdef DARWIN_DDX_MISSING - QuartzMessageServerThread (kXDarwinToggleFullscreen, 0); -#endif - } - } else { - /* If we saw a key equivalent on the down, don't pass - the up through to X. */ - - if (swallow_up != 0 && [e keyCode] == swallow_up) { - swallow_up = 0; - for_x = NO; - } - } - } else for_x = NO; - break; - - case NSFlagsChanged: - /* For the l33t X users who remap modifier keys to normal keysyms. */ - if (!_x_active) for_x = NO; - break; - - case NSAppKitDefined: - switch ([e subtype]) { - case NSApplicationActivatedEventType: - for_x = NO; - if ([self modalWindow] == nil) { - for_appkit = NO; - - /* FIXME: hack to avoid having to pass the event to appkit, - which would cause it to raise one of its windows. */ - _appFlags._active = YES; - - [self activateX:YES]; - if ([e data2] & 0x10) X11ApplicationSetFrontProcess(); - } - break; - - case 18: /* ApplicationDidReactivate */ - if (quartzHasRoot) for_appkit = NO; - break; - - case NSApplicationDeactivatedEventType: - for_x = NO; - [self activateX:NO]; - break; - } - break; - - default: break; /* for gcc */ - } - - if (for_appkit) [super sendEvent:e]; - - if (for_x) send_nsevent (type, e); -} - -- (void) set_window_menu:(NSArray *)list { - [_controller set_window_menu:list]; -} - -- (void) set_window_menu_check:(NSNumber *)n { - [_controller set_window_menu_check:n]; -} - -- (void) set_apps_menu:(NSArray *)list { - [_controller set_apps_menu:list]; -} - -- (void) set_front_process:unused { - [NSApp activateIgnoringOtherApps:YES]; - - if ([self modalWindow] == nil) [self activateX:YES]; - QuartzMessageServerThread(kXDarwinBringAllToFront, 0); -} - -- (void) set_can_quit:(NSNumber *)state { - [_controller set_can_quit:[state boolValue]]; -} - -- (void) server_ready:unused { - [_controller server_ready]; -} - -- (void) show_hide_menubar:(NSNumber *)state { - if ([state boolValue]) ShowMenuBar (); - else HideMenuBar (); -} - - -/* user preferences */ - -/* Note that these functions only work for arrays whose elements - can be toll-free-bridged between NS and CF worlds. */ - -static const void *cfretain (CFAllocatorRef a, const void *b) { - return CFRetain (b); -} - -static void cfrelease (CFAllocatorRef a, const void *b) { - CFRelease (b); -} - -static CFMutableArrayRef nsarray_to_cfarray (NSArray *in) { - CFMutableArrayRef out; - CFArrayCallBacks cb; - NSObject *ns; - const CFTypeRef *cf; - int i, count; - - memset (&cb, 0, sizeof (cb)); - cb.version = 0; - cb.retain = cfretain; - cb.release = cfrelease; - - count = [in count]; - out = CFArrayCreateMutable (NULL, count, &cb); - - for (i = 0; i < count; i++) { - ns = [in objectAtIndex:i]; - - if ([ns isKindOfClass:[NSArray class]]) - cf = (CFTypeRef) nsarray_to_cfarray ((NSArray *) ns); - else - cf = CFRetain ((CFTypeRef) ns); - - CFArrayAppendValue (out, cf); - CFRelease (cf); - } - - return out; -} - -static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) { - NSMutableArray *out; - const CFTypeRef *cf; - NSObject *ns; - int i, count; - - count = CFArrayGetCount (in); - out = [[NSMutableArray alloc] initWithCapacity:count]; - - for (i = 0; i < count; i++) { - cf = CFArrayGetValueAtIndex (in, i); - - if (CFGetTypeID (cf) == CFArrayGetTypeID ()) - ns = cfarray_to_nsarray ((CFArrayRef) cf); - else - ns = [(id)cf retain]; - - [out addObject:ns]; - [ns release]; - } - - return out; -} - -- (CFPropertyListRef) prefs_get:(NSString *)key { - CFPropertyListRef value; - - value = CFPreferencesCopyAppValue ((CFStringRef) key, CFSTR (APP_PREFS)); - - if (value == NULL) { - static CFDictionaryRef defaults; - - if (defaults == NULL) { - CFStringRef error = NULL; - CFDataRef data; - CFURLRef url; - SInt32 error_code; - - url = (CFURLCreateFromFileSystemRepresentation - (NULL, (unsigned char *)DEFAULTS_FILE, strlen (DEFAULTS_FILE), false)); - if (CFURLCreateDataAndPropertiesFromResource (NULL, url, &data, - NULL, NULL, &error_code)) { - defaults = (CFPropertyListCreateFromXMLData - (NULL, data, kCFPropertyListMutableContainersAndLeaves, &error)); - if (error != NULL) CFRelease (error); - CFRelease (data); - } - CFRelease (url); - - if (defaults != NULL) { - NSMutableArray *apps, *elt; - int count, i; - NSString *name, *nname; - - /* Localize the names in the default apps menu. */ - - apps = [(NSDictionary *)defaults objectForKey:@PREFS_APPSMENU]; - if (apps != nil) { - count = [apps count]; - for (i = 0; i < count; i++) { - elt = [apps objectAtIndex:i]; - if (elt != nil && [elt isKindOfClass:[NSArray class]]) { - name = [elt objectAtIndex:0]; - if (name != nil) { - nname = NSLocalizedString (name, nil); - if (nname != nil && nname != name) - [elt replaceObjectAtIndex:0 withObject:nname]; - } - } - } - } - } - } - - if (defaults != NULL) value = CFDictionaryGetValue (defaults, key); - if (value != NULL) CFRetain (value); - } - - return value; -} - -- (int) prefs_get_integer:(NSString *)key default:(int)def { - CFPropertyListRef value; - int ret; - - value = [self prefs_get:key]; - - if (value != NULL && CFGetTypeID (value) == CFNumberGetTypeID ()) - CFNumberGetValue (value, kCFNumberIntType, &ret); - else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ()) - ret = CFStringGetIntValue (value); - else - ret = def; - - if (value != NULL) CFRelease (value); - - return ret; -} - -- (const char *) prefs_get_string:(NSString *)key default:(const char *)def { - CFPropertyListRef value; - const char *ret = NULL; - - value = [self prefs_get:key]; - - if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ()) { - NSString *s = (NSString *) value; - - ret = [s UTF8String]; - } - - if (value != NULL) CFRelease (value); - - return ret != NULL ? ret : def; -} - -- (float) prefs_get_float:(NSString *)key default:(float)def { - CFPropertyListRef value; - float ret = def; - - value = [self prefs_get:key]; - - if (value != NULL - && CFGetTypeID (value) == CFNumberGetTypeID () - && CFNumberIsFloatType (value)) - CFNumberGetValue (value, kCFNumberFloatType, &ret); - else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ()) - ret = CFStringGetDoubleValue (value); - - if (value != NULL) CFRelease (value); - - return ret; -} - -- (int) prefs_get_boolean:(NSString *)key default:(int)def { - CFPropertyListRef value; - int ret = def; - - value = [self prefs_get:key]; - - if (value != NULL) { - if (CFGetTypeID (value) == CFNumberGetTypeID ()) - CFNumberGetValue (value, kCFNumberIntType, &ret); - else if (CFGetTypeID (value) == CFBooleanGetTypeID ()) - ret = CFBooleanGetValue (value); - else if (CFGetTypeID (value) == CFStringGetTypeID ()) { - const char *tem = [(NSString *) value lossyCString]; - if (strcasecmp (tem, "true") == 0 || strcasecmp (tem, "yes") == 0) - ret = YES; - else - ret = NO; - } - - CFRelease (value); - } - return ret; -} - -- (NSArray *) prefs_get_array:(NSString *)key { - NSArray *ret = nil; - CFPropertyListRef value; - - value = [self prefs_get:key]; - - if (value != NULL) { - if (CFGetTypeID (value) == CFArrayGetTypeID ()) - ret = [cfarray_to_nsarray (value) autorelease]; - - CFRelease (value); - } - - return ret; -} - -- (void) prefs_set_integer:(NSString *)key value:(int)value { - CFNumberRef x; - - x = CFNumberCreate (NULL, kCFNumberIntType, &value); - - CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, CFSTR (APP_PREFS), - kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - - CFRelease (x); -} - -- (void) prefs_set_float:(NSString *)key value:(float)value { - CFNumberRef x; - - x = CFNumberCreate (NULL, kCFNumberFloatType, &value); - - CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, CFSTR (APP_PREFS), - kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - - CFRelease (x); -} - -- (void) prefs_set_boolean:(NSString *)key value:(int)value { - CFPreferencesSetValue ((CFStringRef) key, - (CFTypeRef) value ? kCFBooleanTrue - : kCFBooleanFalse, CFSTR (APP_PREFS), - kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - -} - -- (void) prefs_set_array:(NSString *)key value:(NSArray *)value { - CFArrayRef cfarray; - - cfarray = nsarray_to_cfarray (value); - CFPreferencesSetValue ((CFStringRef) key, - (CFTypeRef) cfarray, - CFSTR (APP_PREFS), - kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - CFRelease (cfarray); -} - -- (void) prefs_set_string:(NSString *)key value:(NSString *)value { - CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) value, - CFSTR (APP_PREFS), kCFPreferencesCurrentUser, - kCFPreferencesAnyHost); -} - -- (void) prefs_synchronize { - CFPreferencesAppSynchronize (kCFPreferencesCurrentApplication); -} - -- (void) read_defaults -{ - const char *tem; - - quartzUseSysBeep = [self prefs_get_boolean:@PREFS_SYSBEEP - default:quartzUseSysBeep]; - quartzEnableRootless = [self prefs_get_boolean:@PREFS_ROOTLESS - default:quartzEnableRootless]; -#ifdef DARWIN_DDX_MISSING - quartzFullscreenDisableHotkeys = ![self prefs_get_boolean: - @PREFS_FULLSCREEN_HOTKEYS default: - !quartzFullscreenDisableHotkeys]; - quartzXpluginOptions = [self prefs_get_integer:@PREFS_XP_OPTIONS - default:quartzXpluginOptions]; -#endif - - darwinSwapAltMeta = [self prefs_get_boolean:@PREFS_SWAP_ALT_META - default:darwinSwapAltMeta]; - darwinFakeButtons = [self prefs_get_boolean:@PREFS_FAKEBUTTONS - default:darwinFakeButtons]; - if (darwinFakeButtons) { - const char *fake2, *fake3; - - fake2 = [self prefs_get_string:@PREFS_FAKE_BUTTON2 default:NULL]; - fake3 = [self prefs_get_string:@PREFS_FAKE_BUTTON3 default:NULL]; - - if (fake2 != NULL) darwinFakeMouse2Mask = DarwinParseModifierList(fake2); - if (fake3 != NULL) darwinFakeMouse3Mask = DarwinParseModifierList(fake3); - } - - X11EnableKeyEquivalents = [self prefs_get_boolean:@PREFS_KEYEQUIVS - default:X11EnableKeyEquivalents]; - - darwinSyncKeymap = [self prefs_get_boolean:@PREFS_SYNC_KEYMAP - default:darwinSyncKeymap]; - - tem = [self prefs_get_string:@PREFS_KEYMAP_FILE default:NULL]; - if (tem != NULL) darwinKeymapFile = strdup (tem); - else darwinKeymapFile = NULL; - - darwinDesiredDepth = [self prefs_get_integer:@PREFS_DEPTH - default:darwinDesiredDepth]; - - enable_stereo = [self prefs_get_boolean:@PREFS_ENABLE_STEREO - default:false]; -} - -/* This will end up at the end of the responder chain. */ -- (void) copy:sender { - QuartzMessageServerThread (kXDarwinPasteboardNotify, 1, - AppleWMCopyToPasteboard); -} - -- (BOOL) x_active { - return _x_active; -} - -@end - -static NSArray * -array_with_strings_and_numbers (int nitems, const char **items, - const char *numbers) { - NSMutableArray *array, *subarray; - NSString *string, *number; - int i; - - /* (Can't autorelease on the X server thread) */ - - array = [[NSMutableArray alloc] initWithCapacity:nitems]; - - for (i = 0; i < nitems; i++) { - subarray = [[NSMutableArray alloc] initWithCapacity:2]; - - string = [[NSString alloc] initWithUTF8String:items[i]]; - [subarray addObject:string]; - [string release]; - - if (numbers[i] != 0) { - number = [[NSString alloc] initWithFormat:@"%d", numbers[i]]; - [subarray addObject:number]; - [number release]; - } else - [subarray addObject:@""]; - - [array addObject:subarray]; - [subarray release]; - } - - return array; -} - -void X11ApplicationSetWindowMenu (int nitems, const char **items, - const char *shortcuts) { - NSArray *array; - array = array_with_strings_and_numbers (nitems, items, shortcuts); - - /* Send the array of strings over to the appkit thread */ - - message_kit_thread (@selector (set_window_menu:), array); - [array release]; -} - -void X11ApplicationSetWindowMenuCheck (int idx) { - NSNumber *n; - - n = [[NSNumber alloc] initWithInt:idx]; - - message_kit_thread (@selector (set_window_menu_check:), n); - - [n release]; -} - -void X11ApplicationSetFrontProcess (void) { - message_kit_thread (@selector (set_front_process:), nil); -} - -void X11ApplicationSetCanQuit (int state) { - NSNumber *n; - - n = [[NSNumber alloc] initWithBool:state]; - - message_kit_thread (@selector (set_can_quit:), n); - - [n release]; -} - -void X11ApplicationServerReady (void) { - message_kit_thread (@selector (server_ready:), nil); -} - -void X11ApplicationShowHideMenubar (int state) { - NSNumber *n; - - n = [[NSNumber alloc] initWithBool:state]; - - message_kit_thread (@selector (show_hide_menubar:), n); - - [n release]; -} - -static void * create_thread (void *func, void *arg) { - pthread_attr_t attr; - pthread_t tid; - - pthread_attr_init (&attr); - pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM); - pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); - pthread_create (&tid, &attr, func, arg); - pthread_attr_destroy (&attr); - - return (void *) tid; -} - -static void check_xinitrc (void) { - char *tem, buf[1024]; - NSString *msg; - - if ([X11App prefs_get_boolean:@PREFS_DONE_XINIT_CHECK default:NO]) - return; - - tem = getenv ("HOME"); - if (tem == NULL) goto done; - - snprintf (buf, sizeof (buf), "%s/.xinitrc", tem); - if (access (buf, F_OK) != 0) - goto done; - - /* FIXME: put localized strings into Resources/English.lproj */ - - msg = NSLocalizedString (@"You have an existing ~/.xinitrc file.\n\n\ -Windows displayed by X11 applications may not have titlebars, or may look \ -different to windows displayed by native applications.\n\n\ -Would you like to move aside the existing file and use the standard X11 \ -environment?", @"Startup xinitrc dialog"); - - if (NSRunAlertPanel (nil, msg, NSLocalizedString (@"Yes", @""), - NSLocalizedString (@"No", @""), nil) - == NSAlertDefaultReturn) { - char buf2[1024]; - int i = -1; - - snprintf (buf2, sizeof (buf2), "%s.old", buf); - - for (i = 1; access (buf2, F_OK) == 0; i++) - snprintf (buf2, sizeof (buf2), "%s.old.%d", buf, i); - - rename (buf, buf2); - } - - done: - [X11App prefs_set_boolean:@PREFS_DONE_XINIT_CHECK value:YES]; - [X11App prefs_synchronize]; -} - -void X11ApplicationMain (int argc, const char *argv[], - void (*server_thread) (void *), void *server_arg) { - NSAutoreleasePool *pool; - -#ifdef DEBUG - while (access ("/tmp/x11-block", F_OK) == 0) sleep (1); -#endif - - pool = [[NSAutoreleasePool alloc] init]; - X11App = (X11Application *) [X11Application sharedApplication]; - init_ports (); - [NSApp read_defaults]; - [NSBundle loadNibNamed:@"main" owner:NSApp]; - [[NSNotificationCenter defaultCenter] addObserver:NSApp - selector:@selector (became_key:) - name:NSWindowDidBecomeKeyNotification object:nil]; - check_xinitrc (); - - /* - * The xpr Quartz mode is statically linked into this server. - * Initialize all the Quartz functions. - */ - QuartzModeBundleInit(); - - /* Calculate the height of the menubar so we can avoid it. */ - aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) - - NSMaxY([[NSScreen mainScreen] visibleFrame]); - - if (!create_thread (server_thread, server_arg)) { - ErrorF("can't create secondary thread\n"); - exit (1); - } - - [NSApp run]; - - /* not reached */ -} - - -/* event conversion */ - -static inline unsigned short -convert_flags (unsigned int nsflags) { - unsigned int xflags = 0; - - if (nsflags == ~0) return 0xffff; - - if (nsflags & NSAlphaShiftKeyMask) xflags |= LockMask; - if (nsflags & NSShiftKeyMask) xflags |= ShiftMask; - if (nsflags & NSControlKeyMask) xflags |= ControlMask; - if (nsflags & NSAlternateKeyMask) xflags |= Mod1Mask; - if (nsflags & NSCommandKeyMask) xflags |= Mod2Mask; - /* FIXME: secondaryfn? */ - - return xflags; -} - - -// This code should probably be merged with that in XDarwin's XServer.m - BB -static void send_nsevent (NSEventType type, NSEvent *e) { - // static unsigned int button_state = 0; - NSRect screen; - NSPoint location; - NSWindow *window; - int pointer_x, pointer_y, ev_button, ev_type; - // int num_events=0, i=0, state; - xEvent xe; - - /* convert location to global top-left coordinates */ - location = [e locationInWindow]; - window = [e window]; - screen = [[[NSScreen screens] objectAtIndex:0] frame]; - - if (window != nil) { - NSRect frame = [window frame]; - pointer_x = location.x + frame.origin.x; - pointer_y = (((screen.origin.y + screen.size.height) - - location.y) - frame.origin.y); - } else { - pointer_x = location.x; - pointer_y = (screen.origin.y + screen.size.height) - location.y; - } - - pointer_y -= aquaMenuBarHeight; - // state = convert_flags ([e modifierFlags]); - - switch (type) { - case NSLeftMouseDown: ev_button=1; ev_type=ButtonPress; goto handle_mouse; - case NSOtherMouseDown: ev_button=2; ev_type=ButtonPress; goto handle_mouse; - case NSRightMouseDown: ev_button=3; ev_type=ButtonPress; goto handle_mouse; - case NSLeftMouseUp: ev_button=1; ev_type=ButtonRelease; goto handle_mouse; - case NSOtherMouseUp: ev_button=2; ev_type=ButtonRelease; goto handle_mouse; - case NSRightMouseUp: ev_button=3; ev_type=ButtonRelease; goto handle_mouse; - case NSLeftMouseDragged: ev_button=1; ev_type=MotionNotify; goto handle_mouse; - case NSOtherMouseDragged: ev_button=2; ev_type=MotionNotify; goto handle_mouse; - case NSRightMouseDragged: ev_button=3; ev_type=MotionNotify; goto handle_mouse; - case NSMouseMoved: ev_button=0; ev_type=MotionNotify; goto handle_mouse; - handle_mouse: - - /* I'm not sure the below code is necessary or useful (-bb) - if(ev_type==ButtonPress) { - if (!quartzProcs->IsX11Window([e window], [e windowNumber])) { - fprintf(stderr, "Dropping event because it's not a window\n"); - break; - } - button_state |= (1 << ev_button); - DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y); - } else if (ev_type==ButtonRelease && (button_state & (1 << ev_button)) == 0) break; - */ - DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y); - break; - case NSScrollWheel: - DarwinSendScrollEvents([e deltaY], pointer_x, pointer_y); - break; - - case NSKeyDown: // do we need to translate these keyCodes? - case NSKeyUp: - DarwinSendKeyboardEvents((type == NSKeyDown)?KeyPress:KeyRelease, [e keyCode]); - break; - - case NSFlagsChanged: - DarwinUpdateModKeys([e modifierFlags]); - break; - default: break; /* for gcc */ - } -} diff --git a/hw/darwin/apple/X11Controller.h b/hw/darwin/apple/X11Controller.h deleted file mode 100644 index 8d17fd9c3..000000000 --- a/hw/darwin/apple/X11Controller.h +++ /dev/null @@ -1,85 +0,0 @@ -/* X11Controller.h -- connect the IB ui - - 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 */ diff --git a/hw/darwin/apple/X11Controller.m b/hw/darwin/apple/X11Controller.m deleted file mode 100644 index fbc9c7402..000000000 --- a/hw/darwin/apple/X11Controller.m +++ /dev/null @@ -1,747 +0,0 @@ -/* X11Controller.m -- connect the IB ui, also the NSApp delegate - - 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 "opaque.h" -# include "darwin.h" -# include "../quartz/quartz.h" -# define _APPLEWM_SERVER_ -# include "X11/extensions/applewm.h" -# include "../quartz/applewmExt.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 *argv[7]; - int child1, child2 = 0; - int status; - - argv[0] = "/usr/bin/login"; - argv[1] = "-fp"; - argv[2] = getlogin(); - argv[3] = "/bin/sh"; - argv[4] = "-c"; - argv[5] = command; - argv[6] = 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 ((CFStringRef)NSLocalizedString(@"Mac Help", no comment), 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); -} diff --git a/hw/darwin/apple/Xquartz.man b/hw/darwin/apple/Xquartz.man deleted file mode 100644 index edac30ee9..000000000 --- a/hw/darwin/apple/Xquartz.man +++ /dev/null @@ -1,158 +0,0 @@ -.\" $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 |