aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/kdrive/src/kinput.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/kdrive/src/kinput.c')
-rw-r--r--xorg-server/hw/kdrive/src/kinput.c1358
1 files changed, 661 insertions, 697 deletions
diff --git a/xorg-server/hw/kdrive/src/kinput.c b/xorg-server/hw/kdrive/src/kinput.c
index 968ebb159..e16fe78f2 100644
--- a/xorg-server/hw/kdrive/src/kinput.c
+++ b/xorg-server/hw/kdrive/src/kinput.c
@@ -35,14 +35,14 @@
#include <signal.h>
#include <stdio.h>
#ifdef sun
-#include <sys/file.h> /* needed for FNONBLOCK & FASYNC */
+#include <sys/file.h> /* needed for FNONBLOCK & FASYNC */
#endif
#include "xkbsrv.h"
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
-#include "XIstubs.h" /* even though we don't use stubs. cute, no? */
+#include "XIstubs.h" /* even though we don't use stubs. cute, no? */
#include "exevents.h"
#include "extinit.h"
#include "exglobals.h"
@@ -59,79 +59,80 @@ struct KdConfigDevice {
};
/* kdKeyboards and kdPointers hold all the real devices. */
-static KdKeyboardInfo *kdKeyboards = NULL;
-static KdPointerInfo *kdPointers = NULL;
-static struct KdConfigDevice *kdConfigKeyboards = NULL;
-static struct KdConfigDevice *kdConfigPointers = NULL;
+static KdKeyboardInfo *kdKeyboards = NULL;
+static KdPointerInfo *kdPointers = NULL;
+static struct KdConfigDevice *kdConfigKeyboards = NULL;
+static struct KdConfigDevice *kdConfigPointers = NULL;
static KdKeyboardDriver *kdKeyboardDrivers = NULL;
-static KdPointerDriver *kdPointerDrivers = NULL;
-
-static Bool kdInputEnabled;
-static Bool kdOffScreen;
-static unsigned long kdOffScreenTime;
-static KdPointerMatrix kdPointerMatrix = {
- { { 1, 0, 0 },
- { 0, 1, 0 } }
+static KdPointerDriver *kdPointerDrivers = NULL;
+
+static Bool kdInputEnabled;
+static Bool kdOffScreen;
+static unsigned long kdOffScreenTime;
+
+static KdPointerMatrix kdPointerMatrix = {
+ {{1, 0, 0},
+ {0, 1, 0}}
};
-void KdResetInputMachine (void);
+void KdResetInputMachine(void);
#define KD_MAX_INPUT_FDS 8
typedef struct _kdInputFd {
- int fd;
- void (*read) (int fd, void *closure);
- int (*enable) (int fd, void *closure);
- void (*disable) (int fd, void *closure);
- void *closure;
+ int fd;
+ void (*read) (int fd, void *closure);
+ int (*enable) (int fd, void *closure);
+ void (*disable) (int fd, void *closure);
+ void *closure;
} KdInputFd;
static KdInputFd kdInputFds[KD_MAX_INPUT_FDS];
-static int kdNumInputFds;
+static int kdNumInputFds;
-extern Bool kdRawPointerCoordinates;
+extern Bool kdRawPointerCoordinates;
static void
-KdSigio (int sig)
+KdSigio(int sig)
{
- int i;
+ int i;
for (i = 0; i < kdNumInputFds; i++)
- (*kdInputFds[i].read) (kdInputFds[i].fd, kdInputFds[i].closure);
+ (*kdInputFds[i].read) (kdInputFds[i].fd, kdInputFds[i].closure);
}
static void
-KdBlockSigio (void)
+KdBlockSigio(void)
{
- sigset_t set;
+ sigset_t set;
- sigemptyset (&set);
- sigaddset (&set, SIGIO);
- sigprocmask (SIG_BLOCK, &set, 0);
+ sigemptyset(&set);
+ sigaddset(&set, SIGIO);
+ sigprocmask(SIG_BLOCK, &set, 0);
}
static void
-KdUnblockSigio (void)
+KdUnblockSigio(void)
{
- sigset_t set;
+ sigset_t set;
- sigemptyset (&set);
- sigaddset (&set, SIGIO);
- sigprocmask (SIG_UNBLOCK, &set, 0);
+ sigemptyset(&set);
+ sigaddset(&set, SIGIO);
+ sigprocmask(SIG_UNBLOCK, &set, 0);
}
#ifdef DEBUG_SIGIO
void
-KdAssertSigioBlocked (char *where)
+KdAssertSigioBlocked(char *where)
{
- sigset_t set, old;
+ sigset_t set, old;
- sigemptyset (&set);
- sigprocmask (SIG_BLOCK, &set, &old);
- if (!sigismember (&old, SIGIO)) {
- ErrorF ("SIGIO not blocked at %s\n", where);
+ sigemptyset(&set);
+ sigprocmask(SIG_BLOCK, &set, &old);
+ if (!sigismember(&old, SIGIO)) {
+ ErrorF("SIGIO not blocked at %s\n", where);
KdBacktrace(0);
}
}
@@ -142,7 +143,7 @@ KdAssertSigioBlocked (char *where)
#endif
-static int kdnFds;
+static int kdnFds;
#ifdef FNONBLOCK
#define NOBLOCK FNONBLOCK
@@ -151,7 +152,7 @@ static int kdnFds;
#endif
void
-KdResetInputMachine (void)
+KdResetInputMachine(void)
{
KdPointerInfo *pi;
@@ -162,60 +163,60 @@ KdResetInputMachine (void)
}
static void
-KdNonBlockFd (int fd)
+KdNonBlockFd(int fd)
{
- int flags;
- flags = fcntl (fd, F_GETFL);
- flags |= FASYNC|NOBLOCK;
- fcntl (fd, F_SETFL, flags);
+ int flags;
+
+ flags = fcntl(fd, F_GETFL);
+ flags |= FASYNC | NOBLOCK;
+ fcntl(fd, F_SETFL, flags);
}
static void
-KdAddFd (int fd)
+KdAddFd(int fd)
{
- struct sigaction act;
- sigset_t set;
+ struct sigaction act;
+ sigset_t set;
kdnFds++;
- fcntl (fd, F_SETOWN, getpid());
- KdNonBlockFd (fd);
- AddEnabledDevice (fd);
- memset (&act, '\0', sizeof act);
+ fcntl(fd, F_SETOWN, getpid());
+ KdNonBlockFd(fd);
+ AddEnabledDevice(fd);
+ memset(&act, '\0', sizeof act);
act.sa_handler = KdSigio;
- sigemptyset (&act.sa_mask);
- sigaddset (&act.sa_mask, SIGIO);
- sigaddset (&act.sa_mask, SIGALRM);
- sigaddset (&act.sa_mask, SIGVTALRM);
- sigaction (SIGIO, &act, 0);
- sigemptyset (&set);
- sigprocmask (SIG_SETMASK, &set, 0);
+ sigemptyset(&act.sa_mask);
+ sigaddset(&act.sa_mask, SIGIO);
+ sigaddset(&act.sa_mask, SIGALRM);
+ sigaddset(&act.sa_mask, SIGVTALRM);
+ sigaction(SIGIO, &act, 0);
+ sigemptyset(&set);
+ sigprocmask(SIG_SETMASK, &set, 0);
}
static void
-KdRemoveFd (int fd)
+KdRemoveFd(int fd)
{
- struct sigaction act;
- int flags;
+ struct sigaction act;
+ int flags;
kdnFds--;
- RemoveEnabledDevice (fd);
- flags = fcntl (fd, F_GETFL);
- flags &= ~(FASYNC|NOBLOCK);
- fcntl (fd, F_SETFL, flags);
- if (kdnFds == 0)
- {
- memset (&act, '\0', sizeof act);
- act.sa_handler = SIG_IGN;
- sigemptyset (&act.sa_mask);
- sigaction (SIGIO, &act, 0);
+ RemoveEnabledDevice(fd);
+ flags = fcntl(fd, F_GETFL);
+ flags &= ~(FASYNC | NOBLOCK);
+ fcntl(fd, F_SETFL, flags);
+ if (kdnFds == 0) {
+ memset(&act, '\0', sizeof act);
+ act.sa_handler = SIG_IGN;
+ sigemptyset(&act.sa_mask);
+ sigaction(SIGIO, &act, 0);
}
}
Bool
-KdRegisterFd (int fd, void (*read) (int fd, void *closure), void *closure)
+KdRegisterFd(int fd, void (*read) (int fd, void *closure), void *closure)
{
if (kdNumInputFds == KD_MAX_INPUT_FDS)
- return FALSE;
+ return FALSE;
kdInputFds[kdNumInputFds].fd = fd;
kdInputFds[kdNumInputFds].read = read;
kdInputFds[kdNumInputFds].enable = 0;
@@ -223,38 +224,38 @@ KdRegisterFd (int fd, void (*read) (int fd, void *closure), void *closure)
kdInputFds[kdNumInputFds].closure = closure;
kdNumInputFds++;
if (kdInputEnabled)
- KdAddFd (fd);
+ KdAddFd(fd);
return TRUE;
}
void
-KdUnregisterFd (void *closure, int fd, Bool do_close)
+KdUnregisterFd(void *closure, int fd, Bool do_close)
{
- int i, j;
+ int i, j;
for (i = 0; i < kdNumInputFds; i++) {
- if (kdInputFds[i].closure == closure &&
+ if (kdInputFds[i].closure == closure &&
(fd == -1 || kdInputFds[i].fd == fd)) {
- if (kdInputEnabled)
- KdRemoveFd (kdInputFds[i].fd);
- if (do_close)
- close (kdInputFds[i].fd);
- kdNumInputFds--;
- for (j = i; j < kdNumInputFds; j++)
- kdInputFds[j] = kdInputFds[j+1];
+ if (kdInputEnabled)
+ KdRemoveFd(kdInputFds[i].fd);
+ if (do_close)
+ close(kdInputFds[i].fd);
+ kdNumInputFds--;
+ for (j = i; j < kdNumInputFds; j++)
+ kdInputFds[j] = kdInputFds[j + 1];
break;
- }
+ }
}
}
void
-KdUnregisterFds (void *closure, Bool do_close)
+KdUnregisterFds(void *closure, Bool do_close)
{
KdUnregisterFd(closure, -1, do_close);
}
void
-KdDisableInput (void)
+KdDisableInput(void)
{
KdKeyboardInfo *ki;
KdPointerInfo *pi;
@@ -283,7 +284,7 @@ KdDisableInput (void)
ErrorF(" fd %d belongs to keybd driver %s\n",
kdInputFds[i].fd,
ki->driver && ki->driver->name ?
- ki->driver->name : "(unnamed!)");
+ ki->driver->name : "(unnamed!)");
found = 1;
break;
}
@@ -299,7 +300,7 @@ KdDisableInput (void)
ErrorF(" fd %d belongs to pointer driver %s\n",
kdInputFds[i].fd,
pi->driver && pi->driver->name ?
- pi->driver->name : "(unnamed!)");
+ pi->driver->name : "(unnamed!)");
break;
}
}
@@ -319,7 +320,7 @@ KdDisableInput (void)
}
void
-KdEnableInput (void)
+KdEnableInput(void)
{
InternalEvent ev;
KdKeyboardInfo *ki;
@@ -338,14 +339,15 @@ KdEnableInput (void)
}
/* reset screen saver */
- ev.any.time = GetTimeInMillis ();
- NoticeEventTime (&ev);
+ ev.any.time = GetTimeInMillis();
+ NoticeEventTime(&ev, pi->dixdev);
+ NoticeEventTime(&ev, ki->dixdev);
- KdUnblockSigio ();
+ KdUnblockSigio();
}
static KdKeyboardDriver *
-KdFindKeyboardDriver (const char *name)
+KdFindKeyboardDriver(const char *name)
{
KdKeyboardDriver *ret;
@@ -362,7 +364,7 @@ KdFindKeyboardDriver (const char *name)
}
static KdPointerDriver *
-KdFindPointerDriver (const char *name)
+KdFindPointerDriver(const char *name)
{
KdPointerDriver *ret;
@@ -381,14 +383,14 @@ KdFindPointerDriver (const char *name)
static int
KdPointerProc(DeviceIntPtr pDevice, int onoff)
{
- DevicePtr pDev = (DevicePtr)pDevice;
- KdPointerInfo *pi;
- Atom xiclass;
- Atom *btn_labels;
- Atom *axes_labels;
+ DevicePtr pDev = (DevicePtr) pDevice;
+ KdPointerInfo *pi;
+ Atom xiclass;
+ Atom *btn_labels;
+ Atom *axes_labels;
if (!pDev)
- return BadImplementation;
+ return BadImplementation;
for (pi = kdPointers; pi; pi = pi->next) {
if (pi->dixdev && pi->dixdev->id == pDevice->id)
@@ -401,8 +403,7 @@ KdPointerProc(DeviceIntPtr pDevice, int onoff)
return BadImplementation;
}
- switch (onoff)
- {
+ switch (onoff) {
case DEVICE_INIT:
#ifdef DEBUG
ErrorF("initialising pointer %s ...\n", pi->name);
@@ -433,44 +434,43 @@ KdPointerProc(DeviceIntPtr pDevice, int onoff)
return !Success;
}
- btn_labels = calloc(pi->nButtons, sizeof(Atom));
- if (!btn_labels)
- return BadAlloc;
- axes_labels = calloc(pi->nAxes, sizeof(Atom));
- if (!axes_labels) {
- free(btn_labels);
- return BadAlloc;
- }
-
- switch(pi->nAxes)
- {
- default:
- case 7:
- btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
- case 6:
- btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
- case 5:
- btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
- case 4:
- btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
- case 3:
- btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
- case 2:
- btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
- case 1:
- btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
- case 0:
- break;
- }
-
- if (pi->nAxes >= 2) {
- axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
- axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
- }
-
- InitPointerDeviceStruct(pDev, pi->map, pi->nButtons, btn_labels,
- (PtrCtrlProcPtr)NoopDDA,
- GetMotionHistorySize(), pi->nAxes, axes_labels);
+ btn_labels = calloc(pi->nButtons, sizeof(Atom));
+ if (!btn_labels)
+ return BadAlloc;
+ axes_labels = calloc(pi->nAxes, sizeof(Atom));
+ if (!axes_labels) {
+ free(btn_labels);
+ return BadAlloc;
+ }
+
+ switch (pi->nAxes) {
+ default:
+ case 7:
+ btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
+ case 6:
+ btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
+ case 5:
+ btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
+ case 4:
+ btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
+ case 3:
+ btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
+ case 2:
+ btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
+ case 1:
+ btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
+ case 0:
+ break;
+ }
+
+ if (pi->nAxes >= 2) {
+ axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
+ axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+ }
+
+ InitPointerDeviceStruct(pDev, pi->map, pi->nButtons, btn_labels,
+ (PtrCtrlProcPtr) NoopDDA,
+ GetMotionHistorySize(), pi->nAxes, axes_labels);
free(btn_labels);
free(axes_labels);
@@ -485,7 +485,7 @@ KdPointerProc(DeviceIntPtr pDevice, int onoff)
AssignTypeAndName(pi->dixdev, xiclass,
pi->name ? pi->name : "Generic KDrive Pointer");
- return Success;
+ return Success;
case DEVICE_ON:
if (pDev->on == TRUE)
@@ -504,7 +504,7 @@ KdPointerProc(DeviceIntPtr pDevice, int onoff)
return BadImplementation;
}
- return Success;
+ return Success;
case DEVICE_OFF:
if (pDev->on == FALSE) {
@@ -523,7 +523,7 @@ KdPointerProc(DeviceIntPtr pDevice, int onoff)
return Success;
case DEVICE_CLOSE:
- if (pDev->on) {
+ if (pDev->on) {
if (!pi->driver->Disable) {
return BadImplementation;
}
@@ -552,7 +552,7 @@ LegalModifier(unsigned int key, DeviceIntPtr pDev)
}
static void
-KdBell (int volume, DeviceIntPtr pDev, pointer arg, int something)
+KdBell(int volume, DeviceIntPtr pDev, pointer arg, int something)
{
KeybdCtrl *ctrl = arg;
KdKeyboardInfo *ki = NULL;
@@ -574,7 +574,7 @@ DDXRingBell(int volume, int pitch, int duration)
KdKeyboardInfo *ki = NULL;
if (kdOsFuncs->Bell) {
- (*kdOsFuncs->Bell)(volume, pitch, duration);
+ (*kdOsFuncs->Bell) (volume, pitch, duration);
}
else {
for (ki = kdKeyboards; ki; ki = ki->next) {
@@ -585,7 +585,7 @@ DDXRingBell(int volume, int pitch, int duration)
}
void
-KdRingBell(KdKeyboardInfo *ki, int volume, int pitch, int duration)
+KdRingBell(KdKeyboardInfo * ki, int volume, int pitch, int duration)
{
if (!ki || !ki->driver || !ki->driver->Bell)
return;
@@ -594,9 +594,8 @@ KdRingBell(KdKeyboardInfo *ki, int volume, int pitch, int duration)
(*ki->driver->Bell) (ki, volume, pitch, duration);
}
-
static void
-KdSetLeds (KdKeyboardInfo *ki, int leds)
+KdSetLeds(KdKeyboardInfo * ki, int leds)
{
if (!ki || !ki->driver)
return;
@@ -608,75 +607,85 @@ KdSetLeds (KdKeyboardInfo *ki, int leds)
}
void
-KdSetLed (KdKeyboardInfo *ki, int led, Bool on)
+KdSetLed(KdKeyboardInfo * ki, int led, Bool on)
{
if (!ki || !ki->dixdev || !ki->dixdev->kbdfeed)
return;
- NoteLedState (ki->dixdev, led, on);
- KdSetLeds (ki, ki->dixdev->kbdfeed->ctrl.leds);
+ NoteLedState(ki->dixdev, led, on);
+ KdSetLeds(ki, ki->dixdev->kbdfeed->ctrl.leds);
}
void
-KdSetPointerMatrix (KdPointerMatrix *matrix)
+KdSetPointerMatrix(KdPointerMatrix * matrix)
{
kdPointerMatrix = *matrix;
}
void
-KdComputePointerMatrix (KdPointerMatrix *m, Rotation randr, int width,
- int height)
+KdComputePointerMatrix(KdPointerMatrix * m, Rotation randr, int width,
+ int height)
{
- int x_dir = 1, y_dir = 1;
- int i, j;
- int size[2];
+ int x_dir = 1, y_dir = 1;
+ int i, j;
+ int size[2];
- size[0] = width; size[1] = height;
+ size[0] = width;
+ size[1] = height;
if (randr & RR_Reflect_X)
- x_dir = -1;
+ x_dir = -1;
if (randr & RR_Reflect_Y)
- y_dir = -1;
+ y_dir = -1;
switch (randr & (RR_Rotate_All)) {
case RR_Rotate_0:
- m->matrix[0][0] = x_dir; m->matrix[0][1] = 0;
- m->matrix[1][0] = 0; m->matrix[1][1] = y_dir;
- break;
+ m->matrix[0][0] = x_dir;
+ m->matrix[0][1] = 0;
+ m->matrix[1][0] = 0;
+ m->matrix[1][1] = y_dir;
+ break;
case RR_Rotate_90:
- m->matrix[0][0] = 0; m->matrix[0][1] = -x_dir;
- m->matrix[1][0] = y_dir; m->matrix[1][1] = 0;
- break;
+ m->matrix[0][0] = 0;
+ m->matrix[0][1] = -x_dir;
+ m->matrix[1][0] = y_dir;
+ m->matrix[1][1] = 0;
+ break;
case RR_Rotate_180:
- m->matrix[0][0] = -x_dir; m->matrix[0][1] = 0;
- m->matrix[1][0] = 0; m->matrix[1][1] = -y_dir;
- break;
+ m->matrix[0][0] = -x_dir;
+ m->matrix[0][1] = 0;
+ m->matrix[1][0] = 0;
+ m->matrix[1][1] = -y_dir;
+ break;
case RR_Rotate_270:
- m->matrix[0][0] = 0; m->matrix[0][1] = x_dir;
- m->matrix[1][0] = -y_dir; m->matrix[1][1] = 0;
- break;
+ m->matrix[0][0] = 0;
+ m->matrix[0][1] = x_dir;
+ m->matrix[1][0] = -y_dir;
+ m->matrix[1][1] = 0;
+ break;
}
- for (i = 0; i < 2; i++)
- {
- m->matrix[i][2] = 0;
- for (j = 0 ; j < 2; j++)
- if (m->matrix[i][j] < 0)
- m->matrix[i][2] = size[j] - 1;
+ for (i = 0; i < 2; i++) {
+ m->matrix[i][2] = 0;
+ for (j = 0; j < 2; j++)
+ if (m->matrix[i][j] < 0)
+ m->matrix[i][2] = size[j] - 1;
}
}
void
-KdScreenToPointerCoords (int *x, int *y)
+KdScreenToPointerCoords(int *x, int *y)
{
- int (*m)[3] = kdPointerMatrix.matrix;
+ int (*m)[3] = kdPointerMatrix.matrix;
int div = m[0][1] * m[1][0] - m[1][1] * m[0][0];
int sx = *x;
int sy = *y;
- *x = (m[0][1] * sy - m[0][1] * m[1][2] + m[1][1] * m[0][2] - m[1][1] * sx) / div;
- *y = (m[1][0] * sx + m[0][0] * m[1][2] - m[1][0] * m[0][2] - m[0][0] * sy) / div;
+ *x = (m[0][1] * sy - m[0][1] * m[1][2] + m[1][1] * m[0][2] -
+ m[1][1] * sx) / div;
+ *y = (m[1][0] * sx + m[0][0] * m[1][2] - m[1][0] * m[0][2] -
+ m[0][0] * sy) / div;
}
static void
-KdKbdCtrl (DeviceIntPtr pDevice, KeybdCtrl *ctrl)
+KdKbdCtrl(DeviceIntPtr pDevice, KeybdCtrl * ctrl)
{
KdKeyboardInfo *ki;
@@ -698,14 +707,14 @@ extern KeybdCtrl defaultKeyboardControl;
static int
KdKeyboardProc(DeviceIntPtr pDevice, int onoff)
{
- Bool ret;
- DevicePtr pDev = (DevicePtr)pDevice;
+ Bool ret;
+ DevicePtr pDev = (DevicePtr) pDevice;
KdKeyboardInfo *ki;
Atom xiclass;
XkbRMLVOSet rmlvo;
if (!pDev)
- return BadImplementation;
+ return BadImplementation;
for (ki = kdKeyboards; ki; ki = ki->next) {
if (ki->dixdev && ki->dixdev->id == pDevice->id)
@@ -716,8 +725,7 @@ KdKeyboardProc(DeviceIntPtr pDevice, int onoff)
return BadImplementation;
}
- switch (onoff)
- {
+ switch (onoff) {
case DEVICE_INIT:
#ifdef DEBUG
ErrorF("initialising keyboard %s\n", ki->name);
@@ -754,10 +762,10 @@ KdKeyboardProc(DeviceIntPtr pDevice, int onoff)
rmlvo.layout = ki->xkbLayout;
rmlvo.variant = ki->xkbVariant;
rmlvo.options = ki->xkbOptions;
- ret = InitKeyboardDeviceStruct (pDevice, &rmlvo, KdBell, KdKbdCtrl);
- if (!ret) {
+ ret = InitKeyboardDeviceStruct(pDevice, &rmlvo, KdBell, KdKbdCtrl);
+ if (!ret) {
ErrorF("Couldn't initialise keyboard %s\n", ki->name);
- return BadImplementation;
+ return BadImplementation;
}
xiclass = AtomFromName(XI_KEYBOARD);
@@ -797,13 +805,13 @@ KdKeyboardProc(DeviceIntPtr pDevice, int onoff)
break;
case DEVICE_CLOSE:
- if (pDev->on) {
+ if (pDev->on) {
if (!ki->driver->Disable)
return BadImplementation;
(*ki->driver->Disable) (ki);
pDev->on = FALSE;
- }
+ }
if (!ki->driver->Fini)
return BadImplementation;
@@ -820,7 +828,7 @@ KdKeyboardProc(DeviceIntPtr pDevice, int onoff)
}
void
-KdAddPointerDriver (KdPointerDriver *driver)
+KdAddPointerDriver(KdPointerDriver * driver)
{
KdPointerDriver **prev;
@@ -835,7 +843,7 @@ KdAddPointerDriver (KdPointerDriver *driver)
}
void
-KdRemovePointerDriver (KdPointerDriver *driver)
+KdRemovePointerDriver(KdPointerDriver * driver)
{
KdPointerDriver *tmp;
@@ -852,7 +860,7 @@ KdRemovePointerDriver (KdPointerDriver *driver)
}
void
-KdAddKeyboardDriver (KdKeyboardDriver *driver)
+KdAddKeyboardDriver(KdKeyboardDriver * driver)
{
KdKeyboardDriver **prev;
@@ -867,7 +875,7 @@ KdAddKeyboardDriver (KdKeyboardDriver *driver)
}
void
-KdRemoveKeyboardDriver (KdKeyboardDriver *driver)
+KdRemoveKeyboardDriver(KdKeyboardDriver * driver)
{
KdKeyboardDriver *tmp;
@@ -884,9 +892,10 @@ KdRemoveKeyboardDriver (KdKeyboardDriver *driver)
}
KdKeyboardInfo *
-KdNewKeyboard (void)
+KdNewKeyboard(void)
{
KdKeyboardInfo *ki = calloc(sizeof(KdKeyboardInfo), 1);
+
if (!ki)
return NULL;
@@ -907,7 +916,7 @@ KdNewKeyboard (void)
}
int
-KdAddConfigKeyboard (char *keyboard)
+KdAddConfigKeyboard(char *keyboard)
{
struct KdConfigDevice **prev, *new;
@@ -928,7 +937,7 @@ KdAddConfigKeyboard (char *keyboard)
}
int
-KdAddKeyboard (KdKeyboardInfo *ki)
+KdAddKeyboard(KdKeyboardInfo * ki)
{
KdKeyboardInfo **prev;
@@ -953,7 +962,7 @@ KdAddKeyboard (KdKeyboardInfo *ki)
}
void
-KdRemoveKeyboard (KdKeyboardInfo *ki)
+KdRemoveKeyboard(KdKeyboardInfo * ki)
{
KdKeyboardInfo **prev;
@@ -971,7 +980,7 @@ KdRemoveKeyboard (KdKeyboardInfo *ki)
}
int
-KdAddConfigPointer (char *pointer)
+KdAddConfigPointer(char *pointer)
{
struct KdConfigDevice **prev, *new;
@@ -992,7 +1001,7 @@ KdAddConfigPointer (char *pointer)
}
int
-KdAddPointer (KdPointerInfo *pi)
+KdAddPointer(KdPointerInfo * pi)
{
KdPointerInfo **prev;
@@ -1016,7 +1025,7 @@ KdAddPointer (KdPointerInfo *pi)
}
void
-KdRemovePointer (KdPointerInfo *pi)
+KdRemovePointer(KdPointerInfo * pi)
{
KdPointerInfo **prev;
@@ -1039,15 +1048,13 @@ KdRemovePointer (KdPointerInfo *pi)
* evdev,,device=/dev/input/event1,xkbmodel=abnt2,xkblayout=br
*/
static Bool
-KdGetOptions (InputOption **options, char *string)
+KdGetOptions(InputOption **options, char *string)
{
- InputOption *newopt = NULL;
- char *key = NULL,
- *value = NULL;
- int tam_key = 0;
+ InputOption *newopt = NULL;
+ char *key = NULL, *value = NULL;
+ int tam_key = 0;
- if (strchr(string, '='))
- {
+ if (strchr(string, '=')) {
tam_key = (strchr(string, '=') - string);
key = strndup(string, tam_key);
if (!key)
@@ -1057,8 +1064,7 @@ KdGetOptions (InputOption **options, char *string)
if (!value)
goto out;
}
- else
- {
+ else {
key = strdup(string);
value = NULL;
}
@@ -1067,7 +1073,7 @@ KdGetOptions (InputOption **options, char *string)
if (newopt)
*options = newopt;
-out:
+ out:
free(key);
free(value);
@@ -1075,12 +1081,11 @@ out:
}
static void
-KdParseKbdOptions (KdKeyboardInfo *ki)
+KdParseKbdOptions(KdKeyboardInfo * ki)
{
InputOption *option = NULL;
- nt_list_for_each_entry(option, ki->options, list.next)
- {
+ nt_list_for_each_entry(option, ki->options, list.next) {
const char *key = input_option_get_key(option);
const char *value = input_option_get_value(option);
@@ -1094,21 +1099,21 @@ KdParseKbdOptions (KdKeyboardInfo *ki)
ki->xkbVariant = strdup(value);
else if (strcasecmp(key, "XkbOptions") == 0)
ki->xkbOptions = strdup(value);
- else if (!strcasecmp (key, "device"))
+ else if (!strcasecmp(key, "device"))
ki->path = strdup(value);
else
- ErrorF("Kbd option key (%s) of value (%s) not assigned!\n",
- key, value);
+ ErrorF("Kbd option key (%s) of value (%s) not assigned!\n",
+ key, value);
}
}
KdKeyboardInfo *
-KdParseKeyboard (char *arg)
+KdParseKeyboard(char *arg)
{
- char save[1024];
- char delim;
- InputOption *options = NULL;
- KdKeyboardInfo *ki = NULL;
+ char save[1024];
+ char delim;
+ InputOption *options = NULL;
+ KdKeyboardInfo *ki = NULL;
ki = KdNewKeyboard();
if (!ki)
@@ -1120,53 +1125,46 @@ KdParseKeyboard (char *arg)
ki->driverPrivate = NULL;
ki->next = NULL;
- if (!arg)
- {
+ if (!arg) {
ErrorF("keybd: no arg\n");
- KdFreeKeyboard (ki);
+ KdFreeKeyboard(ki);
return NULL;
}
- if (strlen (arg) >= sizeof (save))
- {
+ if (strlen(arg) >= sizeof(save)) {
ErrorF("keybd: arg too long\n");
- KdFreeKeyboard (ki);
+ KdFreeKeyboard(ki);
return NULL;
}
- arg = KdParseFindNext (arg, ",", save, &delim);
- if (!save[0])
- {
+ arg = KdParseFindNext(arg, ",", save, &delim);
+ if (!save[0]) {
ErrorF("keybd: failed on save[0]\n");
- KdFreeKeyboard (ki);
+ KdFreeKeyboard(ki);
return NULL;
}
- if (strcmp (save, "auto") == 0)
+ if (strcmp(save, "auto") == 0)
ki->driverPrivate = NULL;
else
ki->driverPrivate = strdup(save);
- if (delim != ',')
- {
+ if (delim != ',') {
return ki;
}
- arg = KdParseFindNext (arg, ",", save, &delim);
+ arg = KdParseFindNext(arg, ",", save, &delim);
- while (delim == ',')
- {
- arg = KdParseFindNext (arg, ",", save, &delim);
+ while (delim == ',') {
+ arg = KdParseFindNext(arg, ",", save, &delim);
- if (!KdGetOptions(&options, save))
- {
- KdFreeKeyboard(ki);
- return NULL;
+ if (!KdGetOptions(&options, save)) {
+ KdFreeKeyboard(ki);
+ return NULL;
}
}
- if (options)
- {
+ if (options) {
ki->options = options;
KdParseKbdOptions(ki);
}
@@ -1175,41 +1173,40 @@ KdParseKeyboard (char *arg)
}
static void
-KdParsePointerOptions (KdPointerInfo *pi)
+KdParsePointerOptions(KdPointerInfo * pi)
{
InputOption *option = NULL;
- nt_list_for_each_entry(option, pi->options, list.next)
- {
+ nt_list_for_each_entry(option, pi->options, list.next) {
const char *key = input_option_get_key(option);
const char *value = input_option_get_value(option);
- if (!strcmp (key, "emulatemiddle"))
+ if (!strcmp(key, "emulatemiddle"))
pi->emulateMiddleButton = TRUE;
- else if (!strcmp (key, "noemulatemiddle"))
+ else if (!strcmp(key, "noemulatemiddle"))
pi->emulateMiddleButton = FALSE;
- else if (!strcmp (key, "transformcoord"))
+ else if (!strcmp(key, "transformcoord"))
pi->transformCoordinates = TRUE;
- else if (!strcmp (key, "rawcoord"))
+ else if (!strcmp(key, "rawcoord"))
pi->transformCoordinates = FALSE;
- else if (!strcasecmp (key, "device"))
+ else if (!strcasecmp(key, "device"))
pi->path = strdup(value);
- else if (!strcasecmp (key, "protocol"))
+ else if (!strcasecmp(key, "protocol"))
pi->protocol = strdup(value);
else
ErrorF("Pointer option key (%s) of value (%s) not assigned!\n",
- key, value);
+ key, value);
}
}
KdPointerInfo *
-KdParsePointer (char *arg)
+KdParsePointer(char *arg)
{
- char save[1024];
- char delim;
- KdPointerInfo *pi = NULL;
- InputOption *options = NULL;
- int i = 0;
+ char save[1024];
+ char delim;
+ KdPointerInfo *pi = NULL;
+ InputOption *options = NULL;
+ int i = 0;
pi = KdNewPointer();
if (!pi)
@@ -1217,27 +1214,24 @@ KdParsePointer (char *arg)
pi->emulateMiddleButton = kdEmulateMiddleButton;
pi->transformCoordinates = !kdRawPointerCoordinates;
pi->protocol = NULL;
- pi->nButtons = 5; /* XXX should not be hardcoded */
+ pi->nButtons = 5; /* XXX should not be hardcoded */
pi->inputClass = KD_MOUSE;
- if (!arg)
- {
+ if (!arg) {
ErrorF("mouse: no arg\n");
- KdFreePointer (pi);
+ KdFreePointer(pi);
return NULL;
}
- if (strlen (arg) >= sizeof (save))
- {
+ if (strlen(arg) >= sizeof(save)) {
ErrorF("mouse: arg too long\n");
- KdFreePointer (pi);
+ KdFreePointer(pi);
return NULL;
}
- arg = KdParseFindNext (arg, ",", save, &delim);
- if (!save[0])
- {
+ arg = KdParseFindNext(arg, ",", save, &delim);
+ if (!save[0]) {
ErrorF("failed on save[0]\n");
- KdFreePointer (pi);
+ KdFreePointer(pi);
return NULL;
}
@@ -1246,41 +1240,35 @@ KdParsePointer (char *arg)
else
pi->driverPrivate = strdup(save);
- if (delim != ',')
- {
+ if (delim != ',') {
return pi;
}
- arg = KdParseFindNext (arg, ",", save, &delim);
+ arg = KdParseFindNext(arg, ",", save, &delim);
- while (delim == ',')
- {
- arg = KdParseFindNext (arg, ",", save, &delim);
- if (save[0] == '{')
- {
+ while (delim == ',') {
+ arg = KdParseFindNext(arg, ",", save, &delim);
+ if (save[0] == '{') {
char *s = save + 1;
- i = 0;
- while (*s && *s != '}')
- {
+
+ i = 0;
+ while (*s && *s != '}') {
if ('1' <= *s && *s <= '0' + pi->nButtons)
pi->map[i] = *s - '0';
else
- UseMsg ();
+ UseMsg();
s++;
- }
+ }
}
- else
- {
- if (!KdGetOptions(&options, save))
- {
+ else {
+ if (!KdGetOptions(&options, save)) {
KdFreePointer(pi);
return NULL;
}
}
}
- if (options)
- {
+ if (options) {
pi->options = options;
KdParsePointerOptions(pi);
}
@@ -1288,9 +1276,8 @@ KdParsePointer (char *arg)
return pi;
}
-
void
-KdInitInput (void)
+KdInitInput(void)
{
KdPointerInfo *pi;
KdKeyboardInfo *ki;
@@ -1317,7 +1304,7 @@ KdInitInput (void)
}
void
-KdCloseInput (void)
+KdCloseInput(void)
{
mieqFini();
}
@@ -1480,195 +1467,203 @@ typedef enum _inputAction {
#define MAX_ACTIONS 2
typedef struct _inputTransition {
- KdInputAction actions[MAX_ACTIONS];
+ KdInputAction actions[MAX_ACTIONS];
KdPointerState nextState;
} KdInputTransition;
static const
-KdInputTransition kdInputMachine[num_input_states][num_input_class] = {
+KdInputTransition kdInputMachine[num_input_states][num_input_class] = {
/* start */
{
- { { hold, setto }, button_1_pend }, /* v1 */
- { { deliver, noop }, start }, /* ^1 */
- { { deliver, noop }, button_2_down }, /* v2 */
- { { deliver, noop }, start }, /* ^2 */
- { { hold, setto }, button_3_pend }, /* v3 */
- { { deliver, noop }, start }, /* ^3 */
- { { deliver, noop }, start }, /* vo */
- { { deliver, noop }, start }, /* ^o */
- { { deliver, noop }, start }, /* <> */
- { { deliver, noop }, start }, /* <-> */
- { { noop, noop }, start }, /* k */
- { { noop, noop }, start }, /* ... */
- },
+ {{hold, setto}, button_1_pend}, /* v1 */
+ {{deliver, noop}, start}, /* ^1 */
+ {{deliver, noop}, button_2_down}, /* v2 */
+ {{deliver, noop}, start}, /* ^2 */
+ {{hold, setto}, button_3_pend}, /* v3 */
+ {{deliver, noop}, start}, /* ^3 */
+ {{deliver, noop}, start}, /* vo */
+ {{deliver, noop}, start}, /* ^o */
+ {{deliver, noop}, start}, /* <> */
+ {{deliver, noop}, start}, /* <-> */
+ {{noop, noop}, start}, /* k */
+ {{noop, noop}, start}, /* ... */
+ },
/* button_1_pend */
{
- { { noop, noop }, button_1_pend }, /* v1 */
- { { release, deliver }, start }, /* ^1 */
- { { release, deliver }, button_1_down }, /* v2 */
- { { release, deliver }, button_1_down }, /* ^2 */
- { { clearto, gen_down_2 }, synth_2_down_13 }, /* v3 */
- { { release, deliver }, button_1_down }, /* ^3 */
- { { release, deliver }, button_1_down }, /* vo */
- { { release, deliver }, button_1_down }, /* ^o */
- { { deliver, noop }, button_1_pend }, /* <> */
- { { release, deliver }, button_1_down }, /* <-> */
- { { noop, noop }, button_1_down }, /* k */
- { { release, noop }, button_1_down }, /* ... */
- },
+ {{noop, noop}, button_1_pend}, /* v1 */
+ {{release, deliver}, start}, /* ^1 */
+ {{release, deliver}, button_1_down}, /* v2 */
+ {{release, deliver}, button_1_down}, /* ^2 */
+ {{clearto, gen_down_2}, synth_2_down_13}, /* v3 */
+ {{release, deliver}, button_1_down}, /* ^3 */
+ {{release, deliver}, button_1_down}, /* vo */
+ {{release, deliver}, button_1_down}, /* ^o */
+ {{deliver, noop}, button_1_pend}, /* <> */
+ {{release, deliver}, button_1_down}, /* <-> */
+ {{noop, noop}, button_1_down}, /* k */
+ {{release, noop}, button_1_down}, /* ... */
+ },
/* button_1_down */
{
- { { noop, noop }, button_1_down }, /* v1 */
- { { deliver, noop }, start }, /* ^1 */
- { { deliver, noop }, button_1_down }, /* v2 */
- { { deliver, noop }, button_1_down }, /* ^2 */
- { { deliver, noop }, button_1_down }, /* v3 */
- { { deliver, noop }, button_1_down }, /* ^3 */
- { { deliver, noop }, button_1_down }, /* vo */
- { { deliver, noop }, button_1_down }, /* ^o */
- { { deliver, noop }, button_1_down }, /* <> */
- { { deliver, noop }, button_1_down }, /* <-> */
- { { noop, noop }, button_1_down }, /* k */
- { { noop, noop }, button_1_down }, /* ... */
- },
+ {{noop, noop}, button_1_down}, /* v1 */
+ {{deliver, noop}, start}, /* ^1 */
+ {{deliver, noop}, button_1_down}, /* v2 */
+ {{deliver, noop}, button_1_down}, /* ^2 */
+ {{deliver, noop}, button_1_down}, /* v3 */
+ {{deliver, noop}, button_1_down}, /* ^3 */
+ {{deliver, noop}, button_1_down}, /* vo */
+ {{deliver, noop}, button_1_down}, /* ^o */
+ {{deliver, noop}, button_1_down}, /* <> */
+ {{deliver, noop}, button_1_down}, /* <-> */
+ {{noop, noop}, button_1_down}, /* k */
+ {{noop, noop}, button_1_down}, /* ... */
+ },
/* button_2_down */
{
- { { deliver, noop }, button_2_down }, /* v1 */
- { { deliver, noop }, button_2_down }, /* ^1 */
- { { noop, noop }, button_2_down }, /* v2 */
- { { deliver, noop }, start }, /* ^2 */
- { { deliver, noop }, button_2_down }, /* v3 */
- { { deliver, noop }, button_2_down }, /* ^3 */
- { { deliver, noop }, button_2_down }, /* vo */
- { { deliver, noop }, button_2_down }, /* ^o */
- { { deliver, noop }, button_2_down }, /* <> */
- { { deliver, noop }, button_2_down }, /* <-> */
- { { noop, noop }, button_2_down }, /* k */
- { { noop, noop }, button_2_down }, /* ... */
- },
+ {{deliver, noop}, button_2_down}, /* v1 */
+ {{deliver, noop}, button_2_down}, /* ^1 */
+ {{noop, noop}, button_2_down}, /* v2 */
+ {{deliver, noop}, start}, /* ^2 */
+ {{deliver, noop}, button_2_down}, /* v3 */
+ {{deliver, noop}, button_2_down}, /* ^3 */
+ {{deliver, noop}, button_2_down}, /* vo */
+ {{deliver, noop}, button_2_down}, /* ^o */
+ {{deliver, noop}, button_2_down}, /* <> */
+ {{deliver, noop}, button_2_down}, /* <-> */
+ {{noop, noop}, button_2_down}, /* k */
+ {{noop, noop}, button_2_down}, /* ... */
+ },
/* button_3_pend */
{
- { { clearto, gen_down_2 }, synth_2_down_13 }, /* v1 */
- { { release, deliver }, button_3_down }, /* ^1 */
- { { release, deliver }, button_3_down }, /* v2 */
- { { release, deliver }, button_3_down }, /* ^2 */
- { { release, deliver }, button_3_down }, /* v3 */
- { { release, deliver }, start }, /* ^3 */
- { { release, deliver }, button_3_down }, /* vo */
- { { release, deliver }, button_3_down }, /* ^o */
- { { deliver, noop }, button_3_pend }, /* <> */
- { { release, deliver }, button_3_down }, /* <-> */
- { { release, noop }, button_3_down }, /* k */
- { { release, noop }, button_3_down }, /* ... */
- },
+ {{clearto, gen_down_2}, synth_2_down_13}, /* v1 */
+ {{release, deliver}, button_3_down}, /* ^1 */
+ {{release, deliver}, button_3_down}, /* v2 */
+ {{release, deliver}, button_3_down}, /* ^2 */
+ {{release, deliver}, button_3_down}, /* v3 */
+ {{release, deliver}, start}, /* ^3 */
+ {{release, deliver}, button_3_down}, /* vo */
+ {{release, deliver}, button_3_down}, /* ^o */
+ {{deliver, noop}, button_3_pend}, /* <> */
+ {{release, deliver}, button_3_down}, /* <-> */
+ {{release, noop}, button_3_down}, /* k */
+ {{release, noop}, button_3_down}, /* ... */
+ },
/* button_3_down */
{
- { { deliver, noop }, button_3_down }, /* v1 */
- { { deliver, noop }, button_3_down }, /* ^1 */
- { { deliver, noop }, button_3_down }, /* v2 */
- { { deliver, noop }, button_3_down }, /* ^2 */
- { { noop, noop }, button_3_down }, /* v3 */
- { { deliver, noop }, start }, /* ^3 */
- { { deliver, noop }, button_3_down }, /* vo */
- { { deliver, noop }, button_3_down }, /* ^o */
- { { deliver, noop }, button_3_down }, /* <> */
- { { deliver, noop }, button_3_down }, /* <-> */
- { { noop, noop }, button_3_down }, /* k */
- { { noop, noop }, button_3_down }, /* ... */
- },
+ {{deliver, noop}, button_3_down}, /* v1 */
+ {{deliver, noop}, button_3_down}, /* ^1 */
+ {{deliver, noop}, button_3_down}, /* v2 */
+ {{deliver, noop}, button_3_down}, /* ^2 */
+ {{noop, noop}, button_3_down}, /* v3 */
+ {{deliver, noop}, start}, /* ^3 */
+ {{deliver, noop}, button_3_down}, /* vo */
+ {{deliver, noop}, button_3_down}, /* ^o */
+ {{deliver, noop}, button_3_down}, /* <> */
+ {{deliver, noop}, button_3_down}, /* <-> */
+ {{noop, noop}, button_3_down}, /* k */
+ {{noop, noop}, button_3_down}, /* ... */
+ },
/* synthetic_2_down_13 */
{
- { { noop, noop }, synth_2_down_13 }, /* v1 */
- { { gen_up_2, noop }, synth_2_down_3 }, /* ^1 */
- { { noop, noop }, synth_2_down_13 }, /* v2 */
- { { noop, noop }, synth_2_down_13 }, /* ^2 */
- { { noop, noop }, synth_2_down_13 }, /* v3 */
- { { gen_up_2, noop }, synth_2_down_1 }, /* ^3 */
- { { deliver, noop }, synth_2_down_13 }, /* vo */
- { { deliver, noop }, synth_2_down_13 }, /* ^o */
- { { deliver, noop }, synth_2_down_13 }, /* <> */
- { { deliver, noop }, synth_2_down_13 }, /* <-> */
- { { noop, noop }, synth_2_down_13 }, /* k */
- { { noop, noop }, synth_2_down_13 }, /* ... */
- },
+ {{noop, noop}, synth_2_down_13}, /* v1 */
+ {{gen_up_2, noop}, synth_2_down_3}, /* ^1 */
+ {{noop, noop}, synth_2_down_13}, /* v2 */
+ {{noop, noop}, synth_2_down_13}, /* ^2 */
+ {{noop, noop}, synth_2_down_13}, /* v3 */
+ {{gen_up_2, noop}, synth_2_down_1}, /* ^3 */
+ {{deliver, noop}, synth_2_down_13}, /* vo */
+ {{deliver, noop}, synth_2_down_13}, /* ^o */
+ {{deliver, noop}, synth_2_down_13}, /* <> */
+ {{deliver, noop}, synth_2_down_13}, /* <-> */
+ {{noop, noop}, synth_2_down_13}, /* k */
+ {{noop, noop}, synth_2_down_13}, /* ... */
+ },
/* synthetic_2_down_3 */
{
- { { deliver, noop }, synth_2_down_3 }, /* v1 */
- { { deliver, noop }, synth_2_down_3 }, /* ^1 */
- { { deliver, noop }, synth_2_down_3 }, /* v2 */
- { { deliver, noop }, synth_2_down_3 }, /* ^2 */
- { { noop, noop }, synth_2_down_3 }, /* v3 */
- { { noop, noop }, start }, /* ^3 */
- { { deliver, noop }, synth_2_down_3 }, /* vo */
- { { deliver, noop }, synth_2_down_3 }, /* ^o */
- { { deliver, noop }, synth_2_down_3 }, /* <> */
- { { deliver, noop }, synth_2_down_3 }, /* <-> */
- { { noop, noop }, synth_2_down_3 }, /* k */
- { { noop, noop }, synth_2_down_3 }, /* ... */
- },
+ {{deliver, noop}, synth_2_down_3}, /* v1 */
+ {{deliver, noop}, synth_2_down_3}, /* ^1 */
+ {{deliver, noop}, synth_2_down_3}, /* v2 */
+ {{deliver, noop}, synth_2_down_3}, /* ^2 */
+ {{noop, noop}, synth_2_down_3}, /* v3 */
+ {{noop, noop}, start}, /* ^3 */
+ {{deliver, noop}, synth_2_down_3}, /* vo */
+ {{deliver, noop}, synth_2_down_3}, /* ^o */
+ {{deliver, noop}, synth_2_down_3}, /* <> */
+ {{deliver, noop}, synth_2_down_3}, /* <-> */
+ {{noop, noop}, synth_2_down_3}, /* k */
+ {{noop, noop}, synth_2_down_3}, /* ... */
+ },
/* synthetic_2_down_1 */
{
- { { noop, noop }, synth_2_down_1 }, /* v1 */
- { { noop, noop }, start }, /* ^1 */
- { { deliver, noop }, synth_2_down_1 }, /* v2 */
- { { deliver, noop }, synth_2_down_1 }, /* ^2 */
- { { deliver, noop }, synth_2_down_1 }, /* v3 */
- { { deliver, noop }, synth_2_down_1 }, /* ^3 */
- { { deliver, noop }, synth_2_down_1 }, /* vo */
- { { deliver, noop }, synth_2_down_1 }, /* ^o */
- { { deliver, noop }, synth_2_down_1 }, /* <> */
- { { deliver, noop }, synth_2_down_1 }, /* <-> */
- { { noop, noop }, synth_2_down_1 }, /* k */
- { { noop, noop }, synth_2_down_1 }, /* ... */
- },
+ {{noop, noop}, synth_2_down_1}, /* v1 */
+ {{noop, noop}, start}, /* ^1 */
+ {{deliver, noop}, synth_2_down_1}, /* v2 */
+ {{deliver, noop}, synth_2_down_1}, /* ^2 */
+ {{deliver, noop}, synth_2_down_1}, /* v3 */
+ {{deliver, noop}, synth_2_down_1}, /* ^3 */
+ {{deliver, noop}, synth_2_down_1}, /* vo */
+ {{deliver, noop}, synth_2_down_1}, /* ^o */
+ {{deliver, noop}, synth_2_down_1}, /* <> */
+ {{deliver, noop}, synth_2_down_1}, /* <-> */
+ {{noop, noop}, synth_2_down_1}, /* k */
+ {{noop, noop}, synth_2_down_1}, /* ... */
+ },
};
#define EMULATION_WINDOW 10
#define EMULATION_TIMEOUT 100
static int
-KdInsideEmulationWindow (KdPointerInfo *pi, int x, int y, int z)
+KdInsideEmulationWindow(KdPointerInfo * pi, int x, int y, int z)
{
pi->emulationDx = pi->heldEvent.x - x;
pi->emulationDy = pi->heldEvent.y - y;
- return (abs (pi->emulationDx) < EMULATION_WINDOW &&
- abs (pi->emulationDy) < EMULATION_WINDOW);
+ return (abs(pi->emulationDx) < EMULATION_WINDOW &&
+ abs(pi->emulationDy) < EMULATION_WINDOW);
}
static KdInputClass
-KdClassifyInput (KdPointerInfo *pi, int type, int x, int y, int z, int b)
+KdClassifyInput(KdPointerInfo * pi, int type, int x, int y, int z, int b)
{
switch (type) {
case ButtonPress:
- switch (b) {
- case 1: return down_1;
- case 2: return down_2;
- case 3: return down_3;
- default: return down_o;
- }
- break;
+ switch (b) {
+ case 1:
+ return down_1;
+ case 2:
+ return down_2;
+ case 3:
+ return down_3;
+ default:
+ return down_o;
+ }
+ break;
case ButtonRelease:
- switch (b) {
- case 1: return up_1;
- case 2: return up_2;
- case 3: return up_3;
- default: return up_o;
- }
- break;
+ switch (b) {
+ case 1:
+ return up_1;
+ case 2:
+ return up_2;
+ case 3:
+ return up_3;
+ default:
+ return up_o;
+ }
+ break;
case MotionNotify:
- if (pi->eventHeld && !KdInsideEmulationWindow(pi, x, y, z))
- return outside_box;
- else
- return motion;
+ if (pi->eventHeld && !KdInsideEmulationWindow(pi, x, y, z))
+ return outside_box;
+ else
+ return motion;
default:
- return keyboard;
+ return keyboard;
}
return keyboard;
}
#ifdef DEBUG
-char *kdStateNames[] = {
+char *kdStateNames[] = {
"start",
"button_1_pend",
"button_1_down",
@@ -1681,7 +1676,7 @@ char *kdStateNames[] = {
"num_input_states"
};
-char *kdClassNames[] = {
+char *kdClassNames[] = {
"down_1", "up_1",
"down_2", "up_2",
"down_3", "up_3",
@@ -1700,95 +1695,92 @@ char *kdActionNames[] = {
"gen_down_2",
"gen_up_2",
};
-#endif /* DEBUG */
+#endif /* DEBUG */
static void
-KdQueueEvent (DeviceIntPtr pDev, InternalEvent *ev)
+KdQueueEvent(DeviceIntPtr pDev, InternalEvent *ev)
{
- KdAssertSigioBlocked ("KdQueueEvent");
- mieqEnqueue (pDev, ev);
+ KdAssertSigioBlocked("KdQueueEvent");
+ mieqEnqueue(pDev, ev);
}
/* We return true if we're stealing the event. */
static Bool
-KdRunMouseMachine (KdPointerInfo *pi, KdInputClass c, int type, int x, int y,
- int z, int b, int absrel)
+KdRunMouseMachine(KdPointerInfo * pi, KdInputClass c, int type, int x, int y,
+ int z, int b, int absrel)
{
const KdInputTransition *t;
- int a;
+ int a;
c = KdClassifyInput(pi, type, x, y, z, b);
t = &kdInputMachine[pi->mouseState][c];
- for (a = 0; a < MAX_ACTIONS; a++)
- {
- switch (t->actions[a]) {
- case noop:
- break;
- case hold:
- pi->eventHeld = TRUE;
- pi->emulationDx = 0;
- pi->emulationDy = 0;
- pi->heldEvent.type = type;
+ for (a = 0; a < MAX_ACTIONS; a++) {
+ switch (t->actions[a]) {
+ case noop:
+ break;
+ case hold:
+ pi->eventHeld = TRUE;
+ pi->emulationDx = 0;
+ pi->emulationDy = 0;
+ pi->heldEvent.type = type;
pi->heldEvent.x = x;
pi->heldEvent.y = y;
pi->heldEvent.z = z;
pi->heldEvent.flags = b;
pi->heldEvent.absrel = absrel;
return TRUE;
- break;
- case setto:
- pi->emulationTimeout = GetTimeInMillis () + EMULATION_TIMEOUT;
- pi->timeoutPending = TRUE;
- break;
- case deliver:
- _KdEnqueuePointerEvent (pi, pi->heldEvent.type, pi->heldEvent.x,
- pi->heldEvent.y, pi->heldEvent.z,
- pi->heldEvent.flags, pi->heldEvent.absrel,
- TRUE);
- break;
- case release:
- pi->eventHeld = FALSE;
- pi->timeoutPending = FALSE;
- _KdEnqueuePointerEvent (pi, pi->heldEvent.type, pi->heldEvent.x,
- pi->heldEvent.y, pi->heldEvent.z,
- pi->heldEvent.flags, pi->heldEvent.absrel,
- TRUE);
+ break;
+ case setto:
+ pi->emulationTimeout = GetTimeInMillis() + EMULATION_TIMEOUT;
+ pi->timeoutPending = TRUE;
+ break;
+ case deliver:
+ _KdEnqueuePointerEvent(pi, pi->heldEvent.type, pi->heldEvent.x,
+ pi->heldEvent.y, pi->heldEvent.z,
+ pi->heldEvent.flags, pi->heldEvent.absrel,
+ TRUE);
+ break;
+ case release:
+ pi->eventHeld = FALSE;
+ pi->timeoutPending = FALSE;
+ _KdEnqueuePointerEvent(pi, pi->heldEvent.type, pi->heldEvent.x,
+ pi->heldEvent.y, pi->heldEvent.z,
+ pi->heldEvent.flags, pi->heldEvent.absrel,
+ TRUE);
return TRUE;
- break;
- case clearto:
- pi->timeoutPending = FALSE;
- break;
- case gen_down_2:
- _KdEnqueuePointerEvent (pi, ButtonPress, x, y, z, 2, absrel,
- TRUE);
- pi->eventHeld = FALSE;
+ break;
+ case clearto:
+ pi->timeoutPending = FALSE;
+ break;
+ case gen_down_2:
+ _KdEnqueuePointerEvent(pi, ButtonPress, x, y, z, 2, absrel, TRUE);
+ pi->eventHeld = FALSE;
return TRUE;
- break;
- case gen_up_2:
- _KdEnqueuePointerEvent (pi, ButtonRelease, x, y, z, 2, absrel,
- TRUE);
+ break;
+ case gen_up_2:
+ _KdEnqueuePointerEvent(pi, ButtonRelease, x, y, z, 2, absrel, TRUE);
return TRUE;
- break;
- }
+ break;
+ }
}
pi->mouseState = t->nextState;
return FALSE;
}
static int
-KdHandlePointerEvent (KdPointerInfo *pi, int type, int x, int y, int z, int b,
- int absrel)
+KdHandlePointerEvent(KdPointerInfo * pi, int type, int x, int y, int z, int b,
+ int absrel)
{
if (pi->emulateMiddleButton)
- return KdRunMouseMachine (pi, KdClassifyInput(pi, type, x, y, z, b),
- type, x, y, z, b, absrel);
+ return KdRunMouseMachine(pi, KdClassifyInput(pi, type, x, y, z, b),
+ type, x, y, z, b, absrel);
return FALSE;
}
static void
-KdReceiveTimeout (KdPointerInfo *pi)
+KdReceiveTimeout(KdPointerInfo * pi)
{
- KdRunMouseMachine (pi, timeout, 0, 0, 0, 0, 0, 0);
+ KdRunMouseMachine(pi, timeout, 0, 0, 0, 0, 0, 0);
}
/*
@@ -1805,17 +1797,16 @@ KdReceiveTimeout (KdPointerInfo *pi)
extern int nClients;
void
-KdReleaseAllKeys (void)
+KdReleaseAllKeys(void)
{
#if 0
- int key;
+ int key;
KdKeyboardInfo *ki;
- KdBlockSigio ();
+ KdBlockSigio();
for (ki = kdKeyboards; ki; ki = ki->next) {
- for (key = ki->keySyms.minKeyCode; key < ki->keySyms.maxKeyCode;
- key++) {
+ for (key = ki->keySyms.minKeyCode; key < ki->keySyms.maxKeyCode; key++) {
if (key_is_down(ki->dixdev, key, KEY_POSTED | KEY_PROCESSED)) {
KdHandleKeyboardEvent(ki, KeyRelease, key);
QueueGetKeyboardEvents(ki->dixdev, KeyRelease, key, NULL);
@@ -1823,56 +1814,55 @@ KdReleaseAllKeys (void)
}
}
- KdUnblockSigio ();
+ KdUnblockSigio();
#endif
}
static void
-KdCheckLock (void)
+KdCheckLock(void)
{
- KeyClassPtr keyc = NULL;
- Bool isSet = FALSE, shouldBeSet = FALSE;
- KdKeyboardInfo *tmp = NULL;
+ KeyClassPtr keyc = NULL;
+ Bool isSet = FALSE, shouldBeSet = FALSE;
+ KdKeyboardInfo *tmp = NULL;
for (tmp = kdKeyboards; tmp; tmp = tmp->next) {
if (tmp->LockLed && tmp->dixdev && tmp->dixdev->key) {
keyc = tmp->dixdev->key;
- isSet = (tmp->leds & (1 << (tmp->LockLed-1))) != 0;
+ isSet = (tmp->leds & (1 << (tmp->LockLed - 1))) != 0;
/* FIXME: Just use XKB indicators! */
- shouldBeSet = !!(XkbStateFieldFromRec(&keyc->xkbInfo->state) & LockMask);
+ shouldBeSet =
+ ! !(XkbStateFieldFromRec(&keyc->xkbInfo->state) & LockMask);
if (isSet != shouldBeSet)
- KdSetLed (tmp, tmp->LockLed, shouldBeSet);
+ KdSetLed(tmp, tmp->LockLed, shouldBeSet);
}
}
}
void
-KdEnqueueKeyboardEvent(KdKeyboardInfo *ki,
- unsigned char scan_code,
- unsigned char is_up)
+KdEnqueueKeyboardEvent(KdKeyboardInfo * ki,
+ unsigned char scan_code, unsigned char is_up)
{
unsigned char key_code;
- KeyClassPtr keyc = NULL;
+ KeyClassPtr keyc = NULL;
KeybdCtrl *ctrl = NULL;
int type;
if (!ki || !ki->dixdev || !ki->dixdev->kbdfeed || !ki->dixdev->key)
- return;
+ return;
keyc = ki->dixdev->key;
ctrl = &ki->dixdev->kbdfeed->ctrl;
- if (scan_code >= ki->minScanCode && scan_code <= ki->maxScanCode)
- {
- key_code = scan_code + KD_MIN_KEYCODE - ki->minScanCode;
+ if (scan_code >= ki->minScanCode && scan_code <= ki->maxScanCode) {
+ key_code = scan_code + KD_MIN_KEYCODE - ki->minScanCode;
- /*
- * Set up this event -- the type may be modified below
- */
- if (is_up)
- type = KeyRelease;
- else
- type = KeyPress;
+ /*
+ * Set up this event -- the type may be modified below
+ */
+ if (is_up)
+ type = KeyRelease;
+ else
+ type = KeyPress;
QueueKeyboardEvents(ki->dixdev, type, key_code, NULL);
}
@@ -1893,74 +1883,72 @@ KdEnqueueKeyboardEvent(KdKeyboardInfo *ki,
/* FIXME do something a little more clever to deal with multiple axes here */
void
-KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry,
+KdEnqueuePointerEvent(KdPointerInfo * pi, unsigned long flags, int rx, int ry,
int rz)
{
- CARD32 ms;
+ CARD32 ms;
unsigned char buttons;
- int x, y, z;
- int (*matrix)[3] = kdPointerMatrix.matrix;
+ int x, y, z;
+ int (*matrix)[3] = kdPointerMatrix.matrix;
unsigned long button;
- int n;
- int dixflags = 0;
+ int n;
+ int dixflags = 0;
if (!pi)
- return;
+ return;
ms = GetTimeInMillis();
/* we don't need to transform z, so we don't. */
if (flags & KD_MOUSE_DELTA) {
- if (pi->transformCoordinates) {
- x = matrix[0][0] * rx + matrix[0][1] * ry;
- y = matrix[1][0] * rx + matrix[1][1] * ry;
- }
- else {
- x = rx;
- y = ry;
- }
+ if (pi->transformCoordinates) {
+ x = matrix[0][0] * rx + matrix[0][1] * ry;
+ y = matrix[1][0] * rx + matrix[1][1] * ry;
+ }
+ else {
+ x = rx;
+ y = ry;
+ }
}
else {
- if (pi->transformCoordinates) {
- x = matrix[0][0] * rx + matrix[0][1] * ry + matrix[0][2];
- y = matrix[1][0] * rx + matrix[1][1] * ry + matrix[1][2];
- }
- else {
- x = rx;
- y = ry;
- }
+ if (pi->transformCoordinates) {
+ x = matrix[0][0] * rx + matrix[0][1] * ry + matrix[0][2];
+ y = matrix[1][0] * rx + matrix[1][1] * ry + matrix[1][2];
+ }
+ else {
+ x = rx;
+ y = ry;
+ }
}
z = rz;
- if (flags & KD_MOUSE_DELTA)
- {
- if (x || y || z)
- {
+ if (flags & KD_MOUSE_DELTA) {
+ if (x || y || z) {
dixflags = POINTER_RELATIVE | POINTER_ACCELERATE;
- _KdEnqueuePointerEvent(pi, MotionNotify, x, y, z, 0, dixflags, FALSE);
+ _KdEnqueuePointerEvent(pi, MotionNotify, x, y, z, 0, dixflags,
+ FALSE);
}
- } else
- {
+ }
+ else {
dixflags = POINTER_ABSOLUTE;
if (x != pi->dixdev->last.valuators[0] ||
y != pi->dixdev->last.valuators[1])
- _KdEnqueuePointerEvent(pi, MotionNotify, x, y, z, 0, dixflags, FALSE);
+ _KdEnqueuePointerEvent(pi, MotionNotify, x, y, z, 0, dixflags,
+ FALSE);
}
buttons = flags;
- for (button = KD_BUTTON_1, n = 1; n <= pi->nButtons;
- button <<= 1, n++) {
+ for (button = KD_BUTTON_1, n = 1; n <= pi->nButtons; button <<= 1, n++) {
if (((pi->buttonState & button) ^ (buttons & button)) &&
- !(buttons & button)) {
+ !(buttons & button)) {
_KdEnqueuePointerEvent(pi, ButtonRelease, x, y, z, n,
dixflags, FALSE);
- }
+ }
}
- for (button = KD_BUTTON_1, n = 1; n <= pi->nButtons;
- button <<= 1, n++) {
- if (((pi->buttonState & button) ^ (buttons & button)) &&
- (buttons & button)) {
+ for (button = KD_BUTTON_1, n = 1; n <= pi->nButtons; button <<= 1, n++) {
+ if (((pi->buttonState & button) ^ (buttons & button)) &&
+ (buttons & button)) {
_KdEnqueuePointerEvent(pi, ButtonPress, x, y, z, n,
dixflags, FALSE);
}
@@ -1970,8 +1958,8 @@ KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry,
}
void
-_KdEnqueuePointerEvent (KdPointerInfo *pi, int type, int x, int y, int z,
- int b, int absrel, Bool force)
+_KdEnqueuePointerEvent(KdPointerInfo * pi, int type, int x, int y, int z,
+ int b, int absrel, Bool force)
{
int valuators[3] = { x, y, z };
ValuatorMask mask;
@@ -1986,73 +1974,60 @@ _KdEnqueuePointerEvent (KdPointerInfo *pi, int type, int x, int y, int z,
}
void
-KdBlockHandler (int screen,
- pointer blockData,
- pointer timeout,
- pointer readmask)
+KdBlockHandler(int screen, pointer blockData, pointer timeout, pointer readmask)
{
- KdPointerInfo *pi;
- int myTimeout=0;
-
- for (pi = kdPointers; pi; pi = pi->next)
- {
- if (pi->timeoutPending)
- {
- int ms;
+ KdPointerInfo *pi;
+ int myTimeout = 0;
- ms = pi->emulationTimeout - GetTimeInMillis ();
- if (ms < 1)
- ms = 1;
- if(ms<myTimeout || myTimeout==0)
- myTimeout=ms;
- }
+ for (pi = kdPointers; pi; pi = pi->next) {
+ if (pi->timeoutPending) {
+ int ms;
+
+ ms = pi->emulationTimeout - GetTimeInMillis();
+ if (ms < 1)
+ ms = 1;
+ if (ms < myTimeout || myTimeout == 0)
+ myTimeout = ms;
+ }
}
/* if we need to poll for events, do that */
- if(kdOsFuncs->pollEvents)
- {
- (*kdOsFuncs->pollEvents)();
- myTimeout=20;
+ if (kdOsFuncs->pollEvents) {
+ (*kdOsFuncs->pollEvents) ();
+ myTimeout = 20;
}
- if(myTimeout>0)
- AdjustWaitForDelay (timeout, myTimeout);
+ if (myTimeout > 0)
+ AdjustWaitForDelay(timeout, myTimeout);
}
void
-KdWakeupHandler (int screen,
- pointer data,
- unsigned long lresult,
- pointer readmask)
+KdWakeupHandler(int screen,
+ pointer data, unsigned long lresult, pointer readmask)
{
- int result = (int) lresult;
- fd_set *pReadmask = (fd_set *) readmask;
- int i;
- KdPointerInfo *pi;
+ int result = (int) lresult;
+ fd_set *pReadmask = (fd_set *) readmask;
+ int i;
+ KdPointerInfo *pi;
- if (kdInputEnabled && result > 0)
- {
- for (i = 0; i < kdNumInputFds; i++)
- if (FD_ISSET (kdInputFds[i].fd, pReadmask))
- {
- KdBlockSigio ();
- (*kdInputFds[i].read) (kdInputFds[i].fd, kdInputFds[i].closure);
- KdUnblockSigio ();
- }
- }
- for (pi = kdPointers; pi; pi = pi->next)
- {
- if (pi->timeoutPending)
- {
- if ((long) (GetTimeInMillis () - pi->emulationTimeout) >= 0)
- {
- pi->timeoutPending = FALSE;
- KdBlockSigio ();
- KdReceiveTimeout (pi);
- KdUnblockSigio ();
- }
- }
+ if (kdInputEnabled && result > 0) {
+ for (i = 0; i < kdNumInputFds; i++)
+ if (FD_ISSET(kdInputFds[i].fd, pReadmask)) {
+ KdBlockSigio();
+ (*kdInputFds[i].read) (kdInputFds[i].fd, kdInputFds[i].closure);
+ KdUnblockSigio();
+ }
+ }
+ for (pi = kdPointers; pi; pi = pi->next) {
+ if (pi->timeoutPending) {
+ if ((long) (GetTimeInMillis() - pi->emulationTimeout) >= 0) {
+ pi->timeoutPending = FALSE;
+ KdBlockSigio();
+ KdReceiveTimeout(pi);
+ KdUnblockSigio();
+ }
+ }
}
if (kdSwitchPending)
- KdProcessSwitch ();
+ KdProcessSwitch();
}
#define KdScreenOrigin(pScreen) (&(KdGetScreenPriv(pScreen)->screen->origin))
@@ -2060,84 +2035,75 @@ KdWakeupHandler (int screen,
static Bool
KdCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y)
{
- ScreenPtr pScreen = *ppScreen;
- ScreenPtr pNewScreen;
- int n;
- int dx, dy;
- int best_x, best_y;
- int n_best_x, n_best_y;
- CARD32 ms;
+ ScreenPtr pScreen = *ppScreen;
+ ScreenPtr pNewScreen;
+ int n;
+ int dx, dy;
+ int best_x, best_y;
+ int n_best_x, n_best_y;
+ CARD32 ms;
if (kdDisableZaphod || screenInfo.numScreens <= 1)
- return FALSE;
+ return FALSE;
if (0 <= *x && *x < pScreen->width && 0 <= *y && *y < pScreen->height)
- return FALSE;
+ return FALSE;
- ms = GetTimeInMillis ();
+ ms = GetTimeInMillis();
if (kdOffScreen && (int) (ms - kdOffScreenTime) < 1000)
- return FALSE;
+ return FALSE;
kdOffScreen = TRUE;
kdOffScreenTime = ms;
n_best_x = -1;
best_x = 32767;
n_best_y = -1;
best_y = 32767;
- for (n = 0; n < screenInfo.numScreens; n++)
- {
- pNewScreen = screenInfo.screens[n];
- if (pNewScreen == pScreen)
- continue;
- dx = KdScreenOrigin(pNewScreen)->x - KdScreenOrigin(pScreen)->x;
- dy = KdScreenOrigin(pNewScreen)->y - KdScreenOrigin(pScreen)->y;
- if (*x < 0)
- {
- if (dx <= 0 && -dx < best_x)
- {
- best_x = -dx;
- n_best_x = n;
- }
- }
- else if (*x >= pScreen->width)
- {
- if (dx >= 0 && dx < best_x)
- {
- best_x = dx;
- n_best_x = n;
- }
- }
- if (*y < 0)
- {
- if (dy <= 0 && -dy < best_y)
- {
- best_y = -dy;
- n_best_y = n;
- }
- }
- else if (*y >= pScreen->height)
- {
- if (dy >= 0 && dy < best_y)
- {
- best_y = dy;
- n_best_y = n;
- }
- }
+ for (n = 0; n < screenInfo.numScreens; n++) {
+ pNewScreen = screenInfo.screens[n];
+ if (pNewScreen == pScreen)
+ continue;
+ dx = KdScreenOrigin(pNewScreen)->x - KdScreenOrigin(pScreen)->x;
+ dy = KdScreenOrigin(pNewScreen)->y - KdScreenOrigin(pScreen)->y;
+ if (*x < 0) {
+ if (dx <= 0 && -dx < best_x) {
+ best_x = -dx;
+ n_best_x = n;
+ }
+ }
+ else if (*x >= pScreen->width) {
+ if (dx >= 0 && dx < best_x) {
+ best_x = dx;
+ n_best_x = n;
+ }
+ }
+ if (*y < 0) {
+ if (dy <= 0 && -dy < best_y) {
+ best_y = -dy;
+ n_best_y = n;
+ }
+ }
+ else if (*y >= pScreen->height) {
+ if (dy >= 0 && dy < best_y) {
+ best_y = dy;
+ n_best_y = n;
+ }
+ }
}
if (best_y < best_x)
- n_best_x = n_best_y;
+ n_best_x = n_best_y;
if (n_best_x == -1)
- return FALSE;
+ return FALSE;
pNewScreen = screenInfo.screens[n_best_x];
if (*x < 0)
- *x += pNewScreen->width;
+ *x += pNewScreen->width;
if (*y < 0)
- *y += pNewScreen->height;
+ *y += pNewScreen->height;
if (*x >= pScreen->width)
- *x -= pScreen->width;
+ *x -= pScreen->width;
if (*y >= pScreen->height)
- *y -= pScreen->height;
+ *y -= pScreen->height;
*ppScreen = pNewScreen;
return TRUE;
@@ -2148,31 +2114,30 @@ KdCrossScreen(ScreenPtr pScreen, Bool entering)
{
}
-int KdCurScreen; /* current event screen */
+int KdCurScreen; /* current event screen */
static void
-KdWarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
+KdWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
{
- KdBlockSigio ();
+ KdBlockSigio();
KdCurScreen = pScreen->myNum;
miPointerWarpCursor(pDev, pScreen, x, y);
- KdUnblockSigio ();
+ KdUnblockSigio();
}
-miPointerScreenFuncRec kdPointerScreenFuncs =
-{
+miPointerScreenFuncRec kdPointerScreenFuncs = {
KdCursorOffScreen,
KdCrossScreen,
KdWarpCursor
};
void
-ProcessInputEvents (void)
+ProcessInputEvents(void)
{
mieqProcessInputEvents();
if (kdSwitchPending)
- KdProcessSwitch ();
- KdCheckLock ();
+ KdProcessSwitch();
+ KdCheckLock();
}
/* At the moment, absolute/relative is up to the client. */
@@ -2191,7 +2156,7 @@ SetDeviceValuators(register ClientPtr client, DeviceIntPtr pDev,
int
ChangeDeviceControl(register ClientPtr client, DeviceIntPtr pDev,
- xDeviceCtl *control)
+ xDeviceCtl * control)
{
switch (control->control) {
case DEVICE_RESOLUTION:
@@ -2214,7 +2179,7 @@ ChangeDeviceControl(register ClientPtr client, DeviceIntPtr pDev,
}
int
-NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
+NewInputDeviceRequest(InputOption *options, InputAttributes * attrs,
DeviceIntPtr *pdev)
{
InputOption *option = NULL;
@@ -2243,16 +2208,14 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
}
#ifdef CONFIG_HAL
else if (strcmp(key, "_source") == 0 &&
- strcmp(value, "server/hal") == 0)
- {
+ strcmp(value, "server/hal") == 0) {
ErrorF("Ignoring device from HAL.\n");
return BadValue;
}
#endif
#ifdef CONFIG_UDEV
else if (strcmp(key, "_source") == 0 &&
- strcmp(value, "server/udev") == 0)
- {
+ strcmp(value, "server/udev") == 0) {
ErrorF("Ignoring device from udev.\n");
return BadValue;
}
@@ -2317,7 +2280,8 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
if (pi) {
*pdev = pi->dixdev;
- } else if(ki) {
+ }
+ else if (ki) {
*pdev = ki->dixdev;
}