diff options
-rw-r--r-- | compiz/Apply-this-patch-second-instead-of-0002.patch | 499 |
1 files changed, 499 insertions, 0 deletions
diff --git a/compiz/Apply-this-patch-second-instead-of-0002.patch b/compiz/Apply-this-patch-second-instead-of-0002.patch new file mode 100644 index 0000000..eb43ad2 --- /dev/null +++ b/compiz/Apply-this-patch-second-instead-of-0002.patch @@ -0,0 +1,499 @@ +From 40943030c021df26857a0e7e8b2d4cd94f2849b5 Mon Sep 17 00:00:00 2001 +From: Sam Spilsbury <Sam@XPS-SUSE.site> +Date: Thu, 19 Mar 2009 14:04:11 +0900 +Subject: [PATCH] Apply this patch second instead of 0002 + +--- + src/devices.c | 480 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 480 insertions(+), 0 deletions(-) + create mode 100644 src/devices.c + +diff --git a/src/devices.c b/src/devices.c +new file mode 100644 +index 0000000..e27828e +--- /dev/null ++++ b/src/devices.c +@@ -0,0 +1,480 @@ ++/* ++ * Copyright © 2008 University of South Australia ++ * ++ * 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, and that the name of ++ * the authors not be used in advertising or publicity pertaining to ++ * distribution of the software without specific, written prior permission. ++ * The authors make no representations about the suitability of this ++ * software for any purpose. It is provided "as is" without express or ++ * implied warranty. ++ * ++ * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, ++ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN ++ * NO EVENT SHALL THE AUTHORS 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. ++ * ++ * Author: Peter Hutterer <peter@cs.unisa.edu.au> ++ */ ++ ++#ifdef HAVE_CONFIG_H ++# include "../config.h" ++#endif ++ ++#include <string.h> ++ ++#include <compiz-core.h> ++ ++extern Bool inHandleEvent; ++ ++static Bool ++addDevice(CompDisplay *dpy, XDeviceInfo *info) ++{ ++ int ndevices = 0, ++ cls; ++ CompDevice *d; ++ XAnyClassInfo *any; ++ ++ if (info->use >= IsXExtensionDevice) /* don't care about SDs */ ++ return FALSE; ++ ++ if (!dpy->devices) ++ { ++ dpy->devices = calloc(2, sizeof(CompDevice)); ++ if (!dpy->devices) ++ return FALSE; ++ ndevices = 1; ++ d = dpy->devices; ++ } else ++ { ++ d = dpy->devices; ++ while(d->id != -1) ++ { ++ d++; ++ ndevices++; ++ } ++ dpy->devices = /* + new device, + termination */ ++ realloc(dpy->devices, (ndevices + 2) * sizeof(CompDevice)); ++ if (!dpy->devices) ++ return FALSE; ++ ++ d = &dpy->devices[ndevices]; ++ } ++ ++ ++ d->dev = XOpenDevice(dpy->display, info->id); ++ d->id = info->id; ++ d->use = info->use; ++ d->maxGrab = 0; ++ d->grabSize = 0; ++ d->grabs = NULL; ++ d->pointerX = 0; ++ d->pointerY = 0; ++ fprintf(stderr, "initializing button grabs\n"); ++ d->buttonGrab = 0; ++ d->nButtonGrab = 0; ++ d->keyGrab = 0; ++ d->nKeyGrab = 0; ++ ndevices++; ++ ++ if (info->use == IsXPointer) ++ { ++ Window root, child; ++ int winx, winy, mask; ++ XQueryDevicePointer(dpy->display, d->dev, ++ RootWindow(dpy->display, 0), ++ &root, &child, ++ &d->pointerX, &d->pointerY, ++ &winx, &winy, &mask); ++ DeviceMotionNotify (d->dev, ++ dpy->xi_motion, ++ d->cls_motion); ++ DeviceButtonPress (d->dev, ++ dpy->xi_btpress, ++ d->cls_btpress); ++ DeviceButtonRelease(d->dev, ++ dpy->xi_btrelease, ++ d->cls_btrelease); ++ DeviceEnterNotify (d->dev, ++ dpy->xi_enter, ++ d->cls_enter); ++ DeviceLeaveNotify (d->dev, ++ dpy->xi_leave, ++ d->cls_leave); ++ compLogMessage("devices", CompLogLevelDebug, ++ "Found pointer %s.\n", info->name); ++ } else if (info->use == IsXKeyboard) ++ { ++ DeviceKeyPress (d->dev, ++ dpy->xi_kpress, ++ d->cls_kpress); ++ DeviceKeyRelease(d->dev, ++ dpy->xi_krelease, ++ d->cls_krelease); ++ DeviceFocusIn (d->dev, ++ dpy->xi_focusin, ++ d->cls_focusin); ++ DeviceFocusOut (d->dev, ++ dpy->xi_focusout, ++ d->cls_focusout); ++ compLogMessage("devices", CompLogLevelDebug, ++ "Found keyboard %s.\n", info->name); ++ } ++ ++ any = info->inputclassinfo; ++ for (cls = 0; cls < info->num_classes; cls++) ++ { ++ if (any->class == AttachClass) ++ { ++ d->paired = ((XAttachInfoPtr)any)->attached; ++ break; ++ } ++ any = (XAnyClassPtr)((char*)any + any->length); ++ } ++ ++ /* sort-of NULL-terminate the list */ ++ d[1].id = -1; ++ d[1].use = -1; ++ ++ return TRUE; ++} ++ ++Bool ++compInitDeviceList(CompDisplay *display) ++{ ++ int ninfo, i; ++ XDeviceInfo *info = NULL; ++ XExtensionVersion *ext; ++ int ret = TRUE; ++ ++ display->devices = NULL; ++ display->xi_btpress = 0; ++ display->xi_btrelease = 0; ++ display->xi_motion = 0; ++ display->xi_kpress = 0; ++ display->xi_krelease = 0; ++ ++ ext = XQueryInputVersion(display->display, XI_2_Major, XI_2_Minor); ++ if (ext->major_version < XI_2_Major) ++ { ++ ret = FALSE; ++ compLogMessage("devices", CompLogLevelWarn, ++ "XI 2 not available.\n"); ++ goto unwind; ++ } ++ ++ info = XListInputDevices(display->display, &ninfo); ++ ++ for (i = 0; i < ninfo; i++) ++ { ++ if (info[i].use < IsXExtensionDevice) ++ addDevice(display, &info[i]); ++ } ++ ++unwind: ++ XFree(ext); ++ XFreeDeviceList(info); ++ return ret; ++} ++ ++/** ++ * Add the device with the given deviceid to compiz' internal device list. ++ */ ++Bool ++compAddDevice(CompDisplay *d, int deviceid) ++{ ++ XDeviceInfo *info = NULL; ++ int ninfo, i, ret = FALSE; ++ ++ info = XListInputDevices(d->display, &ninfo); ++ ++ for (i = 0; i < ninfo; i++) ++ { ++ if (info[i].id == deviceid) ++ { ++ ret = addDevice(d, &info[i]); ++ break; ++ } ++ } ++ ++ XFreeDeviceList(info); ++ return ret; ++} ++ ++void ++compRemoveDevice(CompDisplay *dpy, int deviceid) ++{ ++ CompDevice *d = dpy->devices; ++ CompDevice *remove = NULL; ++ int idx, ndevices = 0; ++ ++ while(d && d->id != -1) ++ { ++ if (d->id == deviceid) ++ { ++ remove = d; ++ idx = ndevices; ++ } ++ ndevices++; ++ d++; ++ } ++ ++ /* Reminder: the -1 termination device isn't counted in ndevices */ ++ if (remove) ++ { ++ XCloseDevice(dpy->display, remove->dev); ++ memmove(remove, &remove[1], (ndevices - idx) * sizeof(CompDevice)); ++ dpy->devices = realloc(dpy->devices, ndevices * sizeof(CompDevice)); ++ } ++} ++ ++ ++ ++/** ++ * Find and return the device with the given id or NULL if the id is invalid. ++ */ ++CompDevice* ++compFindDeviceById(CompDisplay *d, int id) ++{ ++ CompDevice *ret = d->devices; ++ ++ while(ret && ret->id != -1) ++ { ++ if (ret->id == id) ++ return ret; ++ ret++; ++ } ++ ++ return NULL; ++} ++ ++ ++int ++pushDeviceGrab(CompScreen *s, ++ CompDevice *device, ++ Cursor cursor, ++ const char *name) ++{ ++ CompDevice *ptr, *kbd; ++ ++ if (device->use == IsXPointer) ++ { ++ ptr = device; ++ kbd = compFindDeviceById(s->display, device->paired); ++ } else ++ { ++ ptr = compFindDeviceById(s->display, device->paired); ++ kbd = device; ++ } ++ ++ if (ptr->maxGrab == 0) ++ { ++ int status; ++ status = XExtendedGrabDevice(s->display->display, ++ ptr->dev, ++ s->grabWindow, ++ GrabModeAsync, ++ FALSE, ++ NULL, ++ cursor, ++ 3, &ptr->cls_btpress, ++ 0, NULL); ++ ++ if (status == GrabSuccess) ++ { ++ status = XGrabDevice(s->display->display, kbd->dev, ++ s->grabWindow, FALSE, ++ 2, &kbd->cls_kpress, ++ GrabModeAsync, GrabModeAsync, CurrentTime); ++ if (status != GrabSuccess) ++ { ++ XUngrabDevice(s->display->display, ptr->dev, CurrentTime); ++ return 0; ++ } ++ } else ++ return 0; ++ } ++ else ++ return 0; ++ ++ if (ptr->grabSize <= ptr->maxGrab) ++ { ++ ptr->grabs = realloc(ptr->grabs, ++ sizeof(CompGrab) * (ptr->maxGrab + 1)); ++ if (!ptr->grabs) ++ return 0; ++ ptr->grabSize = ptr->maxGrab + 1; ++ } ++ ++ /* In theory, ptr & kbd grabs should always be in sync, so we only update ++ * ptr's grab fields */ ++ ptr->grabs[ptr->maxGrab].active = TRUE; ++ ptr->grabs[ptr->maxGrab].name = name; ++ ptr->maxGrab++; ++ return ptr->maxGrab; ++} ++ ++void ++removeDeviceGrab(CompScreen *s, CompDevice *device, int index, ++ XPoint *restorePointer) ++{ ++ CompDevice *ptr, *kbd; ++ int maxGrab; ++ index--; ++ ++ if (device->use == IsXPointer) ++ { ++ ptr = device; ++ kbd = compFindDeviceById(s->display, device->paired); ++ } else ++ { ++ ptr = compFindDeviceById(s->display, device->paired); ++ kbd = device; ++ } ++ ++ ptr->grabs[index].active = FALSE; ++ for (maxGrab = ptr->maxGrab; maxGrab; maxGrab--) ++ if (ptr->grabs[maxGrab - 1].active) ++ break; ++ ++ if (maxGrab != ptr->maxGrab) ++ { ++ /* FIXME: ChangeActivePointerGrab equivalent? */ ++ if (!maxGrab) ++ { ++ if (restorePointer) ++ warpDevicePointer(s, ptr, ++ restorePointer->x - ptr->pointerX, ++ restorePointer->y - ptr->pointerY); ++ XUngrabDevice(s->display->display, ptr->dev, CurrentTime); ++ XUngrabDevice(s->display->display, kbd->dev, CurrentTime); ++ } ++ ++ ptr->maxGrab = maxGrab; ++ } ++} ++ ++void ++warpDevicePointer(CompScreen *s, CompDevice *dev, int dx, int dy) ++{ ++ CompDisplay *display = s->display; ++ ++ dev->pointerX += dx; ++ dev->pointerX += dy; ++ ++ if (dev->pointerX >= s->width) ++ dev->pointerX = s->width - 1; ++ else if (dev->pointerX < 0) ++ dev->pointerX = 0; ++ ++ if (dev->pointerY >= s->height) ++ dev->pointerY = s->height - 1; ++ else if (dev->pointerY < 0) ++ dev->pointerY = 0; ++ ++ XWarpDevicePointer(display->display, ++ dev->dev, ++ None, s->root, ++ 0, 0, 0, 0, ++ dx, dy); ++ XSync(display->display, FALSE); ++ ++ /* TODO: XCheckMaskEvent equivalent */ ++ ++ if (!inHandleEvent) ++ { ++ dev->lastPointerX = dev->pointerX; ++ dev->lastPointerY = dev->pointerY; ++ } ++} ++ ++/* otherScreenGrabExist takes a series of strings terminated by a NULL. ++ It returns TRUE if a grab exists but it is NOT held by one of the ++ plugins listed, returns FALSE otherwise. */ ++ ++Bool ++otherDeviceGrabExist (CompDevice *dev, ...) ++{ ++ va_list ap; ++ char *name; ++ int i; ++ ++ for (i = 0; dev && i < dev->maxGrab; i++) ++ { ++ if (dev->grabs[i].active) ++ { ++ va_start(ap, dev); ++ name = va_arg (ap, char *); ++ while(name) ++ { ++ if (strcmp(name, dev->grabs[i].name) == 0) ++ break; ++ ++ name = va_arg(ap, char*); ++ } ++ va_end(ap); ++ if (!name) ++ return TRUE; ++ } ++ } ++ return FALSE; ++} ++ ++/* Register for all XI events (including presence) on all root windows */ ++void ++compRegisterXIEvents(CompDisplay *d, Window w) ++{ ++ XEventClass *allclasses = NULL; ++ int nclasses = 0; ++ int idx = 0; ++ CompDevice *dev; ++ XEventClass cls_presence; ++ ++ nclasses = 1; /* device presence */ ++ ++ dev = d->devices; ++ while(dev->id != -1) ++ { ++ nclasses += 4; /* button press/rel and enter/leave, ++ or key press/rel and focus in/out, ++ depending on dev->use */ ++ dev++; ++ } ++ allclasses = malloc(nclasses * sizeof(XEventClass)); ++ ++ if (!allclasses) ++ return; ++ ++ DevicePresence(d->display, d->xi_presence, cls_presence); ++ allclasses[idx++] = cls_presence; ++ ++ dev = d->devices; ++ while(dev->id != -1) ++ { ++ ++ if (dev->use == IsXPointer) ++ { ++ allclasses[idx++] = dev->cls_btpress; ++ allclasses[idx++] = dev->cls_btrelease; ++ allclasses[idx++] = dev->cls_enter; ++ allclasses[idx++] = dev->cls_leave; ++ ++ } else if (dev->use == IsXKeyboard) ++ { ++ allclasses[idx++] = dev->cls_kpress; ++ allclasses[idx++] = dev->cls_krelease; ++ allclasses[idx++] = dev->cls_focusin; ++ allclasses[idx++] = dev->cls_focusout; ++ } ++ dev++; ++ } ++ ++ XSelectExtensionEvent(d->display, w, allclasses, nclasses); ++ free(allclasses); ++} +-- +1.5.6 + |