Merge many XDarwin improvements:

- Fix launch of X clients by double clicking in the Finder when there is a
    space in the path (Torrey T. Lyons).
- Interpret scroll wheel mouse events correctly when shift is held down
    (Benjamin Burke).
- Add option to always use Mac command key equivalents (John Harper and
    Torrey T. Lyons).
- Add support for dynamic screen configuration changes in rootless mode
    (John Harper and Torrey T. Lyons).
- Add documentation on generic rootless layer (Torrey T. Lyons).
This commit is contained in:
Torrey Lyons 2004-07-30 19:12:18 +00:00
parent c2275b31ad
commit 784e4d1cc0
17 changed files with 539 additions and 254 deletions

View File

@ -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;

View File

@ -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"];

View File

@ -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.17 2003/11/24 05:39:01 torrey Exp $ */
/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/XServer.h,v 1.2 2004/04/23 19:15:17 eich 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;

View File

@ -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.20 2003/11/27 01:59:53 torrey Exp $ */
/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.2 2004/04/23 19:15:17 eich Exp $ */
/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.19 2003/11/24 05:39:01 torrey Exp $ */
#include "quartzCommon.h"
@ -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 (type == NSKeyDown) {
// 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])
// don't send the X server key events.
if (![self getMousePosition:&xe fromEvent:nil]) {
swallowedKey = [anEvent keyCode];
return NO;
if (type == NSKeyDown)
xe.u.u.type = KeyPress;
else
xe.u.u.type = KeyRelease;
}
// 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;
@ -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;
@ -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) {

View File

@ -1,10 +1,10 @@
/* $XdotOrg$ */
/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/cr/crScreen.m,v 1.2 2004/04/23 19:15:51 eich 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"),
@ -79,36 +79,13 @@ CRDisplayInit(void)
/*
* CRScreenParams
* Set the basic screen parameters.
* CRAddPseudoramiXScreens
* Add a single virtual screen encompassing all the physical screens
* with PseudoramiX.
*/
static void
CRScreenParams(int index, DarwinFramebufferPtr dfb)
CRAddPseudoramiXScreens(int *x, int *y, int *width, int *height)
{
dfb->bitsPerComponent = CGDisplayBitsPerSample(kCGDirectMainDisplay);
dfb->bitsPerPixel = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
dfb->colorBitsPerPixel = 3 * dfb->bitsPerComponent;
if (noPseudoramiXExtension) {
NSScreen *screen = [[NSScreen screens] objectAtIndex:index];
NSRect frame = [screen frame];
// set x, y so (0,0) is top left of main screen
dfb->x = NSMinX(frame);
dfb->y = NSHeight([[NSScreen mainScreen] frame]) -
NSHeight(frame) - NSMinY(frame);
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])) {
dfb->y += aquaMenuBarHeight;
dfb->height -= aquaMenuBarHeight;
}
} else {
int i;
NSRect unionRect = NSMakeRect(0, 0, 0, 0);
NSArray *screens = [NSScreen screens];
@ -127,11 +104,10 @@ CRScreenParams(int index, DarwinFramebufferPtr dfb)
}
// 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;
*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),
@ -172,6 +148,40 @@ CRScreenParams(int index, DarwinFramebufferPtr dfb)
PseudoramiXAddScreen(frame.origin.x, frame.origin.y,
frame.size.width, frame.size.height);
}
}
/*
* CRScreenParams
* Set the basic screen parameters.
*/
static void
CRScreenParams(int index, DarwinFramebufferPtr dfb)
{
dfb->bitsPerComponent = CGDisplayBitsPerSample(kCGDirectMainDisplay);
dfb->bitsPerPixel = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
dfb->colorBitsPerPixel = 3 * dfb->bitsPerComponent;
if (noPseudoramiXExtension) {
NSScreen *screen = [[NSScreen screens] objectAtIndex:index];
NSRect frame = [screen frame];
// set x, y so (0,0) is top left of main screen
dfb->x = NSMinX(frame);
dfb->y = NSHeight([[NSScreen mainScreen] frame]) -
NSHeight(frame) - NSMinY(frame);
dfb->width = NSWidth(frame);
dfb->height = NSHeight(frame);
// Shift the usable part of main screen down to avoid the menu bar.
if (NSEqualRects(frame, [[NSScreen mainScreen] frame])) {
dfb->y += aquaMenuBarHeight;
dfb->height -= aquaMenuBarHeight;
}
} else {
CRAddPseudoramiXScreens(&dfb->x, &dfb->y, &dfb->width, &dfb->height);
}
}
@ -195,8 +205,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);
@ -250,6 +263,34 @@ CRSetupScreen(int index, ScreenPtr 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,6 +341,9 @@ static QuartzModeProcsRec crModeProcs = {
QuartzResumeXCursor,
NULL, // No capture or release in rootless mode
NULL,
CRScreenChanged,
CRAddPseudoramiXScreens,
CRUpdateScreen,
CRIsX11Window,
NULL, // Cocoa NSWindows hide themselves
RootlessFrameForWindow,

View File

@ -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.1 2003/12/06 13:24:23 kaleb Exp $ */
/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/fullscreen/fullscreen.c,v 1.2 2004/04/23 19:16:21 eich 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"
@ -544,6 +544,9 @@ static QuartzModeProcsRec fsModeProcs = {
FSResumeScreen,
FSCapture,
FSRelease,
NULL, // No dynamic screen change support
NULL,
NULL,
NULL, // No rootless code in fullscreen
NULL,
NULL,

View File

@ -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.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)
{

View File

@ -1,9 +1,10 @@
/*
* 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.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);

View File

@ -1,11 +1,11 @@
/* $XdotOrg$ */
/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartz.c,v 1.2 2004/04/23 19:15:17 eich 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;
@ -165,6 +168,71 @@ 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.
@ -320,6 +388,9 @@ void DarwinModeProcessEvent(
break;
case kXDarwinDisplayChanged:
QuartzUpdateScreens();
break;
case kXDarwinWindowState:
case kXDarwinWindowMoved:
// FIXME: Not implemented yet

View File

@ -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.8 2003/11/27 01:59:53 torrey Exp $ */
/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartz.h,v 1.2 2004/04/23 19:15:17 eich Exp $ */
/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartz.h,v 1.7 2003/11/12 20:21:51 torrey Exp $ */
#ifndef _QUARTZ_H
@ -67,6 +67,13 @@ typedef void (*ResumeScreenProc)(ScreenPtr pScreen, int x, int y);
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
*/
@ -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;

View File

@ -1,4 +1,4 @@
/* $XdotOrg$ */
/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartzCocoa.m,v 1.2 2004/04/23 19:15:17 eich 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) {

View File

@ -1,4 +1,4 @@
/* $XdotOrg$ */
/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartzCommon.h,v 1.2 2004/04/23 19:15:17 eich 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;

View File

@ -1,10 +1,10 @@
/* $XdotOrg$ */
/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/xpr/xprScreen.c,v 1.2 2004/04/23 19:16:52 eich 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"
@ -64,6 +64,7 @@ eventHandler(unsigned int type, const void *arg,
if (arg_size >= sizeof(xp_window_state_event))
{
const xp_window_state_event *ws_arg = arg;
QuartzMessageServerThread(kXDarwinWindowState, 2,
ws_arg->id, ws_arg->state);
}
@ -139,11 +140,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 +288,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
@ -327,6 +329,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 +377,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,

View File

@ -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.
*/
/* $XFree86: xc/programs/Xserver/miext/rootless/rootless.h,v 1.5 2003/10/18 00:00:34 torrey Exp $ */
/* $XFree86: xc/programs/Xserver/miext/rootless/rootless.h,v 1.7 2004/07/02 01:30:33 torrey Exp $ */
#ifndef _ROOTLESS_H
#define _ROOTLESS_H
@ -395,5 +395,16 @@ void RootlessStartDrawing(WindowPtr pWindow);
*/
void RootlessStopDrawing(WindowPtr pWindow, Bool flush);
/*
* Alocate a new screen pixmap.
* miCreateScreenResources does not do this properly with a null
* framebuffer pointer.
*/
void RootlessUpdateScreenPixmap(ScreenPtr pScreen);
/*
* Reposition all windows on a screen to their correct positions.
*/
void RootlessRepositionWindows(ScreenPtr pScreen);
#endif /* _ROOTLESS_H */

View File

@ -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/miext/rootless/rootlessCommon.c,v 1.4tsi Exp $ */
/* $XFree86: xc/programs/Xserver/miext/rootless/rootlessCommon.c,v 1.6 2004/07/02 01:30:33 torrey Exp $ */
#include "rootlessCommon.h"
@ -358,6 +358,27 @@ RootlessRedisplay(WindowPtr pWindow)
}
/*
* RootlessRepositionWindows
* Reposition all windows on a screen to their correct positions.
*/
void
RootlessRepositionWindows(ScreenPtr pScreen)
{
WindowPtr root = WindowTable[pScreen->myNum];
WindowPtr win;
if (root != NULL) {
RootlessRepositionWindow(root);
for (win = root->firstChild; win; win = win->nextSib) {
if (WINREC(win) != NULL)
RootlessRepositionWindow(win);
}
}
}
/*
* RootlessRedisplayScreen
* Walk every window on a screen and redisplay the damaged regions.

View File

@ -3,7 +3,7 @@
*/
/*
* 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"),
@ -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.
*/
/* $XFree86: xc/programs/Xserver/miext/rootless/rootlessCommon.h,v 1.3 2003/06/30 01:45:13 torrey Exp $ */
/* $XFree86: xc/programs/Xserver/miext/rootless/rootlessCommon.h,v 1.5 2004/07/02 01:30:33 torrey Exp $ */
#ifndef _ROOTLESSCOMMON_H
#define _ROOTLESSCOMMON_H
@ -246,9 +246,12 @@ void RootlessDamageBox(WindowPtr pWindow, BoxPtr pBox);
void RootlessRedisplay(WindowPtr pWindow);
void RootlessRedisplayScreen(ScreenPtr pScreen);
void RootlessQueueRedisplay (ScreenPtr pScreen);
void RootlessQueueRedisplay(ScreenPtr pScreen);
// Move a window to its proper location on the screen.
void RootlessRepositionWindow(WindowPtr pWin);
// Move the window to it's correct place in the physical stacking order.
void RootlessReorderWindow (WindowPtr pWin);
void RootlessReorderWindow(WindowPtr pWin);
#endif /* _ROOTLESSCOMMON_H */

View File

@ -1,10 +1,10 @@
/* $XdotOrg$ */
/* $XdotOrg: xc/programs/Xserver/miext/rootless/rootlessWindow.c,v 1.2 2004/04/23 19:54:27 eich Exp $ */
/*
* Rootless window management
*/
/*
* 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.
* Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@ -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/miext/rootless/rootlessWindow.c,v 1.10 2003/11/13 20:26:31 torrey Exp $ */
/* $XFree86: xc/programs/Xserver/miext/rootless/rootlessWindow.c,v 1.12 2004/07/02 01:30:33 torrey Exp $ */
#include "rootlessCommon.h"
#include "rootlessWindow.h"
@ -1218,6 +1218,31 @@ RootlessResizeWindow(WindowPtr pWin, int x, int y,
}
/*
* RootlessRepositionWindow
* Called by the implementation when a window needs to be repositioned to
* its correct location on the screen. This routine is typically needed
* due to changes in the underlying window system, such as a screen layout
* change.
*/
void
RootlessRepositionWindow(WindowPtr pWin)
{
RootlessWindowRec *winRec = WINREC(pWin);
ScreenPtr pScreen = pWin->drawable.pScreen;
if (winRec == NULL)
return;
RootlessStopDrawing(pWin, FALSE);
SCREENREC(pScreen)->imp->MoveFrame(winRec->wid, pScreen,
winRec->x + SCREEN_TO_GLOBAL_X,
winRec->y + SCREEN_TO_GLOBAL_Y);
RootlessReorderWindow(pWin);
}
/*
* RootlessReparentWindow
* Called after a window has been reparented. Generally windows are not