diff options
Diffstat (limited to 'hw/darwin')
31 files changed, 1891 insertions, 530 deletions
diff --git a/hw/darwin/bundle/Dutch.lproj/Localizable.strings b/hw/darwin/bundle/Dutch.lproj/Localizable.strings Binary files differindex 22d7683eb..6abd91072 100644 --- a/hw/darwin/bundle/Dutch.lproj/Localizable.strings +++ b/hw/darwin/bundle/Dutch.lproj/Localizable.strings diff --git a/hw/darwin/bundle/English.lproj/Localizable.strings b/hw/darwin/bundle/English.lproj/Localizable.strings index 6025a2469..241d1585b 100644 --- a/hw/darwin/bundle/English.lproj/Localizable.strings +++ b/hw/darwin/bundle/English.lproj/Localizable.strings @@ -1,5 +1,5 @@ /* English localized versions of strings used by the Mac OS X front end. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/Localizable.strings,v 1.3 2002/01/30 06:50:46 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/Localizable.strings,v 1.4 2003/11/04 22:48:14 torrey Exp $ */ /* Title of alert panel */ "Quit X server?" = "Quit X server?"; @@ -14,10 +14,10 @@ "Cancel" = "Cancel"; /* Default keymapping file */ -"USA.keymapping" = "USA.keymapping" +"USA.keymapping" = "USA.keymapping"; /* Default switch string */ -"Cmd-Opt-a" = "Cmd-Opt-a" +"Cmd-Opt-a" = "Cmd-Opt-a"; /* Button title when changing switch key */ -"Press key" = "Press key" +"Press key" = "Press key"; diff --git a/hw/darwin/bundle/English.lproj/MainMenu.nib/classes.nib b/hw/darwin/bundle/English.lproj/MainMenu.nib/classes.nib index ba1e3a206..77f345a4e 100644 --- a/hw/darwin/bundle/English.lproj/MainMenu.nib/classes.nib +++ b/hw/darwin/bundle/English.lproj/MainMenu.nib/classes.nib @@ -41,14 +41,20 @@ }, { ACTIONS = { + bringAllToFront = id; closeHelpAndShow = id; + itemSelected = id; + nextWindow = id; + previousWindow = id; showAction = id; + showSwitchPanel = id; startFullScreen = id; startRootless = id; }; CLASS = XServer; LANGUAGE = ObjC; OUTLETS = { + dockMenu = NSMenu; helpWindow = NSWindow; modeWindow = NSWindow; startFullScreenButton = NSButton; @@ -56,6 +62,8 @@ startupHelpButton = NSButton; startupModeButton = NSButton; switchWindow = NSPanel; + windowMenu = NSMenu; + windowSeparator = NSMenuItem; }; SUPERCLASS = NSObject; } diff --git a/hw/darwin/bundle/English.lproj/MainMenu.nib/objects.nib b/hw/darwin/bundle/English.lproj/MainMenu.nib/objects.nib Binary files differindex 7aedf01c2..5aa102278 100644 --- a/hw/darwin/bundle/English.lproj/MainMenu.nib/objects.nib +++ b/hw/darwin/bundle/English.lproj/MainMenu.nib/objects.nib diff --git a/hw/darwin/bundle/French.lproj/Localizable.strings b/hw/darwin/bundle/French.lproj/Localizable.strings Binary files differindex 591f73cae..21c4a99c1 100644 --- a/hw/darwin/bundle/French.lproj/Localizable.strings +++ b/hw/darwin/bundle/French.lproj/Localizable.strings diff --git a/hw/darwin/bundle/German.lproj/Localizable.strings b/hw/darwin/bundle/German.lproj/Localizable.strings Binary files differindex 365cc291a..5db6306ec 100644 --- a/hw/darwin/bundle/German.lproj/Localizable.strings +++ b/hw/darwin/bundle/German.lproj/Localizable.strings diff --git a/hw/darwin/bundle/Japanese.lproj/Localizable.strings b/hw/darwin/bundle/Japanese.lproj/Localizable.strings Binary files differindex 091138dd5..c5c26d61a 100644 --- a/hw/darwin/bundle/Japanese.lproj/Localizable.strings +++ b/hw/darwin/bundle/Japanese.lproj/Localizable.strings diff --git a/hw/darwin/bundle/Portuguese.lproj/Localizable.strings b/hw/darwin/bundle/Portuguese.lproj/Localizable.strings Binary files differindex b3edbb41d..c79b282f6 100644 --- a/hw/darwin/bundle/Portuguese.lproj/Localizable.strings +++ b/hw/darwin/bundle/Portuguese.lproj/Localizable.strings diff --git a/hw/darwin/bundle/Spanish.lproj/Localizable.strings b/hw/darwin/bundle/Spanish.lproj/Localizable.strings Binary files differindex 06eb0e5fb..5bf813f1f 100644 --- a/hw/darwin/bundle/Spanish.lproj/Localizable.strings +++ b/hw/darwin/bundle/Spanish.lproj/Localizable.strings diff --git a/hw/darwin/bundle/Swedish.lproj/Localizable.strings b/hw/darwin/bundle/Swedish.lproj/Localizable.strings Binary files differindex 7ade67d55..9709e5469 100644 --- a/hw/darwin/bundle/Swedish.lproj/Localizable.strings +++ b/hw/darwin/bundle/Swedish.lproj/Localizable.strings diff --git a/hw/darwin/bundle/ko.lproj/Localizable.strings b/hw/darwin/bundle/ko.lproj/Localizable.strings Binary files differindex 2e7137b05..fb8c77e0d 100644 --- a/hw/darwin/bundle/ko.lproj/Localizable.strings +++ b/hw/darwin/bundle/ko.lproj/Localizable.strings diff --git a/hw/darwin/darwin.c b/hw/darwin/darwin.c index ff5ae1b33..a7a0d839c 100644 --- a/hw/darwin/darwin.c +++ b/hw/darwin/darwin.c @@ -1,11 +1,11 @@ /************************************************************** * * Shared code for the Darwin X Server - * running with Quartz or the IOKit + * running with Quartz or IOKit display mode * **************************************************************/ /* - * Copyright (c) 2001-2002 Torrey T. Lyons. All Rights Reserved. + * Copyright (c) 2001-2003 Torrey T. Lyons. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -29,7 +29,7 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/darwin.c,v 1.50 2003/02/26 09:21:33 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/darwin.c,v 1.55 2003/11/15 00:07:09 torrey Exp $ */ #include "X.h" #include "Xproto.h" @@ -52,6 +52,7 @@ #include <sys/syslimits.h> #include <stdio.h> #include <fcntl.h> +#include <unistd.h> #define NO_CFPLUGIN #include <IOKit/IOKitLib.h> @@ -60,8 +61,6 @@ #include "darwin.h" #include "darwinClut8.h" -#include "quartz/quartz.h" -#include "xfIOKit.h" /* * X server shared global variables @@ -69,9 +68,9 @@ int darwinScreensFound = 0; int darwinScreenIndex = 0; io_connect_t darwinParamConnect = 0; -int darwinEventFD = -1; -Bool quartz = FALSE; -int quartzMouseAccelChange = 1; +int darwinEventReadFD = -1; +int darwinEventWriteFD = -1; +int darwinMouseAccelChange = 1; int darwinFakeButtons = 0; // location of X11's (0,0) point in global screen coordinates @@ -113,7 +112,7 @@ const int NUMFORMATS = sizeof(formats)/sizeof(formats[0]); #define PRE_RELEASE XF86_VERSION_SNAP #endif -static void +void DarwinPrintBanner() { #if PRE_RELEASE @@ -193,11 +192,7 @@ static Bool DarwinAddScreen( SCREEN_PRIV(pScreen) = dfb; // setup hardware/mode specific details - if (quartz) { - ret = QuartzAddScreen(foundIndex, pScreen); - } else { - ret = XFIOKitAddScreen(foundIndex, pScreen); - } + ret = DarwinModeAddScreen(foundIndex, pScreen); foundIndex++; if (! ret) return FALSE; @@ -276,14 +271,8 @@ static Bool DarwinAddScreen( pScreen->SaveScreen = DarwinSaveScreen; // finish mode dependent screen setup including cursor support - if (quartz) { - if (! QuartzSetupScreen(index, pScreen)) { - return FALSE; - } - } else { - if (! XFIOKitSetupScreen(index, pScreen)) { - return FALSE; - } + if (!DarwinModeSetupScreen(index, pScreen)) { + return FALSE; } // create and install the default colormap and @@ -337,7 +326,7 @@ static void DarwinChangePointerControl( kern_return_t kr; double acceleration; - if (!quartzMouseAccelChange) + if (!darwinMouseAccelChange) return; acceleration = ctrl->num / ctrl->den; @@ -378,13 +367,13 @@ static int DarwinMouseProc( case DEVICE_ON: pPointer->public.on = TRUE; - AddEnabledDevice( darwinEventFD ); + AddEnabledDevice( darwinEventReadFD ); return Success; case DEVICE_CLOSE: case DEVICE_OFF: pPointer->public.on = FALSE; - RemoveEnabledDevice( darwinEventFD ); + RemoveEnabledDevice( darwinEventReadFD ); return Success; } @@ -404,11 +393,11 @@ static int DarwinKeybdProc( DeviceIntPtr pDev, int onoff ) break; case DEVICE_ON: pDev->public.on = TRUE; - AddEnabledDevice( darwinEventFD ); + AddEnabledDevice( darwinEventReadFD ); break; case DEVICE_OFF: pDev->public.on = FALSE; - RemoveEnabledDevice( darwinEventFD ); + RemoveEnabledDevice( darwinEventReadFD ); break; case DEVICE_CLOSE: break; @@ -529,12 +518,61 @@ void InitInput( int argc, char **argv ) darwinKeyboard = AddInputDevice(DarwinKeybdProc, TRUE); RegisterKeyboardDevice( darwinKeyboard ); - DarwinEQInit( (DevicePtr)darwinKeyboard, (DevicePtr)darwinPointer ); + if (serverGeneration == 1) { + DarwinEQInit( (DevicePtr)darwinKeyboard, (DevicePtr)darwinPointer ); + } - if (quartz) { - QuartzInitInput(argc, argv); - } else { - XFIOKitInitInput(argc, argv); + DarwinModeInitInput(argc, argv); +} + + +/* + * DarwinAdjustScreenOrigins + * Shift all screens so the X11 (0, 0) coordinate is at the top + * left of the global screen coordinates. + * + * Screens can be arranged so the top left isn't on any screen, so + * instead use the top left of the leftmost screen as (0,0). This + * may mean some screen space is in -y, but it's better that (0,0) + * be onscreen, or else default xterms disappear. It's better that + * -y be used than -x, because when popup menus are forced + * "onscreen" by dumb window managers like twm, they'll shift the + * menus down instead of left, which still looks funny but is an + * easier target to hit. + */ +void +DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo) +{ + int i, left, top; + + left = dixScreenOrigins[0].x; + top = dixScreenOrigins[0].y; + + /* Find leftmost screen. If there's a tie, take the topmost of the two. */ + for (i = 1; i < pScreenInfo->numScreens; i++) { + if (dixScreenOrigins[i].x < left || + (dixScreenOrigins[i].x == left && + dixScreenOrigins[i].y < top)) + { + left = dixScreenOrigins[i].x; + top = dixScreenOrigins[i].y; + } + } + + darwinMainScreenX = left; + darwinMainScreenY = top; + + /* Shift all screens so that there is a screen whose top left + is at X11 (0,0) and at global screen coordinate + (darwinMainScreenX, darwinMainScreenY). */ + + if (darwinMainScreenX != 0 || darwinMainScreenY != 0) { + for (i = 0; i < pScreenInfo->numScreens; i++) { + dixScreenOrigins[i].x -= darwinMainScreenX; + dixScreenOrigins[i].y -= darwinMainScreenY; + ErrorF("Screen %d placed at X11 coordinate (%d,%d).\n", + i, dixScreenOrigins[i].x, dixScreenOrigins[i].y); + } } } @@ -554,7 +592,7 @@ void InitInput( int argc, char **argv ) */ void InitOutput( ScreenInfo *pScreenInfo, int argc, char **argv ) { - int i, left, top; + int i; static unsigned long generation = 0; pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER; @@ -574,55 +612,14 @@ void InitOutput( ScreenInfo *pScreenInfo, int argc, char **argv ) } // Discover screens and do mode specific initialization - if (quartz) { - QuartzInitOutput(argc, argv); - } else { - XFIOKitInitOutput(argc, argv); - } + DarwinModeInitOutput(argc, argv); // Add screens for (i = 0; i < darwinScreensFound; i++) { AddScreen( DarwinAddScreen, argc, argv ); } - // Shift all screens so the X11 (0, 0) coordinate is at the top left - // of the global screen coordinates. - // Screens can be arranged so the top left isn't on any screen, - // so instead use the top left of the leftmost screen as (0,0). - // This may mean some screen space is in -y, but it's better - // that (0,0) be onscreen, or else default xterms disappear. - // It's better that -y be used than -x, because when popup - // menus are forced "onscreen" by dumb window managers like twm, - // they'll shift the menus down instead of left, which still looks - // funny but is an easier target to hit. - left = dixScreenOrigins[0].x; - top = dixScreenOrigins[0].y; - - // Find leftmost screen. If there's a tie, take the topmost of the two. - for (i = 1; i < pScreenInfo->numScreens; i++) { - if (dixScreenOrigins[i].x < left || - (dixScreenOrigins[i].x == left && - dixScreenOrigins[i].y < top)) - { - left = dixScreenOrigins[i].x; - top = dixScreenOrigins[i].y; - } - } - - darwinMainScreenX = left; - darwinMainScreenY = top; - - // Shift all screens so that there is a screen whose top left - // is at X11 (0,0) and at global screen coordinate - // (darwinMainScreenX, darwinMainScreenY). - if (darwinMainScreenX != 0 || darwinMainScreenY != 0) { - for (i = 0; i < pScreenInfo->numScreens; i++) { - dixScreenOrigins[i].x -= darwinMainScreenX; - dixScreenOrigins[i].y -= darwinMainScreenY; - ErrorF("Screen %d placed at X11 coordinate (%d,%d).\n", - i, dixScreenOrigins[i].x, dixScreenOrigins[i].y); - } - } + DarwinAdjustScreenOrigins(pScreenInfo); } @@ -648,13 +645,16 @@ void OsVendorInit(void) // Find the full path to the keymapping file. if ( darwinKeymapFile ) { char *tempStr = DarwinFindLibraryFile(darwinKeymapFile, "Keyboards"); - if ( !tempStr ) - FatalError("Could not find keymapping file %s.\n", - darwinKeymapFile); + if ( !tempStr ) { + ErrorF("Could not find keymapping file %s.\n", darwinKeymapFile); + } else { + ErrorF("Using keymapping provided in %s.\n", tempStr); + } darwinKeymapFile = tempStr; - ErrorF("Using keymapping provided in %s.\n", darwinKeymapFile); - } else { - ErrorF("Reading keymapping from the kernel.\n"); + } + + if ( !darwinKeymapFile ) { + ErrorF("Reading keymap from the system.\n"); } } @@ -667,12 +667,10 @@ void OsVendorInit(void) */ int ddxProcessArgument( int argc, char *argv[], int i ) { -#ifdef DARWIN_WITH_QUARTZ int numDone; - if ((numDone = QuartzProcessArgument( argc, argv, i ))) + if ((numDone = DarwinModeProcessArgument( argc, argv, i ))) return numDone; -#endif if ( !strcmp( argv[i], "-fakebuttons" ) ) { darwinFakeButtons = TRUE; @@ -833,11 +831,7 @@ void ddxGiveUp( void ) { ErrorF( "Quitting XDarwin...\n" ); - if (quartz) { - QuartzGiveUp(); - } else { - XFIOKitGiveUp(); - } + DarwinModeGiveUp(); } diff --git a/hw/darwin/darwin.h b/hw/darwin/darwin.h index 62698d74a..79fa00ffc 100644 --- a/hw/darwin/darwin.h +++ b/hw/darwin/darwin.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2002 Torrey T. Lyons. All Rights Reserved. + * Copyright (c) 2001-2003 Torrey T. Lyons. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -23,16 +23,15 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/darwin.h,v 1.15 2002/12/10 00:00:38 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/darwin.h,v 1.20 2003/11/15 00:07:09 torrey Exp $ */ #ifndef _DARWIN_H #define _DARWIN_H #include <IOKit/IOTypes.h> #include "inputstr.h" -#include "screenint.h" +#include "scrnintstr.h" #include "extensions/XKB.h" -#include "quartz/quartzShared.h" typedef struct { void *framebuffer; @@ -48,6 +47,9 @@ typedef struct { } DarwinFramebufferRec, *DarwinFramebufferPtr; +// From darwin.c +void DarwinPrintBanner(); +void DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo); void xf86SetRootClip (ScreenPtr pScreen, BOOL enable); // From darwinEvents.c @@ -64,6 +66,17 @@ int DarwinModifierNXKeyToNXMask(int key); int DarwinModifierNXMaskToNXKey(int mask); int DarwinModifierStringToNXKey(const char *string); +// Mode specific functions +Bool DarwinModeAddScreen(int index, ScreenPtr pScreen); +Bool DarwinModeSetupScreen(int index, ScreenPtr pScreen); +void DarwinModeInitOutput(int argc,char **argv); +void DarwinModeInitInput(int argc, char **argv); +int DarwinModeProcessArgument(int argc, char *argv[], int i); +void DarwinModeProcessEvent(xEvent *xe); +void DarwinModeGiveUp(void); +void DarwinModeBell(int volume, DeviceIntPtr pDevice, pointer ctrl, int class); + + #undef assert #define assert(x) { if ((x) == 0) \ FatalError("assert failed on line %d of %s!\n", __LINE__, __FILE__); } @@ -76,31 +89,60 @@ int DarwinModifierStringToNXKey(const char *string); #define MIN_KEYCODE XkbMinLegalKeyCode // unfortunately, this isn't 0... + /* * Global variables from darwin.c */ extern int darwinScreenIndex; // index into pScreen.devPrivates extern int darwinScreensFound; extern io_connect_t darwinParamConnect; -extern int darwinEventFD; -extern Bool quartz; +extern int darwinEventReadFD; +extern int darwinEventWriteFD; + +// User preferences +extern int darwinMouseAccelChange; +extern int darwinFakeButtons; +extern int darwinFakeMouse2Mask; +extern int darwinFakeMouse3Mask; +extern char *darwinKeymapFile; +extern unsigned int darwinDesiredWidth, darwinDesiredHeight; +extern int darwinDesiredDepth; +extern int darwinDesiredRefresh; + +// location of X11's (0,0) point in global screen coordinates +extern int darwinMainScreenX; +extern int darwinMainScreenY; + /* * Special ddx events understood by the X server */ enum { - kXDarwinUpdateModifiers // update all modifier keys - = LASTEvent+1, // (from X.h list of event names) - kXDarwinUpdateButtons, // update state of mouse buttons 2 and up - kXDarwinScrollWheel, // scroll wheel event - kXDarwinShow, // vt switch to X server; - // recapture screen and restore X drawing - kXDarwinHide, // vt switch away from X server; - // release screen and clip X drawing - kXDarwinSetRootClip, // enable or disable drawing to the X screen - kXDarwinQuit, // kill the X server and release the display - kXDarwinReadPasteboard, // copy Mac OS X pasteboard into X cut buffer - kXDarwinWritePasteboard // copy X cut buffer onto Mac OS X pasteboard + kXDarwinUpdateModifiers // update all modifier keys + = LASTEvent+1, // (from X.h list of event names) + kXDarwinUpdateButtons, // update state of mouse buttons 2 and up + kXDarwinScrollWheel, // scroll wheel event + + /* + * Quartz-specific events -- not used in IOKit mode + */ + kXDarwinActivate, // restore X drawing and cursor + kXDarwinDeactivate, // clip X drawing and switch to Aqua cursor + kXDarwinSetRootClip, // enable or disable drawing to the X screen + kXDarwinQuit, // kill the X server and release the display + kXDarwinReadPasteboard, // copy Mac OS X pasteboard into X cut buffer + kXDarwinWritePasteboard, // copy X cut buffer onto Mac OS X pasteboard + /* + * AppleWM events + */ + kXDarwinControllerNotify, // send an AppleWMControllerNotify event + kXDarwinPasteboardNotify, // notify the WM to copy or paste + /* + * Xplugin notification events + */ + kXDarwinDisplayChanged, // display configuration has changed + kXDarwinWindowState, // window visibility state has changed + kXDarwinWindowMoved // window has moved on screen }; #endif /* _DARWIN_H */ diff --git a/hw/darwin/darwinClut8.h b/hw/darwin/darwinClut8.h index 06e7b71c5..68a7ad16f 100644 --- a/hw/darwin/darwinClut8.h +++ b/hw/darwin/darwinClut8.h @@ -1,7 +1,7 @@ /* * Darwin default 8-bit Colormap for StaticColor */ -/* $XFree86: xc/programs/Xserver/hw/darwin/darwinClut8.h,v 1.1.8.1 2003/03/04 01:31:43 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/darwinClut8.h,v 1.2 2003/03/04 01:37:59 torrey Exp $ */ #ifndef _DARWIN_CLUT8_ #define _DARWIN_CLUT8_ diff --git a/hw/darwin/darwinEvents.c b/hw/darwin/darwinEvents.c index 72d7eff05..ba1ec8fc2 100644 --- a/hw/darwin/darwinEvents.c +++ b/hw/darwin/darwinEvents.c @@ -28,6 +28,7 @@ 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. */ +/* $XFree86: xc/programs/Xserver/hw/darwin/darwinEvents.c,v 1.5 2003/11/03 05:36:30 tsi Exp $ */ #define NEED_EVENTS #include "X.h" @@ -42,7 +43,6 @@ in this Software without prior written authorization from The Open Group. #include "mipointer.h" #include "darwin.h" -#include "quartz/quartz.h" #include <sys/types.h> #include <sys/uio.h> @@ -181,6 +181,7 @@ DarwinEQEnqueue( const xEvent *e) { HWEventQueueType oldtail, newtail; + char byte = 0; oldtail = darwinEventQueue.tail; @@ -209,6 +210,9 @@ DarwinEQEnqueue( // Update the tail after the event is prepared darwinEventQueue.tail = newtail; + + // Signal there is an event ready to handle + write(darwinEventWriteFD, &byte, 1); } @@ -253,7 +257,7 @@ void ProcessInputEvents(void) // Empty the signaling pipe x = sizeof(xe); while (x == sizeof(xe)) { - x = read(darwinEventFD, &xe, sizeof(xe)); + x = read(darwinEventReadFD, &xe, sizeof(xe)); } while (darwinEventQueue.head != darwinEventQueue.tail) @@ -425,11 +429,8 @@ void ProcessInputEvents(void) } default: - if (quartz) { - QuartzProcessEvent(&xe); - } else { - ErrorF("Unknown X event caught: %d\n", xe.u.u.type); - } + // Check for mode specific event + DarwinModeProcessEvent(&xe); } } } diff --git a/hw/darwin/darwinKeyboard.c b/hw/darwin/darwinKeyboard.c index 4113bacba..57bf5fa3d 100644 --- a/hw/darwin/darwinKeyboard.c +++ b/hw/darwin/darwinKeyboard.c @@ -2,7 +2,8 @@ // // Keyboard support for the Darwin X Server // -// Copyright (c) 2001-2002 Torrey T. Lyons. All Rights Reserved. +// Copyright (c) 2001-2003 Torrey T. Lyons. All Rights Reserved. +// Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. // // The code to parse the Darwin keymap is derived from dumpkeymap.c // by Eric Sunshine, which includes the following copyright: @@ -36,7 +37,7 @@ // //============================================================================= -/* $XFree86: xc/programs/Xserver/hw/darwin/darwinKeyboard.c,v 1.17 2002/12/10 00:00:38 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/darwinKeyboard.c,v 1.19 2003/11/01 08:13:08 torrey Exp $ */ /* =========================================================================== @@ -59,26 +60,18 @@ // in determining how the X server is interpreting the Darwin keymap. #undef DUMP_DARWIN_KEYMAP +/* Define this to use Alt for Mode_switch. */ +#define ALT_IS_MODE_SWITCH 1 + #include <drivers/event_status_driver.h> #include <IOKit/hidsystem/ev_keymap.h> #include <stdio.h> #include <stdlib.h> +#include <errno.h> #include <sys/stat.h> #include <architecture/byte_order.h> // For the NXSwap* #include "darwin.h" -#include "xfIOKit.h" -#include "quartz/quartzAudio.h" -#include "quartz/quartzShared.h" - -#define XK_TECHNICAL // needed to get XK_Escape -#define XK_PUBLISHING -#include "keysym.h" - -// Each key can generate 4 glyphs. They are, in order: -// unshifted, shifted, modeswitch unshifted, modeswitch shifted -#define GLYPHS_PER_KEY 4 -#define NUM_KEYCODES 248 // NX_NUMKEYCODES might be better -#define MAX_KEYCODE NUM_KEYCODES + MIN_KEYCODE - 1 +#include "darwinKeyboard.h" #define AltMask Mod1Mask #define MetaMask Mod2Mask @@ -224,11 +217,9 @@ static void DarwinChangeKeyboardControl( DeviceIntPtr device, KeybdCtrl *ctrl ) // keyclick, bell volume / pitch, autorepead, LED's } -static CARD8 modMap[MAP_LENGTH]; -static KeySym map[MAP_LENGTH * GLYPHS_PER_KEY]; -static unsigned char modifierKeycodes[NX_NUMMODIFIERS][2]; -static FILE *fref = NULL; -static char *inBuffer = NULL; +static darwinKeyboardInfo keyInfo; +static FILE *fref = NULL; +static char *inBuffer = NULL; //----------------------------------------------------------------------------- // Data Stream Object @@ -449,34 +440,18 @@ Bool DarwinReadKeymapFile( /* - * DarwinKeyboardInit - * Get the Darwin keyboard map and compute an equivalent - * X keyboard map and modifier map. Set the new keyboard - * device structure. + * DarwinParseNXKeyMapping */ -void DarwinKeyboardInit( - DeviceIntPtr pDev ) +Bool DarwinParseNXKeyMapping( + darwinKeyboardInfo *info) { KeySym *k; int i; short numMods, numKeys, numPadKeys = 0; - KeySymsRec keySyms; + Bool haveKeymap = FALSE; NXKeyMapping keyMap; DataStream *keyMapStream; unsigned char const *numPadStart = 0; - BellProcPtr bellProc; - Bool haveKeymap = FALSE; - - memset( modMap, NoSymbol, sizeof( modMap ) ); - memset( map, 0, sizeof( map ) ); - for (i = 0; i < NX_NUMMODIFIERS; i++) { - modifierKeycodes[i][0] = modifierKeycodes[i][1] = 0; - } - - // Open a shared connection to the HID System. - // Note that the Event Status Driver is really just a wrapper - // for a kIOHIDParamConnectType connection. - assert( darwinParamConnect = NXOpenEventStatus() ); if (darwinKeymapFile) { haveKeymap = DarwinReadKeymapFile(&keyMap); @@ -494,7 +469,7 @@ void DarwinKeyboardInit( keyMap.size = NXKeyMappingLength( darwinParamConnect ); keyMap.mapping = (char*) xalloc( keyMap.size ); if (!NXGetKeyMapping( darwinParamConnect, &keyMap )) { - FatalError("Could not get kernel keymapping! Load keymapping from file instead.\n"); + return FALSE; } } @@ -507,9 +482,7 @@ void DarwinKeyboardInit( ErrorF("Current 16-bit keymapping may not be interpreted correctly.\n"); } - // Compute the modifier map and - // insert X modifier KeySyms into keyboard map. - // Store modifier keycodes in modifierKeycodes. + // Insert X modifier KeySyms into the keyboard map. numMods = get_number(keyMapStream); while (numMods-- > 0) { int left = 1; // first keycode is left @@ -526,40 +499,33 @@ void DarwinKeyboardInit( while (numKeyCodes-- > 0) { const short keyCode = get_number(keyMapStream); if (charCode != NX_MODIFIERKEY_NUMERICPAD) { - modifierKeycodes[charCode][1-left] = keyCode; switch (charCode) { case NX_MODIFIERKEY_ALPHALOCK: - modMap[keyCode + MIN_KEYCODE] = LockMask; - map[keyCode * GLYPHS_PER_KEY] = XK_Caps_Lock; + info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Caps_Lock; break; case NX_MODIFIERKEY_SHIFT: - modMap[keyCode + MIN_KEYCODE] = ShiftMask; - map[keyCode * GLYPHS_PER_KEY] = + info->keyMap[keyCode * GLYPHS_PER_KEY] = (left ? XK_Shift_L : XK_Shift_R); break; case NX_MODIFIERKEY_CONTROL: - modMap[keyCode + MIN_KEYCODE] = ControlMask; - map[keyCode * GLYPHS_PER_KEY] = + info->keyMap[keyCode * GLYPHS_PER_KEY] = (left ? XK_Control_L : XK_Control_R); break; case NX_MODIFIERKEY_ALTERNATE: - modMap[keyCode + MIN_KEYCODE] = AltMask; - map[keyCode * GLYPHS_PER_KEY] = + info->keyMap[keyCode * GLYPHS_PER_KEY] = (left ? XK_Mode_switch : XK_Alt_R); break; case NX_MODIFIERKEY_COMMAND: - modMap[keyCode + MIN_KEYCODE] = MetaMask; - map[keyCode * GLYPHS_PER_KEY] = + info->keyMap[keyCode * GLYPHS_PER_KEY] = (left ? XK_Meta_L : XK_Meta_R); break; case NX_MODIFIERKEY_SECONDARYFN: - modMap[keyCode + MIN_KEYCODE] = FunctionMask; - map[keyCode * GLYPHS_PER_KEY] = + info->keyMap[keyCode * GLYPHS_PER_KEY] = (left ? XK_Control_L : XK_Control_R); break; case NX_MODIFIERKEY_HELP: // Help is not an X11 modifier; treat as normal key - map[keyCode * GLYPHS_PER_KEY] = XK_Help; + info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Help; break; } } @@ -567,12 +533,12 @@ void DarwinKeyboardInit( } } - // Convert the Darwin keyboard map to an X keyboard map. + // Convert the Darwin keyboard mapping to an X keyboard map. // A key can have a different character code for each combination of // modifiers. We currently ignore all modifier combinations except // those with Shift, AlphaLock, and Alt. numKeys = get_number(keyMapStream); - for (i = 0, k = map; i < numKeys; i++, k += GLYPHS_PER_KEY) { + for (i = 0, k = info->keyMap; i < numKeys; i++, k += GLYPHS_PER_KEY) { short const charGenMask = get_number(keyMapStream); if (charGenMask != 0xFF) { // is key bound? short numKeyCodes = 1 << bits_set(charGenMask); @@ -656,7 +622,7 @@ void DarwinKeyboardInit( keyMapStream->data = numPadStart; while(numPadKeys-- > 0) { const short keyCode = get_number(keyMapStream); - k = &map[keyCode * GLYPHS_PER_KEY]; + k = &info->keyMap[keyCode * GLYPHS_PER_KEY]; for (i = 0; i < NUM_KEYPAD; i++) { if (*k == normal_to_keypad[i].normalSym) { k[0] = normal_to_keypad[i].keypadSym; @@ -671,7 +637,9 @@ void DarwinKeyboardInit( #ifdef DUMP_DARWIN_KEYMAP ErrorF("Darwin -> X converted keyboard map\n"); - for (i = 0, k = map; i < NX_NUMKEYCODES; i++, k += GLYPHS_PER_KEY) { + for (i = 0, k = info->keyMap; i < NX_NUMKEYCODES; + i++, k += GLYPHS_PER_KEY) + { int j; ErrorF("0x%02x:", i); for (j = 0; j < GLYPHS_PER_KEY; j++) { @@ -685,18 +653,145 @@ void DarwinKeyboardInit( } #endif - keySyms.map = map; + return TRUE; +} + + +/* + * DarwinBuildModifierMaps + * Use the keyMap field of keyboard info structure to populate + * the modMap and modifierKeycodes fields. + */ +static void +DarwinBuildModifierMaps( + darwinKeyboardInfo *info) +{ + int i; + KeySym *k; + int darwinSwapAltMeta = 0; + + memset(info->modMap, NoSymbol, sizeof(info->modMap)); + memset(info->modifierKeycodes, 0, sizeof(info->modifierKeycodes)); + + for (i = 0; i < NUM_KEYCODES; i++) + { + k = info->keyMap + i * GLYPHS_PER_KEY; + + switch (k[0]) { + case XK_Shift_L: + info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i; + info->modMap[MIN_KEYCODE + i] = ShiftMask; + break; + + case XK_Shift_R: + info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][1] = i; + info->modMap[MIN_KEYCODE + i] = ShiftMask; + break; + + case XK_Control_L: + info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i; + info->modMap[MIN_KEYCODE + i] = ControlMask; + break; + + case XK_Control_R: + info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][1] = i; + info->modMap[MIN_KEYCODE + i] = ControlMask; + break; + + case XK_Caps_Lock: + info->modifierKeycodes[NX_MODIFIERKEY_ALPHALOCK][0] = i; + info->modMap[MIN_KEYCODE + i] = LockMask; + break; + + case XK_Alt_L: + info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i; + info->modMap[MIN_KEYCODE + i] = Mod1Mask; + break; + + case XK_Alt_R: + info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][1] = i; + info->modMap[MIN_KEYCODE + i] = Mod1Mask; + break; + + case XK_Mode_switch: + info->modMap[MIN_KEYCODE + i] = Mod1Mask; + break; + + case XK_Meta_L: + info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i; + info->modMap[MIN_KEYCODE + i] = Mod2Mask; + break; + + case XK_Meta_R: + info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][1] = i; + info->modMap[MIN_KEYCODE + i] = Mod2Mask; + break; + + case XK_Num_Lock: + info->modMap[MIN_KEYCODE + i] = Mod3Mask; + break; + } + + if (darwinSwapAltMeta) + { + switch (k[0]) + { + case XK_Alt_L: + k[0] = XK_Meta_L; + break; + case XK_Alt_R: + k[0] = XK_Meta_R; + break; + case XK_Meta_L: + k[0] = XK_Alt_L; + break; + case XK_Meta_R: + k[0] = XK_Alt_R; + break; + } + } + +#if ALT_IS_MODE_SWITCH + if (k[0] == XK_Alt_L || k[0] == XK_Alt_R) + k[0] = XK_Mode_switch; +#endif + } +} + + +/* + * DarwinKeyboardInit + * Get the Darwin keyboard map and compute an equivalent + * X keyboard map and modifier map. Set the new keyboard + * device structure. + */ +void DarwinKeyboardInit( + DeviceIntPtr pDev ) +{ + KeySymsRec keySyms; + + memset( keyInfo.keyMap, 0, sizeof( keyInfo.keyMap ) ); + + // Open a shared connection to the HID System. + // Note that the Event Status Driver is really just a wrapper + // for a kIOHIDParamConnectType connection. + assert( darwinParamConnect = NXOpenEventStatus() ); + + if (!DarwinParseNXKeyMapping(&keyInfo)) { + if (!DarwinModeReadSystemKeymap(&keyInfo)) { + FatalError("Could not build a valid keymap."); + } + } + + DarwinBuildModifierMaps(&keyInfo); + + keySyms.map = keyInfo.keyMap; keySyms.mapWidth = GLYPHS_PER_KEY; keySyms.minKeyCode = MIN_KEYCODE; keySyms.maxKeyCode = MAX_KEYCODE; - if (quartz) - bellProc = QuartzBell; - else - bellProc = XFIOKitBell; - - assert( InitKeyboardDeviceStruct( (DevicePtr)pDev, &keySyms, modMap, - bellProc, + assert( InitKeyboardDeviceStruct( (DevicePtr)pDev, &keySyms, + keyInfo.modMap, DarwinModeBell, DarwinChangeKeyboardControl )); } @@ -718,7 +813,7 @@ void DarwinKeyboardInit( */ int DarwinModifierNXKeyToNXKeycode(int key, int side) { - return modifierKeycodes[key][side]; + return keyInfo.modifierKeycodes[key][side]; } /* @@ -734,7 +829,7 @@ int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide) // search modifierKeycodes for this keycode+side for (key = 0; key < NX_NUMMODIFIERS; key++) { for (side = 0; side <= 1; side++) { - if (modifierKeycodes[key][side] == keycode) break; + if (keyInfo.modifierKeycodes[key][side] == keycode) break; } } if (key == NX_NUMMODIFIERS) return -1; diff --git a/hw/darwin/quartz/Preferences.h b/hw/darwin/quartz/Preferences.h index 2c0d6756b..22a2f1441 100644 --- a/hw/darwin/quartz/Preferences.h +++ b/hw/darwin/quartz/Preferences.h @@ -1,4 +1,31 @@ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/Preferences.h,v 1.2 2003/01/15 02:34:05 torrey Exp $ */ +/* + * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name(s) of the above copyright + * holders shall not be used in advertising or otherwise to promote the + * sale, use or other dealings in this Software without prior written + * authorization. + */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/Preferences.h,v 1.3 2003/09/16 00:36:12 torrey Exp $ */ #import <Cocoa/Cocoa.h> @@ -35,14 +62,14 @@ - (IBAction)saveChanges:(id)sender; - (IBAction)setKey:(id)sender; -- (BOOL)sendEvent:(NSEvent*)anEvent; +- (BOOL)sendEvent:(NSEvent *)anEvent; - (void)awakeFromNib; - (void)windowWillClose:(NSNotification *)aNotification; + (void)setUseKeymapFile:(BOOL)newUseKeymapFile; -+ (void)setKeymapFile:(NSString*)newFile; -+ (void)setSwitchString:(NSString*)newString; ++ (void)setKeymapFile:(NSString *)newFile; ++ (void)setSwitchString:(NSString *)newString; + (void)setKeyCode:(int)newKeyCode; + (void)setModifiers:(int)newModifiers; + (void)setDisplay:(int)newDisplay; @@ -59,15 +86,16 @@ + (void)setSystemBeep:(BOOL)newSystemBeep; + (void)setXinerama:(BOOL)newXinerama; + (void)setAddToPath:(BOOL)newAddToPath; -+ (void)setAddToPathString:(NSString*)newAddToPathString; ++ (void)setAddToPathString:(NSString *)newAddToPathString; + (void)setUseDefaultShell:(BOOL)newUseDefaultShell; -+ (void)setShellString:(NSString*)newShellString; ++ (void)setShellString:(NSString *)newShellString; + (void)setDepth:(int)newDepth; ++ (void)setDisplayModeBundles:(NSArray *)newBundles; + (void)saveToDisk; + (BOOL)useKeymapFile; -+ (NSString*)keymapFile; -+ (NSString*)switchString; ++ (NSString *)keymapFile; ++ (NSString *)switchString; + (unsigned int)keyCode; + (unsigned int)modifiers; + (int)display; @@ -84,10 +112,11 @@ + (BOOL)systemBeep; + (BOOL)xinerama; + (BOOL)addToPath; -+ (NSString*)addToPathString; ++ (NSString *)addToPathString; + (BOOL)useDefaultShell; -+ (NSString*)shellString; ++ (NSString *)shellString; + (int)depth; ++ (NSArray *)displayModeBundles; @end diff --git a/hw/darwin/quartz/Preferences.m b/hw/darwin/quartz/Preferences.m index 4f8dacbf0..4120b6360 100644 --- a/hw/darwin/quartz/Preferences.m +++ b/hw/darwin/quartz/Preferences.m @@ -3,10 +3,43 @@ // // This class keeps track of the user preferences. // -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/Preferences.m,v 1.2 2003/01/15 02:34:06 torrey Exp $ */ +/* + * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name(s) of the above copyright + * holders shall not be used in advertising or otherwise to promote the + * sale, use or other dealings in this Software without prior written + * authorization. + */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/Preferences.m,v 1.4 2003/09/16 00:36:12 torrey Exp $ */ -#import "Preferences.h" #import "quartzCommon.h" + +#define BOOL xBOOL +#include "darwin.h" +#undef BOOL + +#import "Preferences.h" + #include <IOKit/hidsystem/IOLLEvent.h> // for modifier masks // Macros to build the path name @@ -36,8 +69,8 @@ @"YES", @"ShowStartupHelp", [NSNumber numberWithInt:0], @"SwitchKeyCode", [NSNumber numberWithInt:(NSCommandKeyMask | NSAlternateKeyMask)], - @"SwitchModifiers", @"NO", @"UseSystemBeep", - @"YES", @"DockSwitch", + @"SwitchModifiers", @"NO", @"UseSystemBeep", + @"YES", @"DockSwitch", @"NO", @"AllowMouseAccelChange", [NSNumber numberWithInt:qdCursor_Not8Bit], @"UseQDCursor", @"YES", @"Xinerama", @@ -45,7 +78,13 @@ [NSString stringWithCString:XSTRPATH(XBINDIR)], @"AddToPathString", @"YES", @"UseDefaultShell", @"/bin/tcsh", @"Shell", - [NSNumber numberWithInt:depth_Current], @"Depth", nil]; + [NSNumber numberWithInt:depth_Current], @"Depth", +#ifdef BUILD_XPR + [NSArray arrayWithObjects:@"xpr.bundle", @"cr.bundle", nil], +#else + [NSArray arrayWithObjects:@"cr.bundle", nil], +#endif + @"DisplayModeBundles", nil]; [super initialize]; [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults]; @@ -207,7 +246,7 @@ [switchString setString:@""]; } -- (BOOL)sendEvent:(NSEvent*)anEvent +- (BOOL)sendEvent:(NSEvent *)anEvent { if(isGettingKeyCode) { if([anEvent type]==NSKeyDown) // wait for keyup @@ -240,7 +279,7 @@ return NO; } -+ (void)setKeymapFile:(NSString*)newFile ++ (void)setKeymapFile:(NSString *)newFile { [[NSUserDefaults standardUserDefaults] setObject:newFile forKey:@"KeymappingFile"]; @@ -252,7 +291,7 @@ forKey:@"UseKeymappingFile"]; } -+ (void)setSwitchString:(NSString*)newString ++ (void)setSwitchString:(NSString *)newString { [[NSUserDefaults standardUserDefaults] setObject:newString forKey:@"SwitchString"]; @@ -311,7 +350,7 @@ [[NSUserDefaults standardUserDefaults] setBool:newMouseAccelChange forKey:@"AllowMouseAccelChange"]; // Update the setting used by the X server thread - quartzMouseAccelChange = newMouseAccelChange; + darwinMouseAccelChange = newMouseAccelChange; } + (void)setUseQDCursor:(int)newUseQDCursor @@ -364,7 +403,7 @@ forKey:@"AddToPath"]; } -+ (void)setAddToPathString:(NSString*)newAddToPathString ++ (void)setAddToPathString:(NSString *)newAddToPathString { [[NSUserDefaults standardUserDefaults] setObject:newAddToPathString forKey:@"AddToPathString"]; @@ -376,7 +415,7 @@ forKey:@"UseDefaultShell"]; } -+ (void)setShellString:(NSString*)newShellString ++ (void)setShellString:(NSString *)newShellString { [[NSUserDefaults standardUserDefaults] setObject:newShellString forKey:@"Shell"]; @@ -388,6 +427,12 @@ forKey:@"Depth"]; } ++ (void)setDisplayModeBundles:(NSArray *)newBundles +{ + [[NSUserDefaults standardUserDefaults] setObject:newBundles + forKey:@"DisplayModeBundles"]; +} + + (void)saveToDisk { [[NSUserDefaults standardUserDefaults] synchronize]; @@ -399,13 +444,13 @@ boolForKey:@"UseKeymappingFile"]; } -+ (NSString*)keymapFile ++ (NSString *)keymapFile { return [[NSUserDefaults standardUserDefaults] stringForKey:@"KeymappingFile"]; } -+ (NSString*)switchString ++ (NSString *)switchString { return [[NSUserDefaults standardUserDefaults] stringForKey:@"SwitchString"]; @@ -502,7 +547,7 @@ return [[NSUserDefaults standardUserDefaults] boolForKey:@"AddToPath"]; } -+ (NSString*)addToPathString ++ (NSString *)addToPathString { return [[NSUserDefaults standardUserDefaults] stringForKey:@"AddToPathString"]; @@ -514,7 +559,7 @@ boolForKey:@"UseDefaultShell"]; } -+ (NSString*)shellString ++ (NSString *)shellString { return [[NSUserDefaults standardUserDefaults] stringForKey:@"Shell"]; @@ -526,5 +571,10 @@ integerForKey:@"Depth"]; } ++ (NSArray *)displayModeBundles +{ + return [[NSUserDefaults standardUserDefaults] + objectForKey:@"DisplayModeBundles"]; +} @end diff --git a/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj b/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj index 574ce5f18..3afc9177b 100644 --- a/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj +++ b/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj @@ -23,48 +23,6 @@ path = XApplication.h; refType = 4; }; - 014C68ED00ED6A9D7F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = XView.h; - refType = 4; - }; - 014C68EE00ED6A9D7F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = XView.m; - refType = 4; - }; - 014C68F200ED7AD67F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = fakeBoxRec.h; - refType = 4; - }; - 014C68F300EE5AB97F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootlessCommon.c; - refType = 4; - }; - 014C68F400EE5AB97F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootlessCommon.h; - refType = 4; - }; - 014C68F700EE678F7F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootlessWindow.c; - refType = 4; - }; - 014C68F800EE678F7F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootlessWindow.h; - refType = 4; - }; 015698ED003DF345CE6F79C2 = { isa = PBXFileReference; path = XDarwin.icns; @@ -99,18 +57,6 @@ path = /System/Library/Frameworks/IOKit.framework; refType = 0; }; - 017D6F4400E861FB7F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootlessGC.c; - refType = 4; - }; - 017D6F4500E861FB7F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootlessScreen.c; - refType = 4; - }; 018F40F2003E1902CE6F79C2 = { children = ( 018F40F3003E1916CE6F79C2, @@ -118,6 +64,7 @@ 3E74E03600863F047F000001, F5A94EF10314BAC70100011B, 018F40F6003E1974CE6F79C2, + 6E5F5F0005537A1A008FEAD7, ); isa = PBXGroup; name = "X Server"; @@ -261,22 +208,6 @@ //042 //043 //044 -//060 -//061 -//062 -//063 -//064 - 06EB6C3B004099E7CE6F79C2 = { - fileEncoding = 30; - isa = PBXFileReference; - path = quartzShared.h; - refType = 4; - }; -//060 -//061 -//062 -//063 -//064 //080 //081 //082 @@ -290,8 +221,6 @@ 0127909800074B1A0A000002, 01279092000747AA0A000002, 1C4A3109004D8F24CE6F79C2, - 014C68EE00ED6A9D7F000001, - 014C68ED00ED6A9D7F000001, ); isa = PBXGroup; name = Classes; @@ -356,6 +285,8 @@ dependencies = ( 6EF065C903D4F0CA006877C2, 6EF065C703D4EE19006877C2, + 6E11A986048BDFFB006877C2, + 6E7904110500F33B00EEC080, ); isa = PBXApplicationTarget; name = XDarwin; @@ -368,10 +299,42 @@ <dict> <key>CFBundleDevelopmentRegion</key> <string>English</string> + <key>CFBundleDocumentTypes</key> + <array> + <dict> + <key>CFBundleTypeExtensions</key> + <array> + <string>x11app</string> + </array> + <key>CFBundleTypeName</key> + <string>X11 Application</string> + <key>CFBundleTypeOSTypes</key> + <array> + <string>****</string> + </array> + <key>CFBundleTypeRole</key> + <string>Viewer</string> + </dict> + <dict> + <key>CFBundleTypeExtensions</key> + <array> + <string>tool</string> + <string>*</string> + </array> + <key>CFBundleTypeName</key> + <string>UNIX Application</string> + <key>CFBundleTypeOSTypes</key> + <array> + <string>****</string> + </array> + <key>CFBundleTypeRole</key> + <string>Viewer</string> + </dict> + </array> <key>CFBundleExecutable</key> <string>XDarwin</string> <key>CFBundleGetInfoString</key> - <string>XDarwin 1.2.0, ©2001-2003 XFree86 Project, Inc.</string> + <string>XDarwin 1.3b4, ©2001-2003 XFree86 Project, Inc.</string> <key>CFBundleIconFile</key> <string>XDarwin.icns</string> <key>CFBundleIdentifier</key> @@ -383,7 +346,7 @@ <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> - <string>XDarwin 1.2.0</string> + <string>XDarwin 1.3b4</string> <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> @@ -548,7 +511,7 @@ }; }; 1220774600712D75416877C2 = { - fileEncoding = 30; + fileEncoding = 10; isa = PBXFileReference; name = Japanese; path = Japanese.lproj/Localizable.strings; @@ -579,7 +542,7 @@ ); isa = PBXGroup; name = IOKit; - path = ..; + path = ../iokit; refType = 4; }; //170 @@ -597,6 +560,8 @@ 0A79E19E004499A1CE6F79C2, 6EF7C58703D3BC6D00000104, 6EF065C603D4EE19006877C2, + 6E11A985048BDFEE006877C2, + 6E7904100500F05600EEC080, ); isa = PBXGroup; name = Products; @@ -770,7 +735,9 @@ targets = ( 0A79E19F004499A1CE6F79C2, 6EF7C58603D3BC6D00000104, + 6E11A984048BDFEE006877C2, 6EF065C503D4EE19006877C2, + 6E79040F0500F05600EEC080, ); }; 29B97314FDCFA39411CA2CEA = { @@ -780,7 +747,10 @@ 170DFB0000729C86416877C2, 43B962CE00617089416877C2, F5614B3D025112D901000114, + 6EC4A64C042A9597006877C2, 32FEE13C00E07C3E7F000001, + 6EE1214104968658006877C2, + 6EC4A66D042A97FC006877C2, 29B97315FDCFA39411CA2CEA, 29B97317FDCFA39411CA2CEA, 29B97323FDCFA39411CA2CEA, @@ -875,66 +845,14 @@ //324 32FEE13C00E07C3E7F000001 = { children = ( - F56CBD0D02EB84A801129B8A, - F56CBD0E02EB84A801129B8A, - F56CBD0F02EBDCFC01129B8A, - 014C68F200ED7AD67F000001, F5269C2D01D5BC3501000001, F5269C2E01D5BC3501000001, - 32FEE13E00E07CBE7F000001, - 32FEE13F00E07CBE7F000001, - 32FEE14000E07CBE7F000001, - 32FEE14100E07CBE7F000001, - 32FEE14200E07CBE7F000001, - 014C68F300EE5AB97F000001, - 014C68F400EE5AB97F000001, - 017D6F4400E861FB7F000001, - 017D6F4500E861FB7F000001, - 014C68F700EE678F7F000001, - 014C68F800EE678F7F000001, - 32FEE14900E07D317F000001, ); isa = PBXGroup; - name = Rootless; + name = "Old Cocoa Imp"; path = ""; refType = 4; }; - 32FEE13E00E07CBE7F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootless.h; - refType = 4; - }; - 32FEE13F00E07CBE7F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootlessAqua.h; - refType = 4; - }; - 32FEE14000E07CBE7F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootlessAquaGlue.c; - refType = 4; - }; - 32FEE14100E07CBE7F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootlessAquaImp.h; - refType = 4; - }; - 32FEE14200E07CBE7F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootlessAquaImp.m; - refType = 4; - }; - 32FEE14900E07D317F000001 = { - fileEncoding = 30; - isa = PBXFileReference; - path = rootlessValTree.c; - refType = 4; - }; //320 //321 //322 @@ -979,17 +897,19 @@ //434 43B962CE00617089416877C2 = { children = ( + 6EE9B21604E859C200CA7FEA, + 6E97A0F505079F9100B8294C, + 6E5F5F030553815A008FEAD7, + 6E5F5F040553815A008FEAD7, 018F40F8003E1979CE6F79C2, 018F40FA003E197ECE6F79C2, 237A34C10076E37E7F000001, 237A34C40076F4F07F000001, - 3576829A0077B8F17F000001, - 0338412F0083BFE57F000001, - 43B962D000617089416877C2, - 43B962D100617089416877C2, 43B962CF00617089416877C2, F5582948015DAD3B01000001, - 06EB6C3B004099E7CE6F79C2, + 6E5F5F0105537A5F008FEAD7, + 43B962D000617089416877C2, + 43B962D100617089416877C2, 02A1FEA8006D38F0416877C2, ); isa = PBXGroup; @@ -1051,6 +971,536 @@ //6E2 //6E3 //6E4 + 6E11A97F048BDFEE006877C2 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 6E11A980048BDFEE006877C2 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXResourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 6E11A981048BDFEE006877C2 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 6E11A982048BDFEE006877C2 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 6E11A983048BDFEE006877C2 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXRezBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 6E11A984048BDFEE006877C2 = { + buildPhases = ( + 6E11A97F048BDFEE006877C2, + 6E11A980048BDFEE006877C2, + 6E11A981048BDFEE006877C2, + 6E11A982048BDFEE006877C2, + 6E11A983048BDFEE006877C2, + ); + buildSettings = { + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = glxCGL; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + WRAPPER_EXTENSION = bundle; + }; + dependencies = ( + ); + isa = PBXBundleTarget; + name = glxCGL; + productInstallPath = "$(USER_LIBRARY_DIR)/Bundles"; + productName = glxCGL; + productReference = 6E11A985048BDFEE006877C2; + productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> +<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"> +<plist version=\"1.0\"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleExecutable</key> + <string>glxCGL</string> + <key>CFBundleGetInfoString</key> + <string></string> + <key>CFBundleIconFile</key> + <string></string> + <key>CFBundleIdentifier</key> + <string></string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>GLX bundle using Apple's OpenGL</string> + <key>CFBundlePackageType</key> + <string>BNDL</string> + <key>CFBundleShortVersionString</key> + <string>0.1</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>0.1</string> +</dict> +</plist> +"; + }; + 6E11A985048BDFEE006877C2 = { + isa = PBXBundleReference; + path = glxCGL.bundle; + refType = 3; + }; + 6E11A986048BDFFB006877C2 = { + isa = PBXTargetDependency; + target = 6E11A984048BDFEE006877C2; + }; + 6E5F5F0005537A1A008FEAD7 = { + fileEncoding = 30; + isa = PBXFileReference; + path = darwinKeyboard.h; + refType = 4; + }; + 6E5F5F0105537A5F008FEAD7 = { + fileEncoding = 30; + isa = PBXFileReference; + path = quartzKeyboard.c; + refType = 4; + }; + 6E5F5F030553815A008FEAD7 = { + fileEncoding = 30; + isa = PBXFileReference; + path = keysym2ucs.c; + refType = 4; + }; + 6E5F5F040553815A008FEAD7 = { + fileEncoding = 30; + isa = PBXFileReference; + path = keysym2ucs.h; + refType = 4; + }; + 6E6656EC048832CF006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "x-hook.c"; + refType = 4; + }; + 6E6656ED048832CF006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "x-hook.h"; + refType = 4; + }; + 6E6656F0048832EC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = dri.c; + refType = 4; + }; + 6E6656F1048832EC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = dri.h; + refType = 4; + }; + 6E6656F2048832EC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = dristruct.h; + refType = 4; + }; + 6E6656F3048832F9006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = appledri.c; + refType = 4; + }; + 6E79040104FD5ED900EEC080 = { + children = ( + 6E79040204FD5EDA00EEC080, + 6E79040304FD5EDA00EEC080, + 6E79040404FD5EDA00EEC080, + ); + isa = PBXGroup; + name = "Safe Alpha"; + path = safeAlpha; + refType = 4; + }; + 6E79040204FD5EDA00EEC080 = { + fileEncoding = 30; + isa = PBXFileReference; + path = safeAlpha.h; + refType = 4; + }; + 6E79040304FD5EDA00EEC080 = { + fileEncoding = 30; + isa = PBXFileReference; + path = safeAlphaPicture.c; + refType = 4; + }; + 6E79040404FD5EDA00EEC080 = { + fileEncoding = 30; + isa = PBXFileReference; + path = safeAlphaWindow.c; + refType = 4; + }; + 6E79040A0500F05600EEC080 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 6E79040B0500F05600EEC080 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXResourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 6E79040C0500F05600EEC080 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 6E79040D0500F05600EEC080 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 6E79040E0500F05600EEC080 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXRezBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 6E79040F0500F05600EEC080 = { + buildPhases = ( + 6E79040A0500F05600EEC080, + 6E79040B0500F05600EEC080, + 6E79040C0500F05600EEC080, + 6E79040D0500F05600EEC080, + 6E79040E0500F05600EEC080, + ); + buildSettings = { + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = xpr; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + WRAPPER_EXTENSION = bundle; + }; + dependencies = ( + ); + isa = PBXBundleTarget; + name = xpr; + productInstallPath = "$(USER_LIBRARY_DIR)/Bundles"; + productName = xpr; + productReference = 6E7904100500F05600EEC080; + productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> +<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"> +<plist version=\"1.0\"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleExecutable</key> + <string>xpr</string> + <key>CFBundleGetInfoString</key> + <string></string> + <key>CFBundleIconFile</key> + <string></string> + <key>CFBundleIdentifier</key> + <string></string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>Xplugin rootless implementation</string> + <key>CFBundlePackageType</key> + <string>BNDL</string> + <key>CFBundleShortVersionString</key> + <string>0.1</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>0.1</string> +</dict> +</plist> +"; + }; + 6E7904100500F05600EEC080 = { + isa = PBXBundleReference; + path = xpr.bundle; + refType = 3; + }; + 6E7904110500F33B00EEC080 = { + isa = PBXTargetDependency; + target = 6E79040F0500F05600EEC080; + }; + 6E97A0F2050798B100B8294C = { + fileEncoding = 4; + isa = PBXFileReference; + path = xprAppleWM.c; + refType = 4; + }; + 6E97A0F305079B6500B8294C = { + fileEncoding = 4; + isa = PBXFileReference; + path = crAppleWM.m; + refType = 4; + }; + 6E97A0F505079F9100B8294C = { + fileEncoding = 4; + isa = PBXFileReference; + path = applewmExt.h; + refType = 4; + }; + 6EA0B3AF0544A9CC006877C2 = { + children = ( + 6EA0B3B00544A9CC006877C2, + 6EA0B3B10544A9CC006877C2, + 6EA0B3B20544A9CC006877C2, + 6EA0B3B30544A9CC006877C2, + 6EA0B3B40544A9CC006877C2, + 6EA0B3B50544A9CC006877C2, + 6EA0B3B60544A9CC006877C2, + 6EA0B3B70544A9CC006877C2, + ); + isa = PBXGroup; + name = Acceleration; + path = accel; + refType = 4; + }; + 6EA0B3B00544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rlAccel.h; + refType = 4; + }; + 6EA0B3B10544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rlBlt.c; + refType = 4; + }; + 6EA0B3B20544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rlCopy.c; + refType = 4; + }; + 6EA0B3B30544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rlFill.c; + refType = 4; + }; + 6EA0B3B40544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rlFillRect.c; + refType = 4; + }; + 6EA0B3B50544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rlFillSpans.c; + refType = 4; + }; + 6EA0B3B60544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rlGlyph.c; + refType = 4; + }; + 6EA0B3B70544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rlSolid.c; + refType = 4; + }; + 6EA8EEC80445E25C006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rootlessConfig.h; + refType = 4; + }; + 6EC4A64C042A9597006877C2 = { + children = ( + 6EC4A65D042A9654006877C2, + 6EC4A65E042A9654006877C2, + 6EC4A65F042A9654006877C2, + 6EA8EEC80445E25C006877C2, + 6EC4A661042A9654006877C2, + 6EC4A662042A9654006877C2, + 6EC4A660042A9654006877C2, + 6EC4A663042A9654006877C2, + 6EC4A664042A9654006877C2, + 6EA0B3AF0544A9CC006877C2, + 6E79040104FD5ED900EEC080, + ); + isa = PBXGroup; + name = Rootless; + path = ../../../miext/rootless; + refType = 2; + }; + 6EC4A65D042A9654006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rootless.h; + refType = 4; + }; + 6EC4A65E042A9654006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rootlessCommon.c; + refType = 4; + }; + 6EC4A65F042A9654006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rootlessCommon.h; + refType = 4; + }; + 6EC4A660042A9654006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rootlessWindow.h; + refType = 4; + }; + 6EC4A661042A9654006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rootlessScreen.c; + refType = 4; + }; + 6EC4A662042A9654006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rootlessWindow.c; + refType = 4; + }; + 6EC4A663042A9654006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rootlessGC.c; + refType = 4; + }; + 6EC4A664042A9654006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = rootlessValTree.c; + refType = 4; + }; + 6EC4A66D042A97FC006877C2 = { + children = ( + 6EF471A004478DE0006877C2, + 6E6656F3048832F9006877C2, + 6E6656F0048832EC006877C2, + 6E6656F1048832EC006877C2, + 6E6656F2048832EC006877C2, + 6ECF218404589E4D006877C2, + 6E97A0F2050798B100B8294C, + 6ECF218604589F40006877C2, + 6EF4719E04478B08006877C2, + 6EDDB2DF04508B2C006877C2, + 6EF471A204479263006877C2, + 6EF471A404479263006877C2, + 6E6656EC048832CF006877C2, + 6E6656ED048832CF006877C2, + 6EF471A504479263006877C2, + 6EF471A304479263006877C2, + ); + isa = PBXGroup; + path = xpr; + refType = 4; + }; + 6ECF218404589E4D006877C2 = { + fileEncoding = 4; + isa = PBXFileReference; + path = xpr.h; + refType = 4; + }; + 6ECF218604589F40006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = xprCursor.c; + refType = 4; + }; + 6EDDB2DF04508B2C006877C2 = { + fileEncoding = 4; + isa = PBXFileReference; + path = xprScreen.c; + refType = 4; + }; + 6EE1214104968658006877C2 = { + children = ( + 6EE1214304968692006877C2, + 6EE1214404968692006877C2, + 6EE1214204968692006877C2, + 6E97A0F305079B6500B8294C, + 6EE1214504968692006877C2, + 6EE1214604968692006877C2, + ); + isa = PBXGroup; + path = cr; + refType = 4; + }; + 6EE1214204968692006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = cr.h; + refType = 4; + }; + 6EE1214304968692006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = XView.m; + refType = 4; + }; + 6EE1214404968692006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = XView.h; + refType = 4; + }; + 6EE1214504968692006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = crFrame.m; + refType = 4; + }; + 6EE1214604968692006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = crScreen.m; + refType = 4; + }; + 6EE9B21604E859C200CA7FEA = { + fileEncoding = 30; + isa = PBXFileReference; + path = applewm.c; + refType = 4; + }; 6EF065C003D4EE19006877C2 = { buildActionMask = 2147483647; files = ( @@ -1153,6 +1603,42 @@ isa = PBXTargetDependency; target = 6EF7C58603D3BC6D00000104; }; + 6EF4719E04478B08006877C2 = { + fileEncoding = 4; + isa = PBXFileReference; + path = xprFrame.c; + refType = 4; + }; + 6EF471A004478DE0006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = Xplugin.h; + refType = 4; + }; + 6EF471A204479263006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "x-hash.c"; + refType = 4; + }; + 6EF471A304479263006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "x-list.h"; + refType = 4; + }; + 6EF471A404479263006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "x-hash.h"; + refType = 4; + }; + 6EF471A504479263006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + path = "x-list.c"; + refType = 4; + }; 6EF7C58103D3BC6D00000104 = { buildActionMask = 2147483647; files = ( @@ -1209,7 +1695,7 @@ ); isa = PBXBundleTarget; name = glxAGL; - productName = glxAqua; + productName = glxAGL; productReference = 6EF7C58703D3BC6D00000104; productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"> @@ -1228,7 +1714,7 @@ <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> - <string>GLX bundle with AGL</string> + <string>GLX bundle using AGL framework</string> <key>CFBundlePackageType</key> <string>BNDL</string> <key>CFBundleShortVersionString</key> @@ -1277,7 +1763,7 @@ refType = 4; }; F51BF62D02026E1C01000001 = { - fileEncoding = 30; + fileEncoding = 10; isa = PBXFileReference; name = Portuguese; path = Portuguese.lproj/Localizable.strings; @@ -1336,7 +1822,7 @@ refType = 4; }; F533213C0193CBC901000001 = { - fileEncoding = 30; + fileEncoding = 10; isa = PBXFileReference; name = German; path = German.lproj/Localizable.strings; @@ -1395,7 +1881,7 @@ refType = 4; }; F533214501A4B42501000001 = { - fileEncoding = 30; + fileEncoding = 10; isa = PBXFileReference; name = Dutch; path = Dutch.lproj/Localizable.strings; @@ -1450,38 +1936,14 @@ path = fullscreen.c; refType = 4; }; - F5614B3C0251124C01000114 = { - fileEncoding = 30; - isa = PBXFileReference; - path = fullscreen.h; - refType = 4; - }; F5614B3D025112D901000114 = { children = ( F5614B3B0251124C01000114, - F5614B3C0251124C01000114, + 3576829A0077B8F17F000001, + 0338412F0083BFE57F000001, ); isa = PBXGroup; - name = "Full Screen"; - path = ""; - refType = 4; - }; - F56CBD0D02EB84A801129B8A = { - fileEncoding = 30; - isa = PBXFileReference; - path = aqua.h; - refType = 4; - }; - F56CBD0E02EB84A801129B8A = { - fileEncoding = 30; - isa = PBXFileReference; - path = aquaPicture.c; - refType = 4; - }; - F56CBD0F02EBDCFC01129B8A = { - fileEncoding = 30; - isa = PBXFileReference; - path = aquaWindow.c; + path = fullscreen; refType = 4; }; F587E16001924C1D01000001 = { @@ -1505,7 +1967,7 @@ refType = 4; }; F587E16301924C5E01000001 = { - fileEncoding = 30; + fileEncoding = 10; isa = PBXFileReference; name = Swedish; path = Swedish.lproj/Localizable.strings; @@ -1552,7 +2014,7 @@ refType = 4; }; F58D65DE018F79A001000001 = { - fileEncoding = 30; + fileEncoding = 10; isa = PBXFileReference; name = French; path = French.lproj/Localizable.strings; @@ -1604,7 +2066,7 @@ refType = 4; }; F5ACD25FC5B5E9AA01000001 = { - fileEncoding = 30; + fileEncoding = 10; isa = PBXFileReference; name = Spanish; path = Spanish.lproj/Localizable.strings; @@ -1651,7 +2113,7 @@ refType = 4; }; F5ACD266C5BE03C501000001 = { - fileEncoding = 30; + fileEncoding = 10; isa = PBXFileReference; name = ko; path = ko.lproj/Localizable.strings; diff --git a/hw/darwin/quartz/XDarwinStartup.c b/hw/darwin/quartz/XDarwinStartup.c index 53343aa1e..7b2c89f38 100644 --- a/hw/darwin/quartz/XDarwinStartup.c +++ b/hw/darwin/quartz/XDarwinStartup.c @@ -38,16 +38,15 @@ * dealings in this Software without prior written authorization from * Torrey T. Lyons. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XDarwinStartup.c,v 1.1 2002/03/28 02:21:18 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XDarwinStartup.c,v 1.2 2003/05/14 05:15:56 torrey Exp $ */ #include <unistd.h> #include <stdio.h> #include <stdlib.h> +#include <errno.h> #include <sys/syslimits.h> #include <ApplicationServices/ApplicationServices.h> -extern int errno; - // Macros to build the path name #ifndef XBINDIR #define XBINDIR /usr/X11R6/bin diff --git a/hw/darwin/quartz/XServer.h b/hw/darwin/quartz/XServer.h index 3eadd650e..58c7ff748 100644 --- a/hw/darwin/quartz/XServer.h +++ b/hw/darwin/quartz/XServer.h @@ -29,7 +29,7 @@ * sale, use or other dealings in this Software without prior written * authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XServer.h,v 1.8 2003/01/23 00:34:26 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XServer.h,v 1.15 2003/11/14 20:27:58 torrey Exp $ */ #define BOOL xBOOL #include "Xproto.h" @@ -41,15 +41,14 @@ // server state int serverState; NSRecursiveLock *serverLock; + NSMutableArray *pendingClients; BOOL serverVisible; BOOL rootlessMenuBarVisible; BOOL queueShowServer; + BOOL quitWithoutQuery; UInt32 mouseState; - Class windowClass; - - // server event queue BOOL sendServerEvents; - int eventWriteFD; + BOOL x11Active; // Aqua interface IBOutlet NSWindow *modeWindow; @@ -59,6 +58,12 @@ IBOutlet NSWindow *helpWindow; IBOutlet NSButton *startupHelpButton; IBOutlet NSPanel *switchWindow; + + // Menu elements setable by Apple-WM extension + IBOutlet NSMenu *windowMenu; + IBOutlet NSMenuItem *windowSeparator; + IBOutlet NSMenu *dockMenu; + int checkedWindowItem; } - (id)init; @@ -68,9 +73,11 @@ + (void)append:(NSString *)value toEnv:(NSString *)name; +- (BOOL)loadDisplayBundle; - (void)startX; - (void)finishStartX; - (BOOL)startXClients; +- (void)runClient:(NSString *)filename; - (void)run; - (void)toggle; - (void)showServer:(BOOL)show; @@ -82,19 +89,36 @@ - (void)sendXEvent:(xEvent *)xe; - (void)sendShowHide:(BOOL)show; - (void)clientProcessDone:(int)clientStatus; +- (void)activateX11:(BOOL)state; +- (void)windowBecameKey:(NSWindow *)window; +- (void)setX11WindowList:(NSArray *)list; +- (void)setX11WindowCheck:(NSNumber *)nn; // Aqua interface actions - (IBAction)startFullScreen:(id)sender; - (IBAction)startRootless:(id)sender; - (IBAction)closeHelpAndShow:(id)sender; +- (IBAction)showSwitchPanel:(id)sender; - (IBAction)showAction:(id)sender; +- (IBAction)itemSelected:(id)sender; +- (IBAction)nextWindow:(id)sender; +- (IBAction)previousWindow:(id)sender; +- (IBAction)performClose:(id)sender; +- (IBAction)performMiniaturize:(id)sender; +- (IBAction)performZoom:(id)sender; +- (IBAction)bringAllToFront:(id)sender; +- (IBAction)copy:(id)sender; // NSApplication delegate - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; +- (void)applicationWillTerminate:(NSNotification *)aNotification; - (void)applicationDidFinishLaunching:(NSNotification *)aNotification; +- (void)applicationDidHide:(NSNotification *)aNotification; +- (void)applicationDidUnhide:(NSNotification *)aNotification; - (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag; - (void)applicationWillResignActive:(NSNotification *)aNotification; - (void)applicationWillBecomeActive:(NSNotification *)aNotification; +- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename; // NSPort delegate - (void)handlePortMessage:(NSPortMessage *)portMessage; @@ -109,4 +133,3 @@ enum { server_Quitting, server_Done }; - diff --git a/hw/darwin/quartz/XServer.m b/hw/darwin/quartz/XServer.m index c57defd53..1be22f82c 100644 --- a/hw/darwin/quartz/XServer.m +++ b/hw/darwin/quartz/XServer.m @@ -34,7 +34,7 @@ * sale, use or other dealings in this Software without prior written * authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.8 2003/01/23 00:34:26 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.17 2003/11/14 20:27:58 torrey Exp $ */ #include "quartzCommon.h" @@ -42,7 +42,12 @@ #include "X.h" #include "Xproto.h" #include "os.h" +#include "opaque.h" #include "darwin.h" +#include "quartz.h" +#define _APPLEWM_SERVER_ +#include "applewm.h" +#include "applewmExt.h" #undef BOOL #import "XServer.h" @@ -64,14 +69,6 @@ #import <IOKit/pwr_mgt/IOPMLib.h> #import <IOKit/IOMessage.h> -#define ENQUEUE(xe) \ -{ \ - char byte = 0; \ - DarwinEQEnqueue(xe); \ - /* signal there is an event ready to handle */ \ - write(eventWriteFD, &byte, 1); \ -} - // Types of shells enum { shell_Unknown, @@ -90,7 +87,7 @@ static shellList_t const shellList[] = { { "sh", shell_Bourne }, // standard Bourne shell { "zsh", shell_Bourne }, // Z shell { "bash", shell_Bourne }, // GNU Bourne again shell - { NULL, shell_Unknown } + { NULL, shell_Unknown } }; extern int argcGlobal; @@ -99,7 +96,6 @@ extern char **envpGlobal; extern int main(int argc, char *argv[], char *envp[]); extern void HideMenuBar(void); extern void ShowMenuBar(void); -extern void QuartzReallySetCursor(); static void childDone(int sig); static void powerDidChange(void *x, io_service_t y, natural_t messageType, void *messageArgument); @@ -122,15 +118,15 @@ static io_connect_t root_port; serverState = server_NotStarted; serverLock = [[NSRecursiveLock alloc] init]; + pendingClients = nil; clientPID = 0; sendServerEvents = NO; + x11Active = YES; serverVisible = NO; rootlessMenuBarVisible = YES; queueShowServer = YES; quartzServerQuitting = NO; mouseState = 0; - eventWriteFD = quartzEventWriteFD; - windowClass = [NSWindow class]; // set up a port to safely send messages to main thread from server thread signalPort = [[NSPort port] retain]; @@ -145,6 +141,11 @@ static io_connect_t root_port; [[NSRunLoop currentRunLoop] addPort:signalPort forMode:NSModalPanelRunLoopMode]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(windowBecameKey:) + name:NSWindowDidBecomeKeyNotification + object:nil]; + return self; } @@ -164,7 +165,7 @@ static io_connect_t root_port; [self showServer:NO]; sendServerEvents = NO; - if (clientPID != 0 || !quartzStartClients) { + if (!quitWithoutQuery && (clientPID != 0 || !quartzStartClients)) { int but; but = NSRunAlertPanel(NSLocalizedString(@"Quit X server?",@""), @@ -270,11 +271,18 @@ static io_connect_t root_port; break; case NSLeftMouseDown: [self getMousePosition:&xe fromEvent:anEvent]; - if (quartzRootless && - ! ([anEvent window] && - [[anEvent window] isKindOfClass:windowClass])) { - // Click in non X window - ignore - return NO; + if (quartzRootless) { + // Check that event is in X11 window + if (!quartzProcs->IsX11Window([anEvent window], + [anEvent windowNumber])) + { + if (x11Active) + [self activateX11:NO]; + return NO; + } else { + if (!x11Active) + [self activateX11:YES]; + } } mouse1Pressed = YES; xe.u.u.type = ButtonPress; @@ -310,6 +318,8 @@ static io_connect_t root_port; break; case NSKeyDown: case NSKeyUp: + if (!x11Active) + return NO; // If the mouse is not on the valid X display area, // we don't send the X server key events. if (![self getMousePosition:&xe fromEvent:nil]) @@ -321,6 +331,8 @@ static io_connect_t root_port; xe.u.u.detail = [anEvent keyCode]; break; case NSFlagsChanged: + if (!x11Active) + return NO; [self getMousePosition:&xe fromEvent:nil]; xe.u.u.type = kXDarwinUpdateModifiers; xe.u.clientMessage.u.l.longs0 = flags; @@ -335,14 +347,13 @@ static io_connect_t root_port; [self sendXEvent:&xe]; - // Rootless: Send first NSLeftMouseDown to windows and views so window - // ordering can be suppressed. + // Rootless: Send first NSLeftMouseDown to Cocoa windows and views so + // window ordering can be suppressed. // Don't pass further events - they (incorrectly?) bring the window // forward no matter what. if (quartzRootless && (type == NSLeftMouseDown || type == NSLeftMouseUp) && - [anEvent clickCount] == 1 && - [[anEvent window] isKindOfClass:windowClass]) + [anEvent clickCount] == 1 && [anEvent window]) { return NO; } @@ -429,6 +440,27 @@ static io_connect_t root_port; } } + +// Load the appropriate display mode bundle +- (BOOL)loadDisplayBundle +{ + if (quartzRootless) { + NSEnumerator *enumerator = [[Preferences displayModeBundles] + objectEnumerator]; + NSString *bundleName; + + while ((bundleName = [enumerator nextObject])) { + if (QuartzLoadDisplayBundle([bundleName cString])) + return YES; + } + + return NO; + } else { + return QuartzLoadDisplayBundle("fullscreen.bundle"); + } +} + + // Start the X server thread and the client process - (void)startX { @@ -455,6 +487,9 @@ static io_connect_t root_port; else NSLog(@"No version"); + if (![self loadDisplayBundle]) + [NSApp terminate:nil]; + // Start the X server thread serverState = server_Starting; [NSThread detachNewThreadSelector:@selector(run) toTarget:self @@ -517,6 +552,19 @@ static io_connect_t root_port; if (quartzServerQuitting) { [self quitServer]; [NSApp replyToApplicationShouldTerminate:YES]; + return; + } + + if (pendingClients) { + NSEnumerator *enumerator = [pendingClients objectEnumerator]; + NSString *filename; + + while ((filename = [enumerator nextObject])) { + [self runClient:filename]; + } + + [pendingClients release]; + pendingClients = nil; } } @@ -666,6 +714,87 @@ static io_connect_t root_port; return YES; } +// Start the specified client in its own task +// FIXME: This should be unified with startXClients +- (void)runClient:(NSString *)filename +{ + const char *command = [filename UTF8String]; + const char *shell; + const char *argv[5]; + int child1, child2 = 0; + int status; + + shell = getenv("SHELL"); + if (shell == NULL) + shell = "/bin/bash"; + + /* At least [ba]sh, [t]csh and zsh all work with this syntax. We + need to use an interactive shell to force it to load the user's + environment. */ + + argv[0] = shell; + argv[1] = "-i"; + argv[2] = "-c"; + argv[3] = command; + argv[4] = NULL; + + /* Do the fork-twice trick to avoid having to reap zombies */ + + child1 = fork(); + + switch (child1) { + case -1: /* error */ + break; + + case 0: /* child1 */ + child2 = fork(); + + switch (child2) { + int max_files, i; + char buf[1024], *tem; + + case -1: /* error */ + _exit(1); + + case 0: /* child2 */ + /* close all open files except for standard streams */ + max_files = sysconf(_SC_OPEN_MAX); + for (i = 3; i < max_files; i++) + close(i); + + /* ensure stdin is on /dev/null */ + close(0); + open("/dev/null", O_RDONLY); + + /* cd $HOME */ + tem = getenv("HOME"); + if (tem != NULL) + chdir(tem); + + /* Setup environment */ + snprintf(buf, sizeof(buf), ":%s", display); + setenv("DISPLAY", buf, TRUE); + tem = getenv("PATH"); + if (tem != NULL && tem[0] != NULL) + snprintf(buf, sizeof(buf), "%s:/usr/X11R6/bin", tem); + else + snprintf(buf, sizeof(buf), "/bin:/usr/bin:/usr/X11R6/bin"); + setenv("PATH", buf, TRUE); + + execvp(argv[0], (char **const) argv); + + _exit(2); + + default: /* parent (child1) */ + _exit(0); + } + break; + + default: /* parent */ + waitpid(child1, &status, 0); + } +} + // Run the X server thread - (void)run { @@ -712,6 +841,12 @@ static io_connect_t root_port; [NSApp activateIgnoringOtherApps:YES]; } +// Show the Aqua-X11 switch panel useful for fullscreen mode +- (IBAction)showSwitchPanel:(id)sender +{ + [switchWindow orderFront:nil]; +} + // Show the X server when sent message from GUI - (IBAction)showAction:(id)sender { @@ -787,11 +922,10 @@ static io_connect_t root_port; if (show) { if (!quartzRootless) { - QuartzFSCapture(); + quartzProcs->CaptureScreens(); HideMenuBar(); } - xe.u.u.type = kXDarwinShow; - [self sendXEvent:&xe]; + [self activateX11:YES]; // the mouse location will have moved; track it xe.u.u.type = MotionNotify; @@ -802,14 +936,19 @@ static io_connect_t root_port; xe.u.clientMessage.u.l.longs0 = [[NSApp currentEvent] modifierFlags]; [self sendXEvent:&xe]; - // put the pasteboard into the X cut buffer - [self readPasteboard]; + // If there is no AppleWM-aware cut and paste manager, do what we can. + if ((AppleWMSelectedEvents() & AppleWMPasteboardNotifyMask) == 0) { + // put the pasteboard into the X cut buffer + [self readPasteboard]; + } } else { - // put the X cut buffer on the pasteboard - [self writePasteboard]; + // If there is no AppleWM-aware cut and paste manager, do what we can. + if ((AppleWMSelectedEvents() & AppleWMPasteboardNotifyMask) == 0) { + // put the X cut buffer on the pasteboard + [self writePasteboard]; + } - xe.u.u.type = kXDarwinHide; - [self sendXEvent:&xe]; + [self activateX11:NO]; } serverVisible = show; @@ -877,7 +1016,7 @@ static io_connect_t root_port; } #endif - ENQUEUE(xe); + DarwinEQEnqueue(xe); } // Handle messages from the X server thread @@ -885,12 +1024,12 @@ static io_connect_t root_port; { unsigned msg = [portMessage msgid]; - switch(msg) { + switch (msg) { case kQuartzServerHidden: // Make sure the X server wasn't queued to be shown again while // the hide was pending. if (!quartzRootless && !serverVisible) { - QuartzFSRelease(); + quartzProcs->ReleaseScreens(); ShowMenuBar(); } break; @@ -908,13 +1047,43 @@ static io_connect_t root_port; break; case kQuartzCursorUpdate: - QuartzReallySetCursor(); + if (quartzProcs->CursorUpdate) + quartzProcs->CursorUpdate(); break; case kQuartzPostEvent: { const xEvent *xe = [[[portMessage components] lastObject] bytes]; - ENQUEUE(xe); + DarwinEQEnqueue(xe); + break; + } + + case kQuartzSetWindowMenu: + { + NSArray *list; + [[[portMessage components] lastObject] getBytes:&list]; + [self setX11WindowList:list]; + [list release]; + break; + } + + case kQuartzSetWindowMenuCheck: + { + int n; + [[[portMessage components] lastObject] getBytes:&n]; + [self setX11WindowCheck:[NSNumber numberWithInt:n]]; + break; + } + + case kQuartzSetFrontProcess: + [NSApp activateIgnoringOtherApps:YES]; + break; + + case kQuartzSetCanQuit: + { + int n; + [[[portMessage components] lastObject] getBytes:&n]; + quitWithoutQuery = (BOOL) n; break; } @@ -939,6 +1108,234 @@ static io_connect_t root_port; } } +// User selected an X11 window from a menu +- (IBAction)itemSelected:(id)sender +{ + xEvent xe; + + [NSApp activateIgnoringOtherApps:YES]; + + // Notify the client of the change through the X server thread + xe.u.u.type = kXDarwinControllerNotify; + xe.u.clientMessage.u.l.longs0 = AppleWMWindowMenuItem; + xe.u.clientMessage.u.l.longs1 = [sender tag]; + [self sendXEvent:&xe]; +} + +// User selected Next from window menu +- (IBAction)nextWindow:(id)sender +{ + QuartzMessageServerThread(kXDarwinControllerNotify, 1, + AppleWMNextWindow); +} + +// User selected Previous from window menu +- (IBAction)previousWindow:(id)sender +{ + QuartzMessageServerThread(kXDarwinControllerNotify, 1, + AppleWMPreviousWindow); +} + +/* + * The XPR implementation handles close, minimize, and zoom actions for X11 + * windows here, while CR handles these in the NSWindow class. + */ + +// Handle Close from window menu for X11 window in XPR implementation +- (IBAction)performClose:(id)sender +{ + QuartzMessageServerThread(kXDarwinControllerNotify, 1, + AppleWMCloseWindow); +} + +// Handle Minimize from window menu for X11 window in XPR implementation +- (IBAction)performMiniaturize:(id)sender +{ + QuartzMessageServerThread(kXDarwinControllerNotify, 1, + AppleWMMinimizeWindow); +} + +// Handle Zoom from window menu for X11 window in XPR implementation +- (IBAction)performZoom:(id)sender +{ + QuartzMessageServerThread(kXDarwinControllerNotify, 1, + AppleWMZoomWindow); +} + +// Handle "Bring All to Front" from window menu +- (IBAction)bringAllToFront:(id)sender +{ + if ((AppleWMSelectedEvents() & AppleWMControllerNotifyMask) != 0) { + QuartzMessageServerThread(kXDarwinControllerNotify, 1, + AppleWMBringAllToFront); + } else { + [NSApp arrangeInFront:nil]; + } +} + +// This ends up at the end of the responder chain. +- (IBAction)copy:(id)sender +{ + QuartzMessageServerThread(kXDarwinPasteboardNotify, 1, + AppleWMCopyToPasteboard); +} + +// Set whether or not X11 is active and should receive all key events +- (void)activateX11:(BOOL)state +{ + if (state) { + QuartzMessageServerThread(kXDarwinActivate, 0); + } + else { + QuartzMessageServerThread(kXDarwinDeactivate, 0); + } + + x11Active = state; +} + +// Some NSWindow became the key window +- (void)windowBecameKey:(NSWindow *)window +{ + if (quartzProcs->IsX11Window(window, [window windowNumber])) { + if (!x11Active) + [self activateX11:YES]; + } else { + if (x11Active) + [self activateX11:NO]; + } +} + +// Set the Apple-WM specifiable part of the window menu +- (void)setX11WindowList:(NSArray *)list +{ + NSMenuItem *item; + int first, count, i; + xEvent xe; + + /* Work backwards so we don't mess up the indices */ + first = [windowMenu indexOfItem:windowSeparator] + 1; + if (first > 0) { + count = [windowMenu numberOfItems]; + for (i = count - 1; i >= first; i--) + [windowMenu removeItemAtIndex:i]; + } else { + windowSeparator = (NSMenuItem *)[windowMenu addItemWithTitle:@"" + action:nil + keyEquivalent:@""]; + } + + count = [dockMenu numberOfItems]; + for (i = 0; i < count; i++) + [dockMenu removeItemAtIndex:0]; + + count = [list count]; + + for (i = 0; i < count; i++) + { + NSString *name, *shortcut; + + name = [[list objectAtIndex:i] objectAtIndex:0]; + shortcut = [[list objectAtIndex:i] objectAtIndex:1]; + + item = (NSMenuItem *)[windowMenu addItemWithTitle:name + action:@selector(itemSelected:) + keyEquivalent:shortcut]; + [item setTarget:self]; + [item setTag:i]; + [item setEnabled:YES]; + + item = (NSMenuItem *)[dockMenu insertItemWithTitle:name + action:@selector(itemSelected:) + keyEquivalent:shortcut atIndex:i]; + [item setTarget:self]; + [item setTag:i]; + [item setEnabled:YES]; + } + + if (checkedWindowItem >= 0 && checkedWindowItem < count) + { + item = (NSMenuItem *)[windowMenu itemAtIndex:first + checkedWindowItem]; + [item setState:NSOnState]; + item = (NSMenuItem *)[dockMenu itemAtIndex:checkedWindowItem]; + [item setState:NSOnState]; + } + + // Notify the client of the change through the X server thread + xe.u.u.type = kXDarwinControllerNotify; + xe.u.clientMessage.u.l.longs0 = AppleWMWindowMenuNotify; + [self sendXEvent:&xe]; +} + +// Set the checked item on the Apple-WM specifiable window menu +- (void)setX11WindowCheck:(NSNumber *)nn +{ + NSMenuItem *item; + int first, count; + int n = [nn intValue]; + + first = [windowMenu indexOfItem:windowSeparator] + 1; + count = [windowMenu numberOfItems] - first; + + if (checkedWindowItem >= 0 && checkedWindowItem < count) + { + item = (NSMenuItem *)[windowMenu itemAtIndex:first + checkedWindowItem]; + [item setState:NSOffState]; + item = (NSMenuItem *)[dockMenu itemAtIndex:checkedWindowItem]; + [item setState:NSOffState]; + } + if (n >= 0 && n < count) + { + item = (NSMenuItem *)[windowMenu itemAtIndex:first + n]; + [item setState:NSOnState]; + item = (NSMenuItem *)[dockMenu itemAtIndex:n]; + [item setState:NSOnState]; + } + checkedWindowItem = n; +} + +// Return whether or not a menu item should be enabled +- (BOOL)validateMenuItem:(NSMenuItem *)item +{ + NSMenu *menu = [item menu]; + + if (menu == windowMenu && [item tag] == 30) { + // Mode switch panel is for fullscreen only + return !quartzRootless; + } + else if ((menu == windowMenu && [item tag] != 40) || menu == dockMenu) { + // The special window and dock menu items should not be active unless + // there is an AppleWM-aware window manager running. + return (AppleWMSelectedEvents() & AppleWMControllerNotifyMask) != 0; + } + else { + return TRUE; + } +} + +/* + * Application Delegate Methods + */ + +- (void)applicationDidHide:(NSNotification *)aNotification +{ + if ((AppleWMSelectedEvents() & AppleWMControllerNotifyMask) != 0) { + QuartzMessageServerThread(kXDarwinControllerNotify, 1, + AppleWMHideAll); + } else { + // FIXME: We need to hide Xplugin windows here + } +} + +- (void)applicationDidUnhide:(NSNotification *)aNotification +{ + if ((AppleWMSelectedEvents() & AppleWMControllerNotifyMask) != 0) { + QuartzMessageServerThread(kXDarwinControllerNotify, 1, + AppleWMShowAll); + } else { + [NSApp arrangeInFront:nil]; + } +} + // Called when the user clicks the application icon, // but not when Cmd-Tab is used. // Rootless: Don't switch until applicationWillBecomeActive. @@ -958,8 +1355,38 @@ static io_connect_t root_port; - (void)applicationWillBecomeActive:(NSNotification *)aNotification { - if (quartzRootless) + if (quartzRootless) { [self showServer:YES]; + + // If there is no AppleWM-aware window manager, we can't allow + // interleaving of Aqua and X11 windows. + if ((AppleWMSelectedEvents() & AppleWMControllerNotifyMask) == 0) { + [NSApp arrangeInFront:nil]; + } + } +} + +// Called when the user opens a document type that we claim (ie. an X11 executable). +- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename +{ + if (serverState == server_Running) { + [self runClient:filename]; + return YES; + } + else if (serverState == server_NotStarted || serverState == server_Starting) { + if ([filename UTF8String][0] != ':') { // Ignore display names + if (!pendingClients) { + pendingClients = [[NSMutableArray alloc] initWithCapacity:1]; + } + [pendingClients addObject:filename]; + return YES; // Assume it will launch successfully + } + return NO; + } + + // If the server is quitting or done, + // its too late to launch new clients this time. + return NO; } @end @@ -970,7 +1397,7 @@ static io_connect_t root_port; // NSPort is not thread safe. void QuartzMessageMainThread(unsigned msg, void *data, unsigned length) { - if (msg == kQuartzPostEvent) { + if (length > 0) { NSData *eventData = [NSData dataWithBytes:data length:length]; NSArray *eventArray = [NSArray arrayWithObject:eventData]; NSPortMessage *newMessage = @@ -986,6 +1413,36 @@ void QuartzMessageMainThread(unsigned msg, void *data, unsigned length) } } +void +QuartzSetWindowMenu(int nitems, const char **items, + const char *shortcuts) +{ + NSMutableArray *array; + int i; + + array = [[NSMutableArray alloc] initWithCapacity:nitems]; + + for (i = 0; i < nitems; i++) { + NSMutableArray *subarray = [NSMutableArray arrayWithCapacity:2]; + NSString *string = [NSString stringWithUTF8String:items[i]]; + + [subarray addObject:string]; + + if (shortcuts[i] != 0) { + NSString *number = [NSString stringWithFormat:@"%d", + shortcuts[i]]; + [subarray addObject:number]; + } else + [subarray addObject:@""]; + + [array addObject:subarray]; + } + + /* Send the array of strings over to the main thread. */ + /* Will be released in main thread. */ + QuartzMessageMainThread(kQuartzSetWindowMenu, &array, sizeof(NSArray *)); +} + // Handle SIGCHLD signals static void childDone(int sig) { @@ -1025,5 +1482,5 @@ static void powerDidChange( } break; } - + } diff --git a/hw/darwin/quartz/pseudoramiX.c b/hw/darwin/quartz/pseudoramiX.c index e55aabd6f..2dd7c3ae5 100644 --- a/hw/darwin/quartz/pseudoramiX.c +++ b/hw/darwin/quartz/pseudoramiX.c @@ -32,7 +32,7 @@ shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from Digital Equipment Corporation. ******************************************************************/ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/pseudoramiX.c,v 1.2 2002/10/16 21:13:33 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/pseudoramiX.c,v 1.3 2003/04/30 23:15:39 torrey Exp $ */ #include "pseudoramiX.h" @@ -111,7 +111,7 @@ void PseudoramiXExtensionInit(int argc, char *argv[]) if (noPseudoramiXExtension) return; - if (pseudoramiXNumScreens == 1 || aquaNumScreens == 1) { + if (pseudoramiXNumScreens == 1) { // Only one screen - disable Xinerama extension. noPseudoramiXExtension = TRUE; return; diff --git a/hw/darwin/quartz/pseudoramiX.h b/hw/darwin/quartz/pseudoramiX.h index d0d596686..23738cfb3 100644 --- a/hw/darwin/quartz/pseudoramiX.h +++ b/hw/darwin/quartz/pseudoramiX.h @@ -1,10 +1,9 @@ /* * Minimal implementation of PanoramiX/Xinerama */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/pseudoramiX.h,v 1.1 2002/03/28 02:21:18 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/pseudoramiX.h,v 1.2 2003/04/30 23:15:39 torrey Exp $ */ extern int noPseudoramiXExtension; -extern int aquaNumScreens; void PseudoramiXAddScreen(int x, int y, int w, int h); void PseudoramiXExtensionInit(int argc, char *argv[]); diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c index 592a0e4a0..4643886f3 100644 --- a/hw/darwin/quartz/quartz.c +++ b/hw/darwin/quartz/quartz.c @@ -29,16 +29,16 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartz.c,v 1.7 2003/01/23 00:34:26 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartz.c,v 1.13 2003/11/12 20:21:51 torrey Exp $ */ #include "quartzCommon.h" #include "quartz.h" #include "darwin.h" #include "quartzAudio.h" -#include "quartzCursor.h" -#include "fullscreen.h" -#include "rootlessAqua.h" #include "pseudoramiX.h" +#define _APPLEWM_SERVER_ +#include "applewm.h" +#include "applewmExt.h" // X headers #include "scrnintstr.h" @@ -61,8 +61,8 @@ int quartzServerQuitting = FALSE; int quartzScreenIndex = 0; int aquaMenuBarHeight = 0; int noPseudoramiXExtension = TRUE; -int aquaNumScreens = 0; - +QuartzModeProcsPtr quartzProcs = NULL; +const char *quartzOpenGLBundle = NULL; /* =========================================================================== @@ -73,10 +73,10 @@ int aquaNumScreens = 0; */ /* - * QuartzAddScreen + * DarwinModeAddScreen * Do mode dependent initialization of each screen for Quartz. */ -Bool QuartzAddScreen( +Bool DarwinModeAddScreen( int index, ScreenPtr pScreen) { @@ -84,34 +84,25 @@ Bool QuartzAddScreen( QuartzScreenPtr displayInfo = xcalloc(sizeof(QuartzScreenRec), 1); QUARTZ_PRIV(pScreen) = displayInfo; - // do full screen or rootless specific initialization - if (quartzRootless) { - return AquaAddScreen(index, pScreen); - } else { - return QuartzFSAddScreen(index, pScreen); - } + // do Quartz mode specific initialization + return quartzProcs->AddScreen(index, pScreen); } /* - * QuartzSetupScreen + * DarwinModeSetupScreen * Finalize mode specific setup of each screen. */ -Bool QuartzSetupScreen( +Bool DarwinModeSetupScreen( int index, ScreenPtr pScreen) { - // do full screen or rootless specific setup - if (quartzRootless) { - if (! AquaSetupScreen(index, pScreen)) - return FALSE; - } else { - if (! QuartzFSSetupScreen(index, pScreen)) - return FALSE; - } + // do Quartz mode specific setup + if (! quartzProcs->SetupScreen(index, pScreen)) + return FALSE; // setup cursor support - if (! QuartzInitCursor(pScreen)) + if (! quartzProcs->InitCursor(pScreen)) return FALSE; return TRUE; @@ -119,10 +110,10 @@ Bool QuartzSetupScreen( /* - * QuartzInitOutput + * DarwinModeInitOutput * Quartz display initialization. */ -void QuartzInitOutput( +void DarwinModeInitOutput( int argc, char **argv ) { @@ -145,13 +136,8 @@ void QuartzInitOutput( FatalError("Could not register block and wakeup handlers."); } - if (quartzRootless) { - ErrorF("Display mode: Rootless Quartz\n"); - AquaDisplayInit(); - } else { - ErrorF("Display mode: Full screen Quartz\n"); - QuartzFSDisplayInit(); - } + // Do display mode specific initialization + quartzProcs->DisplayInit(); // Init PseudoramiX implementation of Xinerama. // This should be in InitExtensions, but that causes link errors @@ -163,21 +149,28 @@ void QuartzInitOutput( /* - * QuartzInitInput + * DarwinModeInitInput * Inform the main thread the X server is ready to handle events. */ -void QuartzInitInput( +void DarwinModeInitInput( int argc, char **argv ) { - QuartzMessageMainThread(kQuartzServerStarted, NULL, 0); + if (serverGeneration == 1) { + QuartzMessageMainThread(kQuartzServerStarted, NULL, 0); + } + + // Do final display mode specific initialization before handling events + if (quartzProcs->InitInput) + quartzProcs->InitInput(argc, argv); } /* * QuartzShow * Show the X server on screen. Does nothing if already shown. - * Restore the X clip regions and the X server cursor state. + * Calls mode specific screen resume to restore the X clip regions + * (if needed) and the X server cursor state. */ static void QuartzShow( int x, // cursor location @@ -189,9 +182,7 @@ static void QuartzShow( quartzServerVisible = TRUE; for (i = 0; i < screenInfo.numScreens; i++) { if (screenInfo.screens[i]) { - QuartzResumeXCursor(screenInfo.screens[i], x, y); - if (!quartzRootless) - xf86SetRootClip(screenInfo.screens[i], TRUE); + quartzProcs->ResumeScreen(screenInfo.screens[i], x, y); } } } @@ -201,8 +192,8 @@ static void QuartzShow( /* * QuartzHide * Remove the X server display from the screen. Does nothing if already - * hidden. Set X clip regions to prevent drawing, and restore the Aqua - * cursor. + * hidden. Calls mode specific screen suspend to set X clip regions to + * prevent drawing (if needed) and restore the Aqua cursor. */ static void QuartzHide(void) { @@ -211,9 +202,7 @@ static void QuartzHide(void) if (quartzServerVisible) { for (i = 0; i < screenInfo.numScreens; i++) { if (screenInfo.screens[i]) { - QuartzSuspendXCursor(screenInfo.screens[i]); - if (!quartzRootless) - xf86SetRootClip(screenInfo.screens[i], FALSE); + quartzProcs->SuspendScreen(screenInfo.screens[i]); } } } @@ -243,20 +232,58 @@ static void QuartzSetRootClip( /* - * QuartzProcessEvent + * QuartzMessageServerThread + * Send the X server thread a message by placing it on the event queue. + */ +void +QuartzMessageServerThread( + int type, + int argc, ...) +{ + xEvent xe; + INT32 *argv; + int i, max_args; + va_list args; + + memset(&xe, 0, sizeof(xe)); + xe.u.u.type = type; + xe.u.clientMessage.u.l.type = type; + + argv = &xe.u.clientMessage.u.l.longs0; + max_args = 4; + + if (argc > 0 && argc <= max_args) { + va_start (args, argc); + for (i = 0; i < argc; i++) + argv[i] = (int) va_arg (args, int); + va_end (args); + } + + DarwinEQEnqueue(&xe); +} + + +/* + * DarwinModeProcessEvent * Process Quartz specific events. */ -void QuartzProcessEvent( +void DarwinModeProcessEvent( xEvent *xe) { switch (xe->u.u.type) { - case kXDarwinShow: + case kXDarwinActivate: QuartzShow(xe->u.keyButtonPointer.rootX, xe->u.keyButtonPointer.rootY); + AppleWMSendEvent(AppleWMActivationNotify, + AppleWMActivationNotifyMask, + AppleWMIsActive, 0); break; - case kXDarwinHide: + case kXDarwinDeactivate: + AppleWMSendEvent(AppleWMActivationNotify, + AppleWMActivationNotifyMask, + AppleWMIsInactive, 0); QuartzHide(); break; @@ -276,18 +303,42 @@ void QuartzProcessEvent( QuartzWritePasteboard(); break; + /* + * AppleWM events + */ + case kXDarwinControllerNotify: + AppleWMSendEvent(AppleWMControllerNotify, + AppleWMControllerNotifyMask, + xe->u.clientMessage.u.l.longs0, + xe->u.clientMessage.u.l.longs1); + break; + + case kXDarwinPasteboardNotify: + AppleWMSendEvent(AppleWMPasteboardNotify, + AppleWMPasteboardNotifyMask, + xe->u.clientMessage.u.l.longs0, + xe->u.clientMessage.u.l.longs1); + break; + + case kXDarwinDisplayChanged: + case kXDarwinWindowState: + case kXDarwinWindowMoved: + // FIXME: Not implemented yet + break; + default: - ErrorF("Unknown application defined event.\n"); + ErrorF("Unknown application defined event type %d.\n", + xe->u.u.type); } } /* - * QuartzGiveUp + * DarwinModeGiveUp * Cleanup before X server shutdown * Release the screen and restore the Aqua cursor. */ -void QuartzGiveUp(void) +void DarwinModeGiveUp(void) { #if 0 // Trying to switch cursors when quitting causes deadlock @@ -301,5 +352,5 @@ void QuartzGiveUp(void) #endif if (!quartzRootless) - QuartzFSRelease(); + quartzProcs->ReleaseScreens(); } diff --git a/hw/darwin/quartz/quartz.h b/hw/darwin/quartz/quartz.h index cd4f732f3..849e10cef 100644 --- a/hw/darwin/quartz/quartz.h +++ b/hw/darwin/quartz/quartz.h @@ -1,11 +1,11 @@ /* * quartz.h * - * External interface of the Quartz modes seen by the generic, mode + * External interface of the Quartz display modes seen by the generic, mode * independent parts of the Darwin X server. */ /* - * Copyright (c) 2001-2002 Greg Parker and Torrey T. Lyons. + * Copyright (c) 2001-2003 Greg Parker and Torrey T. Lyons. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -30,21 +30,88 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartz.h,v 1.4 2002/11/20 23:51:58 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartz.h,v 1.7 2003/11/12 20:21:51 torrey Exp $ */ #ifndef _QUARTZ_H #define _QUARTZ_H -#include "screenint.h" -#include "Xproto.h" #include "quartzPasteboard.h" -int QuartzProcessArgument(int argc, char *argv[], int i); -void QuartzInitOutput(int argc, char **argv); -void QuartzInitInput(int argc, char **argv); -Bool QuartzAddScreen(int index, ScreenPtr pScreen); -Bool QuartzSetupScreen(int index, ScreenPtr pScreen); -void QuartzGiveUp(void); -void QuartzProcessEvent(xEvent *xe); +#include "screenint.h" +#include "window.h" + +/*------------------------------------------ + Quartz display mode function types + ------------------------------------------*/ + +/* + * Display mode initialization + */ +typedef void (*DisplayInitProc)(void); +typedef Bool (*AddScreenProc)(int index, ScreenPtr pScreen); +typedef Bool (*SetupScreenProc)(int index, ScreenPtr pScreen); +typedef void (*InitInputProc)(int argc, char **argv); + +/* + * Cursor functions + */ +typedef Bool (*InitCursorProc)(ScreenPtr pScreen); +typedef void (*CursorUpdateProc)(void); + +/* + * Suspend and resume X11 activity + */ +typedef void (*SuspendScreenProc)(ScreenPtr pScreen); +typedef void (*ResumeScreenProc)(ScreenPtr pScreen, int x, int y); +typedef void (*CaptureScreensProc)(void); +typedef void (*ReleaseScreensProc)(void); + +/* + * Rootless helper functions + */ +typedef Bool (*IsX11WindowProc)(void *nsWindow, int windowNumber); + +/* + * Rootless functions for optional export to GLX layer + */ +typedef void * (*FrameForWindowProc)(WindowPtr pWin, Bool create); +typedef WindowPtr (*TopLevelParentProc)(WindowPtr pWindow); +typedef Bool (*CreateSurfaceProc) + (ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable, + unsigned int client_id, unsigned int *surface_id, + unsigned int key[2], void (*notify) (void *arg, void *data), + void *notify_data); +typedef Bool (*DestroySurfaceProc) + (ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable, + void (*notify) (void *arg, void *data), void *notify_data); + +/* + * Quartz display mode function list + */ +typedef struct _QuartzModeProcs { + DisplayInitProc DisplayInit; + AddScreenProc AddScreen; + SetupScreenProc SetupScreen; + InitInputProc InitInput; + + InitCursorProc InitCursor; + CursorUpdateProc CursorUpdate; // Not used if NULL + + SuspendScreenProc SuspendScreen; + ResumeScreenProc ResumeScreen; + CaptureScreensProc CaptureScreens; // Only called in fullscreen + ReleaseScreensProc ReleaseScreens; // Only called in fullscreen + + IsX11WindowProc IsX11Window; + + FrameForWindowProc FrameForWindow; + TopLevelParentProc TopLevelParent; + CreateSurfaceProc CreateSurface; + DestroySurfaceProc DestroySurface; +} QuartzModeProcsRec, *QuartzModeProcsPtr; + +extern QuartzModeProcsPtr quartzProcs; + +Bool QuartzLoadDisplayBundle(const char *dpyBundleName); #endif diff --git a/hw/darwin/quartz/quartzAudio.c b/hw/darwin/quartz/quartzAudio.c index 2dfb313b7..a3e6af127 100644 --- a/hw/darwin/quartz/quartzAudio.c +++ b/hw/darwin/quartz/quartzAudio.c @@ -35,7 +35,7 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzAudio.c,v 1.1 2002/03/28 02:21:18 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzAudio.c,v 1.2 2003/05/14 05:27:56 torrey Exp $ */ #include "quartzCommon.h" #include "quartzAudio.h" @@ -242,10 +242,10 @@ static void QuartzCoreAudioBell( /* - * QuartzBell + * DarwinModeBell * Ring the bell */ -void QuartzBell( +void DarwinModeBell( int volume, // volume in percent of max DeviceIntPtr pDevice, pointer ctrl, diff --git a/hw/darwin/quartz/quartzCocoa.m b/hw/darwin/quartz/quartzCocoa.m index d6d9bbe32..bba71c041 100644 --- a/hw/darwin/quartz/quartzCocoa.m +++ b/hw/darwin/quartz/quartzCocoa.m @@ -33,12 +33,17 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCocoa.m,v 1.3 2003/01/19 06:52:54 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCocoa.m,v 1.4 2003/05/14 05:27:56 torrey Exp $ */ + +#include "quartzCommon.h" + +#define BOOL xBOOL +#include "darwin.h" +#undef BOOL #include <Cocoa/Cocoa.h> #import "Preferences.h" -#include "quartzCommon.h" #include "pseudoramiX.h" extern void FatalError(const char *, ...); @@ -57,7 +62,7 @@ void QuartzReadPreferences(void) darwinFakeButtons = [Preferences fakeButtons]; darwinFakeMouse2Mask = [Preferences button2Mask]; darwinFakeMouse3Mask = [Preferences button3Mask]; - quartzMouseAccelChange = [Preferences mouseAccelChange]; + darwinMouseAccelChange = [Preferences mouseAccelChange]; quartzUseSysBeep = [Preferences systemBeep]; // quartzRootless has already been set diff --git a/hw/darwin/quartz/quartzCommon.h b/hw/darwin/quartz/quartzCommon.h index 6c375bd04..e3ae4b850 100644 --- a/hw/darwin/quartz/quartzCommon.h +++ b/hw/darwin/quartz/quartzCommon.h @@ -31,7 +31,7 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCommon.h,v 1.8 2003/01/23 00:34:26 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCommon.h,v 1.14 2003/11/12 20:21:51 torrey Exp $ */ #ifndef _QUARTZCOMMON_H #define _QUARTZCOMMON_H @@ -48,8 +48,6 @@ #undef WindowPtr #undef Picture -#include "quartzShared.h" - // Quartz specific per screen storage structure typedef struct { // List of CoreGraphics displays that this X11 screen covers. @@ -78,11 +76,17 @@ extern int quartzServerQuitting; extern int quartzScreenIndex; extern int aquaMenuBarHeight; +// Name of GLX bundle for native OpenGL +extern const char *quartzOpenGLBundle; + void QuartzReadPreferences(void); void QuartzMessageMainThread(unsigned msg, void *data, unsigned length); +void QuartzMessageServerThread(int type, int argc, ...); +void QuartzSetWindowMenu(int nitems, const char **items, + const char *shortcuts); void QuartzFSCapture(void); void QuartzFSRelease(void); -int QuartzFSUseQDCursor(int depth); +int QuartzFSUseQDCursor(int depth); void QuartzBlockHandler(void *blockData, void *pTimeout, void *pReadmask); void QuartzWakeupHandler(void *blockData, int result, void *pReadmask); @@ -92,7 +96,11 @@ enum { kQuartzServerStarted, kQuartzServerDied, kQuartzCursorUpdate, - kQuartzPostEvent + kQuartzPostEvent, + kQuartzSetWindowMenu, + kQuartzSetWindowMenuCheck, + kQuartzSetFrontProcess, + kQuartzSetCanQuit }; #endif /* _QUARTZCOMMON_H */ diff --git a/hw/darwin/quartz/quartzStartup.c b/hw/darwin/quartz/quartzStartup.c index dfa7b8166..bb7c7d214 100644 --- a/hw/darwin/quartz/quartzStartup.c +++ b/hw/darwin/quartz/quartzStartup.c @@ -28,13 +28,14 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzStartup.c,v 1.3 2003/01/19 06:35:13 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzStartup.c,v 1.9 2003/11/15 00:07:09 torrey Exp $ */ #include <fcntl.h> #include <unistd.h> #include <CoreFoundation/CoreFoundation.h> #include "quartzCommon.h" #include "darwin.h" +#include "quartz.h" #include "opaque.h" #include "micmap.h" @@ -50,6 +51,8 @@ static GlxExtensionInitPtr GlxExtensionInit = NULL; typedef void (*GlxWrapInitVisualsPtr)(miInitVisualsProcPtr *); static GlxWrapInitVisualsPtr GlxWrapInitVisuals = NULL; +typedef Bool (*QuartzModeBundleInitPtr)(void); + /* * DarwinHandleGUI @@ -76,19 +79,25 @@ void DarwinHandleGUI( // Make a pipe to pass events assert( pipe(fd) == 0 ); - darwinEventFD = fd[0]; - quartzEventWriteFD = fd[1]; - fcntl(darwinEventFD, F_SETFL, O_NONBLOCK); + darwinEventReadFD = fd[0]; + darwinEventWriteFD = fd[1]; + fcntl(darwinEventReadFD, F_SETFL, O_NONBLOCK); // Store command line arguments to pass back to main() argcGlobal = argc; argvGlobal = argv; envpGlobal = envp; - // Determine if we need to start X clients - // and what display mode to use quartzStartClients = 1; for (i = 1; i < argc; i++) { + // Display version info without starting Mac OS X UI if requested + if (!strcmp( argv[i], "-showconfig" ) || !strcmp( argv[i], "-version" )) { + DarwinPrintBanner(); + exit(0); + } + + // Determine if we need to start X clients + // and what display mode to use if (!strcmp(argv[i], "-nostartx")) { quartzStartClients = 0; } else if (!strcmp( argv[i], "-fullscreen")) { @@ -98,13 +107,70 @@ void DarwinHandleGUI( } } - quartz = TRUE; main_exit = NSApplicationMain(argc, argv); exit(main_exit); } /* + * QuartzLoadDisplayBundle + * Try to load the appropriate bundle containing the back end display code. + */ +Bool QuartzLoadDisplayBundle( + const char *dpyBundleName) +{ + CFBundleRef mainBundle; + CFStringRef bundleName; + CFURLRef bundleURL; + CFBundleRef dpyBundle; + QuartzModeBundleInitPtr bundleInit; + + // Get the main bundle for the application + mainBundle = CFBundleGetMainBundle(); + + // Make CFString from bundle name + bundleName = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, + dpyBundleName, + kCFStringEncodingASCII, + kCFAllocatorNull); + + // Look for the appropriate bundle in the main bundle + bundleURL = CFBundleCopyResourceURL(mainBundle, bundleName, + NULL, NULL); + if (!bundleURL) { + ErrorF("Could not find display mode bundle %s.\n", dpyBundleName); + return FALSE; + } + + // Make a bundle instance using the URLRef + dpyBundle = CFBundleCreate(kCFAllocatorDefault, bundleURL); + + if (!CFBundleLoadExecutable(dpyBundle)) { + ErrorF("Could not load display mode bundle %s.\n", dpyBundleName); + return FALSE; + } + + // Lookup the bundle initialization function + bundleInit = (void *) + CFBundleGetFunctionPointerForName(dpyBundle, + CFSTR("QuartzModeBundleInit")); + if (!bundleInit) { + ErrorF("Could not initialize display mode bundle %s.\n", + dpyBundleName); + return FALSE; + } + if (!bundleInit()) + return FALSE; + + // Release the CF objects + CFRelease(bundleName); + CFRelease(bundleURL); + + return TRUE; +} + + +/* * LoadGlxBundle * The Quartz mode X server needs to dynamically load the appropriate * bundle before initializing GLX. @@ -122,10 +188,14 @@ static void LoadGlxBundle(void) // Choose the bundle to load ErrorF("Loading GLX bundle "); if (quartzUseAGL) { - bundleName = CFSTR("glxAGL.bundle"); - ErrorF("glxAGL.bundle (using Apple's OpenGL)\n"); + bundleName = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, + quartzOpenGLBundle, + kCFStringEncodingASCII, + kCFAllocatorNull); + ErrorF("%s (using Apple's OpenGL)\n", quartzOpenGLBundle); } else { bundleName = CFSTR("glxMesa.bundle"); + CFRetain(bundleName); // so we can release later ErrorF("glxMesa.bundle (using Mesa)\n"); } @@ -155,7 +225,7 @@ static void LoadGlxBundle(void) } // Release the CF objects - CFRelease(mainBundle); + CFRelease(bundleName); CFRelease(bundleURL); } @@ -186,7 +256,7 @@ void DarwinGlxWrapInitVisuals( } -int QuartzProcessArgument( int argc, char *argv[], int i ) +int DarwinModeProcessArgument( int argc, char *argv[], int i ) { // fullscreen: CoreGraphics full-screen mode // rootless: Cocoa rootless mode @@ -208,7 +278,7 @@ int QuartzProcessArgument( int argc, char *argv[], int i ) QUARTZ_SAFETY_DELAY ); #endif return 1; - } + } if ( !strcmp( argv[i], "-quartz" ) ) { ErrorF( "Running in parallel with Mac OS X Quartz window server.\n" ); diff --git a/hw/darwin/utils/dumpkeymap.c b/hw/darwin/utils/dumpkeymap.c index c1b6ea15b..a264cbc10 100644 --- a/hw/darwin/utils/dumpkeymap.c +++ b/hw/darwin/utils/dumpkeymap.c @@ -1,4 +1,4 @@ -// $XFree86: xc/programs/Xserver/hw/darwin/utils/dumpkeymap.c,v 1.3 2000/12/05 21:18:34 dawes Exp $ +// $XFree86: xc/programs/Xserver/hw/darwin/utils/dumpkeymap.c,v 1.4 2003/04/13 14:52:51 herrb Exp $ //============================================================================= // // Copyright (C) 1999,2000 by Eric Sunshine <sunshine@sunshineco.com> @@ -141,6 +141,7 @@ #include <ctype.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <sys/stat.h> #if !defined(DUMPKEYMAP_FILE_ONLY) #include <drivers/event_status_driver.h> |