2006-11-26 11:13:41 -07:00
|
|
|
/***********************************************************
|
|
|
|
|
|
|
|
Copyright 1987, 1998 The Open Group
|
|
|
|
|
|
|
|
Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
the above copyright notice appear in all copies and that both that
|
|
|
|
copyright notice and this permission notice appear in supporting
|
|
|
|
documentation.
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
|
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
Except as contained in this notice, the name of The Open Group shall not be
|
|
|
|
used in advertising or otherwise to promote the sale, use or other dealings
|
|
|
|
in this Software without prior written authorization from The Open Group.
|
|
|
|
|
|
|
|
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
|
|
|
|
|
|
|
|
All Rights Reserved
|
|
|
|
|
|
|
|
Permission to use, copy, modify, and distribute this software and its
|
|
|
|
documentation for any purpose and without fee is hereby granted,
|
|
|
|
provided that the above copyright notice appear in all copies and that
|
|
|
|
both that copyright notice and this permission notice appear in
|
|
|
|
supporting documentation, and that the name of Digital not be
|
|
|
|
used in advertising or publicity pertaining to distribution of the
|
|
|
|
software without specific, written prior permission.
|
|
|
|
|
|
|
|
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
|
|
|
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
|
|
|
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
|
|
|
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
|
|
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
|
|
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
|
|
SOFTWARE.
|
|
|
|
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
/* The panoramix components contained the following notice */
|
|
|
|
/*****************************************************************
|
|
|
|
|
|
|
|
Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
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
|
|
|
|
DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
|
|
|
|
BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
|
|
|
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
|
|
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
Except as contained in this notice, the name of Digital Equipment Corporation
|
|
|
|
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.
|
|
|
|
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
2010-07-27 13:02:24 -06:00
|
|
|
#include <version-config.h>
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <X11/X.h>
|
2012-06-10 07:21:05 -06:00
|
|
|
#include <X11/Xos.h> /* for unistd.h */
|
2006-11-26 11:13:41 -07:00
|
|
|
#include <X11/Xproto.h>
|
2010-07-27 13:02:24 -06:00
|
|
|
#include <pixman.h>
|
2006-11-26 11:13:41 -07:00
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "os.h"
|
|
|
|
#include "windowstr.h"
|
|
|
|
#include "resource.h"
|
|
|
|
#include "dixstruct.h"
|
|
|
|
#include "gcstruct.h"
|
|
|
|
#include "extension.h"
|
|
|
|
#include "colormap.h"
|
|
|
|
#include "colormapst.h"
|
|
|
|
#include "cursorstr.h"
|
2008-11-02 08:26:08 -07:00
|
|
|
#include "selection.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
#include <X11/fonts/font.h>
|
|
|
|
#include "opaque.h"
|
|
|
|
#include "servermd.h"
|
2007-11-24 10:55:21 -07:00
|
|
|
#include "hotplug.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
#include "site.h"
|
|
|
|
#include "dixfont.h"
|
|
|
|
#include "extnsionst.h"
|
2008-11-02 08:26:08 -07:00
|
|
|
#include "privates.h"
|
|
|
|
#include "registry.h"
|
2011-11-05 07:32:40 -06:00
|
|
|
#include "client.h"
|
2013-06-07 11:28:45 -06:00
|
|
|
#include "exevents.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef PANORAMIX
|
|
|
|
#include "panoramiXsrv.h"
|
|
|
|
#else
|
2012-06-10 07:21:05 -06:00
|
|
|
#include "dixevents.h" /* InitEvents() */
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DPMSExtension
|
2010-04-13 13:54:46 -06:00
|
|
|
#include <X11/extensions/dpmsconst.h>
|
2006-11-26 11:13:41 -07:00
|
|
|
#include "dpmsproc.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern void Dispatch(void);
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
#ifdef XQUARTZ
|
|
|
|
#include <pthread.h>
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
BOOL serverRunning = FALSE;
|
|
|
|
pthread_mutex_t serverRunningMutex = PTHREAD_MUTEX_INITIALIZER;
|
|
|
|
pthread_cond_t serverRunningCond = PTHREAD_COND_INITIALIZER;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
int dix_main(int argc, char *argv[], char *envp[]);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
int
|
|
|
|
dix_main(int argc, char *argv[], char *envp[])
|
2009-09-06 13:44:18 -06:00
|
|
|
#else
|
2012-06-10 07:21:05 -06:00
|
|
|
int
|
|
|
|
main(int argc, char *argv[], char *envp[])
|
2009-09-06 13:44:18 -06:00
|
|
|
#endif
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int i;
|
|
|
|
HWEventQueueType alwaysCheckForInput[2];
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
display = "0";
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
InitRegions();
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
CheckUserParameters(argc, argv, envp);
|
|
|
|
|
|
|
|
CheckUserAuthorization();
|
|
|
|
|
|
|
|
InitConnectionLimits();
|
|
|
|
|
|
|
|
ProcessCommandLine(argc, argv);
|
|
|
|
|
|
|
|
alwaysCheckForInput[0] = 0;
|
|
|
|
alwaysCheckForInput[1] = 1;
|
2012-06-10 07:21:05 -06:00
|
|
|
while (1) {
|
|
|
|
serverGeneration++;
|
|
|
|
ScreenSaverTime = defaultScreenSaverTime;
|
|
|
|
ScreenSaverInterval = defaultScreenSaverInterval;
|
|
|
|
ScreenSaverBlanking = defaultScreenSaverBlanking;
|
|
|
|
ScreenSaverAllowExposures = defaultScreenSaverAllowExposures;
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef DPMSExtension
|
2012-06-10 07:21:05 -06:00
|
|
|
DPMSStandbyTime = DPMSSuspendTime = DPMSOffTime = ScreenSaverTime;
|
|
|
|
DPMSEnabled = TRUE;
|
|
|
|
DPMSPowerLevel = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
InitBlockAndWakeupHandlers();
|
|
|
|
/* Perform any operating system dependent initializations you'd like */
|
|
|
|
OsInit();
|
|
|
|
if (serverGeneration == 1) {
|
|
|
|
CreateWellKnownSockets();
|
|
|
|
for (i = 1; i < MAXCLIENTS; i++)
|
|
|
|
clients[i] = NullClient;
|
|
|
|
serverClient = calloc(sizeof(ClientRec), 1);
|
|
|
|
if (!serverClient)
|
|
|
|
FatalError("couldn't create server client");
|
|
|
|
InitClient(serverClient, 0, (pointer) NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ResetWellKnownSockets();
|
|
|
|
clients[0] = serverClient;
|
|
|
|
currentMaxClients = 1;
|
|
|
|
|
|
|
|
/* Initialize privates before first allocation */
|
|
|
|
dixResetPrivates();
|
|
|
|
|
|
|
|
/* Initialize server client devPrivates, to be reallocated as
|
|
|
|
* more client privates are registered
|
|
|
|
*/
|
|
|
|
if (!dixAllocatePrivates(&serverClient->devPrivates, PRIVATE_CLIENT))
|
|
|
|
FatalError("failed to create server client privates");
|
|
|
|
|
|
|
|
if (!InitClientResources(serverClient)) /* for root resources */
|
|
|
|
FatalError("couldn't init server resources");
|
|
|
|
|
|
|
|
SetInputCheck(&alwaysCheckForInput[0], &alwaysCheckForInput[1]);
|
|
|
|
screenInfo.numScreens = 0;
|
|
|
|
|
|
|
|
InitAtoms();
|
|
|
|
InitEvents();
|
|
|
|
InitSelections();
|
|
|
|
InitGlyphCaching();
|
|
|
|
dixResetRegistry();
|
|
|
|
ResetFontPrivateIndex();
|
|
|
|
InitCallbackManager();
|
|
|
|
InitOutput(&screenInfo, argc, argv);
|
|
|
|
|
|
|
|
if (screenInfo.numScreens < 1)
|
|
|
|
FatalError("no screens found");
|
|
|
|
InitExtensions(argc, argv);
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
for (i = 0; i < screenInfo.numGPUScreens; i++) {
|
|
|
|
ScreenPtr pScreen = screenInfo.gpuscreens[i];
|
|
|
|
if (!CreateScratchPixmapsForScreen(pScreen))
|
|
|
|
FatalError("failed to create scratch pixmaps");
|
2013-09-28 09:36:30 -06:00
|
|
|
if (pScreen->CreateScreenResources &&
|
|
|
|
!(*pScreen->CreateScreenResources) (pScreen))
|
|
|
|
FatalError("failed to create screen resources");
|
2013-06-07 11:28:45 -06:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < screenInfo.numScreens; i++) {
|
|
|
|
ScreenPtr pScreen = screenInfo.screens[i];
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
if (!CreateScratchPixmapsForScreen(pScreen))
|
2012-06-10 07:21:05 -06:00
|
|
|
FatalError("failed to create scratch pixmaps");
|
|
|
|
if (pScreen->CreateScreenResources &&
|
|
|
|
!(*pScreen->CreateScreenResources) (pScreen))
|
|
|
|
FatalError("failed to create screen resources");
|
|
|
|
if (!CreateGCperDepth(i))
|
|
|
|
FatalError("failed to create scratch GCs");
|
|
|
|
if (!CreateDefaultStipple(i))
|
|
|
|
FatalError("failed to create default stipple");
|
|
|
|
if (!CreateRootWindow(pScreen))
|
|
|
|
FatalError("failed to create root window");
|
|
|
|
}
|
|
|
|
|
|
|
|
InitFonts();
|
|
|
|
if (SetDefaultFontPath(defaultFontPath) != Success) {
|
|
|
|
ErrorF("[dix] failed to set default font path '%s'",
|
|
|
|
defaultFontPath);
|
|
|
|
}
|
|
|
|
if (!SetDefaultFont(defaultTextFont)) {
|
|
|
|
FatalError("could not open default font '%s'", defaultTextFont);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(rootCursor = CreateRootCursor(NULL, 0))) {
|
|
|
|
FatalError("could not open default cursor font '%s'",
|
|
|
|
defaultCursorFont);
|
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef DPMSExtension
|
2012-06-10 07:21:05 -06:00
|
|
|
/* check all screens, looking for DPMS Capabilities */
|
|
|
|
DPMSCapableFlag = DPMSSupported();
|
|
|
|
if (!DPMSCapableFlag)
|
|
|
|
DPMSEnabled = FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
2012-06-10 07:21:05 -06:00
|
|
|
/*
|
|
|
|
* Consolidate window and colourmap information for each screen
|
|
|
|
*/
|
|
|
|
if (!noPanoramiXExtension)
|
|
|
|
PanoramiXConsolidate();
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < screenInfo.numScreens; i++)
|
|
|
|
InitRootWindow(screenInfo.screens[i]->root);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
InitCoreDevices();
|
2012-06-10 07:21:05 -06:00
|
|
|
InitInput(argc, argv);
|
|
|
|
InitAndStartDevices();
|
|
|
|
ReserveClientIds(serverClient);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!noPanoramiXExtension) {
|
|
|
|
if (!PanoramiXCreateConnectionBlock()) {
|
|
|
|
FatalError("could not create connection block info");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
{
|
|
|
|
if (!CreateConnectionBlock()) {
|
|
|
|
FatalError("could not create connection block info");
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
#ifdef XQUARTZ
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Let the other threads know the server is done with its init */
|
|
|
|
pthread_mutex_lock(&serverRunningMutex);
|
|
|
|
serverRunning = TRUE;
|
|
|
|
pthread_cond_broadcast(&serverRunningCond);
|
|
|
|
pthread_mutex_unlock(&serverRunningMutex);
|
2009-09-06 13:44:18 -06:00
|
|
|
#endif
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
NotifyParentProcess();
|
|
|
|
|
|
|
|
Dispatch();
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
#ifdef XQUARTZ
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Let the other threads know the server is no longer running */
|
|
|
|
pthread_mutex_lock(&serverRunningMutex);
|
|
|
|
serverRunning = FALSE;
|
|
|
|
pthread_mutex_unlock(&serverRunningMutex);
|
2011-11-05 07:32:40 -06:00
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
UndisplayDevices();
|
2013-06-07 11:28:45 -06:00
|
|
|
DisableAllDevices();
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Now free up whatever must be freed */
|
|
|
|
if (screenIsSaved == SCREEN_SAVER_ON)
|
|
|
|
dixSaveScreens(serverClient, SCREEN_SAVER_OFF, ScreenSaverReset);
|
|
|
|
FreeScreenSaverTimer();
|
|
|
|
CloseDownExtensions();
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
2012-06-10 07:21:05 -06:00
|
|
|
{
|
|
|
|
Bool remember_it = noPanoramiXExtension;
|
|
|
|
|
|
|
|
noPanoramiXExtension = TRUE;
|
|
|
|
FreeAllResources();
|
|
|
|
noPanoramiXExtension = remember_it;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
#else
|
2012-06-10 07:21:05 -06:00
|
|
|
FreeAllResources();
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
CloseInput();
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < screenInfo.numScreens; i++)
|
|
|
|
screenInfo.screens[i]->root = NullWindow;
|
2013-06-07 11:28:45 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
CloseDownDevices();
|
2013-06-07 11:28:45 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
CloseDownEvents();
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
for (i = screenInfo.numGPUScreens - 1; i >= 0; i--) {
|
|
|
|
ScreenPtr pScreen = screenInfo.gpuscreens[i];
|
|
|
|
FreeScratchPixmapsForScreen(pScreen);
|
|
|
|
(*pScreen->CloseScreen) (pScreen);
|
|
|
|
dixFreePrivates(pScreen->devPrivates, PRIVATE_SCREEN);
|
|
|
|
free(pScreen);
|
|
|
|
screenInfo.numGPUScreens = i;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = screenInfo.numScreens - 1; i >= 0; i--) {
|
2013-06-07 11:28:45 -06:00
|
|
|
FreeScratchPixmapsForScreen(screenInfo.screens[i]);
|
2012-06-10 07:21:05 -06:00
|
|
|
FreeGCperDepth(i);
|
|
|
|
FreeDefaultStipple(i);
|
2013-06-07 11:28:45 -06:00
|
|
|
dixFreeScreenSpecificPrivates(screenInfo.screens[i]);
|
|
|
|
(*screenInfo.screens[i]->CloseScreen) (screenInfo.screens[i]);
|
2012-06-10 07:21:05 -06:00
|
|
|
dixFreePrivates(screenInfo.screens[i]->devPrivates, PRIVATE_SCREEN);
|
|
|
|
free(screenInfo.screens[i]);
|
|
|
|
screenInfo.numScreens = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReleaseClientIds(serverClient);
|
|
|
|
dixFreePrivates(serverClient->devPrivates, PRIVATE_CLIENT);
|
|
|
|
serverClient->devPrivates = NULL;
|
|
|
|
|
|
|
|
FreeFonts();
|
|
|
|
|
|
|
|
FreeAuditTimer();
|
|
|
|
|
|
|
|
if (dispatchException & DE_TERMINATE) {
|
|
|
|
CloseWellKnownConnections();
|
|
|
|
}
|
|
|
|
|
|
|
|
OsCleanup((dispatchException & DE_TERMINATE) != 0);
|
|
|
|
|
|
|
|
if (dispatchException & DE_TERMINATE) {
|
|
|
|
ddxGiveUp(EXIT_NO_ERROR);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(ConnectionInfo);
|
|
|
|
ConnectionInfo = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
return 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|