2003-11-14 16:54:54 +01:00
|
|
|
/************************************************************
|
|
|
|
|
|
|
|
Copyright 1987, 1989, 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, 1989 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.
|
|
|
|
|
|
|
|
********************************************************/
|
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
/* The panoramix components contained the following notice */
|
2004-04-23 21:54:30 +02:00
|
|
|
/*****************************************************************
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
******************************************************************/
|
|
|
|
|
2006-11-03 21:54:43 +01:00
|
|
|
/* XSERVER_DTRACE additions:
|
|
|
|
* Copyright 2005-2006 Sun Microsystems, Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, and/or sell copies of the Software, and to permit persons
|
|
|
|
* to whom the Software is furnished to do so, provided that the above
|
|
|
|
* copyright notice(s) and this permission notice appear in all copies of
|
|
|
|
* the Software and that both the above copyright notice(s) and this
|
|
|
|
* permission notice appear in supporting documentation.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
|
|
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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.
|
|
|
|
*
|
|
|
|
* Except as contained in this notice, the name of a copyright holder
|
|
|
|
* shall not be used in advertising or otherwise to promote the sale, use
|
|
|
|
* or other dealings in this Software without prior written authorization
|
|
|
|
* of the copyright holder.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
|
2005-07-03 09:02:09 +02:00
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
2009-04-22 05:26:40 +02:00
|
|
|
#include <version-config.h>
|
2005-07-03 09:02:09 +02:00
|
|
|
#endif
|
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
#ifdef PANORAMIX_DEBUG
|
|
|
|
#include <stdio.h>
|
|
|
|
int ProcInitialConnection();
|
|
|
|
#endif
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
#include "windowstr.h"
|
2005-07-03 09:02:09 +02:00
|
|
|
#include <X11/fonts/fontstruct.h>
|
2003-11-14 16:54:54 +01:00
|
|
|
#include "dixfontstr.h"
|
|
|
|
#include "gcstruct.h"
|
|
|
|
#include "selection.h"
|
|
|
|
#include "colormapst.h"
|
|
|
|
#include "cursorstr.h"
|
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "opaque.h"
|
|
|
|
#include "input.h"
|
|
|
|
#include "servermd.h"
|
|
|
|
#include "extnsionst.h"
|
|
|
|
#include "dixfont.h"
|
2003-11-14 17:49:22 +01:00
|
|
|
#include "dispatch.h"
|
|
|
|
#include "swaprep.h"
|
|
|
|
#include "swapreq.h"
|
2007-04-04 21:59:51 +02:00
|
|
|
#include "privates.h"
|
2004-05-05 22:04:52 +02:00
|
|
|
#include "xace.h"
|
2003-11-14 17:49:22 +01:00
|
|
|
#include "inputstr.h"
|
2008-03-18 09:05:57 +01:00
|
|
|
#include "xkbsrv.h"
|
2009-04-22 05:26:40 +02:00
|
|
|
#include "site.h"
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2006-11-03 21:54:43 +01:00
|
|
|
#ifdef XSERVER_DTRACE
|
2007-11-26 22:52:41 +01:00
|
|
|
#include "registry.h"
|
2008-01-03 03:09:26 +01:00
|
|
|
#include <sys/types.h>
|
|
|
|
typedef const char *string;
|
2006-11-03 21:54:43 +01:00
|
|
|
#include "Xserver-dtrace.h"
|
|
|
|
#endif
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
#define mskcnt ((MAXCLIENTS + 31) / 32)
|
2003-11-14 17:49:22 +01:00
|
|
|
#define BITMASK(i) (1U << ((i) & 31))
|
2003-11-14 16:54:54 +01:00
|
|
|
#define MASKIDX(i) ((i) >> 5)
|
|
|
|
#define MASKWORD(buf, i) buf[MASKIDX(i)]
|
|
|
|
#define BITSET(buf, i) MASKWORD(buf, i) |= BITMASK(i)
|
|
|
|
#define BITCLEAR(buf, i) MASKWORD(buf, i) &= ~BITMASK(i)
|
|
|
|
#define GETBIT(buf, i) (MASKWORD(buf, i) & BITMASK(i))
|
|
|
|
|
2009-04-22 05:26:40 +02:00
|
|
|
xConnSetupPrefix connSetupPrefix;
|
|
|
|
|
|
|
|
PaddingInfo PixmapWidthPaddingInfo[33];
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
static ClientPtr grabClient;
|
|
|
|
#define GrabNone 0
|
|
|
|
#define GrabActive 1
|
|
|
|
#define GrabKickout 2
|
|
|
|
static int grabState = GrabNone;
|
|
|
|
static long grabWaiters[mskcnt];
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
CallbackListPtr ServerGrabCallback = NULL;
|
|
|
|
HWEventQueuePtr checkForInput[2];
|
2009-04-22 05:26:40 +02:00
|
|
|
int connBlockScreenStart;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2005-03-08 00:02:59 +01:00
|
|
|
static void KillAllClients(void);
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
static int nextFreeClientID; /* always MIN free client ID */
|
|
|
|
|
|
|
|
static int nClients; /* number of authorized clients */
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
CallbackListPtr ClientStateCallback;
|
2005-07-16 22:52:25 +02:00
|
|
|
|
|
|
|
/* dispatchException & isItTimeToYield must be declared volatile since they
|
|
|
|
* are modified by signal handlers - otherwise optimizer may assume it doesn't
|
|
|
|
* need to actually check value in memory when used and may miss changes from
|
|
|
|
* signal handlers.
|
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
volatile char dispatchException = 0;
|
|
|
|
volatile char isItTimeToYield;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
/* Various of the DIX function interfaces were not designed to allow
|
|
|
|
* the client->errorValue to be set on BadValue and other errors.
|
|
|
|
* Rather than changing interfaces and breaking untold code we introduce
|
|
|
|
* a new global that dispatch can use.
|
|
|
|
*/
|
|
|
|
XID clientErrorValue; /* XXX this is a kludge */
|
|
|
|
|
|
|
|
#define SAME_SCREENS(a, b) (\
|
|
|
|
(a.pScreen == b.pScreen))
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2005-03-08 00:02:59 +01:00
|
|
|
SetInputCheck(HWEventQueuePtr c0, HWEventQueuePtr c1)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
checkForInput[0] = c0;
|
|
|
|
checkForInput[1] = c1;
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2007-04-09 23:33:15 +02:00
|
|
|
UpdateCurrentTime(void)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
TimeStamp systime;
|
|
|
|
|
|
|
|
/* To avoid time running backwards, we must call GetTimeInMillis before
|
|
|
|
* calling ProcessInputEvents.
|
|
|
|
*/
|
|
|
|
systime.months = currentTime.months;
|
|
|
|
systime.milliseconds = GetTimeInMillis();
|
|
|
|
if (systime.milliseconds < currentTime.milliseconds)
|
|
|
|
systime.months++;
|
|
|
|
if (*checkForInput[0] != *checkForInput[1])
|
|
|
|
ProcessInputEvents();
|
|
|
|
if (CompareTimeStamps(systime, currentTime) == LATER)
|
|
|
|
currentTime = systime;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Like UpdateCurrentTime, but can't call ProcessInputEvents */
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2007-04-09 23:33:15 +02:00
|
|
|
UpdateCurrentTimeIf(void)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
TimeStamp systime;
|
|
|
|
|
|
|
|
systime.months = currentTime.months;
|
|
|
|
systime.milliseconds = GetTimeInMillis();
|
|
|
|
if (systime.milliseconds < currentTime.milliseconds)
|
|
|
|
systime.months++;
|
|
|
|
if (*checkForInput[0] == *checkForInput[1])
|
|
|
|
currentTime = systime;
|
|
|
|
}
|
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
|
|
|
|
#undef SMART_DEBUG
|
|
|
|
|
|
|
|
#define SMART_SCHEDULE_DEFAULT_INTERVAL 20 /* ms */
|
|
|
|
#define SMART_SCHEDULE_MAX_SLICE 200 /* ms */
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool SmartScheduleDisable = FALSE;
|
|
|
|
long SmartScheduleSlice = SMART_SCHEDULE_DEFAULT_INTERVAL;
|
|
|
|
long SmartScheduleInterval = SMART_SCHEDULE_DEFAULT_INTERVAL;
|
|
|
|
long SmartScheduleMaxSlice = SMART_SCHEDULE_MAX_SLICE;
|
|
|
|
long SmartScheduleTime;
|
2007-03-25 18:27:01 +02:00
|
|
|
static ClientPtr SmartLastClient;
|
|
|
|
static int SmartLastIndex[SMART_MAX_PRIORITY-SMART_MIN_PRIORITY+1];
|
2003-11-14 17:49:22 +01:00
|
|
|
|
|
|
|
#ifdef SMART_DEBUG
|
|
|
|
long SmartLastPrint;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void Dispatch(void);
|
|
|
|
void InitProcVectors(void);
|
|
|
|
|
2007-03-25 23:57:54 +02:00
|
|
|
static int
|
2003-11-14 17:49:22 +01:00
|
|
|
SmartScheduleClient (int *clientReady, int nready)
|
|
|
|
{
|
|
|
|
ClientPtr pClient;
|
|
|
|
int i;
|
|
|
|
int client;
|
|
|
|
int bestPrio, best = 0;
|
|
|
|
int bestRobin, robin;
|
|
|
|
long now = SmartScheduleTime;
|
|
|
|
long idle;
|
|
|
|
|
|
|
|
bestPrio = -0x7fffffff;
|
|
|
|
bestRobin = 0;
|
|
|
|
idle = 2 * SmartScheduleSlice;
|
|
|
|
for (i = 0; i < nready; i++)
|
|
|
|
{
|
|
|
|
client = clientReady[i];
|
|
|
|
pClient = clients[client];
|
|
|
|
/* Praise clients which are idle */
|
|
|
|
if ((now - pClient->smart_check_tick) >= idle)
|
|
|
|
{
|
|
|
|
if (pClient->smart_priority < 0)
|
|
|
|
pClient->smart_priority++;
|
|
|
|
}
|
|
|
|
pClient->smart_check_tick = now;
|
|
|
|
|
|
|
|
/* check priority to select best client */
|
|
|
|
robin = (pClient->index - SmartLastIndex[pClient->smart_priority-SMART_MIN_PRIORITY]) & 0xff;
|
|
|
|
if (pClient->smart_priority > bestPrio ||
|
|
|
|
(pClient->smart_priority == bestPrio && robin > bestRobin))
|
|
|
|
{
|
|
|
|
bestPrio = pClient->smart_priority;
|
|
|
|
bestRobin = robin;
|
|
|
|
best = client;
|
|
|
|
}
|
|
|
|
#ifdef SMART_DEBUG
|
|
|
|
if ((now - SmartLastPrint) >= 5000)
|
|
|
|
fprintf (stderr, " %2d: %3d", client, pClient->smart_priority);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#ifdef SMART_DEBUG
|
|
|
|
if ((now - SmartLastPrint) >= 5000)
|
|
|
|
{
|
|
|
|
fprintf (stderr, " use %2d\n", best);
|
|
|
|
SmartLastPrint = now;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
pClient = clients[best];
|
|
|
|
SmartLastIndex[bestPrio-SMART_MIN_PRIORITY] = pClient->index;
|
|
|
|
/*
|
|
|
|
* Set current client pointer
|
|
|
|
*/
|
|
|
|
if (SmartLastClient != pClient)
|
|
|
|
{
|
|
|
|
pClient->smart_start_tick = now;
|
|
|
|
SmartLastClient = pClient;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Adjust slice
|
|
|
|
*/
|
|
|
|
if (nready == 1)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* If it's been a long time since another client
|
|
|
|
* has run, bump the slice up to get maximal
|
|
|
|
* performance from a single client
|
|
|
|
*/
|
|
|
|
if ((now - pClient->smart_start_tick) > 1000 &&
|
|
|
|
SmartScheduleSlice < SmartScheduleMaxSlice)
|
|
|
|
{
|
|
|
|
SmartScheduleSlice += SmartScheduleInterval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SmartScheduleSlice = SmartScheduleInterval;
|
|
|
|
}
|
|
|
|
return best;
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
#define MAJOROP ((xReq *)client->requestBuffer)->reqType
|
|
|
|
|
|
|
|
void
|
2003-11-14 17:49:22 +01:00
|
|
|
Dispatch(void)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
int *clientReady; /* array of request ready clients */
|
|
|
|
int result;
|
|
|
|
ClientPtr client;
|
|
|
|
int nready;
|
|
|
|
HWEventQueuePtr* icheck = checkForInput;
|
2004-09-15 11:05:22 +02:00
|
|
|
long start_tick;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
nextFreeClientID = 1;
|
|
|
|
nClients = 0;
|
|
|
|
|
2009-01-22 08:11:16 +01:00
|
|
|
clientReady = xalloc(sizeof(int) * MaxClients);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!clientReady)
|
|
|
|
return;
|
|
|
|
|
|
|
|
while (!dispatchException)
|
|
|
|
{
|
|
|
|
if (*icheck[0] != *icheck[1])
|
|
|
|
{
|
|
|
|
ProcessInputEvents();
|
|
|
|
FlushIfCriticalOutputPending();
|
|
|
|
}
|
|
|
|
|
|
|
|
nready = WaitForSomething(clientReady);
|
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
if (nready && !SmartScheduleDisable)
|
|
|
|
{
|
|
|
|
clientReady[0] = SmartScheduleClient (clientReady, nready);
|
|
|
|
nready = 1;
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
/*****************
|
|
|
|
* Handle events in round robin fashion, doing input between
|
|
|
|
* each round
|
|
|
|
*****************/
|
|
|
|
|
|
|
|
while (!dispatchException && (--nready >= 0))
|
|
|
|
{
|
|
|
|
client = clients[clientReady[nready]];
|
|
|
|
if (! client)
|
|
|
|
{
|
|
|
|
/* KillClient can cause this to happen */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* GrabServer activation can cause this to be true */
|
|
|
|
if (grabState == GrabKickout)
|
|
|
|
{
|
|
|
|
grabState = GrabActive;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
isItTimeToYield = FALSE;
|
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
start_tick = SmartScheduleTime;
|
2003-11-14 16:54:54 +01:00
|
|
|
while (!isItTimeToYield)
|
|
|
|
{
|
|
|
|
if (*icheck[0] != *icheck[1])
|
|
|
|
ProcessInputEvents();
|
2008-01-31 11:39:48 +01:00
|
|
|
|
|
|
|
FlushIfCriticalOutputPending();
|
2003-11-14 17:49:22 +01:00
|
|
|
if (!SmartScheduleDisable &&
|
|
|
|
(SmartScheduleTime - start_tick) >= SmartScheduleSlice)
|
|
|
|
{
|
|
|
|
/* Penalize clients which consume ticks */
|
|
|
|
if (client->smart_priority > SMART_MIN_PRIORITY)
|
|
|
|
client->smart_priority--;
|
|
|
|
break;
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
/* now, finally, deal with client requests */
|
|
|
|
|
|
|
|
result = ReadRequestFromClient(client);
|
|
|
|
if (result <= 0)
|
|
|
|
{
|
|
|
|
if (result < 0)
|
|
|
|
CloseDownClient(client);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
client->sequence++;
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (client->requestLogIndex == MAX_REQUEST_LOG)
|
|
|
|
client->requestLogIndex = 0;
|
|
|
|
client->requestLog[client->requestLogIndex] = MAJOROP;
|
|
|
|
client->requestLogIndex++;
|
2006-11-03 21:54:43 +01:00
|
|
|
#endif
|
|
|
|
#ifdef XSERVER_DTRACE
|
2007-11-26 21:59:44 +01:00
|
|
|
XSERVER_REQUEST_START(LookupMajorName(MAJOROP), MAJOROP,
|
2006-11-03 21:54:43 +01:00
|
|
|
((xReq *)client->requestBuffer)->length,
|
|
|
|
client->index, client->requestBuffer);
|
2003-11-14 16:54:54 +01:00
|
|
|
#endif
|
2003-11-25 20:29:01 +01:00
|
|
|
if (result > (maxBigRequestSize << 2))
|
2003-11-14 16:54:54 +01:00
|
|
|
result = BadLength;
|
2006-12-02 02:48:15 +01:00
|
|
|
else {
|
2008-01-25 23:28:17 +01:00
|
|
|
result = XaceHookDispatch(client, MAJOROP);
|
|
|
|
if (result == Success)
|
|
|
|
result = (* client->requestVector[MAJOROP])(client);
|
2007-11-06 22:26:09 +01:00
|
|
|
XaceHookAuditEnd(client, result);
|
2006-08-26 00:17:01 +02:00
|
|
|
}
|
2006-11-03 21:54:43 +01:00
|
|
|
#ifdef XSERVER_DTRACE
|
2007-11-26 21:59:44 +01:00
|
|
|
XSERVER_REQUEST_DONE(LookupMajorName(MAJOROP), MAJOROP,
|
2006-11-03 21:54:43 +01:00
|
|
|
client->sequence, client->index, result);
|
|
|
|
#endif
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
if (result != Success)
|
|
|
|
{
|
|
|
|
if (client->noClientException != Success)
|
|
|
|
CloseDownClient(client);
|
|
|
|
else
|
|
|
|
SendErrorToClient(client, MAJOROP,
|
|
|
|
MinorOpcodeOfRequest(client),
|
|
|
|
client->errorValue, result);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FlushAllOutput();
|
2003-11-14 17:49:22 +01:00
|
|
|
client = clients[clientReady[nready]];
|
|
|
|
if (client)
|
|
|
|
client->smart_stop_tick = SmartScheduleTime;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
dispatchException &= ~DE_PRIORITYCHANGE;
|
|
|
|
}
|
2004-06-21 15:44:14 +02:00
|
|
|
#if defined(DDXBEFORERESET)
|
|
|
|
ddxBeforeReset ();
|
|
|
|
#endif
|
2003-11-14 16:54:54 +01:00
|
|
|
KillAllClients();
|
2007-11-05 15:36:54 +01:00
|
|
|
xfree(clientReady);
|
2003-11-14 16:54:54 +01:00
|
|
|
dispatchException &= ~DE_RESET;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef MAJOROP
|
|
|
|
|
2009-04-22 05:26:40 +02:00
|
|
|
static int VendorRelease = VENDOR_RELEASE;
|
|
|
|
static char *VendorString = VENDOR_NAME;
|
|
|
|
|
|
|
|
static const int padlength[4] = {0, 3, 2, 1};
|
|
|
|
|
|
|
|
void
|
|
|
|
SetVendorRelease(int release)
|
|
|
|
{
|
|
|
|
VendorRelease = release;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SetVendorString(char *string)
|
|
|
|
{
|
|
|
|
VendorString = string;
|
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
|
|
|
CreateConnectionBlock(void)
|
|
|
|
{
|
|
|
|
xConnSetup setup;
|
|
|
|
xWindowRoot root;
|
|
|
|
xDepth depth;
|
|
|
|
xVisualType visual;
|
|
|
|
xPixmapFormat format;
|
|
|
|
unsigned long vid;
|
|
|
|
int i, j, k,
|
|
|
|
lenofblock,
|
|
|
|
sizesofar = 0;
|
|
|
|
char *pBuf;
|
|
|
|
|
|
|
|
|
|
|
|
memset(&setup, 0, sizeof(xConnSetup));
|
|
|
|
/* Leave off the ridBase and ridMask, these must be sent with
|
|
|
|
connection */
|
|
|
|
|
|
|
|
setup.release = VendorRelease;
|
|
|
|
/*
|
|
|
|
* per-server image and bitmap parameters are defined in Xmd.h
|
|
|
|
*/
|
|
|
|
setup.imageByteOrder = screenInfo.imageByteOrder;
|
|
|
|
|
|
|
|
setup.bitmapScanlineUnit = screenInfo.bitmapScanlineUnit;
|
|
|
|
setup.bitmapScanlinePad = screenInfo.bitmapScanlinePad;
|
|
|
|
|
|
|
|
setup.bitmapBitOrder = screenInfo.bitmapBitOrder;
|
|
|
|
setup.motionBufferSize = NumMotionEvents();
|
|
|
|
setup.numRoots = screenInfo.numScreens;
|
|
|
|
setup.nbytesVendor = strlen(VendorString);
|
|
|
|
setup.numFormats = screenInfo.numPixmapFormats;
|
|
|
|
setup.maxRequestSize = MAX_REQUEST_SIZE;
|
|
|
|
QueryMinMaxKeyCodes(&setup.minKeyCode, &setup.maxKeyCode);
|
|
|
|
|
|
|
|
lenofblock = sizeof(xConnSetup) +
|
|
|
|
((setup.nbytesVendor + 3) & ~3) +
|
|
|
|
(setup.numFormats * sizeof(xPixmapFormat)) +
|
|
|
|
(setup.numRoots * sizeof(xWindowRoot));
|
|
|
|
ConnectionInfo = xalloc(lenofblock);
|
|
|
|
if (!ConnectionInfo)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
memmove(ConnectionInfo, (char *)&setup, sizeof(xConnSetup));
|
|
|
|
sizesofar = sizeof(xConnSetup);
|
|
|
|
pBuf = ConnectionInfo + sizeof(xConnSetup);
|
|
|
|
|
|
|
|
memmove(pBuf, VendorString, (int)setup.nbytesVendor);
|
|
|
|
sizesofar += setup.nbytesVendor;
|
|
|
|
pBuf += setup.nbytesVendor;
|
|
|
|
i = padlength[setup.nbytesVendor & 3];
|
|
|
|
sizesofar += i;
|
|
|
|
while (--i >= 0)
|
|
|
|
*pBuf++ = 0;
|
|
|
|
|
|
|
|
memset(&format, 0, sizeof(xPixmapFormat));
|
|
|
|
for (i=0; i<screenInfo.numPixmapFormats; i++)
|
|
|
|
{
|
|
|
|
format.depth = screenInfo.formats[i].depth;
|
|
|
|
format.bitsPerPixel = screenInfo.formats[i].bitsPerPixel;
|
|
|
|
format.scanLinePad = screenInfo.formats[i].scanlinePad;
|
|
|
|
memmove(pBuf, (char *)&format, sizeof(xPixmapFormat));
|
|
|
|
pBuf += sizeof(xPixmapFormat);
|
|
|
|
sizesofar += sizeof(xPixmapFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
connBlockScreenStart = sizesofar;
|
|
|
|
memset(&depth, 0, sizeof(xDepth));
|
|
|
|
memset(&visual, 0, sizeof(xVisualType));
|
|
|
|
for (i=0; i<screenInfo.numScreens; i++)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
DepthPtr pDepth;
|
|
|
|
VisualPtr pVisual;
|
|
|
|
|
|
|
|
pScreen = screenInfo.screens[i];
|
|
|
|
root.windowId = WindowTable[i]->drawable.id;
|
|
|
|
root.defaultColormap = pScreen->defColormap;
|
|
|
|
root.whitePixel = pScreen->whitePixel;
|
|
|
|
root.blackPixel = pScreen->blackPixel;
|
|
|
|
root.currentInputMask = 0; /* filled in when sent */
|
|
|
|
root.pixWidth = pScreen->width;
|
|
|
|
root.pixHeight = pScreen->height;
|
|
|
|
root.mmWidth = pScreen->mmWidth;
|
|
|
|
root.mmHeight = pScreen->mmHeight;
|
|
|
|
root.minInstalledMaps = pScreen->minInstalledCmaps;
|
|
|
|
root.maxInstalledMaps = pScreen->maxInstalledCmaps;
|
|
|
|
root.rootVisualID = pScreen->rootVisual;
|
|
|
|
root.backingStore = pScreen->backingStoreSupport;
|
|
|
|
root.saveUnders = FALSE;
|
|
|
|
root.rootDepth = pScreen->rootDepth;
|
|
|
|
root.nDepths = pScreen->numDepths;
|
|
|
|
memmove(pBuf, (char *)&root, sizeof(xWindowRoot));
|
|
|
|
sizesofar += sizeof(xWindowRoot);
|
|
|
|
pBuf += sizeof(xWindowRoot);
|
|
|
|
|
|
|
|
pDepth = pScreen->allowedDepths;
|
|
|
|
for(j = 0; j < pScreen->numDepths; j++, pDepth++)
|
|
|
|
{
|
|
|
|
lenofblock += sizeof(xDepth) +
|
|
|
|
(pDepth->numVids * sizeof(xVisualType));
|
|
|
|
pBuf = (char *)xrealloc(ConnectionInfo, lenofblock);
|
|
|
|
if (!pBuf)
|
|
|
|
{
|
|
|
|
xfree(ConnectionInfo);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
ConnectionInfo = pBuf;
|
|
|
|
pBuf += sizesofar;
|
|
|
|
depth.depth = pDepth->depth;
|
|
|
|
depth.nVisuals = pDepth->numVids;
|
|
|
|
memmove(pBuf, (char *)&depth, sizeof(xDepth));
|
|
|
|
pBuf += sizeof(xDepth);
|
|
|
|
sizesofar += sizeof(xDepth);
|
|
|
|
for(k = 0; k < pDepth->numVids; k++)
|
|
|
|
{
|
|
|
|
vid = pDepth->vids[k];
|
|
|
|
for (pVisual = pScreen->visuals;
|
|
|
|
pVisual->vid != vid;
|
|
|
|
pVisual++)
|
|
|
|
;
|
|
|
|
visual.visualID = vid;
|
|
|
|
visual.class = pVisual->class;
|
|
|
|
visual.bitsPerRGB = pVisual->bitsPerRGBValue;
|
|
|
|
visual.colormapEntries = pVisual->ColormapEntries;
|
|
|
|
visual.redMask = pVisual->redMask;
|
|
|
|
visual.greenMask = pVisual->greenMask;
|
|
|
|
visual.blueMask = pVisual->blueMask;
|
|
|
|
memmove(pBuf, (char *)&visual, sizeof(xVisualType));
|
|
|
|
pBuf += sizeof(xVisualType);
|
|
|
|
sizesofar += sizeof(xVisualType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
connSetupPrefix.success = xTrue;
|
|
|
|
connSetupPrefix.length = lenofblock/4;
|
|
|
|
connSetupPrefix.majorVersion = X_PROTOCOL;
|
|
|
|
connSetupPrefix.minorVersion = X_PROTOCOL_REVISION;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2005-03-08 00:02:59 +01:00
|
|
|
ProcBadRequest(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
return (BadRequest);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-03-08 00:02:59 +01:00
|
|
|
ProcCreateWindow(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-12-15 21:50:46 +01:00
|
|
|
WindowPtr pParent, pWin;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xCreateWindowReq);
|
2007-08-13 19:40:47 +02:00
|
|
|
int len, rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xCreateWindowReq);
|
|
|
|
|
|
|
|
LEGAL_NEW_RESOURCE(stuff->wid, client);
|
2007-08-13 19:40:47 +02:00
|
|
|
rc = dixLookupWindow(&pParent, stuff->parent, client, DixAddAccess);
|
2006-12-15 21:50:46 +01:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
len = client->req_len - (sizeof(xCreateWindowReq) >> 2);
|
|
|
|
if (Ones(stuff->mask) != len)
|
|
|
|
return BadLength;
|
|
|
|
if (!stuff->width || !stuff->height)
|
|
|
|
{
|
|
|
|
client->errorValue = 0;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
pWin = CreateWindow(stuff->wid, pParent, stuff->x,
|
|
|
|
stuff->y, stuff->width, stuff->height,
|
|
|
|
stuff->borderWidth, stuff->class,
|
|
|
|
stuff->mask, (XID *) &stuff[1],
|
|
|
|
(int)stuff->depth,
|
2007-08-13 19:40:47 +02:00
|
|
|
client, stuff->visual, &rc);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (pWin)
|
|
|
|
{
|
|
|
|
Mask mask = pWin->eventMask;
|
|
|
|
|
|
|
|
pWin->eventMask = 0; /* subterfuge in case AddResource fails */
|
|
|
|
if (!AddResource(stuff->wid, RT_WINDOW, (pointer)pWin))
|
|
|
|
return BadAlloc;
|
|
|
|
pWin->eventMask = mask;
|
|
|
|
}
|
|
|
|
if (client->noClientException != Success)
|
|
|
|
return(client->noClientException);
|
|
|
|
else
|
2007-08-13 19:40:47 +02:00
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcChangeWindowAttributes(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-12-15 21:50:46 +01:00
|
|
|
WindowPtr pWin;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xChangeWindowAttributesReq);
|
2007-09-19 17:11:41 +02:00
|
|
|
int result, len, rc;
|
2007-09-20 15:17:09 +02:00
|
|
|
Mask access_mode = 0;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
|
2007-09-20 15:17:09 +02:00
|
|
|
access_mode |= (stuff->valueMask & CWEventMask) ? DixReceiveAccess : 0;
|
|
|
|
access_mode |= (stuff->valueMask & ~CWEventMask) ? DixSetAttrAccess : 0;
|
2007-09-19 17:11:41 +02:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->window, client, access_mode);
|
2006-12-15 21:50:46 +01:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
len = client->req_len - (sizeof(xChangeWindowAttributesReq) >> 2);
|
|
|
|
if (len != Ones(stuff->valueMask))
|
|
|
|
return BadLength;
|
|
|
|
result = ChangeWindowAttributes(pWin,
|
|
|
|
stuff->valueMask,
|
|
|
|
(XID *) &stuff[1],
|
|
|
|
client);
|
|
|
|
if (client->noClientException != Success)
|
|
|
|
return(client->noClientException);
|
|
|
|
else
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcGetWindowAttributes(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-12-15 21:50:46 +01:00
|
|
|
WindowPtr pWin;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xResourceReq);
|
|
|
|
xGetWindowAttributesReply wa;
|
2006-12-15 21:50:46 +01:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2007-08-13 19:40:47 +02:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess);
|
2006-12-15 21:50:46 +01:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2009-02-13 10:23:28 +01:00
|
|
|
memset(&wa, 0, sizeof(xGetWindowAttributesReply));
|
2003-11-14 16:54:54 +01:00
|
|
|
GetWindowAttributes(pWin, client, &wa);
|
|
|
|
WriteReplyToClient(client, sizeof(xGetWindowAttributesReply), &wa);
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcDestroyWindow(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-12-15 21:50:46 +01:00
|
|
|
WindowPtr pWin;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xResourceReq);
|
2006-12-15 21:50:46 +01:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2006-12-15 21:50:46 +01:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->id, client, DixDestroyAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2007-08-13 19:40:47 +02:00
|
|
|
if (pWin->parent) {
|
|
|
|
rc = dixLookupWindow(&pWin, pWin->parent->drawable.id, client,
|
|
|
|
DixRemoveAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
FreeResource(stuff->id, RT_NONE);
|
2007-08-13 19:40:47 +02:00
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcDestroySubwindows(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-12-15 21:50:46 +01:00
|
|
|
WindowPtr pWin;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xResourceReq);
|
2006-12-15 21:50:46 +01:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2007-08-13 19:40:47 +02:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->id, client, DixRemoveAccess);
|
2006-12-15 21:50:46 +01:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
DestroySubwindows(pWin, client);
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcChangeSaveSet(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-12-15 21:50:46 +01:00
|
|
|
WindowPtr pWin;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xChangeSaveSetReq);
|
2007-03-08 08:20:19 +01:00
|
|
|
int result, rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xChangeSaveSetReq);
|
2007-08-13 19:40:47 +02:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->window, client, DixManageAccess);
|
2006-12-15 21:50:46 +01:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
if (client->clientAsMask == (CLIENT_BITS(pWin->drawable.id)))
|
|
|
|
return BadMatch;
|
|
|
|
if ((stuff->mode == SetModeInsert) || (stuff->mode == SetModeDelete))
|
|
|
|
{
|
2004-07-29 20:43:58 +02:00
|
|
|
result = AlterSaveSetForClient(client, pWin, stuff->mode, FALSE, TRUE);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (client->noClientException != Success)
|
|
|
|
return(client->noClientException);
|
|
|
|
else
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->mode;
|
|
|
|
return( BadValue );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcReparentWindow(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-12-15 21:50:46 +01:00
|
|
|
WindowPtr pWin, pParent;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xReparentWindowReq);
|
2007-03-08 08:20:19 +01:00
|
|
|
int result, rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xReparentWindowReq);
|
2007-08-13 19:40:47 +02:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->window, client, DixManageAccess);
|
2006-12-15 21:50:46 +01:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2007-08-13 19:40:47 +02:00
|
|
|
rc = dixLookupWindow(&pParent, stuff->parent, client, DixAddAccess);
|
2006-12-15 21:50:46 +01:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
if (SAME_SCREENS(pWin->drawable, pParent->drawable))
|
|
|
|
{
|
|
|
|
if ((pWin->backgroundState == ParentRelative) &&
|
|
|
|
(pParent->drawable.depth != pWin->drawable.depth))
|
|
|
|
return BadMatch;
|
|
|
|
if ((pWin->drawable.class != InputOnly) &&
|
|
|
|
(pParent->drawable.class == InputOnly))
|
|
|
|
return BadMatch;
|
|
|
|
result = ReparentWindow(pWin, pParent,
|
|
|
|
(short)stuff->x, (short)stuff->y, client);
|
|
|
|
if (client->noClientException != Success)
|
|
|
|
return(client->noClientException);
|
|
|
|
else
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return (BadMatch);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcMapWindow(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-12-15 21:50:46 +01:00
|
|
|
WindowPtr pWin;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xResourceReq);
|
2006-12-15 21:50:46 +01:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2007-08-13 19:40:47 +02:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->id, client, DixShowAccess);
|
2006-12-15 21:50:46 +01:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
MapWindow(pWin, client);
|
|
|
|
/* update cache to say it is mapped */
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcMapSubwindows(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-12-15 21:50:46 +01:00
|
|
|
WindowPtr pWin;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xResourceReq);
|
2006-12-15 21:50:46 +01:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2007-08-13 19:40:47 +02:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->id, client, DixListAccess);
|
2006-12-15 21:50:46 +01:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
MapSubwindows(pWin, client);
|
|
|
|
/* update cache to say it is mapped */
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcUnmapWindow(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-12-15 21:50:46 +01:00
|
|
|
WindowPtr pWin;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xResourceReq);
|
2006-12-15 21:50:46 +01:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2007-08-13 19:40:47 +02:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->id, client, DixHideAccess);
|
2006-12-15 21:50:46 +01:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
UnmapWindow(pWin, FALSE);
|
|
|
|
/* update cache to say it is mapped */
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcUnmapSubwindows(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-12-15 21:50:46 +01:00
|
|
|
WindowPtr pWin;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xResourceReq);
|
2006-12-15 21:50:46 +01:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2007-08-13 19:40:47 +02:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->id, client, DixListAccess);
|
2006-12-15 21:50:46 +01:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
UnmapSubwindows(pWin);
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcConfigureWindow(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-12-15 21:50:46 +01:00
|
|
|
WindowPtr pWin;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xConfigureWindowReq);
|
2007-03-08 08:20:19 +01:00
|
|
|
int result;
|
2006-12-15 21:50:46 +01:00
|
|
|
int len, rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xConfigureWindowReq);
|
2007-08-13 19:40:47 +02:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->window, client,
|
|
|
|
DixManageAccess|DixSetAttrAccess);
|
2006-12-15 21:50:46 +01:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
len = client->req_len - (sizeof(xConfigureWindowReq) >> 2);
|
|
|
|
if (Ones((Mask)stuff->mask) != len)
|
|
|
|
return BadLength;
|
|
|
|
result = ConfigureWindow(pWin, (Mask)stuff->mask, (XID *) &stuff[1],
|
|
|
|
client);
|
|
|
|
if (client->noClientException != Success)
|
|
|
|
return(client->noClientException);
|
|
|
|
else
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcCirculateWindow(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-12-15 21:50:46 +01:00
|
|
|
WindowPtr pWin;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xCirculateWindowReq);
|
2006-12-15 21:50:46 +01:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xCirculateWindowReq);
|
|
|
|
if ((stuff->direction != RaiseLowest) &&
|
|
|
|
(stuff->direction != LowerHighest))
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->direction;
|
|
|
|
return BadValue;
|
|
|
|
}
|
2007-08-13 19:40:47 +02:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->window, client, DixManageAccess);
|
2006-12-15 21:50:46 +01:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
CirculateWindow(pWin, (int)stuff->direction, client);
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
2007-03-25 23:57:54 +02:00
|
|
|
static int
|
2007-03-08 08:20:19 +01:00
|
|
|
GetGeometry(ClientPtr client, xGetGeometryReply *rep)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-12-15 01:15:21 +01:00
|
|
|
DrawablePtr pDraw;
|
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xResourceReq);
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2006-12-15 01:15:21 +01:00
|
|
|
|
2007-08-13 19:40:47 +02:00
|
|
|
rc = dixLookupDrawable(&pDraw, stuff->id, client, M_ANY, DixGetAttrAccess);
|
2006-12-15 01:15:21 +01:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
rep->type = X_Reply;
|
|
|
|
rep->length = 0;
|
|
|
|
rep->sequenceNumber = client->sequence;
|
|
|
|
rep->root = WindowTable[pDraw->pScreen->myNum]->drawable.id;
|
|
|
|
rep->depth = pDraw->depth;
|
|
|
|
rep->width = pDraw->width;
|
|
|
|
rep->height = pDraw->height;
|
|
|
|
|
|
|
|
/* XXX - Because the pixmap-implementation of the multibuffer extension
|
|
|
|
* may have the buffer-id's drawable resource value be a pointer
|
|
|
|
* to the buffer's window instead of the buffer itself
|
|
|
|
* (this happens if the buffer is the displayed buffer),
|
|
|
|
* we also have to check that the id matches before we can
|
|
|
|
* truly say that it is a DRAWABLE_WINDOW.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ((pDraw->type == UNDRAWABLE_WINDOW) ||
|
|
|
|
((pDraw->type == DRAWABLE_WINDOW) && (stuff->id == pDraw->id)))
|
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
WindowPtr pWin = (WindowPtr)pDraw;
|
2003-11-14 16:54:54 +01:00
|
|
|
rep->x = pWin->origin.x - wBorderWidth (pWin);
|
|
|
|
rep->y = pWin->origin.y - wBorderWidth (pWin);
|
|
|
|
rep->borderWidth = pWin->borderWidth;
|
|
|
|
}
|
|
|
|
else /* DRAWABLE_PIXMAP or DRAWABLE_BUFFER */
|
|
|
|
{
|
|
|
|
rep->x = rep->y = rep->borderWidth = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcGetGeometry(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
xGetGeometryReply rep;
|
|
|
|
int status;
|
|
|
|
|
2009-02-13 10:23:28 +01:00
|
|
|
memset(&rep, 0, sizeof(xGetGeometryReply));
|
2003-11-14 16:54:54 +01:00
|
|
|
if ((status = GetGeometry(client, &rep)) != Success)
|
|
|
|
return status;
|
|
|
|
|
|
|
|
WriteReplyToClient(client, sizeof(xGetGeometryReply), &rep);
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcQueryTree(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
xQueryTreeReply reply;
|
2006-12-15 21:50:46 +01:00
|
|
|
int rc, numChildren = 0;
|
|
|
|
WindowPtr pChild, pWin, pHead;
|
2003-11-14 16:54:54 +01:00
|
|
|
Window *childIDs = (Window *)NULL;
|
|
|
|
REQUEST(xResourceReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2007-08-13 19:40:47 +02:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->id, client, DixListAccess);
|
2006-12-15 21:50:46 +01:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2009-02-13 10:23:28 +01:00
|
|
|
memset(&reply, 0, sizeof(xQueryTreeReply));
|
2003-11-14 16:54:54 +01:00
|
|
|
reply.type = X_Reply;
|
|
|
|
reply.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id;
|
|
|
|
reply.sequenceNumber = client->sequence;
|
|
|
|
if (pWin->parent)
|
|
|
|
reply.parent = pWin->parent->drawable.id;
|
|
|
|
else
|
|
|
|
reply.parent = (Window)None;
|
|
|
|
pHead = RealChildHead(pWin);
|
|
|
|
for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
|
|
|
|
numChildren++;
|
|
|
|
if (numChildren)
|
|
|
|
{
|
|
|
|
int curChild = 0;
|
|
|
|
|
2009-01-22 08:11:16 +01:00
|
|
|
childIDs = xalloc(numChildren * sizeof(Window));
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!childIDs)
|
|
|
|
return BadAlloc;
|
|
|
|
for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
|
|
|
|
childIDs[curChild++] = pChild->drawable.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
reply.nChildren = numChildren;
|
|
|
|
reply.length = (numChildren * sizeof(Window)) >> 2;
|
|
|
|
|
|
|
|
WriteReplyToClient(client, sizeof(xQueryTreeReply), &reply);
|
|
|
|
if (numChildren)
|
|
|
|
{
|
2003-11-14 17:49:22 +01:00
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
|
2003-11-14 16:54:54 +01:00
|
|
|
WriteSwappedDataToClient(client, numChildren * sizeof(Window), childIDs);
|
2007-11-05 14:53:34 +01:00
|
|
|
xfree(childIDs);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcInternAtom(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
Atom atom;
|
|
|
|
char *tchar;
|
|
|
|
REQUEST(xInternAtomReq);
|
|
|
|
|
|
|
|
REQUEST_FIXED_SIZE(xInternAtomReq, stuff->nbytes);
|
|
|
|
if ((stuff->onlyIfExists != xTrue) && (stuff->onlyIfExists != xFalse))
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->onlyIfExists;
|
|
|
|
return(BadValue);
|
|
|
|
}
|
|
|
|
tchar = (char *) &stuff[1];
|
|
|
|
atom = MakeAtom(tchar, stuff->nbytes, !stuff->onlyIfExists);
|
|
|
|
if (atom != BAD_RESOURCE)
|
|
|
|
{
|
|
|
|
xInternAtomReply reply;
|
2009-02-13 10:23:28 +01:00
|
|
|
memset(&reply, 0, sizeof(xInternAtomReply));
|
2003-11-14 16:54:54 +01:00
|
|
|
reply.type = X_Reply;
|
|
|
|
reply.length = 0;
|
|
|
|
reply.sequenceNumber = client->sequence;
|
|
|
|
reply.atom = atom;
|
|
|
|
WriteReplyToClient(client, sizeof(xInternAtomReply), &reply);
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return (BadAlloc);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcGetAtomName(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2009-02-03 04:25:14 +01:00
|
|
|
const char *str;
|
2003-11-14 16:54:54 +01:00
|
|
|
xGetAtomNameReply reply;
|
|
|
|
int len;
|
|
|
|
REQUEST(xResourceReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
|
|
|
if ( (str = NameForAtom(stuff->id)) )
|
|
|
|
{
|
|
|
|
len = strlen(str);
|
2009-02-13 10:23:28 +01:00
|
|
|
memset(&reply, 0, sizeof(xGetAtomNameReply));
|
2003-11-14 16:54:54 +01:00
|
|
|
reply.type = X_Reply;
|
|
|
|
reply.length = (len + 3) >> 2;
|
|
|
|
reply.sequenceNumber = client->sequence;
|
|
|
|
reply.nameLength = len;
|
|
|
|
WriteReplyToClient(client, sizeof(xGetAtomNameReply), &reply);
|
|
|
|
(void)WriteToClient(client, len, str);
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->id;
|
|
|
|
return (BadAtom);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcGrabServer(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-08-15 20:14:45 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST_SIZE_MATCH(xReq);
|
|
|
|
if (grabState != GrabNone && client != grabClient)
|
|
|
|
{
|
|
|
|
ResetCurrentRequest(client);
|
|
|
|
client->sequence--;
|
|
|
|
BITSET(grabWaiters, client->index);
|
|
|
|
IgnoreClient(client);
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
2007-08-15 20:14:45 +02:00
|
|
|
rc = OnlyListenToOneClient(client);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
grabState = GrabKickout;
|
|
|
|
grabClient = client;
|
|
|
|
|
|
|
|
if (ServerGrabCallback)
|
|
|
|
{
|
|
|
|
ServerGrabInfoRec grabinfo;
|
|
|
|
grabinfo.client = client;
|
|
|
|
grabinfo.grabstate = SERVER_GRABBED;
|
|
|
|
CallCallbacks(&ServerGrabCallback, (pointer)&grabinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-11-14 17:49:22 +01:00
|
|
|
UngrabServer(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
grabState = GrabNone;
|
|
|
|
ListenToAllClients();
|
|
|
|
for (i = mskcnt; --i >= 0 && !grabWaiters[i]; )
|
|
|
|
;
|
|
|
|
if (i >= 0)
|
|
|
|
{
|
|
|
|
i <<= 5;
|
|
|
|
while (!GETBIT(grabWaiters, i))
|
|
|
|
i++;
|
|
|
|
BITCLEAR(grabWaiters, i);
|
|
|
|
AttendClient(clients[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ServerGrabCallback)
|
|
|
|
{
|
|
|
|
ServerGrabInfoRec grabinfo;
|
|
|
|
grabinfo.client = client;
|
|
|
|
grabinfo.grabstate = SERVER_UNGRABBED;
|
|
|
|
CallCallbacks(&ServerGrabCallback, (pointer)&grabinfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcUngrabServer(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
REQUEST_SIZE_MATCH(xReq);
|
|
|
|
UngrabServer(client);
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcTranslateCoords(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
REQUEST(xTranslateCoordsReq);
|
|
|
|
|
2006-12-15 21:50:46 +01:00
|
|
|
WindowPtr pWin, pDst;
|
2003-11-14 16:54:54 +01:00
|
|
|
xTranslateCoordsReply rep;
|
2006-12-15 21:50:46 +01:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xTranslateCoordsReq);
|
2007-08-13 19:40:47 +02:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->srcWid, client, DixGetAttrAccess);
|
2006-12-15 21:50:46 +01:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2007-08-13 19:40:47 +02:00
|
|
|
rc = dixLookupWindow(&pDst, stuff->dstWid, client, DixGetAttrAccess);
|
2006-12-15 21:50:46 +01:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2009-02-13 10:23:28 +01:00
|
|
|
memset(&rep, 0, sizeof(xTranslateCoordsReply));
|
2003-11-14 16:54:54 +01:00
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.length = 0;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
if (!SAME_SCREENS(pWin->drawable, pDst->drawable))
|
|
|
|
{
|
|
|
|
rep.sameScreen = xFalse;
|
|
|
|
rep.child = None;
|
|
|
|
rep.dstX = rep.dstY = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
INT16 x, y;
|
|
|
|
rep.sameScreen = xTrue;
|
|
|
|
rep.child = None;
|
|
|
|
/* computing absolute coordinates -- adjust to destination later */
|
|
|
|
x = pWin->drawable.x + stuff->srcX;
|
|
|
|
y = pWin->drawable.y + stuff->srcY;
|
|
|
|
pWin = pDst->firstChild;
|
|
|
|
while (pWin)
|
|
|
|
{
|
|
|
|
BoxRec box;
|
|
|
|
if ((pWin->mapped) &&
|
|
|
|
(x >= pWin->drawable.x - wBorderWidth (pWin)) &&
|
|
|
|
(x < pWin->drawable.x + (int)pWin->drawable.width +
|
|
|
|
wBorderWidth (pWin)) &&
|
|
|
|
(y >= pWin->drawable.y - wBorderWidth (pWin)) &&
|
|
|
|
(y < pWin->drawable.y + (int)pWin->drawable.height +
|
|
|
|
wBorderWidth (pWin))
|
|
|
|
/* When a window is shaped, a further check
|
|
|
|
* is made to see if the point is inside
|
|
|
|
* borderSize
|
|
|
|
*/
|
|
|
|
&& (!wBoundingShape(pWin) ||
|
|
|
|
POINT_IN_REGION(pWin->drawable.pScreen,
|
|
|
|
&pWin->borderSize, x, y, &box))
|
2005-06-10 06:01:14 +02:00
|
|
|
|
|
|
|
&& (!wInputShape(pWin) ||
|
|
|
|
POINT_IN_REGION(pWin->drawable.pScreen,
|
|
|
|
wInputShape(pWin),
|
|
|
|
x - pWin->drawable.x,
|
|
|
|
y - pWin->drawable.y, &box))
|
2003-11-14 16:54:54 +01:00
|
|
|
)
|
|
|
|
{
|
|
|
|
rep.child = pWin->drawable.id;
|
|
|
|
pWin = (WindowPtr) NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pWin = pWin->nextSib;
|
|
|
|
}
|
|
|
|
/* adjust to destination coordinates */
|
|
|
|
rep.dstX = x - pDst->drawable.x;
|
|
|
|
rep.dstY = y - pDst->drawable.y;
|
|
|
|
}
|
|
|
|
WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep);
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcOpenFont(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
REQUEST(xOpenFontReq);
|
|
|
|
|
|
|
|
REQUEST_FIXED_SIZE(xOpenFontReq, stuff->nbytes);
|
|
|
|
client->errorValue = stuff->fid;
|
|
|
|
LEGAL_NEW_RESOURCE(stuff->fid, client);
|
|
|
|
err = OpenFont(client, stuff->fid, (Mask) 0,
|
|
|
|
stuff->nbytes, (char *)&stuff[1]);
|
|
|
|
if (err == Success)
|
|
|
|
{
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcCloseFont(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
FontPtr pFont;
|
|
|
|
REQUEST(xResourceReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
|
|
|
pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT,
|
2006-12-14 20:45:42 +01:00
|
|
|
DixDestroyAccess);
|
2003-11-14 16:54:54 +01:00
|
|
|
if ( pFont != (FontPtr)NULL) /* id was valid */
|
|
|
|
{
|
|
|
|
FreeResource(stuff->id, RT_NONE);
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->id;
|
|
|
|
return (BadFont);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcQueryFont(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
xQueryFontReply *reply;
|
|
|
|
FontPtr pFont;
|
2007-03-08 08:20:19 +01:00
|
|
|
GC *pGC;
|
2007-08-16 18:02:59 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xResourceReq);
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2007-08-16 18:02:59 +02:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
client->errorValue = stuff->id; /* EITHER font or gc */
|
2008-08-07 00:26:24 +02:00
|
|
|
rc = dixLookupResourceByType((pointer *)&pFont, stuff->id, RT_FONT, client,
|
|
|
|
DixGetAttrAccess);
|
2007-08-16 18:02:59 +02:00
|
|
|
if (rc == BadValue) {
|
2008-08-07 00:26:24 +02:00
|
|
|
rc = dixLookupResourceByType((pointer *)&pGC, stuff->id, RT_GC, client,
|
|
|
|
DixGetAttrAccess);
|
2007-08-16 18:02:59 +02:00
|
|
|
if (rc == Success)
|
|
|
|
pFont = pGC->font;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2007-08-16 18:02:59 +02:00
|
|
|
if (rc != Success)
|
|
|
|
return (rc == BadValue) ? BadFont: rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
xCharInfo *pmax = FONTINKMAX(pFont);
|
|
|
|
xCharInfo *pmin = FONTINKMIN(pFont);
|
|
|
|
int nprotoxcistructs;
|
|
|
|
int rlength;
|
|
|
|
|
|
|
|
nprotoxcistructs = (
|
|
|
|
pmax->rightSideBearing == pmin->rightSideBearing &&
|
|
|
|
pmax->leftSideBearing == pmin->leftSideBearing &&
|
|
|
|
pmax->descent == pmin->descent &&
|
|
|
|
pmax->ascent == pmin->ascent &&
|
|
|
|
pmax->characterWidth == pmin->characterWidth) ?
|
|
|
|
0 : N2dChars(pFont);
|
|
|
|
|
|
|
|
rlength = sizeof(xQueryFontReply) +
|
|
|
|
FONTINFONPROPS(FONTCHARSET(pFont)) * sizeof(xFontProp) +
|
|
|
|
nprotoxcistructs * sizeof(xCharInfo);
|
2009-02-13 10:23:28 +01:00
|
|
|
reply = xcalloc(1, rlength);
|
2003-11-14 16:54:54 +01:00
|
|
|
if(!reply)
|
|
|
|
{
|
|
|
|
return(BadAlloc);
|
|
|
|
}
|
|
|
|
|
|
|
|
reply->type = X_Reply;
|
|
|
|
reply->length = (rlength - sizeof(xGenericReply)) >> 2;
|
|
|
|
reply->sequenceNumber = client->sequence;
|
|
|
|
QueryFont( pFont, reply, nprotoxcistructs);
|
|
|
|
|
|
|
|
WriteReplyToClient(client, rlength, reply);
|
2007-11-05 14:53:34 +01:00
|
|
|
xfree(reply);
|
2003-11-14 16:54:54 +01:00
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcQueryTextExtents(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
xQueryTextExtentsReply reply;
|
|
|
|
FontPtr pFont;
|
|
|
|
GC *pGC;
|
|
|
|
ExtentInfoRec info;
|
|
|
|
unsigned long length;
|
2007-08-16 18:02:59 +02:00
|
|
|
int rc;
|
|
|
|
REQUEST(xQueryTextExtentsReq);
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST_AT_LEAST_SIZE(xQueryTextExtentsReq);
|
|
|
|
|
2007-08-16 18:02:59 +02:00
|
|
|
client->errorValue = stuff->fid; /* EITHER font or gc */
|
2008-08-07 00:26:24 +02:00
|
|
|
rc = dixLookupResourceByType((pointer *)&pFont, stuff->fid, RT_FONT, client,
|
|
|
|
DixGetAttrAccess);
|
2007-08-16 18:02:59 +02:00
|
|
|
if (rc == BadValue) {
|
2008-08-07 00:26:24 +02:00
|
|
|
rc = dixLookupResourceByType((pointer *)&pGC, stuff->fid, RT_GC, client,
|
2007-08-16 18:02:59 +02:00
|
|
|
DixGetAttrAccess);
|
|
|
|
if (rc == Success)
|
|
|
|
pFont = pGC->font;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2007-08-16 18:02:59 +02:00
|
|
|
if (rc != Success)
|
|
|
|
return (rc == BadValue) ? BadFont: rc;
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
length = client->req_len - (sizeof(xQueryTextExtentsReq) >> 2);
|
|
|
|
length = length << 1;
|
|
|
|
if (stuff->oddLength)
|
|
|
|
{
|
|
|
|
if (length == 0)
|
|
|
|
return(BadLength);
|
|
|
|
length--;
|
|
|
|
}
|
|
|
|
if (!QueryTextExtents(pFont, length, (unsigned char *)&stuff[1], &info))
|
|
|
|
return(BadAlloc);
|
|
|
|
reply.type = X_Reply;
|
|
|
|
reply.length = 0;
|
|
|
|
reply.sequenceNumber = client->sequence;
|
|
|
|
reply.drawDirection = info.drawDirection;
|
|
|
|
reply.fontAscent = info.fontAscent;
|
|
|
|
reply.fontDescent = info.fontDescent;
|
|
|
|
reply.overallAscent = info.overallAscent;
|
|
|
|
reply.overallDescent = info.overallDescent;
|
|
|
|
reply.overallWidth = info.overallWidth;
|
|
|
|
reply.overallLeft = info.overallLeft;
|
|
|
|
reply.overallRight = info.overallRight;
|
|
|
|
WriteReplyToClient(client, sizeof(xQueryTextExtentsReply), &reply);
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcListFonts(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
REQUEST(xListFontsReq);
|
|
|
|
|
|
|
|
REQUEST_FIXED_SIZE(xListFontsReq, stuff->nbytes);
|
|
|
|
|
|
|
|
return ListFonts(client, (unsigned char *) &stuff[1], stuff->nbytes,
|
|
|
|
stuff->maxNames);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcListFontsWithInfo(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
REQUEST(xListFontsWithInfoReq);
|
|
|
|
|
|
|
|
REQUEST_FIXED_SIZE(xListFontsWithInfoReq, stuff->nbytes);
|
|
|
|
|
|
|
|
return StartListFontsWithInfo(client, stuff->nbytes,
|
|
|
|
(unsigned char *) &stuff[1], stuff->maxNames);
|
|
|
|
}
|
|
|
|
|
2005-03-08 00:02:59 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* \param value must conform to DeleteType
|
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2005-03-08 00:02:59 +01:00
|
|
|
dixDestroyPixmap(pointer value, XID pid)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
PixmapPtr pPixmap = (PixmapPtr)value;
|
|
|
|
return (*pPixmap->drawable.pScreen->DestroyPixmap)(pPixmap);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcCreatePixmap(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
PixmapPtr pMap;
|
2006-12-15 01:15:21 +01:00
|
|
|
DrawablePtr pDraw;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xCreatePixmapReq);
|
|
|
|
DepthPtr pDepth;
|
2007-03-08 08:20:19 +01:00
|
|
|
int i, rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xCreatePixmapReq);
|
|
|
|
client->errorValue = stuff->pid;
|
|
|
|
LEGAL_NEW_RESOURCE(stuff->pid, client);
|
2006-12-15 01:15:21 +01:00
|
|
|
|
|
|
|
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, M_ANY,
|
2007-08-16 18:27:48 +02:00
|
|
|
DixGetAttrAccess);
|
2006-12-15 01:15:21 +01:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!stuff->width || !stuff->height)
|
|
|
|
{
|
|
|
|
client->errorValue = 0;
|
|
|
|
return BadValue;
|
|
|
|
}
|
2005-09-13 03:33:19 +02:00
|
|
|
if (stuff->width > 32767 || stuff->height > 32767)
|
|
|
|
{
|
|
|
|
/* It is allowed to try and allocate a pixmap which is larger than
|
|
|
|
* 32767 in either dimension. However, all of the framebuffer code
|
|
|
|
* is buggy and does not reliably draw to such big pixmaps, basically
|
|
|
|
* because the Region data structure operates with signed shorts
|
|
|
|
* for the rectangles in it.
|
|
|
|
*
|
|
|
|
* Furthermore, several places in the X server computes the
|
|
|
|
* size in bytes of the pixmap and tries to store it in an
|
|
|
|
* integer. This integer can overflow and cause the allocated size
|
|
|
|
* to be much smaller.
|
|
|
|
*
|
|
|
|
* So, such big pixmaps are rejected here with a BadAlloc
|
|
|
|
*/
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
if (stuff->depth != 1)
|
|
|
|
{
|
|
|
|
pDepth = pDraw->pScreen->allowedDepths;
|
|
|
|
for (i=0; i<pDraw->pScreen->numDepths; i++, pDepth++)
|
|
|
|
if (pDepth->depth == stuff->depth)
|
|
|
|
goto CreatePmap;
|
|
|
|
client->errorValue = stuff->depth;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
CreatePmap:
|
|
|
|
pMap = (PixmapPtr)(*pDraw->pScreen->CreatePixmap)
|
|
|
|
(pDraw->pScreen, stuff->width,
|
2007-10-31 22:15:35 +01:00
|
|
|
stuff->height, stuff->depth, 0);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (pMap)
|
|
|
|
{
|
|
|
|
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
|
|
|
|
pMap->drawable.id = stuff->pid;
|
2007-08-16 18:27:48 +02:00
|
|
|
/* security creation/labeling check */
|
|
|
|
rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, RT_PIXMAP,
|
2007-09-05 17:18:36 +02:00
|
|
|
pMap, RT_NONE, NULL, DixCreateAccess);
|
2007-08-16 18:27:48 +02:00
|
|
|
if (rc != Success) {
|
|
|
|
(*pDraw->pScreen->DestroyPixmap)(pMap);
|
|
|
|
return rc;
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
if (AddResource(stuff->pid, RT_PIXMAP, (pointer)pMap))
|
|
|
|
return(client->noClientException);
|
2008-09-02 22:20:40 +02:00
|
|
|
(*pDraw->pScreen->DestroyPixmap)(pMap);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
return (BadAlloc);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcFreePixmap(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
PixmapPtr pMap;
|
2007-08-16 18:27:48 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xResourceReq);
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2007-08-16 18:27:48 +02:00
|
|
|
|
2008-08-07 00:26:24 +02:00
|
|
|
rc = dixLookupResourceByType((pointer *)&pMap, stuff->id, RT_PIXMAP, client,
|
2007-08-16 18:27:48 +02:00
|
|
|
DixDestroyAccess);
|
|
|
|
if (rc == Success)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
FreeResource(stuff->id, RT_NONE);
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->id;
|
2007-08-16 18:27:48 +02:00
|
|
|
return (rc == BadValue) ? BadPixmap : rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcCreateGC(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-12-14 23:53:43 +01:00
|
|
|
int error, rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
GC *pGC;
|
2006-12-14 23:53:43 +01:00
|
|
|
DrawablePtr pDraw;
|
2003-11-14 16:54:54 +01:00
|
|
|
unsigned len;
|
|
|
|
REQUEST(xCreateGCReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xCreateGCReq);
|
|
|
|
client->errorValue = stuff->gc;
|
|
|
|
LEGAL_NEW_RESOURCE(stuff->gc, client);
|
2007-08-14 19:09:38 +02:00
|
|
|
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
|
|
|
|
DixGetAttrAccess);
|
2006-12-14 23:53:43 +01:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
len = client->req_len - (sizeof(xCreateGCReq) >> 2);
|
|
|
|
if (len != Ones(stuff->mask))
|
|
|
|
return BadLength;
|
2007-08-14 19:09:38 +02:00
|
|
|
pGC = (GC *)CreateGC(pDraw, stuff->mask, (XID *) &stuff[1], &error,
|
|
|
|
stuff->gc, client);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (error != Success)
|
|
|
|
return error;
|
|
|
|
if (!AddResource(stuff->gc, RT_GC, (pointer)pGC))
|
|
|
|
return (BadAlloc);
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcChangeGC(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
GC *pGC;
|
|
|
|
int result;
|
|
|
|
unsigned len;
|
2006-12-15 01:15:21 +01:00
|
|
|
REQUEST(xChangeGCReq);
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST_AT_LEAST_SIZE(xChangeGCReq);
|
2006-12-15 01:15:21 +01:00
|
|
|
|
2007-08-14 19:09:38 +02:00
|
|
|
result = dixLookupGC(&pGC, stuff->gc, client, DixSetAttrAccess);
|
2006-12-15 01:15:21 +01:00
|
|
|
if (result != Success)
|
|
|
|
return result;
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
len = client->req_len - (sizeof(xChangeGCReq) >> 2);
|
|
|
|
if (len != Ones(stuff->mask))
|
|
|
|
return BadLength;
|
2003-11-14 17:49:22 +01:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
result = dixChangeGC(client, pGC, stuff->mask, (CARD32 *) &stuff[1], 0);
|
|
|
|
if (client->noClientException != Success)
|
|
|
|
return(client->noClientException);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = clientErrorValue;
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcCopyGC(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-12-15 01:15:21 +01:00
|
|
|
GC *dstGC;
|
|
|
|
GC *pGC;
|
2003-11-14 16:54:54 +01:00
|
|
|
int result;
|
|
|
|
REQUEST(xCopyGCReq);
|
|
|
|
REQUEST_SIZE_MATCH(xCopyGCReq);
|
2006-12-15 01:15:21 +01:00
|
|
|
|
2007-08-14 19:09:38 +02:00
|
|
|
result = dixLookupGC(&pGC, stuff->srcGC, client, DixGetAttrAccess);
|
2006-12-15 01:15:21 +01:00
|
|
|
if (result != Success)
|
|
|
|
return result;
|
2007-08-14 19:09:38 +02:00
|
|
|
result = dixLookupGC(&dstGC, stuff->dstGC, client, DixSetAttrAccess);
|
2006-12-15 01:15:21 +01:00
|
|
|
if (result != Success)
|
|
|
|
return result;
|
2003-11-14 16:54:54 +01:00
|
|
|
if ((dstGC->pScreen != pGC->pScreen) || (dstGC->depth != pGC->depth))
|
|
|
|
return (BadMatch);
|
|
|
|
result = CopyGC(pGC, dstGC, stuff->mask);
|
|
|
|
if (client->noClientException != Success)
|
|
|
|
return(client->noClientException);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = clientErrorValue;
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcSetDashes(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-12-15 01:15:21 +01:00
|
|
|
GC *pGC;
|
2003-11-14 16:54:54 +01:00
|
|
|
int result;
|
|
|
|
REQUEST(xSetDashesReq);
|
|
|
|
|
|
|
|
REQUEST_FIXED_SIZE(xSetDashesReq, stuff->nDashes);
|
|
|
|
if (stuff->nDashes == 0)
|
|
|
|
{
|
|
|
|
client->errorValue = 0;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
2007-08-14 19:09:38 +02:00
|
|
|
result = dixLookupGC(&pGC,stuff->gc, client, DixSetAttrAccess);
|
2006-12-15 01:15:21 +01:00
|
|
|
if (result != Success)
|
|
|
|
return result;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
result = SetDashes(pGC, stuff->dashOffset, stuff->nDashes,
|
|
|
|
(unsigned char *)&stuff[1]);
|
|
|
|
if (client->noClientException != Success)
|
|
|
|
return(client->noClientException);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = clientErrorValue;
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcSetClipRectangles(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-12-15 01:15:21 +01:00
|
|
|
int nr, result;
|
|
|
|
GC *pGC;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xSetClipRectanglesReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq);
|
|
|
|
if ((stuff->ordering != Unsorted) && (stuff->ordering != YSorted) &&
|
|
|
|
(stuff->ordering != YXSorted) && (stuff->ordering != YXBanded))
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->ordering;
|
|
|
|
return BadValue;
|
|
|
|
}
|
2007-08-14 19:09:38 +02:00
|
|
|
result = dixLookupGC(&pGC,stuff->gc, client, DixSetAttrAccess);
|
2006-12-15 01:15:21 +01:00
|
|
|
if (result != Success)
|
|
|
|
return result;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
nr = (client->req_len << 2) - sizeof(xSetClipRectanglesReq);
|
|
|
|
if (nr & 4)
|
|
|
|
return(BadLength);
|
|
|
|
nr >>= 3;
|
|
|
|
result = SetClipRects(pGC, stuff->xOrigin, stuff->yOrigin,
|
|
|
|
nr, (xRectangle *)&stuff[1], (int)stuff->ordering);
|
|
|
|
if (client->noClientException != Success)
|
|
|
|
return(client->noClientException);
|
|
|
|
else
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcFreeGC(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-12-15 01:15:21 +01:00
|
|
|
GC *pGC;
|
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xResourceReq);
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2006-12-15 01:15:21 +01:00
|
|
|
|
|
|
|
rc = dixLookupGC(&pGC, stuff->id, client, DixDestroyAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
FreeResource(stuff->id, RT_NONE);
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcClearToBackground(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
REQUEST(xClearAreaReq);
|
2006-12-15 21:50:46 +01:00
|
|
|
WindowPtr pWin;
|
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xClearAreaReq);
|
2006-12-15 21:50:46 +01:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
if (pWin->drawable.class == InputOnly)
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->window;
|
|
|
|
return (BadMatch);
|
|
|
|
}
|
|
|
|
if ((stuff->exposures != xTrue) && (stuff->exposures != xFalse))
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->exposures;
|
|
|
|
return(BadValue);
|
|
|
|
}
|
|
|
|
(*pWin->drawable.pScreen->ClearToBackground)(pWin, stuff->x, stuff->y,
|
|
|
|
stuff->width, stuff->height,
|
|
|
|
(Bool)stuff->exposures);
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcCopyArea(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-12-15 01:15:21 +01:00
|
|
|
DrawablePtr pDst;
|
2006-12-14 23:53:43 +01:00
|
|
|
DrawablePtr pSrc;
|
2006-12-15 01:15:21 +01:00
|
|
|
GC *pGC;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xCopyAreaReq);
|
|
|
|
RegionPtr pRgn;
|
2006-12-14 23:53:43 +01:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xCopyAreaReq);
|
|
|
|
|
2007-09-25 15:33:51 +02:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, DixWriteAccess);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (stuff->dstDrawable != stuff->srcDrawable)
|
|
|
|
{
|
2006-12-14 23:53:43 +01:00
|
|
|
rc = dixLookupDrawable(&pSrc, stuff->srcDrawable, client, 0,
|
2006-12-14 20:45:42 +01:00
|
|
|
DixReadAccess);
|
2006-12-14 23:53:43 +01:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
if ((pDst->pScreen != pSrc->pScreen) || (pDst->depth != pSrc->depth))
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->dstDrawable;
|
|
|
|
return (BadMatch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pSrc = pDst;
|
|
|
|
|
|
|
|
pRgn = (*pGC->ops->CopyArea)(pSrc, pDst, pGC, stuff->srcX, stuff->srcY,
|
|
|
|
stuff->width, stuff->height,
|
|
|
|
stuff->dstX, stuff->dstY);
|
|
|
|
if (pGC->graphicsExposures)
|
|
|
|
{
|
|
|
|
(*pDst->pScreen->SendGraphicsExpose)
|
|
|
|
(client, pRgn, stuff->dstDrawable, X_CopyArea, 0);
|
|
|
|
if (pRgn)
|
|
|
|
REGION_DESTROY(pDst->pScreen, pRgn);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcCopyPlane(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-12-14 23:53:43 +01:00
|
|
|
DrawablePtr psrcDraw, pdstDraw;
|
2006-12-15 01:15:21 +01:00
|
|
|
GC *pGC;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xCopyPlaneReq);
|
|
|
|
RegionPtr pRgn;
|
2006-12-14 23:53:43 +01:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xCopyPlaneReq);
|
|
|
|
|
2007-09-25 15:33:51 +02:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, DixWriteAccess);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (stuff->dstDrawable != stuff->srcDrawable)
|
|
|
|
{
|
2006-12-14 23:53:43 +01:00
|
|
|
rc = dixLookupDrawable(&psrcDraw, stuff->srcDrawable, client, 0,
|
|
|
|
DixReadAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
if (pdstDraw->pScreen != psrcDraw->pScreen)
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->dstDrawable;
|
|
|
|
return (BadMatch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
psrcDraw = pdstDraw;
|
|
|
|
|
|
|
|
/* Check to see if stuff->bitPlane has exactly ONE good bit set */
|
|
|
|
if(stuff->bitPlane == 0 || (stuff->bitPlane & (stuff->bitPlane - 1)) ||
|
|
|
|
(stuff->bitPlane > (1L << (psrcDraw->depth - 1))))
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->bitPlane;
|
|
|
|
return(BadValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
pRgn = (*pGC->ops->CopyPlane)(psrcDraw, pdstDraw, pGC, stuff->srcX, stuff->srcY,
|
|
|
|
stuff->width, stuff->height,
|
|
|
|
stuff->dstX, stuff->dstY, stuff->bitPlane);
|
|
|
|
if (pGC->graphicsExposures)
|
|
|
|
{
|
|
|
|
(*pdstDraw->pScreen->SendGraphicsExpose)
|
|
|
|
(client, pRgn, stuff->dstDrawable, X_CopyPlane, 0);
|
|
|
|
if (pRgn)
|
|
|
|
REGION_DESTROY(pdstDraw->pScreen, pRgn);
|
|
|
|
}
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcPolyPoint(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int npoint;
|
2006-12-15 01:15:21 +01:00
|
|
|
GC *pGC;
|
|
|
|
DrawablePtr pDraw;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xPolyPointReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xPolyPointReq);
|
|
|
|
if ((stuff->coordMode != CoordModeOrigin) &&
|
|
|
|
(stuff->coordMode != CoordModePrevious))
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->coordMode;
|
|
|
|
return BadValue;
|
|
|
|
}
|
2007-09-25 15:33:51 +02:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2003-11-14 16:54:54 +01:00
|
|
|
npoint = ((client->req_len << 2) - sizeof(xPolyPointReq)) >> 2;
|
|
|
|
if (npoint)
|
|
|
|
(*pGC->ops->PolyPoint)(pDraw, pGC, stuff->coordMode, npoint,
|
|
|
|
(xPoint *) &stuff[1]);
|
|
|
|
return (client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcPolyLine(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int npoint;
|
2006-12-15 01:15:21 +01:00
|
|
|
GC *pGC;
|
|
|
|
DrawablePtr pDraw;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xPolyLineReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xPolyLineReq);
|
|
|
|
if ((stuff->coordMode != CoordModeOrigin) &&
|
|
|
|
(stuff->coordMode != CoordModePrevious))
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->coordMode;
|
|
|
|
return BadValue;
|
|
|
|
}
|
2007-09-25 15:33:51 +02:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2003-11-14 16:54:54 +01:00
|
|
|
npoint = ((client->req_len << 2) - sizeof(xPolyLineReq)) >> 2;
|
|
|
|
if (npoint > 1)
|
|
|
|
(*pGC->ops->Polylines)(pDraw, pGC, stuff->coordMode, npoint,
|
|
|
|
(DDXPointPtr) &stuff[1]);
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcPolySegment(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int nsegs;
|
2006-12-15 01:15:21 +01:00
|
|
|
GC *pGC;
|
|
|
|
DrawablePtr pDraw;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xPolySegmentReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xPolySegmentReq);
|
2007-09-25 15:33:51 +02:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2003-11-14 16:54:54 +01:00
|
|
|
nsegs = (client->req_len << 2) - sizeof(xPolySegmentReq);
|
|
|
|
if (nsegs & 4)
|
|
|
|
return(BadLength);
|
|
|
|
nsegs >>= 3;
|
|
|
|
if (nsegs)
|
|
|
|
(*pGC->ops->PolySegment)(pDraw, pGC, nsegs, (xSegment *) &stuff[1]);
|
|
|
|
return (client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcPolyRectangle (ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int nrects;
|
2006-12-15 01:15:21 +01:00
|
|
|
GC *pGC;
|
|
|
|
DrawablePtr pDraw;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xPolyRectangleReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xPolyRectangleReq);
|
2007-09-25 15:33:51 +02:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2003-11-14 16:54:54 +01:00
|
|
|
nrects = (client->req_len << 2) - sizeof(xPolyRectangleReq);
|
|
|
|
if (nrects & 4)
|
|
|
|
return(BadLength);
|
|
|
|
nrects >>= 3;
|
|
|
|
if (nrects)
|
|
|
|
(*pGC->ops->PolyRectangle)(pDraw, pGC,
|
|
|
|
nrects, (xRectangle *) &stuff[1]);
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcPolyArc(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int narcs;
|
2006-12-15 01:15:21 +01:00
|
|
|
GC *pGC;
|
|
|
|
DrawablePtr pDraw;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xPolyArcReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xPolyArcReq);
|
2007-09-25 15:33:51 +02:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2003-11-14 16:54:54 +01:00
|
|
|
narcs = (client->req_len << 2) - sizeof(xPolyArcReq);
|
|
|
|
if (narcs % sizeof(xArc))
|
|
|
|
return(BadLength);
|
|
|
|
narcs /= sizeof(xArc);
|
|
|
|
if (narcs)
|
|
|
|
(*pGC->ops->PolyArc)(pDraw, pGC, narcs, (xArc *) &stuff[1]);
|
|
|
|
return (client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcFillPoly(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int things;
|
2006-12-15 01:15:21 +01:00
|
|
|
GC *pGC;
|
|
|
|
DrawablePtr pDraw;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xFillPolyReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xFillPolyReq);
|
|
|
|
if ((stuff->shape != Complex) && (stuff->shape != Nonconvex) &&
|
|
|
|
(stuff->shape != Convex))
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->shape;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
if ((stuff->coordMode != CoordModeOrigin) &&
|
|
|
|
(stuff->coordMode != CoordModePrevious))
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->coordMode;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
2007-09-25 15:33:51 +02:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2003-11-14 16:54:54 +01:00
|
|
|
things = ((client->req_len << 2) - sizeof(xFillPolyReq)) >> 2;
|
|
|
|
if (things)
|
|
|
|
(*pGC->ops->FillPolygon) (pDraw, pGC, stuff->shape,
|
|
|
|
stuff->coordMode, things,
|
|
|
|
(DDXPointPtr) &stuff[1]);
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcPolyFillRectangle(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int things;
|
2006-12-15 01:15:21 +01:00
|
|
|
GC *pGC;
|
|
|
|
DrawablePtr pDraw;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xPolyFillRectangleReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq);
|
2007-09-25 15:33:51 +02:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2003-11-14 16:54:54 +01:00
|
|
|
things = (client->req_len << 2) - sizeof(xPolyFillRectangleReq);
|
|
|
|
if (things & 4)
|
|
|
|
return(BadLength);
|
|
|
|
things >>= 3;
|
2003-11-14 17:49:22 +01:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
if (things)
|
|
|
|
(*pGC->ops->PolyFillRect) (pDraw, pGC, things,
|
|
|
|
(xRectangle *) &stuff[1]);
|
|
|
|
return (client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcPolyFillArc(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int narcs;
|
2006-12-15 01:15:21 +01:00
|
|
|
GC *pGC;
|
|
|
|
DrawablePtr pDraw;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xPolyFillArcReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xPolyFillArcReq);
|
2007-09-25 15:33:51 +02:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2003-11-14 16:54:54 +01:00
|
|
|
narcs = (client->req_len << 2) - sizeof(xPolyFillArcReq);
|
|
|
|
if (narcs % sizeof(xArc))
|
|
|
|
return(BadLength);
|
|
|
|
narcs /= sizeof(xArc);
|
|
|
|
if (narcs)
|
|
|
|
(*pGC->ops->PolyFillArc) (pDraw, pGC, narcs, (xArc *) &stuff[1]);
|
|
|
|
return (client->noClientException);
|
|
|
|
}
|
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
#ifdef MATCH_CLIENT_ENDIAN
|
|
|
|
|
|
|
|
int
|
|
|
|
ServerOrder (void)
|
|
|
|
{
|
|
|
|
int whichbyte = 1;
|
|
|
|
|
|
|
|
if (*((char *) &whichbyte))
|
|
|
|
return LSBFirst;
|
|
|
|
return MSBFirst;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ClientOrder(client) ((client)->swapped ? !ServerOrder() : ServerOrder())
|
|
|
|
|
|
|
|
void
|
|
|
|
ReformatImage (char *base, int nbytes, int bpp, int order)
|
|
|
|
{
|
|
|
|
switch (bpp) {
|
|
|
|
case 1: /* yuck */
|
|
|
|
if (BITMAP_BIT_ORDER != order)
|
|
|
|
BitOrderInvert ((unsigned char *) base, nbytes);
|
|
|
|
#if IMAGE_BYTE_ORDER != BITMAP_BIT_ORDER && BITMAP_SCANLINE_UNIT != 8
|
|
|
|
ReformatImage (base, nbytes, BITMAP_SCANLINE_UNIT, order);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
break; /* yuck */
|
|
|
|
case 8:
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
if (IMAGE_BYTE_ORDER != order)
|
|
|
|
TwoByteSwap ((unsigned char *) base, nbytes);
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
if (IMAGE_BYTE_ORDER != order)
|
|
|
|
FourByteSwap ((unsigned char *) base, nbytes);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define ReformatImage(b,n,bpp,o)
|
|
|
|
#endif
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
/* 64-bit server notes: the protocol restricts padding of images to
|
|
|
|
* 8-, 16-, or 32-bits. We would like to have 64-bits for the server
|
|
|
|
* to use internally. Removes need for internal alignment checking.
|
|
|
|
* All of the PutImage functions could be changed individually, but
|
|
|
|
* as currently written, they call other routines which require things
|
|
|
|
* to be 64-bit padded on scanlines, so we changed things here.
|
|
|
|
* If an image would be padded differently for 64- versus 32-, then
|
|
|
|
* copy each scanline to a 64-bit padded scanline.
|
|
|
|
* Also, we need to make sure that the image is aligned on a 64-bit
|
|
|
|
* boundary, even if the scanlines are padded to our satisfaction.
|
|
|
|
*/
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcPutImage(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-12-15 01:15:21 +01:00
|
|
|
GC *pGC;
|
|
|
|
DrawablePtr pDraw;
|
2003-11-14 16:54:54 +01:00
|
|
|
long length; /* length of scanline server padded */
|
|
|
|
long lengthProto; /* length of scanline protocol padded */
|
|
|
|
char *tmpImage;
|
|
|
|
REQUEST(xPutImageReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xPutImageReq);
|
2007-09-25 15:33:51 +02:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (stuff->format == XYBitmap)
|
|
|
|
{
|
|
|
|
if ((stuff->depth != 1) ||
|
|
|
|
(stuff->leftPad >= (unsigned int)screenInfo.bitmapScanlinePad))
|
|
|
|
return BadMatch;
|
|
|
|
length = BitmapBytePad(stuff->width + stuff->leftPad);
|
|
|
|
}
|
|
|
|
else if (stuff->format == XYPixmap)
|
|
|
|
{
|
|
|
|
if ((pDraw->depth != stuff->depth) ||
|
|
|
|
(stuff->leftPad >= (unsigned int)screenInfo.bitmapScanlinePad))
|
|
|
|
return BadMatch;
|
|
|
|
length = BitmapBytePad(stuff->width + stuff->leftPad);
|
|
|
|
length *= stuff->depth;
|
|
|
|
}
|
|
|
|
else if (stuff->format == ZPixmap)
|
|
|
|
{
|
|
|
|
if ((pDraw->depth != stuff->depth) || (stuff->leftPad != 0))
|
|
|
|
return BadMatch;
|
|
|
|
length = PixmapBytePad(stuff->width, stuff->depth);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->format;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmpImage = (char *)&stuff[1];
|
|
|
|
lengthProto = length;
|
|
|
|
|
|
|
|
if (((((lengthProto * stuff->height) + (unsigned)3) >> 2) +
|
|
|
|
(sizeof(xPutImageReq) >> 2)) != client->req_len)
|
|
|
|
return BadLength;
|
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
ReformatImage (tmpImage, lengthProto * stuff->height,
|
|
|
|
stuff->format == ZPixmap ? BitsPerPixel (stuff->depth) : 1,
|
|
|
|
ClientOrder(client));
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
(*pGC->ops->PutImage) (pDraw, pGC, stuff->depth, stuff->dstX, stuff->dstY,
|
|
|
|
stuff->width, stuff->height,
|
|
|
|
stuff->leftPad, stuff->format, tmpImage);
|
|
|
|
|
|
|
|
return (client->noClientException);
|
|
|
|
}
|
|
|
|
|
2007-03-25 23:57:54 +02:00
|
|
|
static int
|
2007-03-08 08:20:19 +01:00
|
|
|
DoGetImage(ClientPtr client, int format, Drawable drawable,
|
2005-03-08 00:02:59 +01:00
|
|
|
int x, int y, int width, int height,
|
|
|
|
Mask planemask, xGetImageReply **im_return)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-12-14 23:53:43 +01:00
|
|
|
DrawablePtr pDraw;
|
|
|
|
int nlines, linesPerBuf, rc;
|
2007-03-08 08:20:19 +01:00
|
|
|
int linesDone;
|
2003-11-14 16:54:54 +01:00
|
|
|
long widthBytesLine, length;
|
2003-11-14 17:49:22 +01:00
|
|
|
Mask plane = 0;
|
2003-11-14 16:54:54 +01:00
|
|
|
char *pBuf;
|
|
|
|
xGetImageReply xgi;
|
|
|
|
RegionPtr pVisibleRegion = NULL;
|
|
|
|
|
|
|
|
if ((format != XYPixmap) && (format != ZPixmap))
|
|
|
|
{
|
|
|
|
client->errorValue = format;
|
|
|
|
return(BadValue);
|
|
|
|
}
|
2006-12-14 23:53:43 +01:00
|
|
|
rc = dixLookupDrawable(&pDraw, drawable, client, 0, DixReadAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
2009-02-13 10:23:28 +01:00
|
|
|
memset(&xgi, 0, sizeof(xGetImageReply));
|
2003-11-14 16:54:54 +01:00
|
|
|
if(pDraw->type == DRAWABLE_WINDOW)
|
|
|
|
{
|
|
|
|
if( /* check for being viewable */
|
|
|
|
!((WindowPtr) pDraw)->realized ||
|
|
|
|
/* check for being on screen */
|
|
|
|
pDraw->x + x < 0 ||
|
|
|
|
pDraw->x + x + width > pDraw->pScreen->width ||
|
|
|
|
pDraw->y + y < 0 ||
|
|
|
|
pDraw->y + y + height > pDraw->pScreen->height ||
|
|
|
|
/* check for being inside of border */
|
|
|
|
x < - wBorderWidth((WindowPtr)pDraw) ||
|
|
|
|
x + width > wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width ||
|
|
|
|
y < -wBorderWidth((WindowPtr)pDraw) ||
|
|
|
|
y + height > wBorderWidth ((WindowPtr)pDraw) + (int)pDraw->height
|
|
|
|
)
|
|
|
|
return(BadMatch);
|
|
|
|
xgi.visual = wVisual (((WindowPtr) pDraw));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(x < 0 ||
|
|
|
|
x+width > (int)pDraw->width ||
|
|
|
|
y < 0 ||
|
|
|
|
y+height > (int)pDraw->height
|
|
|
|
)
|
|
|
|
return(BadMatch);
|
|
|
|
xgi.visual = None;
|
|
|
|
}
|
|
|
|
|
|
|
|
xgi.type = X_Reply;
|
|
|
|
xgi.sequenceNumber = client->sequence;
|
|
|
|
xgi.depth = pDraw->depth;
|
|
|
|
if(format == ZPixmap)
|
|
|
|
{
|
|
|
|
widthBytesLine = PixmapBytePad(width, pDraw->depth);
|
|
|
|
length = widthBytesLine * height;
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
widthBytesLine = BitmapBytePad(width);
|
|
|
|
plane = ((Mask)1) << (pDraw->depth - 1);
|
|
|
|
/* only planes asked for */
|
|
|
|
length = widthBytesLine * height *
|
|
|
|
Ones(planemask & (plane | (plane - 1)));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
xgi.length = length;
|
|
|
|
|
|
|
|
if (im_return) {
|
2009-02-13 10:23:28 +01:00
|
|
|
pBuf = xcalloc(1, sz_xGetImageReply + length);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!pBuf)
|
|
|
|
return (BadAlloc);
|
|
|
|
if (widthBytesLine == 0)
|
|
|
|
linesPerBuf = 0;
|
|
|
|
else
|
|
|
|
linesPerBuf = height;
|
|
|
|
*im_return = (xGetImageReply *)pBuf;
|
|
|
|
*(xGetImageReply *)pBuf = xgi;
|
|
|
|
pBuf += sz_xGetImageReply;
|
|
|
|
} else {
|
|
|
|
xgi.length = (xgi.length + 3) >> 2;
|
|
|
|
if (widthBytesLine == 0 || height == 0)
|
|
|
|
linesPerBuf = 0;
|
|
|
|
else if (widthBytesLine >= IMAGE_BUFSIZE)
|
|
|
|
linesPerBuf = 1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
linesPerBuf = IMAGE_BUFSIZE / widthBytesLine;
|
|
|
|
if (linesPerBuf > height)
|
|
|
|
linesPerBuf = height;
|
|
|
|
}
|
|
|
|
length = linesPerBuf * widthBytesLine;
|
|
|
|
if (linesPerBuf < height)
|
|
|
|
{
|
|
|
|
/* we have to make sure intermediate buffers don't need padding */
|
|
|
|
while ((linesPerBuf > 1) &&
|
2003-11-14 17:49:22 +01:00
|
|
|
(length & ((1L << LOG2_BYTES_PER_SCANLINE_PAD)-1)))
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
linesPerBuf--;
|
|
|
|
length -= widthBytesLine;
|
|
|
|
}
|
2003-11-14 17:49:22 +01:00
|
|
|
while (length & ((1L << LOG2_BYTES_PER_SCANLINE_PAD)-1))
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
linesPerBuf++;
|
|
|
|
length += widthBytesLine;
|
|
|
|
}
|
|
|
|
}
|
2009-02-13 10:23:28 +01:00
|
|
|
if(!(pBuf = xcalloc(1, length)))
|
2003-11-14 16:54:54 +01:00
|
|
|
return (BadAlloc);
|
|
|
|
WriteReplyToClient(client, sizeof (xGetImageReply), &xgi);
|
|
|
|
}
|
|
|
|
|
2007-09-28 21:04:33 +02:00
|
|
|
if (pDraw->type == DRAWABLE_WINDOW)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
pVisibleRegion = NotClippedByChildren((WindowPtr)pDraw);
|
|
|
|
if (pVisibleRegion)
|
|
|
|
{
|
2006-12-02 02:48:15 +01:00
|
|
|
REGION_TRANSLATE(pDraw->pScreen, pVisibleRegion,
|
|
|
|
-pDraw->x, -pDraw->y);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (linesPerBuf == 0)
|
|
|
|
{
|
|
|
|
/* nothing to do */
|
|
|
|
}
|
|
|
|
else if (format == ZPixmap)
|
|
|
|
{
|
|
|
|
linesDone = 0;
|
|
|
|
while (height - linesDone > 0)
|
|
|
|
{
|
|
|
|
nlines = min(linesPerBuf, height - linesDone);
|
|
|
|
(*pDraw->pScreen->GetImage) (pDraw,
|
|
|
|
x,
|
|
|
|
y + linesDone,
|
|
|
|
width,
|
|
|
|
nlines,
|
|
|
|
format,
|
|
|
|
planemask,
|
|
|
|
(pointer) pBuf);
|
|
|
|
if (pVisibleRegion)
|
2004-05-05 22:04:52 +02:00
|
|
|
XaceCensorImage(client, pVisibleRegion, widthBytesLine,
|
2003-11-14 16:54:54 +01:00
|
|
|
pDraw, x, y + linesDone, width,
|
|
|
|
nlines, format, pBuf);
|
|
|
|
|
|
|
|
/* Note that this is NOT a call to WriteSwappedDataToClient,
|
|
|
|
as we do NOT byte swap */
|
|
|
|
if (!im_return)
|
2003-11-14 17:49:22 +01:00
|
|
|
{
|
|
|
|
ReformatImage (pBuf, (int)(nlines * widthBytesLine),
|
|
|
|
BitsPerPixel (pDraw->depth),
|
|
|
|
ClientOrder(client));
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
/* Don't split me, gcc pukes when you do */
|
|
|
|
(void)WriteToClient(client,
|
|
|
|
(int)(nlines * widthBytesLine),
|
|
|
|
pBuf);
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
linesDone += nlines;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* XYPixmap */
|
|
|
|
{
|
|
|
|
for (; plane; plane >>= 1)
|
|
|
|
{
|
|
|
|
if (planemask & plane)
|
|
|
|
{
|
|
|
|
linesDone = 0;
|
|
|
|
while (height - linesDone > 0)
|
|
|
|
{
|
|
|
|
nlines = min(linesPerBuf, height - linesDone);
|
|
|
|
(*pDraw->pScreen->GetImage) (pDraw,
|
|
|
|
x,
|
|
|
|
y + linesDone,
|
|
|
|
width,
|
|
|
|
nlines,
|
|
|
|
format,
|
|
|
|
plane,
|
|
|
|
(pointer)pBuf);
|
|
|
|
if (pVisibleRegion)
|
2004-05-05 22:04:52 +02:00
|
|
|
XaceCensorImage(client, pVisibleRegion,
|
2003-11-14 16:54:54 +01:00
|
|
|
widthBytesLine,
|
|
|
|
pDraw, x, y + linesDone, width,
|
|
|
|
nlines, format, pBuf);
|
|
|
|
|
|
|
|
/* Note: NOT a call to WriteSwappedDataToClient,
|
|
|
|
as we do NOT byte swap */
|
|
|
|
if (im_return) {
|
|
|
|
pBuf += nlines * widthBytesLine;
|
2003-11-14 17:49:22 +01:00
|
|
|
} else {
|
|
|
|
ReformatImage (pBuf,
|
|
|
|
(int)(nlines * widthBytesLine),
|
|
|
|
1,
|
|
|
|
ClientOrder (client));
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
/* Don't split me, gcc pukes when you do */
|
|
|
|
(void)WriteToClient(client,
|
|
|
|
(int)(nlines * widthBytesLine),
|
|
|
|
pBuf);
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
linesDone += nlines;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pVisibleRegion)
|
2003-11-25 20:29:01 +01:00
|
|
|
REGION_DESTROY(pDraw->pScreen, pVisibleRegion);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!im_return)
|
2007-11-05 14:53:34 +01:00
|
|
|
xfree(pBuf);
|
2003-11-14 16:54:54 +01:00
|
|
|
return (client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcGetImage(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
REQUEST(xGetImageReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xGetImageReq);
|
|
|
|
|
|
|
|
return DoGetImage(client, stuff->format, stuff->drawable,
|
|
|
|
stuff->x, stuff->y,
|
|
|
|
(int)stuff->width, (int)stuff->height,
|
|
|
|
stuff->planeMask, (xGetImageReply **)NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcPolyText(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
REQUEST(xPolyTextReq);
|
|
|
|
DrawablePtr pDraw;
|
|
|
|
GC *pGC;
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xPolyTextReq);
|
2007-09-25 15:33:51 +02:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
err = PolyText(client,
|
|
|
|
pDraw,
|
|
|
|
pGC,
|
|
|
|
(unsigned char *)&stuff[1],
|
|
|
|
((unsigned char *) stuff) + (client->req_len << 2),
|
|
|
|
stuff->x,
|
|
|
|
stuff->y,
|
|
|
|
stuff->reqType,
|
|
|
|
stuff->drawable);
|
|
|
|
|
|
|
|
if (err == Success)
|
|
|
|
{
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcImageText8(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int err;
|
2006-12-15 01:15:21 +01:00
|
|
|
DrawablePtr pDraw;
|
|
|
|
GC *pGC;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST(xImageTextReq);
|
|
|
|
|
|
|
|
REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars);
|
2007-09-25 15:33:51 +02:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
err = ImageText(client,
|
|
|
|
pDraw,
|
|
|
|
pGC,
|
|
|
|
stuff->nChars,
|
|
|
|
(unsigned char *)&stuff[1],
|
|
|
|
stuff->x,
|
|
|
|
stuff->y,
|
|
|
|
stuff->reqType,
|
|
|
|
stuff->drawable);
|
|
|
|
|
|
|
|
if (err == Success)
|
|
|
|
{
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcImageText16(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int err;
|
2006-12-15 01:15:21 +01:00
|
|
|
DrawablePtr pDraw;
|
|
|
|
GC *pGC;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST(xImageTextReq);
|
|
|
|
|
|
|
|
REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars << 1);
|
2007-09-25 15:33:51 +02:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
err = ImageText(client,
|
|
|
|
pDraw,
|
|
|
|
pGC,
|
|
|
|
stuff->nChars,
|
|
|
|
(unsigned char *)&stuff[1],
|
|
|
|
stuff->x,
|
|
|
|
stuff->y,
|
|
|
|
stuff->reqType,
|
|
|
|
stuff->drawable);
|
|
|
|
|
|
|
|
if (err == Success)
|
|
|
|
{
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcCreateColormap(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
VisualPtr pVisual;
|
|
|
|
ColormapPtr pmap;
|
|
|
|
Colormap mid;
|
2006-12-15 21:50:46 +01:00
|
|
|
WindowPtr pWin;
|
2003-11-14 16:54:54 +01:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
REQUEST(xCreateColormapReq);
|
|
|
|
int i, result;
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xCreateColormapReq);
|
|
|
|
|
|
|
|
if ((stuff->alloc != AllocNone) && (stuff->alloc != AllocAll))
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->alloc;
|
|
|
|
return(BadValue);
|
|
|
|
}
|
|
|
|
mid = stuff->mid;
|
|
|
|
LEGAL_NEW_RESOURCE(mid, client);
|
2007-08-06 18:23:21 +02:00
|
|
|
result = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
|
2006-12-15 21:50:46 +01:00
|
|
|
if (result != Success)
|
|
|
|
return result;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
pScreen = pWin->drawable.pScreen;
|
|
|
|
for (i = 0, pVisual = pScreen->visuals;
|
|
|
|
i < pScreen->numVisuals;
|
|
|
|
i++, pVisual++)
|
|
|
|
{
|
|
|
|
if (pVisual->vid != stuff->visual)
|
|
|
|
continue;
|
|
|
|
result = CreateColormap(mid, pScreen, pVisual, &pmap,
|
|
|
|
(int)stuff->alloc, client->index);
|
|
|
|
if (client->noClientException != Success)
|
|
|
|
return(client->noClientException);
|
|
|
|
else
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
client->errorValue = stuff->visual;
|
2006-11-04 18:34:37 +01:00
|
|
|
return(BadMatch);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcFreeColormap(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
ColormapPtr pmap;
|
2007-08-06 18:23:21 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xResourceReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2008-08-07 00:26:24 +02:00
|
|
|
rc = dixLookupResourceByType((pointer *)&pmap, stuff->id, RT_COLORMAP, client,
|
2007-08-06 18:23:21 +02:00
|
|
|
DixDestroyAccess);
|
|
|
|
if (rc == Success)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
/* Freeing a default colormap is a no-op */
|
|
|
|
if (!(pmap->flags & IsDefault))
|
|
|
|
FreeResource(stuff->id, RT_NONE);
|
|
|
|
return (client->noClientException);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->id;
|
2008-02-08 02:14:16 +01:00
|
|
|
return (rc == BadValue) ? BadColor : rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcCopyColormapAndFree(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
Colormap mid;
|
|
|
|
ColormapPtr pSrcMap;
|
|
|
|
REQUEST(xCopyColormapAndFreeReq);
|
2007-08-06 18:23:21 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq);
|
|
|
|
mid = stuff->mid;
|
|
|
|
LEGAL_NEW_RESOURCE(mid, client);
|
2008-08-07 00:26:24 +02:00
|
|
|
rc = dixLookupResourceByType((pointer *)&pSrcMap, stuff->srcCmap, RT_COLORMAP,
|
2007-08-06 18:23:21 +02:00
|
|
|
client, DixReadAccess|DixRemoveAccess);
|
|
|
|
if (rc == Success)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-08-06 18:23:21 +02:00
|
|
|
rc = CopyColormapAndFree(mid, pSrcMap, client->index);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (client->noClientException != Success)
|
|
|
|
return(client->noClientException);
|
|
|
|
else
|
2007-08-06 18:23:21 +02:00
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->srcCmap;
|
2008-02-08 02:14:16 +01:00
|
|
|
return (rc == BadValue) ? BadColor : rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcInstallColormap(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
ColormapPtr pcmp;
|
2007-08-06 18:23:21 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xResourceReq);
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2007-08-06 18:23:21 +02:00
|
|
|
|
2008-08-07 00:26:24 +02:00
|
|
|
rc = dixLookupResourceByType((pointer *)&pcmp, stuff->id, RT_COLORMAP, client,
|
2007-08-06 18:23:21 +02:00
|
|
|
DixInstallAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
rc = XaceHook(XACE_SCREEN_ACCESS, client, pcmp->pScreen, DixSetAttrAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
(*(pcmp->pScreen->InstallColormap)) (pcmp);
|
|
|
|
|
|
|
|
rc = client->noClientException;
|
|
|
|
out:
|
|
|
|
client->errorValue = stuff->id;
|
|
|
|
return (rc == BadValue) ? BadColor : rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcUninstallColormap(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
ColormapPtr pcmp;
|
2007-08-06 18:23:21 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xResourceReq);
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2007-08-06 18:23:21 +02:00
|
|
|
|
2008-08-07 00:26:24 +02:00
|
|
|
rc = dixLookupResourceByType((pointer *)&pcmp, stuff->id, RT_COLORMAP, client,
|
2007-08-06 18:23:21 +02:00
|
|
|
DixUninstallAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
rc = XaceHook(XACE_SCREEN_ACCESS, client, pcmp->pScreen, DixSetAttrAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if(pcmp->mid != pcmp->pScreen->defColormap)
|
|
|
|
(*(pcmp->pScreen->UninstallColormap)) (pcmp);
|
|
|
|
|
|
|
|
rc = client->noClientException;
|
|
|
|
out:
|
|
|
|
client->errorValue = stuff->id;
|
|
|
|
return (rc == BadValue) ? BadColor : rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcListInstalledColormaps(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
xListInstalledColormapsReply *preply;
|
2006-12-15 21:50:46 +01:00
|
|
|
int nummaps, rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
WindowPtr pWin;
|
|
|
|
REQUEST(xResourceReq);
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2007-08-06 18:23:21 +02:00
|
|
|
|
|
|
|
rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess);
|
2006-12-15 21:50:46 +01:00
|
|
|
if (rc != Success)
|
2007-08-06 18:23:21 +02:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
rc = XaceHook(XACE_SCREEN_ACCESS, client, pWin->drawable.pScreen,
|
|
|
|
DixGetAttrAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
goto out;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2009-01-22 08:11:16 +01:00
|
|
|
preply = xalloc(sizeof(xListInstalledColormapsReply) +
|
2003-11-14 16:54:54 +01:00
|
|
|
pWin->drawable.pScreen->maxInstalledCmaps *
|
|
|
|
sizeof(Colormap));
|
|
|
|
if(!preply)
|
|
|
|
return(BadAlloc);
|
|
|
|
|
|
|
|
preply->type = X_Reply;
|
|
|
|
preply->sequenceNumber = client->sequence;
|
|
|
|
nummaps = (*pWin->drawable.pScreen->ListInstalledColormaps)
|
|
|
|
(pWin->drawable.pScreen, (Colormap *)&preply[1]);
|
|
|
|
preply->nColormaps = nummaps;
|
|
|
|
preply->length = nummaps;
|
|
|
|
WriteReplyToClient(client, sizeof (xListInstalledColormapsReply), preply);
|
2003-11-14 17:49:22 +01:00
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
|
2003-11-14 16:54:54 +01:00
|
|
|
WriteSwappedDataToClient(client, nummaps * sizeof(Colormap), &preply[1]);
|
2007-11-05 14:53:34 +01:00
|
|
|
xfree(preply);
|
2007-08-06 18:23:21 +02:00
|
|
|
rc = client->noClientException;
|
|
|
|
out:
|
2008-02-08 02:14:16 +01:00
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcAllocColor (ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
ColormapPtr pmap;
|
2007-08-06 18:23:21 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
xAllocColorReply acr;
|
|
|
|
REQUEST(xAllocColorReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xAllocColorReq);
|
2008-08-07 00:26:24 +02:00
|
|
|
rc = dixLookupResourceByType((pointer *)&pmap, stuff->cmap, RT_COLORMAP, client,
|
2007-08-06 18:23:21 +02:00
|
|
|
DixAddAccess);
|
|
|
|
if (rc == Success)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
acr.type = X_Reply;
|
|
|
|
acr.length = 0;
|
|
|
|
acr.sequenceNumber = client->sequence;
|
|
|
|
acr.red = stuff->red;
|
|
|
|
acr.green = stuff->green;
|
|
|
|
acr.blue = stuff->blue;
|
|
|
|
acr.pixel = 0;
|
2007-08-06 18:23:21 +02:00
|
|
|
if( (rc = AllocColor(pmap, &acr.red, &acr.green, &acr.blue,
|
2003-11-14 16:54:54 +01:00
|
|
|
&acr.pixel, client->index)) )
|
|
|
|
{
|
|
|
|
if (client->noClientException != Success)
|
|
|
|
return(client->noClientException);
|
|
|
|
else
|
2007-08-06 18:23:21 +02:00
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2003-11-14 17:49:22 +01:00
|
|
|
#ifdef PANORAMIX
|
|
|
|
if (noPanoramiXExtension || !pmap->pScreen->myNum)
|
|
|
|
#endif
|
2003-11-14 16:54:54 +01:00
|
|
|
WriteReplyToClient(client, sizeof(xAllocColorReply), &acr);
|
|
|
|
return (client->noClientException);
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->cmap;
|
2007-08-06 18:23:21 +02:00
|
|
|
return (rc == BadValue) ? BadColor : rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcAllocNamedColor (ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
ColormapPtr pcmp;
|
2007-08-06 18:23:21 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xAllocNamedColorReq);
|
|
|
|
|
|
|
|
REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes);
|
2008-08-07 00:26:24 +02:00
|
|
|
rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
|
2007-08-06 18:23:21 +02:00
|
|
|
DixAddAccess);
|
|
|
|
if (rc == Success)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
xAllocNamedColorReply ancr;
|
|
|
|
|
|
|
|
ancr.type = X_Reply;
|
|
|
|
ancr.length = 0;
|
|
|
|
ancr.sequenceNumber = client->sequence;
|
|
|
|
|
|
|
|
if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1], stuff->nbytes,
|
|
|
|
&ancr.exactRed, &ancr.exactGreen, &ancr.exactBlue))
|
|
|
|
{
|
|
|
|
ancr.screenRed = ancr.exactRed;
|
|
|
|
ancr.screenGreen = ancr.exactGreen;
|
|
|
|
ancr.screenBlue = ancr.exactBlue;
|
|
|
|
ancr.pixel = 0;
|
2007-08-06 18:23:21 +02:00
|
|
|
if( (rc = AllocColor(pcmp,
|
2003-11-14 16:54:54 +01:00
|
|
|
&ancr.screenRed, &ancr.screenGreen, &ancr.screenBlue,
|
|
|
|
&ancr.pixel, client->index)) )
|
|
|
|
{
|
|
|
|
if (client->noClientException != Success)
|
|
|
|
return(client->noClientException);
|
|
|
|
else
|
2007-08-06 18:23:21 +02:00
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2003-11-14 17:49:22 +01:00
|
|
|
#ifdef PANORAMIX
|
|
|
|
if (noPanoramiXExtension || !pcmp->pScreen->myNum)
|
|
|
|
#endif
|
2003-11-14 16:54:54 +01:00
|
|
|
WriteReplyToClient(client, sizeof (xAllocNamedColorReply), &ancr);
|
|
|
|
return (client->noClientException);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return(BadName);
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->cmap;
|
2007-08-06 18:23:21 +02:00
|
|
|
return (rc == BadValue) ? BadColor : rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcAllocColorCells (ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
ColormapPtr pcmp;
|
2007-08-06 18:23:21 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xAllocColorCellsReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xAllocColorCellsReq);
|
2008-08-07 00:26:24 +02:00
|
|
|
rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
|
2007-08-06 18:23:21 +02:00
|
|
|
DixAddAccess);
|
|
|
|
if (rc == Success)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
xAllocColorCellsReply accr;
|
2007-08-06 18:23:21 +02:00
|
|
|
int npixels, nmasks;
|
2003-11-14 16:54:54 +01:00
|
|
|
long length;
|
|
|
|
Pixel *ppixels, *pmasks;
|
|
|
|
|
|
|
|
npixels = stuff->colors;
|
|
|
|
if (!npixels)
|
|
|
|
{
|
|
|
|
client->errorValue = npixels;
|
|
|
|
return (BadValue);
|
|
|
|
}
|
|
|
|
if (stuff->contiguous != xTrue && stuff->contiguous != xFalse)
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->contiguous;
|
|
|
|
return (BadValue);
|
|
|
|
}
|
|
|
|
nmasks = stuff->planes;
|
|
|
|
length = ((long)npixels + (long)nmasks) * sizeof(Pixel);
|
2009-01-22 08:11:16 +01:00
|
|
|
ppixels = xalloc(length);
|
2003-11-14 16:54:54 +01:00
|
|
|
if(!ppixels)
|
|
|
|
return(BadAlloc);
|
|
|
|
pmasks = ppixels + npixels;
|
|
|
|
|
2007-08-06 18:23:21 +02:00
|
|
|
if( (rc = AllocColorCells(client->index, pcmp, npixels, nmasks,
|
2003-11-14 16:54:54 +01:00
|
|
|
(Bool)stuff->contiguous, ppixels, pmasks)) )
|
|
|
|
{
|
2007-11-05 14:53:34 +01:00
|
|
|
xfree(ppixels);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (client->noClientException != Success)
|
|
|
|
return(client->noClientException);
|
|
|
|
else
|
2007-08-06 18:23:21 +02:00
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2003-11-14 17:49:22 +01:00
|
|
|
#ifdef PANORAMIX
|
|
|
|
if (noPanoramiXExtension || !pcmp->pScreen->myNum)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
accr.type = X_Reply;
|
|
|
|
accr.length = length >> 2;
|
|
|
|
accr.sequenceNumber = client->sequence;
|
|
|
|
accr.nPixels = npixels;
|
|
|
|
accr.nMasks = nmasks;
|
|
|
|
WriteReplyToClient(client, sizeof (xAllocColorCellsReply), &accr);
|
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
|
|
|
|
WriteSwappedDataToClient(client, length, ppixels);
|
|
|
|
}
|
2007-11-05 14:53:34 +01:00
|
|
|
xfree(ppixels);
|
2003-11-14 16:54:54 +01:00
|
|
|
return (client->noClientException);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->cmap;
|
2007-08-06 18:23:21 +02:00
|
|
|
return (rc == BadValue) ? BadColor : rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcAllocColorPlanes(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
ColormapPtr pcmp;
|
2007-08-06 18:23:21 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xAllocColorPlanesReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xAllocColorPlanesReq);
|
2008-08-07 00:26:24 +02:00
|
|
|
rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
|
2007-08-06 18:23:21 +02:00
|
|
|
DixAddAccess);
|
|
|
|
if (rc == Success)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
xAllocColorPlanesReply acpr;
|
2007-08-06 18:23:21 +02:00
|
|
|
int npixels;
|
2003-11-14 16:54:54 +01:00
|
|
|
long length;
|
|
|
|
Pixel *ppixels;
|
|
|
|
|
|
|
|
npixels = stuff->colors;
|
|
|
|
if (!npixels)
|
|
|
|
{
|
|
|
|
client->errorValue = npixels;
|
|
|
|
return (BadValue);
|
|
|
|
}
|
|
|
|
if (stuff->contiguous != xTrue && stuff->contiguous != xFalse)
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->contiguous;
|
|
|
|
return (BadValue);
|
|
|
|
}
|
|
|
|
acpr.type = X_Reply;
|
|
|
|
acpr.sequenceNumber = client->sequence;
|
|
|
|
acpr.nPixels = npixels;
|
|
|
|
length = (long)npixels * sizeof(Pixel);
|
2009-01-22 08:11:16 +01:00
|
|
|
ppixels = xalloc(length);
|
2003-11-14 16:54:54 +01:00
|
|
|
if(!ppixels)
|
|
|
|
return(BadAlloc);
|
2007-08-06 18:23:21 +02:00
|
|
|
if( (rc = AllocColorPlanes(client->index, pcmp, npixels,
|
2003-11-14 16:54:54 +01:00
|
|
|
(int)stuff->red, (int)stuff->green, (int)stuff->blue,
|
|
|
|
(Bool)stuff->contiguous, ppixels,
|
|
|
|
&acpr.redMask, &acpr.greenMask, &acpr.blueMask)) )
|
|
|
|
{
|
2007-11-05 14:53:34 +01:00
|
|
|
xfree(ppixels);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (client->noClientException != Success)
|
|
|
|
return(client->noClientException);
|
|
|
|
else
|
2007-08-06 18:23:21 +02:00
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
acpr.length = length >> 2;
|
2003-11-14 17:49:22 +01:00
|
|
|
#ifdef PANORAMIX
|
|
|
|
if (noPanoramiXExtension || !pcmp->pScreen->myNum)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
WriteReplyToClient(client, sizeof(xAllocColorPlanesReply), &acpr);
|
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
|
|
|
|
WriteSwappedDataToClient(client, length, ppixels);
|
|
|
|
}
|
2007-11-05 14:53:34 +01:00
|
|
|
xfree(ppixels);
|
2003-11-14 16:54:54 +01:00
|
|
|
return (client->noClientException);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->cmap;
|
2007-08-06 18:23:21 +02:00
|
|
|
return (rc == BadValue) ? BadColor : rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcFreeColors(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
ColormapPtr pcmp;
|
2007-08-06 18:23:21 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xFreeColorsReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xFreeColorsReq);
|
2008-08-07 00:26:24 +02:00
|
|
|
rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
|
2007-08-06 18:23:21 +02:00
|
|
|
DixRemoveAccess);
|
|
|
|
if (rc == Success)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int count;
|
|
|
|
|
|
|
|
if(pcmp->flags & AllAllocated)
|
|
|
|
return(BadAccess);
|
|
|
|
count = ((client->req_len << 2)- sizeof(xFreeColorsReq)) >> 2;
|
2007-08-06 18:23:21 +02:00
|
|
|
rc = FreeColors(pcmp, client->index, count,
|
2003-11-14 16:54:54 +01:00
|
|
|
(Pixel *)&stuff[1], (Pixel)stuff->planeMask);
|
|
|
|
if (client->noClientException != Success)
|
|
|
|
return(client->noClientException);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = clientErrorValue;
|
2007-08-06 18:23:21 +02:00
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->cmap;
|
2007-08-06 18:23:21 +02:00
|
|
|
return (rc == BadValue) ? BadColor : rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-03-08 00:02:59 +01:00
|
|
|
ProcStoreColors (ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
ColormapPtr pcmp;
|
2007-08-06 18:23:21 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xStoreColorsReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xStoreColorsReq);
|
2008-08-07 00:26:24 +02:00
|
|
|
rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
|
2007-08-06 18:23:21 +02:00
|
|
|
DixWriteAccess);
|
|
|
|
if (rc == Success)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int count;
|
|
|
|
|
|
|
|
count = (client->req_len << 2) - sizeof(xStoreColorsReq);
|
|
|
|
if (count % sizeof(xColorItem))
|
|
|
|
return(BadLength);
|
|
|
|
count /= sizeof(xColorItem);
|
2007-08-06 18:23:21 +02:00
|
|
|
rc = StoreColors(pcmp, count, (xColorItem *)&stuff[1]);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (client->noClientException != Success)
|
|
|
|
return(client->noClientException);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = clientErrorValue;
|
2007-08-06 18:23:21 +02:00
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->cmap;
|
2007-08-06 18:23:21 +02:00
|
|
|
return (rc == BadValue) ? BadColor : rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcStoreNamedColor (ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
ColormapPtr pcmp;
|
2007-08-06 18:23:21 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xStoreNamedColorReq);
|
|
|
|
|
|
|
|
REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes);
|
2008-08-07 00:26:24 +02:00
|
|
|
rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
|
2007-08-06 18:23:21 +02:00
|
|
|
DixWriteAccess);
|
|
|
|
if (rc == Success)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
xColorItem def;
|
|
|
|
|
|
|
|
if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1],
|
|
|
|
stuff->nbytes, &def.red, &def.green, &def.blue))
|
|
|
|
{
|
|
|
|
def.flags = stuff->flags;
|
|
|
|
def.pixel = stuff->pixel;
|
2007-08-06 18:23:21 +02:00
|
|
|
rc = StoreColors(pcmp, 1, &def);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (client->noClientException != Success)
|
|
|
|
return(client->noClientException);
|
|
|
|
else
|
2007-08-06 18:23:21 +02:00
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
return (BadName);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->cmap;
|
2007-08-06 18:23:21 +02:00
|
|
|
return (rc == BadValue) ? BadColor : rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcQueryColors(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
ColormapPtr pcmp;
|
2007-08-06 18:23:21 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xQueryColorsReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xQueryColorsReq);
|
2008-08-07 00:26:24 +02:00
|
|
|
rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
|
2007-08-06 18:23:21 +02:00
|
|
|
DixReadAccess);
|
|
|
|
if (rc == Success)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-08-06 18:23:21 +02:00
|
|
|
int count;
|
2003-11-14 16:54:54 +01:00
|
|
|
xrgb *prgbs;
|
|
|
|
xQueryColorsReply qcr;
|
|
|
|
|
|
|
|
count = ((client->req_len << 2) - sizeof(xQueryColorsReq)) >> 2;
|
2009-02-13 10:23:28 +01:00
|
|
|
prgbs = xcalloc(1, count * sizeof(xrgb));
|
2003-11-14 16:54:54 +01:00
|
|
|
if(!prgbs && count)
|
|
|
|
return(BadAlloc);
|
2007-08-06 18:23:21 +02:00
|
|
|
if( (rc = QueryColors(pcmp, count, (Pixel *)&stuff[1], prgbs)) )
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-11-05 14:53:34 +01:00
|
|
|
if (prgbs) xfree(prgbs);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (client->noClientException != Success)
|
|
|
|
return(client->noClientException);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = clientErrorValue;
|
2007-08-06 18:23:21 +02:00
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
2009-02-13 10:23:28 +01:00
|
|
|
memset(&qcr, 0, sizeof(xQueryColorsReply));
|
2003-11-14 16:54:54 +01:00
|
|
|
qcr.type = X_Reply;
|
|
|
|
qcr.length = (count * sizeof(xrgb)) >> 2;
|
|
|
|
qcr.sequenceNumber = client->sequence;
|
|
|
|
qcr.nColors = count;
|
|
|
|
WriteReplyToClient(client, sizeof(xQueryColorsReply), &qcr);
|
|
|
|
if (count)
|
|
|
|
{
|
2003-11-14 17:49:22 +01:00
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) SQColorsExtend;
|
2003-11-14 16:54:54 +01:00
|
|
|
WriteSwappedDataToClient(client, count * sizeof(xrgb), prgbs);
|
|
|
|
}
|
2007-11-05 14:53:34 +01:00
|
|
|
if (prgbs) xfree(prgbs);
|
2003-11-14 16:54:54 +01:00
|
|
|
return(client->noClientException);
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->cmap;
|
2007-08-06 18:23:21 +02:00
|
|
|
return (rc == BadValue) ? BadColor : rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcLookupColor(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
ColormapPtr pcmp;
|
2007-08-06 18:23:21 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xLookupColorReq);
|
|
|
|
|
|
|
|
REQUEST_FIXED_SIZE(xLookupColorReq, stuff->nbytes);
|
2008-08-07 00:26:24 +02:00
|
|
|
rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
|
2007-08-06 18:23:21 +02:00
|
|
|
DixReadAccess);
|
|
|
|
if (rc == Success)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
xLookupColorReply lcr;
|
|
|
|
|
|
|
|
if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1], stuff->nbytes,
|
|
|
|
&lcr.exactRed, &lcr.exactGreen, &lcr.exactBlue))
|
|
|
|
{
|
|
|
|
lcr.type = X_Reply;
|
|
|
|
lcr.length = 0;
|
|
|
|
lcr.sequenceNumber = client->sequence;
|
|
|
|
lcr.screenRed = lcr.exactRed;
|
|
|
|
lcr.screenGreen = lcr.exactGreen;
|
|
|
|
lcr.screenBlue = lcr.exactBlue;
|
|
|
|
(*pcmp->pScreen->ResolveColor)(&lcr.screenRed,
|
|
|
|
&lcr.screenGreen,
|
|
|
|
&lcr.screenBlue,
|
|
|
|
pcmp->pVisual);
|
|
|
|
WriteReplyToClient(client, sizeof(xLookupColorReply), &lcr);
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
return (BadName);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->cmap;
|
2007-08-06 18:23:21 +02:00
|
|
|
return (rc == BadValue) ? BadColor : rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcCreateCursor (ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
CursorPtr pCursor;
|
|
|
|
PixmapPtr src;
|
|
|
|
PixmapPtr msk;
|
2003-11-14 16:54:54 +01:00
|
|
|
unsigned char * srcbits;
|
|
|
|
unsigned char * mskbits;
|
|
|
|
unsigned short width, height;
|
|
|
|
long n;
|
2007-03-08 08:20:19 +01:00
|
|
|
CursorMetricRec cm;
|
2007-08-15 20:13:53 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST(xCreateCursorReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xCreateCursorReq);
|
|
|
|
LEGAL_NEW_RESOURCE(stuff->cid, client);
|
|
|
|
|
2008-08-07 00:26:24 +02:00
|
|
|
rc = dixLookupResourceByType((pointer *)&src, stuff->source, RT_PIXMAP, client,
|
2007-08-15 20:13:53 +02:00
|
|
|
DixReadAccess);
|
|
|
|
if (rc != Success) {
|
2003-11-14 16:54:54 +01:00
|
|
|
client->errorValue = stuff->source;
|
2007-08-15 20:13:53 +02:00
|
|
|
return (rc == BadValue) ? BadPixmap : rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2007-08-15 20:13:53 +02:00
|
|
|
|
2008-08-07 00:26:24 +02:00
|
|
|
rc = dixLookupResourceByType((pointer *)&msk, stuff->mask, RT_PIXMAP, client,
|
2007-08-15 20:13:53 +02:00
|
|
|
DixReadAccess);
|
|
|
|
if (rc != Success)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
if (stuff->mask != None)
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->mask;
|
2007-08-15 20:13:53 +02:00
|
|
|
return (rc == BadValue) ? BadPixmap : rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( src->drawable.width != msk->drawable.width
|
|
|
|
|| src->drawable.height != msk->drawable.height
|
|
|
|
|| src->drawable.depth != 1
|
|
|
|
|| msk->drawable.depth != 1)
|
|
|
|
return (BadMatch);
|
|
|
|
|
|
|
|
width = src->drawable.width;
|
|
|
|
height = src->drawable.height;
|
|
|
|
|
|
|
|
if ( stuff->x > width
|
|
|
|
|| stuff->y > height )
|
|
|
|
return (BadMatch);
|
|
|
|
|
|
|
|
n = BitmapBytePad(width)*height;
|
2008-10-06 20:19:30 +02:00
|
|
|
srcbits = xcalloc(1, n);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!srcbits)
|
|
|
|
return (BadAlloc);
|
2008-10-06 20:19:30 +02:00
|
|
|
mskbits = xalloc(n);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!mskbits)
|
|
|
|
{
|
|
|
|
xfree(srcbits);
|
|
|
|
return (BadAlloc);
|
|
|
|
}
|
|
|
|
|
|
|
|
(* src->drawable.pScreen->GetImage)( (DrawablePtr)src, 0, 0, width, height,
|
|
|
|
XYPixmap, 1, (pointer)srcbits);
|
|
|
|
if ( msk == (PixmapPtr)NULL)
|
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
unsigned char *bits = mskbits;
|
2003-11-14 16:54:54 +01:00
|
|
|
while (--n >= 0)
|
|
|
|
*bits++ = ~0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* zeroing the (pad) bits helps some ddx cursor handling */
|
|
|
|
bzero((char *)mskbits, n);
|
|
|
|
(* msk->drawable.pScreen->GetImage)( (DrawablePtr)msk, 0, 0, width,
|
|
|
|
height, XYPixmap, 1, (pointer)mskbits);
|
|
|
|
}
|
|
|
|
cm.width = width;
|
|
|
|
cm.height = height;
|
|
|
|
cm.xhot = stuff->x;
|
|
|
|
cm.yhot = stuff->y;
|
2007-08-15 20:13:53 +02:00
|
|
|
rc = AllocARGBCursor(srcbits, mskbits, NULL, &cm,
|
|
|
|
stuff->foreRed, stuff->foreGreen, stuff->foreBlue,
|
|
|
|
stuff->backRed, stuff->backGreen, stuff->backBlue,
|
|
|
|
&pCursor, client, stuff->cid);
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2007-08-15 20:13:53 +02:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
if (!AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor))
|
|
|
|
return BadAlloc;
|
|
|
|
|
|
|
|
return client->noClientException;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcCreateGlyphCursor (ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
CursorPtr pCursor;
|
|
|
|
int res;
|
|
|
|
|
|
|
|
REQUEST(xCreateGlyphCursorReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xCreateGlyphCursorReq);
|
|
|
|
LEGAL_NEW_RESOURCE(stuff->cid, client);
|
|
|
|
|
|
|
|
res = AllocGlyphCursor(stuff->source, stuff->sourceChar,
|
|
|
|
stuff->mask, stuff->maskChar,
|
|
|
|
stuff->foreRed, stuff->foreGreen, stuff->foreBlue,
|
|
|
|
stuff->backRed, stuff->backGreen, stuff->backBlue,
|
2007-08-15 20:13:53 +02:00
|
|
|
&pCursor, client, stuff->cid);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (res != Success)
|
|
|
|
return res;
|
|
|
|
if (AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor))
|
|
|
|
return client->noClientException;
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcFreeCursor (ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
CursorPtr pCursor;
|
2007-08-15 20:13:53 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xResourceReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2008-08-07 00:26:24 +02:00
|
|
|
rc = dixLookupResourceByType((pointer *)&pCursor, stuff->id, RT_CURSOR, client,
|
2007-08-15 20:13:53 +02:00
|
|
|
DixDestroyAccess);
|
|
|
|
if (rc == Success)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
FreeResource(stuff->id, RT_NONE);
|
|
|
|
return (client->noClientException);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->id;
|
2007-08-15 20:13:53 +02:00
|
|
|
return (rc == BadValue) ? BadCursor : rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcQueryBestSize (ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
xQueryBestSizeReply reply;
|
2006-12-15 01:15:21 +01:00
|
|
|
DrawablePtr pDraw;
|
2003-11-14 16:54:54 +01:00
|
|
|
ScreenPtr pScreen;
|
2006-12-15 01:15:21 +01:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xQueryBestSizeReq);
|
|
|
|
REQUEST_SIZE_MATCH(xQueryBestSizeReq);
|
2006-12-15 01:15:21 +01:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
if ((stuff->class != CursorShape) &&
|
|
|
|
(stuff->class != TileShape) &&
|
|
|
|
(stuff->class != StippleShape))
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->class;
|
|
|
|
return(BadValue);
|
|
|
|
}
|
2006-12-15 01:15:21 +01:00
|
|
|
|
|
|
|
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, M_ANY,
|
2007-08-13 19:40:47 +02:00
|
|
|
DixGetAttrAccess);
|
2006-12-15 01:15:21 +01:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
if (stuff->class != CursorShape && pDraw->type == UNDRAWABLE_WINDOW)
|
|
|
|
return (BadMatch);
|
|
|
|
pScreen = pDraw->pScreen;
|
2007-08-13 19:40:47 +02:00
|
|
|
rc = XaceHook(XACE_SCREEN_ACCESS, client, pScreen, DixGetAttrAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
(* pScreen->QueryBestSize)(stuff->class, &stuff->width,
|
|
|
|
&stuff->height, pScreen);
|
2009-02-13 10:23:28 +01:00
|
|
|
memset(&reply, 0, sizeof(xQueryBestSizeReply));
|
2003-11-14 16:54:54 +01:00
|
|
|
reply.type = X_Reply;
|
|
|
|
reply.length = 0;
|
|
|
|
reply.sequenceNumber = client->sequence;
|
|
|
|
reply.width = stuff->width;
|
|
|
|
reply.height = stuff->height;
|
|
|
|
WriteReplyToClient(client, sizeof(xQueryBestSizeReply), &reply);
|
|
|
|
return (client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcSetScreenSaver (ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-08-16 16:36:05 +02:00
|
|
|
int rc, i, blankingOption, exposureOption;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xSetScreenSaverReq);
|
|
|
|
REQUEST_SIZE_MATCH(xSetScreenSaverReq);
|
2007-08-16 16:36:05 +02:00
|
|
|
|
|
|
|
for (i = 0; i < screenInfo.numScreens; i++) {
|
|
|
|
rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, screenInfo.screens[i],
|
|
|
|
DixSetAttrAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
blankingOption = stuff->preferBlank;
|
|
|
|
if ((blankingOption != DontPreferBlanking) &&
|
|
|
|
(blankingOption != PreferBlanking) &&
|
|
|
|
(blankingOption != DefaultBlanking))
|
|
|
|
{
|
|
|
|
client->errorValue = blankingOption;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
exposureOption = stuff->allowExpose;
|
|
|
|
if ((exposureOption != DontAllowExposures) &&
|
|
|
|
(exposureOption != AllowExposures) &&
|
|
|
|
(exposureOption != DefaultExposures))
|
|
|
|
{
|
|
|
|
client->errorValue = exposureOption;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
if (stuff->timeout < -1)
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->timeout;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
if (stuff->interval < -1)
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->interval;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (blankingOption == DefaultBlanking)
|
|
|
|
ScreenSaverBlanking = defaultScreenSaverBlanking;
|
|
|
|
else
|
|
|
|
ScreenSaverBlanking = blankingOption;
|
|
|
|
if (exposureOption == DefaultExposures)
|
|
|
|
ScreenSaverAllowExposures = defaultScreenSaverAllowExposures;
|
|
|
|
else
|
|
|
|
ScreenSaverAllowExposures = exposureOption;
|
|
|
|
|
|
|
|
if (stuff->timeout >= 0)
|
|
|
|
ScreenSaverTime = stuff->timeout * MILLI_PER_SECOND;
|
|
|
|
else
|
|
|
|
ScreenSaverTime = defaultScreenSaverTime;
|
|
|
|
if (stuff->interval >= 0)
|
|
|
|
ScreenSaverInterval = stuff->interval * MILLI_PER_SECOND;
|
|
|
|
else
|
|
|
|
ScreenSaverInterval = defaultScreenSaverInterval;
|
2003-11-25 20:29:01 +01:00
|
|
|
|
|
|
|
SetScreenSaverTimer();
|
2003-11-14 16:54:54 +01:00
|
|
|
return (client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcGetScreenSaver(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
xGetScreenSaverReply rep;
|
2007-08-16 16:36:05 +02:00
|
|
|
int rc, i;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST_SIZE_MATCH(xReq);
|
2007-08-16 16:36:05 +02:00
|
|
|
|
|
|
|
for (i = 0; i < screenInfo.numScreens; i++) {
|
|
|
|
rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, screenInfo.screens[i],
|
|
|
|
DixGetAttrAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.length = 0;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
rep.timeout = ScreenSaverTime / MILLI_PER_SECOND;
|
|
|
|
rep.interval = ScreenSaverInterval / MILLI_PER_SECOND;
|
|
|
|
rep.preferBlanking = ScreenSaverBlanking;
|
|
|
|
rep.allowExposures = ScreenSaverAllowExposures;
|
|
|
|
WriteReplyToClient(client, sizeof(xGetScreenSaverReply), &rep);
|
|
|
|
return (client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcChangeHosts(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
REQUEST(xChangeHostsReq);
|
|
|
|
int result;
|
|
|
|
|
|
|
|
REQUEST_FIXED_SIZE(xChangeHostsReq, stuff->hostLength);
|
|
|
|
|
|
|
|
if(stuff->mode == HostInsert)
|
|
|
|
result = AddHost(client, (int)stuff->hostFamily,
|
|
|
|
stuff->hostLength, (pointer)&stuff[1]);
|
|
|
|
else if (stuff->mode == HostDelete)
|
|
|
|
result = RemoveHost(client, (int)stuff->hostFamily,
|
|
|
|
stuff->hostLength, (pointer)&stuff[1]);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->mode;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
if (!result)
|
|
|
|
result = client->noClientException;
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcListHosts(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
xListHostsReply reply;
|
|
|
|
int len, nHosts, result;
|
|
|
|
pointer pdata;
|
2003-11-14 17:49:22 +01:00
|
|
|
/* REQUEST(xListHostsReq); */
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xListHostsReq);
|
2006-12-02 02:48:15 +01:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
/* untrusted clients can't list hosts */
|
2007-08-15 20:14:25 +02:00
|
|
|
result = XaceHook(XACE_SERVER_ACCESS, client, DixReadAccess);
|
2007-04-17 22:01:56 +02:00
|
|
|
if (result != Success)
|
|
|
|
return result;
|
2006-12-02 02:48:15 +01:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
result = GetHosts(&pdata, &nHosts, &len, &reply.enabled);
|
|
|
|
if (result != Success)
|
|
|
|
return(result);
|
|
|
|
reply.type = X_Reply;
|
|
|
|
reply.sequenceNumber = client->sequence;
|
|
|
|
reply.nHosts = nHosts;
|
|
|
|
reply.length = len >> 2;
|
|
|
|
WriteReplyToClient(client, sizeof(xListHostsReply), &reply);
|
|
|
|
if (nHosts)
|
|
|
|
{
|
2003-11-14 17:49:22 +01:00
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) SLHostsExtend;
|
2003-11-14 16:54:54 +01:00
|
|
|
WriteSwappedDataToClient(client, len, pdata);
|
|
|
|
}
|
|
|
|
xfree(pdata);
|
|
|
|
return (client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcChangeAccessControl(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int result;
|
|
|
|
REQUEST(xSetAccessControlReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xSetAccessControlReq);
|
|
|
|
if ((stuff->mode != EnableAccess) && (stuff->mode != DisableAccess))
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->mode;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
result = ChangeAccessControl(client, stuff->mode == EnableAccess);
|
|
|
|
if (!result)
|
|
|
|
result = client->noClientException;
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2007-03-25 23:57:54 +02:00
|
|
|
/*********************
|
|
|
|
* CloseDownRetainedResources
|
|
|
|
*
|
|
|
|
* Find all clients that are gone and have terminated in RetainTemporary
|
|
|
|
* and destroy their resources.
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
static void
|
|
|
|
CloseDownRetainedResources(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
ClientPtr client;
|
|
|
|
|
|
|
|
for (i=1; i<currentMaxClients; i++)
|
|
|
|
{
|
|
|
|
client = clients[i];
|
|
|
|
if (client && (client->closeDownMode == RetainTemporary)
|
|
|
|
&& (client->clientGone))
|
|
|
|
CloseDownClient(client);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcKillClient(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
REQUEST(xResourceReq);
|
2006-12-15 23:26:58 +01:00
|
|
|
ClientPtr killclient;
|
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
|
|
|
if (stuff->id == AllTemporary)
|
|
|
|
{
|
|
|
|
CloseDownRetainedResources();
|
|
|
|
return (client->noClientException);
|
|
|
|
}
|
|
|
|
|
2006-12-15 23:26:58 +01:00
|
|
|
rc = dixLookupClient(&killclient, stuff->id, client, DixDestroyAccess);
|
|
|
|
if (rc == Success) {
|
2003-11-14 16:54:54 +01:00
|
|
|
CloseDownClient(killclient);
|
|
|
|
/* if an LBX proxy gets killed, isItTimeToYield will be set */
|
|
|
|
if (isItTimeToYield || (client == killclient))
|
|
|
|
{
|
|
|
|
/* force yield and return Success, so that Dispatch()
|
|
|
|
* doesn't try to touch client
|
|
|
|
*/
|
|
|
|
isItTimeToYield = TRUE;
|
|
|
|
return (Success);
|
|
|
|
}
|
|
|
|
return (client->noClientException);
|
|
|
|
}
|
|
|
|
else
|
2006-12-15 23:26:58 +01:00
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcSetFontPath(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
unsigned char *ptr;
|
|
|
|
unsigned long nbytes, total;
|
|
|
|
long nfonts;
|
|
|
|
int n, result;
|
|
|
|
int error;
|
|
|
|
REQUEST(xSetFontPathReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xSetFontPathReq);
|
|
|
|
|
|
|
|
nbytes = (client->req_len << 2) - sizeof(xSetFontPathReq);
|
|
|
|
total = nbytes;
|
|
|
|
ptr = (unsigned char *)&stuff[1];
|
|
|
|
nfonts = stuff->nFonts;
|
|
|
|
while (--nfonts >= 0)
|
|
|
|
{
|
|
|
|
if ((total == 0) || (total < (n = (*ptr + 1))))
|
|
|
|
return(BadLength);
|
|
|
|
total -= n;
|
|
|
|
ptr += n;
|
|
|
|
}
|
|
|
|
if (total >= 4)
|
|
|
|
return(BadLength);
|
|
|
|
result = SetFontPath(client, stuff->nFonts, (unsigned char *)&stuff[1],
|
|
|
|
&error);
|
|
|
|
if (!result)
|
|
|
|
{
|
|
|
|
result = client->noClientException;
|
|
|
|
client->errorValue = error;
|
|
|
|
}
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcGetFontPath(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
xGetFontPathReply reply;
|
2007-08-15 20:14:45 +02:00
|
|
|
int rc, stringLens, numpaths;
|
2003-11-14 16:54:54 +01:00
|
|
|
unsigned char *bufferStart;
|
2003-11-14 17:49:22 +01:00
|
|
|
/* REQUEST (xReq); */
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xReq);
|
2007-08-15 20:14:45 +02:00
|
|
|
rc = GetFontPath(client, &numpaths, &stringLens, &bufferStart);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
reply.type = X_Reply;
|
|
|
|
reply.sequenceNumber = client->sequence;
|
|
|
|
reply.length = (stringLens + numpaths + 3) >> 2;
|
|
|
|
reply.nPaths = numpaths;
|
|
|
|
|
|
|
|
WriteReplyToClient(client, sizeof(xGetFontPathReply), &reply);
|
|
|
|
if (stringLens || numpaths)
|
|
|
|
(void)WriteToClient(client, stringLens + numpaths, (char *)bufferStart);
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcChangeCloseDownMode(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-08-16 16:57:49 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xSetCloseDownModeReq);
|
|
|
|
REQUEST_SIZE_MATCH(xSetCloseDownModeReq);
|
2007-08-16 16:57:49 +02:00
|
|
|
|
|
|
|
rc = XaceHook(XACE_CLIENT_ACCESS, client, client, DixManageAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
if ((stuff->mode == AllTemporary) ||
|
|
|
|
(stuff->mode == RetainPermanent) ||
|
|
|
|
(stuff->mode == RetainTemporary))
|
|
|
|
{
|
|
|
|
client->closeDownMode = stuff->mode;
|
|
|
|
return (client->noClientException);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->mode;
|
|
|
|
return (BadValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-08 08:20:19 +01:00
|
|
|
int ProcForceScreenSaver(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-08-16 16:36:05 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xForceScreenSaverReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xForceScreenSaverReq);
|
|
|
|
|
|
|
|
if ((stuff->mode != ScreenSaverReset) &&
|
|
|
|
(stuff->mode != ScreenSaverActive))
|
|
|
|
{
|
|
|
|
client->errorValue = stuff->mode;
|
|
|
|
return BadValue;
|
|
|
|
}
|
2007-11-19 22:55:09 +01:00
|
|
|
rc = dixSaveScreens(client, SCREEN_SAVER_FORCER, (int)stuff->mode);
|
2007-08-16 16:36:05 +02:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
return client->noClientException;
|
|
|
|
}
|
|
|
|
|
2007-03-08 08:20:19 +01:00
|
|
|
int ProcNoOperation(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
REQUEST_AT_LEAST_SIZE(xReq);
|
|
|
|
|
|
|
|
/* noop -- don't do anything */
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-11-14 17:49:22 +01:00
|
|
|
InitProcVectors(void)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i<256; i++)
|
|
|
|
{
|
|
|
|
if(!ProcVector[i])
|
|
|
|
{
|
|
|
|
ProcVector[i] = SwappedProcVector[i] = ProcBadRequest;
|
2003-11-14 17:49:22 +01:00
|
|
|
ReplySwapVector[i] = ReplyNotSwappd;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for(i = LASTEvent; i < 128; i++)
|
|
|
|
{
|
|
|
|
EventSwapVector[i] = NotImplemented;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* CloseDownClient
|
|
|
|
*
|
|
|
|
* Client can either mark his resources destroy or retain. If retained and
|
|
|
|
* then killed again, the client is really destroyed.
|
|
|
|
*********************/
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
char dispatchExceptionAtReset = DE_RESET;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2007-03-08 08:20:19 +01:00
|
|
|
CloseDownClient(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
Bool really_close_down = client->clientGone ||
|
|
|
|
client->closeDownMode == DestroyAll;
|
|
|
|
|
|
|
|
if (!client->clientGone)
|
|
|
|
{
|
|
|
|
/* ungrab server if grabbing client dies */
|
|
|
|
if (grabState != GrabNone && grabClient == client)
|
|
|
|
{
|
|
|
|
UngrabServer(client);
|
|
|
|
}
|
|
|
|
BITCLEAR(grabWaiters, client->index);
|
|
|
|
DeleteClientFromAnySelections(client);
|
|
|
|
ReleaseActiveGrabs(client);
|
|
|
|
DeleteClientFontStuff(client);
|
|
|
|
if (!really_close_down)
|
|
|
|
{
|
|
|
|
/* This frees resources that should never be retained
|
|
|
|
* no matter what the close down mode is. Actually we
|
|
|
|
* could do this unconditionally, but it's probably
|
|
|
|
* better not to traverse all the client's resources
|
|
|
|
* twice (once here, once a few lines down in
|
|
|
|
* FreeClientResources) in the common case of
|
|
|
|
* really_close_down == TRUE.
|
|
|
|
*/
|
|
|
|
FreeClientNeverRetainResources(client);
|
|
|
|
client->clientState = ClientStateRetained;
|
|
|
|
if (ClientStateCallback)
|
|
|
|
{
|
|
|
|
NewClientInfoRec clientinfo;
|
|
|
|
|
|
|
|
clientinfo.client = client;
|
|
|
|
clientinfo.prefix = (xConnSetupPrefix *)NULL;
|
|
|
|
clientinfo.setup = (xConnSetup *) NULL;
|
|
|
|
CallCallbacks((&ClientStateCallback), (pointer)&clientinfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
client->clientGone = TRUE; /* so events aren't sent to client */
|
|
|
|
if (ClientIsAsleep(client))
|
|
|
|
ClientSignal (client);
|
|
|
|
ProcessWorkQueueZombies();
|
|
|
|
CloseDownConnection(client);
|
|
|
|
|
|
|
|
/* If the client made it to the Running stage, nClients has
|
|
|
|
* been incremented on its behalf, so we need to decrement it
|
|
|
|
* now. If it hasn't gotten to Running, nClients has *not*
|
|
|
|
* been incremented, so *don't* decrement it.
|
|
|
|
*/
|
|
|
|
if (client->clientState != ClientStateInitial &&
|
|
|
|
client->clientState != ClientStateAuthenticating )
|
|
|
|
{
|
|
|
|
--nClients;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (really_close_down)
|
|
|
|
{
|
|
|
|
if (client->clientState == ClientStateRunning && nClients == 0)
|
2003-11-14 17:49:22 +01:00
|
|
|
dispatchException |= dispatchExceptionAtReset;
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
client->clientState = ClientStateGone;
|
|
|
|
if (ClientStateCallback)
|
|
|
|
{
|
|
|
|
NewClientInfoRec clientinfo;
|
|
|
|
|
|
|
|
clientinfo.client = client;
|
|
|
|
clientinfo.prefix = (xConnSetupPrefix *)NULL;
|
|
|
|
clientinfo.setup = (xConnSetup *) NULL;
|
|
|
|
CallCallbacks((&ClientStateCallback), (pointer)&clientinfo);
|
|
|
|
}
|
|
|
|
FreeClientResources(client);
|
2006-11-03 21:54:43 +01:00
|
|
|
#ifdef XSERVER_DTRACE
|
|
|
|
XSERVER_CLIENT_DISCONNECT(client->index);
|
|
|
|
#endif
|
2003-11-14 16:54:54 +01:00
|
|
|
if (client->index < nextFreeClientID)
|
|
|
|
nextFreeClientID = client->index;
|
|
|
|
clients[client->index] = NullClient;
|
2003-11-14 17:49:22 +01:00
|
|
|
SmartLastClient = NullClient;
|
2007-08-28 15:28:25 +02:00
|
|
|
dixFreePrivates(client->devPrivates);
|
2003-11-14 16:54:54 +01:00
|
|
|
xfree(client);
|
|
|
|
|
|
|
|
while (!clients[currentMaxClients-1])
|
|
|
|
currentMaxClients--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-04-09 23:33:15 +02:00
|
|
|
KillAllClients(void)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i=1; i<currentMaxClients; i++)
|
|
|
|
if (clients[i]) {
|
|
|
|
/* Make sure Retained clients are released. */
|
|
|
|
clients[i]->closeDownMode = DestroyAll;
|
|
|
|
CloseDownClient(clients[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void InitClient(ClientPtr client, int i, pointer ospriv)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2009-03-30 23:22:28 +02:00
|
|
|
memset(client, 0, sizeof(*client));
|
2003-11-14 16:54:54 +01:00
|
|
|
client->index = i;
|
|
|
|
client->clientAsMask = ((Mask)i) << CLIENTOFFSET;
|
2007-08-14 17:39:26 +02:00
|
|
|
client->closeDownMode = i ? DestroyAll : RetainPermanent;
|
2003-11-14 16:54:54 +01:00
|
|
|
client->requestVector = InitialVector;
|
|
|
|
client->osPrivate = ospriv;
|
2008-03-18 09:05:57 +01:00
|
|
|
QueryMinMaxKeyCodes(&client->minKC,&client->maxKC);
|
2003-11-14 17:49:22 +01:00
|
|
|
client->smart_start_tick = SmartScheduleTime;
|
|
|
|
client->smart_stop_tick = SmartScheduleTime;
|
|
|
|
client->smart_check_tick = SmartScheduleTime;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************
|
|
|
|
* int NextAvailableClient(ospriv)
|
|
|
|
*
|
|
|
|
* OS dependent portion can't assign client id's because of CloseDownModes.
|
|
|
|
* Returns NULL if there are no free clients.
|
|
|
|
*************************/
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
ClientPtr NextAvailableClient(pointer ospriv)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
int i;
|
|
|
|
ClientPtr client;
|
2003-11-14 16:54:54 +01:00
|
|
|
xReq data;
|
|
|
|
|
|
|
|
i = nextFreeClientID;
|
|
|
|
if (i == MAXCLIENTS)
|
|
|
|
return (ClientPtr)NULL;
|
2009-01-22 08:11:16 +01:00
|
|
|
clients[i] = client = xalloc(sizeof(ClientRec));
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!client)
|
|
|
|
return (ClientPtr)NULL;
|
|
|
|
InitClient(client, i, ospriv);
|
|
|
|
if (!InitClientResources(client))
|
|
|
|
{
|
|
|
|
xfree(client);
|
|
|
|
return (ClientPtr)NULL;
|
|
|
|
}
|
|
|
|
data.reqType = 1;
|
|
|
|
data.length = (sz_xReq + sz_xConnClientPrefix) >> 2;
|
|
|
|
if (!InsertFakeRequest(client, (char *)&data, sz_xReq))
|
|
|
|
{
|
|
|
|
FreeClientResources(client);
|
|
|
|
xfree(client);
|
|
|
|
return (ClientPtr)NULL;
|
|
|
|
}
|
|
|
|
if (i == currentMaxClients)
|
|
|
|
currentMaxClients++;
|
|
|
|
while ((nextFreeClientID < MAXCLIENTS) && clients[nextFreeClientID])
|
|
|
|
nextFreeClientID++;
|
|
|
|
if (ClientStateCallback)
|
|
|
|
{
|
|
|
|
NewClientInfoRec clientinfo;
|
|
|
|
|
|
|
|
clientinfo.client = client;
|
|
|
|
clientinfo.prefix = (xConnSetupPrefix *)NULL;
|
|
|
|
clientinfo.setup = (xConnSetup *) NULL;
|
|
|
|
CallCallbacks((&ClientStateCallback), (pointer)&clientinfo);
|
|
|
|
}
|
|
|
|
return(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcInitialConnection(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
REQUEST(xReq);
|
2007-03-08 08:20:19 +01:00
|
|
|
xConnClientPrefix *prefix;
|
2003-11-14 16:54:54 +01:00
|
|
|
int whichbyte = 1;
|
|
|
|
|
|
|
|
prefix = (xConnClientPrefix *)((char *)stuff + sz_xReq);
|
|
|
|
if ((prefix->byteOrder != 'l') && (prefix->byteOrder != 'B'))
|
|
|
|
return (client->noClientException = -1);
|
|
|
|
if (((*(char *) &whichbyte) && (prefix->byteOrder == 'B')) ||
|
|
|
|
(!(*(char *) &whichbyte) && (prefix->byteOrder == 'l')))
|
|
|
|
{
|
|
|
|
client->swapped = TRUE;
|
|
|
|
SwapConnClientPrefix(prefix);
|
|
|
|
}
|
|
|
|
stuff->reqType = 2;
|
|
|
|
stuff->length += ((prefix->nbytesAuthProto + (unsigned)3) >> 2) +
|
|
|
|
((prefix->nbytesAuthString + (unsigned)3) >> 2);
|
|
|
|
if (client->swapped)
|
|
|
|
{
|
|
|
|
swaps(&stuff->length, whichbyte);
|
|
|
|
}
|
|
|
|
ResetCurrentRequest(client);
|
|
|
|
return (client->noClientException);
|
|
|
|
}
|
|
|
|
|
2007-11-15 23:01:33 +01:00
|
|
|
static int
|
2007-03-08 08:20:19 +01:00
|
|
|
SendConnSetup(ClientPtr client, char *reason)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
xWindowRoot *root;
|
|
|
|
int i;
|
2003-11-14 16:54:54 +01:00
|
|
|
int numScreens;
|
|
|
|
char* lConnectionInfo;
|
|
|
|
xConnSetupPrefix* lconnSetupPrefix;
|
|
|
|
|
|
|
|
if (reason)
|
|
|
|
{
|
|
|
|
xConnSetupPrefix csp;
|
|
|
|
|
|
|
|
csp.success = xFalse;
|
|
|
|
csp.lengthReason = strlen(reason);
|
|
|
|
csp.length = (csp.lengthReason + (unsigned)3) >> 2;
|
|
|
|
csp.majorVersion = X_PROTOCOL;
|
|
|
|
csp.minorVersion = X_PROTOCOL_REVISION;
|
|
|
|
if (client->swapped)
|
|
|
|
WriteSConnSetupPrefix(client, &csp);
|
|
|
|
else
|
|
|
|
(void)WriteToClient(client, sz_xConnSetupPrefix, (char *) &csp);
|
|
|
|
(void)WriteToClient(client, (int)csp.lengthReason, reason);
|
|
|
|
return (client->noClientException = -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
numScreens = screenInfo.numScreens;
|
|
|
|
lConnectionInfo = ConnectionInfo;
|
|
|
|
lconnSetupPrefix = &connSetupPrefix;
|
|
|
|
|
|
|
|
/* We're about to start speaking X protocol back to the client by
|
|
|
|
* sending the connection setup info. This means the authorization
|
|
|
|
* step is complete, and we can count the client as an
|
|
|
|
* authorized one.
|
|
|
|
*/
|
|
|
|
nClients++;
|
|
|
|
|
|
|
|
client->requestVector = client->swapped ? SwappedProcVector : ProcVector;
|
|
|
|
client->sequence = 0;
|
|
|
|
((xConnSetup *)lConnectionInfo)->ridBase = client->clientAsMask;
|
|
|
|
((xConnSetup *)lConnectionInfo)->ridMask = RESOURCE_ID_MASK;
|
2003-11-14 17:49:22 +01:00
|
|
|
#ifdef MATCH_CLIENT_ENDIAN
|
|
|
|
((xConnSetup *)lConnectionInfo)->imageByteOrder = ClientOrder (client);
|
|
|
|
((xConnSetup *)lConnectionInfo)->bitmapBitOrder = ClientOrder (client);
|
|
|
|
#endif
|
2003-11-14 16:54:54 +01:00
|
|
|
/* fill in the "currentInputMask" */
|
|
|
|
root = (xWindowRoot *)(lConnectionInfo + connBlockScreenStart);
|
2003-11-14 17:49:22 +01:00
|
|
|
#ifdef PANORAMIX
|
|
|
|
if (noPanoramiXExtension)
|
|
|
|
numScreens = screenInfo.numScreens;
|
|
|
|
else
|
|
|
|
numScreens = ((xConnSetup *)ConnectionInfo)->numRoots;
|
|
|
|
#endif
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
for (i=0; i<numScreens; i++)
|
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
unsigned int j;
|
|
|
|
xDepth *pDepth;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
root->currentInputMask = WindowTable[i]->eventMask |
|
|
|
|
wOtherEventMasks (WindowTable[i]);
|
|
|
|
pDepth = (xDepth *)(root + 1);
|
|
|
|
for (j = 0; j < root->nDepths; j++)
|
|
|
|
{
|
|
|
|
pDepth = (xDepth *)(((char *)(pDepth + 1)) +
|
|
|
|
pDepth->nVisuals * sizeof(xVisualType));
|
|
|
|
}
|
|
|
|
root = (xWindowRoot *)pDepth;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (client->swapped)
|
|
|
|
{
|
|
|
|
WriteSConnSetupPrefix(client, lconnSetupPrefix);
|
|
|
|
WriteSConnectionInfo(client,
|
|
|
|
(unsigned long)(lconnSetupPrefix->length << 2),
|
|
|
|
lConnectionInfo);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
(void)WriteToClient(client, sizeof(xConnSetupPrefix),
|
|
|
|
(char *) lconnSetupPrefix);
|
|
|
|
(void)WriteToClient(client, (int)(lconnSetupPrefix->length << 2),
|
|
|
|
lConnectionInfo);
|
|
|
|
}
|
|
|
|
client->clientState = ClientStateRunning;
|
|
|
|
if (ClientStateCallback)
|
|
|
|
{
|
|
|
|
NewClientInfoRec clientinfo;
|
|
|
|
|
|
|
|
clientinfo.client = client;
|
|
|
|
clientinfo.prefix = lconnSetupPrefix;
|
|
|
|
clientinfo.setup = (xConnSetup *)lConnectionInfo;
|
|
|
|
CallCallbacks((&ClientStateCallback), (pointer)&clientinfo);
|
|
|
|
}
|
|
|
|
return (client->noClientException);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-03-08 08:20:19 +01:00
|
|
|
ProcEstablishConnection(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
char *reason, *auth_proto, *auth_string;
|
2007-03-08 08:20:19 +01:00
|
|
|
xConnClientPrefix *prefix;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xReq);
|
|
|
|
|
|
|
|
prefix = (xConnClientPrefix *)((char *)stuff + sz_xReq);
|
|
|
|
auth_proto = (char *)prefix + sz_xConnClientPrefix;
|
|
|
|
auth_string = auth_proto + ((prefix->nbytesAuthProto + 3) & ~3);
|
|
|
|
if ((prefix->majorVersion != X_PROTOCOL) ||
|
|
|
|
(prefix->minorVersion != X_PROTOCOL_REVISION))
|
|
|
|
reason = "Protocol version mismatch";
|
|
|
|
else
|
|
|
|
reason = ClientAuthorized(client,
|
|
|
|
(unsigned short)prefix->nbytesAuthProto,
|
|
|
|
auth_proto,
|
|
|
|
(unsigned short)prefix->nbytesAuthString,
|
|
|
|
auth_string);
|
|
|
|
/*
|
|
|
|
* If Kerberos is being used for this client, the clientState
|
|
|
|
* will be set to ClientStateAuthenticating at this point.
|
|
|
|
* More messages need to be exchanged among the X server, Kerberos
|
|
|
|
* server, and client to figure out if everyone is authorized.
|
|
|
|
* So we don't want to send the connection setup info yet, since
|
|
|
|
* the auth step isn't really done.
|
|
|
|
*/
|
|
|
|
if (client->clientState == ClientStateCheckingSecurity)
|
|
|
|
client->clientState = ClientStateCheckedSecurity;
|
|
|
|
else if (client->clientState != ClientStateAuthenticating)
|
|
|
|
return(SendConnSetup(client, reason));
|
|
|
|
return(client->noClientException);
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2005-03-08 00:02:59 +01:00
|
|
|
SendErrorToClient(ClientPtr client, unsigned majorCode, unsigned minorCode,
|
|
|
|
XID resId, int errorCode)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
xError rep;
|
|
|
|
|
2009-02-13 10:23:28 +01:00
|
|
|
memset(&rep, 0, sizeof(xError));
|
2003-11-14 16:54:54 +01:00
|
|
|
rep.type = X_Error;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
rep.errorCode = errorCode;
|
|
|
|
rep.majorCode = majorCode;
|
|
|
|
rep.minorCode = minorCode;
|
|
|
|
rep.resourceID = resId;
|
|
|
|
|
|
|
|
WriteEventsToClient (client, 1, (xEvent *)&rep);
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2005-03-08 00:02:59 +01:00
|
|
|
MarkClientException(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
client->noClientException = -1;
|
|
|
|
}
|
2009-04-22 05:26:40 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This array encodes the answer to the question "what is the log base 2
|
|
|
|
* of the number of pixels that fit in a scanline pad unit?"
|
|
|
|
* Note that ~0 is an invalid entry (mostly for the benefit of the reader).
|
|
|
|
*/
|
|
|
|
static int answer[6][4] = {
|
|
|
|
/* pad pad pad pad*/
|
|
|
|
/* 8 16 32 64 */
|
|
|
|
|
|
|
|
{ 3, 4, 5 , 6 }, /* 1 bit per pixel */
|
|
|
|
{ 1, 2, 3 , 4 }, /* 4 bits per pixel */
|
|
|
|
{ 0, 1, 2 , 3 }, /* 8 bits per pixel */
|
|
|
|
{ ~0, 0, 1 , 2 }, /* 16 bits per pixel */
|
|
|
|
{ ~0, ~0, 0 , 1 }, /* 24 bits per pixel */
|
|
|
|
{ ~0, ~0, 0 , 1 } /* 32 bits per pixel */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This array gives the answer to the question "what is the first index for
|
|
|
|
* the answer array above given the number of bits per pixel?"
|
|
|
|
* Note that ~0 is an invalid entry (mostly for the benefit of the reader).
|
|
|
|
*/
|
|
|
|
static int indexForBitsPerPixel[ 33 ] = {
|
|
|
|
~0, 0, ~0, ~0, /* 1 bit per pixel */
|
|
|
|
1, ~0, ~0, ~0, /* 4 bits per pixel */
|
|
|
|
2, ~0, ~0, ~0, /* 8 bits per pixel */
|
|
|
|
~0,~0, ~0, ~0,
|
|
|
|
3, ~0, ~0, ~0, /* 16 bits per pixel */
|
|
|
|
~0,~0, ~0, ~0,
|
|
|
|
4, ~0, ~0, ~0, /* 24 bits per pixel */
|
|
|
|
~0,~0, ~0, ~0,
|
|
|
|
5 /* 32 bits per pixel */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This array gives the bytesperPixel value for cases where the number
|
|
|
|
* of bits per pixel is a multiple of 8 but not a power of 2.
|
|
|
|
*/
|
|
|
|
static int answerBytesPerPixel[ 33 ] = {
|
|
|
|
~0, 0, ~0, ~0, /* 1 bit per pixel */
|
|
|
|
0, ~0, ~0, ~0, /* 4 bits per pixel */
|
|
|
|
0, ~0, ~0, ~0, /* 8 bits per pixel */
|
|
|
|
~0,~0, ~0, ~0,
|
|
|
|
0, ~0, ~0, ~0, /* 16 bits per pixel */
|
|
|
|
~0,~0, ~0, ~0,
|
|
|
|
3, ~0, ~0, ~0, /* 24 bits per pixel */
|
|
|
|
~0,~0, ~0, ~0,
|
|
|
|
0 /* 32 bits per pixel */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This array gives the answer to the question "what is the second index for
|
|
|
|
* the answer array above given the number of bits per scanline pad unit?"
|
|
|
|
* Note that ~0 is an invalid entry (mostly for the benefit of the reader).
|
|
|
|
*/
|
|
|
|
static int indexForScanlinePad[ 65 ] = {
|
|
|
|
~0, ~0, ~0, ~0,
|
|
|
|
~0, ~0, ~0, ~0,
|
|
|
|
0, ~0, ~0, ~0, /* 8 bits per scanline pad unit */
|
|
|
|
~0, ~0, ~0, ~0,
|
|
|
|
1, ~0, ~0, ~0, /* 16 bits per scanline pad unit */
|
|
|
|
~0, ~0, ~0, ~0,
|
|
|
|
~0, ~0, ~0, ~0,
|
|
|
|
~0, ~0, ~0, ~0,
|
|
|
|
2, ~0, ~0, ~0, /* 32 bits per scanline pad unit */
|
|
|
|
~0, ~0, ~0, ~0,
|
|
|
|
~0, ~0, ~0, ~0,
|
|
|
|
~0, ~0, ~0, ~0,
|
|
|
|
~0, ~0, ~0, ~0,
|
|
|
|
~0, ~0, ~0, ~0,
|
|
|
|
~0, ~0, ~0, ~0,
|
|
|
|
~0, ~0, ~0, ~0,
|
|
|
|
3 /* 64 bits per scanline pad unit */
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef MIN
|
|
|
|
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
grow the array of screenRecs if necessary.
|
|
|
|
call the device-supplied initialization procedure
|
|
|
|
with its screen number, a pointer to its ScreenRec, argc, and argv.
|
|
|
|
return the number of successfully installed screens.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
AddScreen(
|
|
|
|
Bool (* pfnInit)(
|
|
|
|
int /*index*/,
|
|
|
|
ScreenPtr /*pScreen*/,
|
|
|
|
int /*argc*/,
|
|
|
|
char ** /*argv*/
|
|
|
|
),
|
|
|
|
int argc,
|
|
|
|
char **argv)
|
|
|
|
{
|
|
|
|
|
|
|
|
int i;
|
|
|
|
int scanlinepad, format, depth, bitsPerPixel, j, k;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
|
|
|
|
i = screenInfo.numScreens;
|
|
|
|
if (i == MAXSCREENS)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
pScreen = (ScreenPtr) xcalloc(1, sizeof(ScreenRec));
|
|
|
|
if (!pScreen)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
pScreen->devPrivates = NULL;
|
|
|
|
pScreen->myNum = i;
|
|
|
|
pScreen->totalPixmapSize = BitmapBytePad(sizeof(PixmapRec)*8);
|
|
|
|
pScreen->ClipNotify = 0; /* for R4 ddx compatibility */
|
|
|
|
pScreen->CreateScreenResources = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This loop gets run once for every Screen that gets added,
|
|
|
|
* but thats ok. If the ddx layer initializes the formats
|
|
|
|
* one at a time calling AddScreen() after each, then each
|
|
|
|
* iteration will make it a little more accurate. Worst case
|
|
|
|
* we do this loop N * numPixmapFormats where N is # of screens.
|
|
|
|
* Anyway, this must be called after InitOutput and before the
|
|
|
|
* screen init routine is called.
|
|
|
|
*/
|
|
|
|
for (format=0; format<screenInfo.numPixmapFormats; format++)
|
|
|
|
{
|
|
|
|
depth = screenInfo.formats[format].depth;
|
|
|
|
bitsPerPixel = screenInfo.formats[format].bitsPerPixel;
|
|
|
|
scanlinepad = screenInfo.formats[format].scanlinePad;
|
|
|
|
j = indexForBitsPerPixel[ bitsPerPixel ];
|
|
|
|
k = indexForScanlinePad[ scanlinepad ];
|
|
|
|
PixmapWidthPaddingInfo[ depth ].padPixelsLog2 = answer[j][k];
|
|
|
|
PixmapWidthPaddingInfo[ depth ].padRoundUp =
|
|
|
|
(scanlinepad/bitsPerPixel) - 1;
|
|
|
|
j = indexForBitsPerPixel[ 8 ]; /* bits per byte */
|
|
|
|
PixmapWidthPaddingInfo[ depth ].padBytesLog2 = answer[j][k];
|
|
|
|
PixmapWidthPaddingInfo[ depth ].bitsPerPixel = bitsPerPixel;
|
|
|
|
if (answerBytesPerPixel[bitsPerPixel])
|
|
|
|
{
|
|
|
|
PixmapWidthPaddingInfo[ depth ].notPower2 = 1;
|
|
|
|
PixmapWidthPaddingInfo[ depth ].bytesPerPixel =
|
|
|
|
answerBytesPerPixel[bitsPerPixel];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PixmapWidthPaddingInfo[ depth ].notPower2 = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is where screen specific stuff gets initialized. Load the
|
|
|
|
screen structure, call the hardware, whatever.
|
|
|
|
This is also where the default colormap should be allocated and
|
|
|
|
also pixel values for blackPixel, whitePixel, and the cursor
|
|
|
|
Note that InitScreen is NOT allowed to modify argc, argv, or
|
|
|
|
any of the strings pointed to by argv. They may be passed to
|
|
|
|
multiple screens.
|
|
|
|
*/
|
|
|
|
pScreen->rgf = ~0L; /* there are no scratch GCs yet*/
|
|
|
|
WindowTable[i] = NullWindow;
|
|
|
|
screenInfo.screens[i] = pScreen;
|
|
|
|
screenInfo.numScreens++;
|
|
|
|
if (!(*pfnInit)(i, pScreen, argc, argv))
|
|
|
|
{
|
|
|
|
dixFreePrivates(pScreen->devPrivates);
|
|
|
|
xfree(pScreen);
|
|
|
|
screenInfo.numScreens--;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|