diff options
Diffstat (limited to 'hw/darwin/quartz')
-rw-r--r-- | hw/darwin/quartz/Preferences.h | 2 | ||||
-rw-r--r-- | hw/darwin/quartz/Preferences.m | 21 | ||||
-rw-r--r-- | hw/darwin/quartz/XDarwin.pbproj/project.pbxproj | 4 | ||||
-rw-r--r-- | hw/darwin/quartz/XServer.h | 7 | ||||
-rw-r--r-- | hw/darwin/quartz/XServer.m | 145 | ||||
-rw-r--r-- | hw/darwin/quartz/cr/crFrame.m | 1 | ||||
-rw-r--r-- | hw/darwin/quartz/cr/crScreen.m | 192 | ||||
-rw-r--r-- | hw/darwin/quartz/fullscreen/fullscreen.c | 15 | ||||
-rw-r--r-- | hw/darwin/quartz/pseudoramiX.c | 14 | ||||
-rw-r--r-- | hw/darwin/quartz/pseudoramiX.h | 3 | ||||
-rw-r--r-- | hw/darwin/quartz/quartz.c | 91 | ||||
-rw-r--r-- | hw/darwin/quartz/quartz.h | 13 | ||||
-rw-r--r-- | hw/darwin/quartz/quartzCocoa.m | 7 | ||||
-rw-r--r-- | hw/darwin/quartz/quartzCommon.h | 9 | ||||
-rw-r--r-- | hw/darwin/quartz/xpr/xpr.h | 2 | ||||
-rw-r--r-- | hw/darwin/quartz/xpr/xprFrame.c | 2 | ||||
-rw-r--r-- | hw/darwin/quartz/xpr/xprScreen.c | 97 |
17 files changed, 436 insertions, 189 deletions
diff --git a/hw/darwin/quartz/Preferences.h b/hw/darwin/quartz/Preferences.h index feecf24d6..d8c3c2ea2 100644 --- a/hw/darwin/quartz/Preferences.h +++ b/hw/darwin/quartz/Preferences.h @@ -84,6 +84,7 @@ + (void)setModeWindow:(BOOL)newModeWindow; + (void)setStartupHelp:(BOOL)newStartupHelp; + (void)setSystemBeep:(BOOL)newSystemBeep; ++ (void)setEnableKeyEquivalents:(BOOL)newKeyEquivs; + (void)setXinerama:(BOOL)newXinerama; + (void)setAddToPath:(BOOL)newAddToPath; + (void)setAddToPathString:(NSString *)newAddToPathString; @@ -110,6 +111,7 @@ + (BOOL)modeWindow; + (BOOL)startupHelp; + (BOOL)systemBeep; ++ (BOOL)enableKeyEquivalents; + (BOOL)xinerama; + (BOOL)addToPath; + (NSString *)addToPathString; diff --git a/hw/darwin/quartz/Preferences.m b/hw/darwin/quartz/Preferences.m index cca2f695d..6c14f4982 100644 --- a/hw/darwin/quartz/Preferences.m +++ b/hw/darwin/quartz/Preferences.m @@ -4,7 +4,7 @@ // This class keeps track of the user preferences. // /* - * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved. + * Copyright (c) 2002-2004 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 @@ -30,7 +30,7 @@ * sale, use or other dealings in this Software without prior written * authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/Preferences.m,v 1.3 2003/05/14 05:27:56 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/Preferences.m,v 1.5 2004/06/08 22:58:10 torrey Exp $ */ #import "quartzCommon.h" @@ -49,6 +49,9 @@ #define STR(s) #s #define XSTRPATH(s) STR(s) +// Keys for user defaults dictionary +static NSString *X11EnableKeyEquivalentsKey = @"EnableKeyEquivalents"; + @implementation Preferences @@ -70,6 +73,7 @@ [NSNumber numberWithInt:0], @"SwitchKeyCode", [NSNumber numberWithInt:(NSCommandKeyMask | NSAlternateKeyMask)], @"SwitchModifiers", @"NO", @"UseSystemBeep", + @"YES", X11EnableKeyEquivalentsKey, @"YES", @"DockSwitch", @"NO", @"AllowMouseAccelChange", [NSNumber numberWithInt:qdCursor_Not8Bit], @"UseQDCursor", @@ -391,6 +395,14 @@ quartzUseSysBeep = newSystemBeep; } ++ (void)setEnableKeyEquivalents:(BOOL)newKeyEquivs +{ + [[NSUserDefaults standardUserDefaults] setBool:newKeyEquivs + forKey:X11EnableKeyEquivalentsKey]; + // Update the setting used by the X server thread + quartzEnableKeyEquivalents = newKeyEquivs; +} + + (void)setXinerama:(BOOL)newXinerama { [[NSUserDefaults standardUserDefaults] setBool:newXinerama @@ -537,6 +549,11 @@ return [[NSUserDefaults standardUserDefaults] boolForKey:@"UseSystemBeep"]; } ++ (BOOL)enableKeyEquivalents +{ + return [[NSUserDefaults standardUserDefaults] boolForKey:X11EnableKeyEquivalentsKey]; +} + + (BOOL)xinerama { return [[NSUserDefaults standardUserDefaults] boolForKey:@"Xinerama"]; diff --git a/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj b/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj index 9dc2bb92c..109e313f3 100644 --- a/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj +++ b/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj @@ -334,7 +334,7 @@ <key>CFBundleExecutable</key> <string>XDarwin</string> <key>CFBundleGetInfoString</key> - <string>XDarwin 1.3.0, X.Org Foundation</string> + <string>XDarwin 1.4.0, X.Org Foundation</string> <key>CFBundleIconFile</key> <string>XDarwin.icns</string> <key>CFBundleIdentifier</key> @@ -346,7 +346,7 @@ <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> - <string>XDarwin 1.3.0</string> + <string>XDarwin 1.4.0</string> <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> diff --git a/hw/darwin/quartz/XServer.h b/hw/darwin/quartz/XServer.h index 5fef683a8..dc6701b22 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. */ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/XServer.h,v 1.1.4.2.4.2 2004/03/04 20:16:11 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/XServer.h,v 1.3 2004/07/30 19:12:17 torrey Exp $ */ /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XServer.h,v 1.16 2003/11/23 06:04:01 torrey Exp $ */ #define BOOL xBOOL @@ -39,7 +39,7 @@ #import <Cocoa/Cocoa.h> @interface XServer : NSObject { - // server state + // Server state int serverState; NSRecursiveLock *serverLock; NSMutableArray *pendingClients; @@ -49,6 +49,7 @@ BOOL quitWithoutQuery; BOOL pendingAppQuitReply; UInt32 mouseState; + unsigned short swallowedKey; BOOL sendServerEvents; BOOL x11Active; @@ -73,7 +74,7 @@ - (BOOL)translateEvent:(NSEvent *)anEvent; - (BOOL)getMousePosition:(xEvent *)xe fromEvent:(NSEvent *)anEvent; -+ (void)append:(NSString *)value toEnv:(NSString *)name; +- (NSString *)makeSafePath:(NSString *)path; - (BOOL)loadDisplayBundle; - (void)startX; diff --git a/hw/darwin/quartz/XServer.m b/hw/darwin/quartz/XServer.m index 58cba6fbc..3b30d1bf3 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. */ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.1.4.2.4.2 2004/03/04 20:16:11 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.3 2004/07/30 19:12:17 torrey Exp $ */ /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.19 2003/11/24 05:39:01 torrey Exp $ */ #include "quartzCommon.h" @@ -83,11 +83,11 @@ typedef struct { } shellList_t; static shellList_t const shellList[] = { - { "csh", shell_C }, // standard C shell - { "tcsh", shell_C }, // ... needs no introduction - { "sh", shell_Bourne }, // standard Bourne shell - { "zsh", shell_Bourne }, // Z shell - { "bash", shell_Bourne }, // GNU Bourne again shell + { "csh", shell_C }, // standard C shell + { "tcsh", shell_C }, // ... needs no introduction + { "sh", shell_Bourne }, // standard Bourne shell + { "zsh", shell_Bourne }, // Z shell + { "bash", shell_Bourne }, // GNU Bourne again shell { NULL, shell_Unknown } }; @@ -267,6 +267,7 @@ static io_connect_t root_port; xe.u.u.type = ButtonRelease; xe.u.u.detail = 1; break; + case NSLeftMouseDown: [self getMousePosition:&xe fromEvent:anEvent]; if (quartzRootless) { @@ -286,6 +287,7 @@ static io_connect_t root_port; xe.u.u.type = ButtonPress; xe.u.u.detail = 1; break; + case NSMouseMoved: case NSLeftMouseDragged: case NSRightMouseDragged: @@ -293,6 +295,7 @@ static io_connect_t root_port; [self getMousePosition:&xe fromEvent:anEvent]; xe.u.u.type = MotionNotify; break; + case NSSystemDefined: { long hwButtons = [anEvent data2]; @@ -309,36 +312,56 @@ static io_connect_t root_port; xe.u.clientMessage.u.l.longs1 =[anEvent data2]; break; } + case NSScrollWheel: [self getMousePosition:&xe fromEvent:anEvent]; xe.u.u.type = kXDarwinScrollWheel; - xe.u.clientMessage.u.s.shorts0 = [anEvent deltaY]; + xe.u.clientMessage.u.s.shorts0 = [anEvent deltaX] + + [anEvent deltaY]; break; + case NSKeyDown: case NSKeyUp: - if (!x11Active) + if (!x11Active) { + swallowedKey = 0; 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]) - return NO; - if (type == NSKeyDown) - xe.u.u.type = KeyPress; - else - xe.u.u.type = KeyRelease; + } + + if (type == NSKeyDown) { + // If the mouse is not on the valid X display area, + // don't send the X server key events. + if (![self getMousePosition:&xe fromEvent:nil]) { + swallowedKey = [anEvent keyCode]; + return NO; + } + + // See if there are any global shortcuts for this key combo. + if (quartzEnableKeyEquivalents + && [[NSApp mainMenu] performKeyEquivalent:anEvent]) + { + swallowedKey = [anEvent keyCode]; + return YES; + } + } else { + // If the down key event was a valid key combo, + // don't pass the up event to X11. + if (swallowedKey != 0 && [anEvent keyCode] == swallowedKey) { + swallowedKey = 0; + return NO; + } + } + + xe.u.u.type = (type == NSKeyDown) ? KeyPress : KeyRelease; 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; break; - case NSOtherMouseDown: // undocumented MouseDown - case NSOtherMouseUp: // undocumented MouseUp - // Hide these from AppKit to avoid its log messages - return YES; + default: return NO; } @@ -395,14 +418,33 @@ static io_connect_t root_port; } } -// Append a string to the given enviroment variable -+ (void)append:(NSString*)value toEnv:(NSString*)name + +// Make a safe path +// +// Return the path in single quotes in case there are problematic characters in it. +// We still have to worry about there being single quotes in the path. So, replace +// all instances of the ' character in the path with '\''. +- (NSString *)makeSafePath:(NSString *)path { - setenv([name cString], - [[[NSString stringWithCString:getenv([name cString])] - stringByAppendingString:value] cString],1); + NSMutableString *safePath = [NSMutableString stringWithString:path]; + NSRange aRange = NSMakeRange(0, [safePath length]); + + while (aRange.length) { + aRange = [safePath rangeOfString:@"'" options:0 range:aRange]; + if (!aRange.length) + break; + [safePath replaceCharactersInRange:aRange + withString:@"\'\\'\'"]; + aRange.location += 4; + aRange.length = [safePath length] - aRange.location; + } + + safePath = [NSMutableString stringWithFormat:@"'%@'", safePath]; + + return safePath; } + - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Block SIGPIPE @@ -488,13 +530,21 @@ static io_connect_t root_port; if (![self loadDisplayBundle]) [NSApp terminate:nil]; - // In rootless mode register to receive notification of key window changes if (quartzRootless) { + // We need to track whether the key window is an X11 window [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowBecameKey:) name:NSWindowDidBecomeKeyNotification object:nil]; + + // Request notification of screen layout changes even when this + // is not the active application + [[NSDistributedNotificationCenter defaultCenter] + addObserver:self + selector:@selector(applicationDidChangeScreenParameters:) + name:NSApplicationDidChangeScreenParametersNotification + object:nil]; } // Start the X server thread @@ -581,8 +631,7 @@ static io_connect_t root_port; { struct passwd *passwdUser; NSString *shellPath, *dashShellName, *commandStr, *startXPath; - NSMutableString *safeStartXPath; - NSRange aRange; + NSString *safeStartXPath; NSBundle *thisBundle; const char *shellPathStr, *newargv[3], *shellNameStr; int fd[2], outFD, length, shellType, i; @@ -645,11 +694,11 @@ static io_connect_t root_port; // Inside the new process: if (fd[0] != STDIN_FILENO) { - dup2(fd[0], STDIN_FILENO); // Take stdin from pipe + dup2(fd[0], STDIN_FILENO); // Take stdin from pipe close(fd[0]); } - close(fd[1]); // Close write end of pipe - if (outFD == STDOUT_FILENO) { // Setup stdout and stderr + close(fd[1]); // Close write end of pipe + if (outFD == STDOUT_FILENO) { // Setup stdout and stderr dup2(outFD, STDERR_FILENO); } else if (outFD == STDERR_FILENO) { dup2(outFD, STDOUT_FILENO); @@ -685,28 +734,14 @@ static io_connect_t root_port; return NO; } - // We will run the startXClients script with the path in single quotes - // in case there are problematic characters in the path. We still have - // to worry about there being single quotes in the path. So, replace - // all instances of the ' character in startXPath with '\''. - safeStartXPath = [NSMutableString stringWithString:startXPath]; - aRange = NSMakeRange(0, [safeStartXPath length]); - while (aRange.length) { - aRange = [safeStartXPath rangeOfString:@"'" options:0 range:aRange]; - if (!aRange.length) - break; - [safeStartXPath replaceCharactersInRange:aRange - withString:@"\'\\'\'"]; - aRange.location += 4; - aRange.length = [safeStartXPath length] - aRange.location; - } + safeStartXPath = [self makeSafePath:startXPath]; if ([Preferences addToPath]) { - commandStr = [NSString stringWithFormat:@"'%@' :%d %@\n", + commandStr = [NSString stringWithFormat:@"%@ :%d %@\n", safeStartXPath, [Preferences display], [Preferences addToPathString]]; } else { - commandStr = [NSString stringWithFormat:@"'%@' :%d\n", + commandStr = [NSString stringWithFormat:@"%@ :%d\n", safeStartXPath, [Preferences display]]; } @@ -726,7 +761,7 @@ static io_connect_t root_port; // FIXME: This should be unified with startXClients - (void)runClient:(NSString *)filename { - const char *command = [filename UTF8String]; + const char *command = [[self makeSafePath:filename] UTF8String]; const char *shell; const char *argv[5]; int child1, child2 = 0; @@ -1177,10 +1212,10 @@ static io_connect_t root_port; - (void)activateX11:(BOOL)state { if (state) { - QuartzMessageServerThread(kXDarwinActivate, 0); + QuartzMessageServerThread(kXDarwinActivate, 0); } else { - QuartzMessageServerThread(kXDarwinDeactivate, 0); + QuartzMessageServerThread(kXDarwinDeactivate, 0); } x11Active = state; @@ -1311,6 +1346,12 @@ static io_connect_t root_port; * Application Delegate Methods */ +- (void)applicationDidChangeScreenParameters:(NSNotification *)aNotification +{ + if (quartzProcs->ScreenChanged) + quartzProcs->ScreenChanged(); +} + - (void)applicationDidHide:(NSNotification *)aNotification { if ((AppleWMSelectedEvents() & AppleWMControllerNotifyMask) != 0) { diff --git a/hw/darwin/quartz/cr/crFrame.m b/hw/darwin/quartz/cr/crFrame.m index 1ea40f0aa..81ec3688f 100644 --- a/hw/darwin/quartz/cr/crFrame.m +++ b/hw/darwin/quartz/cr/crFrame.m @@ -27,6 +27,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. */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/cr/crFrame.m,v 1.2 2004/04/23 19:15:51 eich Exp $ */ /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/cr/crFrame.m,v 1.9 2004/03/19 02:05:29 torrey Exp $ */ #include "quartzCommon.h" diff --git a/hw/darwin/quartz/cr/crScreen.m b/hw/darwin/quartz/cr/crScreen.m index 6b5a2c8cf..1006e0adc 100644 --- a/hw/darwin/quartz/cr/crScreen.m +++ b/hw/darwin/quartz/cr/crScreen.m @@ -1,10 +1,10 @@ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/cr/crScreen.m,v 1.1.4.2.4.2 2004/03/04 17:47:30 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/cr/crScreen.m,v 1.4 2004/08/12 20:24:36 torrey Exp $ */ /* * Cocoa rootless implementation initialization */ /* * Copyright (c) 2001 Greg Parker. All Rights Reserved. - * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved. + * Copyright (c) 2002-2004 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"), @@ -47,6 +47,9 @@ #include "scrnintstr.h" #include "picturestr.h" #include "globals.h" +#ifdef DAMAGE +# include "damage.h" +#endif #undef BOOL // Name of GLX bundle using AGL framework @@ -79,6 +82,79 @@ CRDisplayInit(void) /* + * CRAddPseudoramiXScreens + * Add a single virtual screen encompassing all the physical screens + * with PseudoramiX. + */ +static void +CRAddPseudoramiXScreens(int *x, int *y, int *width, int *height) +{ + int i; + NSRect unionRect = NSMakeRect(0, 0, 0, 0); + NSArray *screens = [NSScreen screens]; + + // Get the union of all screens (minus the menu bar on main screen) + for (i = 0; i < [screens count]; i++) { + NSScreen *screen = [screens objectAtIndex:i]; + NSRect frame = [screen frame]; + frame.origin.y = [[NSScreen mainScreen] frame].size.height - + frame.size.height - frame.origin.y; + if (NSEqualRects([screen frame], [[NSScreen mainScreen] frame])) { + frame.origin.y += aquaMenuBarHeight; + frame.size.height -= aquaMenuBarHeight; + } + unionRect = NSUnionRect(unionRect, frame); + } + + // Use unionRect as the screen size for the X server. + *x = unionRect.origin.x; + *y = unionRect.origin.y; + *width = unionRect.size.width; + *height = unionRect.size.height; + + // Tell PseudoramiX about the real screens. + // InitOutput() will move the big screen to (0,0), + // so compensate for that here. + for (i = 0; i < [screens count]; i++) { + NSScreen *screen = [screens objectAtIndex:i]; + NSRect frame = [screen frame]; + int j; + + // Skip this screen if it's a mirrored copy of an earlier screen. + for (j = 0; j < i; j++) { + if (NSEqualRects(frame, [[screens objectAtIndex:j] frame])) { + ErrorF("PseudoramiX screen %d is a mirror of screen %d.\n", + i, j); + break; + } + } + if (j < i) continue; // this screen is a mirrored copy + + frame.origin.y = [[NSScreen mainScreen] frame].size.height - + frame.size.height - frame.origin.y; + + if (NSEqualRects([screen frame], [[NSScreen mainScreen] frame])) { + frame.origin.y += aquaMenuBarHeight; + frame.size.height -= aquaMenuBarHeight; + } + + ErrorF("PseudoramiX screen %d added: %dx%d @ (%d,%d).\n", i, + (int)frame.size.width, (int)frame.size.height, + (int)frame.origin.x, (int)frame.origin.y); + + frame.origin.x -= unionRect.origin.x; + frame.origin.y -= unionRect.origin.y; + + ErrorF("PseudoramiX screen %d placed at X11 coordinate (%d,%d).\n", + i, (int)frame.origin.x, (int)frame.origin.y); + + PseudoramiXAddScreen(frame.origin.x, frame.origin.y, + frame.size.width, frame.size.height); + } +} + + +/* * CRScreenParams * Set the basic screen parameters. */ @@ -100,7 +176,6 @@ CRScreenParams(int index, DarwinFramebufferPtr dfb) dfb->width = NSWidth(frame); dfb->height = NSHeight(frame); - dfb->pitch = (dfb->width) * (dfb->bitsPerPixel) / 8; // Shift the usable part of main screen down to avoid the menu bar. if (NSEqualRects(frame, [[NSScreen mainScreen] frame])) { @@ -109,69 +184,7 @@ CRScreenParams(int index, DarwinFramebufferPtr dfb) } } else { - int i; - NSRect unionRect = NSMakeRect(0, 0, 0, 0); - NSArray *screens = [NSScreen screens]; - - // Get the union of all screens (minus the menu bar on main screen) - for (i = 0; i < [screens count]; i++) { - NSScreen *screen = [screens objectAtIndex:i]; - NSRect frame = [screen frame]; - frame.origin.y = [[NSScreen mainScreen] frame].size.height - - frame.size.height - frame.origin.y; - if (NSEqualRects([screen frame], [[NSScreen mainScreen] frame])) { - frame.origin.y += aquaMenuBarHeight; - frame.size.height -= aquaMenuBarHeight; - } - unionRect = NSUnionRect(unionRect, frame); - } - - // Use unionRect as the screen size for the X server. - dfb->x = unionRect.origin.x; - dfb->y = unionRect.origin.y; - dfb->width = unionRect.size.width; - dfb->height = unionRect.size.height; - dfb->pitch = (dfb->width) * (dfb->bitsPerPixel) / 8; - - // Tell PseudoramiX about the real screens. - // InitOutput() will move the big screen to (0,0), - // so compensate for that here. - for (i = 0; i < [screens count]; i++) { - NSScreen *screen = [screens objectAtIndex:i]; - NSRect frame = [screen frame]; - int j; - - // Skip this screen if it's a mirrored copy of an earlier screen. - for (j = 0; j < i; j++) { - if (NSEqualRects(frame, [[screens objectAtIndex:j] frame])) { - ErrorF("PseudoramiX screen %d is a mirror of screen %d.\n", - i, j); - break; - } - } - if (j < i) continue; // this screen is a mirrored copy - - frame.origin.y = [[NSScreen mainScreen] frame].size.height - - frame.size.height - frame.origin.y; - - if (NSEqualRects([screen frame], [[NSScreen mainScreen] frame])) { - frame.origin.y += aquaMenuBarHeight; - frame.size.height -= aquaMenuBarHeight; - } - - ErrorF("PseudoramiX screen %d added: %dx%d @ (%d,%d).\n", i, - (int)frame.size.width, (int)frame.size.height, - (int)frame.origin.x, (int)frame.origin.y); - - frame.origin.x -= unionRect.origin.x; - frame.origin.y -= unionRect.origin.y; - - ErrorF("PseudoramiX screen %d placed at X11 coordinate (%d,%d).\n", - i, (int)frame.origin.x, (int)frame.origin.y); - - PseudoramiXAddScreen(frame.origin.x, frame.origin.y, - frame.size.width, frame.size.height); - } + CRAddPseudoramiXScreens(&dfb->x, &dfb->y, &dfb->width, &dfb->height); } } @@ -195,8 +208,11 @@ CRAddScreen(int index, ScreenPtr pScreen) dfb->colorType = TrueColor; - // No frame buffer - it's all in window pixmaps. - dfb->framebuffer = NULL; // malloc(dfb.pitch * dfb.height); + /* Passing zero width (pitch) makes miCreateScreenResources set the + screen pixmap to the framebuffer pointer, i.e. NULL. The generic + rootless code takes care of making this work. */ + dfb->pitch = 0; + dfb->framebuffer = NULL; // Get all CoreGraphics displays covered by this X11 display. cgRect = CGRectMake(dfb->x, dfb->y, dfb->width, dfb->height); @@ -245,12 +261,47 @@ CRSetupScreen(int index, ScreenPtr pScreen) } #endif /* RENDER */ +#ifdef DAMAGE + // The Damage extension needs to wrap underneath the + // generic rootless layer, so do it now. + if (!DamageSetup(pScreen)) + return FALSE; +#endif + // Initialize generic rootless code return CRInit(pScreen); } /* + * CRScreenChanged + * Configuration of displays has changed. + */ +static void +CRScreenChanged(void) +{ + QuartzMessageServerThread(kXDarwinDisplayChanged, 0); +} + + +/* + * CRUpdateScreen + * Update screen after configuation change. + */ +static void +CRUpdateScreen(ScreenPtr pScreen) +{ + rootlessGlobalOffsetX = darwinMainScreenX; + rootlessGlobalOffsetY = darwinMainScreenY; + + AppleWMSetScreenOrigin(WindowTable[pScreen->myNum]); + + RootlessRepositionWindows(pScreen); + RootlessUpdateScreenPixmap(pScreen); +} + + +/* * CRInitInput * Finalize CR specific setup. */ @@ -300,11 +351,14 @@ static QuartzModeProcsRec crModeProcs = { QuartzResumeXCursor, NULL, // No capture or release in rootless mode NULL, + CRScreenChanged, + CRAddPseudoramiXScreens, + CRUpdateScreen, CRIsX11Window, NULL, // Cocoa NSWindows hide themselves RootlessFrameForWindow, TopLevelParent, - NULL, // No support for DRI surfaces + NULL, // No support for DRI surfaces NULL }; diff --git a/hw/darwin/quartz/fullscreen/fullscreen.c b/hw/darwin/quartz/fullscreen/fullscreen.c index 54223e85e..05542eafe 100644 --- a/hw/darwin/quartz/fullscreen/fullscreen.c +++ b/hw/darwin/quartz/fullscreen/fullscreen.c @@ -25,7 +25,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. */ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/fullscreen/fullscreen.c,v 1.1.4.2.4.2 2004/03/04 20:16:14 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/fullscreen/fullscreen.c,v 1.3 2004/07/30 19:12:18 torrey Exp $ */ /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/fullscreen/fullscreen.c,v 1.3 2003/11/27 01:59:53 torrey Exp $ */ #include "quartzCommon.h" @@ -261,7 +261,7 @@ static void FSSuspendScreen( */ static void FSResumeScreen( ScreenPtr pScreen, - int x, // cursor location + int x, // cursor location int y ) { QuartzResumeXCursor(pScreen, x, y); @@ -537,18 +537,21 @@ static QuartzModeProcsRec fsModeProcs = { FSDisplayInit, FSAddScreen, FSSetupScreen, - NULL, // Not needed + NULL, // Not needed QuartzInitCursor, QuartzReallySetCursor, FSSuspendScreen, FSResumeScreen, FSCapture, FSRelease, - NULL, // No rootless code in fullscreen + NULL, // No dynamic screen change support NULL, NULL, + NULL, // No rootless code in fullscreen NULL, - NULL, // No support for DRI surfaces + NULL, + NULL, + NULL, // No support for DRI surfaces NULL }; @@ -561,6 +564,6 @@ Bool QuartzModeBundleInit(void) { quartzProcs = &fsModeProcs; - quartzOpenGLBundle = NULL; // Only Mesa support for now + quartzOpenGLBundle = NULL; // Only Mesa support for now return TRUE; } diff --git a/hw/darwin/quartz/pseudoramiX.c b/hw/darwin/quartz/pseudoramiX.c index 2dd7c3ae5..9f71eae89 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.3 2003/04/30 23:15:39 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/pseudoramiX.c,v 1.4 2004/07/02 01:30:33 torrey Exp $ */ #include "pseudoramiX.h" @@ -111,11 +111,15 @@ void PseudoramiXExtensionInit(int argc, char *argv[]) if (noPseudoramiXExtension) return; + /* Even with only one screen we need to enable PseudoramiX to allow + dynamic screen configuration changes. */ +#if 0 if (pseudoramiXNumScreens == 1) { // Only one screen - disable Xinerama extension. noPseudoramiXExtension = TRUE; return; } +#endif // The server must not run the PanoramiX operations. noPanoramiXExtension = TRUE; @@ -142,12 +146,18 @@ void PseudoramiXExtensionInit(int argc, char *argv[]) } -static void PseudoramiXResetProc(ExtensionEntry *extEntry) +void PseudoramiXResetScreens(void) { pseudoramiXNumScreens = 0; } +static void PseudoramiXResetProc(ExtensionEntry *extEntry) +{ + PseudoramiXResetScreens(); +} + + // was PanoramiX static int ProcPseudoramiXQueryVersion(ClientPtr client) { diff --git a/hw/darwin/quartz/pseudoramiX.h b/hw/darwin/quartz/pseudoramiX.h index 23738cfb3..c2943369d 100644 --- a/hw/darwin/quartz/pseudoramiX.h +++ b/hw/darwin/quartz/pseudoramiX.h @@ -1,9 +1,10 @@ /* * Minimal implementation of PanoramiX/Xinerama */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/pseudoramiX.h,v 1.2 2003/04/30 23:15:39 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/pseudoramiX.h,v 1.3 2004/07/02 01:30:33 torrey Exp $ */ extern int noPseudoramiXExtension; void PseudoramiXAddScreen(int x, int y, int w, int h); void PseudoramiXExtensionInit(int argc, char *argv[]); +void PseudoramiXResetScreens(void); diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c index e7bdb0049..22151198a 100644 --- a/hw/darwin/quartz/quartz.c +++ b/hw/darwin/quartz/quartz.c @@ -1,11 +1,11 @@ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartz.c,v 1.1.4.3.4.2 2004/03/04 17:47:30 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartz.c,v 1.3 2004/07/30 19:12:17 torrey Exp $ */ /************************************************************** * * Quartz-specific support for the Darwin X Server * **************************************************************/ /* - * Copyright (c) 2001-2003 Greg Parker and Torrey T. Lyons. + * Copyright (c) 2001-2004 Greg Parker and Torrey T. Lyons. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -30,7 +30,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/quartz.c,v 1.13 2003/11/12 20:21:51 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartz.c,v 1.16 2004/07/02 01:30:33 torrey Exp $ */ #include "quartzCommon.h" #include "quartz.h" @@ -43,7 +43,9 @@ // X headers #include "scrnintstr.h" +#include "windowstr.h" #include "colormapst.h" +#include "globals.h" // System headers #include <sys/types.h> @@ -57,6 +59,7 @@ int quartzStartClients = 1; int quartzRootless = -1; int quartzUseSysBeep = 0; int quartzUseAGL = 1; +int quartzEnableKeyEquivalents = 1; int quartzServerVisible = TRUE; int quartzServerQuitting = FALSE; int quartzScreenIndex = 0; @@ -166,13 +169,78 @@ void DarwinModeInitInput( /* + * QuartzUpdateScreens + * Adjust for screen arrangement changes. + */ +static void QuartzUpdateScreens(void) +{ + ScreenPtr pScreen; + WindowPtr pRoot; + int x, y, width, height, sx, sy; + xEvent e; + + if (noPseudoramiXExtension || screenInfo.numScreens != 1) + { + /* FIXME: if not using Xinerama, we have multiple screens, and + to do this properly may need to add or remove screens. Which + isn't possible. So don't do anything. Another reason why + we default to running with Xinerama. */ + + return; + } + + pScreen = screenInfo.screens[0]; + + PseudoramiXResetScreens(); + quartzProcs->AddPseudoramiXScreens(&x, &y, &width, &height); + + dixScreenOrigins[pScreen->myNum].x = x; + dixScreenOrigins[pScreen->myNum].y = y; + pScreen->mmWidth = pScreen->mmWidth * ((double) width / pScreen->width); + pScreen->mmHeight = pScreen->mmHeight * ((double) height / pScreen->height); + pScreen->width = width; + pScreen->height = height; + + /* FIXME: should probably do something with RandR here. */ + + DarwinAdjustScreenOrigins(&screenInfo); + quartzProcs->UpdateScreen(pScreen); + + sx = dixScreenOrigins[pScreen->myNum].x + darwinMainScreenX; + sy = dixScreenOrigins[pScreen->myNum].y + darwinMainScreenY; + + /* Adjust the root window. */ + pRoot = WindowTable[pScreen->myNum]; + AppleWMSetScreenOrigin(pRoot); + pScreen->ResizeWindow(pRoot, x - sx, y - sy, width, height, NULL); + pScreen->PaintWindowBackground(pRoot, &pRoot->borderClip, PW_BACKGROUND); +// QuartzIgnoreNextWarpCursor(); + DefineInitialRootWindow(pRoot); + + /* Send an event for the root reconfigure */ + e.u.u.type = ConfigureNotify; + e.u.configureNotify.window = pRoot->drawable.id; + e.u.configureNotify.aboveSibling = None; + e.u.configureNotify.x = x - sx; + e.u.configureNotify.y = y - sy; + e.u.configureNotify.width = width; + e.u.configureNotify.height = height; + e.u.configureNotify.borderWidth = wBorderWidth(pRoot); + e.u.configureNotify.override = pRoot->overrideRedirect; + DeliverEvents(pRoot, &e, 1, NullWindow); + + /* FIXME: Should we use RREditConnectionInfo(pScreen)? */ +} + + +/* * QuartzShow * Show the X server on screen. Does nothing if already shown. * 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 + int x, // cursor location int y ) { int i; @@ -252,10 +320,10 @@ QuartzMessageServerThread( 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); + va_start (args, argc); + for (i = 0; i < argc; i++) + argv[i] = (int) va_arg (args, int); + va_end (args); } DarwinEQEnqueue(&xe); @@ -308,8 +376,8 @@ void DarwinModeProcessEvent( case kXDarwinControllerNotify: AppleWMSendEvent(AppleWMControllerNotify, AppleWMControllerNotifyMask, - xe->u.clientMessage.u.l.longs0, - xe->u.clientMessage.u.l.longs1); + xe->u.clientMessage.u.l.longs0, + xe->u.clientMessage.u.l.longs1); break; case kXDarwinPasteboardNotify: @@ -320,6 +388,9 @@ void DarwinModeProcessEvent( break; case kXDarwinDisplayChanged: + QuartzUpdateScreens(); + break; + case kXDarwinWindowState: case kXDarwinWindowMoved: // FIXME: Not implemented yet diff --git a/hw/darwin/quartz/quartz.h b/hw/darwin/quartz/quartz.h index 3961fe031..cee43325d 100644 --- a/hw/darwin/quartz/quartz.h +++ b/hw/darwin/quartz/quartz.h @@ -30,7 +30,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. */ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartz.h,v 1.1.4.2.4.2 2004/03/04 20:16:11 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartz.h,v 1.3 2004/07/30 19:12:17 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 @@ -68,6 +68,13 @@ typedef void (*CaptureScreensProc)(void); typedef void (*ReleaseScreensProc)(void); /* + * Screen state change support + */ +typedef void (*ScreenChangedProc)(void); +typedef void (*AddPseudoramiXScreensProc)(int *x, int *y, int *width, int *height); +typedef void (*UpdateScreenProc)(ScreenPtr pScreen); + +/* * Rootless helper functions */ typedef Bool (*IsX11WindowProc)(void *nsWindow, int windowNumber); @@ -104,6 +111,10 @@ typedef struct _QuartzModeProcs { CaptureScreensProc CaptureScreens; // Only called in fullscreen ReleaseScreensProc ReleaseScreens; // Only called in fullscreen + ScreenChangedProc ScreenChanged; + AddPseudoramiXScreensProc AddPseudoramiXScreens; + UpdateScreenProc UpdateScreen; + IsX11WindowProc IsX11Window; HideWindowsProc HideWindows; diff --git a/hw/darwin/quartz/quartzCocoa.m b/hw/darwin/quartz/quartzCocoa.m index 6adbaafba..52832ccd6 100644 --- a/hw/darwin/quartz/quartzCocoa.m +++ b/hw/darwin/quartz/quartzCocoa.m @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartzCocoa.m,v 1.1.4.3.2.2 2004/03/04 17:47:30 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartzCocoa.m,v 1.3 2004/07/30 19:12:17 torrey Exp $ */ /************************************************************** * * Quartz-specific support for the Darwin X Server @@ -9,7 +9,7 @@ * **************************************************************/ /* - * Copyright (c) 2001-2003 Torrey T. Lyons and Greg Parker. + * Copyright (c) 2001-2004 Torrey T. Lyons and Greg Parker. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -34,7 +34,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/quartzCocoa.m,v 1.3 2003/01/19 06:52:54 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCocoa.m,v 1.5 2004/06/08 22:58:10 torrey Exp $ */ #include "quartzCommon.h" @@ -65,6 +65,7 @@ void QuartzReadPreferences(void) darwinFakeMouse3Mask = [Preferences button3Mask]; darwinMouseAccelChange = [Preferences mouseAccelChange]; quartzUseSysBeep = [Preferences systemBeep]; + quartzEnableKeyEquivalents = [Preferences enableKeyEquivalents]; // quartzRootless has already been set if (quartzRootless) { diff --git a/hw/darwin/quartz/quartzCommon.h b/hw/darwin/quartz/quartzCommon.h index a09475d31..949f724c1 100644 --- a/hw/darwin/quartz/quartzCommon.h +++ b/hw/darwin/quartz/quartzCommon.h @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartzCommon.h,v 1.1.4.2.4.2 2004/03/04 17:47:30 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartzCommon.h,v 1.3 2004/07/30 19:12:17 torrey Exp $ */ /* * quartzCommon.h * @@ -7,7 +7,7 @@ * This file should be included before any X11 or IOKit headers * so that it can avoid symbol conflicts. * - * Copyright (c) 2001-2003 Torrey T. Lyons and Greg Parker. + * Copyright (c) 2001-2004 Torrey T. Lyons and Greg Parker. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -32,7 +32,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.13 2003/10/16 23:50:10 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCommon.h,v 1.15 2004/06/08 22:58:10 torrey Exp $ */ #ifndef _QUARTZCOMMON_H #define _QUARTZCOMMON_H @@ -70,6 +70,7 @@ extern int quartzStartClients; extern int quartzRootless; extern int quartzUseSysBeep; extern int quartzUseAGL; +extern int quartzEnableKeyEquivalents; // Other shared data extern int quartzServerVisible; @@ -104,4 +105,4 @@ enum { kQuartzSetCanQuit }; -#endif /* _QUARTZCOMMON_H */ +#endif /* _QUARTZCOMMON_H */ diff --git a/hw/darwin/quartz/xpr/xpr.h b/hw/darwin/quartz/xpr/xpr.h index ab9b9fd42..5b881c725 100644 --- a/hw/darwin/quartz/xpr/xpr.h +++ b/hw/darwin/quartz/xpr/xpr.h @@ -26,7 +26,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. */ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/xpr/xpr.h,v 1.1.4.1.4.2 2004/03/04 20:16:15 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/xpr/xpr.h,v 1.2 2004/04/23 19:16:52 eich Exp $ */ /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xpr.h,v 1.4 2003/11/12 20:21:52 torrey Exp $ */ #ifndef XPR_H diff --git a/hw/darwin/quartz/xpr/xprFrame.c b/hw/darwin/quartz/xpr/xprFrame.c index 0bf104a09..089f18c71 100644 --- a/hw/darwin/quartz/xpr/xprFrame.c +++ b/hw/darwin/quartz/xpr/xprFrame.c @@ -27,7 +27,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. */ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/xpr/xprFrame.c,v 1.1.4.1.4.2 2004/03/04 20:16:15 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/xpr/xprFrame.c,v 1.2 2004/04/23 19:16:52 eich Exp $ */ /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xprFrame.c,v 1.4 2003/11/12 20:21:52 torrey Exp $ */ #include "xpr.h" diff --git a/hw/darwin/quartz/xpr/xprScreen.c b/hw/darwin/quartz/xpr/xprScreen.c index 3adb62a63..5c77756fd 100644 --- a/hw/darwin/quartz/xpr/xprScreen.c +++ b/hw/darwin/quartz/xpr/xprScreen.c @@ -1,10 +1,10 @@ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/xpr/xprScreen.c,v 1.1.4.2.4.2 2004/03/04 17:47:30 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/xpr/xprScreen.c,v 1.4 2004/08/12 20:24:36 torrey Exp $ */ /* * Xplugin rootless implementation screen functions */ /* * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. - * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved. + * Copyright (c) 2004 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"), @@ -28,7 +28,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/xpr/xprScreen.c,v 1.8 2003/11/12 20:21:52 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xprScreen.c,v 1.11 2004/07/15 18:53:25 torrey Exp $ */ #include "quartzCommon.h" #include "quartz.h" @@ -42,6 +42,10 @@ #include "Xplugin.h" #include "applewmExt.h" +#ifdef DAMAGE +# include "damage.h" +#endif + // Name of GLX bundle for native OpenGL static const char *xprOpenGLBundle = "glxCGL.bundle"; @@ -57,41 +61,42 @@ eventHandler(unsigned int type, const void *arg, switch (type) { case XP_EVENT_DISPLAY_CHANGED: - QuartzMessageServerThread(kXDarwinDisplayChanged, 0); - break; + QuartzMessageServerThread(kXDarwinDisplayChanged, 0); + break; case XP_EVENT_WINDOW_STATE_CHANGED: - if (arg_size >= sizeof(xp_window_state_event)) + if (arg_size >= sizeof(xp_window_state_event)) { - const xp_window_state_event *ws_arg = arg; - QuartzMessageServerThread(kXDarwinWindowState, 2, + const xp_window_state_event *ws_arg = arg; + + QuartzMessageServerThread(kXDarwinWindowState, 2, ws_arg->id, ws_arg->state); - } - break; + } + break; case XP_EVENT_WINDOW_MOVED: - if (arg_size == sizeof(xp_window_id)) - { - xp_window_id id = * (xp_window_id *) arg; + if (arg_size == sizeof(xp_window_id)) + { + xp_window_id id = * (xp_window_id *) arg; - QuartzMessageServerThread(kXDarwinWindowMoved, 1, id); - } - break; + QuartzMessageServerThread(kXDarwinWindowMoved, 1, id); + } + break; case XP_EVENT_SURFACE_DESTROYED: case XP_EVENT_SURFACE_CHANGED: - if (arg_size == sizeof(xp_surface_id)) - { - int kind; - - if (type == XP_EVENT_SURFACE_DESTROYED) - kind = AppleDRISurfaceNotifyDestroyed; - else - kind = AppleDRISurfaceNotifyChanged; - - DRISurfaceNotify(*(xp_surface_id *) arg, kind); - } - break; + if (arg_size == sizeof(xp_surface_id)) + { + int kind; + + if (type == XP_EVENT_SURFACE_DESTROYED) + kind = AppleDRISurfaceNotifyDestroyed; + else + kind = AppleDRISurfaceNotifyChanged; + + DRISurfaceNotify(*(xp_surface_id *) arg, kind); + } + break; } } @@ -139,11 +144,12 @@ displayScreenBounds(CGDirectDisplayID id) /* - * addPseudoramiXScreens - * Add a physical screen with PseudoramiX. + * xprAddPseudoramiXScreens + * Add a single virtual screen encompassing all the physical screens + * with PseudoramiX. */ static void -addPseudoramiXScreens(int *x, int *y, int *width, int *height) +xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height) { CGDisplayCount i, displayCount; CGDirectDisplayID *displayList = NULL; @@ -286,7 +292,7 @@ xprAddScreen(int index, ScreenPtr pScreen) } else { - addPseudoramiXScreens(&dfb->x, &dfb->y, &dfb->width, &dfb->height); + xprAddPseudoramiXScreens(&dfb->x, &dfb->y, &dfb->width, &dfb->height); } /* Passing zero width (pitch) makes miCreateScreenResources set the @@ -319,6 +325,13 @@ xprSetupScreen(int index, ScreenPtr pScreen) } #endif /* RENDER */ +#ifdef DAMAGE + // The Damage extension needs to wrap underneath the + // generic rootless layer, so do it now. + if (!DamageSetup(pScreen)) + return FALSE; +#endif + // Initialize generic rootless code if (!xprInit(pScreen)) return FALSE; @@ -328,6 +341,23 @@ xprSetupScreen(int index, ScreenPtr pScreen) /* + * xprUpdateScreen + * Update screen after configuation change. + */ +static void +xprUpdateScreen(ScreenPtr pScreen) +{ + rootlessGlobalOffsetX = darwinMainScreenX; + rootlessGlobalOffsetY = darwinMainScreenY; + + AppleWMSetScreenOrigin(WindowTable[pScreen->myNum]); + + RootlessRepositionWindows(pScreen); + RootlessUpdateScreenPixmap(pScreen); +} + + +/* * xprInitInput * Finalize xpr specific setup. */ @@ -358,6 +388,9 @@ static QuartzModeProcsRec xprModeProcs = { QuartzResumeXCursor, NULL, // No capture or release in rootless mode NULL, + NULL, // Xplugin sends screen change events directly + xprAddPseudoramiXScreens, + xprUpdateScreen, xprIsX11Window, xprHideWindows, RootlessFrameForWindow, |