2006-11-26 11:13:41 -07: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
|
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
Permission to use, copy, modify, and distribute this software and its
|
|
|
|
documentation for any purpose and without fee is hereby granted,
|
2006-11-26 11:13:41 -07:00
|
|
|
provided that the above copyright notice appear in all copies and that
|
2015-09-16 13:10:19 -06:00
|
|
|
both that copyright notice and this permission notice appear in
|
2006-11-26 11:13:41 -07:00
|
|
|
supporting documentation, and that the name of Digital not be
|
|
|
|
used in advertising or publicity pertaining to distribution of the
|
2015-09-16 13:10:19 -06:00
|
|
|
software without specific, written prior permission.
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
|
|
|
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
|
|
|
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
|
|
|
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
|
|
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
|
|
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
|
|
SOFTWARE.
|
|
|
|
|
|
|
|
********************************************************/
|
|
|
|
|
|
|
|
/* The panoramix components contained the following notice */
|
|
|
|
/*****************************************************************
|
|
|
|
|
|
|
|
Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software.
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
|
|
|
|
BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
|
|
|
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
|
|
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
Except as contained in this notice, the name of Digital Equipment Corporation
|
|
|
|
shall not be used in advertising or otherwise to promote the sale, use or other
|
|
|
|
dealings in this Software without prior written authorization from Digital
|
|
|
|
Equipment Corporation.
|
|
|
|
|
|
|
|
******************************************************************/
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
/* XSERVER_DTRACE additions:
|
2011-11-05 07:32:40 -06:00
|
|
|
* Copyright (c) 2005-2006, Oracle and/or its affiliates. All rights reserved.
|
2007-11-24 10:55:21 -07:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
2010-07-27 13:02:24 -06:00
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
|
2007-11-24 10:55:21 -07:00
|
|
|
*/
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
2010-07-27 13:02:24 -06:00
|
|
|
#include <version-config.h>
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef PANORAMIX_DEBUG
|
|
|
|
#include <stdio.h>
|
|
|
|
int ProcInitialConnection();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "windowstr.h"
|
|
|
|
#include <X11/fonts/fontstruct.h>
|
|
|
|
#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"
|
|
|
|
#include "dispatch.h"
|
|
|
|
#include "swaprep.h"
|
|
|
|
#include "swapreq.h"
|
2008-11-02 08:26:08 -07:00
|
|
|
#include "privates.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
#include "xace.h"
|
|
|
|
#include "inputstr.h"
|
2010-07-27 13:02:24 -06:00
|
|
|
#include "xkbsrv.h"
|
|
|
|
#include "site.h"
|
2011-11-05 07:32:40 -06:00
|
|
|
#include "client.h"
|
2007-11-24 10:55:21 -07:00
|
|
|
|
|
|
|
#ifdef XSERVER_DTRACE
|
2008-11-02 08:26:08 -07:00
|
|
|
#include "registry.h"
|
2015-11-07 09:48:51 -07:00
|
|
|
#include "probes.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define mskcnt ((MAXCLIENTS + 31) / 32)
|
|
|
|
#define BITMASK(i) (1U << ((i) & 31))
|
|
|
|
#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))
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
xConnSetupPrefix connSetupPrefix;
|
|
|
|
|
|
|
|
PaddingInfo PixmapWidthPaddingInfo[33];
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static ClientPtr grabClient;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
#define GrabNone 0
|
|
|
|
#define GrabActive 1
|
|
|
|
#define GrabKickout 2
|
|
|
|
static int grabState = GrabNone;
|
|
|
|
static long grabWaiters[mskcnt];
|
2010-07-27 13:02:24 -06:00
|
|
|
CallbackListPtr ServerGrabCallback = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
HWEventQueuePtr checkForInput[2];
|
2010-07-27 13:02:24 -06:00
|
|
|
int connBlockScreenStart;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static void KillAllClients(void);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int nextFreeClientID; /* always MIN free client ID */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int nClients; /* number of authorized clients */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
CallbackListPtr ClientStateCallback;
|
2006-11-26 11:13:41 -07: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.
|
|
|
|
*/
|
2010-07-27 13:02:24 -06:00
|
|
|
volatile char dispatchException = 0;
|
|
|
|
volatile char isItTimeToYield;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#define SAME_SCREENS(a, b) (\
|
|
|
|
(a.pScreen == b.pScreen))
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
void
|
2006-11-26 11:13:41 -07:00
|
|
|
SetInputCheck(HWEventQueuePtr c0, HWEventQueuePtr c1)
|
|
|
|
{
|
|
|
|
checkForInput[0] = c0;
|
|
|
|
checkForInput[1] = c1;
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2007-11-24 10:55:21 -07:00
|
|
|
UpdateCurrentTime(void)
|
2006-11-26 11:13:41 -07: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)
|
2012-06-10 07:21:05 -06:00
|
|
|
systime.months++;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (*checkForInput[0] != *checkForInput[1])
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcessInputEvents();
|
2006-11-26 11:13:41 -07:00
|
|
|
if (CompareTimeStamps(systime, currentTime) == LATER)
|
2012-06-10 07:21:05 -06:00
|
|
|
currentTime = systime;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Like UpdateCurrentTime, but can't call ProcessInputEvents */
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2007-11-24 10:55:21 -07:00
|
|
|
UpdateCurrentTimeIf(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
TimeStamp systime;
|
|
|
|
|
|
|
|
systime.months = currentTime.months;
|
|
|
|
systime.milliseconds = GetTimeInMillis();
|
|
|
|
if (systime.milliseconds < currentTime.milliseconds)
|
2012-06-10 07:21:05 -06:00
|
|
|
systime.months++;
|
|
|
|
if (CompareTimeStamps(systime, currentTime) == LATER)
|
|
|
|
currentTime = systime;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef SMART_DEBUG
|
|
|
|
|
2014-05-02 13:27:46 -06:00
|
|
|
/* in milliseconds */
|
|
|
|
#define SMART_SCHEDULE_DEFAULT_INTERVAL 5
|
|
|
|
#define SMART_SCHEDULE_MAX_SLICE 15
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
#if defined(WIN32) && !defined(__CYGWIN__)
|
|
|
|
Bool SmartScheduleDisable = TRUE;
|
|
|
|
#else
|
2010-07-27 13:02:24 -06:00
|
|
|
Bool SmartScheduleDisable = FALSE;
|
2013-06-07 11:28:45 -06:00
|
|
|
#endif
|
2010-07-27 13:02:24 -06:00
|
|
|
long SmartScheduleSlice = SMART_SCHEDULE_DEFAULT_INTERVAL;
|
|
|
|
long SmartScheduleInterval = SMART_SCHEDULE_DEFAULT_INTERVAL;
|
|
|
|
long SmartScheduleMaxSlice = SMART_SCHEDULE_MAX_SLICE;
|
|
|
|
long SmartScheduleTime;
|
|
|
|
int SmartScheduleLatencyLimited = 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
static ClientPtr SmartLastClient;
|
|
|
|
static int SmartLastIndex[SMART_MAX_PRIORITY - SMART_MIN_PRIORITY + 1];
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#ifdef SMART_DEBUG
|
2012-06-10 07:21:05 -06:00
|
|
|
long SmartLastPrint;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
void Dispatch(void);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SmartScheduleClient(int *clientReady, int nready)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ClientPtr pClient;
|
|
|
|
int i;
|
|
|
|
int client;
|
|
|
|
int bestPrio, best = 0;
|
|
|
|
int bestRobin, robin;
|
|
|
|
long now = SmartScheduleTime;
|
|
|
|
long idle;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
bestPrio = -0x7fffffff;
|
|
|
|
bestRobin = 0;
|
|
|
|
idle = 2 * SmartScheduleSlice;
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < nready; i++) {
|
|
|
|
client = clientReady[i];
|
|
|
|
pClient = clients[client];
|
2014-09-27 11:52:59 -06:00
|
|
|
/* Praise clients which haven't run in a while */
|
|
|
|
if ((now - pClient->smart_stop_tick) >= idle) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pClient->smart_priority < 0)
|
|
|
|
pClient->smart_priority++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef SMART_DEBUG
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((now - SmartLastPrint) >= 5000)
|
|
|
|
fprintf(stderr, " %2d: %3d", client, pClient->smart_priority);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#ifdef SMART_DEBUG
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((now - SmartLastPrint) >= 5000) {
|
|
|
|
fprintf(stderr, " use %2d\n", best);
|
|
|
|
SmartLastPrint = now;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
pClient = clients[best];
|
2012-06-10 07:21:05 -06:00
|
|
|
SmartLastIndex[bestPrio - SMART_MIN_PRIORITY] = pClient->index;
|
2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
* Set current client pointer
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
if (SmartLastClient != pClient) {
|
|
|
|
pClient->smart_start_tick = now;
|
|
|
|
SmartLastClient = pClient;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Adjust slice
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
if (nready == 1 && SmartScheduleLatencyLimited == 0) {
|
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
SmartScheduleSlice = SmartScheduleInterval;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return best;
|
|
|
|
}
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
void
|
|
|
|
EnableLimitedSchedulingLatency(void)
|
|
|
|
{
|
|
|
|
++SmartScheduleLatencyLimited;
|
|
|
|
SmartScheduleSlice = SmartScheduleInterval;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisableLimitedSchedulingLatency(void)
|
|
|
|
{
|
|
|
|
--SmartScheduleLatencyLimited;
|
|
|
|
|
|
|
|
/* protect against bugs */
|
|
|
|
if (SmartScheduleLatencyLimited < 0)
|
2012-06-10 07:21:05 -06:00
|
|
|
SmartScheduleLatencyLimited = 0;
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
Dispatch(void)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int *clientReady; /* array of request ready clients */
|
|
|
|
int result;
|
|
|
|
ClientPtr client;
|
|
|
|
int nready;
|
|
|
|
HWEventQueuePtr *icheck = checkForInput;
|
|
|
|
long start_tick;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
nextFreeClientID = 1;
|
|
|
|
nClients = 0;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
clientReady = malloc(sizeof(int) * MaxClients);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!clientReady)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
SmartScheduleSlice = SmartScheduleInterval;
|
2012-06-10 07:21:05 -06:00
|
|
|
while (!dispatchException) {
|
|
|
|
if (*icheck[0] != *icheck[1]) {
|
|
|
|
ProcessInputEvents();
|
|
|
|
FlushIfCriticalOutputPending();
|
|
|
|
}
|
|
|
|
|
|
|
|
nready = WaitForSomething(clientReady);
|
|
|
|
|
|
|
|
if (nready && !SmartScheduleDisable) {
|
|
|
|
clientReady[0] = SmartScheduleClient(clientReady, nready);
|
|
|
|
nready = 1;
|
|
|
|
}
|
2015-09-16 13:10:19 -06:00
|
|
|
/*****************
|
|
|
|
* Handle events in round robin fashion, doing input between
|
|
|
|
* each round
|
2006-11-26 11:13:41 -07:00
|
|
|
*****************/
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
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;
|
|
|
|
|
|
|
|
start_tick = SmartScheduleTime;
|
|
|
|
while (!isItTimeToYield) {
|
|
|
|
if (*icheck[0] != *icheck[1])
|
|
|
|
ProcessInputEvents();
|
|
|
|
|
|
|
|
FlushIfCriticalOutputPending();
|
|
|
|
if (!SmartScheduleDisable &&
|
|
|
|
(SmartScheduleTime - start_tick) >= SmartScheduleSlice) {
|
|
|
|
/* Penalize clients which consume ticks */
|
|
|
|
if (client->smart_priority > SMART_MIN_PRIORITY)
|
|
|
|
client->smart_priority--;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* now, finally, deal with client requests */
|
|
|
|
|
|
|
|
/* Update currentTime so request time checks, such as for input
|
|
|
|
* device grabs, are calculated correctly */
|
|
|
|
UpdateCurrentTimeIf();
|
|
|
|
result = ReadRequestFromClient(client);
|
|
|
|
if (result <= 0) {
|
|
|
|
if (result < 0)
|
|
|
|
CloseDownClient(client);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
client->sequence++;
|
|
|
|
client->majorOp = ((xReq *) client->requestBuffer)->reqType;
|
|
|
|
client->minorOp = 0;
|
|
|
|
if (client->majorOp >= EXTENSION_BASE) {
|
|
|
|
ExtensionEntry *ext = GetExtensionEntry(client->majorOp);
|
|
|
|
|
|
|
|
if (ext)
|
|
|
|
client->minorOp = ext->MinorOpcode(client);
|
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
#ifdef XSERVER_DTRACE
|
2012-06-10 07:21:05 -06:00
|
|
|
if (XSERVER_REQUEST_START_ENABLED())
|
|
|
|
XSERVER_REQUEST_START(LookupMajorName(client->majorOp),
|
|
|
|
client->majorOp,
|
|
|
|
((xReq *) client->requestBuffer)->length,
|
|
|
|
client->index,
|
|
|
|
client->requestBuffer);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
if (result > (maxBigRequestSize << 2))
|
|
|
|
result = BadLength;
|
|
|
|
else {
|
|
|
|
result = XaceHookDispatch(client, client->majorOp);
|
|
|
|
if (result == Success)
|
|
|
|
result =
|
|
|
|
(*client->requestVector[client->majorOp]) (client);
|
|
|
|
XaceHookAuditEnd(client, result);
|
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
#ifdef XSERVER_DTRACE
|
2012-06-10 07:21:05 -06:00
|
|
|
if (XSERVER_REQUEST_DONE_ENABLED())
|
|
|
|
XSERVER_REQUEST_DONE(LookupMajorName(client->majorOp),
|
|
|
|
client->majorOp, client->sequence,
|
|
|
|
client->index, result);
|
2007-11-24 10:55:21 -07:00
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (client->noClientException != Success) {
|
|
|
|
CloseDownClient(client);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (result != Success) {
|
|
|
|
SendErrorToClient(client, client->majorOp,
|
|
|
|
client->minorOp,
|
|
|
|
client->errorValue, result);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FlushAllOutput();
|
|
|
|
client = clients[clientReady[nready]];
|
|
|
|
if (client)
|
|
|
|
client->smart_stop_tick = SmartScheduleTime;
|
|
|
|
}
|
|
|
|
dispatchException &= ~DE_PRIORITYCHANGE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
#if defined(DDXBEFORERESET)
|
2012-06-10 07:21:05 -06:00
|
|
|
ddxBeforeReset();
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
KillAllClients();
|
2010-12-05 08:36:02 -07:00
|
|
|
free(clientReady);
|
2006-11-26 11:13:41 -07:00
|
|
|
dispatchException &= ~DE_RESET;
|
2009-09-06 13:44:18 -06:00
|
|
|
SmartScheduleLatencyLimited = 0;
|
2014-05-02 13:27:46 -06:00
|
|
|
ResetOsBuffers();
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int VendorRelease = VENDOR_RELEASE;
|
2014-09-27 11:52:59 -06:00
|
|
|
static const char *VendorString = VENDOR_NAME;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
void
|
|
|
|
SetVendorRelease(int release)
|
|
|
|
{
|
|
|
|
VendorRelease = release;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-09-27 11:52:59 -06:00
|
|
|
SetVendorString(const char *vendor)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
2014-09-27 11:52:59 -06:00
|
|
|
VendorString = vendor;
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
|
|
|
CreateConnectionBlock(void)
|
|
|
|
{
|
|
|
|
xConnSetup setup;
|
|
|
|
xWindowRoot root;
|
2012-06-10 07:21:05 -06:00
|
|
|
xDepth depth;
|
2010-07-27 13:02:24 -06:00
|
|
|
xVisualType visual;
|
|
|
|
xPixmapFormat format;
|
|
|
|
unsigned long vid;
|
2012-06-10 07:21:05 -06:00
|
|
|
int i, j, k, lenofblock, sizesofar = 0;
|
2010-07-27 13:02:24 -06:00
|
|
|
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) +
|
2012-06-10 07:21:05 -06:00
|
|
|
pad_to_int32(setup.nbytesVendor) +
|
|
|
|
(setup.numFormats * sizeof(xPixmapFormat)) +
|
|
|
|
(setup.numRoots * sizeof(xWindowRoot));
|
2010-12-05 08:36:02 -07:00
|
|
|
ConnectionInfo = malloc(lenofblock);
|
2010-07-27 13:02:24 -06:00
|
|
|
if (!ConnectionInfo)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
memmove(ConnectionInfo, (char *) &setup, sizeof(xConnSetup));
|
2010-07-27 13:02:24 -06:00
|
|
|
sizesofar = sizeof(xConnSetup);
|
|
|
|
pBuf = ConnectionInfo + sizeof(xConnSetup);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
memmove(pBuf, VendorString, (int) setup.nbytesVendor);
|
2010-07-27 13:02:24 -06:00
|
|
|
sizesofar += setup.nbytesVendor;
|
|
|
|
pBuf += setup.nbytesVendor;
|
2013-06-07 11:28:45 -06:00
|
|
|
i = padding_for_int32(setup.nbytesVendor);
|
2010-07-27 13:02:24 -06:00
|
|
|
sizesofar += i;
|
|
|
|
while (--i >= 0)
|
2012-06-10 07:21:05 -06:00
|
|
|
*pBuf++ = 0;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
memset(&format, 0, sizeof(xPixmapFormat));
|
2012-06-10 07:21:05 -06:00
|
|
|
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);
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
connBlockScreenStart = sizesofar;
|
|
|
|
memset(&depth, 0, sizeof(xDepth));
|
|
|
|
memset(&visual, 0, sizeof(xVisualType));
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < screenInfo.numScreens; i++) {
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
DepthPtr pDepth;
|
|
|
|
VisualPtr pVisual;
|
|
|
|
|
|
|
|
pScreen = screenInfo.screens[i];
|
|
|
|
root.windowId = pScreen->root->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 *) realloc(ConnectionInfo, lenofblock);
|
|
|
|
if (!pBuf) {
|
|
|
|
free(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);
|
|
|
|
}
|
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
|
|
|
connSetupPrefix.success = xTrue;
|
2012-06-10 07:21:05 -06:00
|
|
|
connSetupPrefix.length = lenofblock / 4;
|
2010-07-27 13:02:24 -06:00
|
|
|
connSetupPrefix.majorVersion = X_PROTOCOL;
|
|
|
|
connSetupPrefix.minorVersion = X_PROTOCOL_REVISION;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2006-11-26 11:13:41 -07:00
|
|
|
ProcBadRequest(ClientPtr client)
|
|
|
|
{
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadRequest;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ProcCreateWindow(ClientPtr client)
|
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pParent, pWin;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xCreateWindowReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
int len, rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xCreateWindowReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
LEGAL_NEW_RESOURCE(stuff->wid, client);
|
2008-11-02 08:26:08 -07:00
|
|
|
rc = dixLookupWindow(&pParent, stuff->parent, client, DixAddAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2010-07-27 13:02:24 -06:00
|
|
|
len = client->req_len - bytes_to_int32(sizeof(xCreateWindowReq));
|
2006-11-26 11:13:41 -07:00
|
|
|
if (Ones(stuff->mask) != len)
|
|
|
|
return BadLength;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!stuff->width || !stuff->height) {
|
|
|
|
client->errorValue = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
pWin = CreateWindow(stuff->wid, pParent, stuff->x,
|
2012-06-10 07:21:05 -06:00
|
|
|
stuff->y, stuff->width, stuff->height,
|
|
|
|
stuff->borderWidth, stuff->class,
|
|
|
|
stuff->mask, (XID *) &stuff[1],
|
|
|
|
(int) stuff->depth, client, stuff->visual, &rc);
|
|
|
|
if (pWin) {
|
|
|
|
Mask mask = pWin->eventMask;
|
|
|
|
|
|
|
|
pWin->eventMask = 0; /* subterfuge in case AddResource fails */
|
2014-09-27 11:52:59 -06:00
|
|
|
if (!AddResource(stuff->wid, RT_WINDOW, (void *) pWin))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadAlloc;
|
|
|
|
pWin->eventMask = mask;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcChangeWindowAttributes(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pWin;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xChangeWindowAttributesReq);
|
2010-12-05 08:36:02 -07:00
|
|
|
int len, rc;
|
2008-11-02 08:26:08 -07:00
|
|
|
Mask access_mode = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
access_mode |= (stuff->valueMask & CWEventMask) ? DixReceiveAccess : 0;
|
|
|
|
access_mode |= (stuff->valueMask & ~CWEventMask) ? DixSetAttrAccess : 0;
|
|
|
|
rc = dixLookupWindow(&pWin, stuff->window, client, access_mode);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2010-07-27 13:02:24 -06:00
|
|
|
len = client->req_len - bytes_to_int32(sizeof(xChangeWindowAttributesReq));
|
2006-11-26 11:13:41 -07:00
|
|
|
if (len != Ones(stuff->valueMask))
|
|
|
|
return BadLength;
|
2010-12-05 08:36:02 -07:00
|
|
|
return ChangeWindowAttributes(pWin,
|
2012-06-10 07:21:05 -06:00
|
|
|
stuff->valueMask, (XID *) &stuff[1], client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcGetWindowAttributes(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pWin;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xResourceReq);
|
|
|
|
xGetWindowAttributesReply wa;
|
2007-11-24 10:55:21 -07:00
|
|
|
int rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2010-07-27 13:02:24 -06:00
|
|
|
memset(&wa, 0, sizeof(xGetWindowAttributesReply));
|
2006-11-26 11:13:41 -07:00
|
|
|
GetWindowAttributes(pWin, client, &wa);
|
|
|
|
WriteReplyToClient(client, sizeof(xGetWindowAttributesReply), &wa);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcDestroyWindow(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pWin;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xResourceReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
int rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->id, client, DixDestroyAccess);
|
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2008-11-02 08:26:08 -07:00
|
|
|
if (pWin->parent) {
|
2012-06-10 07:21:05 -06:00
|
|
|
rc = dixLookupWindow(&pWin, pWin->parent->drawable.id, client,
|
|
|
|
DixRemoveAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
FreeResource(stuff->id, RT_NONE);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcDestroySubwindows(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pWin;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xResourceReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
int rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->id, client, DixRemoveAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
DestroySubwindows(pWin, client);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcChangeSaveSet(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pWin;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xChangeSaveSetReq);
|
2010-12-05 08:36:02 -07:00
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xChangeSaveSetReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->window, client, DixManageAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (client->clientAsMask == (CLIENT_BITS(pWin->drawable.id)))
|
|
|
|
return BadMatch;
|
|
|
|
if ((stuff->mode == SetModeInsert) || (stuff->mode == SetModeDelete))
|
2010-12-05 08:36:02 -07:00
|
|
|
return AlterSaveSetForClient(client, pWin, stuff->mode, FALSE, TRUE);
|
|
|
|
client->errorValue = stuff->mode;
|
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcReparentWindow(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pWin, pParent;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xReparentWindowReq);
|
2010-12-05 08:36:02 -07:00
|
|
|
int rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xReparentWindowReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->window, client, DixManageAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2008-11-02 08:26:08 -07:00
|
|
|
rc = dixLookupWindow(&pParent, stuff->parent, client, DixAddAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2010-12-05 08:36:02 -07:00
|
|
|
if (!SAME_SCREENS(pWin->drawable, pParent->drawable))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadMatch;
|
2010-12-05 08:36:02 -07:00
|
|
|
if ((pWin->backgroundState == ParentRelative) &&
|
2012-06-10 07:21:05 -06:00
|
|
|
(pParent->drawable.depth != pWin->drawable.depth))
|
|
|
|
return BadMatch;
|
2010-12-05 08:36:02 -07:00
|
|
|
if ((pWin->drawable.class != InputOnly) &&
|
2012-06-10 07:21:05 -06:00
|
|
|
(pParent->drawable.class == InputOnly))
|
|
|
|
return BadMatch;
|
2010-12-05 08:36:02 -07:00
|
|
|
return ReparentWindow(pWin, pParent,
|
2012-06-10 07:21:05 -06:00
|
|
|
(short) stuff->x, (short) stuff->y, client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcMapWindow(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pWin;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xResourceReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
int rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->id, client, DixShowAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
MapWindow(pWin, client);
|
2012-06-10 07:21:05 -06:00
|
|
|
/* update cache to say it is mapped */
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcMapSubwindows(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pWin;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xResourceReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
int rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->id, client, DixListAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
MapSubwindows(pWin, client);
|
2012-06-10 07:21:05 -06:00
|
|
|
/* update cache to say it is mapped */
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcUnmapWindow(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pWin;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xResourceReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
int rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->id, client, DixHideAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
UnmapWindow(pWin, FALSE);
|
2012-06-10 07:21:05 -06:00
|
|
|
/* update cache to say it is mapped */
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcUnmapSubwindows(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pWin;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xResourceReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
int rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->id, client, DixListAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
UnmapSubwindows(pWin);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcConfigureWindow(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pWin;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xConfigureWindowReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
int len, rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xConfigureWindowReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->window, client,
|
2012-06-10 07:21:05 -06:00
|
|
|
DixManageAccess | DixSetAttrAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2010-07-27 13:02:24 -06:00
|
|
|
len = client->req_len - bytes_to_int32(sizeof(xConfigureWindowReq));
|
2012-06-10 07:21:05 -06:00
|
|
|
if (Ones((Mask) stuff->mask) != len)
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadLength;
|
2012-06-10 07:21:05 -06:00
|
|
|
return ConfigureWindow(pWin, (Mask) stuff->mask, (XID *) &stuff[1], client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcCirculateWindow(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pWin;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xCirculateWindowReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
int rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xCirculateWindowReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((stuff->direction != RaiseLowest) && (stuff->direction != LowerHighest)) {
|
|
|
|
client->errorValue = stuff->direction;
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->window, client, DixManageAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
CirculateWindow(pWin, (int) stuff->direction, client);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
GetGeometry(ClientPtr client, xGetGeometryReply * rep)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
DrawablePtr pDraw;
|
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xResourceReq);
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
rc = dixLookupDrawable(&pDraw, stuff->id, client, M_ANY, DixGetAttrAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
rep->type = X_Reply;
|
|
|
|
rep->length = 0;
|
|
|
|
rep->sequenceNumber = client->sequence;
|
2010-12-05 08:36:02 -07:00
|
|
|
rep->root = pDraw->pScreen->root->drawable.id;
|
2006-11-26 11:13:41 -07:00
|
|
|
rep->depth = pDraw->depth;
|
|
|
|
rep->width = pDraw->width;
|
|
|
|
rep->height = pDraw->height;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (WindowDrawable(pDraw->type)) {
|
|
|
|
WindowPtr pWin = (WindowPtr) pDraw;
|
|
|
|
|
|
|
|
rep->x = pWin->origin.x - wBorderWidth(pWin);
|
|
|
|
rep->y = pWin->origin.y - wBorderWidth(pWin);
|
|
|
|
rep->borderWidth = pWin->borderWidth;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else { /* DRAWABLE_PIXMAP */
|
|
|
|
|
|
|
|
rep->x = rep->y = rep->borderWidth = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcGetGeometry(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2013-06-07 11:28:45 -06:00
|
|
|
xGetGeometryReply rep = { .type = X_Reply };
|
2006-11-26 11:13:41 -07:00
|
|
|
int status;
|
|
|
|
|
|
|
|
if ((status = GetGeometry(client, &rep)) != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
WriteReplyToClient(client, sizeof(xGetGeometryReply), &rep);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcQueryTree(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
xQueryTreeReply reply;
|
2007-11-24 10:55:21 -07:00
|
|
|
int rc, numChildren = 0;
|
|
|
|
WindowPtr pChild, pWin, pHead;
|
2012-06-10 07:21:05 -06:00
|
|
|
Window *childIDs = (Window *) NULL;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xResourceReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->id, client, DixListAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2013-06-07 11:28:45 -06:00
|
|
|
|
|
|
|
reply = (xQueryTreeReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.root = pWin->drawable.pScreen->root->drawable.id,
|
|
|
|
.parent = (pWin->parent) ? pWin->parent->drawable.id : (Window) None
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
pHead = RealChildHead(pWin);
|
|
|
|
for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
|
2012-06-10 07:21:05 -06:00
|
|
|
numChildren++;
|
|
|
|
if (numChildren) {
|
|
|
|
int curChild = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
childIDs = malloc(numChildren * sizeof(Window));
|
|
|
|
if (!childIDs)
|
|
|
|
return BadAlloc;
|
|
|
|
for (pChild = pWin->lastChild; pChild != pHead;
|
|
|
|
pChild = pChild->prevSib)
|
|
|
|
childIDs[curChild++] = pChild->drawable.id;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
reply.nChildren = numChildren;
|
2010-07-27 13:02:24 -06:00
|
|
|
reply.length = bytes_to_int32(numChildren * sizeof(Window));
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
WriteReplyToClient(client, sizeof(xQueryTreeReply), &reply);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (numChildren) {
|
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
|
|
|
|
WriteSwappedDataToClient(client, numChildren * sizeof(Window),
|
|
|
|
childIDs);
|
|
|
|
free(childIDs);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcInternAtom(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
Atom atom;
|
|
|
|
char *tchar;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xInternAtomReq);
|
|
|
|
|
|
|
|
REQUEST_FIXED_SIZE(xInternAtomReq, stuff->nbytes);
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((stuff->onlyIfExists != xTrue) && (stuff->onlyIfExists != xFalse)) {
|
|
|
|
client->errorValue = stuff->onlyIfExists;
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
tchar = (char *) &stuff[1];
|
|
|
|
atom = MakeAtom(tchar, stuff->nbytes, !stuff->onlyIfExists);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (atom != BAD_RESOURCE) {
|
2013-06-07 11:28:45 -06:00
|
|
|
xInternAtomReply reply = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.atom = atom
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteReplyToClient(client, sizeof(xInternAtomReply), &reply);
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcGetAtomName(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2010-07-27 13:02:24 -06:00
|
|
|
const char *str;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xResourceReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((str = NameForAtom(stuff->id))) {
|
2013-06-07 11:28:45 -06:00
|
|
|
int len = strlen(str);
|
|
|
|
xGetAtomNameReply reply = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = bytes_to_int32(len),
|
|
|
|
.nameLength = len
|
|
|
|
};
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteReplyToClient(client, sizeof(xGetAtomNameReply), &reply);
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, len, str);
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
client->errorValue = stuff->id;
|
|
|
|
return BadAtom;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcGrabServer(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (grabState != GrabNone && client != grabClient) {
|
|
|
|
ResetCurrentRequest(client);
|
|
|
|
client->sequence--;
|
|
|
|
BITSET(grabWaiters, client->index);
|
|
|
|
IgnoreClient(client);
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
rc = OnlyListenToOneClient(client);
|
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
grabState = GrabKickout;
|
|
|
|
grabClient = client;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (ServerGrabCallback) {
|
|
|
|
ServerGrabInfoRec grabinfo;
|
|
|
|
|
|
|
|
grabinfo.client = client;
|
|
|
|
grabinfo.grabstate = SERVER_GRABBED;
|
2014-09-27 11:52:59 -06:00
|
|
|
CallCallbacks(&ServerGrabCallback, (void *) &grabinfo);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
UngrabServer(ClientPtr client)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
grabState = GrabNone;
|
|
|
|
ListenToAllClients();
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = mskcnt; --i >= 0 && !grabWaiters[i];);
|
|
|
|
if (i >= 0) {
|
|
|
|
i <<= 5;
|
|
|
|
while (!GETBIT(grabWaiters, i))
|
|
|
|
i++;
|
|
|
|
BITCLEAR(grabWaiters, i);
|
|
|
|
AttendClient(clients[i]);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (ServerGrabCallback) {
|
|
|
|
ServerGrabInfoRec grabinfo;
|
|
|
|
|
|
|
|
grabinfo.client = client;
|
|
|
|
grabinfo.grabstate = SERVER_UNGRABBED;
|
2014-09-27 11:52:59 -06:00
|
|
|
CallCallbacks(&ServerGrabCallback, (void *) &grabinfo);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcUngrabServer(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST_SIZE_MATCH(xReq);
|
|
|
|
UngrabServer(client);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcTranslateCoords(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xTranslateCoordsReq);
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pWin, pDst;
|
2006-11-26 11:13:41 -07:00
|
|
|
xTranslateCoordsReply rep;
|
2007-11-24 10:55:21 -07:00
|
|
|
int rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xTranslateCoordsReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->srcWid, client, DixGetAttrAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2008-11-02 08:26:08 -07:00
|
|
|
rc = dixLookupWindow(&pDst, stuff->dstWid, client, DixGetAttrAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2013-06-07 11:28:45 -06:00
|
|
|
|
|
|
|
rep = (xTranslateCoordsReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!SAME_SCREENS(pWin->drawable, pDst->drawable)) {
|
|
|
|
rep.sameScreen = xFalse;
|
2006-11-26 11:13:41 -07:00
|
|
|
rep.child = None;
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.dstX = rep.dstY = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
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) ||
|
|
|
|
RegionContainsPoint(&pWin->borderSize, x, y, &box))
|
|
|
|
|
|
|
|
&& (!wInputShape(pWin) ||
|
|
|
|
RegionContainsPoint(wInputShape(pWin),
|
|
|
|
x - pWin->drawable.x,
|
|
|
|
y - pWin->drawable.y, &box))
|
|
|
|
) {
|
|
|
|
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;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcOpenFont(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int err;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
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,
|
2012-06-10 07:21:05 -06:00
|
|
|
stuff->nbytes, (char *) &stuff[1]);
|
|
|
|
if (err == Success) {
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
return err;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcCloseFont(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
FontPtr pFont;
|
2010-07-27 13:02:24 -06:00
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xResourceReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &pFont, stuff->id, RT_FONT,
|
2012-06-10 07:21:05 -06:00
|
|
|
client, DixDestroyAccess);
|
|
|
|
if (rc == Success) {
|
2006-11-26 11:13:41 -07:00
|
|
|
FreeResource(stuff->id, RT_NONE);
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
client->errorValue = stuff->id;
|
2010-12-05 08:36:02 -07:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcQueryFont(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
xQueryFontReply *reply;
|
2006-11-26 11:13:41 -07:00
|
|
|
FontPtr pFont;
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xResourceReq);
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
rc = dixLookupFontable(&pFont, stuff->id, client, DixGetAttrAccess);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
{
|
2012-06-10 07:21:05 -06: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);
|
|
|
|
reply = calloc(1, rlength);
|
|
|
|
if (!reply) {
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
reply->type = X_Reply;
|
|
|
|
reply->length = bytes_to_int32(rlength - sizeof(xGenericReply));
|
|
|
|
reply->sequenceNumber = client->sequence;
|
|
|
|
QueryFont(pFont, reply, nprotoxcistructs);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
WriteReplyToClient(client, rlength, reply);
|
2012-06-10 07:21:05 -06:00
|
|
|
free(reply);
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcQueryTextExtents(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
xQueryTextExtentsReply reply;
|
|
|
|
FontPtr pFont;
|
|
|
|
ExtentInfoRec info;
|
|
|
|
unsigned long length;
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
REQUEST(xQueryTextExtentsReq);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_AT_LEAST_SIZE(xQueryTextExtentsReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
rc = dixLookupFontable(&pFont, stuff->fid, client, DixGetAttrAccess);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
length = client->req_len - bytes_to_int32(sizeof(xQueryTextExtentsReq));
|
2006-11-26 11:13:41 -07:00
|
|
|
length = length << 1;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->oddLength) {
|
|
|
|
if (length == 0)
|
|
|
|
return BadLength;
|
2006-11-26 11:13:41 -07:00
|
|
|
length--;
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!QueryTextExtents(pFont, length, (unsigned char *) &stuff[1], &info))
|
|
|
|
return BadAlloc;
|
2013-06-07 11:28:45 -06:00
|
|
|
reply = (xQueryTextExtentsReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.drawDirection = info.drawDirection,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.fontAscent = info.fontAscent,
|
|
|
|
.fontDescent = info.fontDescent,
|
|
|
|
.overallAscent = info.overallAscent,
|
|
|
|
.overallDescent = info.overallDescent,
|
|
|
|
.overallWidth = info.overallWidth,
|
|
|
|
.overallLeft = info.overallLeft,
|
|
|
|
.overallRight = info.overallRight
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
WriteReplyToClient(client, sizeof(xQueryTextExtentsReply), &reply);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcListFonts(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xListFontsReq);
|
|
|
|
|
|
|
|
REQUEST_FIXED_SIZE(xListFontsReq, stuff->nbytes);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return ListFonts(client, (unsigned char *) &stuff[1], stuff->nbytes,
|
|
|
|
stuff->maxNames);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcListFontsWithInfo(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xListFontsWithInfoReq);
|
|
|
|
|
|
|
|
REQUEST_FIXED_SIZE(xListFontsWithInfoReq, stuff->nbytes);
|
|
|
|
|
|
|
|
return StartListFontsWithInfo(client, stuff->nbytes,
|
2012-06-10 07:21:05 -06:00
|
|
|
(unsigned char *) &stuff[1], stuff->maxNames);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* \param value must conform to DeleteType
|
|
|
|
*/
|
|
|
|
int
|
2014-09-27 11:52:59 -06:00
|
|
|
dixDestroyPixmap(void *value, XID pid)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
PixmapPtr pPixmap = (PixmapPtr) value;
|
|
|
|
|
|
|
|
return (*pPixmap->drawable.pScreen->DestroyPixmap) (pPixmap);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcCreatePixmap(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
PixmapPtr pMap;
|
2007-11-24 10:55:21 -07:00
|
|
|
DrawablePtr pDraw;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xCreatePixmapReq);
|
|
|
|
DepthPtr pDepth;
|
2007-11-24 10:55:21 -07:00
|
|
|
int i, rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xCreatePixmapReq);
|
|
|
|
client->errorValue = stuff->pid;
|
|
|
|
LEGAL_NEW_RESOURCE(stuff->pid, client);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, M_ANY,
|
2012-06-10 07:21:05 -06:00
|
|
|
DixGetAttrAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!stuff->width || !stuff->height) {
|
|
|
|
client->errorValue = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
|
|
|
}
|
2012-06-10 07:21:05 -06: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;
|
|
|
|
}
|
|
|
|
if (stuff->depth != 1) {
|
2006-11-26 11:13:41 -07:00
|
|
|
pDepth = pDraw->pScreen->allowedDepths;
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < pDraw->pScreen->numDepths; i++, pDepth++)
|
|
|
|
if (pDepth->depth == stuff->depth)
|
|
|
|
goto CreatePmap;
|
|
|
|
client->errorValue = stuff->depth;
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
CreatePmap:
|
|
|
|
pMap = (PixmapPtr) (*pDraw->pScreen->CreatePixmap)
|
|
|
|
(pDraw->pScreen, stuff->width, stuff->height, stuff->depth, 0);
|
|
|
|
if (pMap) {
|
|
|
|
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
|
|
|
|
pMap->drawable.id = stuff->pid;
|
|
|
|
/* security creation/labeling check */
|
|
|
|
rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, RT_PIXMAP,
|
|
|
|
pMap, RT_NONE, NULL, DixCreateAccess);
|
|
|
|
if (rc != Success) {
|
|
|
|
(*pDraw->pScreen->DestroyPixmap) (pMap);
|
|
|
|
return rc;
|
|
|
|
}
|
2014-09-27 11:52:59 -06:00
|
|
|
if (AddResource(stuff->pid, RT_PIXMAP, (void *) pMap))
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcFreePixmap(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
PixmapPtr pMap;
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xResourceReq);
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &pMap, stuff->id, RT_PIXMAP,
|
2012-06-10 07:21:05 -06:00
|
|
|
client, DixDestroyAccess);
|
|
|
|
if (rc == Success) {
|
|
|
|
FreeResource(stuff->id, RT_NONE);
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
client->errorValue = stuff->id;
|
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcCreateGC(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
int error, rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
GC *pGC;
|
2007-11-24 10:55:21 -07:00
|
|
|
DrawablePtr pDraw;
|
2006-11-26 11:13:41 -07:00
|
|
|
unsigned len;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xCreateGCReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xCreateGCReq);
|
|
|
|
client->errorValue = stuff->gc;
|
|
|
|
LEGAL_NEW_RESOURCE(stuff->gc, client);
|
2008-11-02 08:26:08 -07:00
|
|
|
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
|
2012-06-10 07:21:05 -06:00
|
|
|
DixGetAttrAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
len = client->req_len - bytes_to_int32(sizeof(xCreateGCReq));
|
2006-11-26 11:13:41 -07:00
|
|
|
if (len != Ones(stuff->mask))
|
|
|
|
return BadLength;
|
2012-06-10 07:21:05 -06:00
|
|
|
pGC = (GC *) CreateGC(pDraw, stuff->mask, (XID *) &stuff[1], &error,
|
|
|
|
stuff->gc, client);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (error != Success)
|
|
|
|
return error;
|
2014-09-27 11:52:59 -06:00
|
|
|
if (!AddResource(stuff->gc, RT_GC, (void *) pGC))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadAlloc;
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcChangeGC(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
GC *pGC;
|
|
|
|
int result;
|
|
|
|
unsigned len;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
REQUEST(xChangeGCReq);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_AT_LEAST_SIZE(xChangeGCReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
result = dixLookupGC(&pGC, stuff->gc, client, DixSetAttrAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (result != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return result;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
len = client->req_len - bytes_to_int32(sizeof(xChangeGCReq));
|
2006-11-26 11:13:41 -07:00
|
|
|
if (len != Ones(stuff->mask))
|
|
|
|
return BadLength;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return ChangeGCXIDs(client, pGC, stuff->mask, (CARD32 *) &stuff[1]);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcCopyGC(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
GC *dstGC;
|
|
|
|
GC *pGC;
|
2006-11-26 11:13:41 -07:00
|
|
|
int result;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xCopyGCReq);
|
|
|
|
REQUEST_SIZE_MATCH(xCopyGCReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
result = dixLookupGC(&pGC, stuff->srcGC, client, DixGetAttrAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (result != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return result;
|
2008-11-02 08:26:08 -07:00
|
|
|
result = dixLookupGC(&dstGC, stuff->dstGC, client, DixSetAttrAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (result != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return result;
|
2006-11-26 11:13:41 -07:00
|
|
|
if ((dstGC->pScreen != pGC->pScreen) || (dstGC->depth != pGC->depth))
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadMatch;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->mask & ~GCAllBits) {
|
|
|
|
client->errorValue = stuff->mask;
|
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
return CopyGC(pGC, dstGC, stuff->mask);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcSetDashes(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
GC *pGC;
|
2006-11-26 11:13:41 -07:00
|
|
|
int result;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xSetDashesReq);
|
|
|
|
|
|
|
|
REQUEST_FIXED_SIZE(xSetDashesReq, stuff->nDashes);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->nDashes == 0) {
|
|
|
|
client->errorValue = 0;
|
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
result = dixLookupGC(&pGC, stuff->gc, client, DixSetAttrAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (result != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return result;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
/* If there's an error, either there's no sensible errorValue,
|
|
|
|
* or there was a dash segment of 0. */
|
|
|
|
client->errorValue = 0;
|
|
|
|
return SetDashes(pGC, stuff->dashOffset, stuff->nDashes,
|
2012-06-10 07:21:05 -06:00
|
|
|
(unsigned char *) &stuff[1]);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcSetClipRectangles(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int nr, result;
|
2007-11-24 10:55:21 -07:00
|
|
|
GC *pGC;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xSetClipRectanglesReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq);
|
|
|
|
if ((stuff->ordering != Unsorted) && (stuff->ordering != YSorted) &&
|
2012-06-10 07:21:05 -06:00
|
|
|
(stuff->ordering != YXSorted) && (stuff->ordering != YXBanded)) {
|
|
|
|
client->errorValue = stuff->ordering;
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
result = dixLookupGC(&pGC, stuff->gc, client, DixSetAttrAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (result != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return result;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
nr = (client->req_len << 2) - sizeof(xSetClipRectanglesReq);
|
|
|
|
if (nr & 4)
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadLength;
|
2006-11-26 11:13:41 -07:00
|
|
|
nr >>= 3;
|
2010-12-05 08:36:02 -07:00
|
|
|
return SetClipRects(pGC, stuff->xOrigin, stuff->yOrigin,
|
2012-06-10 07:21:05 -06:00
|
|
|
nr, (xRectangle *) &stuff[1], (int) stuff->ordering);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcFreeGC(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
GC *pGC;
|
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xResourceReq);
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
|
|
|
|
rc = dixLookupGC(&pGC, stuff->id, client, DixDestroyAccess);
|
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
FreeResource(stuff->id, RT_NONE);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcClearToBackground(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xClearAreaReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pWin;
|
|
|
|
int rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xClearAreaReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pWin->drawable.class == InputOnly) {
|
|
|
|
client->errorValue = stuff->window;
|
|
|
|
return BadMatch;
|
|
|
|
}
|
|
|
|
if ((stuff->exposures != xTrue) && (stuff->exposures != xFalse)) {
|
|
|
|
client->errorValue = stuff->exposures;
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pWin->drawable.pScreen->ClearToBackground) (pWin, stuff->x, stuff->y,
|
|
|
|
stuff->width, stuff->height,
|
|
|
|
(Bool) stuff->exposures);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
/* send GraphicsExpose events, or a NoExpose event, based on the region */
|
|
|
|
void
|
|
|
|
SendGraphicsExpose(ClientPtr client, RegionPtr pRgn, XID drawable,
|
|
|
|
int major, int minor)
|
|
|
|
{
|
|
|
|
if (pRgn && !RegionNil(pRgn)) {
|
|
|
|
xEvent *pEvent;
|
|
|
|
xEvent *pe;
|
|
|
|
BoxPtr pBox;
|
|
|
|
int i;
|
|
|
|
int numRects;
|
|
|
|
|
|
|
|
numRects = RegionNumRects(pRgn);
|
|
|
|
pBox = RegionRects(pRgn);
|
|
|
|
if (!(pEvent = calloc(numRects, sizeof(xEvent))))
|
|
|
|
return;
|
|
|
|
pe = pEvent;
|
|
|
|
|
|
|
|
for (i = 1; i <= numRects; i++, pe++, pBox++) {
|
|
|
|
pe->u.u.type = GraphicsExpose;
|
|
|
|
pe->u.graphicsExposure.drawable = drawable;
|
|
|
|
pe->u.graphicsExposure.x = pBox->x1;
|
|
|
|
pe->u.graphicsExposure.y = pBox->y1;
|
|
|
|
pe->u.graphicsExposure.width = pBox->x2 - pBox->x1;
|
|
|
|
pe->u.graphicsExposure.height = pBox->y2 - pBox->y1;
|
|
|
|
pe->u.graphicsExposure.count = numRects - i;
|
|
|
|
pe->u.graphicsExposure.majorEvent = major;
|
|
|
|
pe->u.graphicsExposure.minorEvent = minor;
|
|
|
|
}
|
|
|
|
/* GraphicsExpose is a "critical event", which TryClientEvents
|
|
|
|
* handles specially. */
|
|
|
|
TryClientEvents(client, NULL, pEvent, numRects,
|
|
|
|
(Mask) 0, NoEventMask, NullGrab);
|
|
|
|
free(pEvent);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
xEvent event = {
|
|
|
|
.u.noExposure.drawable = drawable,
|
|
|
|
.u.noExposure.majorEvent = major,
|
|
|
|
.u.noExposure.minorEvent = minor
|
|
|
|
};
|
|
|
|
event.u.u.type = NoExpose;
|
|
|
|
WriteEventsToClient(client, 1, &event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcCopyArea(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
DrawablePtr pDst;
|
|
|
|
DrawablePtr pSrc;
|
|
|
|
GC *pGC;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xCopyAreaReq);
|
|
|
|
RegionPtr pRgn;
|
2007-11-24 10:55:21 -07:00
|
|
|
int rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xCopyAreaReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, DixWriteAccess);
|
|
|
|
if (stuff->dstDrawable != stuff->srcDrawable) {
|
|
|
|
rc = dixLookupDrawable(&pSrc, stuff->srcDrawable, client, 0,
|
|
|
|
DixReadAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
if ((pDst->pScreen != pSrc->pScreen) || (pDst->depth != pSrc->depth)) {
|
|
|
|
client->errorValue = stuff->dstDrawable;
|
|
|
|
return BadMatch;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
pSrc = pDst;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pRgn = (*pGC->ops->CopyArea) (pSrc, pDst, pGC, stuff->srcX, stuff->srcY,
|
|
|
|
stuff->width, stuff->height,
|
|
|
|
stuff->dstX, stuff->dstY);
|
|
|
|
if (pGC->graphicsExposures) {
|
2015-09-16 13:10:19 -06:00
|
|
|
SendGraphicsExpose(client, pRgn, stuff->dstDrawable, X_CopyArea, 0);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pRgn)
|
|
|
|
RegionDestroy(pRgn);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcCopyPlane(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
DrawablePtr psrcDraw, pdstDraw;
|
|
|
|
GC *pGC;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xCopyPlaneReq);
|
|
|
|
RegionPtr pRgn;
|
2007-11-24 10:55:21 -07:00
|
|
|
int rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xCopyPlaneReq);
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, DixWriteAccess);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->dstDrawable != stuff->srcDrawable) {
|
|
|
|
rc = dixLookupDrawable(&psrcDraw, stuff->srcDrawable, client, 0,
|
|
|
|
DixReadAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
if (pdstDraw->pScreen != psrcDraw->pScreen) {
|
|
|
|
client->errorValue = stuff->dstDrawable;
|
|
|
|
return BadMatch;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
psrcDraw = pdstDraw;
|
|
|
|
|
|
|
|
/* Check to see if stuff->bitPlane has exactly ONE good bit set */
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->bitPlane == 0 || (stuff->bitPlane & (stuff->bitPlane - 1)) ||
|
|
|
|
(stuff->bitPlane > (1L << (psrcDraw->depth - 1)))) {
|
|
|
|
client->errorValue = stuff->bitPlane;
|
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pRgn =
|
|
|
|
(*pGC->ops->CopyPlane) (psrcDraw, pdstDraw, pGC, stuff->srcX,
|
|
|
|
stuff->srcY, stuff->width, stuff->height,
|
|
|
|
stuff->dstX, stuff->dstY, stuff->bitPlane);
|
|
|
|
if (pGC->graphicsExposures) {
|
2015-09-16 13:10:19 -06:00
|
|
|
SendGraphicsExpose(client, pRgn, stuff->dstDrawable, X_CopyPlane, 0);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pRgn)
|
|
|
|
RegionDestroy(pRgn);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcPolyPoint(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
int npoint;
|
2007-11-24 10:55:21 -07:00
|
|
|
GC *pGC;
|
|
|
|
DrawablePtr pDraw;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xPolyPointReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xPolyPointReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((stuff->coordMode != CoordModeOrigin) &&
|
|
|
|
(stuff->coordMode != CoordModePrevious)) {
|
|
|
|
client->errorValue = stuff->coordMode;
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyPointReq));
|
2006-11-26 11:13:41 -07:00
|
|
|
if (npoint)
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pGC->ops->PolyPoint) (pDraw, pGC, stuff->coordMode, npoint,
|
|
|
|
(xPoint *) &stuff[1]);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcPolyLine(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
int npoint;
|
2007-11-24 10:55:21 -07:00
|
|
|
GC *pGC;
|
|
|
|
DrawablePtr pDraw;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xPolyLineReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xPolyLineReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((stuff->coordMode != CoordModeOrigin) &&
|
|
|
|
(stuff->coordMode != CoordModePrevious)) {
|
|
|
|
client->errorValue = stuff->coordMode;
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyLineReq));
|
2006-11-26 11:13:41 -07:00
|
|
|
if (npoint > 1)
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pGC->ops->Polylines) (pDraw, pGC, stuff->coordMode, npoint,
|
|
|
|
(DDXPointPtr) &stuff[1]);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcPolySegment(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
int nsegs;
|
2007-11-24 10:55:21 -07:00
|
|
|
GC *pGC;
|
|
|
|
DrawablePtr pDraw;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xPolySegmentReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xPolySegmentReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
nsegs = (client->req_len << 2) - sizeof(xPolySegmentReq);
|
|
|
|
if (nsegs & 4)
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadLength;
|
2006-11-26 11:13:41 -07:00
|
|
|
nsegs >>= 3;
|
|
|
|
if (nsegs)
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pGC->ops->PolySegment) (pDraw, pGC, nsegs, (xSegment *) &stuff[1]);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcPolyRectangle(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
int nrects;
|
2007-11-24 10:55:21 -07:00
|
|
|
GC *pGC;
|
|
|
|
DrawablePtr pDraw;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xPolyRectangleReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xPolyRectangleReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
nrects = (client->req_len << 2) - sizeof(xPolyRectangleReq);
|
|
|
|
if (nrects & 4)
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadLength;
|
2006-11-26 11:13:41 -07:00
|
|
|
nrects >>= 3;
|
|
|
|
if (nrects)
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pGC->ops->PolyRectangle) (pDraw, pGC,
|
|
|
|
nrects, (xRectangle *) &stuff[1]);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcPolyArc(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int narcs;
|
2007-11-24 10:55:21 -07:00
|
|
|
GC *pGC;
|
|
|
|
DrawablePtr pDraw;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xPolyArcReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xPolyArcReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
narcs = (client->req_len << 2) - sizeof(xPolyArcReq);
|
|
|
|
if (narcs % sizeof(xArc))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadLength;
|
2006-11-26 11:13:41 -07:00
|
|
|
narcs /= sizeof(xArc);
|
|
|
|
if (narcs)
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pGC->ops->PolyArc) (pDraw, pGC, narcs, (xArc *) &stuff[1]);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcFillPoly(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int things;
|
2007-11-24 10:55:21 -07:00
|
|
|
GC *pGC;
|
|
|
|
DrawablePtr pDraw;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xFillPolyReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xFillPolyReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((stuff->shape != Complex) && (stuff->shape != Nonconvex) &&
|
|
|
|
(stuff->shape != Convex)) {
|
|
|
|
client->errorValue = stuff->shape;
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((stuff->coordMode != CoordModeOrigin) &&
|
|
|
|
(stuff->coordMode != CoordModePrevious)) {
|
|
|
|
client->errorValue = stuff->coordMode;
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
things = bytes_to_int32((client->req_len << 2) - sizeof(xFillPolyReq));
|
2006-11-26 11:13:41 -07:00
|
|
|
if (things)
|
|
|
|
(*pGC->ops->FillPolygon) (pDraw, pGC, stuff->shape,
|
2012-06-10 07:21:05 -06:00
|
|
|
stuff->coordMode, things,
|
|
|
|
(DDXPointPtr) &stuff[1]);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcPolyFillRectangle(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int things;
|
2007-11-24 10:55:21 -07:00
|
|
|
GC *pGC;
|
|
|
|
DrawablePtr pDraw;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xPolyFillRectangleReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
things = (client->req_len << 2) - sizeof(xPolyFillRectangleReq);
|
|
|
|
if (things & 4)
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadLength;
|
2006-11-26 11:13:41 -07:00
|
|
|
things >>= 3;
|
|
|
|
|
|
|
|
if (things)
|
|
|
|
(*pGC->ops->PolyFillRect) (pDraw, pGC, things,
|
2012-06-10 07:21:05 -06:00
|
|
|
(xRectangle *) &stuff[1]);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcPolyFillArc(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int narcs;
|
2007-11-24 10:55:21 -07:00
|
|
|
GC *pGC;
|
|
|
|
DrawablePtr pDraw;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xPolyFillArcReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xPolyFillArcReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
narcs = (client->req_len << 2) - sizeof(xPolyFillArcReq);
|
|
|
|
if (narcs % sizeof(xArc))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadLength;
|
2006-11-26 11:13:41 -07:00
|
|
|
narcs /= sizeof(xArc);
|
|
|
|
if (narcs)
|
|
|
|
(*pGC->ops->PolyFillArc) (pDraw, pGC, narcs, (xArc *) &stuff[1]);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef MATCH_CLIENT_ENDIAN
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ServerOrder(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int whichbyte = 1;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (*((char *) &whichbyte))
|
2012-06-10 07:21:05 -06:00
|
|
|
return LSBFirst;
|
2006-11-26 11:13:41 -07:00
|
|
|
return MSBFirst;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ClientOrder(client) ((client)->swapped ? !ServerOrder() : ServerOrder())
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
ReformatImage(char *base, int nbytes, int bpp, int order)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
switch (bpp) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1: /* yuck */
|
|
|
|
if (BITMAP_BIT_ORDER != order)
|
|
|
|
BitOrderInvert((unsigned char *) base, nbytes);
|
2006-11-26 11:13:41 -07:00
|
|
|
#if IMAGE_BYTE_ORDER != BITMAP_BIT_ORDER && BITMAP_SCANLINE_UNIT != 8
|
2012-06-10 07:21:05 -06:00
|
|
|
ReformatImage(base, nbytes, BITMAP_SCANLINE_UNIT, order);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case 4:
|
2012-06-10 07:21:05 -06:00
|
|
|
break; /* yuck */
|
2006-11-26 11:13:41 -07:00
|
|
|
case 8:
|
2012-06-10 07:21:05 -06:00
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case 16:
|
2012-06-10 07:21:05 -06:00
|
|
|
if (IMAGE_BYTE_ORDER != order)
|
|
|
|
TwoByteSwap((unsigned char *) base, nbytes);
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case 32:
|
2012-06-10 07:21:05 -06:00
|
|
|
if (IMAGE_BYTE_ORDER != order)
|
|
|
|
FourByteSwap((unsigned char *) base, nbytes);
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define ReformatImage(b,n,bpp,o)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* 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-11-24 10:55:21 -07:00
|
|
|
ProcPutImage(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
GC *pGC;
|
|
|
|
DrawablePtr pDraw;
|
2012-06-10 07:21:05 -06:00
|
|
|
long length; /* length of scanline server padded */
|
|
|
|
long lengthProto; /* length of scanline protocol padded */
|
|
|
|
char *tmpImage;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xPutImageReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xPutImageReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->format == XYBitmap) {
|
2006-11-26 11:13:41 -07:00
|
|
|
if ((stuff->depth != 1) ||
|
2012-06-10 07:21:05 -06:00
|
|
|
(stuff->leftPad >= (unsigned int) screenInfo.bitmapScanlinePad))
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadMatch;
|
2012-06-10 07:21:05 -06:00
|
|
|
length = BitmapBytePad(stuff->width + stuff->leftPad);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else if (stuff->format == XYPixmap) {
|
|
|
|
if ((pDraw->depth != stuff->depth) ||
|
|
|
|
(stuff->leftPad >= (unsigned int) screenInfo.bitmapScanlinePad))
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadMatch;
|
2012-06-10 07:21:05 -06:00
|
|
|
length = BitmapBytePad(stuff->width + stuff->leftPad);
|
|
|
|
length *= stuff->depth;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else if (stuff->format == ZPixmap) {
|
2006-11-26 11:13:41 -07:00
|
|
|
if ((pDraw->depth != stuff->depth) || (stuff->leftPad != 0))
|
|
|
|
return BadMatch;
|
2012-06-10 07:21:05 -06:00
|
|
|
length = PixmapBytePad(stuff->width, stuff->depth);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
client->errorValue = stuff->format;
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
tmpImage = (char *) &stuff[1];
|
2006-11-26 11:13:41 -07:00
|
|
|
lengthProto = length;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2015-02-11 13:58:46 -07:00
|
|
|
if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
|
2014-12-09 10:58:52 -07:00
|
|
|
return BadLength;
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
if ((bytes_to_int32(lengthProto * stuff->height) +
|
2012-06-10 07:21:05 -06:00
|
|
|
bytes_to_int32(sizeof(xPutImageReq))) != client->req_len)
|
|
|
|
return BadLength;
|
|
|
|
|
|
|
|
ReformatImage(tmpImage, lengthProto * stuff->height,
|
|
|
|
stuff->format == ZPixmap ? BitsPerPixel(stuff->depth) : 1,
|
|
|
|
ClientOrder(client));
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
(*pGC->ops->PutImage) (pDraw, pGC, stuff->depth, stuff->dstX, stuff->dstY,
|
2012-06-10 07:21:05 -06:00
|
|
|
stuff->width, stuff->height,
|
|
|
|
stuff->leftPad, stuff->format, tmpImage);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
DoGetImage(ClientPtr client, int format, Drawable drawable,
|
|
|
|
int x, int y, int width, int height,
|
2014-05-02 13:27:46 -06:00
|
|
|
Mask planemask)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
DrawablePtr pDraw, pBoundingDraw;
|
|
|
|
int nlines, linesPerBuf, rc;
|
|
|
|
int linesDone;
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
/* coordinates relative to the bounding drawable */
|
2012-06-10 07:21:05 -06:00
|
|
|
int relx, rely;
|
|
|
|
long widthBytesLine, length;
|
|
|
|
Mask plane = 0;
|
|
|
|
char *pBuf;
|
|
|
|
xGetImageReply xgi;
|
2006-11-26 11:13:41 -07:00
|
|
|
RegionPtr pVisibleRegion = NULL;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((format != XYPixmap) && (format != ZPixmap)) {
|
|
|
|
client->errorValue = format;
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
rc = dixLookupDrawable(&pDraw, drawable, client, 0, DixReadAccess);
|
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
memset(&xgi, 0, sizeof(xGetImageReply));
|
|
|
|
|
|
|
|
relx = x;
|
|
|
|
rely = y;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pDraw->type == DRAWABLE_WINDOW) {
|
|
|
|
WindowPtr pWin = (WindowPtr) pDraw;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* "If the drawable is a window, the window must be viewable ... or a
|
|
|
|
* BadMatch error results" */
|
|
|
|
if (!pWin->viewable)
|
|
|
|
return BadMatch;
|
|
|
|
|
|
|
|
/* If the drawable is a window, the rectangle must be contained within
|
|
|
|
* its bounds (including the border). */
|
|
|
|
if (x < -wBorderWidth(pWin) ||
|
|
|
|
x + width > wBorderWidth(pWin) + (int) pDraw->width ||
|
|
|
|
y < -wBorderWidth(pWin) ||
|
|
|
|
y + height > wBorderWidth(pWin) + (int) pDraw->height)
|
|
|
|
return BadMatch;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
relx += pDraw->x;
|
|
|
|
rely += pDraw->y;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pDraw->pScreen->GetWindowPixmap) {
|
|
|
|
PixmapPtr pPix = (*pDraw->pScreen->GetWindowPixmap) (pWin);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pBoundingDraw = &pPix->drawable;
|
2010-07-27 13:02:24 -06:00
|
|
|
#ifdef COMPOSITE
|
2012-06-10 07:21:05 -06:00
|
|
|
relx -= pPix->screen_x;
|
|
|
|
rely -= pPix->screen_y;
|
2010-07-27 13:02:24 -06:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
pBoundingDraw = (DrawablePtr) pDraw->pScreen->root;
|
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
xgi.visual = wVisual(pWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
pBoundingDraw = pDraw;
|
|
|
|
xgi.visual = None;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
/* "If the drawable is a pixmap, the given rectangle must be wholly
|
|
|
|
* contained within the pixmap, or a BadMatch error results. If the
|
|
|
|
* drawable is a window [...] it must be the case that if there were no
|
|
|
|
* inferiors or overlapping windows, the specified rectangle of the window
|
|
|
|
* would be fully visible on the screen and wholly contained within the
|
|
|
|
* outside edges of the window, or a BadMatch error results."
|
|
|
|
*
|
|
|
|
* We relax the window case slightly to mean that the rectangle must exist
|
|
|
|
* within the bounds of the window's backing pixmap. In particular, this
|
|
|
|
* means that a GetImage request may succeed or fail with BadMatch depending
|
|
|
|
* on whether any of its ancestor windows are redirected. */
|
2012-06-10 07:21:05 -06:00
|
|
|
if (relx < 0 || relx + width > (int) pBoundingDraw->width ||
|
|
|
|
rely < 0 || rely + height > (int) pBoundingDraw->height)
|
|
|
|
return BadMatch;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
xgi.type = X_Reply;
|
|
|
|
xgi.sequenceNumber = client->sequence;
|
|
|
|
xgi.depth = pDraw->depth;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (format == ZPixmap) {
|
|
|
|
widthBytesLine = PixmapBytePad(width, pDraw->depth);
|
|
|
|
length = widthBytesLine * height;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
widthBytesLine = BitmapBytePad(width);
|
|
|
|
plane = ((Mask) 1) << (pDraw->depth - 1);
|
|
|
|
/* only planes asked for */
|
|
|
|
length = widthBytesLine * height *
|
|
|
|
Ones(planemask & (plane | (plane - 1)));
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
xgi.length = length;
|
|
|
|
|
2014-05-02 13:27:46 -06:00
|
|
|
xgi.length = bytes_to_int32(xgi.length);
|
|
|
|
if (widthBytesLine == 0 || height == 0)
|
|
|
|
linesPerBuf = 0;
|
|
|
|
else if (widthBytesLine >= IMAGE_BUFSIZE)
|
|
|
|
linesPerBuf = 1;
|
|
|
|
else {
|
|
|
|
linesPerBuf = IMAGE_BUFSIZE / widthBytesLine;
|
|
|
|
if (linesPerBuf > height)
|
2012-06-10 07:21:05 -06:00
|
|
|
linesPerBuf = height;
|
|
|
|
}
|
2014-05-02 13:27:46 -06:00
|
|
|
length = linesPerBuf * widthBytesLine;
|
|
|
|
if (linesPerBuf < height) {
|
|
|
|
/* we have to make sure intermediate buffers don't need padding */
|
|
|
|
while ((linesPerBuf > 1) &&
|
|
|
|
(length & ((1L << LOG2_BYTES_PER_SCANLINE_PAD) - 1))) {
|
|
|
|
linesPerBuf--;
|
|
|
|
length -= widthBytesLine;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
2014-05-02 13:27:46 -06:00
|
|
|
while (length & ((1L << LOG2_BYTES_PER_SCANLINE_PAD) - 1)) {
|
|
|
|
linesPerBuf++;
|
|
|
|
length += widthBytesLine;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2014-05-02 13:27:46 -06:00
|
|
|
if (!(pBuf = calloc(1, length)))
|
|
|
|
return BadAlloc;
|
|
|
|
WriteReplyToClient(client, sizeof(xGetImageReply), &xgi);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pDraw->type == DRAWABLE_WINDOW) {
|
|
|
|
pVisibleRegion = NotClippedByChildren((WindowPtr) pDraw);
|
|
|
|
if (pVisibleRegion) {
|
|
|
|
RegionTranslate(pVisibleRegion, -pDraw->x, -pDraw->y);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
if (linesPerBuf == 0) {
|
|
|
|
/* nothing to do */
|
|
|
|
}
|
|
|
|
else if (format == ZPixmap) {
|
2006-11-26 11:13:41 -07:00
|
|
|
linesDone = 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
while (height - linesDone > 0) {
|
|
|
|
nlines = min(linesPerBuf, height - linesDone);
|
|
|
|
(*pDraw->pScreen->GetImage) (pDraw,
|
|
|
|
x,
|
|
|
|
y + linesDone,
|
|
|
|
width,
|
|
|
|
nlines,
|
2014-09-27 11:52:59 -06:00
|
|
|
format, planemask, (void *) pBuf);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pVisibleRegion)
|
|
|
|
XaceCensorImage(client, pVisibleRegion, widthBytesLine,
|
|
|
|
pDraw, x, y + linesDone, width,
|
|
|
|
nlines, format, pBuf);
|
|
|
|
|
|
|
|
/* Note that this is NOT a call to WriteSwappedDataToClient,
|
2006-11-26 11:13:41 -07:00
|
|
|
as we do NOT byte swap */
|
2014-05-02 13:27:46 -06:00
|
|
|
ReformatImage(pBuf, (int) (nlines * widthBytesLine),
|
|
|
|
BitsPerPixel(pDraw->depth), ClientOrder(client));
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-05-02 13:27:46 -06:00
|
|
|
WriteToClient(client, (int) (nlines * widthBytesLine), pBuf);
|
2012-06-10 07:21:05 -06:00
|
|
|
linesDone += nlines;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
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,
|
2014-09-27 11:52:59 -06:00
|
|
|
format, plane, (void *) pBuf);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pVisibleRegion)
|
|
|
|
XaceCensorImage(client, pVisibleRegion,
|
|
|
|
widthBytesLine,
|
|
|
|
pDraw, x, y + linesDone, width,
|
|
|
|
nlines, format, pBuf);
|
|
|
|
|
|
|
|
/* Note: NOT a call to WriteSwappedDataToClient,
|
|
|
|
as we do NOT byte swap */
|
2014-05-02 13:27:46 -06:00
|
|
|
ReformatImage(pBuf, (int) (nlines * widthBytesLine),
|
|
|
|
1, ClientOrder(client));
|
|
|
|
|
|
|
|
WriteToClient(client, (int)(nlines * widthBytesLine), pBuf);
|
2012-06-10 07:21:05 -06:00
|
|
|
linesDone += nlines;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (pVisibleRegion)
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionDestroy(pVisibleRegion);
|
2014-05-02 13:27:46 -06:00
|
|
|
free(pBuf);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcGetImage(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xGetImageReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xGetImageReq);
|
|
|
|
|
|
|
|
return DoGetImage(client, stuff->format, stuff->drawable,
|
2012-06-10 07:21:05 -06:00
|
|
|
stuff->x, stuff->y,
|
|
|
|
(int) stuff->width, (int) stuff->height,
|
2014-05-02 13:27:46 -06:00
|
|
|
stuff->planeMask);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcPolyText(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int err;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xPolyTextReq);
|
|
|
|
DrawablePtr pDraw;
|
|
|
|
GC *pGC;
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xPolyTextReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
err = PolyText(client,
|
2012-06-10 07:21:05 -06:00
|
|
|
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 Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
return err;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcImageText8(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int err;
|
2007-11-24 10:55:21 -07:00
|
|
|
DrawablePtr pDraw;
|
|
|
|
GC *pGC;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST(xImageTextReq);
|
|
|
|
|
|
|
|
REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars);
|
2008-11-02 08:26:08 -07:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
err = ImageText(client,
|
2012-06-10 07:21:05 -06:00
|
|
|
pDraw,
|
|
|
|
pGC,
|
|
|
|
stuff->nChars,
|
|
|
|
(unsigned char *) &stuff[1],
|
|
|
|
stuff->x, stuff->y, stuff->reqType, stuff->drawable);
|
|
|
|
|
|
|
|
if (err == Success) {
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
return err;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcImageText16(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int err;
|
2007-11-24 10:55:21 -07:00
|
|
|
DrawablePtr pDraw;
|
|
|
|
GC *pGC;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST(xImageTextReq);
|
|
|
|
|
|
|
|
REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars << 1);
|
2008-11-02 08:26:08 -07:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
err = ImageText(client,
|
2012-06-10 07:21:05 -06:00
|
|
|
pDraw,
|
|
|
|
pGC,
|
|
|
|
stuff->nChars,
|
|
|
|
(unsigned char *) &stuff[1],
|
|
|
|
stuff->x, stuff->y, stuff->reqType, stuff->drawable);
|
|
|
|
|
|
|
|
if (err == Success) {
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
return err;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcCreateColormap(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
VisualPtr pVisual;
|
|
|
|
ColormapPtr pmap;
|
|
|
|
Colormap mid;
|
|
|
|
WindowPtr pWin;
|
2006-11-26 11:13:41 -07:00
|
|
|
ScreenPtr pScreen;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xCreateColormapReq);
|
|
|
|
int i, result;
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xCreateColormapReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((stuff->alloc != AllocNone) && (stuff->alloc != AllocAll)) {
|
|
|
|
client->errorValue = stuff->alloc;
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
mid = stuff->mid;
|
|
|
|
LEGAL_NEW_RESOURCE(mid, client);
|
2008-11-02 08:26:08 -07:00
|
|
|
result = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (result != Success)
|
|
|
|
return result;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pScreen = pWin->drawable.pScreen;
|
|
|
|
for (i = 0, pVisual = pScreen->visuals;
|
2012-06-10 07:21:05 -06:00
|
|
|
i < pScreen->numVisuals; i++, pVisual++) {
|
|
|
|
if (pVisual->vid != stuff->visual)
|
|
|
|
continue;
|
|
|
|
return CreateColormap(mid, pScreen, pVisual, &pmap,
|
|
|
|
(int) stuff->alloc, client->index);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
client->errorValue = stuff->visual;
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcFreeColormap(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ColormapPtr pmap;
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xResourceReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &pmap, stuff->id, RT_COLORMAP,
|
2012-06-10 07:21:05 -06:00
|
|
|
client, DixDestroyAccess);
|
|
|
|
if (rc == Success) {
|
|
|
|
/* Freeing a default colormap is a no-op */
|
|
|
|
if (!(pmap->flags & IsDefault))
|
|
|
|
FreeResource(stuff->id, RT_NONE);
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
client->errorValue = stuff->id;
|
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcCopyColormapAndFree(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
Colormap mid;
|
|
|
|
ColormapPtr pSrcMap;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xCopyColormapAndFreeReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq);
|
|
|
|
mid = stuff->mid;
|
|
|
|
LEGAL_NEW_RESOURCE(mid, client);
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &pSrcMap, stuff->srcCmap,
|
2012-06-10 07:21:05 -06:00
|
|
|
RT_COLORMAP, client,
|
|
|
|
DixReadAccess | DixRemoveAccess);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (rc == Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return CopyColormapAndFree(mid, pSrcMap, client->index);
|
2010-12-05 08:36:02 -07:00
|
|
|
client->errorValue = stuff->srcCmap;
|
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcInstallColormap(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ColormapPtr pcmp;
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xResourceReq);
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &pcmp, stuff->id, RT_COLORMAP,
|
2012-06-10 07:21:05 -06:00
|
|
|
client, DixInstallAccess);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
goto out;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
rc = XaceHook(XACE_SCREEN_ACCESS, client, pcmp->pScreen, DixSetAttrAccess);
|
2010-12-05 08:36:02 -07:00
|
|
|
if (rc != Success) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (rc == BadValue)
|
|
|
|
rc = BadColor;
|
|
|
|
goto out;
|
2010-12-05 08:36:02 -07:00
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
(*(pcmp->pScreen->InstallColormap)) (pcmp);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
out:
|
2008-11-02 08:26:08 -07:00
|
|
|
client->errorValue = stuff->id;
|
2010-12-05 08:36:02 -07:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcUninstallColormap(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ColormapPtr pcmp;
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xResourceReq);
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &pcmp, stuff->id, RT_COLORMAP,
|
2012-06-10 07:21:05 -06:00
|
|
|
client, DixUninstallAccess);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
goto out;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
rc = XaceHook(XACE_SCREEN_ACCESS, client, pcmp->pScreen, DixSetAttrAccess);
|
2010-12-05 08:36:02 -07:00
|
|
|
if (rc != Success) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (rc == BadValue)
|
|
|
|
rc = BadColor;
|
|
|
|
goto out;
|
2010-12-05 08:36:02 -07:00
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pcmp->mid != pcmp->pScreen->defColormap)
|
|
|
|
(*(pcmp->pScreen->UninstallColormap)) (pcmp);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
out:
|
2008-11-02 08:26:08 -07:00
|
|
|
client->errorValue = stuff->id;
|
2010-12-05 08:36:02 -07:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcListInstalledColormaps(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
xListInstalledColormapsReply *preply;
|
2007-11-24 10:55:21 -07:00
|
|
|
int nummaps, rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
WindowPtr pWin;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xResourceReq);
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
rc = XaceHook(XACE_SCREEN_ACCESS, client, pWin->drawable.pScreen,
|
2012-06-10 07:21:05 -06:00
|
|
|
DixGetAttrAccess);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
preply = malloc(sizeof(xListInstalledColormapsReply) +
|
2012-06-10 07:21:05 -06:00
|
|
|
pWin->drawable.pScreen->maxInstalledCmaps *
|
|
|
|
sizeof(Colormap));
|
|
|
|
if (!preply)
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
preply->type = X_Reply;
|
|
|
|
preply->sequenceNumber = client->sequence;
|
|
|
|
nummaps = (*pWin->drawable.pScreen->ListInstalledColormaps)
|
2013-06-07 11:28:45 -06:00
|
|
|
(pWin->drawable.pScreen, (Colormap *) &preply[1]);
|
2006-11-26 11:13:41 -07:00
|
|
|
preply->nColormaps = nummaps;
|
|
|
|
preply->length = nummaps;
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteReplyToClient(client, sizeof(xListInstalledColormapsReply), preply);
|
2006-11-26 11:13:41 -07:00
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
|
|
|
|
WriteSwappedDataToClient(client, nummaps * sizeof(Colormap), &preply[1]);
|
2010-12-05 08:36:02 -07:00
|
|
|
free(preply);
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcAllocColor(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ColormapPtr pmap;
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xAllocColorReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xAllocColorReq);
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &pmap, stuff->cmap, RT_COLORMAP,
|
2012-06-10 07:21:05 -06:00
|
|
|
client, DixAddAccess);
|
|
|
|
if (rc == Success) {
|
2013-06-07 11:28:45 -06:00
|
|
|
xAllocColorReply acr = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.red = stuff->red,
|
|
|
|
.green = stuff->green,
|
|
|
|
.blue = stuff->blue,
|
|
|
|
.pixel = 0
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((rc = AllocColor(pmap, &acr.red, &acr.green, &acr.blue,
|
|
|
|
&acr.pixel, client->index)))
|
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef PANORAMIX
|
2012-06-10 07:21:05 -06:00
|
|
|
if (noPanoramiXExtension || !pmap->pScreen->myNum)
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteReplyToClient(client, sizeof(xAllocColorReply), &acr);
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
2006-11-26 11:13:41 -07:00
|
|
|
client->errorValue = stuff->cmap;
|
2010-12-05 08:36:02 -07:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcAllocNamedColor(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ColormapPtr pcmp;
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xAllocNamedColorReq);
|
|
|
|
|
|
|
|
REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes);
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP,
|
2012-06-10 07:21:05 -06:00
|
|
|
client, DixAddAccess);
|
|
|
|
if (rc == Success) {
|
2013-06-07 11:28:45 -06:00
|
|
|
xAllocNamedColorReply ancr = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
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;
|
|
|
|
if ((rc = AllocColor(pcmp,
|
|
|
|
&ancr.screenRed, &ancr.screenGreen,
|
|
|
|
&ancr.screenBlue, &ancr.pixel, client->index)))
|
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef PANORAMIX
|
2012-06-10 07:21:05 -06:00
|
|
|
if (noPanoramiXExtension || !pcmp->pScreen->myNum)
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteReplyToClient(client, sizeof(xAllocNamedColorReply),
|
|
|
|
&ancr);
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return BadName;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
2006-11-26 11:13:41 -07:00
|
|
|
client->errorValue = stuff->cmap;
|
2010-12-05 08:36:02 -07:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcAllocColorCells(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ColormapPtr pcmp;
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xAllocColorCellsReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xAllocColorCellsReq);
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP,
|
2012-06-10 07:21:05 -06:00
|
|
|
client, DixAddAccess);
|
|
|
|
if (rc == Success) {
|
|
|
|
int npixels, nmasks;
|
|
|
|
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);
|
|
|
|
ppixels = malloc(length);
|
|
|
|
if (!ppixels)
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadAlloc;
|
2012-06-10 07:21:05 -06:00
|
|
|
pmasks = ppixels + npixels;
|
|
|
|
|
|
|
|
if ((rc = AllocColorCells(client->index, pcmp, npixels, nmasks,
|
|
|
|
(Bool) stuff->contiguous, ppixels, pmasks))) {
|
|
|
|
free(ppixels);
|
|
|
|
return rc;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef PANORAMIX
|
2012-06-10 07:21:05 -06:00
|
|
|
if (noPanoramiXExtension || !pcmp->pScreen->myNum)
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
{
|
2013-06-07 11:28:45 -06:00
|
|
|
xAllocColorCellsReply accr = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = bytes_to_int32(length),
|
|
|
|
.nPixels = npixels,
|
|
|
|
.nMasks = nmasks
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteReplyToClient(client, sizeof(xAllocColorCellsReply), &accr);
|
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
|
|
|
|
WriteSwappedDataToClient(client, length, ppixels);
|
|
|
|
}
|
|
|
|
free(ppixels);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
2006-11-26 11:13:41 -07:00
|
|
|
client->errorValue = stuff->cmap;
|
2010-12-05 08:36:02 -07:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcAllocColorPlanes(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ColormapPtr pcmp;
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xAllocColorPlanesReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xAllocColorPlanesReq);
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP,
|
2012-06-10 07:21:05 -06:00
|
|
|
client, DixAddAccess);
|
|
|
|
if (rc == Success) {
|
|
|
|
xAllocColorPlanesReply acpr;
|
|
|
|
int npixels;
|
|
|
|
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;
|
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
acpr = (xAllocColorPlanesReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.nPixels = npixels
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
length = (long) npixels *sizeof(Pixel);
|
|
|
|
|
|
|
|
ppixels = malloc(length);
|
|
|
|
if (!ppixels)
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadAlloc;
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((rc = AllocColorPlanes(client->index, pcmp, npixels,
|
|
|
|
(int) stuff->red, (int) stuff->green,
|
|
|
|
(int) stuff->blue, (Bool) stuff->contiguous,
|
|
|
|
ppixels, &acpr.redMask, &acpr.greenMask,
|
|
|
|
&acpr.blueMask))) {
|
2010-12-05 08:36:02 -07:00
|
|
|
free(ppixels);
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
acpr.length = bytes_to_int32(length);
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef PANORAMIX
|
2012-06-10 07:21:05 -06:00
|
|
|
if (noPanoramiXExtension || !pcmp->pScreen->myNum)
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
{
|
|
|
|
WriteReplyToClient(client, sizeof(xAllocColorPlanesReply), &acpr);
|
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
|
|
|
|
WriteSwappedDataToClient(client, length, ppixels);
|
|
|
|
}
|
|
|
|
free(ppixels);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
2006-11-26 11:13:41 -07:00
|
|
|
client->errorValue = stuff->cmap;
|
2010-12-05 08:36:02 -07:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcFreeColors(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ColormapPtr pcmp;
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xFreeColorsReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xFreeColorsReq);
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP,
|
2012-06-10 07:21:05 -06:00
|
|
|
client, DixRemoveAccess);
|
|
|
|
if (rc == Success) {
|
|
|
|
int count;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pcmp->flags & AllAllocated)
|
|
|
|
return BadAccess;
|
|
|
|
count = bytes_to_int32((client->req_len << 2) - sizeof(xFreeColorsReq));
|
|
|
|
return FreeColors(pcmp, client->index, count,
|
|
|
|
(Pixel *) &stuff[1], (Pixel) stuff->planeMask);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
2006-11-26 11:13:41 -07:00
|
|
|
client->errorValue = stuff->cmap;
|
2010-12-05 08:36:02 -07:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcStoreColors(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ColormapPtr pcmp;
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xStoreColorsReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xStoreColorsReq);
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP,
|
2012-06-10 07:21:05 -06:00
|
|
|
client, DixWriteAccess);
|
|
|
|
if (rc == Success) {
|
|
|
|
int count;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
count = (client->req_len << 2) - sizeof(xStoreColorsReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (count % sizeof(xColorItem))
|
|
|
|
return BadLength;
|
|
|
|
count /= sizeof(xColorItem);
|
|
|
|
return StoreColors(pcmp, count, (xColorItem *) &stuff[1], client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
2006-11-26 11:13:41 -07:00
|
|
|
client->errorValue = stuff->cmap;
|
2010-12-05 08:36:02 -07:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcStoreNamedColor(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ColormapPtr pcmp;
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xStoreNamedColorReq);
|
|
|
|
|
|
|
|
REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes);
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP,
|
2012-06-10 07:21:05 -06:00
|
|
|
client, DixWriteAccess);
|
|
|
|
if (rc == Success) {
|
|
|
|
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;
|
|
|
|
return StoreColors(pcmp, 1, &def, client);
|
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadName;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
2006-11-26 11:13:41 -07:00
|
|
|
client->errorValue = stuff->cmap;
|
2010-12-05 08:36:02 -07:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcQueryColors(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ColormapPtr pcmp;
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xQueryColorsReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xQueryColorsReq);
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP,
|
2012-06-10 07:21:05 -06:00
|
|
|
client, DixReadAccess);
|
|
|
|
if (rc == Success) {
|
|
|
|
int count;
|
|
|
|
xrgb *prgbs;
|
|
|
|
xQueryColorsReply qcr;
|
|
|
|
|
|
|
|
count =
|
|
|
|
bytes_to_int32((client->req_len << 2) - sizeof(xQueryColorsReq));
|
|
|
|
prgbs = calloc(1, count * sizeof(xrgb));
|
|
|
|
if (!prgbs && count)
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadAlloc;
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((rc =
|
|
|
|
QueryColors(pcmp, count, (Pixel *) &stuff[1], prgbs, client))) {
|
|
|
|
free(prgbs);
|
|
|
|
return rc;
|
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
qcr = (xQueryColorsReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = bytes_to_int32(count * sizeof(xrgb)),
|
|
|
|
.nColors = count
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteReplyToClient(client, sizeof(xQueryColorsReply), &qcr);
|
|
|
|
if (count) {
|
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) SQColorsExtend;
|
|
|
|
WriteSwappedDataToClient(client, count * sizeof(xrgb), prgbs);
|
|
|
|
}
|
|
|
|
free(prgbs);
|
|
|
|
return Success;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
2006-11-26 11:13:41 -07:00
|
|
|
client->errorValue = stuff->cmap;
|
2010-12-05 08:36:02 -07:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcLookupColor(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ColormapPtr pcmp;
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xLookupColorReq);
|
|
|
|
|
|
|
|
REQUEST_FIXED_SIZE(xLookupColorReq, stuff->nbytes);
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP,
|
2012-06-10 07:21:05 -06:00
|
|
|
client, DixReadAccess);
|
|
|
|
if (rc == Success) {
|
2013-06-07 11:28:45 -06:00
|
|
|
CARD16 exactRed, exactGreen, exactBlue;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
if (OsLookupColor
|
|
|
|
(pcmp->pScreen->myNum, (char *) &stuff[1], stuff->nbytes,
|
2013-06-07 11:28:45 -06:00
|
|
|
&exactRed, &exactGreen, &exactBlue)) {
|
|
|
|
xLookupColorReply lcr = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.exactRed = exactRed,
|
|
|
|
.exactGreen = exactGreen,
|
|
|
|
.exactBlue = exactBlue,
|
|
|
|
.screenRed = exactRed,
|
|
|
|
.screenGreen = exactGreen,
|
|
|
|
.screenBlue = exactBlue
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pcmp->pScreen->ResolveColor) (&lcr.screenRed,
|
|
|
|
&lcr.screenGreen,
|
|
|
|
&lcr.screenBlue, pcmp->pVisual);
|
|
|
|
WriteReplyToClient(client, sizeof(xLookupColorReply), &lcr);
|
|
|
|
return Success;
|
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadName;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
2006-11-26 11:13:41 -07:00
|
|
|
client->errorValue = stuff->cmap;
|
2010-12-05 08:36:02 -07:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcCreateCursor(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
CursorPtr pCursor;
|
|
|
|
PixmapPtr src;
|
|
|
|
PixmapPtr msk;
|
|
|
|
unsigned char *srcbits;
|
|
|
|
unsigned char *mskbits;
|
|
|
|
unsigned short width, height;
|
|
|
|
long n;
|
|
|
|
CursorMetricRec cm;
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST(xCreateCursorReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xCreateCursorReq);
|
|
|
|
LEGAL_NEW_RESOURCE(stuff->cid, client);
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &src, stuff->source, RT_PIXMAP,
|
2012-06-10 07:21:05 -06:00
|
|
|
client, DixReadAccess);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (rc != Success) {
|
2012-06-10 07:21:05 -06:00
|
|
|
client->errorValue = stuff->source;
|
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2014-05-02 13:27:46 -06:00
|
|
|
if (src->drawable.depth != 1)
|
|
|
|
return (BadMatch);
|
|
|
|
|
|
|
|
/* Find and validate cursor mask pixmap, if one is provided */
|
|
|
|
if (stuff->mask != None) {
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &msk, stuff->mask, RT_PIXMAP,
|
2014-05-02 13:27:46 -06:00
|
|
|
client, DixReadAccess);
|
|
|
|
if (rc != Success) {
|
2012-06-10 07:21:05 -06:00
|
|
|
client->errorValue = stuff->mask;
|
|
|
|
return rc;
|
|
|
|
}
|
2014-05-02 13:27:46 -06:00
|
|
|
|
|
|
|
if (src->drawable.width != msk->drawable.width
|
|
|
|
|| src->drawable.height != msk->drawable.height
|
|
|
|
|| src->drawable.depth != 1 || msk->drawable.depth != 1)
|
|
|
|
return BadMatch;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
2014-05-02 13:27:46 -06:00
|
|
|
else
|
|
|
|
msk = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
width = src->drawable.width;
|
|
|
|
height = src->drawable.height;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->x > width || stuff->y > height)
|
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
n = BitmapBytePad(width) * height;
|
2010-12-05 08:36:02 -07:00
|
|
|
srcbits = calloc(1, n);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!srcbits)
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadAlloc;
|
2010-12-05 08:36:02 -07:00
|
|
|
mskbits = malloc(n);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!mskbits) {
|
|
|
|
free(srcbits);
|
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(*src->drawable.pScreen->GetImage) ((DrawablePtr) src, 0, 0, width, height,
|
2014-09-27 11:52:59 -06:00
|
|
|
XYPixmap, 1, (void *) srcbits);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (msk == (PixmapPtr) NULL) {
|
|
|
|
unsigned char *bits = mskbits;
|
|
|
|
|
|
|
|
while (--n >= 0)
|
|
|
|
*bits++ = ~0;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
/* zeroing the (pad) bits helps some ddx cursor handling */
|
|
|
|
memset((char *) mskbits, 0, n);
|
|
|
|
(*msk->drawable.pScreen->GetImage) ((DrawablePtr) msk, 0, 0, width,
|
|
|
|
height, XYPixmap, 1,
|
2014-09-27 11:52:59 -06:00
|
|
|
(void *) mskbits);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
cm.width = width;
|
|
|
|
cm.height = height;
|
|
|
|
cm.xhot = stuff->x;
|
|
|
|
cm.yhot = stuff->y;
|
2008-11-02 08:26:08 -07:00
|
|
|
rc = AllocARGBCursor(srcbits, mskbits, NULL, &cm,
|
2012-06-10 07:21:05 -06:00
|
|
|
stuff->foreRed, stuff->foreGreen, stuff->foreBlue,
|
|
|
|
stuff->backRed, stuff->backGreen, stuff->backBlue,
|
|
|
|
&pCursor, client, stuff->cid);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
goto bail;
|
2014-09-27 11:52:59 -06:00
|
|
|
if (!AddResource(stuff->cid, RT_CURSOR, (void *) pCursor)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
rc = BadAlloc;
|
|
|
|
goto bail;
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2012-06-10 07:21:05 -06:00
|
|
|
bail:
|
2011-11-05 07:32:40 -06:00
|
|
|
free(srcbits);
|
|
|
|
free(mskbits);
|
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcCreateGlyphCursor(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
CursorPtr pCursor;
|
|
|
|
int res;
|
|
|
|
|
|
|
|
REQUEST(xCreateGlyphCursorReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xCreateGlyphCursorReq);
|
|
|
|
LEGAL_NEW_RESOURCE(stuff->cid, client);
|
|
|
|
|
|
|
|
res = AllocGlyphCursor(stuff->source, stuff->sourceChar,
|
2012-06-10 07:21:05 -06:00
|
|
|
stuff->mask, stuff->maskChar,
|
|
|
|
stuff->foreRed, stuff->foreGreen, stuff->foreBlue,
|
|
|
|
stuff->backRed, stuff->backGreen, stuff->backBlue,
|
|
|
|
&pCursor, client, stuff->cid);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (res != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return res;
|
2014-09-27 11:52:59 -06:00
|
|
|
if (AddResource(stuff->cid, RT_CURSOR, (void *) pCursor))
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcFreeCursor(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
CursorPtr pCursor;
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xResourceReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &pCursor, stuff->id, RT_CURSOR,
|
2012-06-10 07:21:05 -06:00
|
|
|
client, DixDestroyAccess);
|
|
|
|
if (rc == Success) {
|
|
|
|
FreeResource(stuff->id, RT_NONE);
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
client->errorValue = stuff->id;
|
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcQueryBestSize(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
xQueryBestSizeReply reply;
|
2007-11-24 10:55:21 -07:00
|
|
|
DrawablePtr pDraw;
|
2006-11-26 11:13:41 -07:00
|
|
|
ScreenPtr pScreen;
|
2007-11-24 10:55:21 -07:00
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xQueryBestSizeReq);
|
|
|
|
REQUEST_SIZE_MATCH(xQueryBestSizeReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((stuff->class != CursorShape) &&
|
|
|
|
(stuff->class != TileShape) && (stuff->class != StippleShape)) {
|
|
|
|
client->errorValue = stuff->class;
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
|
|
|
|
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, M_ANY,
|
2012-06-10 07:21:05 -06:00
|
|
|
DixGetAttrAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (stuff->class != CursorShape && pDraw->type == UNDRAWABLE_WINDOW)
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
pScreen = pDraw->pScreen;
|
2008-11-02 08:26:08 -07:00
|
|
|
rc = XaceHook(XACE_SCREEN_ACCESS, client, pScreen, DixGetAttrAccess);
|
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
|
|
|
(*pScreen->QueryBestSize) (stuff->class, &stuff->width,
|
|
|
|
&stuff->height, pScreen);
|
2013-06-07 11:28:45 -06:00
|
|
|
reply = (xQueryBestSizeReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.width = stuff->width,
|
|
|
|
.height = stuff->height
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
WriteReplyToClient(client, sizeof(xQueryBestSizeReply), &reply);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcSetScreenSaver(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc, i, blankingOption, exposureOption;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xSetScreenSaverReq);
|
|
|
|
REQUEST_SIZE_MATCH(xSetScreenSaverReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
for (i = 0; i < screenInfo.numScreens; i++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, screenInfo.screens[i],
|
|
|
|
DixSetAttrAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
blankingOption = stuff->preferBlank;
|
|
|
|
if ((blankingOption != DontPreferBlanking) &&
|
|
|
|
(blankingOption != PreferBlanking) &&
|
2012-06-10 07:21:05 -06:00
|
|
|
(blankingOption != DefaultBlanking)) {
|
|
|
|
client->errorValue = blankingOption;
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
exposureOption = stuff->allowExpose;
|
|
|
|
if ((exposureOption != DontAllowExposures) &&
|
|
|
|
(exposureOption != AllowExposures) &&
|
2012-06-10 07:21:05 -06:00
|
|
|
(exposureOption != DefaultExposures)) {
|
|
|
|
client->errorValue = exposureOption;
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->timeout < -1) {
|
|
|
|
client->errorValue = stuff->timeout;
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->interval < -1) {
|
|
|
|
client->errorValue = stuff->interval;
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (blankingOption == DefaultBlanking)
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenSaverBlanking = defaultScreenSaverBlanking;
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenSaverBlanking = blankingOption;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (exposureOption == DefaultExposures)
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenSaverAllowExposures = defaultScreenSaverAllowExposures;
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenSaverAllowExposures = exposureOption;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (stuff->timeout >= 0)
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenSaverTime = stuff->timeout * MILLI_PER_SECOND;
|
|
|
|
else
|
|
|
|
ScreenSaverTime = defaultScreenSaverTime;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (stuff->interval >= 0)
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenSaverInterval = stuff->interval * MILLI_PER_SECOND;
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenSaverInterval = defaultScreenSaverInterval;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
SetScreenSaverTimer();
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcGetScreenSaver(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
xGetScreenSaverReply rep;
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc, i;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
for (i = 0; i < screenInfo.numScreens; i++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, screenInfo.screens[i],
|
|
|
|
DixGetAttrAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
rep = (xGetScreenSaverReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.timeout = ScreenSaverTime / MILLI_PER_SECOND,
|
|
|
|
.interval = ScreenSaverInterval / MILLI_PER_SECOND,
|
|
|
|
.preferBlanking = ScreenSaverBlanking,
|
|
|
|
.allowExposures = ScreenSaverAllowExposures
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
WriteReplyToClient(client, sizeof(xGetScreenSaverReply), &rep);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcChangeHosts(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xChangeHostsReq);
|
|
|
|
|
|
|
|
REQUEST_FIXED_SIZE(xChangeHostsReq, stuff->hostLength);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->mode == HostInsert)
|
|
|
|
return AddHost(client, (int) stuff->hostFamily,
|
2014-09-27 11:52:59 -06:00
|
|
|
stuff->hostLength, (void *) &stuff[1]);
|
2010-12-05 08:36:02 -07:00
|
|
|
if (stuff->mode == HostDelete)
|
2012-06-10 07:21:05 -06:00
|
|
|
return RemoveHost(client, (int) stuff->hostFamily,
|
2014-09-27 11:52:59 -06:00
|
|
|
stuff->hostLength, (void *) &stuff[1]);
|
2010-12-05 08:36:02 -07:00
|
|
|
client->errorValue = stuff->mode;
|
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcListHosts(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
xListHostsReply reply;
|
2012-06-10 07:21:05 -06:00
|
|
|
int len, nHosts, result;
|
2013-06-07 11:28:45 -06:00
|
|
|
BOOL enabled;
|
2014-09-27 11:52:59 -06:00
|
|
|
void *pdata;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/* REQUEST(xListHostsReq); */
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xListHostsReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/* untrusted clients can't list hosts */
|
2008-11-02 08:26:08 -07:00
|
|
|
result = XaceHook(XACE_SERVER_ACCESS, client, DixReadAccess);
|
|
|
|
if (result != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return result;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
result = GetHosts(&pdata, &nHosts, &len, &enabled);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (result != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return result;
|
2013-06-07 11:28:45 -06:00
|
|
|
|
|
|
|
reply = (xListHostsReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.enabled = enabled,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = bytes_to_int32(len),
|
|
|
|
.nHosts = nHosts
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
WriteReplyToClient(client, sizeof(xListHostsReply), &reply);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (nHosts) {
|
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) SLHostsExtend;
|
|
|
|
WriteSwappedDataToClient(client, len, pdata);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
free(pdata);
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcChangeAccessControl(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xSetAccessControlReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xSetAccessControlReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((stuff->mode != EnableAccess) && (stuff->mode != DisableAccess)) {
|
|
|
|
client->errorValue = stuff->mode;
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
return ChangeAccessControl(client, stuff->mode == EnableAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
/*********************
|
|
|
|
* CloseDownRetainedResources
|
|
|
|
*
|
2015-09-16 13:10:19 -06:00
|
|
|
* Find all clients that are gone and have terminated in RetainTemporary
|
2007-11-24 10:55:21 -07:00
|
|
|
* and destroy their resources.
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
static void
|
|
|
|
CloseDownRetainedResources(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
ClientPtr client;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 1; i < currentMaxClients; i++) {
|
2007-11-24 10:55:21 -07:00
|
|
|
client = clients[i];
|
|
|
|
if (client && (client->closeDownMode == RetainTemporary)
|
2012-06-10 07:21:05 -06:00
|
|
|
&& (client->clientGone))
|
|
|
|
CloseDownClient(client);
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcKillClient(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xResourceReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
ClientPtr killclient;
|
|
|
|
int rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xResourceReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->id == AllTemporary) {
|
|
|
|
CloseDownRetainedResources();
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
rc = dixLookupClient(&killclient, stuff->id, client, DixDestroyAccess);
|
|
|
|
if (rc == Success) {
|
2012-06-10 07:21:05 -06:00
|
|
|
CloseDownClient(killclient);
|
2015-09-16 13:10:19 -06:00
|
|
|
if (client == killclient) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/* force yield and return Success, so that Dispatch()
|
|
|
|
* doesn't try to touch client
|
|
|
|
*/
|
|
|
|
isItTimeToYield = TRUE;
|
|
|
|
}
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcSetFontPath(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
unsigned char *ptr;
|
|
|
|
unsigned long nbytes, total;
|
|
|
|
long nfonts;
|
2010-12-05 08:36:02 -07:00
|
|
|
int n;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xSetFontPathReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_AT_LEAST_SIZE(xSetFontPathReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
nbytes = (client->req_len << 2) - sizeof(xSetFontPathReq);
|
|
|
|
total = nbytes;
|
2012-06-10 07:21:05 -06:00
|
|
|
ptr = (unsigned char *) &stuff[1];
|
2006-11-26 11:13:41 -07:00
|
|
|
nfonts = stuff->nFonts;
|
2012-06-10 07:21:05 -06:00
|
|
|
while (--nfonts >= 0) {
|
|
|
|
if ((total == 0) || (total < (n = (*ptr + 1))))
|
|
|
|
return BadLength;
|
|
|
|
total -= n;
|
|
|
|
ptr += n;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (total >= 4)
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadLength;
|
|
|
|
return SetFontPath(client, stuff->nFonts, (unsigned char *) &stuff[1]);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcGetFontPath(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
xGetFontPathReply reply;
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc, stringLens, numpaths;
|
2006-11-26 11:13:41 -07:00
|
|
|
unsigned char *bufferStart;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/* REQUEST (xReq); */
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
rc = GetFontPath(client, &numpaths, &stringLens, &bufferStart);
|
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
reply = (xGetFontPathReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = bytes_to_int32(stringLens + numpaths),
|
|
|
|
.nPaths = numpaths
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
WriteReplyToClient(client, sizeof(xGetFontPathReply), &reply);
|
|
|
|
if (stringLens || numpaths)
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, stringLens + numpaths, bufferStart);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcChangeCloseDownMode(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xSetCloseDownModeReq);
|
|
|
|
REQUEST_SIZE_MATCH(xSetCloseDownModeReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
rc = XaceHook(XACE_CLIENT_ACCESS, client, client, DixManageAccess);
|
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if ((stuff->mode == AllTemporary) ||
|
2012-06-10 07:21:05 -06:00
|
|
|
(stuff->mode == RetainPermanent) || (stuff->mode == RetainTemporary)) {
|
|
|
|
client->closeDownMode = stuff->mode;
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
client->errorValue = stuff->mode;
|
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
int
|
|
|
|
ProcForceScreenSaver(ClientPtr client)
|
|
|
|
{
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xForceScreenSaverReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xForceScreenSaverReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
if ((stuff->mode != ScreenSaverReset) && (stuff->mode != ScreenSaverActive)) {
|
|
|
|
client->errorValue = stuff->mode;
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
rc = dixSaveScreens(client, SCREEN_SAVER_FORCER, (int) stuff->mode);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
int
|
|
|
|
ProcNoOperation(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST_AT_LEAST_SIZE(xReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/* noop -- don't do anything */
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* CloseDownClient
|
|
|
|
*
|
|
|
|
* Client can either mark his resources destroy or retain. If retained and
|
|
|
|
* then killed again, the client is really destroyed.
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
char dispatchExceptionAtReset = DE_RESET;
|
|
|
|
|
|
|
|
void
|
2007-11-24 10:55:21 -07:00
|
|
|
CloseDownClient(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
Bool really_close_down = client->clientGone ||
|
2012-06-10 07:21:05 -06:00
|
|
|
client->closeDownMode == DestroyAll;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
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;
|
2014-09-27 11:52:59 -06:00
|
|
|
CallCallbacks((&ClientStateCallback), (void *) &clientinfo);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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) {
|
|
|
|
--nClients;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (really_close_down) {
|
|
|
|
if (client->clientState == ClientStateRunning && nClients == 0)
|
|
|
|
dispatchException |= dispatchExceptionAtReset;
|
|
|
|
|
|
|
|
client->clientState = ClientStateGone;
|
|
|
|
if (ClientStateCallback) {
|
|
|
|
NewClientInfoRec clientinfo;
|
|
|
|
|
|
|
|
clientinfo.client = client;
|
|
|
|
clientinfo.prefix = (xConnSetupPrefix *) NULL;
|
|
|
|
clientinfo.setup = (xConnSetup *) NULL;
|
2014-09-27 11:52:59 -06:00
|
|
|
CallCallbacks((&ClientStateCallback), (void *) &clientinfo);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
2013-09-28 09:36:30 -06:00
|
|
|
TouchListenerGone(client->clientAsMask);
|
2012-06-10 07:21:05 -06:00
|
|
|
FreeClientResources(client);
|
|
|
|
/* Disable client ID tracking. This must be done after
|
|
|
|
* ClientStateCallback. */
|
|
|
|
ReleaseClientIds(client);
|
2007-11-24 10:55:21 -07:00
|
|
|
#ifdef XSERVER_DTRACE
|
2012-06-10 07:21:05 -06:00
|
|
|
XSERVER_CLIENT_DISCONNECT(client->index);
|
|
|
|
#endif
|
|
|
|
if (client->index < nextFreeClientID)
|
|
|
|
nextFreeClientID = client->index;
|
|
|
|
clients[client->index] = NullClient;
|
|
|
|
SmartLastClient = NullClient;
|
|
|
|
dixFreeObjectWithPrivates(client, PRIVATE_CLIENT);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
while (!clients[currentMaxClients - 1])
|
|
|
|
currentMaxClients--;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-11-24 10:55:21 -07:00
|
|
|
KillAllClients(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
int i;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
for (i = 1; i < currentMaxClients; i++)
|
2006-11-26 11:13:41 -07:00
|
|
|
if (clients[i]) {
|
|
|
|
/* Make sure Retained clients are released. */
|
|
|
|
clients[i]->closeDownMode = DestroyAll;
|
2012-06-10 07:21:05 -06:00
|
|
|
CloseDownClient(clients[i]);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
2014-09-27 11:52:59 -06:00
|
|
|
InitClient(ClientPtr client, int i, void *ospriv)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
client->index = i;
|
2012-06-10 07:21:05 -06:00
|
|
|
client->clientAsMask = ((Mask) i) << CLIENTOFFSET;
|
2008-11-02 08:26:08 -07:00
|
|
|
client->closeDownMode = i ? DestroyAll : RetainPermanent;
|
2006-11-26 11:13:41 -07:00
|
|
|
client->requestVector = InitialVector;
|
|
|
|
client->osPrivate = ospriv;
|
2012-06-10 07:21:05 -06:00
|
|
|
QueryMinMaxKeyCodes(&client->minKC, &client->maxKC);
|
2006-11-26 11:13:41 -07:00
|
|
|
client->smart_start_tick = SmartScheduleTime;
|
|
|
|
client->smart_stop_tick = SmartScheduleTime;
|
2011-11-05 07:32:40 -06:00
|
|
|
client->clientIds = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************
|
|
|
|
* int NextAvailableClient(ospriv)
|
|
|
|
*
|
|
|
|
* OS dependent portion can't assign client id's because of CloseDownModes.
|
|
|
|
* Returns NULL if there are no free clients.
|
|
|
|
*************************/
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
ClientPtr
|
2014-09-27 11:52:59 -06:00
|
|
|
NextAvailableClient(void *ospriv)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
int i;
|
|
|
|
ClientPtr client;
|
2006-11-26 11:13:41 -07:00
|
|
|
xReq data;
|
|
|
|
|
|
|
|
i = nextFreeClientID;
|
|
|
|
if (i == MAXCLIENTS)
|
2012-06-10 07:21:05 -06:00
|
|
|
return (ClientPtr) NULL;
|
|
|
|
clients[i] = client =
|
|
|
|
dixAllocateObjectWithPrivates(ClientRec, PRIVATE_CLIENT);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!client)
|
2012-06-10 07:21:05 -06:00
|
|
|
return (ClientPtr) NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
InitClient(client, i, ospriv);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!InitClientResources(client)) {
|
|
|
|
dixFreeObjectWithPrivates(client, PRIVATE_CLIENT);
|
|
|
|
return (ClientPtr) NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
data.reqType = 1;
|
2010-07-27 13:02:24 -06:00
|
|
|
data.length = bytes_to_int32(sz_xReq + sz_xConnClientPrefix);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!InsertFakeRequest(client, (char *) &data, sz_xReq)) {
|
|
|
|
FreeClientResources(client);
|
|
|
|
dixFreeObjectWithPrivates(client, PRIVATE_CLIENT);
|
|
|
|
return (ClientPtr) NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (i == currentMaxClients)
|
2012-06-10 07:21:05 -06:00
|
|
|
currentMaxClients++;
|
2006-11-26 11:13:41 -07:00
|
|
|
while ((nextFreeClientID < MAXCLIENTS) && clients[nextFreeClientID])
|
2012-06-10 07:21:05 -06:00
|
|
|
nextFreeClientID++;
|
2011-11-05 07:32:40 -06:00
|
|
|
|
|
|
|
/* Enable client ID tracking. This must be done before
|
|
|
|
* ClientStateCallback. */
|
|
|
|
ReserveClientIds(client);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (ClientStateCallback) {
|
|
|
|
NewClientInfoRec clientinfo;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
clientinfo.client = client;
|
|
|
|
clientinfo.prefix = (xConnSetupPrefix *) NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
clientinfo.setup = (xConnSetup *) NULL;
|
2014-09-27 11:52:59 -06:00
|
|
|
CallCallbacks((&ClientStateCallback), (void *) &clientinfo);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
return client;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcInitialConnection(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
xConnClientPrefix *prefix;
|
2006-11-26 11:13:41 -07:00
|
|
|
int whichbyte = 1;
|
2013-06-07 11:28:45 -06:00
|
|
|
char order;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
prefix = (xConnClientPrefix *) ((char *)stuff + sz_xReq);
|
|
|
|
order = prefix->byteOrder;
|
|
|
|
if (order != 'l' && order != 'B' && order != 'r' && order != 'R')
|
|
|
|
return client->noClientException = -1;
|
|
|
|
if (((*(char *) &whichbyte) && (order == 'B' || order == 'R')) ||
|
|
|
|
(!(*(char *) &whichbyte) && (order == 'l' || order == 'r'))) {
|
|
|
|
client->swapped = TRUE;
|
|
|
|
SwapConnClientPrefix(prefix);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
stuff->reqType = 2;
|
2010-07-27 13:02:24 -06:00
|
|
|
stuff->length += bytes_to_int32(prefix->nbytesAuthProto) +
|
2012-06-10 07:21:05 -06:00
|
|
|
bytes_to_int32(prefix->nbytesAuthString);
|
|
|
|
if (client->swapped) {
|
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
if (order == 'r' || order == 'R') {
|
|
|
|
client->local = FALSE;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
ResetCurrentRequest(client);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SendConnSetup(ClientPtr client, const char *reason)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
xWindowRoot *root;
|
|
|
|
int i;
|
2006-11-26 11:13:41 -07:00
|
|
|
int numScreens;
|
2012-06-10 07:21:05 -06:00
|
|
|
char *lConnectionInfo;
|
|
|
|
xConnSetupPrefix *lconnSetupPrefix;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (reason) {
|
|
|
|
xConnSetupPrefix csp;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
csp.success = xFalse;
|
|
|
|
csp.lengthReason = strlen(reason);
|
|
|
|
csp.length = bytes_to_int32(csp.lengthReason);
|
|
|
|
csp.majorVersion = X_PROTOCOL;
|
|
|
|
csp.minorVersion = X_PROTOCOL_REVISION;
|
|
|
|
if (client->swapped)
|
|
|
|
WriteSConnSetupPrefix(client, &csp);
|
|
|
|
else
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sz_xConnSetupPrefix, &csp);
|
|
|
|
WriteToClient(client, (int) csp.lengthReason, reason);
|
2012-06-10 07:21:05 -06:00
|
|
|
return client->noClientException = -1;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2012-06-10 07:21:05 -06:00
|
|
|
((xConnSetup *) lConnectionInfo)->ridBase = client->clientAsMask;
|
|
|
|
((xConnSetup *) lConnectionInfo)->ridMask = RESOURCE_ID_MASK;
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef MATCH_CLIENT_ENDIAN
|
2012-06-10 07:21:05 -06:00
|
|
|
((xConnSetup *) lConnectionInfo)->imageByteOrder = ClientOrder(client);
|
|
|
|
((xConnSetup *) lConnectionInfo)->bitmapBitOrder = ClientOrder(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
/* fill in the "currentInputMask" */
|
2012-06-10 07:21:05 -06:00
|
|
|
root = (xWindowRoot *) (lConnectionInfo + connBlockScreenStart);
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef PANORAMIX
|
|
|
|
if (noPanoramiXExtension)
|
2012-06-10 07:21:05 -06:00
|
|
|
numScreens = screenInfo.numScreens;
|
|
|
|
else
|
|
|
|
numScreens = ((xConnSetup *) ConnectionInfo)->numRoots;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < numScreens; i++) {
|
|
|
|
unsigned int j;
|
|
|
|
xDepth *pDepth;
|
|
|
|
WindowPtr pRoot = screenInfo.screens[i]->root;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
root->currentInputMask = pRoot->eventMask | wOtherEventMasks(pRoot);
|
2012-06-10 07:21:05 -06:00
|
|
|
pDepth = (xDepth *) (root + 1);
|
|
|
|
for (j = 0; j < root->nDepths; j++) {
|
|
|
|
pDepth = (xDepth *) (((char *) (pDepth + 1)) +
|
|
|
|
pDepth->nVisuals * sizeof(xVisualType));
|
|
|
|
}
|
|
|
|
root = (xWindowRoot *) pDepth;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (client->swapped) {
|
|
|
|
WriteSConnSetupPrefix(client, lconnSetupPrefix);
|
|
|
|
WriteSConnectionInfo(client,
|
|
|
|
(unsigned long) (lconnSetupPrefix->length << 2),
|
|
|
|
lConnectionInfo);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xConnSetupPrefix), lconnSetupPrefix);
|
|
|
|
WriteToClient(client, (int) (lconnSetupPrefix->length << 2),
|
|
|
|
lConnectionInfo);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
client->clientState = ClientStateRunning;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (ClientStateCallback) {
|
|
|
|
NewClientInfoRec clientinfo;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
clientinfo.client = client;
|
|
|
|
clientinfo.prefix = lconnSetupPrefix;
|
|
|
|
clientinfo.setup = (xConnSetup *) lConnectionInfo;
|
2014-09-27 11:52:59 -06:00
|
|
|
CallCallbacks((&ClientStateCallback), (void *) &clientinfo);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ProcEstablishConnection(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
const char *reason;
|
|
|
|
char *auth_proto, *auth_string;
|
2007-11-24 10:55:21 -07:00
|
|
|
xConnClientPrefix *prefix;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
prefix = (xConnClientPrefix *) ((char *) stuff + sz_xReq);
|
|
|
|
auth_proto = (char *) prefix + sz_xConnClientPrefix;
|
2010-07-27 13:02:24 -06:00
|
|
|
auth_string = auth_proto + pad_to_int32(prefix->nbytesAuthProto);
|
2006-11-26 11:13:41 -07:00
|
|
|
if ((prefix->majorVersion != X_PROTOCOL) ||
|
2012-06-10 07:21:05 -06:00
|
|
|
(prefix->minorVersion != X_PROTOCOL_REVISION))
|
|
|
|
reason = "Protocol version mismatch";
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
reason = ClientAuthorized(client,
|
|
|
|
(unsigned short) prefix->nbytesAuthProto,
|
|
|
|
auth_proto,
|
|
|
|
(unsigned short) prefix->nbytesAuthString,
|
|
|
|
auth_string);
|
|
|
|
|
|
|
|
return (SendConnSetup(client, reason));
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
SendErrorToClient(ClientPtr client, unsigned majorCode, unsigned minorCode,
|
2006-11-26 11:13:41 -07:00
|
|
|
XID resId, int errorCode)
|
|
|
|
{
|
2013-06-07 11:28:45 -06:00
|
|
|
xError rep = {
|
|
|
|
.type = X_Error,
|
|
|
|
.errorCode = errorCode,
|
|
|
|
.resourceID = resId,
|
|
|
|
.minorCode = minorCode,
|
|
|
|
.majorCode = majorCode
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteEventsToClient(client, 1, (xEvent *) &rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MarkClientException(ClientPtr client)
|
|
|
|
{
|
|
|
|
client->noClientException = -1;
|
|
|
|
}
|
2010-07-27 13:02:24 -06: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] = {
|
2012-06-10 07:21:05 -06:00
|
|
|
/* 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 */
|
2010-07-27 13:02:24 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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).
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
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 */
|
2010-07-27 13:02:24 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
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 */
|
2010-07-27 13:02:24 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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).
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
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 */
|
2010-07-27 13:02:24 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
static int init_screen(ScreenPtr pScreen, int i, Bool gpu)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
|
|
|
int scanlinepad, format, depth, bitsPerPixel, j, k;
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
dixInitScreenSpecificPrivates(pScreen);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
if (!dixAllocatePrivates(&pScreen->devPrivates, PRIVATE_SCREEN)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
return -1;
|
2010-12-05 08:36:02 -07:00
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
pScreen->myNum = i;
|
2013-06-07 11:28:45 -06:00
|
|
|
if (gpu) {
|
|
|
|
pScreen->myNum += GPU_SCREEN_OFFSET;
|
|
|
|
pScreen->isGPU = TRUE;
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
pScreen->totalPixmapSize = 0; /* computed in CreateScratchPixmapForScreen */
|
|
|
|
pScreen->ClipNotify = 0; /* for R4 ddx compatibility */
|
2010-07-27 13:02:24 -06:00
|
|
|
pScreen->CreateScreenResources = 0;
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
xorg_list_init(&pScreen->pixmap_dirty_list);
|
|
|
|
xorg_list_init(&pScreen->unattached_list);
|
|
|
|
xorg_list_init(&pScreen->output_slave_list);
|
|
|
|
xorg_list_init(&pScreen->offload_slave_list);
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
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;
|
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
AddScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ ,
|
|
|
|
int /*argc */ ,
|
|
|
|
char ** /*argv */
|
|
|
|
), int argc, char **argv)
|
|
|
|
{
|
|
|
|
|
|
|
|
int i;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
Bool ret;
|
|
|
|
|
|
|
|
i = screenInfo.numScreens;
|
|
|
|
if (i == MAXSCREENS)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
pScreen = (ScreenPtr) calloc(1, sizeof(ScreenRec));
|
|
|
|
if (!pScreen)
|
|
|
|
return -1;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
ret = init_screen(pScreen, i, FALSE);
|
|
|
|
if (ret != 0) {
|
|
|
|
free(pScreen);
|
|
|
|
return ret;
|
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
/* 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.
|
2012-06-10 07:21:05 -06:00
|
|
|
*/
|
2010-07-27 13:02:24 -06:00
|
|
|
screenInfo.screens[i] = pScreen;
|
|
|
|
screenInfo.numScreens++;
|
2013-06-07 11:28:45 -06:00
|
|
|
if (!(*pfnInit) (pScreen, argc, argv)) {
|
|
|
|
dixFreeScreenSpecificPrivates(pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
dixFreePrivates(pScreen->devPrivates, PRIVATE_SCREEN);
|
|
|
|
free(pScreen);
|
|
|
|
screenInfo.numScreens--;
|
|
|
|
return -1;
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
update_desktop_dimensions();
|
|
|
|
|
|
|
|
dixRegisterScreenPrivateKey(&cursorScreenDevPriv, pScreen, PRIVATE_CURSOR,
|
|
|
|
0);
|
2010-12-05 08:36:02 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
return i;
|
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
|
|
|
|
int
|
|
|
|
AddGPUScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ ,
|
|
|
|
int /*argc */ ,
|
|
|
|
char ** /*argv */
|
|
|
|
),
|
|
|
|
int argc, char **argv)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
Bool ret;
|
|
|
|
|
|
|
|
i = screenInfo.numGPUScreens;
|
|
|
|
if (i == MAXGPUSCREENS)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
pScreen = (ScreenPtr) calloc(1, sizeof(ScreenRec));
|
|
|
|
if (!pScreen)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
ret = init_screen(pScreen, i, TRUE);
|
|
|
|
if (ret != 0) {
|
|
|
|
free(pScreen);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
screenInfo.gpuscreens[i] = pScreen;
|
|
|
|
screenInfo.numGPUScreens++;
|
|
|
|
if (!(*pfnInit) (pScreen, argc, argv)) {
|
|
|
|
dixFreePrivates(pScreen->devPrivates, PRIVATE_SCREEN);
|
|
|
|
free(pScreen);
|
|
|
|
screenInfo.numGPUScreens--;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
update_desktop_dimensions();
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RemoveGPUScreen(ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
int idx, j;
|
|
|
|
if (!pScreen->isGPU)
|
|
|
|
return;
|
|
|
|
|
|
|
|
idx = pScreen->myNum - GPU_SCREEN_OFFSET;
|
|
|
|
for (j = idx; j < screenInfo.numGPUScreens - 1; j++) {
|
|
|
|
screenInfo.gpuscreens[j] = screenInfo.gpuscreens[j + 1];
|
|
|
|
screenInfo.gpuscreens[j]->myNum = j + GPU_SCREEN_OFFSET;
|
|
|
|
}
|
|
|
|
screenInfo.numGPUScreens--;
|
|
|
|
|
|
|
|
/* this gets freed later in the resource list, but without
|
|
|
|
* the screen existing it causes crashes - so remove it here */
|
|
|
|
if (pScreen->defColormap)
|
|
|
|
FreeResource(pScreen->defColormap, RT_COLORMAP);
|
|
|
|
free(pScreen);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AttachUnboundGPU(ScreenPtr pScreen, ScreenPtr new)
|
|
|
|
{
|
|
|
|
assert(new->isGPU);
|
|
|
|
assert(!new->current_master);
|
|
|
|
xorg_list_add(&new->unattached_head, &pScreen->unattached_list);
|
|
|
|
new->current_master = pScreen;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DetachUnboundGPU(ScreenPtr slave)
|
|
|
|
{
|
|
|
|
assert(slave->isGPU);
|
|
|
|
xorg_list_del(&slave->unattached_head);
|
|
|
|
slave->current_master = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AttachOutputGPU(ScreenPtr pScreen, ScreenPtr new)
|
|
|
|
{
|
|
|
|
assert(new->isGPU);
|
|
|
|
xorg_list_add(&new->output_head, &pScreen->output_slave_list);
|
|
|
|
new->current_master = pScreen;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DetachOutputGPU(ScreenPtr slave)
|
|
|
|
{
|
|
|
|
assert(slave->isGPU);
|
|
|
|
xorg_list_del(&slave->output_head);
|
|
|
|
slave->current_master = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AttachOffloadGPU(ScreenPtr pScreen, ScreenPtr new)
|
|
|
|
{
|
|
|
|
assert(new->isGPU);
|
|
|
|
xorg_list_add(&new->offload_head, &pScreen->offload_slave_list);
|
|
|
|
new->current_master = pScreen;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DetachOffloadGPU(ScreenPtr slave)
|
|
|
|
{
|
|
|
|
assert(slave->isGPU);
|
|
|
|
xorg_list_del(&slave->offload_head);
|
|
|
|
slave->current_master = NULL;
|
|
|
|
}
|
|
|
|
|