interactive.c revision 1088
/*
*
* 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,
* 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.
*/
/************************************************************
Basic boilerplate extension.
This file also contains the code to make the priocntl on behalf
of the clients.
Note that ChangePriority also sets the last client with focus
to the normal priority.
If there are knobs to be added to the system, for say the nice
values for the IA class, they would be added here.
********************************************************/
/* THIS IS NOT AN X CONSORTIUM STANDARD */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <errno.h>
#include <stdio.h>
#include <sys/priocntl.h>
#include <sys/iapriocntl.h>
#include <unistd.h>
#include "os.h"
#include "dixstruct.h"
#include "windowstr.h"
#include "inputstr.h"
#include "extnsionst.h"
#define _XIA_SERVER_
#include <X11/Xfuncproto.h>
#include "dix.h"
#include "interactive_srv.h"
static int InitializeClass(void);
static void SetIAPrivate(int *);
static void ChangeInteractive(ClientPtr);
static int SetPriority(const ClientProcessPtr, int);
int length);
/* static int LocalConnection(OsCommPtr); */
static int IAWrapProcVectors(void);
static int IAUnwrapProcVectors(void);
static unsigned long IAExtensionGeneration = 0;
static DevPrivateKeyRec IAPrivKeyRec;
#define IAPrivKey (&IAPrivKeyRec)
#define GetIAClient(pClient) \
static inline ClientProcessPtr
{
return NULL;
} else {
}
}
/* Set via xorg.conf option in loadable module */
int IADebugLevel = 0;
#define IA_DEBUG_BASIC 1
#define IA_DEBUG_PRIOCNTL 3
void
IAExtensionInit(void)
{
return;
if (InitializeClass() != Success)
return;
return;
return;
return;
return;
if (IAWrapProcVectors() != 0)
return;
return;
/* InitExtensions is called before InitClientPrivates(serverClient)
so we set this timer to callback as soon as we hit WaitForSomething
to initialize the serverClient */
"SolarisIA: Finished initializing (generation %ld)\n",
}
/* Allocate client private structure for this client */
static int
{
return Success;
}
return BadAlloc;
}
return Success;
}
/* Called when we first hit WaitForSomething to initialize serverClient */
static CARD32
{
if (InteractiveOS != TRUE)
return 0;
return 0;
}
/* Called when new client connects or existing client disconnects */
static void
{
switch (pClient->clientState) {
case ClientStateGone:
case ClientStateRetained:
return;
}
"SolarisIA: WindowManager closed (pid %d)\n",
}
}
}
break;
case ClientStateInitial:
}
}
break;
default:
break;
}
}
static int
{
{
case X_IAQueryVersion:
return ProcIAQueryVersion(client);
case X_IASetProcessInfo:
return ProcIASetProcessInfo(client);
case X_IAGetProcessInfo:
return ProcIAGetProcessInfo(client);
default:
return BadRequest;
}
}
static int
{
return (client->noClientException);
}
static int
{
register int length;
LocalClient(client)) {
}
LocalClient(client)) {
}
return (client->noClientException);
}
static int
{
register int length = 0;
int i;
} else {
if (write_back == NULL)
return ~Success;
else {
for (i = 0; i < CurrentPids->count; ++i)
}
}
}
if (write_back == NULL)
return ~Success;
}
(char *) write_back);
}
return (client->noClientException);
}
static void
{
}
/*
The SProc* functions are here for completeness. They should never get
called. But since they do the server has to eat the request and
return thanks for sharing.
*/
/*ARGSUSED*/
static int
{
{
case X_IAQueryVersion:
return SProcIAQueryVersion(client);
case X_IASetProcessInfo:
return SProcIASetProcessInfo(client);
case X_IAGetProcessInfo:
return SProcIAGetProcessInfo(client);
default:
return BadRequest;
}
}
/*ARGSUSED*/
static int
{
return (client->noClientException);
}
/*ARGSUSED*/
static int
{
return (client->noClientException);
}
/*ARGSUSED*/
static int
{
return (client->noClientException);
}
static void
{
if (InteractiveOS==FALSE)
return;
return;
}
/*
* Loop through pids associated with client. Magically make last focus
* group go non-interactive -IA_BOOST.
*/
static void
{
/* Shortcut. Focus changed between two windows with same pid */
return;
}
/* Remove priority boost for last focus group */
if (LastPids) {
}
/* If no pid info for current client, then we're done here.
* This can happen if we have a remote client with focus or if the client
* is statically linked or if it is using a down rev version of libX11.
*/
return;
}
/* Set the priority boost if it isn't already active */
if (!CurrentPids->boosted) {
}
/* Make sure server or wmgr isn't unset by testing for them, so
* that LastPids is never set to point to the server or wmgr pid.
*/
}
}
static int
InitializeClass(void)
{
/* Get TS class information */
/* Get IA class information */
return ~Success;
return Success;
}
static int
{
int i;
return Success;
}
if ( setegid(0) < 0 ) {
Error("Error in setting egid to 0");
}
Error("Error in resetting egid");
}
return ~Success; /* Scary time; punt */
}
/* If process is in TS or IA class we can safely set parameters */
switch (cmd) {
case UNSET_PRIORITY:
break;
case SET_PRIORITY:
break;
case SET_INTERACTIVE:
/* If this returns true, the process is already in the */
/* IA class, so we don't need to update it. */
continue;
break;
}
{
}
{
const char *cmdmsg;
switch (cmd) {
default: cmdmsg = "UNKNOWN_CMD!!!"; break;
}
});
}
}
Error("Error in resetting egid");
if (cmd == SET_PRIORITY) {
} else if (cmd == UNSET_PRIORITY) {
}
}
return ret;
}
static void
SetIAPrivate(int *value)
{
}
/*****************************************************************************
*/
/* In Xsun we used the osPrivate in OsCommPtr, so this was SetOsPrivate. */
static int
{
} else {
}
return BadAlloc;
return BadAlloc;
}
return Success;
}
static void
{
return;
}
/*
Check to see that all in current (a) are in last (b).
And that a and b have the same number of members in the set.
*/
static int
{
int retval = 1;
return 0; /* definately NOT the same set */
}
retval = 0;
retval = 1;
break;
}
}
if (retval == 0)
return retval;
}
return retval;
}
/*****************************************************************************
* Wrappers for normal procs - in Xsun we modified the original procs directly
* in dix, but here we wrap them for a small performance loss but a large
* increase in maintainability and ease of porting to new releases.
*/
static int
{
int res;
return res;
switch (focusID) {
case None:
break;
case PointerRoot:
break;
default:
return res;
}
}
return res;
}
static int
{
int res;
return res;
if ((InteractiveOS==TRUE) &&
{
if (inputFocus == NoneWin)
return Success;
/* If the input focus is PointerRootWin, send the event to where
the pointer is if possible, then perhaps propogate up to root. */
if (inputFocus == PointerRootWin)
else
pWin = inputFocus;
}
else
{
return res;
}
if (!pWin)
return BadWindow;
}
return res;
}
static Bool
{
while (tmask) {
if (index2 == CWEventMask) {
break;
}
pVlist++;
}
"SolarisIA: WindowManager detected (pid %d)\n",
}
}
}
static int
IAWrapProcVectors(void)
{
return 0;
}
static int
IAUnwrapProcVectors(void)
{
return 0;
}