aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw')
-rw-r--r--xorg-server/hw/dmx/dmxinit.c2083
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyr.c2363
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyr.h4
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrinit.c830
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrlog.h4
-rw-r--r--xorg-server/hw/kdrive/ephyr/hostx.c40
-rw-r--r--xorg-server/hw/kdrive/ephyr/hostx.h4
-rw-r--r--xorg-server/hw/kdrive/ephyr/makefile6
-rw-r--r--xorg-server/hw/kdrive/src/kdrive.c6
-rw-r--r--xorg-server/hw/kdrive/src/kinput.c4727
-rw-r--r--xorg-server/hw/kdrive/src/kmap.c9
-rw-r--r--xorg-server/hw/kdrive/src/makefile14
-rw-r--r--xorg-server/hw/xfree86/common/compiler.h2722
-rw-r--r--xorg-server/hw/xwin/InitInput.c21
-rw-r--r--xorg-server/hw/xwin/InitOutput.c2266
-rw-r--r--xorg-server/hw/xwin/XWin.rc210
-rw-r--r--xorg-server/hw/xwin/ddraw.h2106
-rw-r--r--xorg-server/hw/xwin/makefile112
-rw-r--r--xorg-server/hw/xwin/win.h2889
-rw-r--r--xorg-server/hw/xwin/winallpriv.c8
-rw-r--r--xorg-server/hw/xwin/winauth.c417
-rw-r--r--xorg-server/hw/xwin/winclip.c2
-rw-r--r--xorg-server/hw/xwin/winclipboard.h14
-rw-r--r--xorg-server/hw/xwin/winclipboardinit.c2
-rw-r--r--xorg-server/hw/xwin/winclipboardtextconv.c310
-rw-r--r--xorg-server/hw/xwin/winclipboardthread.c965
-rw-r--r--xorg-server/hw/xwin/winclipboardunicode.c34
-rw-r--r--xorg-server/hw/xwin/winclipboardwndproc.c1179
-rw-r--r--xorg-server/hw/xwin/winclipboardwrappers.c1021
-rw-r--r--xorg-server/hw/xwin/winclipboardxevents.c1640
-rw-r--r--xorg-server/hw/xwin/wincmap.c1296
-rw-r--r--xorg-server/hw/xwin/winconfig.c99
-rw-r--r--xorg-server/hw/xwin/wincreatewnd.c31
-rw-r--r--xorg-server/hw/xwin/wincursor.c37
-rw-r--r--xorg-server/hw/xwin/windialogs.c1568
-rw-r--r--xorg-server/hw/xwin/winengine.c26
-rw-r--r--xorg-server/hw/xwin/winerror.c27
-rw-r--r--xorg-server/hw/xwin/winfont.c12
-rw-r--r--xorg-server/hw/xwin/wingc.c91
-rw-r--r--xorg-server/hw/xwin/wingetsp.c19
-rw-r--r--xorg-server/hw/xwin/winglobals.c292
-rw-r--r--xorg-server/hw/xwin/winkeybd.c1225
-rw-r--r--xorg-server/hw/xwin/winkeybd.h626
-rw-r--r--xorg-server/hw/xwin/winkeyhook.c3
-rw-r--r--xorg-server/hw/xwin/winlayouts.h2
-rw-r--r--xorg-server/hw/xwin/winmisc.c2
-rw-r--r--xorg-server/hw/xwin/winmouse.c773
-rw-r--r--xorg-server/hw/xwin/winmsg.c90
-rw-r--r--xorg-server/hw/xwin/winmsg.h21
-rw-r--r--xorg-server/hw/xwin/winmultiwindowicons.c1298
-rw-r--r--xorg-server/hw/xwin/winmultiwindowshape.c20
-rw-r--r--xorg-server/hw/xwin/winmultiwindowwindow.c1885
-rw-r--r--xorg-server/hw/xwin/winmultiwindowwm.c3339
-rw-r--r--xorg-server/hw/xwin/winmultiwindowwndproc.c76
-rw-r--r--xorg-server/hw/xwin/winnativegdi.c18
-rw-r--r--xorg-server/hw/xwin/winpfbdd.c32
-rw-r--r--xorg-server/hw/xwin/winpixmap.c48
-rw-r--r--xorg-server/hw/xwin/winpolyline.c2
-rw-r--r--xorg-server/hw/xwin/winprefs.c18
-rw-r--r--xorg-server/hw/xwin/winprefs.h381
-rw-r--r--xorg-server/hw/xwin/winprefslex.c2191
-rw-r--r--xorg-server/hw/xwin/winprefslex.l4
-rw-r--r--xorg-server/hw/xwin/winprefsyacc.c2248
-rw-r--r--xorg-server/hw/xwin/winprefsyacc.h128
-rw-r--r--xorg-server/hw/xwin/winprefsyacc.y917
-rw-r--r--xorg-server/hw/xwin/winpriv.c2
-rw-r--r--xorg-server/hw/xwin/winprocarg.c3102
-rw-r--r--xorg-server/hw/xwin/winregistry.c4
-rw-r--r--xorg-server/hw/xwin/winscrinit.c1567
-rw-r--r--xorg-server/hw/xwin/winshaddd.c47
-rw-r--r--xorg-server/hw/xwin/winshadddnl.c42
-rw-r--r--xorg-server/hw/xwin/winshadgdi.c50
-rw-r--r--xorg-server/hw/xwin/wintrayicon.c49
-rw-r--r--xorg-server/hw/xwin/winvalargs.c2
-rw-r--r--xorg-server/hw/xwin/winwin32rootless.c111
-rw-r--r--xorg-server/hw/xwin/winwin32rootlesswndproc.c8
-rw-r--r--xorg-server/hw/xwin/winwindow.c76
-rw-r--r--xorg-server/hw/xwin/winwindow.h26
-rw-r--r--xorg-server/hw/xwin/winwindowswm.c1285
-rw-r--r--xorg-server/hw/xwin/winwndproc.c58
-rw-r--r--xorg-server/hw/xwin/xlaunch/config.h42
-rw-r--r--xorg-server/hw/xwin/xlaunch/main.cc89
-rw-r--r--xorg-server/hw/xwin/xlaunch/makefile111
-rw-r--r--xorg-server/hw/xwin/xlaunch/resources/resources.h2
-rw-r--r--xorg-server/hw/xwin/xlaunch/resources/resources.rc2
-rw-r--r--xorg-server/hw/xwin/xlaunch/resources/strings.rc6
-rw-r--r--xorg-server/hw/xwin/xlaunch/window/makefile4
-rw-r--r--xorg-server/hw/xwin/xlaunch/window/util.cc2
-rw-r--r--xorg-server/hw/xwin/xlaunch/window/util.h4
-rw-r--r--xorg-server/hw/xwin/xlaunch/window/wizard.h1
90 files changed, 22163 insertions, 29382 deletions
diff --git a/xorg-server/hw/dmx/dmxinit.c b/xorg-server/hw/dmx/dmxinit.c
index f481cf5c9..739c4ca7f 100644
--- a/xorg-server/hw/dmx/dmxinit.c
+++ b/xorg-server/hw/dmx/dmxinit.c
@@ -1,1041 +1,1042 @@
-/*
- * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
- *
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation on 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
- * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
- * 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.
- */
-
-/*
- * Authors:
- * Kevin E. Martin <kem@redhat.com>
- * David H. Dawes <dawes@xfree86.org>
- * Rickard E. (Rik) Faith <faith@redhat.com>
- *
- */
-
-/** \file
- * Provide expected functions for initialization from the ddx layer and
- * global variables for the DMX server. */
-
-#ifdef HAVE_DMX_CONFIG_H
-#include <dmx-config.h>
-#endif
-
-#include "dmx.h"
-#include "dmxinit.h"
-#include "dmxsync.h"
-#include "dmxlog.h"
-#include "dmxinput.h"
-#include "dmxscrinit.h"
-#include "dmxcursor.h"
-#include "dmxfont.h"
-#include "config/dmxconfig.h"
-#include "dmxcb.h"
-#include "dmxprop.h"
-#include "dmxstat.h"
-#ifdef RENDER
-#include "dmxpict.h"
-#endif
-
-#include <X11/Xos.h> /* For gettimeofday */
-#include "dixstruct.h"
-#ifdef PANORAMIX
-#include "panoramiXsrv.h"
-#endif
-
-#include <signal.h> /* For SIGQUIT */
-
-#ifdef GLXEXT
-#include <GL/glx.h>
-#include <GL/glxint.h>
-#include "dmx_glxvisuals.h"
-#include <X11/extensions/Xext.h>
-#include <X11/extensions/extutil.h>
-
-extern void GlxSetVisualConfigs(
- int nconfigs,
- __GLXvisualConfig *configs,
- void **configprivs
-);
-#endif /* GLXEXT */
-
-/* Global variables available to all Xserver/hw/dmx routines. */
-int dmxNumScreens;
-DMXScreenInfo *dmxScreens;
-
-int dmxNumInputs;
-DMXInputInfo *dmxInputs;
-
-int dmxShadowFB = FALSE;
-
-XErrorEvent dmxLastErrorEvent;
-Bool dmxErrorOccurred = FALSE;
-
-char *dmxFontPath = NULL;
-
-Bool dmxOffScreenOpt = TRUE;
-
-Bool dmxSubdividePrimitives = TRUE;
-
-Bool dmxLazyWindowCreation = TRUE;
-
-Bool dmxUseXKB = TRUE;
-
-int dmxDepth = 0;
-
-#ifndef GLXEXT
-static Bool dmxGLXProxy = FALSE;
-#else
-Bool dmxGLXProxy = TRUE;
-
-Bool dmxGLXSwapGroupSupport = TRUE;
-
-Bool dmxGLXSyncSwap = FALSE;
-
-Bool dmxGLXFinishSwap = FALSE;
-#endif
-
-Bool dmxIgnoreBadFontPaths = FALSE;
-
-Bool dmxAddRemoveScreens = FALSE;
-
-/* dmxErrorHandler catches errors that occur when calling one of the
- * back-end servers. Some of this code is based on _XPrintDefaultError
- * in xc/lib/X11/XlibInt.c */
-static int dmxErrorHandler(Display *dpy, XErrorEvent *ev)
-{
-#define DMX_ERROR_BUF_SIZE 256
- /* RATS: these buffers are only used in
- * length-limited calls. */
- char buf[DMX_ERROR_BUF_SIZE];
- char request[DMX_ERROR_BUF_SIZE];
- _XExtension *ext = NULL;
-
- dmxErrorOccurred = TRUE;
- dmxLastErrorEvent = *ev;
-
- XGetErrorText(dpy, ev->error_code, buf, sizeof(buf));
- dmxLog(dmxWarning, "dmxErrorHandler: %s\n", buf);
-
- /* Find major opcode name */
- if (ev->request_code < 128) {
- XmuSnprintf(request, sizeof(request), "%d", ev->request_code);
- XGetErrorDatabaseText(dpy, "XRequest", request, "", buf, sizeof(buf));
- } else {
- for (ext = dpy->ext_procs;
- ext && ext->codes.major_opcode != ev->request_code;
- ext = ext->next);
- if (ext) strncpy(buf, ext->name, sizeof(buf));
- else buf[0] = '\0';
- }
- dmxLog(dmxWarning, " Major opcode: %d (%s)\n",
- ev->request_code, buf);
-
- /* Find minor opcode name */
- if (ev->request_code >= 128 && ext) {
- XmuSnprintf(request, sizeof(request), "%d", ev->request_code);
- XmuSnprintf(request, sizeof(request), "%s.%d",
- ext->name, ev->minor_code);
- XGetErrorDatabaseText(dpy, "XRequest", request, "", buf, sizeof(buf));
- dmxLog(dmxWarning, " Minor opcode: %d (%s)\n",
- ev->minor_code, buf);
- }
-
- /* Provide value information */
- switch (ev->error_code) {
- case BadValue:
- dmxLog(dmxWarning, " Value: 0x%x\n",
- ev->resourceid);
- break;
- case BadAtom:
- dmxLog(dmxWarning, " AtomID: 0x%x\n",
- ev->resourceid);
- break;
- default:
- dmxLog(dmxWarning, " ResourceID: 0x%x\n",
- ev->resourceid);
- break;
- }
-
- /* Provide serial number information */
- dmxLog(dmxWarning, " Failed serial number: %d\n",
- ev->serial);
- dmxLog(dmxWarning, " Current serial number: %d\n",
- dpy->request);
- return 0;
-}
-
-#ifdef GLXEXT
-static int dmxNOPErrorHandler(Display *dpy, XErrorEvent *ev)
-{
- return 0;
-}
-#endif
-
-Bool dmxOpenDisplay(DMXScreenInfo *dmxScreen)
-{
- if (!(dmxScreen->beDisplay = XOpenDisplay(dmxScreen->name)))
- return FALSE;
-
- dmxPropertyDisplay(dmxScreen);
- return TRUE;
-}
-
-void dmxSetErrorHandler(DMXScreenInfo *dmxScreen)
-{
- XSetErrorHandler(dmxErrorHandler);
-}
-
-static void dmxPrintScreenInfo(DMXScreenInfo *dmxScreen)
-{
- XWindowAttributes attribs;
- int ndepths = 0, *depths = NULL;
- int i;
- Display *dpy = dmxScreen->beDisplay;
- Screen *s = DefaultScreenOfDisplay(dpy);
- int scr = DefaultScreen(dpy);
-
- XGetWindowAttributes(dpy, DefaultRootWindow(dpy), &attribs);
- if (!(depths = XListDepths(dpy, scr, &ndepths))) ndepths = 0;
-
- dmxLogOutput(dmxScreen, "Name of display: %s\n", DisplayString(dpy));
- dmxLogOutput(dmxScreen, "Version number: %d.%d\n",
- ProtocolVersion(dpy), ProtocolRevision(dpy));
- dmxLogOutput(dmxScreen, "Vendor string: %s\n", ServerVendor(dpy));
- if (!strstr(ServerVendor(dpy), "XFree86")) {
- dmxLogOutput(dmxScreen, "Vendor release: %d\n", VendorRelease(dpy));
- } else {
- /* This code based on xdpyinfo.c */
- int v = VendorRelease(dpy);
- int major = -1, minor = -1, patch = -1, subpatch = -1;
-
- if (v < 336)
- major = v / 100, minor = (v / 10) % 10, patch = v % 10;
- else if (v < 3900) {
- major = v / 1000;
- minor = (v / 100) % 10;
- if (((v / 10) % 10) || (v % 10)) {
- patch = (v / 10) % 10;
- if (v % 10) subpatch = v % 10;
- }
- } else if (v < 40000000) {
- major = v / 1000;
- minor = (v / 10) % 10;
- if (v % 10) patch = v % 10;
- } else {
- major = v / 10000000;
- minor = (v / 100000) % 100;
- patch = (v / 1000) % 100;
- if (v % 1000) subpatch = v % 1000;
- }
- dmxLogOutput(dmxScreen, "Vendor release: %d (XFree86 version: %d.%d",
- v, major, minor);
- if (patch > 0) dmxLogOutputCont(dmxScreen, ".%d", patch);
- if (subpatch > 0) dmxLogOutputCont(dmxScreen, ".%d", subpatch);
- dmxLogOutputCont(dmxScreen, ")\n");
- }
-
-
- dmxLogOutput(dmxScreen, "Dimensions: %dx%d pixels\n",
- attribs.width, attribs.height);
- dmxLogOutput(dmxScreen, "%d depths on screen %d: ", ndepths, scr);
- for (i = 0; i < ndepths; i++)
- dmxLogOutputCont(dmxScreen, "%c%d", i ? ',' : ' ', depths[i]);
- dmxLogOutputCont(dmxScreen, "\n");
- dmxLogOutput(dmxScreen, "Depth of root window: %d plane%s (%d)\n",
- attribs.depth, attribs.depth == 1 ? "" : "s",
- DisplayPlanes(dpy, scr));
- dmxLogOutput(dmxScreen, "Number of colormaps: %d min, %d max\n",
- MinCmapsOfScreen(s), MaxCmapsOfScreen(s));
- dmxLogOutput(dmxScreen, "Options: backing-store %s, save-unders %s\n",
- (DoesBackingStore (s) == NotUseful) ? "no" :
- ((DoesBackingStore (s) == Always) ? "yes" : "when mapped"),
- DoesSaveUnders (s) ? "yes" : "no");
- dmxLogOutput(dmxScreen, "Window Manager running: %s\n",
- (dmxScreen->WMRunningOnBE) ? "yes" : "no");
-
- if (dmxScreen->WMRunningOnBE) {
- dmxLogOutputWarning(dmxScreen,
- "Window manager running "
- "-- colormaps not supported\n");
- }
- XFree(depths);
-}
-
-void dmxGetScreenAttribs(DMXScreenInfo *dmxScreen)
-{
- XWindowAttributes attribs;
- Display *dpy = dmxScreen->beDisplay;
-#ifdef GLXEXT
- int dummy;
-#endif
-
- XGetWindowAttributes(dpy, DefaultRootWindow(dpy), &attribs);
-
- dmxScreen->beWidth = attribs.width;
- dmxScreen->beHeight = attribs.height;
-
- /* Fill in missing geometry information */
- if (dmxScreen->scrnXSign < 0) {
- if (dmxScreen->scrnWidth) {
- dmxScreen->scrnX = (attribs.width - dmxScreen->scrnWidth
- - dmxScreen->scrnX);
- } else {
- dmxScreen->scrnWidth = attribs.width - dmxScreen->scrnX;
- dmxScreen->scrnX = 0;
- }
- }
- if (dmxScreen->scrnYSign < 0) {
- if (dmxScreen->scrnHeight) {
- dmxScreen->scrnY = (attribs.height - dmxScreen->scrnHeight
- - dmxScreen->scrnY);
- } else {
- dmxScreen->scrnHeight = attribs.height - dmxScreen->scrnY;
- dmxScreen->scrnY = 0;
- }
- }
- if (!dmxScreen->scrnWidth)
- dmxScreen->scrnWidth = attribs.width - dmxScreen->scrnX;
- if (!dmxScreen->scrnHeight)
- dmxScreen->scrnHeight = attribs.height - dmxScreen->scrnY;
-
- if (!dmxScreen->rootWidth) dmxScreen->rootWidth = dmxScreen->scrnWidth;
- if (!dmxScreen->rootHeight) dmxScreen->rootHeight = dmxScreen->scrnHeight;
- if (dmxScreen->rootWidth + dmxScreen->rootX > dmxScreen->scrnWidth)
- dmxScreen->rootWidth = dmxScreen->scrnWidth - dmxScreen->rootX;
- if (dmxScreen->rootHeight + dmxScreen->rootY > dmxScreen->scrnHeight)
- dmxScreen->rootHeight = dmxScreen->scrnHeight - dmxScreen->rootY;
-
- /* FIXME: Get these from the back-end server */
- dmxScreen->beXDPI = 75;
- dmxScreen->beYDPI = 75;
-
- dmxScreen->beDepth = attribs.depth; /* FIXME: verify that this
- * works always. In
- * particular, this will work
- * well for depth=16, will fail
- * because of colormap issues
- * at depth 8. More work needs
- * to be done here. */
-
- if (dmxScreen->beDepth <= 8) dmxScreen->beBPP = 8;
- else if (dmxScreen->beDepth <= 16) dmxScreen->beBPP = 16;
- else dmxScreen->beBPP = 32;
-
-#ifdef GLXEXT
- /* get the majorOpcode for the back-end GLX extension */
- XQueryExtension(dpy, "GLX", &dmxScreen->glxMajorOpcode,
- &dummy, &dmxScreen->glxErrorBase);
-#endif
-
- dmxPrintScreenInfo(dmxScreen);
- dmxLogOutput(dmxScreen, "%dx%d+%d+%d on %dx%d at depth=%d, bpp=%d\n",
- dmxScreen->scrnWidth, dmxScreen->scrnHeight,
- dmxScreen->scrnX, dmxScreen->scrnY,
- dmxScreen->beWidth, dmxScreen->beHeight,
- dmxScreen->beDepth, dmxScreen->beBPP);
- if (dmxScreen->beDepth == 8)
- dmxLogOutputWarning(dmxScreen,
- "Support for depth == 8 is not complete\n");
-}
-
-Bool dmxGetVisualInfo(DMXScreenInfo *dmxScreen)
-{
- int i;
- XVisualInfo visinfo;
-
- visinfo.screen = DefaultScreen(dmxScreen->beDisplay);
- dmxScreen->beVisuals = XGetVisualInfo(dmxScreen->beDisplay,
- VisualScreenMask,
- &visinfo,
- &dmxScreen->beNumVisuals);
-
- dmxScreen->beDefVisualIndex = -1;
-
- if (defaultColorVisualClass >= 0 || dmxDepth > 0) {
- for (i = 0; i < dmxScreen->beNumVisuals; i++)
- if (defaultColorVisualClass >= 0) {
- if (dmxScreen->beVisuals[i].class == defaultColorVisualClass) {
- if (dmxDepth > 0) {
- if (dmxScreen->beVisuals[i].depth == dmxDepth) {
- dmxScreen->beDefVisualIndex = i;
- break;
- }
- } else {
- dmxScreen->beDefVisualIndex = i;
- break;
- }
- }
- } else if (dmxScreen->beVisuals[i].depth == dmxDepth) {
- dmxScreen->beDefVisualIndex = i;
- break;
- }
- } else {
- visinfo.visualid =
- XVisualIDFromVisual(DefaultVisual(dmxScreen->beDisplay,
- visinfo.screen));
-
- for (i = 0; i < dmxScreen->beNumVisuals; i++)
- if (visinfo.visualid == dmxScreen->beVisuals[i].visualid) {
- dmxScreen->beDefVisualIndex = i;
- break;
- }
- }
-
- for (i = 0; i < dmxScreen->beNumVisuals; i++)
- dmxLogVisual(dmxScreen, &dmxScreen->beVisuals[i],
- (i == dmxScreen->beDefVisualIndex));
-
- return (dmxScreen->beDefVisualIndex >= 0);
-}
-
-void dmxGetColormaps(DMXScreenInfo *dmxScreen)
-{
- int i;
-
- dmxScreen->beNumDefColormaps = dmxScreen->beNumVisuals;
- dmxScreen->beDefColormaps = xalloc(dmxScreen->beNumDefColormaps *
- sizeof(*dmxScreen->beDefColormaps));
-
- for (i = 0; i < dmxScreen->beNumDefColormaps; i++)
- dmxScreen->beDefColormaps[i] =
- XCreateColormap(dmxScreen->beDisplay,
- DefaultRootWindow(dmxScreen->beDisplay),
- dmxScreen->beVisuals[i].visual,
- AllocNone);
-
- dmxScreen->beBlackPixel = BlackPixel(dmxScreen->beDisplay,
- DefaultScreen(dmxScreen->beDisplay));
- dmxScreen->beWhitePixel = WhitePixel(dmxScreen->beDisplay,
- DefaultScreen(dmxScreen->beDisplay));
-}
-
-void dmxGetPixmapFormats(DMXScreenInfo *dmxScreen)
-{
- dmxScreen->beDepths =
- XListDepths(dmxScreen->beDisplay, DefaultScreen(dmxScreen->beDisplay),
- &dmxScreen->beNumDepths);
-
- dmxScreen->bePixmapFormats =
- XListPixmapFormats(dmxScreen->beDisplay,
- &dmxScreen->beNumPixmapFormats);
-}
-
-static Bool dmxSetPixmapFormats(ScreenInfo *pScreenInfo,
- DMXScreenInfo *dmxScreen)
-{
- XPixmapFormatValues *bePixmapFormat;
- PixmapFormatRec *format;
- int i, j;
-
- pScreenInfo->imageByteOrder = ImageByteOrder(dmxScreen->beDisplay);
- pScreenInfo->bitmapScanlineUnit = BitmapUnit(dmxScreen->beDisplay);
- pScreenInfo->bitmapScanlinePad = BitmapPad(dmxScreen->beDisplay);
- pScreenInfo->bitmapBitOrder = BitmapBitOrder(dmxScreen->beDisplay);
-
- pScreenInfo->numPixmapFormats = 0;
- for (i = 0; i < dmxScreen->beNumPixmapFormats; i++) {
- bePixmapFormat = &dmxScreen->bePixmapFormats[i];
- for (j = 0; j < dmxScreen->beNumDepths; j++)
- if ((bePixmapFormat->depth == 1) ||
- (bePixmapFormat->depth == dmxScreen->beDepths[j])) {
- format = &pScreenInfo->formats[pScreenInfo->numPixmapFormats];
-
- format->depth = bePixmapFormat->depth;
- format->bitsPerPixel = bePixmapFormat->bits_per_pixel;
- format->scanlinePad = bePixmapFormat->scanline_pad;
-
- pScreenInfo->numPixmapFormats++;
- break;
- }
- }
-
- return TRUE;
-}
-
-void dmxCheckForWM(DMXScreenInfo *dmxScreen)
-{
- Status status;
- XWindowAttributes xwa;
-
- status = XGetWindowAttributes(dmxScreen->beDisplay,
- DefaultRootWindow(dmxScreen->beDisplay),
- &xwa);
- dmxScreen->WMRunningOnBE =
- (status &&
- ((xwa.all_event_masks & SubstructureRedirectMask) ||
- (xwa.all_event_masks & SubstructureNotifyMask)));
-}
-
-/** Initialize the display and collect relevant information about the
- * display properties */
-static void dmxDisplayInit(DMXScreenInfo *dmxScreen)
-{
- if (!dmxOpenDisplay(dmxScreen))
- dmxLog(dmxFatal,
- "dmxOpenDisplay: Unable to open display %s\n",
- dmxScreen->name);
-
- dmxSetErrorHandler(dmxScreen);
- dmxCheckForWM(dmxScreen);
- dmxGetScreenAttribs(dmxScreen);
-
- if (!dmxGetVisualInfo(dmxScreen))
- dmxLog(dmxFatal, "dmxGetVisualInfo: No matching visuals found\n");
-
- dmxGetColormaps(dmxScreen);
- dmxGetPixmapFormats(dmxScreen);
-}
-
-/* If this doesn't compile, just add || defined(yoursystem) to the line
- * below. This information is to help with bug reports and is not
- * critical. */
-#if !defined(_POSIX_SOURCE)
-static const char *dmxExecOS(void) { return ""; }
-#else
-#include <sys/utsname.h>
-static const char *dmxExecOS(void)
-{
- static char buffer[128];
- static int initialized = 0;
- struct utsname u;
-
- if (!initialized++) {
- memset(buffer, 0, sizeof(buffer));
- uname(&u);
- XmuSnprintf(buffer, sizeof(buffer)-1, "%s %s %s",
- u.sysname, u.release, u.version);
- }
- return buffer;
-}
-#endif
-
-static const char *dmxBuildCompiler(void)
-{
- static char buffer[128];
- static int initialized = 0;
-
- if (!initialized++) {
- memset(buffer, 0, sizeof(buffer));
-#if defined(__GNUC__) && defined(__GNUC_MINOR__) &&defined(__GNUC_PATCHLEVEL__)
- XmuSnprintf(buffer, sizeof(buffer)-1, "gcc %d.%d.%d",
- __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
-#endif
- }
- return buffer;
-}
-
-static const char *dmxExecHost(void)
-{
- static char buffer[128];
- static int initialized = 0;
-
- if (!initialized++) {
- memset(buffer, 0, sizeof(buffer));
- XmuGetHostname(buffer, sizeof(buffer) - 1);
- }
- return buffer;
-}
-
-/** This routine is called in Xserver/dix/main.c from \a main(). */
-void InitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[])
-{
- int i;
- static unsigned long dmxGeneration = 0;
-#ifdef GLXEXT
- Bool glxSupported = TRUE;
-#endif
-
- if (dmxGeneration != serverGeneration) {
- int vendrel = VENDOR_RELEASE;
- int major, minor, year, month, day;
-
- dmxGeneration = serverGeneration;
-
- major = vendrel / 100000000;
- vendrel -= major * 100000000;
- minor = vendrel / 1000000;
- vendrel -= minor * 1000000;
- year = vendrel / 10000;
- vendrel -= year * 10000;
- month = vendrel / 100;
- vendrel -= month * 100;
- day = vendrel;
-
- /* Add other epoch tests here */
- if (major > 0 && minor > 0) year += 2000;
-
- dmxLog(dmxInfo, "Generation: %d\n", dmxGeneration);
- dmxLog(dmxInfo, "DMX version: %d.%d.%02d%02d%02d (%s)\n",
- major, minor, year, month, day, VENDOR_STRING);
-
- SetVendorRelease(VENDOR_RELEASE);
- SetVendorString(VENDOR_STRING);
-
- if (dmxGeneration == 1) {
- dmxLog(dmxInfo, "DMX Build OS: %s (%s)\n", OSNAME, OSVENDOR);
- dmxLog(dmxInfo, "DMX Build Compiler: %s\n", dmxBuildCompiler());
- dmxLog(dmxInfo, "DMX Execution OS: %s\n", dmxExecOS());
- dmxLog(dmxInfo, "DMX Execution Host: %s\n", dmxExecHost());
- }
- dmxLog(dmxInfo, "MAXSCREENS: %d\n", MAXSCREENS);
-
- for (i = 0; i < dmxNumScreens; i++) {
- if (dmxScreens[i].beDisplay)
- dmxLog(dmxWarning, "Display \"%s\" still open\n",
- dmxScreens[i].name);
- dmxStatFree(dmxScreens[i].stat);
- dmxScreens[i].stat = NULL;
- }
- for (i = 0; i < dmxNumInputs; i++) dmxInputFree(&dmxInputs[i]);
- if (dmxScreens) free(dmxScreens);
- if (dmxInputs) free(dmxInputs);
- dmxScreens = NULL;
- dmxInputs = NULL;
- dmxNumScreens = 0;
- dmxNumInputs = 0;
- }
-
- /* Make sure that the command-line arguments are sane. */
- if (dmxAddRemoveScreens && dmxGLXProxy) {
- /* Currently it is not possible to support GLX and Render
- * extensions with dynamic screen addition/removal due to the
- * state that each extension keeps, which cannot be restored. */
- dmxLog(dmxWarning,
- "GLX Proxy and Render extensions do not yet support dynamic\n");
- dmxLog(dmxWarning,
- "screen addition and removal. Please specify -noglxproxy\n");
- dmxLog(dmxWarning,
- "and -norender on the command line or in the configuration\n");
- dmxLog(dmxWarning,
- "file to disable these two extensions if you wish to use\n");
- dmxLog(dmxWarning,
- "the dynamic addition and removal of screens support.\n");
- dmxLog(dmxFatal,
- "Dynamic screen addition/removal error (see above).\n");
- }
-
- /* ddxProcessArgument has been called at this point, but any data
- * from the configuration file has not been applied. Do so, and be
- * sure we have at least one back-end display. */
- dmxConfigConfigure();
- if (!dmxNumScreens)
- dmxLog(dmxFatal, "InitOutput: no back-end displays found\n");
- if (!dmxNumInputs)
- dmxLog(dmxInfo, "InitOutput: no inputs found\n");
-
- /* Disable lazy window creation optimization if offscreen
- * optimization is disabled */
- if (!dmxOffScreenOpt && dmxLazyWindowCreation) {
- dmxLog(dmxInfo,
- "InitOutput: Disabling lazy window creation optimization\n");
- dmxLog(dmxInfo,
- " since it requires the offscreen optimization\n");
- dmxLog(dmxInfo,
- " to function properly.\n");
- dmxLazyWindowCreation = FALSE;
- }
-
- /* Open each display and gather information about it. */
- for (i = 0; i < dmxNumScreens; i++)
- dmxDisplayInit(&dmxScreens[i]);
-
-#if PANORAMIX
- /* Register a Xinerama callback which will run from within
- * PanoramiXCreateConnectionBlock. We can use the callback to
- * determine if Xinerama is loaded and to check the visuals
- * determined by PanoramiXConsolidate. */
- XineramaRegisterConnectionBlockCallback(dmxConnectionBlockCallback);
-#endif
-
- /* Since we only have a single screen thus far, we only need to set
- the pixmap formats to match that screen. FIXME: this isn't true.*/
- if (!dmxSetPixmapFormats(pScreenInfo, &dmxScreens[0])) return;
-
- /* Might want to install a signal handler to allow cleaning up after
- * unexpected signals. The DIX/OS layer already handles SIGINT and
- * SIGTERM, so everything is OK for expected signals. --DD
- *
- * SIGHUP, SIGINT, and SIGTERM are trapped in os/connection.c
- * SIGQUIT is another common signal that is sent from the keyboard.
- * Trap it here, to ensure that the keyboard modifier map and other
- * state for the input devices are restored. (This makes the
- * behavior of SIGQUIT somewhat unexpected, since it will be the
- * same as the behavior of SIGINT. However, leaving the modifier
- * map of the input devices empty is even more unexpected.) --RF
- */
- OsSignal(SIGQUIT, GiveUp);
-
-#ifdef GLXEXT
- /* Check if GLX extension exists on all back-end servers */
- for (i = 0; i < dmxNumScreens; i++)
- glxSupported &= (dmxScreens[i].glxMajorOpcode > 0);
-#endif
-
- /* Tell dix layer about the backend displays */
- for (i = 0; i < dmxNumScreens; i++) {
-
-#ifdef GLXEXT
- if (glxSupported) {
- /*
- * Builds GLX configurations from the list of visuals
- * supported by the back-end server, and give that
- * configuration list to the glx layer - so that he will
- * build the visuals accordingly.
- */
-
- DMXScreenInfo *dmxScreen = &dmxScreens[i];
- __GLXvisualConfig *configs = NULL;
- dmxGlxVisualPrivate **configprivs = NULL;
- int nconfigs = 0;
- int (*oldErrorHandler)(Display *, XErrorEvent *);
- int i;
-
- /* Catch errors if when using an older GLX w/o FBconfigs */
- oldErrorHandler = XSetErrorHandler(dmxNOPErrorHandler);
-
- /* Get FBConfigs of the back-end server */
- dmxScreen->fbconfigs = GetGLXFBConfigs(dmxScreen->beDisplay,
- dmxScreen->glxMajorOpcode,
- &dmxScreen->numFBConfigs);
-
- XSetErrorHandler(oldErrorHandler);
-
- dmxScreen->glxVisuals =
- GetGLXVisualConfigs(dmxScreen->beDisplay,
- DefaultScreen(dmxScreen->beDisplay),
- &dmxScreen->numGlxVisuals);
-
- if (dmxScreen->fbconfigs) {
- configs =
- GetGLXVisualConfigsFromFBConfigs(dmxScreen->fbconfigs,
- dmxScreen->numFBConfigs,
- dmxScreen->beVisuals,
- dmxScreen->beNumVisuals,
- dmxScreen->glxVisuals,
- dmxScreen->numGlxVisuals,
- &nconfigs);
- } else {
- configs = dmxScreen->glxVisuals;
- nconfigs = dmxScreen->numGlxVisuals;
- }
-
- configprivs = xalloc(nconfigs * sizeof(dmxGlxVisualPrivate*));
-
- if (configs != NULL && configprivs != NULL) {
-
- /* Initialize our private info for each visual
- * (currently only x_visual_depth and x_visual_class)
- */
- for (i = 0; i < nconfigs; i++) {
-
- configprivs[i] = (dmxGlxVisualPrivate *)
- xalloc(sizeof(dmxGlxVisualPrivate));
- configprivs[i]->x_visual_depth = 0;
- configprivs[i]->x_visual_class = 0;
-
- /* Find the visual depth */
- if (configs[i].vid > 0) {
- int j;
- for (j = 0; j < dmxScreen->beNumVisuals; j++) {
- if (dmxScreen->beVisuals[j].visualid ==
- configs[i].vid) {
- configprivs[i]->x_visual_depth =
- dmxScreen->beVisuals[j].depth;
- configprivs[i]->x_visual_class =
- dmxScreen->beVisuals[j].class;
- break;
- }
- }
- }
- }
-
- /* Hand out the glx configs to glx extension */
- GlxSetVisualConfigs(nconfigs, configs, (void**)configprivs);
-
- XFlush(dmxScreen->beDisplay);
- }
- }
-#endif /* GLXEXT */
-
- AddScreen(dmxScreenInit, argc, argv);
- }
-
- /* Compute origin information. */
- dmxInitOrigins();
-
- /* Compute overlap information. */
- dmxInitOverlap();
-
- /* Make sure there is a global width/height available */
- dmxComputeWidthHeight(DMX_NO_RECOMPUTE_BOUNDING_BOX);
-
- /* FIXME: The following is temporarily placed here. When the DMX
- * extension is available, it will be move there.
- */
- dmxInitFonts();
-
-#ifdef RENDER
- /* Initialize the render extension */
- if (!noRenderExtension)
- dmxInitRender();
-#endif
-
- /* Initialized things that need timer hooks */
- dmxStatInit();
- dmxSyncInit(); /* Calls RegisterBlockAndWakeupHandlers */
-
- dmxLog(dmxInfo, "Shadow framebuffer support %s\n",
- dmxShadowFB ? "enabled" : "disabled");
-}
-
-/* RATS: Assuming the fp string (which comes from the command-line argv
- vector) is NULL-terminated, the buffer is large enough for the
- strcpy. */
-static void dmxSetDefaultFontPath(char *fp)
-{
- int fplen = strlen(fp) + 1;
-
- if (dmxFontPath) {
- int len;
-
- len = strlen(dmxFontPath);
- dmxFontPath = xrealloc(dmxFontPath, len+fplen+1);
- dmxFontPath[len] = ',';
- strncpy(&dmxFontPath[len+1], fp, fplen);
- } else {
- dmxFontPath = xalloc(fplen);
- strncpy(dmxFontPath, fp, fplen);
- }
-
- defaultFontPath = dmxFontPath;
-}
-
-/** This function is called in Xserver/os/utils.c from \a AbortServer().
- * We must ensure that backend and console state is restored in the
- * event the server shutdown wasn't clean. */
-void AbortDDX(void)
-{
- int i;
-
- for (i=0; i < dmxNumScreens; i++) {
- DMXScreenInfo *dmxScreen = &dmxScreens[i];
-
- if (dmxScreen->beDisplay) XCloseDisplay(dmxScreen->beDisplay);
- dmxScreen->beDisplay = NULL;
- }
-}
-
-#ifdef DDXBEFORERESET
-void ddxBeforeReset(void)
-{
-}
-#endif
-
-/** This function is called in Xserver/dix/main.c from \a main() when
- * dispatchException & DE_TERMINATE (which is the only way to exit the
- * main loop without an interruption. */
-void ddxGiveUp(void)
-{
- AbortDDX();
-}
-
-/** This function is called in Xserver/os/osinit.c from \a OsInit(). */
-void OsVendorInit(void)
-{
-}
-
-/** This function is called in Xserver/os/utils.c from \a FatalError()
- * and \a VFatalError(). (Note that setting the function pointer \a
- * OsVendorVErrorFProc will cause \a VErrorF() (which is called by the
- * two routines mentioned here, as well as by others) to use the
- * referenced routine instead of \a vfprintf().) */
-void OsVendorFatalError(void)
-{
-}
-
-/** Process our command line arguments. */
-int ddxProcessArgument(int argc, char *argv[], int i)
-{
- int retval = 0;
-
- if (!strcmp(argv[i], "-display")) {
- if (++i < argc) dmxConfigStoreDisplay(argv[i]);
- retval = 2;
- } else if (!strcmp(argv[i], "-inputfrom") || !strcmp(argv[i], "-input")) {
- if (++i < argc) dmxConfigStoreInput(argv[i]);
- retval = 2;
- } else if (!strcmp(argv[i], "-xinputfrom") || !strcmp(argv[i],"-xinput")) {
- if (++i < argc) dmxConfigStoreXInput(argv[i]);
- retval = 2;
- } else if (!strcmp(argv[i], "-noshadowfb")) {
- dmxLog(dmxWarning,
- "-noshadowfb has been deprecated "
- "since it is now the default\n");
- dmxShadowFB = FALSE;
- retval = 1;
- } else if (!strcmp(argv[i], "-nomulticursor")) {
- dmxCursorNoMulti();
- retval = 1;
- } else if (!strcmp(argv[i], "-shadowfb")) {
- dmxShadowFB = TRUE;
- retval = 1;
- } else if (!strcmp(argv[i], "-configfile")) {
- if (++i < argc) dmxConfigStoreFile(argv[i]);
- retval = 2;
- } else if (!strcmp(argv[i], "-config")) {
- if (++i < argc) dmxConfigStoreConfig(argv[i]);
- retval = 2;
- } else if (!strcmp(argv[i], "-fontpath")) {
- if (++i < argc) dmxSetDefaultFontPath(argv[i]);
- retval = 2;
- } else if (!strcmp(argv[i], "-stat")) {
- if ((i += 2) < argc) dmxStatActivate(argv[i-1], argv[i]);
- retval = 3;
- } else if (!strcmp(argv[i], "-syncbatch")) {
- if (++i < argc) dmxSyncActivate(argv[i]);
- retval = 2;
- } else if (!strcmp(argv[i], "-nooffscreenopt")) {
- dmxOffScreenOpt = FALSE;
- retval = 1;
- } else if (!strcmp(argv[i], "-nosubdivprims")) {
- dmxSubdividePrimitives = FALSE;
- retval = 1;
- } else if (!strcmp(argv[i], "-nowindowopt")) {
- dmxLazyWindowCreation = FALSE;
- retval = 1;
- } else if (!strcmp(argv[i], "-noxkb")) {
- dmxUseXKB = FALSE;
- retval = 1;
- } else if (!strcmp(argv[i], "-depth")) {
- if (++i < argc) dmxDepth = atoi(argv[i]);
- retval = 2;
- } else if (!strcmp(argv[i], "-norender")) {
- noRenderExtension = TRUE;
- retval = 1;
-#ifdef GLXEXT
- } else if (!strcmp(argv[i], "-noglxproxy")) {
- dmxGLXProxy = FALSE;
- retval = 1;
- } else if (!strcmp(argv[i], "-noglxswapgroup")) {
- dmxGLXSwapGroupSupport = FALSE;
- retval = 1;
- } else if (!strcmp(argv[i], "-glxsyncswap")) {
- dmxGLXSyncSwap = TRUE;
- retval = 1;
- } else if (!strcmp(argv[i], "-glxfinishswap")) {
- dmxGLXFinishSwap = TRUE;
- retval = 1;
-#endif
- } else if (!strcmp(argv[i], "-ignorebadfontpaths")) {
- dmxIgnoreBadFontPaths = TRUE;
- retval = 1;
- } else if (!strcmp(argv[i], "-addremovescreens")) {
- dmxAddRemoveScreens = TRUE;
- retval = 1;
- } else if (!strcmp(argv[i], "-param")) {
- if ((i += 2) < argc) {
- if (!strcasecmp(argv[i-1], "xkbrules"))
- dmxConfigSetXkbRules(argv[i]);
- else if (!strcasecmp(argv[i-1], "xkbmodel"))
- dmxConfigSetXkbModel(argv[i]);
- else if (!strcasecmp(argv[i-1], "xkblayout"))
- dmxConfigSetXkbLayout(argv[i]);
- else if (!strcasecmp(argv[i-1], "xkbvariant"))
- dmxConfigSetXkbVariant(argv[i]);
- else if (!strcasecmp(argv[i-1], "xkboptions"))
- dmxConfigSetXkbOptions(argv[i]);
- else
- dmxLog(dmxWarning,
- "-param requires: XkbRules, XkbModel, XkbLayout,"
- " XkbVariant, or XkbOptions\n");
- }
- retval = 3;
- }
- if (!serverGeneration) dmxConfigSetMaxScreens();
- return retval;
-}
-
-/** Provide succinct usage information for the DMX server. */
-void ddxUseMsg(void)
-{
- ErrorF("\n\nDevice Dependent Usage:\n");
- ErrorF("-display string Specify the back-end display(s)\n");
- ErrorF("-input string Specify input source for core device\n");
- ErrorF("-xinput string Specify input source for XInput device\n");
- ErrorF("-shadowfb Enable shadow frame buffer\n");
- ErrorF("-configfile file Read from a configuration file\n");
- ErrorF("-config config Select a specific configuration\n");
- ErrorF("-nomulticursor Turn of multiple cursor support\n");
- ErrorF("-fontpath Sets the default font path\n");
- ErrorF("-stat inter scrns Print out performance statistics\n");
- ErrorF("-syncbatch inter Set interval for XSync batching\n");
- ErrorF("-nooffscreenopt Disable offscreen optimization\n");
- ErrorF("-nosubdivprims Disable primitive subdivision\n");
- ErrorF(" optimization\n");
- ErrorF("-nowindowopt Disable lazy window creation optimization\n");
- ErrorF("-noxkb Disable use of the XKB extension with\n");
- ErrorF(" backend displays (cf. -kb).\n");
- ErrorF("-depth Specify the default root window depth\n");
- ErrorF("-norender Disable RENDER extension support\n");
-#ifdef GLXEXT
- ErrorF("-noglxproxy Disable GLX Proxy\n");
- ErrorF("-noglxswapgroup Disable swap group and swap barrier\n");
- ErrorF(" extensions in GLX proxy\n");
- ErrorF("-glxsyncswap Force XSync after swap buffers\n");
- ErrorF("-glxfinishswap Force glFinish after swap buffers\n");
-#endif
- ErrorF("-ignorebadfontpaths Ignore bad font paths during initialization\n");
- ErrorF("-addremovescreens Enable dynamic screen addition/removal\n");
- ErrorF("-param ... Specify configuration parameters (e.g.,\n");
- ErrorF(" XkbRules, XkbModel, XkbLayout, etc.)\n");
- ErrorF("\n");
- ErrorF(" If the -input string matches a -display string, then input\n"
- " is taken from that backend display. (XInput cannot be taken\n"
- " from a backend display.) Placing \",console\" after the\n"
- " display name will force a console window to be opened on\n"
- " that display in addition to the backend input. This is\n"
- " useful if the backend window does not cover the whole\n"
- " physical display.\n\n");
-
- ErrorF(" Otherwise, if the -input or -xinput string specifies another\n"
- " X display, then a console window will be created on that\n"
- " display. Placing \",windows\" or \",nowindows\" after the\n"
- " display name will control the display of window outlines in\n"
- " the console.\n\n");
-
- ErrorF(" -input or -xinput dummy specifies no input.\n");
- ErrorF(" -input or -xinput local specifies the use of a raw keyboard,\n"
- " mouse, or other (extension) device:\n"
- " -input local,kbd,ps2 will use a ps2 mouse\n"
- " -input local,kbd,ms will use a serial mouse\n"
- " -input local,usb-kbd,usb-mou will use USB devices \n"
- " -xinput local,usb-oth will use a non-mouse and\n"
- " non-keyboard USB device with XInput\n\n");
-
- ErrorF(" Special Keys:\n");
- ErrorF(" Ctrl-Alt-g Server grab/ungrab (console only)\n");
- ErrorF(" Ctrl-Alt-f Fine (1-pixel) mouse mode (console only)\n");
- ErrorF(" Ctrl-Alt-q Quit (core devices only)\n");
- ErrorF(" Ctrl-Alt-F* Switch to VC (local only)\n");
-}
+/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * 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.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ * David H. Dawes <dawes@xfree86.org>
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Provide expected functions for initialization from the ddx layer and
+ * global variables for the DMX server. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxinit.h"
+#include "dmxsync.h"
+#include "dmxlog.h"
+#include "dmxinput.h"
+#include "dmxscrinit.h"
+#include "dmxcursor.h"
+#include "dmxfont.h"
+#include "config/dmxconfig.h"
+#include "dmxcb.h"
+#include "dmxprop.h"
+#include "dmxstat.h"
+#ifdef RENDER
+#include "dmxpict.h"
+#endif
+
+#include <X11/Xos.h> /* For gettimeofday */
+#include "dixstruct.h"
+#ifdef PANORAMIX
+#include "panoramiXsrv.h"
+#endif
+
+#include <signal.h> /* For SIGQUIT */
+
+#ifdef GLXEXT
+#include <GL/glx.h>
+#include <GL/glxint.h>
+#include "dmx_glxvisuals.h"
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+
+extern void GlxSetVisualConfigs(
+ int nconfigs,
+ __GLXvisualConfig *configs,
+ void **configprivs
+);
+#endif /* GLXEXT */
+
+/* Global variables available to all Xserver/hw/dmx routines. */
+int dmxNumScreens;
+DMXScreenInfo *dmxScreens;
+
+int dmxNumInputs;
+DMXInputInfo *dmxInputs;
+
+int dmxShadowFB = FALSE;
+
+XErrorEvent dmxLastErrorEvent;
+Bool dmxErrorOccurred = FALSE;
+
+char *dmxFontPath = NULL;
+
+Bool dmxOffScreenOpt = TRUE;
+
+Bool dmxSubdividePrimitives = TRUE;
+
+Bool dmxLazyWindowCreation = TRUE;
+
+Bool dmxUseXKB = TRUE;
+
+int dmxDepth = 0;
+
+#ifndef GLXEXT
+static Bool dmxGLXProxy = FALSE;
+#else
+Bool dmxGLXProxy = TRUE;
+
+Bool dmxGLXSwapGroupSupport = TRUE;
+
+Bool dmxGLXSyncSwap = FALSE;
+
+Bool dmxGLXFinishSwap = FALSE;
+#endif
+
+Bool dmxIgnoreBadFontPaths = FALSE;
+
+Bool dmxAddRemoveScreens = FALSE;
+
+/* dmxErrorHandler catches errors that occur when calling one of the
+ * back-end servers. Some of this code is based on _XPrintDefaultError
+ * in xc/lib/X11/XlibInt.c */
+static int dmxErrorHandler(Display *dpy, XErrorEvent *ev)
+{
+#define DMX_ERROR_BUF_SIZE 256
+ /* RATS: these buffers are only used in
+ * length-limited calls. */
+ char buf[DMX_ERROR_BUF_SIZE];
+ char request[DMX_ERROR_BUF_SIZE];
+ _XExtension *ext = NULL;
+
+ dmxErrorOccurred = TRUE;
+ dmxLastErrorEvent = *ev;
+
+ XGetErrorText(dpy, ev->error_code, buf, sizeof(buf));
+ dmxLog(dmxWarning, "dmxErrorHandler: %s\n", buf);
+
+ /* Find major opcode name */
+ if (ev->request_code < 128) {
+ XmuSnprintf(request, sizeof(request), "%d", ev->request_code);
+ XGetErrorDatabaseText(dpy, "XRequest", request, "", buf, sizeof(buf));
+ } else {
+ for (ext = dpy->ext_procs;
+ ext && ext->codes.major_opcode != ev->request_code;
+ ext = ext->next);
+ if (ext) strncpy(buf, ext->name, sizeof(buf));
+ else buf[0] = '\0';
+ }
+ dmxLog(dmxWarning, " Major opcode: %d (%s)\n",
+ ev->request_code, buf);
+
+ /* Find minor opcode name */
+ if (ev->request_code >= 128 && ext) {
+ XmuSnprintf(request, sizeof(request), "%d", ev->request_code);
+ XmuSnprintf(request, sizeof(request), "%s.%d",
+ ext->name, ev->minor_code);
+ XGetErrorDatabaseText(dpy, "XRequest", request, "", buf, sizeof(buf));
+ dmxLog(dmxWarning, " Minor opcode: %d (%s)\n",
+ ev->minor_code, buf);
+ }
+
+ /* Provide value information */
+ switch (ev->error_code) {
+ case BadValue:
+ dmxLog(dmxWarning, " Value: 0x%x\n",
+ ev->resourceid);
+ break;
+ case BadAtom:
+ dmxLog(dmxWarning, " AtomID: 0x%x\n",
+ ev->resourceid);
+ break;
+ default:
+ dmxLog(dmxWarning, " ResourceID: 0x%x\n",
+ ev->resourceid);
+ break;
+ }
+
+ /* Provide serial number information */
+ dmxLog(dmxWarning, " Failed serial number: %d\n",
+ ev->serial);
+ dmxLog(dmxWarning, " Current serial number: %d\n",
+ dpy->request);
+ return 0;
+}
+
+#ifdef GLXEXT
+static int dmxNOPErrorHandler(Display *dpy, XErrorEvent *ev)
+{
+ return 0;
+}
+#endif
+
+Bool dmxOpenDisplay(DMXScreenInfo *dmxScreen)
+{
+ if (!(dmxScreen->beDisplay = XOpenDisplay(dmxScreen->name)))
+ return FALSE;
+
+ dmxPropertyDisplay(dmxScreen);
+ return TRUE;
+}
+
+void dmxSetErrorHandler(DMXScreenInfo *dmxScreen)
+{
+ XSetErrorHandler(dmxErrorHandler);
+}
+
+static void dmxPrintScreenInfo(DMXScreenInfo *dmxScreen)
+{
+ XWindowAttributes attribs;
+ int ndepths = 0, *depths = NULL;
+ int i;
+ Display *dpy = dmxScreen->beDisplay;
+ Screen *s = DefaultScreenOfDisplay(dpy);
+ int scr = DefaultScreen(dpy);
+
+ XGetWindowAttributes(dpy, DefaultRootWindow(dpy), &attribs);
+ if (!(depths = XListDepths(dpy, scr, &ndepths))) ndepths = 0;
+
+ dmxLogOutput(dmxScreen, "Name of display: %s\n", DisplayString(dpy));
+ dmxLogOutput(dmxScreen, "Version number: %d.%d\n",
+ ProtocolVersion(dpy), ProtocolRevision(dpy));
+ dmxLogOutput(dmxScreen, "Vendor string: %s\n", ServerVendor(dpy));
+ if (!strstr(ServerVendor(dpy), "XFree86")) {
+ dmxLogOutput(dmxScreen, "Vendor release: %d\n", VendorRelease(dpy));
+ } else {
+ /* This code based on xdpyinfo.c */
+ int v = VendorRelease(dpy);
+ int major = -1, minor = -1, patch = -1, subpatch = -1;
+
+ if (v < 336)
+ major = v / 100, minor = (v / 10) % 10, patch = v % 10;
+ else if (v < 3900) {
+ major = v / 1000;
+ minor = (v / 100) % 10;
+ if (((v / 10) % 10) || (v % 10)) {
+ patch = (v / 10) % 10;
+ if (v % 10) subpatch = v % 10;
+ }
+ } else if (v < 40000000) {
+ major = v / 1000;
+ minor = (v / 10) % 10;
+ if (v % 10) patch = v % 10;
+ } else {
+ major = v / 10000000;
+ minor = (v / 100000) % 100;
+ patch = (v / 1000) % 100;
+ if (v % 1000) subpatch = v % 1000;
+ }
+ dmxLogOutput(dmxScreen, "Vendor release: %d (XFree86 version: %d.%d",
+ v, major, minor);
+ if (patch > 0) dmxLogOutputCont(dmxScreen, ".%d", patch);
+ if (subpatch > 0) dmxLogOutputCont(dmxScreen, ".%d", subpatch);
+ dmxLogOutputCont(dmxScreen, ")\n");
+ }
+
+
+ dmxLogOutput(dmxScreen, "Dimensions: %dx%d pixels\n",
+ attribs.width, attribs.height);
+ dmxLogOutput(dmxScreen, "%d depths on screen %d: ", ndepths, scr);
+ for (i = 0; i < ndepths; i++)
+ dmxLogOutputCont(dmxScreen, "%c%d", i ? ',' : ' ', depths[i]);
+ dmxLogOutputCont(dmxScreen, "\n");
+ dmxLogOutput(dmxScreen, "Depth of root window: %d plane%s (%d)\n",
+ attribs.depth, attribs.depth == 1 ? "" : "s",
+ DisplayPlanes(dpy, scr));
+ dmxLogOutput(dmxScreen, "Number of colormaps: %d min, %d max\n",
+ MinCmapsOfScreen(s), MaxCmapsOfScreen(s));
+ dmxLogOutput(dmxScreen, "Options: backing-store %s, save-unders %s\n",
+ (DoesBackingStore (s) == NotUseful) ? "no" :
+ ((DoesBackingStore (s) == Always) ? "yes" : "when mapped"),
+ DoesSaveUnders (s) ? "yes" : "no");
+ dmxLogOutput(dmxScreen, "Window Manager running: %s\n",
+ (dmxScreen->WMRunningOnBE) ? "yes" : "no");
+
+ if (dmxScreen->WMRunningOnBE) {
+ dmxLogOutputWarning(dmxScreen,
+ "Window manager running "
+ "-- colormaps not supported\n");
+ }
+ XFree(depths);
+}
+
+void dmxGetScreenAttribs(DMXScreenInfo *dmxScreen)
+{
+ XWindowAttributes attribs;
+ Display *dpy = dmxScreen->beDisplay;
+#ifdef GLXEXT
+ int dummy;
+#endif
+
+ XGetWindowAttributes(dpy, DefaultRootWindow(dpy), &attribs);
+
+ dmxScreen->beWidth = attribs.width;
+ dmxScreen->beHeight = attribs.height;
+
+ /* Fill in missing geometry information */
+ if (dmxScreen->scrnXSign < 0) {
+ if (dmxScreen->scrnWidth) {
+ dmxScreen->scrnX = (attribs.width - dmxScreen->scrnWidth
+ - dmxScreen->scrnX);
+ } else {
+ dmxScreen->scrnWidth = attribs.width - dmxScreen->scrnX;
+ dmxScreen->scrnX = 0;
+ }
+ }
+ if (dmxScreen->scrnYSign < 0) {
+ if (dmxScreen->scrnHeight) {
+ dmxScreen->scrnY = (attribs.height - dmxScreen->scrnHeight
+ - dmxScreen->scrnY);
+ } else {
+ dmxScreen->scrnHeight = attribs.height - dmxScreen->scrnY;
+ dmxScreen->scrnY = 0;
+ }
+ }
+ if (!dmxScreen->scrnWidth)
+ dmxScreen->scrnWidth = attribs.width - dmxScreen->scrnX;
+ if (!dmxScreen->scrnHeight)
+ dmxScreen->scrnHeight = attribs.height - dmxScreen->scrnY;
+
+ if (!dmxScreen->rootWidth) dmxScreen->rootWidth = dmxScreen->scrnWidth;
+ if (!dmxScreen->rootHeight) dmxScreen->rootHeight = dmxScreen->scrnHeight;
+ if (dmxScreen->rootWidth + dmxScreen->rootX > dmxScreen->scrnWidth)
+ dmxScreen->rootWidth = dmxScreen->scrnWidth - dmxScreen->rootX;
+ if (dmxScreen->rootHeight + dmxScreen->rootY > dmxScreen->scrnHeight)
+ dmxScreen->rootHeight = dmxScreen->scrnHeight - dmxScreen->rootY;
+
+ /* FIXME: Get these from the back-end server */
+ dmxScreen->beXDPI = 75;
+ dmxScreen->beYDPI = 75;
+
+ dmxScreen->beDepth = attribs.depth; /* FIXME: verify that this
+ * works always. In
+ * particular, this will work
+ * well for depth=16, will fail
+ * because of colormap issues
+ * at depth 8. More work needs
+ * to be done here. */
+
+ if (dmxScreen->beDepth <= 8) dmxScreen->beBPP = 8;
+ else if (dmxScreen->beDepth <= 16) dmxScreen->beBPP = 16;
+ else dmxScreen->beBPP = 32;
+
+#ifdef GLXEXT
+ /* get the majorOpcode for the back-end GLX extension */
+ XQueryExtension(dpy, "GLX", &dmxScreen->glxMajorOpcode,
+ &dummy, &dmxScreen->glxErrorBase);
+#endif
+
+ dmxPrintScreenInfo(dmxScreen);
+ dmxLogOutput(dmxScreen, "%dx%d+%d+%d on %dx%d at depth=%d, bpp=%d\n",
+ dmxScreen->scrnWidth, dmxScreen->scrnHeight,
+ dmxScreen->scrnX, dmxScreen->scrnY,
+ dmxScreen->beWidth, dmxScreen->beHeight,
+ dmxScreen->beDepth, dmxScreen->beBPP);
+ if (dmxScreen->beDepth == 8)
+ dmxLogOutputWarning(dmxScreen,
+ "Support for depth == 8 is not complete\n");
+}
+
+Bool dmxGetVisualInfo(DMXScreenInfo *dmxScreen)
+{
+ int i;
+ XVisualInfo visinfo;
+
+ visinfo.screen = DefaultScreen(dmxScreen->beDisplay);
+ dmxScreen->beVisuals = XGetVisualInfo(dmxScreen->beDisplay,
+ VisualScreenMask,
+ &visinfo,
+ &dmxScreen->beNumVisuals);
+
+ dmxScreen->beDefVisualIndex = -1;
+
+ if (defaultColorVisualClass >= 0 || dmxDepth > 0) {
+ for (i = 0; i < dmxScreen->beNumVisuals; i++)
+ if (defaultColorVisualClass >= 0) {
+ if (dmxScreen->beVisuals[i].class == defaultColorVisualClass) {
+ if (dmxDepth > 0) {
+ if (dmxScreen->beVisuals[i].depth == dmxDepth) {
+ dmxScreen->beDefVisualIndex = i;
+ break;
+ }
+ } else {
+ dmxScreen->beDefVisualIndex = i;
+ break;
+ }
+ }
+ } else if (dmxScreen->beVisuals[i].depth == dmxDepth) {
+ dmxScreen->beDefVisualIndex = i;
+ break;
+ }
+ } else {
+ visinfo.visualid =
+ XVisualIDFromVisual(DefaultVisual(dmxScreen->beDisplay,
+ visinfo.screen));
+
+ for (i = 0; i < dmxScreen->beNumVisuals; i++)
+ if (visinfo.visualid == dmxScreen->beVisuals[i].visualid) {
+ dmxScreen->beDefVisualIndex = i;
+ break;
+ }
+ }
+
+ for (i = 0; i < dmxScreen->beNumVisuals; i++)
+ dmxLogVisual(dmxScreen, &dmxScreen->beVisuals[i],
+ (i == dmxScreen->beDefVisualIndex));
+
+ return (dmxScreen->beDefVisualIndex >= 0);
+}
+
+void dmxGetColormaps(DMXScreenInfo *dmxScreen)
+{
+ int i;
+
+ dmxScreen->beNumDefColormaps = dmxScreen->beNumVisuals;
+ dmxScreen->beDefColormaps = xalloc(dmxScreen->beNumDefColormaps *
+ sizeof(*dmxScreen->beDefColormaps));
+
+ for (i = 0; i < dmxScreen->beNumDefColormaps; i++)
+ dmxScreen->beDefColormaps[i] =
+ XCreateColormap(dmxScreen->beDisplay,
+ DefaultRootWindow(dmxScreen->beDisplay),
+ dmxScreen->beVisuals[i].visual,
+ AllocNone);
+
+ dmxScreen->beBlackPixel = BlackPixel(dmxScreen->beDisplay,
+ DefaultScreen(dmxScreen->beDisplay));
+ dmxScreen->beWhitePixel = WhitePixel(dmxScreen->beDisplay,
+ DefaultScreen(dmxScreen->beDisplay));
+}
+
+void dmxGetPixmapFormats(DMXScreenInfo *dmxScreen)
+{
+ dmxScreen->beDepths =
+ XListDepths(dmxScreen->beDisplay, DefaultScreen(dmxScreen->beDisplay),
+ &dmxScreen->beNumDepths);
+
+ dmxScreen->bePixmapFormats =
+ XListPixmapFormats(dmxScreen->beDisplay,
+ &dmxScreen->beNumPixmapFormats);
+}
+
+static Bool dmxSetPixmapFormats(ScreenInfo *pScreenInfo,
+ DMXScreenInfo *dmxScreen)
+{
+ XPixmapFormatValues *bePixmapFormat;
+ PixmapFormatRec *format;
+ int i, j;
+
+ pScreenInfo->imageByteOrder = ImageByteOrder(dmxScreen->beDisplay);
+ pScreenInfo->bitmapScanlineUnit = BitmapUnit(dmxScreen->beDisplay);
+ pScreenInfo->bitmapScanlinePad = BitmapPad(dmxScreen->beDisplay);
+ pScreenInfo->bitmapBitOrder = BitmapBitOrder(dmxScreen->beDisplay);
+
+ pScreenInfo->numPixmapFormats = 0;
+ for (i = 0; i < dmxScreen->beNumPixmapFormats; i++) {
+ bePixmapFormat = &dmxScreen->bePixmapFormats[i];
+ for (j = 0; j < dmxScreen->beNumDepths; j++)
+ if ((bePixmapFormat->depth == 1) ||
+ (bePixmapFormat->depth == dmxScreen->beDepths[j])) {
+ format = &pScreenInfo->formats[pScreenInfo->numPixmapFormats];
+
+ format->depth = bePixmapFormat->depth;
+ format->bitsPerPixel = bePixmapFormat->bits_per_pixel;
+ format->scanlinePad = bePixmapFormat->scanline_pad;
+
+ pScreenInfo->numPixmapFormats++;
+ break;
+ }
+ }
+
+ return TRUE;
+}
+
+void dmxCheckForWM(DMXScreenInfo *dmxScreen)
+{
+ Status status;
+ XWindowAttributes xwa;
+
+ status = XGetWindowAttributes(dmxScreen->beDisplay,
+ DefaultRootWindow(dmxScreen->beDisplay),
+ &xwa);
+ dmxScreen->WMRunningOnBE =
+ (status &&
+ ((xwa.all_event_masks & SubstructureRedirectMask) ||
+ (xwa.all_event_masks & SubstructureNotifyMask)));
+}
+
+/** Initialize the display and collect relevant information about the
+ * display properties */
+static void dmxDisplayInit(DMXScreenInfo *dmxScreen)
+{
+ if (!dmxOpenDisplay(dmxScreen))
+ dmxLog(dmxFatal,
+ "dmxOpenDisplay: Unable to open display %s\n",
+ dmxScreen->name);
+
+ dmxSetErrorHandler(dmxScreen);
+ dmxCheckForWM(dmxScreen);
+ dmxGetScreenAttribs(dmxScreen);
+
+ if (!dmxGetVisualInfo(dmxScreen))
+ dmxLog(dmxFatal, "dmxGetVisualInfo: No matching visuals found\n");
+
+ dmxGetColormaps(dmxScreen);
+ dmxGetPixmapFormats(dmxScreen);
+}
+
+/* If this doesn't compile, just add || defined(yoursystem) to the line
+ * below. This information is to help with bug reports and is not
+ * critical. */
+#if !defined(_POSIX_SOURCE)
+static const char *dmxExecOS(void) { return ""; }
+#else
+#include <sys/utsname.h>
+static const char *dmxExecOS(void)
+{
+ static char buffer[128];
+ static int initialized = 0;
+ struct utsname u;
+
+ if (!initialized++) {
+ memset(buffer, 0, sizeof(buffer));
+ uname(&u);
+ XmuSnprintf(buffer, sizeof(buffer)-1, "%s %s %s",
+ u.sysname, u.release, u.version);
+ }
+ return buffer;
+}
+#endif
+
+static const char *dmxBuildCompiler(void)
+{
+ static char buffer[128];
+ static int initialized = 0;
+
+ if (!initialized++) {
+ memset(buffer, 0, sizeof(buffer));
+#if defined(__GNUC__) && defined(__GNUC_MINOR__) &&defined(__GNUC_PATCHLEVEL__)
+ XmuSnprintf(buffer, sizeof(buffer)-1, "gcc %d.%d.%d",
+ __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
+#endif
+ }
+ return buffer;
+}
+
+static const char *dmxExecHost(void)
+{
+ static char buffer[128];
+ static int initialized = 0;
+
+ if (!initialized++) {
+ memset(buffer, 0, sizeof(buffer));
+ XmuGetHostname(buffer, sizeof(buffer) - 1);
+ }
+ return buffer;
+}
+
+/** This routine is called in Xserver/dix/main.c from \a main(). */
+void InitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[])
+{
+ int i;
+ static unsigned long dmxGeneration = 0;
+#ifdef GLXEXT
+ Bool glxSupported = TRUE;
+#endif
+
+ if (dmxGeneration != serverGeneration) {
+ int vendrel = VENDOR_RELEASE;
+ int major, minor, year, month, day;
+
+ dmxGeneration = serverGeneration;
+
+ major = vendrel / 100000000;
+ vendrel -= major * 100000000;
+ minor = vendrel / 1000000;
+ vendrel -= minor * 1000000;
+ year = vendrel / 10000;
+ vendrel -= year * 10000;
+ month = vendrel / 100;
+ vendrel -= month * 100;
+ day = vendrel;
+
+ /* Add other epoch tests here */
+ if (major > 0 && minor > 0) year += 2000;
+
+ dmxLog(dmxInfo, "Generation: %d\n", dmxGeneration);
+ dmxLog(dmxInfo, "DMX version: %d.%d.%02d%02d%02d (%s)\n",
+ major, minor, year, month, day, VENDOR_STRING);
+
+ SetVendorRelease(VENDOR_RELEASE);
+ SetVendorString(VENDOR_STRING);
+
+ if (dmxGeneration == 1) {
+ dmxLog(dmxInfo, "DMX Build OS: %s (%s)\n", OSNAME, OSVENDOR);
+ dmxLog(dmxInfo, "DMX Build Compiler: %s\n", dmxBuildCompiler());
+ dmxLog(dmxInfo, "DMX Execution OS: %s\n", dmxExecOS());
+ dmxLog(dmxInfo, "DMX Execution Host: %s\n", dmxExecHost());
+ }
+ dmxLog(dmxInfo, "MAXSCREENS: %d\n", MAXSCREENS);
+
+ for (i = 0; i < dmxNumScreens; i++) {
+ if (dmxScreens[i].beDisplay)
+ dmxLog(dmxWarning, "Display \"%s\" still open\n",
+ dmxScreens[i].name);
+ dmxStatFree(dmxScreens[i].stat);
+ dmxScreens[i].stat = NULL;
+ }
+ for (i = 0; i < dmxNumInputs; i++) dmxInputFree(&dmxInputs[i]);
+ if (dmxScreens) free(dmxScreens);
+ if (dmxInputs) free(dmxInputs);
+ dmxScreens = NULL;
+ dmxInputs = NULL;
+ dmxNumScreens = 0;
+ dmxNumInputs = 0;
+ }
+
+ /* Make sure that the command-line arguments are sane. */
+ if (dmxAddRemoveScreens && dmxGLXProxy) {
+ /* Currently it is not possible to support GLX and Render
+ * extensions with dynamic screen addition/removal due to the
+ * state that each extension keeps, which cannot be restored. */
+ dmxLog(dmxWarning,
+ "GLX Proxy and Render extensions do not yet support dynamic\n");
+ dmxLog(dmxWarning,
+ "screen addition and removal. Please specify -noglxproxy\n");
+ dmxLog(dmxWarning,
+ "and -norender on the command line or in the configuration\n");
+ dmxLog(dmxWarning,
+ "file to disable these two extensions if you wish to use\n");
+ dmxLog(dmxWarning,
+ "the dynamic addition and removal of screens support.\n");
+ dmxLog(dmxFatal,
+ "Dynamic screen addition/removal error (see above).\n");
+ }
+
+ /* ddxProcessArgument has been called at this point, but any data
+ * from the configuration file has not been applied. Do so, and be
+ * sure we have at least one back-end display. */
+ dmxConfigConfigure();
+ if (!dmxNumScreens)
+ dmxLog(dmxFatal, "InitOutput: no back-end displays found\n");
+ if (!dmxNumInputs)
+ dmxLog(dmxInfo, "InitOutput: no inputs found\n");
+
+ /* Disable lazy window creation optimization if offscreen
+ * optimization is disabled */
+ if (!dmxOffScreenOpt && dmxLazyWindowCreation) {
+ dmxLog(dmxInfo,
+ "InitOutput: Disabling lazy window creation optimization\n");
+ dmxLog(dmxInfo,
+ " since it requires the offscreen optimization\n");
+ dmxLog(dmxInfo,
+ " to function properly.\n");
+ dmxLazyWindowCreation = FALSE;
+ }
+
+ /* Open each display and gather information about it. */
+ for (i = 0; i < dmxNumScreens; i++)
+ dmxDisplayInit(&dmxScreens[i]);
+
+#if PANORAMIX
+ /* Register a Xinerama callback which will run from within
+ * PanoramiXCreateConnectionBlock. We can use the callback to
+ * determine if Xinerama is loaded and to check the visuals
+ * determined by PanoramiXConsolidate. */
+ XineramaRegisterConnectionBlockCallback(dmxConnectionBlockCallback);
+#endif
+
+ /* Since we only have a single screen thus far, we only need to set
+ the pixmap formats to match that screen. FIXME: this isn't true.*/
+ if (!dmxSetPixmapFormats(pScreenInfo, &dmxScreens[0])) return;
+
+ /* Might want to install a signal handler to allow cleaning up after
+ * unexpected signals. The DIX/OS layer already handles SIGINT and
+ * SIGTERM, so everything is OK for expected signals. --DD
+ *
+ * SIGHUP, SIGINT, and SIGTERM are trapped in os/connection.c
+ * SIGQUIT is another common signal that is sent from the keyboard.
+ * Trap it here, to ensure that the keyboard modifier map and other
+ * state for the input devices are restored. (This makes the
+ * behavior of SIGQUIT somewhat unexpected, since it will be the
+ * same as the behavior of SIGINT. However, leaving the modifier
+ * map of the input devices empty is even more unexpected.) --RF
+ */
+ OsSignal(SIGQUIT, GiveUp);
+
+#ifdef GLXEXT
+ /* Check if GLX extension exists on all back-end servers */
+ for (i = 0; i < dmxNumScreens; i++)
+ glxSupported &= (dmxScreens[i].glxMajorOpcode > 0);
+#endif
+
+ /* Tell dix layer about the backend displays */
+ for (i = 0; i < dmxNumScreens; i++) {
+
+#ifdef GLXEXT
+ if (glxSupported) {
+ /*
+ * Builds GLX configurations from the list of visuals
+ * supported by the back-end server, and give that
+ * configuration list to the glx layer - so that he will
+ * build the visuals accordingly.
+ */
+
+ DMXScreenInfo *dmxScreen = &dmxScreens[i];
+ __GLXvisualConfig *configs = NULL;
+ dmxGlxVisualPrivate **configprivs = NULL;
+ int nconfigs = 0;
+ int (*oldErrorHandler)(Display *, XErrorEvent *);
+ int i;
+
+ /* Catch errors if when using an older GLX w/o FBconfigs */
+ oldErrorHandler = XSetErrorHandler(dmxNOPErrorHandler);
+
+ /* Get FBConfigs of the back-end server */
+ dmxScreen->fbconfigs = GetGLXFBConfigs(dmxScreen->beDisplay,
+ dmxScreen->glxMajorOpcode,
+ &dmxScreen->numFBConfigs);
+
+ XSetErrorHandler(oldErrorHandler);
+
+ dmxScreen->glxVisuals =
+ GetGLXVisualConfigs(dmxScreen->beDisplay,
+ DefaultScreen(dmxScreen->beDisplay),
+ &dmxScreen->numGlxVisuals);
+
+ if (dmxScreen->fbconfigs) {
+ configs =
+ GetGLXVisualConfigsFromFBConfigs(dmxScreen->fbconfigs,
+ dmxScreen->numFBConfigs,
+ dmxScreen->beVisuals,
+ dmxScreen->beNumVisuals,
+ dmxScreen->glxVisuals,
+ dmxScreen->numGlxVisuals,
+ &nconfigs);
+ } else {
+ configs = dmxScreen->glxVisuals;
+ nconfigs = dmxScreen->numGlxVisuals;
+ }
+
+ configprivs = xalloc(nconfigs * sizeof(dmxGlxVisualPrivate*));
+
+ if (configs != NULL && configprivs != NULL) {
+
+ /* Initialize our private info for each visual
+ * (currently only x_visual_depth and x_visual_class)
+ */
+ for (i = 0; i < nconfigs; i++) {
+
+ configprivs[i] = (dmxGlxVisualPrivate *)
+ xalloc(sizeof(dmxGlxVisualPrivate));
+ configprivs[i]->x_visual_depth = 0;
+ configprivs[i]->x_visual_class = 0;
+
+ /* Find the visual depth */
+ if (configs[i].vid > 0) {
+ int j;
+ for (j = 0; j < dmxScreen->beNumVisuals; j++) {
+ if (dmxScreen->beVisuals[j].visualid ==
+ configs[i].vid) {
+ configprivs[i]->x_visual_depth =
+ dmxScreen->beVisuals[j].depth;
+ configprivs[i]->x_visual_class =
+ dmxScreen->beVisuals[j].class;
+ break;
+ }
+ }
+ }
+ }
+
+ /* Hand out the glx configs to glx extension */
+ GlxSetVisualConfigs(nconfigs, configs, (void**)configprivs);
+
+ XFlush(dmxScreen->beDisplay);
+ }
+ }
+#endif /* GLXEXT */
+
+ AddScreen(dmxScreenInit, argc, argv);
+ }
+
+ /* Compute origin information. */
+ dmxInitOrigins();
+
+ /* Compute overlap information. */
+ dmxInitOverlap();
+
+ /* Make sure there is a global width/height available */
+ dmxComputeWidthHeight(DMX_NO_RECOMPUTE_BOUNDING_BOX);
+
+ /* FIXME: The following is temporarily placed here. When the DMX
+ * extension is available, it will be move there.
+ */
+ dmxInitFonts();
+
+#ifdef RENDER
+ /* Initialize the render extension */
+ if (!noRenderExtension)
+ dmxInitRender();
+#endif
+
+ /* Initialized things that need timer hooks */
+ dmxStatInit();
+ dmxSyncInit(); /* Calls RegisterBlockAndWakeupHandlers */
+
+ dmxLog(dmxInfo, "Shadow framebuffer support %s\n",
+ dmxShadowFB ? "enabled" : "disabled");
+}
+
+/* RATS: Assuming the fp string (which comes from the command-line argv
+ vector) is NULL-terminated, the buffer is large enough for the
+ strcpy. */
+static void dmxSetDefaultFontPath(char *fp)
+{
+ int fplen = strlen(fp) + 1;
+
+ if (dmxFontPath) {
+ int len;
+
+ len = strlen(dmxFontPath);
+ dmxFontPath = xrealloc(dmxFontPath, len+fplen+1);
+ dmxFontPath[len] = ',';
+ strncpy(&dmxFontPath[len+1], fp, fplen);
+ } else {
+ dmxFontPath = xalloc(fplen);
+ strncpy(dmxFontPath, fp, fplen);
+ }
+
+ defaultFontPath = dmxFontPath;
+}
+
+/** This function is called in Xserver/os/utils.c from \a AbortServer().
+ * We must ensure that backend and console state is restored in the
+ * event the server shutdown wasn't clean. */
+void AbortDDX(void)
+{
+ int i;
+
+ for (i=0; i < dmxNumScreens; i++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[i];
+
+ if (dmxScreen->beDisplay) XCloseDisplay(dmxScreen->beDisplay);
+ dmxScreen->beDisplay = NULL;
+ }
+}
+
+#ifdef DDXBEFORERESET
+/* This function is called in Xserver/dix/dispatch.c */
+void ddxBeforeReset(void)
+{
+}
+#endif
+
+/** This function is called in Xserver/dix/main.c from \a main() when
+ * dispatchException & DE_TERMINATE (which is the only way to exit the
+ * main loop without an interruption. */
+void ddxGiveUp(void)
+{
+ AbortDDX();
+}
+
+/** This function is called in Xserver/os/osinit.c from \a OsInit(). */
+void OsVendorInit(void)
+{
+}
+
+/** This function is called in Xserver/os/utils.c from \a FatalError()
+ * and \a VFatalError(). (Note that setting the function pointer \a
+ * OsVendorVErrorFProc will cause \a VErrorF() (which is called by the
+ * two routines mentioned here, as well as by others) to use the
+ * referenced routine instead of \a vfprintf().) */
+void OsVendorFatalError(void)
+{
+}
+
+/** Process our command line arguments. */
+int ddxProcessArgument(int argc, char *argv[], int i)
+{
+ int retval = 0;
+
+ if (!strcmp(argv[i], "-display")) {
+ if (++i < argc) dmxConfigStoreDisplay(argv[i]);
+ retval = 2;
+ } else if (!strcmp(argv[i], "-inputfrom") || !strcmp(argv[i], "-input")) {
+ if (++i < argc) dmxConfigStoreInput(argv[i]);
+ retval = 2;
+ } else if (!strcmp(argv[i], "-xinputfrom") || !strcmp(argv[i],"-xinput")) {
+ if (++i < argc) dmxConfigStoreXInput(argv[i]);
+ retval = 2;
+ } else if (!strcmp(argv[i], "-noshadowfb")) {
+ dmxLog(dmxWarning,
+ "-noshadowfb has been deprecated "
+ "since it is now the default\n");
+ dmxShadowFB = FALSE;
+ retval = 1;
+ } else if (!strcmp(argv[i], "-nomulticursor")) {
+ dmxCursorNoMulti();
+ retval = 1;
+ } else if (!strcmp(argv[i], "-shadowfb")) {
+ dmxShadowFB = TRUE;
+ retval = 1;
+ } else if (!strcmp(argv[i], "-configfile")) {
+ if (++i < argc) dmxConfigStoreFile(argv[i]);
+ retval = 2;
+ } else if (!strcmp(argv[i], "-config")) {
+ if (++i < argc) dmxConfigStoreConfig(argv[i]);
+ retval = 2;
+ } else if (!strcmp(argv[i], "-fontpath")) {
+ if (++i < argc) dmxSetDefaultFontPath(argv[i]);
+ retval = 2;
+ } else if (!strcmp(argv[i], "-stat")) {
+ if ((i += 2) < argc) dmxStatActivate(argv[i-1], argv[i]);
+ retval = 3;
+ } else if (!strcmp(argv[i], "-syncbatch")) {
+ if (++i < argc) dmxSyncActivate(argv[i]);
+ retval = 2;
+ } else if (!strcmp(argv[i], "-nooffscreenopt")) {
+ dmxOffScreenOpt = FALSE;
+ retval = 1;
+ } else if (!strcmp(argv[i], "-nosubdivprims")) {
+ dmxSubdividePrimitives = FALSE;
+ retval = 1;
+ } else if (!strcmp(argv[i], "-nowindowopt")) {
+ dmxLazyWindowCreation = FALSE;
+ retval = 1;
+ } else if (!strcmp(argv[i], "-noxkb")) {
+ dmxUseXKB = FALSE;
+ retval = 1;
+ } else if (!strcmp(argv[i], "-depth")) {
+ if (++i < argc) dmxDepth = atoi(argv[i]);
+ retval = 2;
+ } else if (!strcmp(argv[i], "-norender")) {
+ noRenderExtension = TRUE;
+ retval = 1;
+#ifdef GLXEXT
+ } else if (!strcmp(argv[i], "-noglxproxy")) {
+ dmxGLXProxy = FALSE;
+ retval = 1;
+ } else if (!strcmp(argv[i], "-noglxswapgroup")) {
+ dmxGLXSwapGroupSupport = FALSE;
+ retval = 1;
+ } else if (!strcmp(argv[i], "-glxsyncswap")) {
+ dmxGLXSyncSwap = TRUE;
+ retval = 1;
+ } else if (!strcmp(argv[i], "-glxfinishswap")) {
+ dmxGLXFinishSwap = TRUE;
+ retval = 1;
+#endif
+ } else if (!strcmp(argv[i], "-ignorebadfontpaths")) {
+ dmxIgnoreBadFontPaths = TRUE;
+ retval = 1;
+ } else if (!strcmp(argv[i], "-addremovescreens")) {
+ dmxAddRemoveScreens = TRUE;
+ retval = 1;
+ } else if (!strcmp(argv[i], "-param")) {
+ if ((i += 2) < argc) {
+ if (!strcasecmp(argv[i-1], "xkbrules"))
+ dmxConfigSetXkbRules(argv[i]);
+ else if (!strcasecmp(argv[i-1], "xkbmodel"))
+ dmxConfigSetXkbModel(argv[i]);
+ else if (!strcasecmp(argv[i-1], "xkblayout"))
+ dmxConfigSetXkbLayout(argv[i]);
+ else if (!strcasecmp(argv[i-1], "xkbvariant"))
+ dmxConfigSetXkbVariant(argv[i]);
+ else if (!strcasecmp(argv[i-1], "xkboptions"))
+ dmxConfigSetXkbOptions(argv[i]);
+ else
+ dmxLog(dmxWarning,
+ "-param requires: XkbRules, XkbModel, XkbLayout,"
+ " XkbVariant, or XkbOptions\n");
+ }
+ retval = 3;
+ }
+ if (!serverGeneration) dmxConfigSetMaxScreens();
+ return retval;
+}
+
+/** Provide succinct usage information for the DMX server. */
+void ddxUseMsg(void)
+{
+ ErrorF("\n\nDevice Dependent Usage:\n");
+ ErrorF("-display string Specify the back-end display(s)\n");
+ ErrorF("-input string Specify input source for core device\n");
+ ErrorF("-xinput string Specify input source for XInput device\n");
+ ErrorF("-shadowfb Enable shadow frame buffer\n");
+ ErrorF("-configfile file Read from a configuration file\n");
+ ErrorF("-config config Select a specific configuration\n");
+ ErrorF("-nomulticursor Turn of multiple cursor support\n");
+ ErrorF("-fontpath Sets the default font path\n");
+ ErrorF("-stat inter scrns Print out performance statistics\n");
+ ErrorF("-syncbatch inter Set interval for XSync batching\n");
+ ErrorF("-nooffscreenopt Disable offscreen optimization\n");
+ ErrorF("-nosubdivprims Disable primitive subdivision\n");
+ ErrorF(" optimization\n");
+ ErrorF("-nowindowopt Disable lazy window creation optimization\n");
+ ErrorF("-noxkb Disable use of the XKB extension with\n");
+ ErrorF(" backend displays (cf. -kb).\n");
+ ErrorF("-depth Specify the default root window depth\n");
+ ErrorF("-norender Disable RENDER extension support\n");
+#ifdef GLXEXT
+ ErrorF("-noglxproxy Disable GLX Proxy\n");
+ ErrorF("-noglxswapgroup Disable swap group and swap barrier\n");
+ ErrorF(" extensions in GLX proxy\n");
+ ErrorF("-glxsyncswap Force XSync after swap buffers\n");
+ ErrorF("-glxfinishswap Force glFinish after swap buffers\n");
+#endif
+ ErrorF("-ignorebadfontpaths Ignore bad font paths during initialization\n");
+ ErrorF("-addremovescreens Enable dynamic screen addition/removal\n");
+ ErrorF("-param ... Specify configuration parameters (e.g.,\n");
+ ErrorF(" XkbRules, XkbModel, XkbLayout, etc.)\n");
+ ErrorF("\n");
+ ErrorF(" If the -input string matches a -display string, then input\n"
+ " is taken from that backend display. (XInput cannot be taken\n"
+ " from a backend display.) Placing \",console\" after the\n"
+ " display name will force a console window to be opened on\n"
+ " that display in addition to the backend input. This is\n"
+ " useful if the backend window does not cover the whole\n"
+ " physical display.\n\n");
+
+ ErrorF(" Otherwise, if the -input or -xinput string specifies another\n"
+ " X display, then a console window will be created on that\n"
+ " display. Placing \",windows\" or \",nowindows\" after the\n"
+ " display name will control the display of window outlines in\n"
+ " the console.\n\n");
+
+ ErrorF(" -input or -xinput dummy specifies no input.\n");
+ ErrorF(" -input or -xinput local specifies the use of a raw keyboard,\n"
+ " mouse, or other (extension) device:\n"
+ " -input local,kbd,ps2 will use a ps2 mouse\n"
+ " -input local,kbd,ms will use a serial mouse\n"
+ " -input local,usb-kbd,usb-mou will use USB devices \n"
+ " -xinput local,usb-oth will use a non-mouse and\n"
+ " non-keyboard USB device with XInput\n\n");
+
+ ErrorF(" Special Keys:\n");
+ ErrorF(" Ctrl-Alt-g Server grab/ungrab (console only)\n");
+ ErrorF(" Ctrl-Alt-f Fine (1-pixel) mouse mode (console only)\n");
+ ErrorF(" Ctrl-Alt-q Quit (core devices only)\n");
+ ErrorF(" Ctrl-Alt-F* Switch to VC (local only)\n");
+}
diff --git a/xorg-server/hw/kdrive/ephyr/ephyr.c b/xorg-server/hw/kdrive/ephyr/ephyr.c
index 254fcbc54..87e48afaf 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyr.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyr.c
@@ -1,1176 +1,1187 @@
-/*
- * Xephyr - A kdrive X server thats runs in a host X window.
- * Authored by Matthew Allum <mallum@openedhand.com>
- *
- * Copyright © 2004 Nokia
- *
- * 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 Nokia not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Nokia makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * NOKIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL NOKIA 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "ephyr.h"
-
-#include "inputstr.h"
-#include "scrnintstr.h"
-#include "ephyrlog.h"
-
-#ifdef XF86DRI
-#include "ephyrdri.h"
-#include "ephyrdriext.h"
-#include "ephyrglxext.h"
-#endif /* XF86DRI */
-
-extern int KdTsPhyScreen;
-#ifdef GLXEXT
-extern Bool noGlxVisualInit;
-#endif
-
-KdKeyboardInfo *ephyrKbd;
-KdPointerInfo *ephyrMouse;
-EphyrKeySyms ephyrKeySyms;
-Bool ephyrNoDRI=FALSE ;
-Bool ephyrNoXV=FALSE ;
-
-static int mouseState = 0;
-
-typedef struct _EphyrInputPrivate {
- Bool enabled;
-} EphyrKbdPrivate, EphyrPointerPrivate;
-
-Bool EphyrWantGrayScale = 0;
-
-
-Bool
-ephyrInitialize (KdCardInfo *card, EphyrPriv *priv)
-{
- OsSignal(SIGUSR1, hostx_handle_signal);
-
- priv->base = 0;
- priv->bytes_per_line = 0;
- return TRUE;
-}
-
-Bool
-ephyrCardInit (KdCardInfo *card)
-{
- EphyrPriv *priv;
-
- priv = (EphyrPriv *) xalloc (sizeof (EphyrPriv));
- if (!priv)
- return FALSE;
-
- if (!ephyrInitialize (card, priv))
- {
- xfree (priv);
- return FALSE;
- }
- card->driver = priv;
-
- return TRUE;
-}
-
-Bool
-ephyrScreenInitialize (KdScreenInfo *screen, EphyrScrPriv *scrpriv)
-{
- int width = 640, height = 480;
- CARD32 redMask, greenMask, blueMask;
-
- if (hostx_want_screen_size(screen, &width, &height)
- || !screen->width || !screen->height)
- {
- screen->width = width;
- screen->height = height;
- }
-
- if (EphyrWantGrayScale)
- screen->fb[0].depth = 8;
-
- if (screen->fb[0].depth && screen->fb[0].depth != hostx_get_depth())
- {
- if (screen->fb[0].depth < hostx_get_depth()
- && (screen->fb[0].depth == 24 || screen->fb[0].depth == 16
- || screen->fb[0].depth == 8))
- {
- hostx_set_server_depth(screen, screen->fb[0].depth);
- }
- else
- ErrorF("\nXephyr: requested screen depth not supported, setting to match hosts.\n");
- }
-
- screen->fb[0].depth = hostx_get_server_depth(screen);
- screen->rate = 72;
-
- if (screen->fb[0].depth <= 8)
- {
- if (EphyrWantGrayScale)
- screen->fb[0].visuals = ((1 << StaticGray) | (1 << GrayScale));
- else
- screen->fb[0].visuals = ((1 << StaticGray) |
- (1 << GrayScale) |
- (1 << StaticColor) |
- (1 << PseudoColor) |
- (1 << TrueColor) |
- (1 << DirectColor));
-
- screen->fb[0].redMask = 0x00;
- screen->fb[0].greenMask = 0x00;
- screen->fb[0].blueMask = 0x00;
- screen->fb[0].depth = 8;
- screen->fb[0].bitsPerPixel = 8;
- }
- else
- {
- screen->fb[0].visuals = (1 << TrueColor);
-
- if (screen->fb[0].depth <= 15)
- {
- screen->fb[0].depth = 15;
- screen->fb[0].bitsPerPixel = 16;
- }
- else if (screen->fb[0].depth <= 16)
- {
- screen->fb[0].depth = 16;
- screen->fb[0].bitsPerPixel = 16;
- }
- else if (screen->fb[0].depth <= 24)
- {
- screen->fb[0].depth = 24;
- screen->fb[0].bitsPerPixel = 32;
- }
- else if (screen->fb[0].depth <= 30)
- {
- screen->fb[0].depth = 30;
- screen->fb[0].bitsPerPixel = 32;
- }
- else
- {
- ErrorF("\nXephyr: Unsupported screen depth %d\n",
- screen->fb[0].depth);
- return FALSE;
- }
-
- hostx_get_visual_masks (screen, &redMask, &greenMask, &blueMask);
-
- screen->fb[0].redMask = (Pixel) redMask;
- screen->fb[0].greenMask = (Pixel) greenMask;
- screen->fb[0].blueMask = (Pixel) blueMask;
-
- }
-
- scrpriv->randr = screen->randr;
-
- return ephyrMapFramebuffer (screen);
-}
-
-Bool
-ephyrScreenInit (KdScreenInfo *screen)
-{
- EphyrScrPriv *scrpriv;
-
- scrpriv = xcalloc (1, sizeof (EphyrScrPriv));
-
- if (!scrpriv)
- return FALSE;
-
- screen->driver = scrpriv;
-
- if (!ephyrScreenInitialize (screen, scrpriv))
- {
- screen->driver = 0;
- xfree (scrpriv);
- return FALSE;
- }
-
- return TRUE;
-}
-
-void*
-ephyrWindowLinear (ScreenPtr pScreen,
- CARD32 row,
- CARD32 offset,
- int mode,
- CARD32 *size,
- void *closure)
-{
- KdScreenPriv(pScreen);
- EphyrPriv *priv = pScreenPriv->card->driver;
-
- if (!pScreenPriv->enabled)
- return 0;
-
- *size = priv->bytes_per_line;
- return priv->base + row * priv->bytes_per_line + offset;
-}
-
-Bool
-ephyrMapFramebuffer (KdScreenInfo *screen)
-{
- EphyrScrPriv *scrpriv = screen->driver;
- EphyrPriv *priv = screen->card->driver;
- KdPointerMatrix m;
- int buffer_height;
-
- EPHYR_LOG("screen->width: %d, screen->height: %d index=%d",
- screen->width, screen->height, screen->mynum);
-
- KdComputePointerMatrix (&m, scrpriv->randr, screen->width, screen->height);
- KdSetPointerMatrix (&m);
-
- priv->bytes_per_line = ((screen->width * screen->fb[0].bitsPerPixel + 31) >> 5) << 2;
-
- /* point the framebuffer to the data in an XImage */
- /* If fakexa is enabled, allocate a larger buffer so that fakexa has space to
- * put offscreen pixmaps.
- */
- if (ephyrFuncs.initAccel == NULL)
- buffer_height = screen->height;
- else
- buffer_height = 3 * screen->height;
-
- priv->base = hostx_screen_init (screen, screen->width, screen->height, buffer_height);
-
- screen->memory_base = (CARD8 *) (priv->base);
- screen->memory_size = priv->bytes_per_line * buffer_height;
- screen->off_screen_base = priv->bytes_per_line * screen->height;
-
- if ((scrpriv->randr & RR_Rotate_0) && !(scrpriv->randr & RR_Reflect_All))
- {
- scrpriv->shadow = FALSE;
-
- screen->fb[0].byteStride = priv->bytes_per_line;
- screen->fb[0].pixelStride = screen->width;
- screen->fb[0].frameBuffer = (CARD8 *) (priv->base);
- }
- else
- {
- /* Rotated/Reflected so we need to use shadow fb */
- scrpriv->shadow = TRUE;
-
- EPHYR_LOG("allocing shadow");
-
- KdShadowFbAlloc (screen, 0,
- scrpriv->randr & (RR_Rotate_90|RR_Rotate_270));
- }
-
- return TRUE;
-}
-
-void
-ephyrSetScreenSizes (ScreenPtr pScreen)
-{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- EphyrScrPriv *scrpriv = screen->driver;
-
- if (scrpriv->randr & (RR_Rotate_0|RR_Rotate_180))
- {
- pScreen->width = screen->width;
- pScreen->height = screen->height;
- pScreen->mmWidth = screen->width_mm;
- pScreen->mmHeight = screen->height_mm;
- }
- else
- {
- pScreen->width = screen->height;
- pScreen->height = screen->width;
- pScreen->mmWidth = screen->height_mm;
- pScreen->mmHeight = screen->width_mm;
- }
-}
-
-Bool
-ephyrUnmapFramebuffer (KdScreenInfo *screen)
-{
- EphyrScrPriv *scrpriv = screen->driver;
-
- if (scrpriv->shadow)
- KdShadowFbFree (screen, 0);
-
- /* Note, priv->base will get freed when XImage recreated */
-
- return TRUE;
-}
-
-void
-ephyrShadowUpdate (ScreenPtr pScreen, shadowBufPtr pBuf)
-{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
-
- EPHYR_LOG("slow paint");
-
- /* FIXME: Slow Rotated/Reflected updates could be much
- * much faster efficiently updating via tranforming
- * pBuf->pDamage regions
- */
- shadowUpdateRotatePacked(pScreen, pBuf);
- hostx_paint_rect(screen, 0,0,0,0, screen->width, screen->height);
-}
-
-static void
-ephyrInternalDamageRedisplay (ScreenPtr pScreen)
-{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- EphyrScrPriv *scrpriv = screen->driver;
- RegionPtr pRegion;
-
- if (!scrpriv || !scrpriv->pDamage)
- return;
-
- pRegion = DamageRegion (scrpriv->pDamage);
-
- if (REGION_NOTEMPTY (pScreen, pRegion))
- {
- int nbox;
- BoxPtr pbox;
-
- nbox = REGION_NUM_RECTS (pRegion);
- pbox = REGION_RECTS (pRegion);
-
- while (nbox--)
- {
- hostx_paint_rect(screen,
- pbox->x1, pbox->y1,
- pbox->x1, pbox->y1,
- pbox->x2 - pbox->x1,
- pbox->y2 - pbox->y1);
- pbox++;
- }
- DamageEmpty (scrpriv->pDamage);
- }
-}
-
-static void
-ephyrInternalDamageBlockHandler (pointer data,
- OSTimePtr pTimeout,
- pointer pRead)
-{
- ScreenPtr pScreen = (ScreenPtr) data;
-
- ephyrInternalDamageRedisplay (pScreen);
-}
-
-static void
-ephyrInternalDamageWakeupHandler (pointer data, int i, pointer LastSelectMask)
-{
- /* FIXME: Not needed ? */
-}
-
-Bool
-ephyrSetInternalDamage (ScreenPtr pScreen)
-{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- EphyrScrPriv *scrpriv = screen->driver;
- PixmapPtr pPixmap = NULL;
-
- scrpriv->pDamage = DamageCreate ((DamageReportFunc) 0,
- (DamageDestroyFunc) 0,
- DamageReportNone,
- TRUE,
- pScreen,
- pScreen);
-
- if (!RegisterBlockAndWakeupHandlers (ephyrInternalDamageBlockHandler,
- ephyrInternalDamageWakeupHandler,
- (pointer) pScreen))
- return FALSE;
-
- pPixmap = (*pScreen->GetScreenPixmap) (pScreen);
-
- DamageRegister (&pPixmap->drawable, scrpriv->pDamage);
-
- return TRUE;
-}
-
-void
-ephyrUnsetInternalDamage (ScreenPtr pScreen)
-{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- EphyrScrPriv *scrpriv = screen->driver;
- PixmapPtr pPixmap = NULL;
-
- pPixmap = (*pScreen->GetScreenPixmap) (pScreen);
- DamageUnregister (&pPixmap->drawable, scrpriv->pDamage);
- DamageDestroy (scrpriv->pDamage);
-
- RemoveBlockAndWakeupHandlers (ephyrInternalDamageBlockHandler,
- ephyrInternalDamageWakeupHandler,
- (pointer) pScreen);
-}
-
-#ifdef RANDR
-Bool
-ephyrRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
-{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- EphyrScrPriv *scrpriv = screen->driver;
- RRScreenSizePtr pSize;
- Rotation randr;
- int n = 0;
-
- struct { int width, height; } sizes[] =
- {
- { 1600, 1200 },
- { 1400, 1050 },
- { 1280, 960 },
- { 1280, 1024 },
- { 1152, 864 },
- { 1024, 768 },
- { 832, 624 },
- { 800, 600 },
- { 720, 400 },
- { 480, 640 },
- { 640, 480 },
- { 640, 400 },
- { 320, 240 },
- { 240, 320 },
- { 160, 160 },
- { 0, 0 }
- };
-
- EPHYR_LOG("mark");
-
- *rotations = RR_Rotate_All|RR_Reflect_All;
-
- if (!hostx_want_preexisting_window (screen)
- && !hostx_want_fullscreen ()) /* only if no -parent switch */
- {
- while (sizes[n].width != 0 && sizes[n].height != 0)
- {
- RRRegisterSize (pScreen,
- sizes[n].width,
- sizes[n].height,
- (sizes[n].width * screen->width_mm)/screen->width,
- (sizes[n].height *screen->height_mm)/screen->height
- );
- n++;
- }
- }
-
- pSize = RRRegisterSize (pScreen,
- screen->width,
- screen->height,
- screen->width_mm,
- screen->height_mm);
-
- randr = KdSubRotation (scrpriv->randr, screen->randr);
-
- RRSetCurrentConfig (pScreen, randr, 0, pSize);
-
- return TRUE;
-}
-
-Bool
-ephyrRandRSetConfig (ScreenPtr pScreen,
- Rotation randr,
- int rate,
- RRScreenSizePtr pSize)
-{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- EphyrScrPriv *scrpriv = screen->driver;
- Bool wasEnabled = pScreenPriv->enabled;
- EphyrScrPriv oldscr;
- int oldwidth, oldheight, oldmmwidth, oldmmheight;
- Bool oldshadow;
- int newwidth, newheight;
-
- if (screen->randr & (RR_Rotate_0|RR_Rotate_180))
- {
- newwidth = pSize->width;
- newheight = pSize->height;
- }
- else
- {
- newwidth = pSize->height;
- newheight = pSize->width;
- }
-
- if (wasEnabled)
- KdDisableScreen (pScreen);
-
- oldscr = *scrpriv;
-
- oldwidth = screen->width;
- oldheight = screen->height;
- oldmmwidth = pScreen->mmWidth;
- oldmmheight = pScreen->mmHeight;
- oldshadow = scrpriv->shadow;
-
- /*
- * Set new configuration
- */
-
- scrpriv->randr = KdAddRotation (screen->randr, randr);
-
- ephyrUnmapFramebuffer (screen);
-
- screen->width = newwidth;
- screen->height = newheight;
-
- if (!ephyrMapFramebuffer (screen))
- goto bail4;
-
- /* FIXME below should go in own call */
-
- if (oldshadow)
- KdShadowUnset (screen->pScreen);
- else
- ephyrUnsetInternalDamage(screen->pScreen);
-
- if (scrpriv->shadow)
- {
- if (!KdShadowSet (screen->pScreen,
- scrpriv->randr,
- ephyrShadowUpdate,
- ephyrWindowLinear))
- goto bail4;
- }
- else
- {
- /* Without shadow fb ( non rotated ) we need
- * to use damage to efficiently update display
- * via signal regions what to copy from 'fb'.
- */
- if (!ephyrSetInternalDamage(screen->pScreen))
- goto bail4;
- }
-
- ephyrSetScreenSizes (screen->pScreen);
-
- /*
- * Set frame buffer mapping
- */
- (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
- pScreen->width,
- pScreen->height,
- screen->fb[0].depth,
- screen->fb[0].bitsPerPixel,
- screen->fb[0].byteStride,
- screen->fb[0].frameBuffer);
-
- /* set the subpixel order */
-
- KdSetSubpixelOrder (pScreen, scrpriv->randr);
-
- if (wasEnabled)
- KdEnableScreen (pScreen);
-
- return TRUE;
-
- bail4:
- EPHYR_LOG("bailed");
-
- ephyrUnmapFramebuffer (screen);
- *scrpriv = oldscr;
- (void) ephyrMapFramebuffer (screen);
-
- pScreen->width = oldwidth;
- pScreen->height = oldheight;
- pScreen->mmWidth = oldmmwidth;
- pScreen->mmHeight = oldmmheight;
-
- if (wasEnabled)
- KdEnableScreen (pScreen);
- return FALSE;
-}
-
-Bool
-ephyrRandRInit (ScreenPtr pScreen)
-{
- rrScrPrivPtr pScrPriv;
-
- if (!RRScreenInit (pScreen))
- return FALSE;
-
- pScrPriv = rrGetScrPriv(pScreen);
- pScrPriv->rrGetInfo = ephyrRandRGetInfo;
- pScrPriv->rrSetConfig = ephyrRandRSetConfig;
- return TRUE;
-}
-#endif
-
-Bool
-ephyrCreateColormap (ColormapPtr pmap)
-{
- return fbInitializeColormap (pmap);
-}
-
-Bool
-ephyrInitScreen (ScreenPtr pScreen)
-{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
-
- EPHYR_LOG ("pScreen->myNum:%d\n", pScreen->myNum) ;
- hostx_set_screen_number (screen, pScreen->myNum);
- hostx_set_win_title (screen, "(ctrl+shift grabs mouse and keyboard)") ;
- pScreen->CreateColormap = ephyrCreateColormap;
-
-#ifdef XV
- if (!ephyrNoXV) {
- if (!ephyrInitVideo (pScreen)) {
- EPHYR_LOG_ERROR ("failed to initialize xvideo\n") ;
- } else {
- EPHYR_LOG ("initialized xvideo okay\n") ;
- }
- }
-#endif /*XV*/
-
-#ifdef XF86DRI
- if (!ephyrNoDRI && !hostx_has_dri ()) {
- EPHYR_LOG ("host x does not support DRI. Disabling DRI forwarding\n") ;
- ephyrNoDRI = TRUE ;
-#ifdef GLXEXT
- noGlxVisualInit = FALSE ;
-#endif
- }
- if (!ephyrNoDRI) {
- ephyrDRIExtensionInit (pScreen) ;
- ephyrHijackGLXExtension () ;
- }
-#endif
-
-#ifdef GLXEXT
- if (ephyrNoDRI) {
- noGlxVisualInit = FALSE ;
- }
-#endif
-
- return TRUE;
-}
-
-Bool
-ephyrFinishInitScreen (ScreenPtr pScreen)
-{
- /* FIXME: Calling this even if not using shadow.
- * Seems harmless enough. But may be safer elsewhere.
- */
- if (!shadowSetup (pScreen))
- return FALSE;
-
-#ifdef RANDR
- if (!ephyrRandRInit (pScreen))
- return FALSE;
-#endif
-
- return TRUE;
-}
-
-Bool
-ephyrCreateResources (ScreenPtr pScreen)
-{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- EphyrScrPriv *scrpriv = screen->driver;
-
- EPHYR_LOG("mark pScreen=%p mynum=%d shadow=%d",
- pScreen, pScreen->myNum, scrpriv->shadow);
-
- if (scrpriv->shadow)
- return KdShadowSet (pScreen,
- scrpriv->randr,
- ephyrShadowUpdate,
- ephyrWindowLinear);
- else
- return ephyrSetInternalDamage(pScreen);
-}
-
-void
-ephyrPreserve (KdCardInfo *card)
-{
-}
-
-Bool
-ephyrEnable (ScreenPtr pScreen)
-{
- return TRUE;
-}
-
-Bool
-ephyrDPMS (ScreenPtr pScreen, int mode)
-{
- return TRUE;
-}
-
-void
-ephyrDisable (ScreenPtr pScreen)
-{
-}
-
-void
-ephyrRestore (KdCardInfo *card)
-{
-}
-
-void
-ephyrScreenFini (KdScreenInfo *screen)
-{
- EphyrScrPriv *scrpriv = screen->driver;
- if (scrpriv->shadow) {
- KdShadowFbFree (screen, 0);
- }
- xfree(screen->driver);
- screen->driver = NULL;
-}
-
-/*
- * Port of Mark McLoughlin's Xnest fix for focus in + modifier bug.
- * See https://bugs.freedesktop.org/show_bug.cgi?id=3030
- */
-void
-ephyrUpdateModifierState(unsigned int state)
-{
-#if 0
- DeviceIntPtr pkeydev;
- KeyClassPtr keyc;
- int i;
- CARD8 mask;
-
- pkeydev = inputInfo.keyboard;
-
- if (!pkeydev)
- return;
-
-/* This is pretty broken.
- *
- * What should happen is that focus out should do as a VT switch does in
- * traditional servers: fake releases for all keys (and buttons too, come
- * to think of it) currently down. Then, on focus in, get the state from
- * the host, and fake keypresses for everything currently down.
- *
- * So I'm leaving this broken for a little while. Sorry, folks.
- *
- * -daniels
- */
-
- keyc = pkeydev->key;
-
- state = state & 0xff;
-
- if (keyc->state == state)
- return;
-
- for (i = 0, mask = 1; i < 8; i++, mask <<= 1)
- {
- int key;
-
- /* Modifier is down, but shouldn't be */
- if ((keyc->state & mask) && !(state & mask))
- {
- int count = keyc->modifierKeyCount[i];
-
- for (key = 0; key < MAP_LENGTH; key++)
- if (keyc->xkbInfo->desc->map->modmap[key] & mask)
- {
- int bit;
- BYTE *kptr;
-
- kptr = &keyc->down[key >> 3];
- bit = 1 << (key & 7);
-
- if (*kptr & bit && ephyrKbd &&
- ((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
- KdEnqueueKeyboardEvent(ephyrKbd, key, TRUE); /* release */
-
- if (--count == 0)
- break;
- }
- }
-
- /* Modifier shoud be down, but isn't */
- if (!(keyc->state & mask) && (state & mask))
- for (key = 0; key < MAP_LENGTH; key++)
- if (keyc->xkbInfo->desc->map->modmap[key] & mask)
- {
- if (keyc->xkbInfo->desc->map->modmap[key] & mask && ephyrKbd &&
- ((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
- KdEnqueueKeyboardEvent(ephyrKbd, key, FALSE); /* press */
- break;
- }
- }
-#endif
-}
-
-static void
-ephyrBlockSigio (void)
-{
- sigset_t set;
-
- sigemptyset (&set);
- sigaddset (&set, SIGIO);
- sigprocmask (SIG_BLOCK, &set, 0);
-}
-
-static void
-ephyrUnblockSigio (void)
-{
- sigset_t set;
-
- sigemptyset (&set);
- sigaddset (&set, SIGIO);
- sigprocmask (SIG_UNBLOCK, &set, 0);
-}
-
-static Bool
-ephyrCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y)
-{
- return FALSE;
-}
-
-static void
-ephyrCrossScreen (ScreenPtr pScreen, Bool entering)
-{
-}
-
-int ephyrCurScreen; /*current event screen*/
-
-static void
-ephyrWarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
-{
- ephyrBlockSigio ();
- ephyrCurScreen = pScreen->myNum;
- miPointerWarpCursor (inputInfo.pointer, pScreen, x, y);
- ephyrUnblockSigio ();
-}
-
-miPointerScreenFuncRec ephyrPointerScreenFuncs =
-{
- ephyrCursorOffScreen,
- ephyrCrossScreen,
- ephyrWarpCursor,
- NULL,
- NULL
-};
-
-#ifdef XF86DRI
-/**
- * find if the remote window denoted by a_remote
- * is paired with an internal Window within the Xephyr server.
- * If the remove window is paired with an internal window, send an
- * expose event to the client insterested in the internal window expose event.
- *
- * Pairing happens when a drawable inside Xephyr is associated with
- * a GL surface in a DRI environment.
- * Look at the function ProcXF86DRICreateDrawable in ephyrdriext.c to
- * know a paired window is created.
- *
- * This is useful to make GL drawables (only windows for now) handle
- * expose events and send those events to clients.
- */
-static void
-ephyrExposePairedWindow (int a_remote)
-{
- EphyrWindowPair *pair = NULL;
- RegionRec reg;
- ScreenPtr screen;
-
- if (!findWindowPairFromRemote (a_remote, &pair)) {
- EPHYR_LOG ("did not find a pair for this window\n");
- return;
- }
- screen = pair->local->drawable.pScreen;
- REGION_NULL (screen, &reg);
- REGION_COPY (screen, &reg, &pair->local->clipList);
- screen->WindowExposures (pair->local, &reg, NullRegion);
- REGION_UNINIT (screen, &reg);
-}
-#endif /* XF86DRI */
-
-void
-ephyrPoll(void)
-{
- EphyrHostXEvent ev;
-
- while (hostx_get_event(&ev))
- {
- switch (ev.type)
- {
- case EPHYR_EV_MOUSE_MOTION:
- if (!ephyrMouse ||
- !((EphyrPointerPrivate *)ephyrMouse->driverPrivate)->enabled) {
- EPHYR_LOG ("skipping mouse motion:%d\n", ephyrCurScreen) ;
- continue;
- }
- {
- if (ev.data.mouse_motion.screen >=0
- && (ephyrCurScreen != ev.data.mouse_motion.screen))
- {
- EPHYR_LOG ("warping mouse cursor. "
- "cur_screen%d, motion_screen:%d\n",
- ephyrCurScreen, ev.data.mouse_motion.screen) ;
- if (ev.data.mouse_motion.screen >= 0)
- {
- ephyrWarpCursor
- (inputInfo.pointer, screenInfo.screens[ev.data.mouse_motion.screen],
- ev.data.mouse_motion.x,
- ev.data.mouse_motion.y );
- }
- }
- else
- {
- int x=0, y=0;
-#ifdef XF86DRI
- EphyrWindowPair *pair = NULL;
-#endif
- EPHYR_LOG ("enqueuing mouse motion:%d\n", ephyrCurScreen) ;
- x = ev.data.mouse_motion.x;
- y = ev.data.mouse_motion.y;
- EPHYR_LOG ("initial (x,y):(%d,%d)\n", x, y) ;
-#ifdef XF86DRI
- EPHYR_LOG ("is this window peered by a gl drawable ?\n") ;
- if (findWindowPairFromRemote (ev.data.mouse_motion.window,
- &pair))
- {
- EPHYR_LOG ("yes, it is peered\n") ;
- x += pair->local->drawable.x;
- y += pair->local->drawable.y;
- }
- else
- {
- EPHYR_LOG ("no, it is not peered\n") ;
- }
- EPHYR_LOG ("final (x,y):(%d,%d)\n", x, y) ;
-#endif
- KdEnqueuePointerEvent(ephyrMouse, mouseState, x, y, 0);
- }
- }
- break;
-
- case EPHYR_EV_MOUSE_PRESS:
- if (!ephyrMouse ||
- !((EphyrPointerPrivate *)ephyrMouse->driverPrivate)->enabled) {
- EPHYR_LOG ("skipping mouse press:%d\n", ephyrCurScreen) ;
- continue;
- }
- EPHYR_LOG ("enqueuing mouse press:%d\n", ephyrCurScreen) ;
- ephyrUpdateModifierState(ev.key_state);
- mouseState |= ev.data.mouse_down.button_num;
- KdEnqueuePointerEvent(ephyrMouse, mouseState|KD_MOUSE_DELTA, 0, 0, 0);
- break;
-
- case EPHYR_EV_MOUSE_RELEASE:
- if (!ephyrMouse ||
- !((EphyrPointerPrivate *)ephyrMouse->driverPrivate)->enabled)
- continue;
- ephyrUpdateModifierState(ev.key_state);
- mouseState &= ~ev.data.mouse_up.button_num;
- EPHYR_LOG ("enqueuing mouse release:%d\n", ephyrCurScreen) ;
- KdEnqueuePointerEvent(ephyrMouse, mouseState|KD_MOUSE_DELTA, 0, 0, 0);
- break;
-
- case EPHYR_EV_KEY_PRESS:
- if (!ephyrKbd ||
- !((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
- continue;
- ephyrUpdateModifierState(ev.key_state);
- KdEnqueueKeyboardEvent (ephyrKbd, ev.data.key_down.scancode, FALSE);
- break;
-
- case EPHYR_EV_KEY_RELEASE:
- if (!ephyrKbd ||
- !((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
- continue;
- KdEnqueueKeyboardEvent (ephyrKbd, ev.data.key_up.scancode, TRUE);
- break;
-
-#ifdef XF86DRI
- case EPHYR_EV_EXPOSE:
- /*
- * We only receive expose events when the expose event have
- * be generated for a drawable that is a host X window managed
- * by Xephyr. Host X windows managed by Xephyr exists for instance
- * when Xephyr is asked to create a GL drawable in a DRI environment.
- */
- ephyrExposePairedWindow (ev.data.expose.window);
- break;
-#endif /* XF86DRI */
-
- default:
- break;
- }
- }
-}
-
-void
-ephyrCardFini (KdCardInfo *card)
-{
- EphyrPriv *priv = card->driver;
- xfree (priv);
-}
-
-void
-ephyrGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
-{
- /* XXX Not sure if this is right */
-
- EPHYR_LOG("mark");
-
- while (n--)
- {
- pdefs->red = 0;
- pdefs->green = 0;
- pdefs->blue = 0;
- pdefs++;
- }
-
-}
-
-void
-ephyrPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
-{
- int min, max, p;
-
- /* XXX Not sure if this is right */
-
- min = 256;
- max = 0;
-
- while (n--)
- {
- p = pdefs->pixel;
- if (p < min)
- min = p;
- if (p > max)
- max = p;
-
- hostx_set_cmap_entry(p,
- pdefs->red >> 8,
- pdefs->green >> 8,
- pdefs->blue >> 8);
- pdefs++;
- }
-}
-
-/* Mouse calls */
-
-static Status
-MouseInit (KdPointerInfo *pi)
-{
- pi->driverPrivate = (EphyrPointerPrivate *)
- xcalloc(sizeof(EphyrPointerPrivate), 1);
- ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE;
- pi->nAxes = 3;
- pi->nButtons = 32;
- if (pi->name)
- xfree(pi->name);
- pi->name = strdup("Xephyr virtual mouse");
- ephyrMouse = pi;
- return Success;
-}
-
-static Status
-MouseEnable (KdPointerInfo *pi)
-{
- ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = TRUE;
- return Success;
-}
-
-static void
-MouseDisable (KdPointerInfo *pi)
-{
- ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE;
- return;
-}
-
-static void
-MouseFini (KdPointerInfo *pi)
-{
- ephyrMouse = NULL;
- return;
-}
-
-KdPointerDriver EphyrMouseDriver = {
- "ephyr",
- MouseInit,
- MouseEnable,
- MouseDisable,
- MouseFini,
- NULL,
-};
-
-/* Keyboard */
-
-static Status
-EphyrKeyboardInit (KdKeyboardInfo *ki)
-{
- ki->driverPrivate = (EphyrKbdPrivate *)
- xcalloc(sizeof(EphyrKbdPrivate), 1);
- hostx_load_keymap();
- if (!ephyrKeySyms.map) {
- ErrorF("Couldn't load keymap from host\n");
- return BadAlloc;
- }
- ki->minScanCode = ephyrKeySyms.minKeyCode;
- ki->maxScanCode = ephyrKeySyms.maxKeyCode;
- if (ki->name)
- xfree(ki->name);
- ki->name = strdup("Xephyr virtual keyboard");
- ephyrKbd = ki;
- return Success;
-}
-
-static Status
-EphyrKeyboardEnable (KdKeyboardInfo *ki)
-{
- ((EphyrKbdPrivate *)ki->driverPrivate)->enabled = TRUE;
-
- return Success;
-}
-
-static void
-EphyrKeyboardDisable (KdKeyboardInfo *ki)
-{
- ((EphyrKbdPrivate *)ki->driverPrivate)->enabled = FALSE;
-}
-
-static void
-EphyrKeyboardFini (KdKeyboardInfo *ki)
-{
- ephyrKbd = NULL;
- return;
-}
-
-static void
-EphyrKeyboardLeds (KdKeyboardInfo *ki, int leds)
-{
-}
-
-static void
-EphyrKeyboardBell (KdKeyboardInfo *ki, int volume, int frequency, int duration)
-{
-}
-
-
-KdKeyboardDriver EphyrKeyboardDriver = {
- "ephyr",
- EphyrKeyboardInit,
- EphyrKeyboardEnable,
- EphyrKeyboardLeds,
- EphyrKeyboardBell,
- EphyrKeyboardDisable,
- EphyrKeyboardFini,
- NULL,
-};
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@openedhand.com>
+ *
+ * Copyright © 2004 Nokia
+ *
+ * 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 Nokia not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Nokia makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * NOKIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL NOKIA 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "ephyr.h"
+
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "ephyrlog.h"
+
+#ifdef XF86DRI
+#include "ephyrdri.h"
+#include "ephyrdriext.h"
+#include "ephyrglxext.h"
+#endif /* XF86DRI */
+
+extern int KdTsPhyScreen;
+#ifdef GLXEXT
+extern Bool noGlxVisualInit;
+#endif
+
+KdKeyboardInfo *ephyrKbd;
+KdPointerInfo *ephyrMouse;
+EphyrKeySyms ephyrKeySyms;
+Bool ephyrNoDRI=FALSE ;
+Bool ephyrNoXV=FALSE ;
+
+static int mouseState = 0;
+
+typedef struct _EphyrInputPrivate {
+ Bool enabled;
+} EphyrKbdPrivate, EphyrPointerPrivate;
+
+Bool EphyrWantGrayScale = 0;
+
+
+Bool
+ephyrInitialize (KdCardInfo *card, EphyrPriv *priv)
+{
+#ifdef _MSC_VER
+ __asm int 3;
+#else
+ OsSignal(SIGUSR1, hostx_handle_signal);
+#endif
+ priv->base = 0;
+ priv->bytes_per_line = 0;
+ return TRUE;
+}
+
+Bool
+ephyrCardInit (KdCardInfo *card)
+{
+ EphyrPriv *priv;
+
+ priv = (EphyrPriv *) xalloc (sizeof (EphyrPriv));
+ if (!priv)
+ return FALSE;
+
+ if (!ephyrInitialize (card, priv))
+ {
+ xfree (priv);
+ return FALSE;
+ }
+ card->driver = priv;
+
+ return TRUE;
+}
+
+Bool
+ephyrScreenInitialize (KdScreenInfo *screen, EphyrScrPriv *scrpriv)
+{
+ int width = 640, height = 480;
+ CARD32 redMask, greenMask, blueMask;
+
+ if (hostx_want_screen_size(screen, &width, &height)
+ || !screen->width || !screen->height)
+ {
+ screen->width = width;
+ screen->height = height;
+ }
+
+ if (EphyrWantGrayScale)
+ screen->fb[0].depth = 8;
+
+ if (screen->fb[0].depth && screen->fb[0].depth != hostx_get_depth())
+ {
+ if (screen->fb[0].depth < hostx_get_depth()
+ && (screen->fb[0].depth == 24 || screen->fb[0].depth == 16
+ || screen->fb[0].depth == 8))
+ {
+ hostx_set_server_depth(screen, screen->fb[0].depth);
+ }
+ else
+ ErrorF("\nXephyr: requested screen depth not supported, setting to match hosts.\n");
+ }
+
+ screen->fb[0].depth = hostx_get_server_depth(screen);
+ screen->rate = 72;
+
+ if (screen->fb[0].depth <= 8)
+ {
+ if (EphyrWantGrayScale)
+ screen->fb[0].visuals = ((1 << StaticGray) | (1 << GrayScale));
+ else
+ screen->fb[0].visuals = ((1 << StaticGray) |
+ (1 << GrayScale) |
+ (1 << StaticColor) |
+ (1 << PseudoColor) |
+ (1 << TrueColor) |
+ (1 << DirectColor));
+
+ screen->fb[0].redMask = 0x00;
+ screen->fb[0].greenMask = 0x00;
+ screen->fb[0].blueMask = 0x00;
+ screen->fb[0].depth = 8;
+ screen->fb[0].bitsPerPixel = 8;
+ }
+ else
+ {
+ screen->fb[0].visuals = (1 << TrueColor);
+
+ if (screen->fb[0].depth <= 15)
+ {
+ screen->fb[0].depth = 15;
+ screen->fb[0].bitsPerPixel = 16;
+ }
+ else if (screen->fb[0].depth <= 16)
+ {
+ screen->fb[0].depth = 16;
+ screen->fb[0].bitsPerPixel = 16;
+ }
+ else if (screen->fb[0].depth <= 24)
+ {
+ screen->fb[0].depth = 24;
+ screen->fb[0].bitsPerPixel = 32;
+ }
+ else if (screen->fb[0].depth <= 30)
+ {
+ screen->fb[0].depth = 30;
+ screen->fb[0].bitsPerPixel = 32;
+ }
+ else
+ {
+ ErrorF("\nXephyr: Unsupported screen depth %d\n",
+ screen->fb[0].depth);
+ return FALSE;
+ }
+
+ hostx_get_visual_masks (screen, &redMask, &greenMask, &blueMask);
+
+ screen->fb[0].redMask = (Pixel) redMask;
+ screen->fb[0].greenMask = (Pixel) greenMask;
+ screen->fb[0].blueMask = (Pixel) blueMask;
+
+ }
+
+ scrpriv->randr = screen->randr;
+
+ return ephyrMapFramebuffer (screen);
+}
+
+Bool
+ephyrScreenInit (KdScreenInfo *screen)
+{
+ EphyrScrPriv *scrpriv;
+
+ scrpriv = xcalloc (1, sizeof (EphyrScrPriv));
+
+ if (!scrpriv)
+ return FALSE;
+
+ screen->driver = scrpriv;
+
+ if (!ephyrScreenInitialize (screen, scrpriv))
+ {
+ screen->driver = 0;
+ xfree (scrpriv);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+void*
+ephyrWindowLinear (ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size,
+ void *closure)
+{
+ KdScreenPriv(pScreen);
+ EphyrPriv *priv = pScreenPriv->card->driver;
+
+ if (!pScreenPriv->enabled)
+ return 0;
+
+ *size = priv->bytes_per_line;
+ return priv->base + row * priv->bytes_per_line + offset;
+}
+
+Bool
+ephyrMapFramebuffer (KdScreenInfo *screen)
+{
+ EphyrScrPriv *scrpriv = screen->driver;
+ EphyrPriv *priv = screen->card->driver;
+ KdPointerMatrix m;
+ int buffer_height;
+
+ EPHYR_LOG("screen->width: %d, screen->height: %d index=%d",
+ screen->width, screen->height, screen->mynum);
+
+ KdComputePointerMatrix (&m, scrpriv->randr, screen->width, screen->height);
+ KdSetPointerMatrix (&m);
+
+ priv->bytes_per_line = ((screen->width * screen->fb[0].bitsPerPixel + 31) >> 5) << 2;
+
+ /* point the framebuffer to the data in an XImage */
+ /* If fakexa is enabled, allocate a larger buffer so that fakexa has space to
+ * put offscreen pixmaps.
+ */
+ if (ephyrFuncs.initAccel == NULL)
+ buffer_height = screen->height;
+ else
+ buffer_height = 3 * screen->height;
+
+ priv->base = hostx_screen_init (screen, screen->width, screen->height, buffer_height);
+
+ screen->memory_base = (CARD8 *) (priv->base);
+ screen->memory_size = priv->bytes_per_line * buffer_height;
+ screen->off_screen_base = priv->bytes_per_line * screen->height;
+
+ if ((scrpriv->randr & RR_Rotate_0) && !(scrpriv->randr & RR_Reflect_All))
+ {
+ scrpriv->shadow = FALSE;
+
+ screen->fb[0].byteStride = priv->bytes_per_line;
+ screen->fb[0].pixelStride = screen->width;
+ screen->fb[0].frameBuffer = (CARD8 *) (priv->base);
+ }
+ else
+ {
+ /* Rotated/Reflected so we need to use shadow fb */
+ scrpriv->shadow = TRUE;
+
+ EPHYR_LOG("allocing shadow");
+
+ KdShadowFbAlloc (screen, 0,
+ scrpriv->randr & (RR_Rotate_90|RR_Rotate_270));
+ }
+
+ return TRUE;
+}
+
+void
+ephyrSetScreenSizes (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+
+ if (scrpriv->randr & (RR_Rotate_0|RR_Rotate_180))
+ {
+ pScreen->width = screen->width;
+ pScreen->height = screen->height;
+ pScreen->mmWidth = screen->width_mm;
+ pScreen->mmHeight = screen->height_mm;
+ }
+ else
+ {
+ pScreen->width = screen->height;
+ pScreen->height = screen->width;
+ pScreen->mmWidth = screen->height_mm;
+ pScreen->mmHeight = screen->width_mm;
+ }
+}
+
+Bool
+ephyrUnmapFramebuffer (KdScreenInfo *screen)
+{
+ EphyrScrPriv *scrpriv = screen->driver;
+
+ if (scrpriv->shadow)
+ KdShadowFbFree (screen, 0);
+
+ /* Note, priv->base will get freed when XImage recreated */
+
+ return TRUE;
+}
+
+void
+ephyrShadowUpdate (ScreenPtr pScreen, shadowBufPtr pBuf)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+
+ EPHYR_LOG("slow paint");
+
+ /* FIXME: Slow Rotated/Reflected updates could be much
+ * much faster efficiently updating via tranforming
+ * pBuf->pDamage regions
+ */
+ shadowUpdateRotatePacked(pScreen, pBuf);
+ hostx_paint_rect(screen, 0,0,0,0, screen->width, screen->height);
+}
+
+static void
+ephyrInternalDamageRedisplay (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ RegionPtr pRegion;
+
+ if (!scrpriv || !scrpriv->pDamage)
+ return;
+
+ pRegion = DamageRegion (scrpriv->pDamage);
+
+ if (REGION_NOTEMPTY (pScreen, pRegion))
+ {
+ int nbox;
+ BoxPtr pbox;
+
+ nbox = REGION_NUM_RECTS (pRegion);
+ pbox = REGION_RECTS (pRegion);
+
+ while (nbox--)
+ {
+ hostx_paint_rect(screen,
+ pbox->x1, pbox->y1,
+ pbox->x1, pbox->y1,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1);
+ pbox++;
+ }
+ DamageEmpty (scrpriv->pDamage);
+ }
+}
+
+static void
+ephyrInternalDamageBlockHandler (pointer data,
+ OSTimePtr pTimeout,
+ pointer pRead)
+{
+ ScreenPtr pScreen = (ScreenPtr) data;
+
+ ephyrInternalDamageRedisplay (pScreen);
+}
+
+static void
+ephyrInternalDamageWakeupHandler (pointer data, int i, pointer LastSelectMask)
+{
+ /* FIXME: Not needed ? */
+}
+
+Bool
+ephyrSetInternalDamage (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ PixmapPtr pPixmap = NULL;
+
+ scrpriv->pDamage = DamageCreate ((DamageReportFunc) 0,
+ (DamageDestroyFunc) 0,
+ DamageReportNone,
+ TRUE,
+ pScreen,
+ pScreen);
+
+ if (!RegisterBlockAndWakeupHandlers (ephyrInternalDamageBlockHandler,
+ ephyrInternalDamageWakeupHandler,
+ (pointer) pScreen))
+ return FALSE;
+
+ pPixmap = (*pScreen->GetScreenPixmap) (pScreen);
+
+ DamageRegister (&pPixmap->drawable, scrpriv->pDamage);
+
+ return TRUE;
+}
+
+void
+ephyrUnsetInternalDamage (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ PixmapPtr pPixmap = NULL;
+
+ pPixmap = (*pScreen->GetScreenPixmap) (pScreen);
+ DamageUnregister (&pPixmap->drawable, scrpriv->pDamage);
+ DamageDestroy (scrpriv->pDamage);
+
+ RemoveBlockAndWakeupHandlers (ephyrInternalDamageBlockHandler,
+ ephyrInternalDamageWakeupHandler,
+ (pointer) pScreen);
+}
+
+#ifdef RANDR
+Bool
+ephyrRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ RRScreenSizePtr pSize;
+ Rotation randr;
+ int n = 0;
+
+ struct { int width, height; } sizes[] =
+ {
+ { 1600, 1200 },
+ { 1400, 1050 },
+ { 1280, 960 },
+ { 1280, 1024 },
+ { 1152, 864 },
+ { 1024, 768 },
+ { 832, 624 },
+ { 800, 600 },
+ { 720, 400 },
+ { 480, 640 },
+ { 640, 480 },
+ { 640, 400 },
+ { 320, 240 },
+ { 240, 320 },
+ { 160, 160 },
+ { 0, 0 }
+ };
+
+ EPHYR_LOG("mark");
+
+ *rotations = RR_Rotate_All|RR_Reflect_All;
+
+ if (!hostx_want_preexisting_window (screen)
+ && !hostx_want_fullscreen ()) /* only if no -parent switch */
+ {
+ while (sizes[n].width != 0 && sizes[n].height != 0)
+ {
+ RRRegisterSize (pScreen,
+ sizes[n].width,
+ sizes[n].height,
+ (sizes[n].width * screen->width_mm)/screen->width,
+ (sizes[n].height *screen->height_mm)/screen->height
+ );
+ n++;
+ }
+ }
+
+ pSize = RRRegisterSize (pScreen,
+ screen->width,
+ screen->height,
+ screen->width_mm,
+ screen->height_mm);
+
+ randr = KdSubRotation (scrpriv->randr, screen->randr);
+
+ RRSetCurrentConfig (pScreen, randr, 0, pSize);
+
+ return TRUE;
+}
+
+Bool
+ephyrRandRSetConfig (ScreenPtr pScreen,
+ Rotation randr,
+ int rate,
+ RRScreenSizePtr pSize)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ Bool wasEnabled = pScreenPriv->enabled;
+ EphyrScrPriv oldscr;
+ int oldwidth, oldheight, oldmmwidth, oldmmheight;
+ Bool oldshadow;
+ int newwidth, newheight;
+
+ if (screen->randr & (RR_Rotate_0|RR_Rotate_180))
+ {
+ newwidth = pSize->width;
+ newheight = pSize->height;
+ }
+ else
+ {
+ newwidth = pSize->height;
+ newheight = pSize->width;
+ }
+
+ if (wasEnabled)
+ KdDisableScreen (pScreen);
+
+ oldscr = *scrpriv;
+
+ oldwidth = screen->width;
+ oldheight = screen->height;
+ oldmmwidth = pScreen->mmWidth;
+ oldmmheight = pScreen->mmHeight;
+ oldshadow = scrpriv->shadow;
+
+ /*
+ * Set new configuration
+ */
+
+ scrpriv->randr = KdAddRotation (screen->randr, randr);
+
+ ephyrUnmapFramebuffer (screen);
+
+ screen->width = newwidth;
+ screen->height = newheight;
+
+ if (!ephyrMapFramebuffer (screen))
+ goto bail4;
+
+ /* FIXME below should go in own call */
+
+ if (oldshadow)
+ KdShadowUnset (screen->pScreen);
+ else
+ ephyrUnsetInternalDamage(screen->pScreen);
+
+ if (scrpriv->shadow)
+ {
+ if (!KdShadowSet (screen->pScreen,
+ scrpriv->randr,
+ ephyrShadowUpdate,
+ ephyrWindowLinear))
+ goto bail4;
+ }
+ else
+ {
+ /* Without shadow fb ( non rotated ) we need
+ * to use damage to efficiently update display
+ * via signal regions what to copy from 'fb'.
+ */
+ if (!ephyrSetInternalDamage(screen->pScreen))
+ goto bail4;
+ }
+
+ ephyrSetScreenSizes (screen->pScreen);
+
+ /*
+ * Set frame buffer mapping
+ */
+ (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
+ pScreen->width,
+ pScreen->height,
+ screen->fb[0].depth,
+ screen->fb[0].bitsPerPixel,
+ screen->fb[0].byteStride,
+ screen->fb[0].frameBuffer);
+
+ /* set the subpixel order */
+
+ KdSetSubpixelOrder (pScreen, scrpriv->randr);
+
+ if (wasEnabled)
+ KdEnableScreen (pScreen);
+
+ return TRUE;
+
+ bail4:
+ EPHYR_LOG("bailed");
+
+ ephyrUnmapFramebuffer (screen);
+ *scrpriv = oldscr;
+ (void) ephyrMapFramebuffer (screen);
+
+ pScreen->width = oldwidth;
+ pScreen->height = oldheight;
+ pScreen->mmWidth = oldmmwidth;
+ pScreen->mmHeight = oldmmheight;
+
+ if (wasEnabled)
+ KdEnableScreen (pScreen);
+ return FALSE;
+}
+
+Bool
+ephyrRandRInit (ScreenPtr pScreen)
+{
+ rrScrPrivPtr pScrPriv;
+
+ if (!RRScreenInit (pScreen))
+ return FALSE;
+
+ pScrPriv = rrGetScrPriv(pScreen);
+ pScrPriv->rrGetInfo = ephyrRandRGetInfo;
+ pScrPriv->rrSetConfig = ephyrRandRSetConfig;
+ return TRUE;
+}
+#endif
+
+Bool
+ephyrCreateColormap (ColormapPtr pmap)
+{
+ return fbInitializeColormap (pmap);
+}
+
+Bool
+ephyrInitScreen (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+
+ EPHYR_LOG ("pScreen->myNum:%d\n", pScreen->myNum) ;
+ hostx_set_screen_number (screen, pScreen->myNum);
+ hostx_set_win_title (screen, "(ctrl+shift grabs mouse and keyboard)") ;
+ pScreen->CreateColormap = ephyrCreateColormap;
+
+#ifdef XV
+ if (!ephyrNoXV) {
+ if (!ephyrInitVideo (pScreen)) {
+ EPHYR_LOG_ERROR ("failed to initialize xvideo\n") ;
+ } else {
+ EPHYR_LOG ("initialized xvideo okay\n") ;
+ }
+ }
+#endif /*XV*/
+
+#ifdef XF86DRI
+ if (!ephyrNoDRI && !hostx_has_dri ()) {
+ EPHYR_LOG ("host x does not support DRI. Disabling DRI forwarding\n") ;
+ ephyrNoDRI = TRUE ;
+#ifdef GLXEXT
+ noGlxVisualInit = FALSE ;
+#endif
+ }
+ if (!ephyrNoDRI) {
+ ephyrDRIExtensionInit (pScreen) ;
+ ephyrHijackGLXExtension () ;
+ }
+#endif
+
+#ifdef GLXEXT
+ if (ephyrNoDRI) {
+ noGlxVisualInit = FALSE ;
+ }
+#endif
+
+ return TRUE;
+}
+
+Bool
+ephyrFinishInitScreen (ScreenPtr pScreen)
+{
+ /* FIXME: Calling this even if not using shadow.
+ * Seems harmless enough. But may be safer elsewhere.
+ */
+ if (!shadowSetup (pScreen))
+ return FALSE;
+
+#ifdef RANDR
+ if (!ephyrRandRInit (pScreen))
+ return FALSE;
+#endif
+
+ return TRUE;
+}
+
+Bool
+ephyrCreateResources (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+
+ EPHYR_LOG("mark pScreen=%p mynum=%d shadow=%d",
+ pScreen, pScreen->myNum, scrpriv->shadow);
+
+ if (scrpriv->shadow)
+ return KdShadowSet (pScreen,
+ scrpriv->randr,
+ ephyrShadowUpdate,
+ ephyrWindowLinear);
+ else
+ return ephyrSetInternalDamage(pScreen);
+}
+
+void
+ephyrPreserve (KdCardInfo *card)
+{
+}
+
+Bool
+ephyrEnable (ScreenPtr pScreen)
+{
+ return TRUE;
+}
+
+Bool
+ephyrDPMS (ScreenPtr pScreen, int mode)
+{
+ return TRUE;
+}
+
+void
+ephyrDisable (ScreenPtr pScreen)
+{
+}
+
+void
+ephyrRestore (KdCardInfo *card)
+{
+}
+
+void
+ephyrScreenFini (KdScreenInfo *screen)
+{
+ EphyrScrPriv *scrpriv = screen->driver;
+ if (scrpriv->shadow) {
+ KdShadowFbFree (screen, 0);
+ }
+ xfree(screen->driver);
+ screen->driver = NULL;
+}
+
+/*
+ * Port of Mark McLoughlin's Xnest fix for focus in + modifier bug.
+ * See https://bugs.freedesktop.org/show_bug.cgi?id=3030
+ */
+void
+ephyrUpdateModifierState(unsigned int state)
+{
+#if 0
+ DeviceIntPtr pkeydev;
+ KeyClassPtr keyc;
+ int i;
+ CARD8 mask;
+
+ pkeydev = inputInfo.keyboard;
+
+ if (!pkeydev)
+ return;
+
+/* This is pretty broken.
+ *
+ * What should happen is that focus out should do as a VT switch does in
+ * traditional servers: fake releases for all keys (and buttons too, come
+ * to think of it) currently down. Then, on focus in, get the state from
+ * the host, and fake keypresses for everything currently down.
+ *
+ * So I'm leaving this broken for a little while. Sorry, folks.
+ *
+ * -daniels
+ */
+
+ keyc = pkeydev->key;
+
+ state = state & 0xff;
+
+ if (keyc->state == state)
+ return;
+
+ for (i = 0, mask = 1; i < 8; i++, mask <<= 1)
+ {
+ int key;
+
+ /* Modifier is down, but shouldn't be */
+ if ((keyc->state & mask) && !(state & mask))
+ {
+ int count = keyc->modifierKeyCount[i];
+
+ for (key = 0; key < MAP_LENGTH; key++)
+ if (keyc->xkbInfo->desc->map->modmap[key] & mask)
+ {
+ int bit;
+ BYTE *kptr;
+
+ kptr = &keyc->down[key >> 3];
+ bit = 1 << (key & 7);
+
+ if (*kptr & bit && ephyrKbd &&
+ ((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
+ KdEnqueueKeyboardEvent(ephyrKbd, key, TRUE); /* release */
+
+ if (--count == 0)
+ break;
+ }
+ }
+
+ /* Modifier shoud be down, but isn't */
+ if (!(keyc->state & mask) && (state & mask))
+ for (key = 0; key < MAP_LENGTH; key++)
+ if (keyc->xkbInfo->desc->map->modmap[key] & mask)
+ {
+ if (keyc->xkbInfo->desc->map->modmap[key] & mask && ephyrKbd &&
+ ((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
+ KdEnqueueKeyboardEvent(ephyrKbd, key, FALSE); /* press */
+ break;
+ }
+ }
+#endif
+}
+
+static void
+ephyrBlockSigio (void)
+{
+#ifdef _MSC_VER
+ __asm int 3;
+#else
+ sigset_t set;
+
+ sigemptyset (&set);
+ sigaddset (&set, SIGIO);
+ sigprocmask (SIG_BLOCK, &set, 0);
+#endif
+}
+
+static void
+ephyrUnblockSigio (void)
+{
+#ifdef _MSC_VER
+ __asm int 3;
+#else
+ sigset_t set;
+
+ sigemptyset (&set);
+ sigaddset (&set, SIGIO);
+ sigprocmask (SIG_UNBLOCK, &set, 0);
+#endif
+}
+
+static Bool
+ephyrCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y)
+{
+ return FALSE;
+}
+
+static void
+ephyrCrossScreen (ScreenPtr pScreen, Bool entering)
+{
+}
+
+int ephyrCurScreen; /*current event screen*/
+
+static void
+ephyrWarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
+{
+ ephyrBlockSigio ();
+ ephyrCurScreen = pScreen->myNum;
+ miPointerWarpCursor (inputInfo.pointer, pScreen, x, y);
+ ephyrUnblockSigio ();
+}
+
+miPointerScreenFuncRec ephyrPointerScreenFuncs =
+{
+ ephyrCursorOffScreen,
+ ephyrCrossScreen,
+ ephyrWarpCursor,
+ NULL,
+ NULL
+};
+
+#ifdef XF86DRI
+/**
+ * find if the remote window denoted by a_remote
+ * is paired with an internal Window within the Xephyr server.
+ * If the remove window is paired with an internal window, send an
+ * expose event to the client insterested in the internal window expose event.
+ *
+ * Pairing happens when a drawable inside Xephyr is associated with
+ * a GL surface in a DRI environment.
+ * Look at the function ProcXF86DRICreateDrawable in ephyrdriext.c to
+ * know a paired window is created.
+ *
+ * This is useful to make GL drawables (only windows for now) handle
+ * expose events and send those events to clients.
+ */
+static void
+ephyrExposePairedWindow (int a_remote)
+{
+ EphyrWindowPair *pair = NULL;
+ RegionRec reg;
+ ScreenPtr screen;
+
+ if (!findWindowPairFromRemote (a_remote, &pair)) {
+ EPHYR_LOG ("did not find a pair for this window\n");
+ return;
+ }
+ screen = pair->local->drawable.pScreen;
+ REGION_NULL (screen, &reg);
+ REGION_COPY (screen, &reg, &pair->local->clipList);
+ screen->WindowExposures (pair->local, &reg, NullRegion);
+ REGION_UNINIT (screen, &reg);
+}
+#endif /* XF86DRI */
+
+void
+ephyrPoll(void)
+{
+ EphyrHostXEvent ev;
+
+ while (hostx_get_event(&ev))
+ {
+ switch (ev.type)
+ {
+ case EPHYR_EV_MOUSE_MOTION:
+ if (!ephyrMouse ||
+ !((EphyrPointerPrivate *)ephyrMouse->driverPrivate)->enabled) {
+ EPHYR_LOG ("skipping mouse motion:%d\n", ephyrCurScreen) ;
+ continue;
+ }
+ {
+ if (ev.data.mouse_motion.screen >=0
+ && (ephyrCurScreen != ev.data.mouse_motion.screen))
+ {
+ EPHYR_LOG ("warping mouse cursor. "
+ "cur_screen%d, motion_screen:%d\n",
+ ephyrCurScreen, ev.data.mouse_motion.screen) ;
+ if (ev.data.mouse_motion.screen >= 0)
+ {
+ ephyrWarpCursor
+ (inputInfo.pointer, screenInfo.screens[ev.data.mouse_motion.screen],
+ ev.data.mouse_motion.x,
+ ev.data.mouse_motion.y );
+ }
+ }
+ else
+ {
+ int x=0, y=0;
+#ifdef XF86DRI
+ EphyrWindowPair *pair = NULL;
+#endif
+ EPHYR_LOG ("enqueuing mouse motion:%d\n", ephyrCurScreen) ;
+ x = ev.data.mouse_motion.x;
+ y = ev.data.mouse_motion.y;
+ EPHYR_LOG ("initial (x,y):(%d,%d)\n", x, y) ;
+#ifdef XF86DRI
+ EPHYR_LOG ("is this window peered by a gl drawable ?\n") ;
+ if (findWindowPairFromRemote (ev.data.mouse_motion.window,
+ &pair))
+ {
+ EPHYR_LOG ("yes, it is peered\n") ;
+ x += pair->local->drawable.x;
+ y += pair->local->drawable.y;
+ }
+ else
+ {
+ EPHYR_LOG ("no, it is not peered\n") ;
+ }
+ EPHYR_LOG ("final (x,y):(%d,%d)\n", x, y) ;
+#endif
+ KdEnqueuePointerEvent(ephyrMouse, mouseState, x, y, 0);
+ }
+ }
+ break;
+
+ case EPHYR_EV_MOUSE_PRESS:
+ if (!ephyrMouse ||
+ !((EphyrPointerPrivate *)ephyrMouse->driverPrivate)->enabled) {
+ EPHYR_LOG ("skipping mouse press:%d\n", ephyrCurScreen) ;
+ continue;
+ }
+ EPHYR_LOG ("enqueuing mouse press:%d\n", ephyrCurScreen) ;
+ ephyrUpdateModifierState(ev.key_state);
+ mouseState |= ev.data.mouse_down.button_num;
+ KdEnqueuePointerEvent(ephyrMouse, mouseState|KD_MOUSE_DELTA, 0, 0, 0);
+ break;
+
+ case EPHYR_EV_MOUSE_RELEASE:
+ if (!ephyrMouse ||
+ !((EphyrPointerPrivate *)ephyrMouse->driverPrivate)->enabled)
+ continue;
+ ephyrUpdateModifierState(ev.key_state);
+ mouseState &= ~ev.data.mouse_up.button_num;
+ EPHYR_LOG ("enqueuing mouse release:%d\n", ephyrCurScreen) ;
+ KdEnqueuePointerEvent(ephyrMouse, mouseState|KD_MOUSE_DELTA, 0, 0, 0);
+ break;
+
+ case EPHYR_EV_KEY_PRESS:
+ if (!ephyrKbd ||
+ !((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
+ continue;
+ ephyrUpdateModifierState(ev.key_state);
+ KdEnqueueKeyboardEvent (ephyrKbd, ev.data.key_down.scancode, FALSE);
+ break;
+
+ case EPHYR_EV_KEY_RELEASE:
+ if (!ephyrKbd ||
+ !((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
+ continue;
+ KdEnqueueKeyboardEvent (ephyrKbd, ev.data.key_up.scancode, TRUE);
+ break;
+
+#ifdef XF86DRI
+ case EPHYR_EV_EXPOSE:
+ /*
+ * We only receive expose events when the expose event have
+ * be generated for a drawable that is a host X window managed
+ * by Xephyr. Host X windows managed by Xephyr exists for instance
+ * when Xephyr is asked to create a GL drawable in a DRI environment.
+ */
+ ephyrExposePairedWindow (ev.data.expose.window);
+ break;
+#endif /* XF86DRI */
+
+ default:
+ break;
+ }
+ }
+}
+
+void
+ephyrCardFini (KdCardInfo *card)
+{
+ EphyrPriv *priv = card->driver;
+ xfree (priv);
+}
+
+void
+ephyrGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
+{
+ /* XXX Not sure if this is right */
+
+ EPHYR_LOG("mark");
+
+ while (n--)
+ {
+ pdefs->red = 0;
+ pdefs->green = 0;
+ pdefs->blue = 0;
+ pdefs++;
+ }
+
+}
+
+void
+ephyrPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
+{
+ int min, max, p;
+
+ /* XXX Not sure if this is right */
+
+ min = 256;
+ max = 0;
+
+ while (n--)
+ {
+ p = pdefs->pixel;
+ if (p < min)
+ min = p;
+ if (p > max)
+ max = p;
+
+ hostx_set_cmap_entry(p,
+ pdefs->red >> 8,
+ pdefs->green >> 8,
+ pdefs->blue >> 8);
+ pdefs++;
+ }
+}
+
+/* Mouse calls */
+
+static Status
+MouseInit (KdPointerInfo *pi)
+{
+ pi->driverPrivate = (EphyrPointerPrivate *)
+ xcalloc(sizeof(EphyrPointerPrivate), 1);
+ ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE;
+ pi->nAxes = 3;
+ pi->nButtons = 32;
+ if (pi->name)
+ xfree(pi->name);
+ pi->name = strdup("Xephyr virtual mouse");
+ ephyrMouse = pi;
+ return Success;
+}
+
+static Status
+MouseEnable (KdPointerInfo *pi)
+{
+ ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = TRUE;
+ return Success;
+}
+
+static void
+MouseDisable (KdPointerInfo *pi)
+{
+ ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE;
+ return;
+}
+
+static void
+MouseFini (KdPointerInfo *pi)
+{
+ ephyrMouse = NULL;
+ return;
+}
+
+KdPointerDriver EphyrMouseDriver = {
+ "ephyr",
+ MouseInit,
+ MouseEnable,
+ MouseDisable,
+ MouseFini,
+ NULL,
+};
+
+/* Keyboard */
+
+static Status
+EphyrKeyboardInit (KdKeyboardInfo *ki)
+{
+ ki->driverPrivate = (EphyrKbdPrivate *)
+ xcalloc(sizeof(EphyrKbdPrivate), 1);
+ hostx_load_keymap();
+ if (!ephyrKeySyms.map) {
+ ErrorF("Couldn't load keymap from host\n");
+ return BadAlloc;
+ }
+ ki->minScanCode = ephyrKeySyms.minKeyCode;
+ ki->maxScanCode = ephyrKeySyms.maxKeyCode;
+ if (ki->name)
+ xfree(ki->name);
+ ki->name = strdup("Xephyr virtual keyboard");
+ ephyrKbd = ki;
+ return Success;
+}
+
+static Status
+EphyrKeyboardEnable (KdKeyboardInfo *ki)
+{
+ ((EphyrKbdPrivate *)ki->driverPrivate)->enabled = TRUE;
+
+ return Success;
+}
+
+static void
+EphyrKeyboardDisable (KdKeyboardInfo *ki)
+{
+ ((EphyrKbdPrivate *)ki->driverPrivate)->enabled = FALSE;
+}
+
+static void
+EphyrKeyboardFini (KdKeyboardInfo *ki)
+{
+ ephyrKbd = NULL;
+ return;
+}
+
+static void
+EphyrKeyboardLeds (KdKeyboardInfo *ki, int leds)
+{
+}
+
+static void
+EphyrKeyboardBell (KdKeyboardInfo *ki, int volume, int frequency, int duration)
+{
+}
+
+
+KdKeyboardDriver EphyrKeyboardDriver = {
+ "ephyr",
+ EphyrKeyboardInit,
+ EphyrKeyboardEnable,
+ EphyrKeyboardLeds,
+ EphyrKeyboardBell,
+ EphyrKeyboardDisable,
+ EphyrKeyboardFini,
+ NULL,
+};
diff --git a/xorg-server/hw/kdrive/ephyr/ephyr.h b/xorg-server/hw/kdrive/ephyr/ephyr.h
index 5d58a216c..dd22bd150 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyr.h
+++ b/xorg-server/hw/kdrive/ephyr/ephyr.h
@@ -26,9 +26,11 @@
#ifndef _EPHYR_H_
#define _EPHYR_H_
#include <stdio.h>
+#ifndef _MSC_VER
#include <unistd.h>
-#include <signal.h>
#include <libgen.h>
+#endif
+#include <signal.h>
#include "os.h" /* for OsSignal() */
#include "kdrive.h"
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrinit.c b/xorg-server/hw/kdrive/ephyr/ephyrinit.c
index 2b72b4e0a..0c638e98d 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrinit.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrinit.c
@@ -1,409 +1,421 @@
-/*
- * Xephyr - A kdrive X server thats runs in a host X window.
- * Authored by Matthew Allum <mallum@o-hand.com>
- *
- * Copyright © 2004 Nokia
- *
- * 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 Nokia not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Nokia makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * NOKIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL NOKIA 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "ephyr.h"
-#include "ephyrlog.h"
-
-extern Window EphyrPreExistingHostWin;
-extern Bool EphyrWantGrayScale;
-extern Bool kdHasPointer;
-extern Bool kdHasKbd;
-
-#ifdef GLXEXT
-extern Bool ephyrNoDRI;
-extern Bool noGlxVisualInit;
-#endif
-extern Bool ephyrNoXV;
-
-void processScreenArg (char *screen_size, char *parent_id) ;
-
-void
-InitCard (char *name)
-{
- KdCardAttr attr;
-
- EPHYR_DBG("mark");
-
-
- KdCardInfoAdd (&ephyrFuncs, &attr, 0);
-}
-
-void
-InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
-{
- KdInitOutput (pScreenInfo, argc, argv);
-}
-
-void
-InitInput (int argc, char **argv)
-{
- KdKeyboardInfo *ki;
- KdPointerInfo *pi;
-
- KdAddKeyboardDriver(&EphyrKeyboardDriver);
-#ifdef linux
- KdAddKeyboardDriver(&LinuxEvdevKeyboardDriver);
-#endif
- KdAddPointerDriver(&EphyrMouseDriver);
-#ifdef linux
- KdAddPointerDriver(&LinuxEvdevMouseDriver);
-#endif
-
- if (!kdHasKbd) {
- ki = KdNewKeyboard();
- if (!ki)
- FatalError("Couldn't create Xephyr keyboard\n");
- ki->driver = &EphyrKeyboardDriver;
- KdAddKeyboard(ki);
- }
-
- if (!kdHasPointer) {
- pi = KdNewPointer();
- if (!pi)
- FatalError("Couldn't create Xephyr pointer\n");
- pi->driver = &EphyrMouseDriver;
- KdAddPointer(pi);
- }
-
- KdInitInput();
-}
-
-#ifdef DDXBEFORERESET
-void
-ddxBeforeReset (void)
-{
-}
-#endif
-
-void
-ddxUseMsg (void)
-{
- KdUseMsg();
-
- ErrorF("\nXephyr Option Usage:\n");
- ErrorF("-parent <XID> Use existing window as Xephyr root win\n");
- ErrorF("-host-cursor Re-use exisiting X host server cursor\n");
- ErrorF("-fullscreen Attempt to run Xephyr fullscreen\n");
- ErrorF("-grayscale Simulate 8bit grayscale\n");
- ErrorF("-fakexa Simulate acceleration using software rendering\n");
- ErrorF("-verbosity <level> Set log verbosity level\n");
-#ifdef GLXEXT
- ErrorF("-nodri do not use DRI\n");
-#endif
- ErrorF("-noxv do not use XV\n");
- ErrorF("-name [name] define the name in the WM_CLASS property\n");
- ErrorF("-title [title] set the window title in the WM_NAME property\n");
- ErrorF("\n");
-
- exit(1);
-}
-
-void
-processScreenArg (char *screen_size, char *parent_id)
-{
- KdCardInfo *card;
-
- InitCard (0); /*Put each screen on a separate card*/
- card = KdCardInfoLast ();
-
- if (card)
- {
- KdScreenInfo *screen;
- unsigned long p_id = 0;
-
- screen = KdScreenInfoAdd (card);
- KdParseScreen (screen, screen_size);
-
- if (parent_id)
- {
- p_id = strtol (parent_id, NULL, 0);
- }
- EPHYR_DBG ("screen number:%d\n", screen->mynum) ;
- hostx_add_screen (screen, p_id, screen->mynum);
- }
- else
- {
- ErrorF("No matching card found!\n");
- }
-}
-
-int
-ddxProcessArgument (int argc, char **argv, int i)
-{
- static char* parent = NULL;
- EPHYR_DBG("mark argv[%d]='%s'", i, argv[i] );
-
- if (i == 1)
- {
- hostx_use_resname(basename(argv[0]), 0);
- }
-
- if (!strcmp (argv[i], "-parent"))
- {
- if(i+1 < argc)
- {
- int j;
- /* If parent is specified and a screen argument follows, don't do
- * anything, let the -screen handling init the rest */
- for (j = i; j < argc; j++)
- {
- if (!strcmp(argv[j], "-screen"))
- {
- parent = argv[i + 1];
- return 2;
- }
- }
-
- processScreenArg ("100x100", argv[i+1]);
- return 2;
- }
-
- UseMsg();
- exit(1);
- }
- else if (!strcmp (argv[i], "-screen"))
- {
- if ((i+1) < argc)
- {
- processScreenArg (argv[i+1], parent);
- parent = NULL;
- return 2;
- }
-
- UseMsg();
- exit(1);
- }
- else if (!strcmp (argv[i], "-host-cursor"))
- {
- hostx_use_host_cursor();
- return 1;
- }
- else if (!strcmp (argv[i], "-fullscreen"))
- {
- hostx_use_fullscreen();
- return 1;
- }
- else if (!strcmp (argv[i], "-grayscale"))
- {
- EphyrWantGrayScale = 1;
- return 1;
- }
- else if (!strcmp (argv[i], "-fakexa"))
- {
- ephyrFuncs.initAccel = ephyrDrawInit;
- ephyrFuncs.enableAccel = ephyrDrawEnable;
- ephyrFuncs.disableAccel = ephyrDrawDisable;
- ephyrFuncs.finiAccel = ephyrDrawFini;
- return 1;
- }
- else if (!strcmp (argv[i], "-verbosity"))
- {
- if(i+1 < argc && argv[i+1][0] != '-')
- {
- int verbosity=atoi (argv[i+1]) ;
- LogSetParameter (XLOG_VERBOSITY, verbosity) ;
- EPHYR_LOG ("set verbosiry to %d\n", verbosity) ;
- return 2 ;
- }
- else
- {
- UseMsg() ;
- exit(1) ;
- }
- }
-#ifdef GLXEXT
- else if (!strcmp (argv[i], "-nodri"))
- {
- noGlxVisualInit = FALSE ;
- ephyrNoDRI = TRUE ;
- EPHYR_LOG ("no direct rendering enabled\n") ;
- return 1 ;
- }
-#endif
- else if (!strcmp (argv[i], "-noxv"))
- {
- ephyrNoXV = TRUE ;
- EPHYR_LOG ("no XVideo enabled\n") ;
- return 1 ;
- }
- else if (!strcmp (argv[i], "-name"))
- {
- if (i+1 < argc && argv[i+1][0] != '-')
- {
- hostx_use_resname(argv[i+1], 1);
- return 2;
- }
- else
- {
- UseMsg();
- return 0;
- }
- }
- else if (!strcmp (argv[i], "-title"))
- {
- if (i+1 < argc && argv[i+1][0] != '-')
- {
- hostx_set_title(argv[i+1]);
- return 2;
- }
- else
- {
- UseMsg();
- return 0;
- }
- }
- else if (argv[i][0] == ':')
- {
- hostx_set_display_name(argv[i]);
- }
- /* Xnest compatibility */
- else if (!strcmp(argv[i], "-display"))
- {
- hostx_set_display_name(argv[i+1]);
- return 2;
- }
- else if (!strcmp(argv[i], "-sync") ||
- !strcmp(argv[i], "-full") ||
- !strcmp(argv[i], "-sss") ||
- !strcmp(argv[i], "-install"))
- {
- return 1;
- }
- else if (!strcmp(argv[i], "-bw") ||
- !strcmp(argv[i], "-class") ||
- !strcmp(argv[i], "-geometry") ||
- !strcmp(argv[i], "-scrns"))
- {
- return 2;
- }
- /* end Xnest compat */
-
- return KdProcessArgument (argc, argv, i);
-}
-
-void
-OsVendorInit (void)
-{
- EPHYR_DBG("mark");
-
- if (hostx_want_host_cursor())
- {
- ephyrFuncs.initCursor = &ephyrCursorInit;
- ephyrFuncs.enableCursor = &ephyrCursorEnable;
- }
-
- KdOsInit (&EphyrOsFuncs);
-}
-
-/* 'Fake' cursor stuff, could be improved */
-
-static Bool
-ephyrRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
-{
- return TRUE;
-}
-
-static Bool
-ephyrUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
-{
- return TRUE;
-}
-
-static void
-ephyrSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
-{
- ;
-}
-
-static void
-ephyrMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
-{
- ;
-}
-
-static Bool
-ephyrDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
-{
- return TRUE;
-}
-
-miPointerSpriteFuncRec EphyrPointerSpriteFuncs = {
- ephyrRealizeCursor,
- ephyrUnrealizeCursor,
- ephyrSetCursor,
- ephyrMoveCursor,
- ephyrDeviceCursorInitialize,
- NULL
-};
-
-
-Bool
-ephyrCursorInit(ScreenPtr pScreen)
-{
- miPointerInitialize(pScreen,
- &EphyrPointerSpriteFuncs,
- &ephyrPointerScreenFuncs,
- FALSE);
-
- return TRUE;
-}
-
-void
-ephyrCursorEnable(ScreenPtr pScreen)
-{
- ;
-}
-
-KdCardFuncs ephyrFuncs = {
- ephyrCardInit, /* cardinit */
- ephyrScreenInit, /* scrinit */
- ephyrInitScreen, /* initScreen */
- ephyrFinishInitScreen, /* finishInitScreen */
- ephyrCreateResources, /* createRes */
- ephyrPreserve, /* preserve */
- ephyrEnable, /* enable */
- ephyrDPMS, /* dpms */
- ephyrDisable, /* disable */
- ephyrRestore, /* restore */
- ephyrScreenFini, /* scrfini */
- ephyrCardFini, /* cardfini */
-
- 0, /* initCursor */
- 0, /* enableCursor */
- 0, /* disableCursor */
- 0, /* finiCursor */
- 0, /* recolorCursor */
-
- 0, /* initAccel */
- 0, /* enableAccel */
- 0, /* disableAccel */
- 0, /* finiAccel */
-
- ephyrGetColors,/* getColors */
- ephyrPutColors, /* putColors */
-};
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@o-hand.com>
+ *
+ * Copyright © 2004 Nokia
+ *
+ * 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 Nokia not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Nokia makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * NOKIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL NOKIA 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "ephyr.h"
+#include "ephyrlog.h"
+
+extern Window EphyrPreExistingHostWin;
+extern Bool EphyrWantGrayScale;
+extern Bool kdHasPointer;
+extern Bool kdHasKbd;
+
+#ifdef GLXEXT
+extern Bool ephyrNoDRI;
+extern Bool noGlxVisualInit;
+#endif
+extern Bool ephyrNoXV;
+
+void processScreenArg (char *screen_size, char *parent_id) ;
+
+void
+InitCard (char *name)
+{
+ KdCardAttr attr;
+
+ EPHYR_DBG("mark");
+
+
+ KdCardInfoAdd (&ephyrFuncs, &attr, 0);
+}
+
+#ifndef _MSC_VER
+void
+InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+ KdInitOutput (pScreenInfo, argc, argv);
+}
+
+void
+InitInput (int argc, char **argv)
+{
+ KdKeyboardInfo *ki;
+ KdPointerInfo *pi;
+
+ KdAddKeyboardDriver(&EphyrKeyboardDriver);
+#ifdef linux
+ KdAddKeyboardDriver(&LinuxEvdevKeyboardDriver);
+#endif
+ KdAddPointerDriver(&EphyrMouseDriver);
+#ifdef linux
+ KdAddPointerDriver(&LinuxEvdevMouseDriver);
+#endif
+
+ if (!kdHasKbd) {
+ ki = KdNewKeyboard();
+ if (!ki)
+ FatalError("Couldn't create Xephyr keyboard\n");
+ ki->driver = &EphyrKeyboardDriver;
+ KdAddKeyboard(ki);
+ }
+
+ if (!kdHasPointer) {
+ pi = KdNewPointer();
+ if (!pi)
+ FatalError("Couldn't create Xephyr pointer\n");
+ pi->driver = &EphyrMouseDriver;
+ KdAddPointer(pi);
+ }
+
+ KdInitInput();
+}
+
+#ifdef DDXBEFORERESET
+void
+ddxBeforeReset (void)
+{
+}
+#endif
+
+void
+ddxUseMsg (void)
+{
+ KdUseMsg();
+
+ ErrorF("\nXephyr Option Usage:\n");
+ ErrorF("-parent <XID> Use existing window as Xephyr root win\n");
+ ErrorF("-host-cursor Re-use exisiting X host server cursor\n");
+ ErrorF("-fullscreen Attempt to run Xephyr fullscreen\n");
+ ErrorF("-grayscale Simulate 8bit grayscale\n");
+ ErrorF("-fakexa Simulate acceleration using software rendering\n");
+ ErrorF("-verbosity <level> Set log verbosity level\n");
+#ifdef GLXEXT
+ ErrorF("-nodri do not use DRI\n");
+#endif
+ ErrorF("-noxv do not use XV\n");
+ ErrorF("-name [name] define the name in the WM_CLASS property\n");
+ ErrorF("-title [title] set the window title in the WM_NAME property\n");
+ ErrorF("\n");
+
+ exit(1);
+}
+#endif
+
+void
+processScreenArg (char *screen_size, char *parent_id)
+{
+ KdCardInfo *card;
+
+ InitCard (0); /*Put each screen on a separate card*/
+ card = KdCardInfoLast ();
+
+ if (card)
+ {
+ KdScreenInfo *screen;
+ unsigned long p_id = 0;
+
+ screen = KdScreenInfoAdd (card);
+ KdParseScreen (screen, screen_size);
+
+ if (parent_id)
+ {
+ p_id = strtol (parent_id, NULL, 0);
+ }
+ EPHYR_DBG ("screen number:%d\n", screen->mynum) ;
+ hostx_add_screen (screen, p_id, screen->mynum);
+ }
+ else
+ {
+ ErrorF("No matching card found!\n");
+ }
+}
+
+#ifndef _MSC_VER
+int
+ddxProcessArgument (int argc, char **argv, int i)
+{
+ static char* parent = NULL;
+ EPHYR_DBG("mark argv[%d]='%s'", i, argv[i] );
+
+ if (i == 1)
+ {
+ hostx_use_resname(basename(argv[0]), 0);
+ }
+
+ if (!strcmp (argv[i], "-parent"))
+ {
+ if(i+1 < argc)
+ {
+ int j;
+ /* If parent is specified and a screen argument follows, don't do
+ * anything, let the -screen handling init the rest */
+ for (j = i; j < argc; j++)
+ {
+ if (!strcmp(argv[j], "-screen"))
+ {
+ parent = argv[i + 1];
+ return 2;
+ }
+ }
+
+ processScreenArg ("100x100", argv[i+1]);
+ return 2;
+ }
+
+ UseMsg();
+ exit(1);
+ }
+ else if (!strcmp (argv[i], "-screen"))
+ {
+ if ((i+1) < argc)
+ {
+ processScreenArg (argv[i+1], parent);
+ parent = NULL;
+ return 2;
+ }
+
+ UseMsg();
+ exit(1);
+ }
+ else if (!strcmp (argv[i], "-host-cursor"))
+ {
+ hostx_use_host_cursor();
+ return 1;
+ }
+ else if (!strcmp (argv[i], "-fullscreen"))
+ {
+ hostx_use_fullscreen();
+ return 1;
+ }
+ else if (!strcmp (argv[i], "-grayscale"))
+ {
+ EphyrWantGrayScale = 1;
+ return 1;
+ }
+ else if (!strcmp (argv[i], "-fakexa"))
+ {
+ ephyrFuncs.initAccel = ephyrDrawInit;
+ ephyrFuncs.enableAccel = ephyrDrawEnable;
+ ephyrFuncs.disableAccel = ephyrDrawDisable;
+ ephyrFuncs.finiAccel = ephyrDrawFini;
+ return 1;
+ }
+ else if (!strcmp (argv[i], "-verbosity"))
+ {
+ if(i+1 < argc && argv[i+1][0] != '-')
+ {
+ int verbosity=atoi (argv[i+1]) ;
+ LogSetParameter (XLOG_VERBOSITY, verbosity) ;
+ EPHYR_LOG ("set verbosiry to %d\n", verbosity) ;
+ return 2 ;
+ }
+ else
+ {
+ UseMsg() ;
+ exit(1) ;
+ }
+ }
+#ifdef GLXEXT
+ else if (!strcmp (argv[i], "-nodri"))
+ {
+ noGlxVisualInit = FALSE ;
+ ephyrNoDRI = TRUE ;
+ EPHYR_LOG ("no direct rendering enabled\n") ;
+ return 1 ;
+ }
+#endif
+ else if (!strcmp (argv[i], "-noxv"))
+ {
+ ephyrNoXV = TRUE ;
+ EPHYR_LOG ("no XVideo enabled\n") ;
+ return 1 ;
+ }
+ else if (!strcmp (argv[i], "-name"))
+ {
+ if (i+1 < argc && argv[i+1][0] != '-')
+ {
+ hostx_use_resname(argv[i+1], 1);
+ return 2;
+ }
+ else
+ {
+ UseMsg();
+ return 0;
+ }
+ }
+ else if (!strcmp (argv[i], "-title"))
+ {
+ if (i+1 < argc && argv[i+1][0] != '-')
+ {
+ hostx_set_title(argv[i+1]);
+ return 2;
+ }
+ else
+ {
+ UseMsg();
+ return 0;
+ }
+ }
+ else if (argv[i][0] == ':')
+ {
+ hostx_set_display_name(argv[i]);
+ }
+ /* Xnest compatibility */
+ else if (!strcmp(argv[i], "-display"))
+ {
+ hostx_set_display_name(argv[i+1]);
+ return 2;
+ }
+ else if (!strcmp(argv[i], "-sync") ||
+ !strcmp(argv[i], "-full") ||
+ !strcmp(argv[i], "-sss") ||
+ !strcmp(argv[i], "-install"))
+ {
+ return 1;
+ }
+ else if (!strcmp(argv[i], "-bw") ||
+ !strcmp(argv[i], "-class") ||
+ !strcmp(argv[i], "-geometry") ||
+ !strcmp(argv[i], "-scrns"))
+ {
+ return 2;
+ }
+ /* end Xnest compat */
+
+ return KdProcessArgument (argc, argv, i);
+}
+
+void
+OsVendorInit (void)
+{
+ EPHYR_DBG("mark");
+
+ if (hostx_want_host_cursor())
+ {
+ ephyrFuncs.initCursor = &ephyrCursorInit;
+ ephyrFuncs.enableCursor = &ephyrCursorEnable;
+ }
+
+ KdOsInit (&EphyrOsFuncs);
+}
+
+#ifdef DDXOSFATALERROR
+void
+OsVendorFatalError(void)
+{
+}
+#endif
+
+#endif
+
+/* 'Fake' cursor stuff, could be improved */
+
+static Bool
+ephyrRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
+{
+ return TRUE;
+}
+
+static Bool
+ephyrUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
+{
+ return TRUE;
+}
+
+static void
+ephyrSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
+{
+ ;
+}
+
+static void
+ephyrMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
+{
+ ;
+}
+
+static Bool
+ephyrDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
+{
+ return TRUE;
+}
+
+miPointerSpriteFuncRec EphyrPointerSpriteFuncs = {
+ ephyrRealizeCursor,
+ ephyrUnrealizeCursor,
+ ephyrSetCursor,
+ ephyrMoveCursor,
+ ephyrDeviceCursorInitialize,
+ NULL
+};
+
+
+Bool
+ephyrCursorInit(ScreenPtr pScreen)
+{
+ miPointerInitialize(pScreen,
+ &EphyrPointerSpriteFuncs,
+ &ephyrPointerScreenFuncs,
+ FALSE);
+
+ return TRUE;
+}
+
+void
+ephyrCursorEnable(ScreenPtr pScreen)
+{
+ ;
+}
+
+KdCardFuncs ephyrFuncs = {
+ ephyrCardInit, /* cardinit */
+ ephyrScreenInit, /* scrinit */
+ ephyrInitScreen, /* initScreen */
+ ephyrFinishInitScreen, /* finishInitScreen */
+ ephyrCreateResources, /* createRes */
+ ephyrPreserve, /* preserve */
+ ephyrEnable, /* enable */
+ ephyrDPMS, /* dpms */
+ ephyrDisable, /* disable */
+ ephyrRestore, /* restore */
+ ephyrScreenFini, /* scrfini */
+ ephyrCardFini, /* cardfini */
+
+ 0, /* initCursor */
+ 0, /* enableCursor */
+ 0, /* disableCursor */
+ 0, /* finiCursor */
+ 0, /* recolorCursor */
+
+ 0, /* initAccel */
+ 0, /* enableAccel */
+ 0, /* disableAccel */
+ 0, /* finiAccel */
+
+ ephyrGetColors,/* getColors */
+ ephyrPutColors, /* putColors */
+};
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrlog.h b/xorg-server/hw/kdrive/ephyr/ephyrlog.h
index a07a0a097..ba52a3bce 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrlog.h
+++ b/xorg-server/hw/kdrive/ephyr/ephyrlog.h
@@ -43,14 +43,14 @@
#ifndef EPHYR_LOG
#define EPHYR_LOG(...) \
LogMessageVerb(X_NOTICE, INFO_LOG_LEVEL, "in %s:%d:%s: ",\
- __FILE__, __LINE__, __func__) ; \
+ __FILE__, __LINE__, __FUNCTION__) ; \
LogMessageVerb(X_NOTICE, INFO_LOG_LEVEL, __VA_ARGS__)
#endif /*nomadik_log*/
#ifndef EPHYR_LOG_ERROR
#define EPHYR_LOG_ERROR(...) \
LogMessageVerb(X_NOTICE, ERROR_LOG_LEVEL, "Error:in %s:%d:%s: ",\
- __FILE__, __LINE__, __func__) ; \
+ __FILE__, __LINE__, __FUNCTION__) ; \
LogMessageVerb(X_NOTICE, ERROR_LOG_LEVEL, __VA_ARGS__)
#endif /*EPHYR_LOG_ERROR*/
diff --git a/xorg-server/hw/kdrive/ephyr/hostx.c b/xorg-server/hw/kdrive/ephyr/hostx.c
index d546370ba..7a828eb31 100644
--- a/xorg-server/hw/kdrive/ephyr/hostx.c
+++ b/xorg-server/hw/kdrive/ephyr/hostx.c
@@ -47,9 +47,11 @@
#include <string.h> /* for memset */
#include <time.h>
+#ifndef _MSC_VER
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/time.h>
+#endif
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@@ -208,7 +210,11 @@ hostx_add_screen (EphyrScreenInfo screen,
void
hostx_set_display_name (char *name)
{
+#ifdef _MSC_VER
+ __asm int 3;
+#else
HostX.server_dpy_name = strdup (name);
+#endif
}
void
@@ -475,6 +481,9 @@ hostx_init (void)
}
/* Try to get share memory ximages for a little bit more speed */
+#ifdef _MSC_VER
+ __asm int 3;
+#else
if (!XShmQueryExtension(HostX.dpy) || getenv("XEPHYR_NO_SHM"))
{
fprintf(stderr, "\nXephyr unable to use SHM XImages\n");
@@ -505,6 +514,7 @@ hostx_init (void)
shmdt(shminfo.shmaddr);
shmctl(shminfo.shmid, IPC_RMID, 0);
}
+#endif
XFlush(HostX.dpy);
@@ -647,7 +657,7 @@ hostx_screen_init (EphyrScreenInfo screen,
struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
if (!host_screen)
{
- fprintf (stderr, "%s: Error in accessing hostx data\n", __func__ );
+ fprintf (stderr, "%s: Error in accessing hostx data\n", __FUNCTION__ );
exit(1);
}
@@ -662,10 +672,14 @@ hostx_screen_init (EphyrScreenInfo screen,
if (HostX.have_shm)
{
+#ifdef _MSC_VER
+ __asm int 3;
+#else
XShmDetach(HostX.dpy, &host_screen->shminfo);
XDestroyImage (host_screen->ximg);
shmdt(host_screen->shminfo.shmaddr);
shmctl(host_screen->shminfo.shmid, IPC_RMID, 0);
+#endif
}
else
{
@@ -681,6 +695,9 @@ hostx_screen_init (EphyrScreenInfo screen,
if (HostX.have_shm)
{
+#ifdef _MSC_VER
+__asm int 3;
+#else
host_screen->ximg = XShmCreateImage (HostX.dpy, HostX.visual, HostX.depth,
ZPixmap, NULL, &host_screen->shminfo,
width, buffer_height );
@@ -706,6 +723,7 @@ hostx_screen_init (EphyrScreenInfo screen,
XShmAttach(HostX.dpy, &host_screen->shminfo);
shm_success = True;
}
+#endif
}
if (!shm_success)
@@ -834,9 +852,13 @@ hostx_paint_rect (EphyrScreenInfo screen,
if (HostX.have_shm)
{
+#ifdef _MSC_VER
+ __asm int 3;
+#else
XShmPutImage (HostX.dpy, host_screen->win,
HostX.gc, host_screen->ximg,
sx, sy, dx, dy, width, height, False);
+#endif
}
else
{
@@ -852,6 +874,9 @@ hostx_paint_debug_rect (struct EphyrHostScreen *host_screen,
int x, int y,
int width, int height)
{
+#ifdef _MSC_VER
+ __asm int 3;
+#else
struct timespec tspec;
tspec.tv_sec = HostX.damage_debug_msec / (1000000);
@@ -867,6 +892,7 @@ hostx_paint_debug_rect (struct EphyrHostScreen *host_screen,
/* nanosleep seems to work better than usleep for me... */
nanosleep(&tspec, NULL);
+#endif
}
void
@@ -1288,8 +1314,12 @@ hostx_set_window_bounding_rectangles (int a_window,
rects[i].width, rects[i].height) ;
}
/*this aways returns 1*/
+#ifdef _MSC_VER
+ __asm int 3;
+#else
XShapeCombineRectangles (dpy, a_window, ShapeBounding, 0, 0,
rects, a_num_rects, ShapeSet, YXBanded) ;
+#endif
is_ok = TRUE ;
if (rects) {
@@ -1325,8 +1355,12 @@ hostx_set_window_clipping_rectangles (int a_window,
rects[i].width, rects[i].height) ;
}
/*this aways returns 1*/
+#ifdef _MSC_VER
+ __asm int 3;
+#else
XShapeCombineRectangles (dpy, a_window, ShapeClip, 0, 0,
rects, a_num_rects, ShapeSet, YXBanded) ;
+#endif
is_ok = TRUE ;
if (rects) {
@@ -1341,12 +1375,16 @@ int
hostx_has_xshape (void)
{
int event_base=0, error_base=0 ;
+#ifdef _MSC_VER
+ __asm int 3;
+#else
Display *dpy=hostx_get_display () ;
if (!XShapeQueryExtension (dpy,
&event_base,
&error_base)) {
return FALSE ;
}
+#endif
return TRUE;
}
diff --git a/xorg-server/hw/kdrive/ephyr/hostx.h b/xorg-server/hw/kdrive/ephyr/hostx.h
index e65e0c9bc..f455b3003 100644
--- a/xorg-server/hw/kdrive/ephyr/hostx.h
+++ b/xorg-server/hw/kdrive/ephyr/hostx.h
@@ -35,8 +35,12 @@
#define EPHYR_DBG(x, a...) \
fprintf(stderr, __FILE__ ":%d,%s() " x "\n", __LINE__, __func__, ##a)
#else
+#ifdef _MSC_VER
+#define EPHYR_DBG()
+#else
#define EPHYR_DBG(x, a...) do {} while (0)
#endif
+#endif
typedef struct EphyrHostXVars EphyrHostXVars;
typedef struct EphyrHostXEvent EphyrHostXEvent;
diff --git a/xorg-server/hw/kdrive/ephyr/makefile b/xorg-server/hw/kdrive/ephyr/makefile
new file mode 100644
index 000000000..eba9a93e1
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/makefile
@@ -0,0 +1,6 @@
+LIBRARY = libxephyr
+
+CSRCS=ephyrinit.c ephyr.c hostx.c
+
+INCLUDES += ..\src ..\..\..\exa
+
diff --git a/xorg-server/hw/kdrive/src/kdrive.c b/xorg-server/hw/kdrive/src/kdrive.c
index 5cfe54ff8..f79b96f6f 100644
--- a/xorg-server/hw/kdrive/src/kdrive.c
+++ b/xorg-server/hw/kdrive/src/kdrive.c
@@ -321,6 +321,7 @@ KdProcessSwitch (void)
KdEnableScreens ();
}
+#ifndef _MSC_VER
void
AbortDDX(void)
{
@@ -343,6 +344,7 @@ ddxGiveUp (void)
{
AbortDDX ();
}
+#endif
Bool kdDumbDriver;
Bool kdSoftCursor;
@@ -1310,11 +1312,14 @@ KdInitOutput (ScreenInfo *pScreenInfo,
OsRegisterSigWrapper(KdSignalWrapper);
}
+#ifndef _MSC_VER
void
OsVendorFatalError(void)
{
}
+#endif
+#ifndef _MSC_VER
int
DPMSSet(ClientPtr client, int level)
{
@@ -1326,3 +1331,4 @@ DPMSSupported (void)
{
return FALSE;
}
+#endif
diff --git a/xorg-server/hw/kdrive/src/kinput.c b/xorg-server/hw/kdrive/src/kinput.c
index 65fc75a54..5222e9509 100644
--- a/xorg-server/hw/kdrive/src/kinput.c
+++ b/xorg-server/hw/kdrive/src/kinput.c
@@ -1,2351 +1,2376 @@
-/*
- * Copyright © 1999 Keith Packard
- * Copyright © 2006 Nokia Corporation
- *
- * 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "kdrive.h"
-#include "inputstr.h"
-
-#define XK_PUBLISHING
-#include <X11/keysym.h>
-#if HAVE_X11_XF86KEYSYM_H
-#include <X11/XF86keysym.h>
-#endif
-#include <signal.h>
-#include <stdio.h>
-#ifdef sun
-#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 "exevents.h"
-#include "extinit.h"
-#include "exglobals.h"
-#include "eventstr.h"
-#include "xserver-properties.h"
-
-#define AtomFromName(x) MakeAtom(x, strlen(x), 1)
-
-struct KdConfigDevice {
- char *line;
- struct KdConfigDevice *next;
-};
-
-/* 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 KdKeyboardDriver *kdKeyboardDrivers = NULL;
-static KdPointerDriver *kdPointerDrivers = NULL;
-
-static EventListPtr kdEvents = NULL;
-
-static Bool kdInputEnabled;
-static Bool kdOffScreen;
-static unsigned long kdOffScreenTime;
-static KdPointerMatrix kdPointerMatrix = {
- { { 1, 0, 0 },
- { 0, 1, 0 } }
-};
-
-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;
-} KdInputFd;
-
-static KdInputFd kdInputFds[KD_MAX_INPUT_FDS];
-static int kdNumInputFds;
-
-extern Bool kdRawPointerCoordinates;
-
-static void
-KdSigio (int sig)
-{
- int i;
-
- for (i = 0; i < kdNumInputFds; i++)
- (*kdInputFds[i].read) (kdInputFds[i].fd, kdInputFds[i].closure);
-}
-
-static void
-KdBlockSigio (void)
-{
- sigset_t set;
-
- sigemptyset (&set);
- sigaddset (&set, SIGIO);
- sigprocmask (SIG_BLOCK, &set, 0);
-}
-
-static void
-KdUnblockSigio (void)
-{
- sigset_t set;
-
- sigemptyset (&set);
- sigaddset (&set, SIGIO);
- sigprocmask (SIG_UNBLOCK, &set, 0);
-}
-
-#ifdef DEBUG_SIGIO
-
-void
-KdAssertSigioBlocked (char *where)
-{
- sigset_t set, old;
-
- sigemptyset (&set);
- sigprocmask (SIG_BLOCK, &set, &old);
- if (!sigismember (&old, SIGIO)) {
- ErrorF ("SIGIO not blocked at %s\n", where);
- KdBacktrace(0);
- }
-}
-
-#else
-
-#define KdAssertSigioBlocked(s)
-
-#endif
-
-static int kdnFds;
-
-#ifdef FNONBLOCK
-#define NOBLOCK FNONBLOCK
-#else
-#define NOBLOCK FNDELAY
-#endif
-
-void
-KdResetInputMachine (void)
-{
- KdPointerInfo *pi;
-
- for (pi = kdPointers; pi; pi = pi->next) {
- pi->mouseState = start;
- pi->eventHeld = FALSE;
- }
-}
-
-static void
-KdNonBlockFd (int fd)
-{
- int flags;
- flags = fcntl (fd, F_GETFL);
- flags |= FASYNC|NOBLOCK;
- fcntl (fd, F_SETFL, flags);
-}
-
-static void
-KdAddFd (int fd)
-{
- struct sigaction act;
- sigset_t set;
-
- kdnFds++;
- 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);
-}
-
-static void
-KdRemoveFd (int fd)
-{
- 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);
- }
-}
-
-Bool
-KdRegisterFd (int fd, void (*read) (int fd, void *closure), void *closure)
-{
- if (kdNumInputFds == KD_MAX_INPUT_FDS)
- return FALSE;
- kdInputFds[kdNumInputFds].fd = fd;
- kdInputFds[kdNumInputFds].read = read;
- kdInputFds[kdNumInputFds].enable = 0;
- kdInputFds[kdNumInputFds].disable = 0;
- kdInputFds[kdNumInputFds].closure = closure;
- kdNumInputFds++;
- if (kdInputEnabled)
- KdAddFd (fd);
- return TRUE;
-}
-
-void
-KdUnregisterFd (void *closure, int fd, Bool do_close)
-{
- int i, j;
-
- for (i = 0; i < kdNumInputFds; i++) {
- 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];
- break;
- }
- }
-}
-
-void
-KdUnregisterFds (void *closure, Bool do_close)
-{
- KdUnregisterFd(closure, -1, do_close);
-}
-
-void
-KdDisableInput (void)
-{
- KdKeyboardInfo *ki;
- KdPointerInfo *pi;
- int found = 0, i = 0;
-
- KdBlockSigio();
-
- for (ki = kdKeyboards; ki; ki = ki->next) {
- if (ki->driver && ki->driver->Disable)
- (*ki->driver->Disable) (ki);
- }
-
- for (pi = kdPointers; pi; pi = pi->next) {
- if (pi->driver && pi->driver->Disable)
- (*pi->driver->Disable) (pi);
- }
-
- if (kdNumInputFds) {
- ErrorF("[KdDisableInput] Buggy drivers: still %d input fds left!",
- kdNumInputFds);
- i = 0;
- while (i < kdNumInputFds) {
- found = 0;
- for (ki = kdKeyboards; ki; ki = ki->next) {
- if (ki == kdInputFds[i].closure) {
- ErrorF(" fd %d belongs to keybd driver %s\n",
- kdInputFds[i].fd,
- ki->driver && ki->driver->name ?
- ki->driver->name : "(unnamed!)");
- found = 1;
- break;
- }
- }
-
- if (found) {
- i++;
- continue;
- }
-
- for (pi = kdPointers; pi; pi = pi->next) {
- if (pi == kdInputFds[i].closure) {
- ErrorF(" fd %d belongs to pointer driver %s\n",
- kdInputFds[i].fd,
- pi->driver && pi->driver->name ?
- pi->driver->name : "(unnamed!)");
- break;
- }
- }
-
- if (found) {
- i++;
- continue;
- }
-
- ErrorF(" fd %d not claimed by any active device!\n",
- kdInputFds[i].fd);
- KdUnregisterFd(kdInputFds[i].closure, kdInputFds[i].fd, TRUE);
- }
- }
-
- kdInputEnabled = FALSE;
-}
-
-void
-KdEnableInput (void)
-{
- InternalEvent ev;
- KdKeyboardInfo *ki;
- KdPointerInfo *pi;
-
- kdInputEnabled = TRUE;
-
- for (ki = kdKeyboards; ki; ki = ki->next) {
- if (ki->driver && ki->driver->Enable)
- (*ki->driver->Enable) (ki);
- }
-
- for (pi = kdPointers; pi; pi = pi->next) {
- if (pi->driver && pi->driver->Enable)
- (*pi->driver->Enable) (pi);
- }
-
- /* reset screen saver */
- ev.any.time = GetTimeInMillis ();
- NoticeEventTime (&ev);
-
- KdUnblockSigio ();
-}
-
-static KdKeyboardDriver *
-KdFindKeyboardDriver (char *name)
-{
- KdKeyboardDriver *ret;
-
- /* ask a stupid question ... */
- if (!name)
- return NULL;
-
- for (ret = kdKeyboardDrivers; ret; ret = ret->next) {
- if (strcmp(ret->name, name) == 0)
- return ret;
- }
-
- return NULL;
-}
-
-static KdPointerDriver *
-KdFindPointerDriver (char *name)
-{
- KdPointerDriver *ret;
-
- /* ask a stupid question ... */
- if (!name)
- return NULL;
-
- for (ret = kdPointerDrivers; ret; ret = ret->next) {
- if (strcmp(ret->name, name) == 0)
- return ret;
- }
-
- return NULL;
-}
-
-static int
-KdPointerProc(DeviceIntPtr pDevice, int onoff)
-{
- DevicePtr pDev = (DevicePtr)pDevice;
- KdPointerInfo *pi;
- Atom xiclass;
- Atom *btn_labels;
- Atom *axes_labels;
-
- if (!pDev)
- return BadImplementation;
-
- for (pi = kdPointers; pi; pi = pi->next) {
- if (pi->dixdev && pi->dixdev->id == pDevice->id)
- break;
- }
-
- if (!pi || !pi->dixdev || pi->dixdev->id != pDevice->id) {
- ErrorF("[KdPointerProc] Failed to find pointer for device %d!\n",
- pDevice->id);
- return BadImplementation;
- }
-
- switch (onoff)
- {
- case DEVICE_INIT:
-#ifdef DEBUG
- ErrorF("initialising pointer %s ...\n", pi->name);
-#endif
- if (!pi->driver) {
- if (!pi->driverPrivate) {
- ErrorF("no driver specified for %s\n", pi->name);
- return BadImplementation;
- }
-
- pi->driver = KdFindPointerDriver(pi->driverPrivate);
- if (!pi->driver) {
- ErrorF("Couldn't find pointer driver %s\n",
- pi->driverPrivate ? (char *) pi->driverPrivate :
- "(unnamed)");
- return !Success;
- }
- xfree(pi->driverPrivate);
- pi->driverPrivate = NULL;
- }
-
- if (!pi->driver->Init) {
- ErrorF("no init function\n");
- return BadImplementation;
- }
-
- if ((*pi->driver->Init) (pi) != Success) {
- return !Success;
- }
-
- btn_labels = xcalloc(pi->nButtons, sizeof(Atom));
- if (!btn_labels)
- return BadAlloc;
- axes_labels = xcalloc(pi->nAxes, sizeof(Atom));
- if (!axes_labels) {
- xfree(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);
-
- xfree(btn_labels);
- xfree(axes_labels);
-
- if (pi->inputClass == KD_TOUCHSCREEN) {
- InitAbsoluteClassDeviceStruct(pDevice);
- xiclass = AtomFromName(XI_TOUCHSCREEN);
- }
- else {
- xiclass = AtomFromName(XI_MOUSE);
- }
-
- AssignTypeAndName(pi->dixdev, xiclass,
- pi->name ? pi->name : "Generic KDrive Pointer");
-
- return Success;
-
- case DEVICE_ON:
- if (pDev->on == TRUE)
- return Success;
-
- if (!pi->driver->Enable) {
- ErrorF("no enable function\n");
- return BadImplementation;
- }
-
- if ((*pi->driver->Enable) (pi) == Success) {
- pDev->on = TRUE;
- return Success;
- }
- else {
- return BadImplementation;
- }
-
- return Success;
-
- case DEVICE_OFF:
- if (pDev->on == FALSE) {
- return Success;
- }
-
- if (!pi->driver->Disable) {
- return BadImplementation;
- }
- else {
- (*pi->driver->Disable) (pi);
- pDev->on = FALSE;
- return Success;
- }
-
- return Success;
-
- case DEVICE_CLOSE:
- if (pDev->on) {
- if (!pi->driver->Disable) {
- return BadImplementation;
- }
- (*pi->driver->Disable) (pi);
- pDev->on = FALSE;
- }
-
- if (!pi->driver->Fini)
- return BadImplementation;
-
- (*pi->driver->Fini) (pi);
-
- KdRemovePointer(pi);
-
- return Success;
- }
-
- /* NOTREACHED */
- return BadImplementation;
-}
-
-Bool
-LegalModifier(unsigned int key, DeviceIntPtr pDev)
-{
- return TRUE;
-}
-
-static void
-KdBell (int volume, DeviceIntPtr pDev, pointer arg, int something)
-{
- KeybdCtrl *ctrl = arg;
- KdKeyboardInfo *ki = NULL;
-
- for (ki = kdKeyboards; ki; ki = ki->next) {
- if (ki->dixdev && ki->dixdev->id == pDev->id)
- break;
- }
-
- if (!ki || !ki->dixdev || ki->dixdev->id != pDev->id || !ki->driver)
- return;
-
- KdRingBell(ki, volume, ctrl->bell_pitch, ctrl->bell_duration);
-}
-
-void
-DDXRingBell(int volume, int pitch, int duration)
-{
- KdKeyboardInfo *ki = NULL;
-
- if (kdOsFuncs->Bell) {
- (*kdOsFuncs->Bell)(volume, pitch, duration);
- }
- else {
- for (ki = kdKeyboards; ki; ki = ki->next) {
- if (ki->dixdev->coreEvents)
- KdRingBell(ki, volume, pitch, duration);
- }
- }
-}
-
-void
-KdRingBell(KdKeyboardInfo *ki, int volume, int pitch, int duration)
-{
- if (!ki || !ki->driver || !ki->driver->Bell)
- return;
-
- if (kdInputEnabled)
- (*ki->driver->Bell) (ki, volume, pitch, duration);
-}
-
-
-static void
-KdSetLeds (KdKeyboardInfo *ki, int leds)
-{
- if (!ki || !ki->driver)
- return;
-
- if (kdInputEnabled) {
- if (ki->driver->Leds)
- (*ki->driver->Leds) (ki, leds);
- }
-}
-
-void
-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);
-}
-
-void
-KdSetPointerMatrix (KdPointerMatrix *matrix)
-{
- kdPointerMatrix = *matrix;
-}
-
-void
-KdComputePointerMatrix (KdPointerMatrix *m, Rotation randr, int width,
- int height)
-{
- int x_dir = 1, y_dir = 1;
- int i, j;
- int size[2];
-
- size[0] = width; size[1] = height;
- if (randr & RR_Reflect_X)
- x_dir = -1;
- if (randr & RR_Reflect_Y)
- 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;
- 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;
- 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;
- 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;
- }
- 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)
-{
- 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;
-}
-
-static void
-KdKbdCtrl (DeviceIntPtr pDevice, KeybdCtrl *ctrl)
-{
- KdKeyboardInfo *ki;
-
- for (ki = kdKeyboards; ki; ki = ki->next) {
- if (ki->dixdev && ki->dixdev->id == pDevice->id)
- break;
- }
-
- if (!ki || !ki->dixdev || ki->dixdev->id != pDevice->id || !ki->driver)
- return;
-
- KdSetLeds(ki, ctrl->leds);
- ki->bellPitch = ctrl->bell_pitch;
- ki->bellDuration = ctrl->bell_duration;
-}
-
-extern KeybdCtrl defaultKeyboardControl;
-
-static int
-KdKeyboardProc(DeviceIntPtr pDevice, int onoff)
-{
- Bool ret;
- DevicePtr pDev = (DevicePtr)pDevice;
- KdKeyboardInfo *ki;
- Atom xiclass;
- XkbRMLVOSet rmlvo;
-
- if (!pDev)
- return BadImplementation;
-
- for (ki = kdKeyboards; ki; ki = ki->next) {
- if (ki->dixdev && ki->dixdev->id == pDevice->id)
- break;
- }
-
- if (!ki || !ki->dixdev || ki->dixdev->id != pDevice->id) {
- return BadImplementation;
- }
-
- switch (onoff)
- {
- case DEVICE_INIT:
-#ifdef DEBUG
- ErrorF("initialising keyboard %s\n", ki->name);
-#endif
- if (!ki->driver) {
- if (!ki->driverPrivate) {
- ErrorF("no driver specified!\n");
- return BadImplementation;
- }
-
- ki->driver = KdFindKeyboardDriver(ki->driverPrivate);
- if (!ki->driver) {
- ErrorF("Couldn't find keyboard driver %s\n",
- ki->driverPrivate ? (char *) ki->driverPrivate :
- "(unnamed)");
- return !Success;
- }
- xfree(ki->driverPrivate);
- ki->driverPrivate = NULL;
- }
-
- if (!ki->driver->Init) {
- ErrorF("Keyboard %s: no init function\n", ki->name);
- return BadImplementation;
- }
-
- if ((*ki->driver->Init) (ki) != Success) {
- return !Success;
- }
-
- memset(&rmlvo, 0, sizeof(rmlvo));
- rmlvo.rules = ki->xkbRules;
- rmlvo.model = ki->xkbModel;
- rmlvo.layout = ki->xkbLayout;
- rmlvo.variant = ki->xkbVariant;
- rmlvo.options = ki->xkbOptions;
- ret = InitKeyboardDeviceStruct (pDevice, &rmlvo, KdBell, KdKbdCtrl);
- if (!ret) {
- ErrorF("Couldn't initialise keyboard %s\n", ki->name);
- return BadImplementation;
- }
-
- xiclass = AtomFromName(XI_KEYBOARD);
- AssignTypeAndName(pDevice, xiclass,
- ki->name ? ki->name : "Generic KDrive Keyboard");
-
- KdResetInputMachine();
-
- return Success;
-
- case DEVICE_ON:
- if (pDev->on == TRUE)
- return Success;
-
- if (!ki->driver->Enable)
- return BadImplementation;
-
- if ((*ki->driver->Enable) (ki) != Success) {
- return BadMatch;
- }
-
- pDev->on = TRUE;
- return Success;
-
- case DEVICE_OFF:
- if (pDev->on == FALSE)
- return Success;
-
- if (!ki->driver->Disable)
- return BadImplementation;
-
- (*ki->driver->Disable) (ki);
- pDev->on = FALSE;
-
- return Success;
-
- break;
-
- case DEVICE_CLOSE:
- if (pDev->on) {
- if (!ki->driver->Disable)
- return BadImplementation;
-
- (*ki->driver->Disable) (ki);
- pDev->on = FALSE;
- }
-
- if (!ki->driver->Fini)
- return BadImplementation;
-
- (*ki->driver->Fini) (ki);
-
- KdRemoveKeyboard(ki);
-
- return Success;
- }
-
- /* NOTREACHED */
- return BadImplementation;
-}
-
-void
-KdAddPointerDriver (KdPointerDriver *driver)
-{
- KdPointerDriver **prev;
-
- if (!driver)
- return;
-
- for (prev = &kdPointerDrivers; *prev; prev = &(*prev)->next) {
- if (*prev == driver)
- return;
- }
- *prev = driver;
-}
-
-void
-KdRemovePointerDriver (KdPointerDriver *driver)
-{
- KdPointerDriver *tmp;
-
- if (!driver)
- return;
-
- /* FIXME remove all pointers using this driver */
- for (tmp = kdPointerDrivers; tmp; tmp = tmp->next) {
- if (tmp->next == driver)
- tmp->next = driver->next;
- }
- if (tmp == driver)
- tmp = NULL;
-}
-
-void
-KdAddKeyboardDriver (KdKeyboardDriver *driver)
-{
- KdKeyboardDriver **prev;
-
- if (!driver)
- return;
-
- for (prev = &kdKeyboardDrivers; *prev; prev = &(*prev)->next) {
- if (*prev == driver)
- return;
- }
- *prev = driver;
-}
-
-void
-KdRemoveKeyboardDriver (KdKeyboardDriver *driver)
-{
- KdKeyboardDriver *tmp;
-
- if (!driver)
- return;
-
- /* FIXME remove all keyboards using this driver */
- for (tmp = kdKeyboardDrivers; tmp; tmp = tmp->next) {
- if (tmp->next == driver)
- tmp->next = driver->next;
- }
- if (tmp == driver)
- tmp = NULL;
-}
-
-KdKeyboardInfo *
-KdNewKeyboard (void)
-{
- KdKeyboardInfo *ki = xcalloc(sizeof(KdKeyboardInfo), 1);
- if (!ki)
- return NULL;
-
- ki->minScanCode = 0;
- ki->maxScanCode = 0;
- ki->leds = 0;
- ki->bellPitch = 1000;
- ki->bellDuration = 200;
- ki->next = NULL;
- ki->options = NULL;
- ki->xkbRules = strdup(XKB_DFLT_RULES);
- ki->xkbModel = strdup(XKB_DFLT_MODEL);
- ki->xkbLayout = strdup(XKB_DFLT_LAYOUT);
- ki->xkbVariant = strdup(XKB_DFLT_VARIANT);
- ki->xkbOptions = strdup(XKB_DFLT_OPTIONS);
-
- return ki;
-}
-
-int
-KdAddConfigKeyboard (char *keyboard)
-{
- struct KdConfigDevice **prev, *new;
-
- if (!keyboard)
- return Success;
-
- new = (struct KdConfigDevice *) xcalloc(sizeof(struct KdConfigDevice), 1);
- if (!new)
- return BadAlloc;
-
- new->line = xstrdup(keyboard);
- new->next = NULL;
-
- for (prev = &kdConfigKeyboards; *prev; prev = &(*prev)->next);
- *prev = new;
-
- return Success;
-}
-
-int
-KdAddKeyboard (KdKeyboardInfo *ki)
-{
- KdKeyboardInfo **prev;
-
- if (!ki)
- return !Success;
-
- ki->dixdev = AddInputDevice(serverClient, KdKeyboardProc, TRUE);
- if (!ki->dixdev) {
- ErrorF("Couldn't register keyboard device %s\n",
- ki->name ? ki->name : "(unnamed)");
- return !Success;
- }
-
- ki->dixdev->deviceGrab.ActivateGrab = ActivateKeyboardGrab;
- ki->dixdev->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab;
- RegisterOtherDevice(ki->dixdev);
-
-#ifdef DEBUG
- ErrorF("added keyboard %s with dix id %d\n", ki->name, ki->dixdev->id);
-#endif
-
- for (prev = &kdKeyboards; *prev; prev = &(*prev)->next);
- *prev = ki;
-
- return Success;
-}
-
-void
-KdRemoveKeyboard (KdKeyboardInfo *ki)
-{
- KdKeyboardInfo **prev;
-
- if (!ki)
- return;
-
- for (prev = &kdKeyboards; *prev; prev = &(*prev)->next) {
- if (*prev == ki) {
- *prev = ki->next;
- break;
- }
- }
-
- KdFreeKeyboard(ki);
-}
-
-int
-KdAddConfigPointer (char *pointer)
-{
- struct KdConfigDevice **prev, *new;
-
- if (!pointer)
- return Success;
-
- new = (struct KdConfigDevice *) xcalloc(sizeof(struct KdConfigDevice), 1);
- if (!new)
- return BadAlloc;
-
- new->line = xstrdup(pointer);
- new->next = NULL;
-
- for (prev = &kdConfigPointers; *prev; prev = &(*prev)->next);
- *prev = new;
-
- return Success;
-}
-
-int
-KdAddPointer (KdPointerInfo *pi)
-{
- KdPointerInfo **prev;
-
- if (!pi)
- return Success;
-
- pi->mouseState = start;
- pi->eventHeld = FALSE;
-
- pi->dixdev = AddInputDevice(serverClient, KdPointerProc, TRUE);
- if (!pi->dixdev) {
- ErrorF("Couldn't add pointer device %s\n",
- pi->name ? pi->name : "(unnamed)");
- return BadDevice;
- }
-
- pi->dixdev->deviceGrab.ActivateGrab = ActivatePointerGrab;
- pi->dixdev->deviceGrab.DeactivateGrab = DeactivatePointerGrab;
- RegisterOtherDevice(pi->dixdev);
-
- for (prev = &kdPointers; *prev; prev = &(*prev)->next);
- *prev = pi;
-
- return Success;
-}
-
-void
-KdRemovePointer (KdPointerInfo *pi)
-{
- KdPointerInfo **prev;
-
- if (!pi)
- return;
-
- for (prev = &kdPointers; *prev; prev = &(*prev)->next) {
- if (*prev == pi) {
- *prev = pi->next;
- break;
- }
- }
-
- KdFreePointer(pi);
-}
-
-/*
- * You can call your kdriver server with something like:
- * $ ./hw/kdrive/yourserver/X :1 -mouse evdev,,device=/dev/input/event4 -keybd
- * evdev,,device=/dev/input/event1,xkbmodel=abnt2,xkblayout=br
- */
-static Bool
-KdGetOptions (InputOption **options, char *string)
-{
- InputOption *newopt = NULL, **tmpo = NULL;
- int tam_key = 0;
-
- newopt = xcalloc(1, sizeof (InputOption));
- if (!newopt)
- return FALSE;
-
- for (tmpo = options; *tmpo; tmpo = &(*tmpo)->next)
- ; /* Hello, I'm here */
- *tmpo = newopt;
-
- if (strchr(string, '='))
- {
- tam_key = (strchr(string, '=') - string);
- newopt->key = (char *)xalloc(tam_key);
- strncpy(newopt->key, string, tam_key);
- newopt->key[tam_key] = '\0';
- newopt->value = xstrdup(strchr(string, '=') + 1);
- }
- else
- {
- newopt->key = xstrdup(string);
- newopt->value = NULL;
- }
- newopt->next = NULL;
-
- return TRUE;
-}
-
-static void
-KdParseKbdOptions (KdKeyboardInfo *ki)
-{
- InputOption *option = NULL;
-
- for (option = ki->options; option; option = option->next)
- {
- if (strcasecmp(option->key, "XkbRules") == 0)
- ki->xkbRules = option->value;
- else if (strcasecmp(option->key, "XkbModel") == 0)
- ki->xkbModel = option->value;
- else if (strcasecmp(option->key, "XkbLayout") == 0)
- ki->xkbLayout = option->value;
- else if (strcasecmp(option->key, "XkbVariant") == 0)
- ki->xkbVariant = option->value;
- else if (strcasecmp(option->key, "XkbOptions") == 0)
- ki->xkbOptions = option->value;
- else if (!strcasecmp (option->key, "device"))
- ki->path = strdup(option->value);
- else
- ErrorF("Kbd option key (%s) of value (%s) not assigned!\n",
- option->key, option->value);
- }
-}
-
-KdKeyboardInfo *
-KdParseKeyboard (char *arg)
-{
- char save[1024];
- char delim;
- InputOption *options = NULL;
- KdKeyboardInfo *ki = NULL;
-
- ki = KdNewKeyboard();
- if (!ki)
- return NULL;
-
- ki->name = strdup("Unknown KDrive Keyboard");
- ki->path = NULL;
- ki->driver = NULL;
- ki->driverPrivate = NULL;
- ki->next = NULL;
-
- if (!arg)
- {
- ErrorF("keybd: no arg\n");
- KdFreeKeyboard (ki);
- return NULL;
- }
-
- if (strlen (arg) >= sizeof (save))
- {
- ErrorF("keybd: arg too long\n");
- KdFreeKeyboard (ki);
- return NULL;
- }
-
- arg = KdParseFindNext (arg, ",", save, &delim);
- if (!save[0])
- {
- ErrorF("keybd: failed on save[0]\n");
- KdFreeKeyboard (ki);
- return NULL;
- }
-
- if (strcmp (save, "auto") == 0)
- ki->driverPrivate = NULL;
- else
- ki->driverPrivate = xstrdup(save);
-
- if (delim != ',')
- {
- return ki;
- }
-
- arg = KdParseFindNext (arg, ",", save, &delim);
-
- while (delim == ',')
- {
- arg = KdParseFindNext (arg, ",", save, &delim);
-
- if (!KdGetOptions(&options, save))
- {
- KdFreeKeyboard(ki);
- return NULL;
- }
- }
-
- if (options)
- {
- ki->options = options;
- KdParseKbdOptions(ki);
- }
-
- return ki;
-}
-
-static void
-KdParsePointerOptions (KdPointerInfo *pi)
-{
- InputOption *option = NULL;
-
- for (option = pi->options; option; option = option->next)
- {
- if (!strcmp (option->key, "emulatemiddle"))
- pi->emulateMiddleButton = TRUE;
- else if (!strcmp (option->key, "noemulatemiddle"))
- pi->emulateMiddleButton = FALSE;
- else if (!strcmp (option->key, "transformcoord"))
- pi->transformCoordinates = TRUE;
- else if (!strcmp (option->key, "rawcoord"))
- pi->transformCoordinates = FALSE;
- else if (!strcasecmp (option->key, "device"))
- pi->path = strdup(option->value);
- else if (!strcasecmp (option->key, "protocol"))
- pi->protocol = strdup(option->value);
- else
- ErrorF("Pointer option key (%s) of value (%s) not assigned!\n",
- option->key, option->value);
- }
-}
-
-KdPointerInfo *
-KdParsePointer (char *arg)
-{
- char save[1024];
- char delim;
- KdPointerInfo *pi = NULL;
- InputOption *options = NULL;
- int i = 0;
-
- pi = KdNewPointer();
- if (!pi)
- return NULL;
- pi->emulateMiddleButton = kdEmulateMiddleButton;
- pi->transformCoordinates = !kdRawPointerCoordinates;
- pi->protocol = NULL;
- pi->nButtons = 5; /* XXX should not be hardcoded */
- pi->inputClass = KD_MOUSE;
-
- if (!arg)
- {
- ErrorF("mouse: no arg\n");
- KdFreePointer (pi);
- return NULL;
- }
-
- if (strlen (arg) >= sizeof (save))
- {
- ErrorF("mouse: arg too long\n");
- KdFreePointer (pi);
- return NULL;
- }
- arg = KdParseFindNext (arg, ",", save, &delim);
- if (!save[0])
- {
- ErrorF("failed on save[0]\n");
- KdFreePointer (pi);
- return NULL;
- }
-
- if (strcmp(save, "auto") == 0)
- pi->driverPrivate = NULL;
- else
- pi->driverPrivate = xstrdup(save);
-
- if (delim != ',')
- {
- return pi;
- }
-
- arg = KdParseFindNext (arg, ",", save, &delim);
-
- while (delim == ',')
- {
- arg = KdParseFindNext (arg, ",", save, &delim);
- if (save[0] == '{')
- {
- char *s = save + 1;
- i = 0;
- while (*s && *s != '}')
- {
- if ('1' <= *s && *s <= '0' + pi->nButtons)
- pi->map[i] = *s - '0';
- else
- UseMsg ();
- s++;
- }
- }
- else
- {
- if (!KdGetOptions(&options, save))
- {
- KdFreePointer(pi);
- return NULL;
- }
- }
- }
-
- if (options)
- {
- pi->options = options;
- KdParsePointerOptions(pi);
- }
-
- return pi;
-}
-
-
-void
-KdInitInput (void)
-{
- KdPointerInfo *pi;
- KdKeyboardInfo *ki;
- struct KdConfigDevice *dev;
-
- kdInputEnabled = TRUE;
-
- for (dev = kdConfigPointers; dev; dev = dev->next) {
- pi = KdParsePointer(dev->line);
- if (!pi)
- ErrorF("Failed to parse pointer\n");
- if (KdAddPointer(pi) != Success)
- ErrorF("Failed to add pointer!\n");
- }
- for (dev = kdConfigKeyboards; dev; dev = dev->next) {
- ki = KdParseKeyboard(dev->line);
- if (!ki)
- ErrorF("Failed to parse keyboard\n");
- if (KdAddKeyboard(ki) != Success)
- ErrorF("Failed to add keyboard!\n");
- }
-
- mieqInit();
-}
-
-/*
- * Middle button emulation state machine
- *
- * Possible transitions:
- * Button 1 press v1
- * Button 1 release ^1
- * Button 2 press v2
- * Button 2 release ^2
- * Button 3 press v3
- * Button 3 release ^3
- * Button other press vo
- * Button other release ^o
- * Mouse motion <>
- * Keyboard event k
- * timeout ...
- * outside box <->
- *
- * States:
- * start
- * button_1_pend
- * button_1_down
- * button_2_down
- * button_3_pend
- * button_3_down
- * synthetic_2_down_13
- * synthetic_2_down_3
- * synthetic_2_down_1
- *
- * Transition diagram
- *
- * start
- * v1 -> (hold) (settimeout) button_1_pend
- * ^1 -> (deliver) start
- * v2 -> (deliver) button_2_down
- * ^2 -> (deliever) start
- * v3 -> (hold) (settimeout) button_3_pend
- * ^3 -> (deliver) start
- * vo -> (deliver) start
- * ^o -> (deliver) start
- * <> -> (deliver) start
- * k -> (deliver) start
- *
- * button_1_pend (button 1 is down, timeout pending)
- * ^1 -> (release) (deliver) start
- * v2 -> (release) (deliver) button_1_down
- * ^2 -> (release) (deliver) button_1_down
- * v3 -> (cleartimeout) (generate v2) synthetic_2_down_13
- * ^3 -> (release) (deliver) button_1_down
- * vo -> (release) (deliver) button_1_down
- * ^o -> (release) (deliver) button_1_down
- * <-> -> (release) (deliver) button_1_down
- * <> -> (deliver) button_1_pend
- * k -> (release) (deliver) button_1_down
- * ... -> (release) button_1_down
- *
- * button_1_down (button 1 is down)
- * ^1 -> (deliver) start
- * v2 -> (deliver) button_1_down
- * ^2 -> (deliver) button_1_down
- * v3 -> (deliver) button_1_down
- * ^3 -> (deliver) button_1_down
- * vo -> (deliver) button_1_down
- * ^o -> (deliver) button_1_down
- * <> -> (deliver) button_1_down
- * k -> (deliver) button_1_down
- *
- * button_2_down (button 2 is down)
- * v1 -> (deliver) button_2_down
- * ^1 -> (deliver) button_2_down
- * ^2 -> (deliver) start
- * v3 -> (deliver) button_2_down
- * ^3 -> (deliver) button_2_down
- * vo -> (deliver) button_2_down
- * ^o -> (deliver) button_2_down
- * <> -> (deliver) button_2_down
- * k -> (deliver) button_2_down
- *
- * button_3_pend (button 3 is down, timeout pending)
- * v1 -> (generate v2) synthetic_2_down
- * ^1 -> (release) (deliver) button_3_down
- * v2 -> (release) (deliver) button_3_down
- * ^2 -> (release) (deliver) button_3_down
- * ^3 -> (release) (deliver) start
- * vo -> (release) (deliver) button_3_down
- * ^o -> (release) (deliver) button_3_down
- * <-> -> (release) (deliver) button_3_down
- * <> -> (deliver) button_3_pend
- * k -> (release) (deliver) button_3_down
- * ... -> (release) button_3_down
- *
- * button_3_down (button 3 is down)
- * v1 -> (deliver) button_3_down
- * ^1 -> (deliver) button_3_down
- * v2 -> (deliver) button_3_down
- * ^2 -> (deliver) button_3_down
- * ^3 -> (deliver) start
- * vo -> (deliver) button_3_down
- * ^o -> (deliver) button_3_down
- * <> -> (deliver) button_3_down
- * k -> (deliver) button_3_down
- *
- * synthetic_2_down_13 (button 1 and 3 are down)
- * ^1 -> (generate ^2) synthetic_2_down_3
- * v2 -> synthetic_2_down_13
- * ^2 -> synthetic_2_down_13
- * ^3 -> (generate ^2) synthetic_2_down_1
- * vo -> (deliver) synthetic_2_down_13
- * ^o -> (deliver) synthetic_2_down_13
- * <> -> (deliver) synthetic_2_down_13
- * k -> (deliver) synthetic_2_down_13
- *
- * synthetic_2_down_3 (button 3 is down)
- * v1 -> (deliver) synthetic_2_down_3
- * ^1 -> (deliver) synthetic_2_down_3
- * v2 -> synthetic_2_down_3
- * ^2 -> synthetic_2_down_3
- * ^3 -> start
- * vo -> (deliver) synthetic_2_down_3
- * ^o -> (deliver) synthetic_2_down_3
- * <> -> (deliver) synthetic_2_down_3
- * k -> (deliver) synthetic_2_down_3
- *
- * synthetic_2_down_1 (button 1 is down)
- * ^1 -> start
- * v2 -> synthetic_2_down_1
- * ^2 -> synthetic_2_down_1
- * v3 -> (deliver) synthetic_2_down_1
- * ^3 -> (deliver) synthetic_2_down_1
- * vo -> (deliver) synthetic_2_down_1
- * ^o -> (deliver) synthetic_2_down_1
- * <> -> (deliver) synthetic_2_down_1
- * k -> (deliver) synthetic_2_down_1
- */
-
-typedef enum _inputClass {
- down_1, up_1,
- down_2, up_2,
- down_3, up_3,
- down_o, up_o,
- motion, outside_box,
- keyboard, timeout,
- num_input_class
-} KdInputClass;
-
-typedef enum _inputAction {
- noop,
- hold,
- setto,
- deliver,
- release,
- clearto,
- gen_down_2,
- gen_up_2
-} KdInputAction;
-
-#define MAX_ACTIONS 2
-
-typedef struct _inputTransition {
- KdInputAction actions[MAX_ACTIONS];
- KdPointerState nextState;
-} KdInputTransition;
-
-static const
-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 }, /* ... */
- },
- /* 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 }, /* ... */
- },
- /* 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 }, /* ... */
- },
- /* 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 }, /* ... */
- },
- /* 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 }, /* ... */
- },
- /* 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 }, /* ... */
- },
- /* 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 }, /* ... */
- },
-};
-
-#define EMULATION_WINDOW 10
-#define EMULATION_TIMEOUT 100
-
-static int
-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);
-}
-
-static KdInputClass
-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;
- case ButtonRelease:
- 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;
- default:
- return keyboard;
- }
- return keyboard;
-}
-
-#ifdef DEBUG
-char *kdStateNames[] = {
- "start",
- "button_1_pend",
- "button_1_down",
- "button_2_down",
- "button_3_pend",
- "button_3_down",
- "synth_2_down_13",
- "synth_2_down_3",
- "synthetic_2_down_1",
- "num_input_states"
-};
-
-char *kdClassNames[] = {
- "down_1", "up_1",
- "down_2", "up_2",
- "down_3", "up_3",
- "motion", "ouside_box",
- "keyboard", "timeout",
- "num_input_class"
-};
-
-char *kdActionNames[] = {
- "noop",
- "hold",
- "setto",
- "deliver",
- "release",
- "clearto",
- "gen_down_2",
- "gen_up_2",
-};
-#endif /* DEBUG */
-
-static void
-KdQueueEvent (DeviceIntPtr pDev, InternalEvent *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)
-{
- const KdInputTransition *t;
- 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;
- 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);
- 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;
- return TRUE;
- break;
- case gen_up_2:
- _KdEnqueuePointerEvent (pi, ButtonRelease, x, y, z, 2, absrel,
- TRUE);
- return TRUE;
- break;
- }
- }
- pi->mouseState = t->nextState;
- return FALSE;
-}
-
-static int
-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 FALSE;
-}
-
-static void
-KdReceiveTimeout (KdPointerInfo *pi)
-{
- KdRunMouseMachine (pi, timeout, 0, 0, 0, 0, 0, 0);
-}
-
-/*
- * kdCheckTermination
- *
- * This function checks for the key sequence that terminates the server. When
- * detected, it sets the dispatchException flag and returns. The key sequence
- * is:
- * Control-Alt
- * It's assumed that the server will be waken up by the caller when this
- * function returns.
- */
-
-extern int nClients;
-
-void
-KdReleaseAllKeys (void)
-{
-#if 0
- int key, nEvents, i;
- KdKeyboardInfo *ki;
-
- KdBlockSigio ();
-
- for (ki = kdKeyboards; ki; ki = ki->next) {
- 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);
- GetEventList(&kdEvents);
- nEvents = GetKeyboardEvents(kdEvents, ki->dixdev, KeyRelease, key);
- for (i = 0; i < nEvents; i++)
- KdQueueEvent (ki->dixdev, (kdEvents + i)->event);
- }
- }
- }
-
- KdUnblockSigio ();
-#endif
-}
-
-static void
-KdCheckLock (void)
-{
- 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;
- /* FIXME: Just use XKB indicators! */
- shouldBeSet = !!(XkbStateFieldFromRec(&keyc->xkbInfo->state) & LockMask);
- if (isSet != shouldBeSet)
- KdSetLed (tmp, tmp->LockLed, shouldBeSet);
- }
- }
-}
-
-void
-KdEnqueueKeyboardEvent(KdKeyboardInfo *ki,
- unsigned char scan_code,
- unsigned char is_up)
-{
- unsigned char key_code;
- KeyClassPtr keyc = NULL;
- KeybdCtrl *ctrl = NULL;
- int type, nEvents, i;
-
- if (!ki || !ki->dixdev || !ki->dixdev->kbdfeed || !ki->dixdev->key)
- 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;
-
- /*
- * Set up this event -- the type may be modified below
- */
- if (is_up)
- type = KeyRelease;
- else
- type = KeyPress;
-
- GetEventList(&kdEvents);
-
- nEvents = GetKeyboardEvents(kdEvents, ki->dixdev, type, key_code);
- for (i = 0; i < nEvents; i++)
- KdQueueEvent(ki->dixdev, (InternalEvent *)((kdEvents + i)->event));
- }
- else {
- ErrorF("driver %s wanted to post scancode %d outside of [%d, %d]!\n",
- ki->name, scan_code, ki->minScanCode, ki->maxScanCode);
- }
-}
-
-/*
- * kdEnqueuePointerEvent
- *
- * This function converts hardware mouse event information into X event
- * information. A mouse movement event is passed off to MI to generate
- * a MotionNotify event, if appropriate. Button events are created and
- * passed off to MI for enqueueing.
- */
-
-/* FIXME do something a little more clever to deal with multiple axes here */
-void
-KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry,
- int rz)
-{
- CARD32 ms;
- unsigned char buttons;
- int x, y, z;
- int (*matrix)[3] = kdPointerMatrix.matrix;
- unsigned long button;
- int n;
- int dixflags = 0;
-
- if (!pi)
- 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;
- }
- }
- 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;
- }
- }
- z = rz;
-
- if (flags & KD_MOUSE_DELTA)
- {
- if (x || y || z)
- {
- dixflags = POINTER_RELATIVE | POINTER_ACCELERATE;
- _KdEnqueuePointerEvent(pi, MotionNotify, x, y, z, 0, dixflags, FALSE);
- }
- } 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);
- }
-
- buttons = flags;
-
- for (button = KD_BUTTON_1, n = 1; n <= pi->nButtons;
- button <<= 1, n++) {
- if (((pi->buttonState & 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)) {
- _KdEnqueuePointerEvent(pi, ButtonPress, x, y, z, n,
- dixflags, FALSE);
- }
- }
-
- pi->buttonState = buttons;
-}
-
-void
-_KdEnqueuePointerEvent (KdPointerInfo *pi, int type, int x, int y, int z,
- int b, int absrel, Bool force)
-{
- int nEvents = 0, i = 0;
- int valuators[3] = { x, y, z };
-
- /* TRUE from KdHandlePointerEvent, means 'we swallowed the event'. */
- if (!force && KdHandlePointerEvent(pi, type, x, y, z, b, absrel))
- return;
-
- GetEventList(&kdEvents);
- nEvents = GetPointerEvents(kdEvents, pi->dixdev, type, b, absrel,
- 0, 3, valuators);
- for (i = 0; i < nEvents; i++)
- KdQueueEvent(pi->dixdev, (InternalEvent *)((kdEvents + i)->event));
-}
-
-void
-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;
-
- 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(myTimeout>0)
- AdjustWaitForDelay (timeout, myTimeout);
-}
-
-void
-KdWakeupHandler (int screen,
- pointer data,
- unsigned long lresult,
- pointer readmask)
-{
- 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 (kdSwitchPending)
- KdProcessSwitch ();
-}
-
-#define KdScreenOrigin(pScreen) (&(KdGetScreenPriv(pScreen)->screen->origin))
-
-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;
-
- if (kdDisableZaphod || screenInfo.numScreens <= 1)
- return FALSE;
-
- if (0 <= *x && *x < pScreen->width && 0 <= *y && *y < pScreen->height)
- return FALSE;
-
- ms = GetTimeInMillis ();
- if (kdOffScreen && (int) (ms - kdOffScreenTime) < 1000)
- 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;
- }
- }
- }
- if (best_y < best_x)
- n_best_x = n_best_y;
- if (n_best_x == -1)
- return FALSE;
- pNewScreen = screenInfo.screens[n_best_x];
-
- if (*x < 0)
- *x += pNewScreen->width;
- if (*y < 0)
- *y += pNewScreen->height;
-
- if (*x >= pScreen->width)
- *x -= pScreen->width;
- if (*y >= pScreen->height)
- *y -= pScreen->height;
-
- *ppScreen = pNewScreen;
- return TRUE;
-}
-
-static void
-KdCrossScreen(ScreenPtr pScreen, Bool entering)
-{
-#ifndef XIPAQ
- if (entering)
- KdEnableScreen (pScreen);
- else
- KdDisableScreen (pScreen);
-#endif
-}
-
-int KdCurScreen; /* current event screen */
-
-static void
-KdWarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
-{
- KdBlockSigio ();
- KdCurScreen = pScreen->myNum;
- miPointerWarpCursor(pDev, pScreen, x, y);
- KdUnblockSigio ();
-}
-
-miPointerScreenFuncRec kdPointerScreenFuncs =
-{
- KdCursorOffScreen,
- KdCrossScreen,
- KdWarpCursor
-};
-
-void
-ProcessInputEvents (void)
-{
- mieqProcessInputEvents();
- miPointerUpdateSprite(inputInfo.pointer);
- if (kdSwitchPending)
- KdProcessSwitch ();
- KdCheckLock ();
-}
-
-/* FIXME use XSECURITY to work out whether the client should be allowed to
- * open and close. */
-void
-OpenInputDevice(DeviceIntPtr pDev, ClientPtr client, int *status)
-{
- if (!pDev)
- *status = BadDevice;
- else
- *status = Success;
-}
-
-void
-CloseInputDevice(DeviceIntPtr pDev, ClientPtr client)
-{
- return;
-}
-
-/* We initialise all input devices at startup. */
-void
-AddOtherInputDevices(void)
-{
- return;
-}
-
-/* At the moment, absolute/relative is up to the client. */
-int
-SetDeviceMode(register ClientPtr client, DeviceIntPtr pDev, int mode)
-{
- return BadMatch;
-}
-
-int
-SetDeviceValuators(register ClientPtr client, DeviceIntPtr pDev,
- int *valuators, int first_valuator, int num_valuators)
-{
- return BadMatch;
-}
-
-int
-ChangeDeviceControl(register ClientPtr client, DeviceIntPtr pDev,
- xDeviceCtl *control)
-{
- switch (control->control) {
- case DEVICE_RESOLUTION:
- /* FIXME do something more intelligent here */
- return BadMatch;
-
- case DEVICE_ABS_CALIB:
- case DEVICE_ABS_AREA:
- return Success;
-
- case DEVICE_CORE:
- return BadMatch;
- case DEVICE_ENABLE:
- return Success;
-
- default:
- return BadMatch;
- }
-
- /* NOTREACHED */
- return BadImplementation;
-}
-
-int
-NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
-{
- InputOption *option = NULL;
- KdPointerInfo *pi = NULL;
- KdKeyboardInfo *ki = NULL;
-
- for (option = options; option; option = option->next) {
- if (strcmp(option->key, "type") == 0) {
- if (strcmp(option->value, "pointer") == 0) {
- pi = KdNewPointer();
- if (!pi)
- return BadAlloc;
- }
- else if (strcmp(option->value, "keyboard") == 0) {
- ki = KdNewKeyboard();
- if (!ki)
- return BadAlloc;
- }
- else {
- ErrorF("unrecognised device type!\n");
- return BadValue;
- }
- }
-#ifdef CONFIG_HAL
- else if (strcmp(option->key, "_source") == 0 &&
- strcmp(option->value, "server/hal") == 0)
- {
- ErrorF("Ignoring device from HAL.\n");
- return BadValue;
- }
-#endif
- }
-
- if (!ki && !pi) {
- ErrorF("unrecognised device identifier!\n");
- return BadValue;
- }
-
- /* FIXME: change this code below to use KdParseKbdOptions and
- * KdParsePointerOptions */
- for (option = options; option; option = option->next) {
- if (strcmp(option->key, "device") == 0) {
- if (pi && option->value)
- pi->path = strdup(option->value);
- else if (ki && option->value)
- ki->path = strdup(option->value);
- }
- else if (strcmp(option->key, "driver") == 0) {
- if (pi) {
- pi->driver = KdFindPointerDriver(option->value);
- if (!pi->driver) {
- ErrorF("couldn't find driver!\n");
- KdFreePointer(pi);
- return BadValue;
- }
- pi->options = options;
- }
- else if (ki) {
- ki->driver = KdFindKeyboardDriver(option->value);
- if (!ki->driver) {
- ErrorF("couldn't find driver!\n");
- KdFreeKeyboard(ki);
- return BadValue;
- }
- ki->options = options;
- }
- }
- }
-
- if (pi) {
- if (KdAddPointer(pi) != Success ||
- ActivateDevice(pi->dixdev, TRUE) != Success ||
- EnableDevice(pi->dixdev, TRUE) != TRUE) {
- ErrorF("couldn't add or enable pointer\n");
- return BadImplementation;
- }
- }
- else if (ki) {
- if (KdAddKeyboard(ki) != Success ||
- ActivateDevice(ki->dixdev, TRUE) != Success ||
- EnableDevice(ki->dixdev, TRUE) != TRUE) {
- ErrorF("couldn't add or enable keyboard\n");
- return BadImplementation;
- }
- }
-
- if (pi) {
- *pdev = pi->dixdev;
- } else if(ki) {
- *pdev = ki->dixdev;
- }
-
- return Success;
-}
-
-void
-DeleteInputDeviceRequest(DeviceIntPtr pDev)
-{
- RemoveDevice(pDev, TRUE);
-}
+/*
+ * Copyright © 1999 Keith Packard
+ * Copyright © 2006 Nokia Corporation
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+#include "inputstr.h"
+
+#define XK_PUBLISHING
+#include <X11/keysym.h>
+#if HAVE_X11_XF86KEYSYM_H
+#include <X11/XF86keysym.h>
+#endif
+#include <signal.h>
+#include <stdio.h>
+#ifdef sun
+#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 "exevents.h"
+#include "extinit.h"
+#include "exglobals.h"
+#include "eventstr.h"
+#include "xserver-properties.h"
+
+#define AtomFromName(x) MakeAtom(x, strlen(x), 1)
+
+struct KdConfigDevice {
+ char *line;
+ struct KdConfigDevice *next;
+};
+
+/* 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 KdKeyboardDriver *kdKeyboardDrivers = NULL;
+static KdPointerDriver *kdPointerDrivers = NULL;
+
+static EventListPtr kdEvents = NULL;
+
+static Bool kdInputEnabled;
+static Bool kdOffScreen;
+static unsigned long kdOffScreenTime;
+static KdPointerMatrix kdPointerMatrix = {
+ { { 1, 0, 0 },
+ { 0, 1, 0 } }
+};
+
+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;
+} KdInputFd;
+
+static KdInputFd kdInputFds[KD_MAX_INPUT_FDS];
+static int kdNumInputFds;
+
+extern Bool kdRawPointerCoordinates;
+
+static void
+KdSigio (int sig)
+{
+ int i;
+
+ for (i = 0; i < kdNumInputFds; i++)
+ (*kdInputFds[i].read) (kdInputFds[i].fd, kdInputFds[i].closure);
+}
+
+static void
+KdBlockSigio (void)
+{
+#ifdef _MSC_VER
+ __asm int 3;
+#else
+ sigset_t set;
+
+ sigemptyset (&set);
+ sigaddset (&set, SIGIO);
+ sigprocmask (SIG_BLOCK, &set, 0);
+#endif
+}
+
+static void
+KdUnblockSigio (void)
+{
+#ifdef _MSC_VER
+ __asm int 3;
+#else
+ sigset_t set;
+
+ sigemptyset (&set);
+ sigaddset (&set, SIGIO);
+ sigprocmask (SIG_UNBLOCK, &set, 0);
+#endif
+}
+
+#ifdef DEBUG_SIGIO
+
+void
+KdAssertSigioBlocked (char *where)
+{
+ sigset_t set, old;
+
+ sigemptyset (&set);
+ sigprocmask (SIG_BLOCK, &set, &old);
+ if (!sigismember (&old, SIGIO)) {
+ ErrorF ("SIGIO not blocked at %s\n", where);
+ KdBacktrace(0);
+ }
+}
+
+#else
+
+#define KdAssertSigioBlocked(s)
+
+#endif
+
+static int kdnFds;
+
+#ifdef FNONBLOCK
+#define NOBLOCK FNONBLOCK
+#else
+#define NOBLOCK FNDELAY
+#endif
+
+void
+KdResetInputMachine (void)
+{
+ KdPointerInfo *pi;
+
+ for (pi = kdPointers; pi; pi = pi->next) {
+ pi->mouseState = start;
+ pi->eventHeld = FALSE;
+ }
+}
+
+static void
+KdNonBlockFd (int fd)
+{
+#ifdef _MSC_VER
+ __asm int 3;
+#else
+ int flags;
+ flags = fcntl (fd, F_GETFL);
+ flags |= FASYNC|NOBLOCK;
+ fcntl (fd, F_SETFL, flags);
+#endif
+}
+
+static void
+KdAddFd (int fd)
+{
+#ifdef _MSC_VER
+ __asm int 3;
+#else
+ struct sigaction act;
+ sigset_t set;
+
+ kdnFds++;
+ 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);
+#endif
+}
+
+static void
+KdRemoveFd (int fd)
+{
+#ifdef _MSC_VER
+ __asm int 3;
+#else
+ 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);
+ }
+#endif
+}
+
+Bool
+KdRegisterFd (int fd, void (*read) (int fd, void *closure), void *closure)
+{
+ if (kdNumInputFds == KD_MAX_INPUT_FDS)
+ return FALSE;
+ kdInputFds[kdNumInputFds].fd = fd;
+ kdInputFds[kdNumInputFds].read = read;
+ kdInputFds[kdNumInputFds].enable = 0;
+ kdInputFds[kdNumInputFds].disable = 0;
+ kdInputFds[kdNumInputFds].closure = closure;
+ kdNumInputFds++;
+ if (kdInputEnabled)
+ KdAddFd (fd);
+ return TRUE;
+}
+
+void
+KdUnregisterFd (void *closure, int fd, Bool do_close)
+{
+ int i, j;
+
+ for (i = 0; i < kdNumInputFds; i++) {
+ 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];
+ break;
+ }
+ }
+}
+
+void
+KdUnregisterFds (void *closure, Bool do_close)
+{
+ KdUnregisterFd(closure, -1, do_close);
+}
+
+void
+KdDisableInput (void)
+{
+ KdKeyboardInfo *ki;
+ KdPointerInfo *pi;
+ int found = 0, i = 0;
+
+ KdBlockSigio();
+
+ for (ki = kdKeyboards; ki; ki = ki->next) {
+ if (ki->driver && ki->driver->Disable)
+ (*ki->driver->Disable) (ki);
+ }
+
+ for (pi = kdPointers; pi; pi = pi->next) {
+ if (pi->driver && pi->driver->Disable)
+ (*pi->driver->Disable) (pi);
+ }
+
+ if (kdNumInputFds) {
+ ErrorF("[KdDisableInput] Buggy drivers: still %d input fds left!",
+ kdNumInputFds);
+ i = 0;
+ while (i < kdNumInputFds) {
+ found = 0;
+ for (ki = kdKeyboards; ki; ki = ki->next) {
+ if (ki == kdInputFds[i].closure) {
+ ErrorF(" fd %d belongs to keybd driver %s\n",
+ kdInputFds[i].fd,
+ ki->driver && ki->driver->name ?
+ ki->driver->name : "(unnamed!)");
+ found = 1;
+ break;
+ }
+ }
+
+ if (found) {
+ i++;
+ continue;
+ }
+
+ for (pi = kdPointers; pi; pi = pi->next) {
+ if (pi == kdInputFds[i].closure) {
+ ErrorF(" fd %d belongs to pointer driver %s\n",
+ kdInputFds[i].fd,
+ pi->driver && pi->driver->name ?
+ pi->driver->name : "(unnamed!)");
+ break;
+ }
+ }
+
+ if (found) {
+ i++;
+ continue;
+ }
+
+ ErrorF(" fd %d not claimed by any active device!\n",
+ kdInputFds[i].fd);
+ KdUnregisterFd(kdInputFds[i].closure, kdInputFds[i].fd, TRUE);
+ }
+ }
+
+ kdInputEnabled = FALSE;
+}
+
+void
+KdEnableInput (void)
+{
+ InternalEvent ev;
+ KdKeyboardInfo *ki;
+ KdPointerInfo *pi;
+
+ kdInputEnabled = TRUE;
+
+ for (ki = kdKeyboards; ki; ki = ki->next) {
+ if (ki->driver && ki->driver->Enable)
+ (*ki->driver->Enable) (ki);
+ }
+
+ for (pi = kdPointers; pi; pi = pi->next) {
+ if (pi->driver && pi->driver->Enable)
+ (*pi->driver->Enable) (pi);
+ }
+
+ /* reset screen saver */
+ ev.any.time = GetTimeInMillis ();
+ NoticeEventTime (&ev);
+
+ KdUnblockSigio ();
+}
+
+static KdKeyboardDriver *
+KdFindKeyboardDriver (char *name)
+{
+ KdKeyboardDriver *ret;
+
+ /* ask a stupid question ... */
+ if (!name)
+ return NULL;
+
+ for (ret = kdKeyboardDrivers; ret; ret = ret->next) {
+ if (strcmp(ret->name, name) == 0)
+ return ret;
+ }
+
+ return NULL;
+}
+
+static KdPointerDriver *
+KdFindPointerDriver (char *name)
+{
+ KdPointerDriver *ret;
+
+ /* ask a stupid question ... */
+ if (!name)
+ return NULL;
+
+ for (ret = kdPointerDrivers; ret; ret = ret->next) {
+ if (strcmp(ret->name, name) == 0)
+ return ret;
+ }
+
+ return NULL;
+}
+
+static int
+KdPointerProc(DeviceIntPtr pDevice, int onoff)
+{
+ DevicePtr pDev = (DevicePtr)pDevice;
+ KdPointerInfo *pi;
+ Atom xiclass;
+ Atom *btn_labels;
+ Atom *axes_labels;
+
+ if (!pDev)
+ return BadImplementation;
+
+ for (pi = kdPointers; pi; pi = pi->next) {
+ if (pi->dixdev && pi->dixdev->id == pDevice->id)
+ break;
+ }
+
+ if (!pi || !pi->dixdev || pi->dixdev->id != pDevice->id) {
+ ErrorF("[KdPointerProc] Failed to find pointer for device %d!\n",
+ pDevice->id);
+ return BadImplementation;
+ }
+
+ switch (onoff)
+ {
+ case DEVICE_INIT:
+#ifdef DEBUG
+ ErrorF("initialising pointer %s ...\n", pi->name);
+#endif
+ if (!pi->driver) {
+ if (!pi->driverPrivate) {
+ ErrorF("no driver specified for %s\n", pi->name);
+ return BadImplementation;
+ }
+
+ pi->driver = KdFindPointerDriver(pi->driverPrivate);
+ if (!pi->driver) {
+ ErrorF("Couldn't find pointer driver %s\n",
+ pi->driverPrivate ? (char *) pi->driverPrivate :
+ "(unnamed)");
+ return !Success;
+ }
+ xfree(pi->driverPrivate);
+ pi->driverPrivate = NULL;
+ }
+
+ if (!pi->driver->Init) {
+ ErrorF("no init function\n");
+ return BadImplementation;
+ }
+
+ if ((*pi->driver->Init) (pi) != Success) {
+ return !Success;
+ }
+
+ btn_labels = xcalloc(pi->nButtons, sizeof(Atom));
+ if (!btn_labels)
+ return BadAlloc;
+ axes_labels = xcalloc(pi->nAxes, sizeof(Atom));
+ if (!axes_labels) {
+ xfree(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);
+
+ xfree(btn_labels);
+ xfree(axes_labels);
+
+ if (pi->inputClass == KD_TOUCHSCREEN) {
+ InitAbsoluteClassDeviceStruct(pDevice);
+ xiclass = AtomFromName(XI_TOUCHSCREEN);
+ }
+ else {
+ xiclass = AtomFromName(XI_MOUSE);
+ }
+
+ AssignTypeAndName(pi->dixdev, xiclass,
+ pi->name ? pi->name : "Generic KDrive Pointer");
+
+ return Success;
+
+ case DEVICE_ON:
+ if (pDev->on == TRUE)
+ return Success;
+
+ if (!pi->driver->Enable) {
+ ErrorF("no enable function\n");
+ return BadImplementation;
+ }
+
+ if ((*pi->driver->Enable) (pi) == Success) {
+ pDev->on = TRUE;
+ return Success;
+ }
+ else {
+ return BadImplementation;
+ }
+
+ return Success;
+
+ case DEVICE_OFF:
+ if (pDev->on == FALSE) {
+ return Success;
+ }
+
+ if (!pi->driver->Disable) {
+ return BadImplementation;
+ }
+ else {
+ (*pi->driver->Disable) (pi);
+ pDev->on = FALSE;
+ return Success;
+ }
+
+ return Success;
+
+ case DEVICE_CLOSE:
+ if (pDev->on) {
+ if (!pi->driver->Disable) {
+ return BadImplementation;
+ }
+ (*pi->driver->Disable) (pi);
+ pDev->on = FALSE;
+ }
+
+ if (!pi->driver->Fini)
+ return BadImplementation;
+
+ (*pi->driver->Fini) (pi);
+
+ KdRemovePointer(pi);
+
+ return Success;
+ }
+
+ /* NOTREACHED */
+ return BadImplementation;
+}
+
+#ifndef _MSC_VER
+Bool
+LegalModifier(unsigned int key, DeviceIntPtr pDev)
+{
+ return TRUE;
+}
+#endif
+
+static void
+KdBell (int volume, DeviceIntPtr pDev, pointer arg, int something)
+{
+ KeybdCtrl *ctrl = arg;
+ KdKeyboardInfo *ki = NULL;
+
+ for (ki = kdKeyboards; ki; ki = ki->next) {
+ if (ki->dixdev && ki->dixdev->id == pDev->id)
+ break;
+ }
+
+ if (!ki || !ki->dixdev || ki->dixdev->id != pDev->id || !ki->driver)
+ return;
+
+ KdRingBell(ki, volume, ctrl->bell_pitch, ctrl->bell_duration);
+}
+
+#ifndef _MSC_VER
+void
+DDXRingBell(int volume, int pitch, int duration)
+{
+ KdKeyboardInfo *ki = NULL;
+
+ if (kdOsFuncs->Bell) {
+ (*kdOsFuncs->Bell)(volume, pitch, duration);
+ }
+ else {
+ for (ki = kdKeyboards; ki; ki = ki->next) {
+ if (ki->dixdev->coreEvents)
+ KdRingBell(ki, volume, pitch, duration);
+ }
+ }
+}
+#endif
+void
+KdRingBell(KdKeyboardInfo *ki, int volume, int pitch, int duration)
+{
+ if (!ki || !ki->driver || !ki->driver->Bell)
+ return;
+
+ if (kdInputEnabled)
+ (*ki->driver->Bell) (ki, volume, pitch, duration);
+}
+
+
+static void
+KdSetLeds (KdKeyboardInfo *ki, int leds)
+{
+ if (!ki || !ki->driver)
+ return;
+
+ if (kdInputEnabled) {
+ if (ki->driver->Leds)
+ (*ki->driver->Leds) (ki, leds);
+ }
+}
+
+void
+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);
+}
+
+void
+KdSetPointerMatrix (KdPointerMatrix *matrix)
+{
+ kdPointerMatrix = *matrix;
+}
+
+void
+KdComputePointerMatrix (KdPointerMatrix *m, Rotation randr, int width,
+ int height)
+{
+ int x_dir = 1, y_dir = 1;
+ int i, j;
+ int size[2];
+
+ size[0] = width; size[1] = height;
+ if (randr & RR_Reflect_X)
+ x_dir = -1;
+ if (randr & RR_Reflect_Y)
+ 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;
+ 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;
+ 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;
+ 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;
+ }
+ 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)
+{
+ 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;
+}
+
+static void
+KdKbdCtrl (DeviceIntPtr pDevice, KeybdCtrl *ctrl)
+{
+ KdKeyboardInfo *ki;
+
+ for (ki = kdKeyboards; ki; ki = ki->next) {
+ if (ki->dixdev && ki->dixdev->id == pDevice->id)
+ break;
+ }
+
+ if (!ki || !ki->dixdev || ki->dixdev->id != pDevice->id || !ki->driver)
+ return;
+
+ KdSetLeds(ki, ctrl->leds);
+ ki->bellPitch = ctrl->bell_pitch;
+ ki->bellDuration = ctrl->bell_duration;
+}
+
+extern KeybdCtrl defaultKeyboardControl;
+
+static int
+KdKeyboardProc(DeviceIntPtr pDevice, int onoff)
+{
+ Bool ret;
+ DevicePtr pDev = (DevicePtr)pDevice;
+ KdKeyboardInfo *ki;
+ Atom xiclass;
+ XkbRMLVOSet rmlvo;
+
+ if (!pDev)
+ return BadImplementation;
+
+ for (ki = kdKeyboards; ki; ki = ki->next) {
+ if (ki->dixdev && ki->dixdev->id == pDevice->id)
+ break;
+ }
+
+ if (!ki || !ki->dixdev || ki->dixdev->id != pDevice->id) {
+ return BadImplementation;
+ }
+
+ switch (onoff)
+ {
+ case DEVICE_INIT:
+#ifdef DEBUG
+ ErrorF("initialising keyboard %s\n", ki->name);
+#endif
+ if (!ki->driver) {
+ if (!ki->driverPrivate) {
+ ErrorF("no driver specified!\n");
+ return BadImplementation;
+ }
+
+ ki->driver = KdFindKeyboardDriver(ki->driverPrivate);
+ if (!ki->driver) {
+ ErrorF("Couldn't find keyboard driver %s\n",
+ ki->driverPrivate ? (char *) ki->driverPrivate :
+ "(unnamed)");
+ return !Success;
+ }
+ xfree(ki->driverPrivate);
+ ki->driverPrivate = NULL;
+ }
+
+ if (!ki->driver->Init) {
+ ErrorF("Keyboard %s: no init function\n", ki->name);
+ return BadImplementation;
+ }
+
+ if ((*ki->driver->Init) (ki) != Success) {
+ return !Success;
+ }
+
+ memset(&rmlvo, 0, sizeof(rmlvo));
+ rmlvo.rules = ki->xkbRules;
+ rmlvo.model = ki->xkbModel;
+ rmlvo.layout = ki->xkbLayout;
+ rmlvo.variant = ki->xkbVariant;
+ rmlvo.options = ki->xkbOptions;
+ ret = InitKeyboardDeviceStruct (pDevice, &rmlvo, KdBell, KdKbdCtrl);
+ if (!ret) {
+ ErrorF("Couldn't initialise keyboard %s\n", ki->name);
+ return BadImplementation;
+ }
+
+ xiclass = AtomFromName(XI_KEYBOARD);
+ AssignTypeAndName(pDevice, xiclass,
+ ki->name ? ki->name : "Generic KDrive Keyboard");
+
+ KdResetInputMachine();
+
+ return Success;
+
+ case DEVICE_ON:
+ if (pDev->on == TRUE)
+ return Success;
+
+ if (!ki->driver->Enable)
+ return BadImplementation;
+
+ if ((*ki->driver->Enable) (ki) != Success) {
+ return BadMatch;
+ }
+
+ pDev->on = TRUE;
+ return Success;
+
+ case DEVICE_OFF:
+ if (pDev->on == FALSE)
+ return Success;
+
+ if (!ki->driver->Disable)
+ return BadImplementation;
+
+ (*ki->driver->Disable) (ki);
+ pDev->on = FALSE;
+
+ return Success;
+
+ break;
+
+ case DEVICE_CLOSE:
+ if (pDev->on) {
+ if (!ki->driver->Disable)
+ return BadImplementation;
+
+ (*ki->driver->Disable) (ki);
+ pDev->on = FALSE;
+ }
+
+ if (!ki->driver->Fini)
+ return BadImplementation;
+
+ (*ki->driver->Fini) (ki);
+
+ KdRemoveKeyboard(ki);
+
+ return Success;
+ }
+
+ /* NOTREACHED */
+ return BadImplementation;
+}
+
+void
+KdAddPointerDriver (KdPointerDriver *driver)
+{
+ KdPointerDriver **prev;
+
+ if (!driver)
+ return;
+
+ for (prev = &kdPointerDrivers; *prev; prev = &(*prev)->next) {
+ if (*prev == driver)
+ return;
+ }
+ *prev = driver;
+}
+
+void
+KdRemovePointerDriver (KdPointerDriver *driver)
+{
+ KdPointerDriver *tmp;
+
+ if (!driver)
+ return;
+
+ /* FIXME remove all pointers using this driver */
+ for (tmp = kdPointerDrivers; tmp; tmp = tmp->next) {
+ if (tmp->next == driver)
+ tmp->next = driver->next;
+ }
+ if (tmp == driver)
+ tmp = NULL;
+}
+
+void
+KdAddKeyboardDriver (KdKeyboardDriver *driver)
+{
+ KdKeyboardDriver **prev;
+
+ if (!driver)
+ return;
+
+ for (prev = &kdKeyboardDrivers; *prev; prev = &(*prev)->next) {
+ if (*prev == driver)
+ return;
+ }
+ *prev = driver;
+}
+
+void
+KdRemoveKeyboardDriver (KdKeyboardDriver *driver)
+{
+ KdKeyboardDriver *tmp;
+
+ if (!driver)
+ return;
+
+ /* FIXME remove all keyboards using this driver */
+ for (tmp = kdKeyboardDrivers; tmp; tmp = tmp->next) {
+ if (tmp->next == driver)
+ tmp->next = driver->next;
+ }
+ if (tmp == driver)
+ tmp = NULL;
+}
+
+KdKeyboardInfo *
+KdNewKeyboard (void)
+{
+ KdKeyboardInfo *ki = xcalloc(sizeof(KdKeyboardInfo), 1);
+ if (!ki)
+ return NULL;
+
+ ki->minScanCode = 0;
+ ki->maxScanCode = 0;
+ ki->leds = 0;
+ ki->bellPitch = 1000;
+ ki->bellDuration = 200;
+ ki->next = NULL;
+ ki->options = NULL;
+ ki->xkbRules = strdup(XKB_DFLT_RULES);
+ ki->xkbModel = strdup(XKB_DFLT_MODEL);
+ ki->xkbLayout = strdup(XKB_DFLT_LAYOUT);
+ ki->xkbVariant = strdup(XKB_DFLT_VARIANT);
+ ki->xkbOptions = strdup(XKB_DFLT_OPTIONS);
+
+ return ki;
+}
+
+int
+KdAddConfigKeyboard (char *keyboard)
+{
+ struct KdConfigDevice **prev, *new;
+
+ if (!keyboard)
+ return Success;
+
+ new = (struct KdConfigDevice *) xcalloc(sizeof(struct KdConfigDevice), 1);
+ if (!new)
+ return BadAlloc;
+
+ new->line = xstrdup(keyboard);
+ new->next = NULL;
+
+ for (prev = &kdConfigKeyboards; *prev; prev = &(*prev)->next);
+ *prev = new;
+
+ return Success;
+}
+
+int
+KdAddKeyboard (KdKeyboardInfo *ki)
+{
+ KdKeyboardInfo **prev;
+
+ if (!ki)
+ return !Success;
+
+ ki->dixdev = AddInputDevice(serverClient, KdKeyboardProc, TRUE);
+ if (!ki->dixdev) {
+ ErrorF("Couldn't register keyboard device %s\n",
+ ki->name ? ki->name : "(unnamed)");
+ return !Success;
+ }
+
+ ki->dixdev->deviceGrab.ActivateGrab = ActivateKeyboardGrab;
+ ki->dixdev->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab;
+ RegisterOtherDevice(ki->dixdev);
+
+#ifdef DEBUG
+ ErrorF("added keyboard %s with dix id %d\n", ki->name, ki->dixdev->id);
+#endif
+
+ for (prev = &kdKeyboards; *prev; prev = &(*prev)->next);
+ *prev = ki;
+
+ return Success;
+}
+
+void
+KdRemoveKeyboard (KdKeyboardInfo *ki)
+{
+ KdKeyboardInfo **prev;
+
+ if (!ki)
+ return;
+
+ for (prev = &kdKeyboards; *prev; prev = &(*prev)->next) {
+ if (*prev == ki) {
+ *prev = ki->next;
+ break;
+ }
+ }
+
+ KdFreeKeyboard(ki);
+}
+
+int
+KdAddConfigPointer (char *pointer)
+{
+ struct KdConfigDevice **prev, *new;
+
+ if (!pointer)
+ return Success;
+
+ new = (struct KdConfigDevice *) xcalloc(sizeof(struct KdConfigDevice), 1);
+ if (!new)
+ return BadAlloc;
+
+ new->line = xstrdup(pointer);
+ new->next = NULL;
+
+ for (prev = &kdConfigPointers; *prev; prev = &(*prev)->next);
+ *prev = new;
+
+ return Success;
+}
+
+int
+KdAddPointer (KdPointerInfo *pi)
+{
+ KdPointerInfo **prev;
+
+ if (!pi)
+ return Success;
+
+ pi->mouseState = start;
+ pi->eventHeld = FALSE;
+
+ pi->dixdev = AddInputDevice(serverClient, KdPointerProc, TRUE);
+ if (!pi->dixdev) {
+ ErrorF("Couldn't add pointer device %s\n",
+ pi->name ? pi->name : "(unnamed)");
+ return BadDevice;
+ }
+
+ pi->dixdev->deviceGrab.ActivateGrab = ActivatePointerGrab;
+ pi->dixdev->deviceGrab.DeactivateGrab = DeactivatePointerGrab;
+ RegisterOtherDevice(pi->dixdev);
+
+ for (prev = &kdPointers; *prev; prev = &(*prev)->next);
+ *prev = pi;
+
+ return Success;
+}
+
+void
+KdRemovePointer (KdPointerInfo *pi)
+{
+ KdPointerInfo **prev;
+
+ if (!pi)
+ return;
+
+ for (prev = &kdPointers; *prev; prev = &(*prev)->next) {
+ if (*prev == pi) {
+ *prev = pi->next;
+ break;
+ }
+ }
+
+ KdFreePointer(pi);
+}
+
+/*
+ * You can call your kdriver server with something like:
+ * $ ./hw/kdrive/yourserver/X :1 -mouse evdev,,device=/dev/input/event4 -keybd
+ * evdev,,device=/dev/input/event1,xkbmodel=abnt2,xkblayout=br
+ */
+static Bool
+KdGetOptions (InputOption **options, char *string)
+{
+ InputOption *newopt = NULL, **tmpo = NULL;
+ int tam_key = 0;
+
+ newopt = xcalloc(1, sizeof (InputOption));
+ if (!newopt)
+ return FALSE;
+
+ for (tmpo = options; *tmpo; tmpo = &(*tmpo)->next)
+ ; /* Hello, I'm here */
+ *tmpo = newopt;
+
+ if (strchr(string, '='))
+ {
+ tam_key = (strchr(string, '=') - string);
+ newopt->key = (char *)xalloc(tam_key);
+ strncpy(newopt->key, string, tam_key);
+ newopt->key[tam_key] = '\0';
+ newopt->value = xstrdup(strchr(string, '=') + 1);
+ }
+ else
+ {
+ newopt->key = xstrdup(string);
+ newopt->value = NULL;
+ }
+ newopt->next = NULL;
+
+ return TRUE;
+}
+
+static void
+KdParseKbdOptions (KdKeyboardInfo *ki)
+{
+ InputOption *option = NULL;
+
+ for (option = ki->options; option; option = option->next)
+ {
+ if (strcasecmp(option->key, "XkbRules") == 0)
+ ki->xkbRules = option->value;
+ else if (strcasecmp(option->key, "XkbModel") == 0)
+ ki->xkbModel = option->value;
+ else if (strcasecmp(option->key, "XkbLayout") == 0)
+ ki->xkbLayout = option->value;
+ else if (strcasecmp(option->key, "XkbVariant") == 0)
+ ki->xkbVariant = option->value;
+ else if (strcasecmp(option->key, "XkbOptions") == 0)
+ ki->xkbOptions = option->value;
+ else if (!strcasecmp (option->key, "device"))
+ ki->path = strdup(option->value);
+ else
+ ErrorF("Kbd option key (%s) of value (%s) not assigned!\n",
+ option->key, option->value);
+ }
+}
+
+KdKeyboardInfo *
+KdParseKeyboard (char *arg)
+{
+ char save[1024];
+ char delim;
+ InputOption *options = NULL;
+ KdKeyboardInfo *ki = NULL;
+
+ ki = KdNewKeyboard();
+ if (!ki)
+ return NULL;
+
+ ki->name = strdup("Unknown KDrive Keyboard");
+ ki->path = NULL;
+ ki->driver = NULL;
+ ki->driverPrivate = NULL;
+ ki->next = NULL;
+
+ if (!arg)
+ {
+ ErrorF("keybd: no arg\n");
+ KdFreeKeyboard (ki);
+ return NULL;
+ }
+
+ if (strlen (arg) >= sizeof (save))
+ {
+ ErrorF("keybd: arg too long\n");
+ KdFreeKeyboard (ki);
+ return NULL;
+ }
+
+ arg = KdParseFindNext (arg, ",", save, &delim);
+ if (!save[0])
+ {
+ ErrorF("keybd: failed on save[0]\n");
+ KdFreeKeyboard (ki);
+ return NULL;
+ }
+
+ if (strcmp (save, "auto") == 0)
+ ki->driverPrivate = NULL;
+ else
+ ki->driverPrivate = xstrdup(save);
+
+ if (delim != ',')
+ {
+ return ki;
+ }
+
+ arg = KdParseFindNext (arg, ",", save, &delim);
+
+ while (delim == ',')
+ {
+ arg = KdParseFindNext (arg, ",", save, &delim);
+
+ if (!KdGetOptions(&options, save))
+ {
+ KdFreeKeyboard(ki);
+ return NULL;
+ }
+ }
+
+ if (options)
+ {
+ ki->options = options;
+ KdParseKbdOptions(ki);
+ }
+
+ return ki;
+}
+
+static void
+KdParsePointerOptions (KdPointerInfo *pi)
+{
+ InputOption *option = NULL;
+
+ for (option = pi->options; option; option = option->next)
+ {
+ if (!strcmp (option->key, "emulatemiddle"))
+ pi->emulateMiddleButton = TRUE;
+ else if (!strcmp (option->key, "noemulatemiddle"))
+ pi->emulateMiddleButton = FALSE;
+ else if (!strcmp (option->key, "transformcoord"))
+ pi->transformCoordinates = TRUE;
+ else if (!strcmp (option->key, "rawcoord"))
+ pi->transformCoordinates = FALSE;
+ else if (!strcasecmp (option->key, "device"))
+ pi->path = strdup(option->value);
+ else if (!strcasecmp (option->key, "protocol"))
+ pi->protocol = strdup(option->value);
+ else
+ ErrorF("Pointer option key (%s) of value (%s) not assigned!\n",
+ option->key, option->value);
+ }
+}
+
+KdPointerInfo *
+KdParsePointer (char *arg)
+{
+ char save[1024];
+ char delim;
+ KdPointerInfo *pi = NULL;
+ InputOption *options = NULL;
+ int i = 0;
+
+ pi = KdNewPointer();
+ if (!pi)
+ return NULL;
+ pi->emulateMiddleButton = kdEmulateMiddleButton;
+ pi->transformCoordinates = !kdRawPointerCoordinates;
+ pi->protocol = NULL;
+ pi->nButtons = 5; /* XXX should not be hardcoded */
+ pi->inputClass = KD_MOUSE;
+
+ if (!arg)
+ {
+ ErrorF("mouse: no arg\n");
+ KdFreePointer (pi);
+ return NULL;
+ }
+
+ if (strlen (arg) >= sizeof (save))
+ {
+ ErrorF("mouse: arg too long\n");
+ KdFreePointer (pi);
+ return NULL;
+ }
+ arg = KdParseFindNext (arg, ",", save, &delim);
+ if (!save[0])
+ {
+ ErrorF("failed on save[0]\n");
+ KdFreePointer (pi);
+ return NULL;
+ }
+
+ if (strcmp(save, "auto") == 0)
+ pi->driverPrivate = NULL;
+ else
+ pi->driverPrivate = xstrdup(save);
+
+ if (delim != ',')
+ {
+ return pi;
+ }
+
+ arg = KdParseFindNext (arg, ",", save, &delim);
+
+ while (delim == ',')
+ {
+ arg = KdParseFindNext (arg, ",", save, &delim);
+ if (save[0] == '{')
+ {
+ char *s = save + 1;
+ i = 0;
+ while (*s && *s != '}')
+ {
+ if ('1' <= *s && *s <= '0' + pi->nButtons)
+ pi->map[i] = *s - '0';
+ else
+ UseMsg ();
+ s++;
+ }
+ }
+ else
+ {
+ if (!KdGetOptions(&options, save))
+ {
+ KdFreePointer(pi);
+ return NULL;
+ }
+ }
+ }
+
+ if (options)
+ {
+ pi->options = options;
+ KdParsePointerOptions(pi);
+ }
+
+ return pi;
+}
+
+
+void
+KdInitInput (void)
+{
+ KdPointerInfo *pi;
+ KdKeyboardInfo *ki;
+ struct KdConfigDevice *dev;
+
+ kdInputEnabled = TRUE;
+
+ for (dev = kdConfigPointers; dev; dev = dev->next) {
+ pi = KdParsePointer(dev->line);
+ if (!pi)
+ ErrorF("Failed to parse pointer\n");
+ if (KdAddPointer(pi) != Success)
+ ErrorF("Failed to add pointer!\n");
+ }
+ for (dev = kdConfigKeyboards; dev; dev = dev->next) {
+ ki = KdParseKeyboard(dev->line);
+ if (!ki)
+ ErrorF("Failed to parse keyboard\n");
+ if (KdAddKeyboard(ki) != Success)
+ ErrorF("Failed to add keyboard!\n");
+ }
+
+ mieqInit();
+}
+
+/*
+ * Middle button emulation state machine
+ *
+ * Possible transitions:
+ * Button 1 press v1
+ * Button 1 release ^1
+ * Button 2 press v2
+ * Button 2 release ^2
+ * Button 3 press v3
+ * Button 3 release ^3
+ * Button other press vo
+ * Button other release ^o
+ * Mouse motion <>
+ * Keyboard event k
+ * timeout ...
+ * outside box <->
+ *
+ * States:
+ * start
+ * button_1_pend
+ * button_1_down
+ * button_2_down
+ * button_3_pend
+ * button_3_down
+ * synthetic_2_down_13
+ * synthetic_2_down_3
+ * synthetic_2_down_1
+ *
+ * Transition diagram
+ *
+ * start
+ * v1 -> (hold) (settimeout) button_1_pend
+ * ^1 -> (deliver) start
+ * v2 -> (deliver) button_2_down
+ * ^2 -> (deliever) start
+ * v3 -> (hold) (settimeout) button_3_pend
+ * ^3 -> (deliver) start
+ * vo -> (deliver) start
+ * ^o -> (deliver) start
+ * <> -> (deliver) start
+ * k -> (deliver) start
+ *
+ * button_1_pend (button 1 is down, timeout pending)
+ * ^1 -> (release) (deliver) start
+ * v2 -> (release) (deliver) button_1_down
+ * ^2 -> (release) (deliver) button_1_down
+ * v3 -> (cleartimeout) (generate v2) synthetic_2_down_13
+ * ^3 -> (release) (deliver) button_1_down
+ * vo -> (release) (deliver) button_1_down
+ * ^o -> (release) (deliver) button_1_down
+ * <-> -> (release) (deliver) button_1_down
+ * <> -> (deliver) button_1_pend
+ * k -> (release) (deliver) button_1_down
+ * ... -> (release) button_1_down
+ *
+ * button_1_down (button 1 is down)
+ * ^1 -> (deliver) start
+ * v2 -> (deliver) button_1_down
+ * ^2 -> (deliver) button_1_down
+ * v3 -> (deliver) button_1_down
+ * ^3 -> (deliver) button_1_down
+ * vo -> (deliver) button_1_down
+ * ^o -> (deliver) button_1_down
+ * <> -> (deliver) button_1_down
+ * k -> (deliver) button_1_down
+ *
+ * button_2_down (button 2 is down)
+ * v1 -> (deliver) button_2_down
+ * ^1 -> (deliver) button_2_down
+ * ^2 -> (deliver) start
+ * v3 -> (deliver) button_2_down
+ * ^3 -> (deliver) button_2_down
+ * vo -> (deliver) button_2_down
+ * ^o -> (deliver) button_2_down
+ * <> -> (deliver) button_2_down
+ * k -> (deliver) button_2_down
+ *
+ * button_3_pend (button 3 is down, timeout pending)
+ * v1 -> (generate v2) synthetic_2_down
+ * ^1 -> (release) (deliver) button_3_down
+ * v2 -> (release) (deliver) button_3_down
+ * ^2 -> (release) (deliver) button_3_down
+ * ^3 -> (release) (deliver) start
+ * vo -> (release) (deliver) button_3_down
+ * ^o -> (release) (deliver) button_3_down
+ * <-> -> (release) (deliver) button_3_down
+ * <> -> (deliver) button_3_pend
+ * k -> (release) (deliver) button_3_down
+ * ... -> (release) button_3_down
+ *
+ * button_3_down (button 3 is down)
+ * v1 -> (deliver) button_3_down
+ * ^1 -> (deliver) button_3_down
+ * v2 -> (deliver) button_3_down
+ * ^2 -> (deliver) button_3_down
+ * ^3 -> (deliver) start
+ * vo -> (deliver) button_3_down
+ * ^o -> (deliver) button_3_down
+ * <> -> (deliver) button_3_down
+ * k -> (deliver) button_3_down
+ *
+ * synthetic_2_down_13 (button 1 and 3 are down)
+ * ^1 -> (generate ^2) synthetic_2_down_3
+ * v2 -> synthetic_2_down_13
+ * ^2 -> synthetic_2_down_13
+ * ^3 -> (generate ^2) synthetic_2_down_1
+ * vo -> (deliver) synthetic_2_down_13
+ * ^o -> (deliver) synthetic_2_down_13
+ * <> -> (deliver) synthetic_2_down_13
+ * k -> (deliver) synthetic_2_down_13
+ *
+ * synthetic_2_down_3 (button 3 is down)
+ * v1 -> (deliver) synthetic_2_down_3
+ * ^1 -> (deliver) synthetic_2_down_3
+ * v2 -> synthetic_2_down_3
+ * ^2 -> synthetic_2_down_3
+ * ^3 -> start
+ * vo -> (deliver) synthetic_2_down_3
+ * ^o -> (deliver) synthetic_2_down_3
+ * <> -> (deliver) synthetic_2_down_3
+ * k -> (deliver) synthetic_2_down_3
+ *
+ * synthetic_2_down_1 (button 1 is down)
+ * ^1 -> start
+ * v2 -> synthetic_2_down_1
+ * ^2 -> synthetic_2_down_1
+ * v3 -> (deliver) synthetic_2_down_1
+ * ^3 -> (deliver) synthetic_2_down_1
+ * vo -> (deliver) synthetic_2_down_1
+ * ^o -> (deliver) synthetic_2_down_1
+ * <> -> (deliver) synthetic_2_down_1
+ * k -> (deliver) synthetic_2_down_1
+ */
+
+typedef enum _inputClass {
+ down_1, up_1,
+ down_2, up_2,
+ down_3, up_3,
+ down_o, up_o,
+ motion, outside_box,
+ keyboard, timeout,
+ num_input_class
+} KdInputClass;
+
+typedef enum _inputAction {
+ noop,
+ hold,
+ setto,
+ deliver,
+ release,
+ clearto,
+ gen_down_2,
+ gen_up_2
+} KdInputAction;
+
+#define MAX_ACTIONS 2
+
+typedef struct _inputTransition {
+ KdInputAction actions[MAX_ACTIONS];
+ KdPointerState nextState;
+} KdInputTransition;
+
+static const
+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 }, /* ... */
+ },
+ /* 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 }, /* ... */
+ },
+ /* 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 }, /* ... */
+ },
+ /* 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 }, /* ... */
+ },
+ /* 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 }, /* ... */
+ },
+ /* 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 }, /* ... */
+ },
+ /* 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 }, /* ... */
+ },
+};
+
+#define EMULATION_WINDOW 10
+#define EMULATION_TIMEOUT 100
+
+static int
+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);
+}
+
+static KdInputClass
+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;
+ case ButtonRelease:
+ 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;
+ default:
+ return keyboard;
+ }
+ return keyboard;
+}
+
+#ifdef DEBUG
+char *kdStateNames[] = {
+ "start",
+ "button_1_pend",
+ "button_1_down",
+ "button_2_down",
+ "button_3_pend",
+ "button_3_down",
+ "synth_2_down_13",
+ "synth_2_down_3",
+ "synthetic_2_down_1",
+ "num_input_states"
+};
+
+char *kdClassNames[] = {
+ "down_1", "up_1",
+ "down_2", "up_2",
+ "down_3", "up_3",
+ "motion", "ouside_box",
+ "keyboard", "timeout",
+ "num_input_class"
+};
+
+char *kdActionNames[] = {
+ "noop",
+ "hold",
+ "setto",
+ "deliver",
+ "release",
+ "clearto",
+ "gen_down_2",
+ "gen_up_2",
+};
+#endif /* DEBUG */
+
+static void
+KdQueueEvent (DeviceIntPtr pDev, InternalEvent *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)
+{
+ const KdInputTransition *t;
+ 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;
+ 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);
+ 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;
+ return TRUE;
+ break;
+ case gen_up_2:
+ _KdEnqueuePointerEvent (pi, ButtonRelease, x, y, z, 2, absrel,
+ TRUE);
+ return TRUE;
+ break;
+ }
+ }
+ pi->mouseState = t->nextState;
+ return FALSE;
+}
+
+static int
+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 FALSE;
+}
+
+static void
+KdReceiveTimeout (KdPointerInfo *pi)
+{
+ KdRunMouseMachine (pi, timeout, 0, 0, 0, 0, 0, 0);
+}
+
+/*
+ * kdCheckTermination
+ *
+ * This function checks for the key sequence that terminates the server. When
+ * detected, it sets the dispatchException flag and returns. The key sequence
+ * is:
+ * Control-Alt
+ * It's assumed that the server will be waken up by the caller when this
+ * function returns.
+ */
+
+extern int nClients;
+
+void
+KdReleaseAllKeys (void)
+{
+#if 0
+ int key, nEvents, i;
+ KdKeyboardInfo *ki;
+
+ KdBlockSigio ();
+
+ for (ki = kdKeyboards; ki; ki = ki->next) {
+ 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);
+ GetEventList(&kdEvents);
+ nEvents = GetKeyboardEvents(kdEvents, ki->dixdev, KeyRelease, key);
+ for (i = 0; i < nEvents; i++)
+ KdQueueEvent (ki->dixdev, (kdEvents + i)->event);
+ }
+ }
+ }
+
+ KdUnblockSigio ();
+#endif
+}
+
+static void
+KdCheckLock (void)
+{
+ 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;
+ /* FIXME: Just use XKB indicators! */
+ shouldBeSet = !!(XkbStateFieldFromRec(&keyc->xkbInfo->state) & LockMask);
+ if (isSet != shouldBeSet)
+ KdSetLed (tmp, tmp->LockLed, shouldBeSet);
+ }
+ }
+}
+
+void
+KdEnqueueKeyboardEvent(KdKeyboardInfo *ki,
+ unsigned char scan_code,
+ unsigned char is_up)
+{
+ unsigned char key_code;
+ KeyClassPtr keyc = NULL;
+ KeybdCtrl *ctrl = NULL;
+ int type, nEvents, i;
+
+ if (!ki || !ki->dixdev || !ki->dixdev->kbdfeed || !ki->dixdev->key)
+ 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;
+
+ /*
+ * Set up this event -- the type may be modified below
+ */
+ if (is_up)
+ type = KeyRelease;
+ else
+ type = KeyPress;
+
+ GetEventList(&kdEvents);
+
+ nEvents = GetKeyboardEvents(kdEvents, ki->dixdev, type, key_code);
+ for (i = 0; i < nEvents; i++)
+ KdQueueEvent(ki->dixdev, (InternalEvent *)((kdEvents + i)->event));
+ }
+ else {
+ ErrorF("driver %s wanted to post scancode %d outside of [%d, %d]!\n",
+ ki->name, scan_code, ki->minScanCode, ki->maxScanCode);
+ }
+}
+
+/*
+ * kdEnqueuePointerEvent
+ *
+ * This function converts hardware mouse event information into X event
+ * information. A mouse movement event is passed off to MI to generate
+ * a MotionNotify event, if appropriate. Button events are created and
+ * passed off to MI for enqueueing.
+ */
+
+/* FIXME do something a little more clever to deal with multiple axes here */
+void
+KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry,
+ int rz)
+{
+ CARD32 ms;
+ unsigned char buttons;
+ int x, y, z;
+ int (*matrix)[3] = kdPointerMatrix.matrix;
+ unsigned long button;
+ int n;
+ int dixflags = 0;
+
+ if (!pi)
+ 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;
+ }
+ }
+ 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;
+ }
+ }
+ z = rz;
+
+ if (flags & KD_MOUSE_DELTA)
+ {
+ if (x || y || z)
+ {
+ dixflags = POINTER_RELATIVE | POINTER_ACCELERATE;
+ _KdEnqueuePointerEvent(pi, MotionNotify, x, y, z, 0, dixflags, FALSE);
+ }
+ } 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);
+ }
+
+ buttons = flags;
+
+ for (button = KD_BUTTON_1, n = 1; n <= pi->nButtons;
+ button <<= 1, n++) {
+ if (((pi->buttonState & 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)) {
+ _KdEnqueuePointerEvent(pi, ButtonPress, x, y, z, n,
+ dixflags, FALSE);
+ }
+ }
+
+ pi->buttonState = buttons;
+}
+
+void
+_KdEnqueuePointerEvent (KdPointerInfo *pi, int type, int x, int y, int z,
+ int b, int absrel, Bool force)
+{
+ int nEvents = 0, i = 0;
+ int valuators[3] = { x, y, z };
+
+ /* TRUE from KdHandlePointerEvent, means 'we swallowed the event'. */
+ if (!force && KdHandlePointerEvent(pi, type, x, y, z, b, absrel))
+ return;
+
+ GetEventList(&kdEvents);
+ nEvents = GetPointerEvents(kdEvents, pi->dixdev, type, b, absrel,
+ 0, 3, valuators);
+ for (i = 0; i < nEvents; i++)
+ KdQueueEvent(pi->dixdev, (InternalEvent *)((kdEvents + i)->event));
+}
+
+void
+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;
+
+ 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(myTimeout>0)
+ AdjustWaitForDelay (timeout, myTimeout);
+}
+
+void
+KdWakeupHandler (int screen,
+ pointer data,
+ unsigned long lresult,
+ pointer readmask)
+{
+ 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 (kdSwitchPending)
+ KdProcessSwitch ();
+}
+
+#define KdScreenOrigin(pScreen) (&(KdGetScreenPriv(pScreen)->screen->origin))
+
+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;
+
+ if (kdDisableZaphod || screenInfo.numScreens <= 1)
+ return FALSE;
+
+ if (0 <= *x && *x < pScreen->width && 0 <= *y && *y < pScreen->height)
+ return FALSE;
+
+ ms = GetTimeInMillis ();
+ if (kdOffScreen && (int) (ms - kdOffScreenTime) < 1000)
+ 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;
+ }
+ }
+ }
+ if (best_y < best_x)
+ n_best_x = n_best_y;
+ if (n_best_x == -1)
+ return FALSE;
+ pNewScreen = screenInfo.screens[n_best_x];
+
+ if (*x < 0)
+ *x += pNewScreen->width;
+ if (*y < 0)
+ *y += pNewScreen->height;
+
+ if (*x >= pScreen->width)
+ *x -= pScreen->width;
+ if (*y >= pScreen->height)
+ *y -= pScreen->height;
+
+ *ppScreen = pNewScreen;
+ return TRUE;
+}
+
+static void
+KdCrossScreen(ScreenPtr pScreen, Bool entering)
+{
+#ifndef XIPAQ
+ if (entering)
+ KdEnableScreen (pScreen);
+ else
+ KdDisableScreen (pScreen);
+#endif
+}
+
+int KdCurScreen; /* current event screen */
+
+static void
+KdWarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
+{
+ KdBlockSigio ();
+ KdCurScreen = pScreen->myNum;
+ miPointerWarpCursor(pDev, pScreen, x, y);
+ KdUnblockSigio ();
+}
+
+miPointerScreenFuncRec kdPointerScreenFuncs =
+{
+ KdCursorOffScreen,
+ KdCrossScreen,
+ KdWarpCursor
+};
+
+#ifndef _MSC_VER
+void
+ProcessInputEvents (void)
+{
+ mieqProcessInputEvents();
+ miPointerUpdateSprite(inputInfo.pointer);
+ if (kdSwitchPending)
+ KdProcessSwitch ();
+ KdCheckLock ();
+}
+#endif
+
+/* FIXME use XSECURITY to work out whether the client should be allowed to
+ * open and close. */
+void
+OpenInputDevice(DeviceIntPtr pDev, ClientPtr client, int *status)
+{
+ if (!pDev)
+ *status = BadDevice;
+ else
+ *status = Success;
+}
+
+void
+CloseInputDevice(DeviceIntPtr pDev, ClientPtr client)
+{
+ return;
+}
+
+/* We initialise all input devices at startup. */
+void
+AddOtherInputDevices(void)
+{
+ return;
+}
+
+/* At the moment, absolute/relative is up to the client. */
+int
+SetDeviceMode(register ClientPtr client, DeviceIntPtr pDev, int mode)
+{
+ return BadMatch;
+}
+
+int
+SetDeviceValuators(register ClientPtr client, DeviceIntPtr pDev,
+ int *valuators, int first_valuator, int num_valuators)
+{
+ return BadMatch;
+}
+
+int
+ChangeDeviceControl(register ClientPtr client, DeviceIntPtr pDev,
+ xDeviceCtl *control)
+{
+ switch (control->control) {
+ case DEVICE_RESOLUTION:
+ /* FIXME do something more intelligent here */
+ return BadMatch;
+
+ case DEVICE_ABS_CALIB:
+ case DEVICE_ABS_AREA:
+ return Success;
+
+ case DEVICE_CORE:
+ return BadMatch;
+ case DEVICE_ENABLE:
+ return Success;
+
+ default:
+ return BadMatch;
+ }
+
+ /* NOTREACHED */
+ return BadImplementation;
+}
+
+int
+NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
+{
+ InputOption *option = NULL;
+ KdPointerInfo *pi = NULL;
+ KdKeyboardInfo *ki = NULL;
+
+ for (option = options; option; option = option->next) {
+ if (strcmp(option->key, "type") == 0) {
+ if (strcmp(option->value, "pointer") == 0) {
+ pi = KdNewPointer();
+ if (!pi)
+ return BadAlloc;
+ }
+ else if (strcmp(option->value, "keyboard") == 0) {
+ ki = KdNewKeyboard();
+ if (!ki)
+ return BadAlloc;
+ }
+ else {
+ ErrorF("unrecognised device type!\n");
+ return BadValue;
+ }
+ }
+#ifdef CONFIG_HAL
+ else if (strcmp(option->key, "_source") == 0 &&
+ strcmp(option->value, "server/hal") == 0)
+ {
+ ErrorF("Ignoring device from HAL.\n");
+ return BadValue;
+ }
+#endif
+ }
+
+ if (!ki && !pi) {
+ ErrorF("unrecognised device identifier!\n");
+ return BadValue;
+ }
+
+ /* FIXME: change this code below to use KdParseKbdOptions and
+ * KdParsePointerOptions */
+ for (option = options; option; option = option->next) {
+ if (strcmp(option->key, "device") == 0) {
+ if (pi && option->value)
+ pi->path = strdup(option->value);
+ else if (ki && option->value)
+ ki->path = strdup(option->value);
+ }
+ else if (strcmp(option->key, "driver") == 0) {
+ if (pi) {
+ pi->driver = KdFindPointerDriver(option->value);
+ if (!pi->driver) {
+ ErrorF("couldn't find driver!\n");
+ KdFreePointer(pi);
+ return BadValue;
+ }
+ pi->options = options;
+ }
+ else if (ki) {
+ ki->driver = KdFindKeyboardDriver(option->value);
+ if (!ki->driver) {
+ ErrorF("couldn't find driver!\n");
+ KdFreeKeyboard(ki);
+ return BadValue;
+ }
+ ki->options = options;
+ }
+ }
+ }
+
+ if (pi) {
+ if (KdAddPointer(pi) != Success ||
+ ActivateDevice(pi->dixdev, TRUE) != Success ||
+ EnableDevice(pi->dixdev, TRUE) != TRUE) {
+ ErrorF("couldn't add or enable pointer\n");
+ return BadImplementation;
+ }
+ }
+ else if (ki) {
+ if (KdAddKeyboard(ki) != Success ||
+ ActivateDevice(ki->dixdev, TRUE) != Success ||
+ EnableDevice(ki->dixdev, TRUE) != TRUE) {
+ ErrorF("couldn't add or enable keyboard\n");
+ return BadImplementation;
+ }
+ }
+
+ if (pi) {
+ *pdev = pi->dixdev;
+ } else if(ki) {
+ *pdev = ki->dixdev;
+ }
+
+ return Success;
+}
+
+void
+DeleteInputDeviceRequest(DeviceIntPtr pDev)
+{
+ RemoveDevice(pDev, TRUE);
+}
diff --git a/xorg-server/hw/kdrive/src/kmap.c b/xorg-server/hw/kdrive/src/kmap.c
index 60e8ae134..a10c9ec09 100644
--- a/xorg-server/hw/kdrive/src/kmap.c
+++ b/xorg-server/hw/kdrive/src/kmap.c
@@ -24,6 +24,7 @@
#include "kdrive.h"
#include <errno.h>
+#ifndef _MSC_VER
#include <unistd.h>
#include <sys/mman.h>
#ifdef HAVE_ASM_MTRR_H
@@ -31,6 +32,9 @@
#endif
#include <sys/ioctl.h>
+#else
+#define DRAW_DEBUG(a)
+#endif
void *
KdMapDevice (CARD32 addr, CARD32 size)
@@ -39,7 +43,8 @@ KdMapDevice (CARD32 addr, CARD32 size)
void *a;
void *d;
- d = VirtualAlloc (NULL, size, MEM_RESERVE, PAGE_NOACCESS);
+ d = VirtualAlloc (NULL, size, MEM_RESERVE, PAGE_READWRITE|PAGE_NOCACHE);
+/*
if (!d)
return NULL;
DRAW_DEBUG ((DEBUG_S3INIT, "Virtual address of 0x%x is 0x%x", addr, d));
@@ -53,6 +58,8 @@ KdMapDevice (CARD32 addr, CARD32 size)
return NULL;
}
DRAW_DEBUG ((DEBUG_S3INIT, "Device mapped successfully"));
+*/
+ __asm int 3;
return d;
#endif
#ifdef linux
diff --git a/xorg-server/hw/kdrive/src/makefile b/xorg-server/hw/kdrive/src/makefile
new file mode 100644
index 000000000..e3a826faa
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/makefile
@@ -0,0 +1,14 @@
+LIBRARY = libkdrive
+
+CSRCS = \
+ kcmap.c \
+ kcurscol.c \
+ kdrive.c \
+ kinfo.c \
+ kinput.c \
+ kmap.c \
+ kmode.c \
+ kshadow.c
+
+
+
diff --git a/xorg-server/hw/xfree86/common/compiler.h b/xorg-server/hw/xfree86/common/compiler.h
index a450bd676..ae6a4615c 100644
--- a/xorg-server/hw/xfree86/common/compiler.h
+++ b/xorg-server/hw/xfree86/common/compiler.h
@@ -1,1361 +1,1361 @@
-/*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- *
- * 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 Thomas Roell not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Thomas Roell makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THOMAS ROELL 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.
- *
- */
-/*
- * Copyright (c) 1994-2003 by The XFree86 Project, Inc.
- *
- * 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, 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 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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 copyright holder(s)
- * and author(s) 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 copyright holder(s) and author(s).
- */
-
-#ifndef _COMPILER_H
-
-# define _COMPILER_H
-
-#if defined(__SUNPRO_C)
-# define DO_PROTOTYPES
-#endif
-
-#ifndef _X_EXPORT
-# include <X11/Xfuncproto.h>
-#endif
-
-# include <pixman.h> /* for uint*_t types */
-
-/* Allow drivers to use the GCC-supported __inline__ and/or __inline. */
-# ifndef __inline__
-# if defined(__GNUC__)
- /* gcc has __inline__ */
-# elif defined(__HIGHC__)
-# define __inline__ _Inline
-# else
-# define __inline__ /**/
-# endif
-# endif /* __inline__ */
-# ifndef __inline
-# if defined(__GNUC__)
- /* gcc has __inline */
-# elif defined(__HIGHC__)
-# define __inline _Inline
-# else
-# define __inline /**/
-# endif
-# endif /* __inline */
-
-/* Support gcc's __FUNCTION__ for people using other compilers */
-#if !defined(__GNUC__) && !defined(__FUNCTION__)
-# define __FUNCTION__ __func__ /* C99 */
-#endif
-
-# if defined(NO_INLINE) || defined(DO_PROTOTYPES)
-
-# if !defined(__arm__)
-# if !defined(__sparc__) && !defined(__sparc) && !defined(__arm32__) \
- && !(defined(__alpha__) && defined(linux)) \
- && !(defined(__ia64__) && defined(linux)) \
-
-extern _X_EXPORT void outb(unsigned short, unsigned char);
-extern _X_EXPORT void outw(unsigned short, unsigned short);
-extern _X_EXPORT void outl(unsigned short, unsigned int);
-extern _X_EXPORT unsigned int inb(unsigned short);
-extern _X_EXPORT unsigned int inw(unsigned short);
-extern _X_EXPORT unsigned int inl(unsigned short);
-
-# else /* __sparc__, __arm32__, __alpha__*/
-
-extern _X_EXPORT void outb(unsigned long, unsigned char);
-extern _X_EXPORT void outw(unsigned long, unsigned short);
-extern _X_EXPORT void outl(unsigned long, unsigned int);
-extern _X_EXPORT unsigned int inb(unsigned long);
-extern _X_EXPORT unsigned int inw(unsigned long);
-extern _X_EXPORT unsigned int inl(unsigned long);
-
-# endif /* __sparc__, __arm32__, __alpha__ */
-# endif /* __arm__ */
-
-# if defined(__powerpc__) && !defined(__OpenBSD__)
-extern unsigned long ldq_u(unsigned long *);
-extern unsigned long ldl_u(unsigned int *);
-extern unsigned long ldw_u(unsigned short *);
-extern void stq_u(unsigned long, unsigned long *);
-extern void stl_u(unsigned long, unsigned int *);
-extern void stw_u(unsigned long, unsigned short *);
-extern void mem_barrier(void);
-extern void write_mem_barrier(void);
-extern void stl_brx(unsigned long, volatile unsigned char *, int);
-extern void stw_brx(unsigned short, volatile unsigned char *, int);
-extern unsigned long ldl_brx(volatile unsigned char *, int);
-extern unsigned short ldw_brx(volatile unsigned char *, int);
-# endif /* __powerpc__ && !__OpenBSD */
-
-# endif /* NO_INLINE || DO_PROTOTYPES */
-
-# ifndef NO_INLINE
-# ifdef __GNUC__
-# ifdef __i386__
-
-# ifdef __SSE__
-# define write_mem_barrier() __asm__ __volatile__ ("sfence" : : : "memory")
-# else
-# define write_mem_barrier() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory")
-# endif
-
-# ifdef __SSE2__
-# define mem_barrier() __asm__ __volatile__ ("mfence" : : : "memory")
-# else
-# define mem_barrier() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory")
-# endif
-
-# elif defined __alpha__
-
-# define mem_barrier() __asm__ __volatile__ ("mb" : : : "memory")
-# define write_mem_barrier() __asm__ __volatile__ ("wmb" : : : "memory")
-
-# elif defined __amd64__
-
-# define mem_barrier() __asm__ __volatile__ ("mfence" : : : "memory")
-# define write_mem_barrier() __asm__ __volatile__ ("sfence" : : : "memory")
-
-# elif defined __ia64__
-
-# ifndef __INTEL_COMPILER
-# define mem_barrier() __asm__ __volatile__ ("mf" : : : "memory")
-# define write_mem_barrier() __asm__ __volatile__ ("mf" : : : "memory")
-# else
-# include "ia64intrin.h"
-# define mem_barrier() __mf()
-# define write_mem_barrier() __mf()
-# endif
-
-# elif defined __mips__
- /* Note: sync instruction requires MIPS II instruction set */
-# define mem_barrier() \
- __asm__ __volatile__( \
- ".set push\n\t" \
- ".set noreorder\n\t" \
- ".set mips2\n\t" \
- "sync\n\t" \
- ".set pop" \
- : /* no output */ \
- : /* no input */ \
- : "memory")
-# define write_mem_barrier() mem_barrier()
-
-# elif defined __powerpc__
-
-# if defined(linux) && defined(__powerpc64__)
-# include <linux/version.h>
-# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
-# include <asm/memory.h>
-# endif
-# endif /* defined(linux) && defined(__powerpc64__) */
-
-# ifndef eieio /* We deal with arch-specific eieio() routines above... */
-# define eieio() __asm__ __volatile__ ("eieio" ::: "memory")
-# endif /* eieio */
-# define mem_barrier() eieio()
-# define write_mem_barrier() eieio()
-
-# elif defined __sparc__
-
-# define barrier() __asm__ __volatile__ (".word 0x8143e00a" : : : "memory")
-# define mem_barrier() /* XXX: nop for now */
-# define write_mem_barrier() /* XXX: nop for now */
-# endif
-# endif /* __GNUC__ */
-# endif /* NO_INLINE */
-
-# ifndef mem_barrier
-# define mem_barrier() /* NOP */
-# endif
-
-# ifndef write_mem_barrier
-# define write_mem_barrier() /* NOP */
-# endif
-
-
-# ifndef NO_INLINE
-# ifdef __GNUC__
-
-/* Define some packed structures to use with unaligned accesses */
-
-struct __una_u64 { uint64_t x __attribute__((packed)); };
-struct __una_u32 { uint32_t x __attribute__((packed)); };
-struct __una_u16 { uint16_t x __attribute__((packed)); };
-
-/* Elemental unaligned loads */
-
-static __inline__ uint64_t ldq_u(uint64_t *p)
-{
- const struct __una_u64 *ptr = (const struct __una_u64 *) p;
- return ptr->x;
-}
-
-static __inline__ uint32_t ldl_u(uint32_t *p)
-{
- const struct __una_u32 *ptr = (const struct __una_u32 *) p;
- return ptr->x;
-}
-
-static __inline__ uint16_t ldw_u(uint16_t *p)
-{
- const struct __una_u16 *ptr = (const struct __una_u16 *) p;
- return ptr->x;
-}
-
-/* Elemental unaligned stores */
-
-static __inline__ void stq_u(uint64_t val, uint64_t *p)
-{
- struct __una_u64 *ptr = (struct __una_u64 *) p;
- ptr->x = val;
-}
-
-static __inline__ void stl_u(uint32_t val, uint32_t *p)
-{
- struct __una_u32 *ptr = (struct __una_u32 *) p;
- ptr->x = val;
-}
-
-static __inline__ void stw_u(uint16_t val, uint16_t *p)
-{
- struct __una_u16 *ptr = (struct __una_u16 *) p;
- ptr->x = val;
-}
-# else /* !__GNUC__ */
-
-#include <string.h> /* needed for memmove */
-
-static __inline__ uint64_t ldq_u(uint64_t *p)
-{
- uint64_t ret;
- memmove(&ret, p, sizeof(*p));
- return ret;
-}
-
-static __inline__ uint32_t ldl_u(uint32_t *p)
-{
- uint32_t ret;
- memmove(&ret, p, sizeof(*p));
- return ret;
-}
-
-static __inline__ uint16_t ldw_u(uint16_t *p)
-{
- uint16_t ret;
- memmove(&ret, p, sizeof(*p));
- return ret;
-}
-
-static __inline__ void stq_u(uint64_t val, uint64_t *p)
-{
- uint64_t tmp = val;
- memmove(p, &tmp, sizeof(*p));
-}
-
-static __inline__ void stl_u(uint32_t val, uint32_t *p)
-{
- uint32_t tmp = val;
- memmove(p, &tmp, sizeof(*p));
-}
-
-static __inline__ void stw_u(uint16_t val, uint16_t *p)
-{
- uint16_t tmp = val;
- memmove(p, &tmp, sizeof(*p));
-}
-
-# endif /* __GNUC__ */
-# endif /* NO_INLINE */
-
-# ifndef NO_INLINE
-# ifdef __GNUC__
-# if (defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) && (defined(__alpha__))
-
-# ifdef linux
-/* for Linux on Alpha, we use the LIBC _inx/_outx routines */
-/* note that the appropriate setup via "ioperm" needs to be done */
-/* *before* any inx/outx is done. */
-
-extern _X_EXPORT void (*_alpha_outb)(char val, unsigned long port);
-static __inline__ void
-outb(unsigned long port, unsigned char val)
-{
- _alpha_outb(val, port);
-}
-
-extern _X_EXPORT void (*_alpha_outw)(short val, unsigned long port);
-static __inline__ void
-outw(unsigned long port, unsigned short val)
-{
- _alpha_outw(val, port);
-}
-
-extern _X_EXPORT void (*_alpha_outl)(int val, unsigned long port);
-static __inline__ void
-outl(unsigned long port, unsigned int val)
-{
- _alpha_outl(val, port);
-}
-
-extern _X_EXPORT unsigned int (*_alpha_inb)(unsigned long port);
-static __inline__ unsigned int
-inb(unsigned long port)
-{
- return _alpha_inb(port);
-}
-
-extern _X_EXPORT unsigned int (*_alpha_inw)(unsigned long port);
-static __inline__ unsigned int
-inw(unsigned long port)
-{
- return _alpha_inw(port);
-}
-
-extern _X_EXPORT unsigned int (*_alpha_inl)(unsigned long port);
-static __inline__ unsigned int
-inl(unsigned long port)
-{
- return _alpha_inl(port);
-}
-
-# endif /* linux */
-
-# if (defined(__FreeBSD__) || defined(__OpenBSD__)) \
- && !defined(DO_PROTOTYPES)
-
-/* for FreeBSD and OpenBSD on Alpha, we use the libio (resp. libalpha) */
-/* inx/outx routines */
-/* note that the appropriate setup via "ioperm" needs to be done */
-/* *before* any inx/outx is done. */
-
-extern _X_EXPORT void outb(unsigned int port, unsigned char val);
-extern _X_EXPORT void outw(unsigned int port, unsigned short val);
-extern _X_EXPORT void outl(unsigned int port, unsigned int val);
-extern _X_EXPORT unsigned char inb(unsigned int port);
-extern _X_EXPORT unsigned short inw(unsigned int port);
-extern _X_EXPORT unsigned int inl(unsigned int port);
-
-# endif /* (__FreeBSD__ || __OpenBSD__ ) && !DO_PROTOTYPES */
-
-
-#if defined(__NetBSD__)
-#include <machine/pio.h>
-#endif /* __NetBSD__ */
-
-# elif defined(linux) && defined(__ia64__)
-
-# include <inttypes.h>
-
-# include <sys/io.h>
-
-# undef outb
-# undef outw
-# undef outl
-# undef inb
-# undef inw
-# undef inl
-extern _X_EXPORT void outb(unsigned long port, unsigned char val);
-extern _X_EXPORT void outw(unsigned long port, unsigned short val);
-extern _X_EXPORT void outl(unsigned long port, unsigned int val);
-extern _X_EXPORT unsigned int inb(unsigned long port);
-extern _X_EXPORT unsigned int inw(unsigned long port);
-extern _X_EXPORT unsigned int inl(unsigned long port);
-
-# elif (defined(linux) || defined(__FreeBSD__)) && defined(__amd64__)
-
-# include <inttypes.h>
-
-static __inline__ void
-outb(unsigned short port, unsigned char val)
-{
- __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
-}
-
-
-static __inline__ void
-outw(unsigned short port, unsigned short val)
-{
- __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
-}
-
-static __inline__ void
-outl(unsigned short port, unsigned int val)
-{
- __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
-}
-
-static __inline__ unsigned int
-inb(unsigned short port)
-{
- unsigned char ret;
- __asm__ __volatile__("inb %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-static __inline__ unsigned int
-inw(unsigned short port)
-{
- unsigned short ret;
- __asm__ __volatile__("inw %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-static __inline__ unsigned int
-inl(unsigned short port)
-{
- unsigned int ret;
- __asm__ __volatile__("inl %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-# elif (defined(linux) || defined(sun) || defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc__)
-
-# ifndef ASI_PL
-# define ASI_PL 0x88
-# endif
-
-static __inline__ void
-outb(unsigned long port, unsigned char val)
-{
- __asm__ __volatile__("stba %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (port), "i" (ASI_PL));
- barrier();
-}
-
-static __inline__ void
-outw(unsigned long port, unsigned short val)
-{
- __asm__ __volatile__("stha %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (port), "i" (ASI_PL));
- barrier();
-}
-
-static __inline__ void
-outl(unsigned long port, unsigned int val)
-{
- __asm__ __volatile__("sta %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (port), "i" (ASI_PL));
- barrier();
-}
-
-static __inline__ unsigned int
-inb(unsigned long port)
-{
- unsigned int ret;
- __asm__ __volatile__("lduba [%1] %2, %0"
- : "=r" (ret)
- : "r" (port), "i" (ASI_PL));
- return ret;
-}
-
-static __inline__ unsigned int
-inw(unsigned long port)
-{
- unsigned int ret;
- __asm__ __volatile__("lduha [%1] %2, %0"
- : "=r" (ret)
- : "r" (port), "i" (ASI_PL));
- return ret;
-}
-
-static __inline__ unsigned int
-inl(unsigned long port)
-{
- unsigned int ret;
- __asm__ __volatile__("lda [%1] %2, %0"
- : "=r" (ret)
- : "r" (port), "i" (ASI_PL));
- return ret;
-}
-
-static __inline__ unsigned char
-xf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
-{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned char ret;
-
- __asm__ __volatile__("lduba [%1] %2, %0"
- : "=r" (ret)
- : "r" (addr), "i" (ASI_PL));
- return ret;
-}
-
-static __inline__ unsigned short
-xf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset)
-{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned short ret;
-
- __asm__ __volatile__("lduh [%1], %0"
- : "=r" (ret)
- : "r" (addr));
- return ret;
-}
-
-static __inline__ unsigned short
-xf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset)
-{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned short ret;
-
- __asm__ __volatile__("lduha [%1] %2, %0"
- : "=r" (ret)
- : "r" (addr), "i" (ASI_PL));
- return ret;
-}
-
-static __inline__ unsigned int
-xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
-{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned int ret;
-
- __asm__ __volatile__("ld [%1], %0"
- : "=r" (ret)
- : "r" (addr));
- return ret;
-}
-
-static __inline__ unsigned int
-xf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset)
-{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned int ret;
-
- __asm__ __volatile__("lda [%1] %2, %0"
- : "=r" (ret)
- : "r" (addr), "i" (ASI_PL));
- return ret;
-}
-
-static __inline__ void
-xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("stba %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("sth %0, [%1]"
- : /* No outputs */
- : "r" (val), "r" (addr));
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("stha %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("st %0, [%1]"
- : /* No outputs */
- : "r" (val), "r" (addr));
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("sta %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio8NB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("stba %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
-}
-
-static __inline__ void
-xf86WriteMmio16BeNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("sth %0, [%1]"
- : /* No outputs */
- : "r" (val), "r" (addr));
-}
-
-static __inline__ void
-xf86WriteMmio16LeNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("stha %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
-}
-
-static __inline__ void
-xf86WriteMmio32BeNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("st %0, [%1]"
- : /* No outputs */
- : "r" (val), "r" (addr));
-}
-
-static __inline__ void
-xf86WriteMmio32LeNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("sta %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
-}
-
-# elif defined(__mips__) || (defined(__arm32__) && !defined(__linux__))
-# ifdef __arm32__
-# define PORT_SIZE long
-# else
-# define PORT_SIZE short
-# endif
-
-_X_EXPORT unsigned int IOPortBase; /* Memory mapped I/O port area */
-
-static __inline__ void
-outb(unsigned PORT_SIZE port, unsigned char val)
-{
- *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
-}
-
-static __inline__ void
-outw(unsigned PORT_SIZE port, unsigned short val)
-{
- *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
-}
-
-static __inline__ void
-outl(unsigned PORT_SIZE port, unsigned int val)
-{
- *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
-}
-
-static __inline__ unsigned int
-inb(unsigned PORT_SIZE port)
-{
- return *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase);
-}
-
-static __inline__ unsigned int
-inw(unsigned PORT_SIZE port)
-{
- return *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase);
-}
-
-static __inline__ unsigned int
-inl(unsigned PORT_SIZE port)
-{
- return *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase);
-}
-
-
-# if defined(__mips__)
-# ifdef linux /* don't mess with other OSs */
-# if X_BYTE_ORDER == X_BIG_ENDIAN
-static __inline__ unsigned int
-xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
-{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned int ret;
-
- __asm__ __volatile__("lw %0, 0(%1)"
- : "=r" (ret)
- : "r" (addr));
- return ret;
-}
-
-static __inline__ void
-xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("sw %0, 0(%1)"
- : /* No outputs */
- : "r" (val), "r" (addr));
-}
-# endif
-# endif /* !linux */
-# endif /* __mips__ */
-
-# elif (defined(linux) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)) && defined(__powerpc__)
-
-# ifndef MAP_FAILED
-# define MAP_FAILED ((void *)-1)
-# endif
-
-extern _X_EXPORT volatile unsigned char *ioBase;
-
-static __inline__ unsigned char
-xf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
-{
- register unsigned char val;
- __asm__ __volatile__(
- "lbzx %0,%1,%2\n\t"
- "eieio"
- : "=r" (val)
- : "b" (base), "r" (offset),
- "m" (*((volatile unsigned char *)base+offset)));
- return val;
-}
-
-static __inline__ unsigned short
-xf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset)
-{
- register unsigned short val;
- __asm__ __volatile__(
- "lhzx %0,%1,%2\n\t"
- "eieio"
- : "=r" (val)
- : "b" (base), "r" (offset),
- "m" (*((volatile unsigned char *)base+offset)));
- return val;
-}
-
-static __inline__ unsigned short
-xf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset)
-{
- register unsigned short val;
- __asm__ __volatile__(
- "lhbrx %0,%1,%2\n\t"
- "eieio"
- : "=r" (val)
- : "b" (base), "r" (offset),
- "m" (*((volatile unsigned char *)base+offset)));
- return val;
-}
-
-static __inline__ unsigned int
-xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
-{
- register unsigned int val;
- __asm__ __volatile__(
- "lwzx %0,%1,%2\n\t"
- "eieio"
- : "=r" (val)
- : "b" (base), "r" (offset),
- "m" (*((volatile unsigned char *)base+offset)));
- return val;
-}
-
-static __inline__ unsigned int
-xf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset)
-{
- register unsigned int val;
- __asm__ __volatile__(
- "lwbrx %0,%1,%2\n\t"
- "eieio"
- : "=r" (val)
- : "b" (base), "r" (offset),
- "m" (*((volatile unsigned char *)base+offset)));
- return val;
-}
-
-static __inline__ void
-xf86WriteMmioNB8(__volatile__ void *base, const unsigned long offset,
- const unsigned char val)
-{
- __asm__ __volatile__(
- "stbx %1,%2,%3\n\t"
- : "=m" (*((volatile unsigned char *)base+offset))
- : "r" (val), "b" (base), "r" (offset));
-}
-
-static __inline__ void
-xf86WriteMmioNB16Le(__volatile__ void *base, const unsigned long offset,
- const unsigned short val)
-{
- __asm__ __volatile__(
- "sthbrx %1,%2,%3\n\t"
- : "=m" (*((volatile unsigned char *)base+offset))
- : "r" (val), "b" (base), "r" (offset));
-}
-
-static __inline__ void
-xf86WriteMmioNB16Be(__volatile__ void *base, const unsigned long offset,
- const unsigned short val)
-{
- __asm__ __volatile__(
- "sthx %1,%2,%3\n\t"
- : "=m" (*((volatile unsigned char *)base+offset))
- : "r" (val), "b" (base), "r" (offset));
-}
-
-static __inline__ void
-xf86WriteMmioNB32Le(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- __asm__ __volatile__(
- "stwbrx %1,%2,%3\n\t"
- : "=m" (*((volatile unsigned char *)base+offset))
- : "r" (val), "b" (base), "r" (offset));
-}
-
-static __inline__ void
-xf86WriteMmioNB32Be(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- __asm__ __volatile__(
- "stwx %1,%2,%3\n\t"
- : "=m" (*((volatile unsigned char *)base+offset))
- : "r" (val), "b" (base), "r" (offset));
-}
-
-static __inline__ void
-xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
- const unsigned char val)
-{
- xf86WriteMmioNB8(base, offset, val);
- eieio();
-}
-
-static __inline__ void
-xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset,
- const unsigned short val)
-{
- xf86WriteMmioNB16Le(base, offset, val);
- eieio();
-}
-
-static __inline__ void
-xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset,
- const unsigned short val)
-{
- xf86WriteMmioNB16Be(base, offset, val);
- eieio();
-}
-
-static __inline__ void
-xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- xf86WriteMmioNB32Le(base, offset, val);
- eieio();
-}
-
-static __inline__ void
-xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- xf86WriteMmioNB32Be(base, offset, val);
- eieio();
-}
-
-
-static __inline__ void
-outb(unsigned short port, unsigned char value)
-{
- if(ioBase == MAP_FAILED) return;
- xf86WriteMmio8((void *)ioBase, port, value);
-}
-
-static __inline__ void
-outw(unsigned short port, unsigned short value)
-{
- if(ioBase == MAP_FAILED) return;
- xf86WriteMmio16Le((void *)ioBase, port, value);
-}
-
-static __inline__ void
-outl(unsigned short port, unsigned int value)
-{
- if(ioBase == MAP_FAILED) return;
- xf86WriteMmio32Le((void *)ioBase, port, value);
-}
-
-static __inline__ unsigned int
-inb(unsigned short port)
-{
- if(ioBase == MAP_FAILED) return 0;
- return xf86ReadMmio8((void *)ioBase, port);
-}
-
-static __inline__ unsigned int
-inw(unsigned short port)
-{
- if(ioBase == MAP_FAILED) return 0;
- return xf86ReadMmio16Le((void *)ioBase, port);
-}
-
-static __inline__ unsigned int
-inl(unsigned short port)
-{
- if(ioBase == MAP_FAILED) return 0;
- return xf86ReadMmio32Le((void *)ioBase, port);
-}
-
-#elif defined(__arm__) && defined(__linux__)
-
-/* for Linux on ARM, we use the LIBC inx/outx routines */
-/* note that the appropriate setup via "ioperm" needs to be done */
-/* *before* any inx/outx is done. */
-
-#include <sys/io.h>
-
-static __inline__ void
-xf_outb(unsigned short port, unsigned char val)
-{
- outb(val, port);
-}
-
-static __inline__ void
-xf_outw(unsigned short port, unsigned short val)
-{
- outw(val, port);
-}
-
-static __inline__ void
-xf_outl(unsigned short port, unsigned int val)
-{
- outl(val, port);
-}
-
-#define outb xf_outb
-#define outw xf_outw
-#define outl xf_outl
-
-# else /* ix86 */
-
-# if !defined(__SUNPRO_C)
-# if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__m32r__)
-# ifdef GCCUSESGAS
-
-/*
- * If gcc uses gas rather than the native assembler, the syntax of these
- * inlines has to be different. DHD
- */
-
-static __inline__ void
-outb(unsigned short port, unsigned char val)
-{
- __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
-}
-
-
-static __inline__ void
-outw(unsigned short port, unsigned short val)
-{
- __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
-}
-
-static __inline__ void
-outl(unsigned short port, unsigned int val)
-{
- __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
-}
-
-static __inline__ unsigned int
-inb(unsigned short port)
-{
- unsigned char ret;
- __asm__ __volatile__("inb %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-static __inline__ unsigned int
-inw(unsigned short port)
-{
- unsigned short ret;
- __asm__ __volatile__("inw %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-static __inline__ unsigned int
-inl(unsigned short port)
-{
- unsigned int ret;
- __asm__ __volatile__("inl %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-# else /* GCCUSESGAS */
-
-static __inline__ void
-outb(unsigned short port, unsigned char val)
-{
- __asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port));
-}
-
-static __inline__ void
-outw(unsigned short port, unsigned short val)
-{
- __asm__ __volatile__("out%W0 (%1)" : :"a" (val), "d" (port));
-}
-
-static __inline__ void
-outl(unsigned short port, unsigned int val)
-{
- __asm__ __volatile__("out%L0 (%1)" : :"a" (val), "d" (port));
-}
-
-static __inline__ unsigned int
-inb(unsigned short port)
-{
- unsigned char ret;
- __asm__ __volatile__("in%B0 (%1)" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-static __inline__ unsigned int
-inw(unsigned short port)
-{
- unsigned short ret;
- __asm__ __volatile__("in%W0 (%1)" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-static __inline__ unsigned int
-inl(unsigned short port)
-{
- unsigned int ret;
- __asm__ __volatile__("in%L0 (%1)" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-# endif /* GCCUSESGAS */
-
-# else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__m32r__) */
-
-static __inline__ void
-outb(unsigned short port, unsigned char val)
-{
-}
-
-static __inline__ void
-outw(unsigned short port, unsigned short val)
-{
-}
-
-static __inline__ void
-outl(unsigned short port, unsigned int val)
-{
-}
-
-static __inline__ unsigned int
-inb(unsigned short port)
-{
- return 0;
-}
-
-static __inline__ unsigned int
-inw(unsigned short port)
-{
- return 0;
-}
-
-static __inline__ unsigned int
-inl(unsigned short port)
-{
- return 0;
-}
-
-# endif /* FAKEIT */
-# endif /* __SUNPRO_C */
-
-# endif /* ix86 */
-
-# else /* !GNUC */
-# if defined(__STDC__) && (__STDC__ == 1)
-# ifndef asm
-# define asm __asm
-# endif
-# endif
-# ifndef SCO325
-# if defined(__UNIXWARE__)
-# /* avoid including <sys/types.h> for <sys/inline.h> on UnixWare */
-# define ushort unsigned short
-# define ushort_t unsigned short
-# define ulong unsigned long
-# define ulong_t unsigned long
-# define uint_t unsigned int
-# define uchar_t unsigned char
-# endif /* __UNIXWARE__ */
-# if !defined(__SUNPRO_C)
-# include <sys/inline.h>
-# endif
-# else
-# include "scoasm.h"
-# endif
-# if !defined(__HIGHC__) && !defined(__SUNPRO_C) || \
- defined(__USLC__)
-# pragma asm partial_optimization outl
-# pragma asm partial_optimization outw
-# pragma asm partial_optimization outb
-# pragma asm partial_optimization inl
-# pragma asm partial_optimization inw
-# pragma asm partial_optimization inb
-# endif
-# endif /* __GNUC__ */
-
-# endif /* NO_INLINE */
-
-# ifdef __alpha__
-/* entry points for Mmio memory access routines */
-extern _X_EXPORT int (*xf86ReadMmio8)(void *, unsigned long);
-extern _X_EXPORT int (*xf86ReadMmio16)(void *, unsigned long);
-# ifndef STANDALONE_MMIO
-extern _X_EXPORT int (*xf86ReadMmio32)(void *, unsigned long);
-# else
-/* Some DRI 3D drivers need MMIO_IN32. */
-static __inline__ int
-xf86ReadMmio32(void *Base, unsigned long Offset)
-{
- mem_barrier();
- return *(volatile unsigned int*)((unsigned long)Base+(Offset));
-}
-# endif
-extern _X_EXPORT void (*xf86WriteMmio8)(int, void *, unsigned long);
-extern _X_EXPORT void (*xf86WriteMmio16)(int, void *, unsigned long);
-extern _X_EXPORT void (*xf86WriteMmio32)(int, void *, unsigned long);
-extern _X_EXPORT void (*xf86WriteMmioNB8)(int, void *, unsigned long);
-extern _X_EXPORT void (*xf86WriteMmioNB16)(int, void *, unsigned long);
-extern _X_EXPORT void (*xf86WriteMmioNB32)(int, void *, unsigned long);
-extern _X_EXPORT void xf86SlowBCopyFromBus(unsigned char *, unsigned char *, int);
-extern _X_EXPORT void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int);
-
-/* Some macros to hide the system dependencies for MMIO accesses */
-/* Changed to kill noise generated by gcc's -Wcast-align */
-# define MMIO_IN8(base, offset) (*xf86ReadMmio8)(base, offset)
-# define MMIO_IN16(base, offset) (*xf86ReadMmio16)(base, offset)
-# ifndef STANDALONE_MMIO
-# define MMIO_IN32(base, offset) (*xf86ReadMmio32)(base, offset)
-# else
-# define MMIO_IN32(base, offset) xf86ReadMmio32(base, offset)
-# endif
-
-# define MMIO_OUT32(base, offset, val) \
- do { \
- write_mem_barrier(); \
- *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val); \
- } while (0)
-# define MMIO_ONB32(base, offset, val) \
- *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
-
-# define MMIO_OUT8(base, offset, val) \
- (*xf86WriteMmio8)((CARD8)(val), base, offset)
-# define MMIO_OUT16(base, offset, val) \
- (*xf86WriteMmio16)((CARD16)(val), base, offset)
-# define MMIO_ONB8(base, offset, val) \
- (*xf86WriteMmioNB8)((CARD8)(val), base, offset)
-# define MMIO_ONB16(base, offset, val) \
- (*xf86WriteMmioNB16)((CARD16)(val), base, offset)
-# define MMIO_MOVE32(base, offset, val) \
- MMIO_OUT32(base, offset, val)
-
-# elif defined(__powerpc__)
- /*
- * we provide byteswapping and no byteswapping functions here
- * with byteswapping as default,
- * drivers that don't need byteswapping should define PPC_MMIO_IS_BE
- */
-# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
-# define MMIO_OUT8(base, offset, val) \
- xf86WriteMmio8(base, offset, (CARD8)(val))
-# define MMIO_ONB8(base, offset, val) \
- xf86WriteMmioNB8(base, offset, (CARD8)(val))
-
-# if defined(PPC_MMIO_IS_BE) /* No byteswapping */
-# define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
-# define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
-# define MMIO_OUT16(base, offset, val) \
- xf86WriteMmio16Be(base, offset, (CARD16)(val))
-# define MMIO_OUT32(base, offset, val) \
- xf86WriteMmio32Be(base, offset, (CARD32)(val))
-# define MMIO_ONB16(base, offset, val) \
- xf86WriteMmioNB16Be(base, offset, (CARD16)(val))
-# define MMIO_ONB32(base, offset, val) \
- xf86WriteMmioNB32Be(base, offset, (CARD32)(val))
-# else /* byteswapping is the default */
-# define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset)
-# define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset)
-# define MMIO_OUT16(base, offset, val) \
- xf86WriteMmio16Le(base, offset, (CARD16)(val))
-# define MMIO_OUT32(base, offset, val) \
- xf86WriteMmio32Le(base, offset, (CARD32)(val))
-# define MMIO_ONB16(base, offset, val) \
- xf86WriteMmioNB16Le(base, offset, (CARD16)(val))
-# define MMIO_ONB32(base, offset, val) \
- xf86WriteMmioNB32Le(base, offset, (CARD32)(val))
-# endif
-
-# define MMIO_MOVE32(base, offset, val) \
- xf86WriteMmio32Be(base, offset, (CARD32)(val))
-
-# elif defined(__sparc__) || defined(sparc) || defined(__sparc)
- /*
- * Like powerpc, we provide byteswapping and no byteswapping functions
- * here with byteswapping as default, drivers that don't need byteswapping
- * should define SPARC_MMIO_IS_BE (perhaps create a generic macro so that we
- * do not need to use PPC_MMIO_IS_BE and the sparc one in all the same places
- * of drivers?).
- */
-# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
-# define MMIO_OUT8(base, offset, val) \
- xf86WriteMmio8(base, offset, (CARD8)(val))
-# define MMIO_ONB8(base, offset, val) \
- xf86WriteMmio8NB(base, offset, (CARD8)(val))
-
-# if defined(SPARC_MMIO_IS_BE) /* No byteswapping */
-# define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
-# define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
-# define MMIO_OUT16(base, offset, val) \
- xf86WriteMmio16Be(base, offset, (CARD16)(val))
-# define MMIO_OUT32(base, offset, val) \
- xf86WriteMmio32Be(base, offset, (CARD32)(val))
-# define MMIO_ONB16(base, offset, val) \
- xf86WriteMmio16BeNB(base, offset, (CARD16)(val))
-# define MMIO_ONB32(base, offset, val) \
- xf86WriteMmio32BeNB(base, offset, (CARD32)(val))
-# else /* byteswapping is the default */
-# define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset)
-# define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset)
-# define MMIO_OUT16(base, offset, val) \
- xf86WriteMmio16Le(base, offset, (CARD16)(val))
-# define MMIO_OUT32(base, offset, val) \
- xf86WriteMmio32Le(base, offset, (CARD32)(val))
-# define MMIO_ONB16(base, offset, val) \
- xf86WriteMmio16LeNB(base, offset, (CARD16)(val))
-# define MMIO_ONB32(base, offset, val) \
- xf86WriteMmio32LeNB(base, offset, (CARD32)(val))
-# endif
-
-# define MMIO_MOVE32(base, offset, val) \
- xf86WriteMmio32Be(base, offset, (CARD32)(val))
-
-# else /* !__alpha__ && !__powerpc__ && !__sparc__ */
-
-# define MMIO_IN8(base, offset) \
- *(volatile CARD8 *)(((CARD8*)(base)) + (offset))
-# define MMIO_IN16(base, offset) \
- *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset))
-# define MMIO_IN32(base, offset) \
- *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset))
-# define MMIO_OUT8(base, offset, val) \
- *(volatile CARD8 *)(((CARD8*)(base)) + (offset)) = (val)
-# define MMIO_OUT16(base, offset, val) \
- *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
-# define MMIO_OUT32(base, offset, val) \
- *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
-# define MMIO_ONB8(base, offset, val) MMIO_OUT8(base, offset, val)
-# define MMIO_ONB16(base, offset, val) MMIO_OUT16(base, offset, val)
-# define MMIO_ONB32(base, offset, val) MMIO_OUT32(base, offset, val)
-
-# define MMIO_MOVE32(base, offset, val) MMIO_OUT32(base, offset, val)
-
-# endif /* __alpha__ */
-
-/*
- * With Intel, the version in os-support/misc/SlowBcopy.s is used.
- * This avoids port I/O during the copy (which causes problems with
- * some hardware).
- */
-# ifdef __alpha__
-# define slowbcopy_tobus(src,dst,count) xf86SlowBCopyToBus(src,dst,count)
-# define slowbcopy_frombus(src,dst,count) xf86SlowBCopyFromBus(src,dst,count)
-# else /* __alpha__ */
-# define slowbcopy_tobus(src,dst,count) xf86SlowBcopy(src,dst,count)
-# define slowbcopy_frombus(src,dst,count) xf86SlowBcopy(src,dst,count)
-# endif /* __alpha__ */
-
-#endif /* _COMPILER_H */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * 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 Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Roell makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL 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.
+ *
+ */
+/*
+ * Copyright (c) 1994-2003 by The XFree86 Project, Inc.
+ *
+ * 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, 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 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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 copyright holder(s)
+ * and author(s) 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 copyright holder(s) and author(s).
+ */
+
+#ifndef _COMPILER_H
+
+# define _COMPILER_H
+
+#if defined(__SUNPRO_C)
+# define DO_PROTOTYPES
+#endif
+
+#ifndef _X_EXPORT
+# include <X11/Xfuncproto.h>
+#endif
+
+# include <pixman.h> /* for uint*_t types */
+
+/* Allow drivers to use the GCC-supported __inline__ and/or __inline. */
+# ifndef __inline__
+# if defined(__GNUC__)
+ /* gcc has __inline__ */
+# elif defined(__HIGHC__)
+# define __inline__ _Inline
+# else
+# define __inline__ /**/
+# endif
+# endif /* __inline__ */
+# ifndef __inline
+# if defined(__GNUC__) || defined(_MSC_VER)
+ /* gcc has __inline */
+# elif defined(__HIGHC__)
+# define __inline _Inline
+# else
+# define __inline /**/
+# endif
+# endif /* __inline */
+
+/* Support gcc's __FUNCTION__ for people using other compilers */
+#if !defined(__GNUC__) && !defined(__FUNCTION__)
+# define __FUNCTION__ __func__ /* C99 */
+#endif
+
+# if defined(NO_INLINE) || defined(DO_PROTOTYPES)
+
+# if !defined(__arm__)
+# if !defined(__sparc__) && !defined(__sparc) && !defined(__arm32__) \
+ && !(defined(__alpha__) && defined(linux)) \
+ && !(defined(__ia64__) && defined(linux)) \
+
+extern _X_EXPORT void outb(unsigned short, unsigned char);
+extern _X_EXPORT void outw(unsigned short, unsigned short);
+extern _X_EXPORT void outl(unsigned short, unsigned int);
+extern _X_EXPORT unsigned int inb(unsigned short);
+extern _X_EXPORT unsigned int inw(unsigned short);
+extern _X_EXPORT unsigned int inl(unsigned short);
+
+# else /* __sparc__, __arm32__, __alpha__*/
+
+extern _X_EXPORT void outb(unsigned long, unsigned char);
+extern _X_EXPORT void outw(unsigned long, unsigned short);
+extern _X_EXPORT void outl(unsigned long, unsigned int);
+extern _X_EXPORT unsigned int inb(unsigned long);
+extern _X_EXPORT unsigned int inw(unsigned long);
+extern _X_EXPORT unsigned int inl(unsigned long);
+
+# endif /* __sparc__, __arm32__, __alpha__ */
+# endif /* __arm__ */
+
+# if defined(__powerpc__) && !defined(__OpenBSD__)
+extern unsigned long ldq_u(unsigned long *);
+extern unsigned long ldl_u(unsigned int *);
+extern unsigned long ldw_u(unsigned short *);
+extern void stq_u(unsigned long, unsigned long *);
+extern void stl_u(unsigned long, unsigned int *);
+extern void stw_u(unsigned long, unsigned short *);
+extern void mem_barrier(void);
+extern void write_mem_barrier(void);
+extern void stl_brx(unsigned long, volatile unsigned char *, int);
+extern void stw_brx(unsigned short, volatile unsigned char *, int);
+extern unsigned long ldl_brx(volatile unsigned char *, int);
+extern unsigned short ldw_brx(volatile unsigned char *, int);
+# endif /* __powerpc__ && !__OpenBSD */
+
+# endif /* NO_INLINE || DO_PROTOTYPES */
+
+# ifndef NO_INLINE
+# ifdef __GNUC__
+# ifdef __i386__
+
+# ifdef __SSE__
+# define write_mem_barrier() __asm__ __volatile__ ("sfence" : : : "memory")
+# else
+# define write_mem_barrier() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory")
+# endif
+
+# ifdef __SSE2__
+# define mem_barrier() __asm__ __volatile__ ("mfence" : : : "memory")
+# else
+# define mem_barrier() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory")
+# endif
+
+# elif defined __alpha__
+
+# define mem_barrier() __asm__ __volatile__ ("mb" : : : "memory")
+# define write_mem_barrier() __asm__ __volatile__ ("wmb" : : : "memory")
+
+# elif defined __amd64__
+
+# define mem_barrier() __asm__ __volatile__ ("mfence" : : : "memory")
+# define write_mem_barrier() __asm__ __volatile__ ("sfence" : : : "memory")
+
+# elif defined __ia64__
+
+# ifndef __INTEL_COMPILER
+# define mem_barrier() __asm__ __volatile__ ("mf" : : : "memory")
+# define write_mem_barrier() __asm__ __volatile__ ("mf" : : : "memory")
+# else
+# include "ia64intrin.h"
+# define mem_barrier() __mf()
+# define write_mem_barrier() __mf()
+# endif
+
+# elif defined __mips__
+ /* Note: sync instruction requires MIPS II instruction set */
+# define mem_barrier() \
+ __asm__ __volatile__( \
+ ".set push\n\t" \
+ ".set noreorder\n\t" \
+ ".set mips2\n\t" \
+ "sync\n\t" \
+ ".set pop" \
+ : /* no output */ \
+ : /* no input */ \
+ : "memory")
+# define write_mem_barrier() mem_barrier()
+
+# elif defined __powerpc__
+
+# if defined(linux) && defined(__powerpc64__)
+# include <linux/version.h>
+# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
+# include <asm/memory.h>
+# endif
+# endif /* defined(linux) && defined(__powerpc64__) */
+
+# ifndef eieio /* We deal with arch-specific eieio() routines above... */
+# define eieio() __asm__ __volatile__ ("eieio" ::: "memory")
+# endif /* eieio */
+# define mem_barrier() eieio()
+# define write_mem_barrier() eieio()
+
+# elif defined __sparc__
+
+# define barrier() __asm__ __volatile__ (".word 0x8143e00a" : : : "memory")
+# define mem_barrier() /* XXX: nop for now */
+# define write_mem_barrier() /* XXX: nop for now */
+# endif
+# endif /* __GNUC__ */
+# endif /* NO_INLINE */
+
+# ifndef mem_barrier
+# define mem_barrier() /* NOP */
+# endif
+
+# ifndef write_mem_barrier
+# define write_mem_barrier() /* NOP */
+# endif
+
+
+# ifndef NO_INLINE
+# ifdef __GNUC__
+
+/* Define some packed structures to use with unaligned accesses */
+
+struct __una_u64 { uint64_t x __attribute__((packed)); };
+struct __una_u32 { uint32_t x __attribute__((packed)); };
+struct __una_u16 { uint16_t x __attribute__((packed)); };
+
+/* Elemental unaligned loads */
+
+static __inline__ uint64_t ldq_u(uint64_t *p)
+{
+ const struct __una_u64 *ptr = (const struct __una_u64 *) p;
+ return ptr->x;
+}
+
+static __inline__ uint32_t ldl_u(uint32_t *p)
+{
+ const struct __una_u32 *ptr = (const struct __una_u32 *) p;
+ return ptr->x;
+}
+
+static __inline__ uint16_t ldw_u(uint16_t *p)
+{
+ const struct __una_u16 *ptr = (const struct __una_u16 *) p;
+ return ptr->x;
+}
+
+/* Elemental unaligned stores */
+
+static __inline__ void stq_u(uint64_t val, uint64_t *p)
+{
+ struct __una_u64 *ptr = (struct __una_u64 *) p;
+ ptr->x = val;
+}
+
+static __inline__ void stl_u(uint32_t val, uint32_t *p)
+{
+ struct __una_u32 *ptr = (struct __una_u32 *) p;
+ ptr->x = val;
+}
+
+static __inline__ void stw_u(uint16_t val, uint16_t *p)
+{
+ struct __una_u16 *ptr = (struct __una_u16 *) p;
+ ptr->x = val;
+}
+# else /* !__GNUC__ */
+
+#include <string.h> /* needed for memmove */
+
+static __inline__ uint64_t ldq_u(uint64_t *p)
+{
+ uint64_t ret;
+ memmove(&ret, p, sizeof(*p));
+ return ret;
+}
+
+static __inline__ uint32_t ldl_u(uint32_t *p)
+{
+ uint32_t ret;
+ memmove(&ret, p, sizeof(*p));
+ return ret;
+}
+
+static __inline__ uint16_t ldw_u(uint16_t *p)
+{
+ uint16_t ret;
+ memmove(&ret, p, sizeof(*p));
+ return ret;
+}
+
+static __inline__ void stq_u(uint64_t val, uint64_t *p)
+{
+ uint64_t tmp = val;
+ memmove(p, &tmp, sizeof(*p));
+}
+
+static __inline__ void stl_u(uint32_t val, uint32_t *p)
+{
+ uint32_t tmp = val;
+ memmove(p, &tmp, sizeof(*p));
+}
+
+static __inline__ void stw_u(uint16_t val, uint16_t *p)
+{
+ uint16_t tmp = val;
+ memmove(p, &tmp, sizeof(*p));
+}
+
+# endif /* __GNUC__ */
+# endif /* NO_INLINE */
+
+# ifndef NO_INLINE
+# ifdef __GNUC__
+# if (defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) && (defined(__alpha__))
+
+# ifdef linux
+/* for Linux on Alpha, we use the LIBC _inx/_outx routines */
+/* note that the appropriate setup via "ioperm" needs to be done */
+/* *before* any inx/outx is done. */
+
+extern _X_EXPORT void (*_alpha_outb)(char val, unsigned long port);
+static __inline__ void
+outb(unsigned long port, unsigned char val)
+{
+ _alpha_outb(val, port);
+}
+
+extern _X_EXPORT void (*_alpha_outw)(short val, unsigned long port);
+static __inline__ void
+outw(unsigned long port, unsigned short val)
+{
+ _alpha_outw(val, port);
+}
+
+extern _X_EXPORT void (*_alpha_outl)(int val, unsigned long port);
+static __inline__ void
+outl(unsigned long port, unsigned int val)
+{
+ _alpha_outl(val, port);
+}
+
+extern _X_EXPORT unsigned int (*_alpha_inb)(unsigned long port);
+static __inline__ unsigned int
+inb(unsigned long port)
+{
+ return _alpha_inb(port);
+}
+
+extern _X_EXPORT unsigned int (*_alpha_inw)(unsigned long port);
+static __inline__ unsigned int
+inw(unsigned long port)
+{
+ return _alpha_inw(port);
+}
+
+extern _X_EXPORT unsigned int (*_alpha_inl)(unsigned long port);
+static __inline__ unsigned int
+inl(unsigned long port)
+{
+ return _alpha_inl(port);
+}
+
+# endif /* linux */
+
+# if (defined(__FreeBSD__) || defined(__OpenBSD__)) \
+ && !defined(DO_PROTOTYPES)
+
+/* for FreeBSD and OpenBSD on Alpha, we use the libio (resp. libalpha) */
+/* inx/outx routines */
+/* note that the appropriate setup via "ioperm" needs to be done */
+/* *before* any inx/outx is done. */
+
+extern _X_EXPORT void outb(unsigned int port, unsigned char val);
+extern _X_EXPORT void outw(unsigned int port, unsigned short val);
+extern _X_EXPORT void outl(unsigned int port, unsigned int val);
+extern _X_EXPORT unsigned char inb(unsigned int port);
+extern _X_EXPORT unsigned short inw(unsigned int port);
+extern _X_EXPORT unsigned int inl(unsigned int port);
+
+# endif /* (__FreeBSD__ || __OpenBSD__ ) && !DO_PROTOTYPES */
+
+
+#if defined(__NetBSD__)
+#include <machine/pio.h>
+#endif /* __NetBSD__ */
+
+# elif defined(linux) && defined(__ia64__)
+
+# include <inttypes.h>
+
+# include <sys/io.h>
+
+# undef outb
+# undef outw
+# undef outl
+# undef inb
+# undef inw
+# undef inl
+extern _X_EXPORT void outb(unsigned long port, unsigned char val);
+extern _X_EXPORT void outw(unsigned long port, unsigned short val);
+extern _X_EXPORT void outl(unsigned long port, unsigned int val);
+extern _X_EXPORT unsigned int inb(unsigned long port);
+extern _X_EXPORT unsigned int inw(unsigned long port);
+extern _X_EXPORT unsigned int inl(unsigned long port);
+
+# elif (defined(linux) || defined(__FreeBSD__)) && defined(__amd64__)
+
+# include <inttypes.h>
+
+static __inline__ void
+outb(unsigned short port, unsigned char val)
+{
+ __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
+}
+
+
+static __inline__ void
+outw(unsigned short port, unsigned short val)
+{
+ __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
+}
+
+static __inline__ void
+outl(unsigned short port, unsigned int val)
+{
+ __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
+}
+
+static __inline__ unsigned int
+inb(unsigned short port)
+{
+ unsigned char ret;
+ __asm__ __volatile__("inb %1,%0" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+static __inline__ unsigned int
+inw(unsigned short port)
+{
+ unsigned short ret;
+ __asm__ __volatile__("inw %1,%0" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+static __inline__ unsigned int
+inl(unsigned short port)
+{
+ unsigned int ret;
+ __asm__ __volatile__("inl %1,%0" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+# elif (defined(linux) || defined(sun) || defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc__)
+
+# ifndef ASI_PL
+# define ASI_PL 0x88
+# endif
+
+static __inline__ void
+outb(unsigned long port, unsigned char val)
+{
+ __asm__ __volatile__("stba %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (port), "i" (ASI_PL));
+ barrier();
+}
+
+static __inline__ void
+outw(unsigned long port, unsigned short val)
+{
+ __asm__ __volatile__("stha %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (port), "i" (ASI_PL));
+ barrier();
+}
+
+static __inline__ void
+outl(unsigned long port, unsigned int val)
+{
+ __asm__ __volatile__("sta %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (port), "i" (ASI_PL));
+ barrier();
+}
+
+static __inline__ unsigned int
+inb(unsigned long port)
+{
+ unsigned int ret;
+ __asm__ __volatile__("lduba [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (port), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ unsigned int
+inw(unsigned long port)
+{
+ unsigned int ret;
+ __asm__ __volatile__("lduha [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (port), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ unsigned int
+inl(unsigned long port)
+{
+ unsigned int ret;
+ __asm__ __volatile__("lda [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (port), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ unsigned char
+xf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned char ret;
+
+ __asm__ __volatile__("lduba [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (addr), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ unsigned short
+xf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned short ret;
+
+ __asm__ __volatile__("lduh [%1], %0"
+ : "=r" (ret)
+ : "r" (addr));
+ return ret;
+}
+
+static __inline__ unsigned short
+xf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned short ret;
+
+ __asm__ __volatile__("lduha [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (addr), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ unsigned int
+xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned int ret;
+
+ __asm__ __volatile__("ld [%1], %0"
+ : "=r" (ret)
+ : "r" (addr));
+ return ret;
+}
+
+static __inline__ unsigned int
+xf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned int ret;
+
+ __asm__ __volatile__("lda [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (addr), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ void
+xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("stba %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("sth %0, [%1]"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("stha %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("st %0, [%1]"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("sta %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio8NB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("stba %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+}
+
+static __inline__ void
+xf86WriteMmio16BeNB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("sth %0, [%1]"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+}
+
+static __inline__ void
+xf86WriteMmio16LeNB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("stha %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+}
+
+static __inline__ void
+xf86WriteMmio32BeNB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("st %0, [%1]"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+}
+
+static __inline__ void
+xf86WriteMmio32LeNB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("sta %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+}
+
+# elif defined(__mips__) || (defined(__arm32__) && !defined(__linux__))
+# ifdef __arm32__
+# define PORT_SIZE long
+# else
+# define PORT_SIZE short
+# endif
+
+_X_EXPORT unsigned int IOPortBase; /* Memory mapped I/O port area */
+
+static __inline__ void
+outb(unsigned PORT_SIZE port, unsigned char val)
+{
+ *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
+}
+
+static __inline__ void
+outw(unsigned PORT_SIZE port, unsigned short val)
+{
+ *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
+}
+
+static __inline__ void
+outl(unsigned PORT_SIZE port, unsigned int val)
+{
+ *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
+}
+
+static __inline__ unsigned int
+inb(unsigned PORT_SIZE port)
+{
+ return *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase);
+}
+
+static __inline__ unsigned int
+inw(unsigned PORT_SIZE port)
+{
+ return *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase);
+}
+
+static __inline__ unsigned int
+inl(unsigned PORT_SIZE port)
+{
+ return *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase);
+}
+
+
+# if defined(__mips__)
+# ifdef linux /* don't mess with other OSs */
+# if X_BYTE_ORDER == X_BIG_ENDIAN
+static __inline__ unsigned int
+xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned int ret;
+
+ __asm__ __volatile__("lw %0, 0(%1)"
+ : "=r" (ret)
+ : "r" (addr));
+ return ret;
+}
+
+static __inline__ void
+xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("sw %0, 0(%1)"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+}
+# endif
+# endif /* !linux */
+# endif /* __mips__ */
+
+# elif (defined(linux) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)) && defined(__powerpc__)
+
+# ifndef MAP_FAILED
+# define MAP_FAILED ((void *)-1)
+# endif
+
+extern _X_EXPORT volatile unsigned char *ioBase;
+
+static __inline__ unsigned char
+xf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
+{
+ register unsigned char val;
+ __asm__ __volatile__(
+ "lbzx %0,%1,%2\n\t"
+ "eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset),
+ "m" (*((volatile unsigned char *)base+offset)));
+ return val;
+}
+
+static __inline__ unsigned short
+xf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset)
+{
+ register unsigned short val;
+ __asm__ __volatile__(
+ "lhzx %0,%1,%2\n\t"
+ "eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset),
+ "m" (*((volatile unsigned char *)base+offset)));
+ return val;
+}
+
+static __inline__ unsigned short
+xf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset)
+{
+ register unsigned short val;
+ __asm__ __volatile__(
+ "lhbrx %0,%1,%2\n\t"
+ "eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset),
+ "m" (*((volatile unsigned char *)base+offset)));
+ return val;
+}
+
+static __inline__ unsigned int
+xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
+{
+ register unsigned int val;
+ __asm__ __volatile__(
+ "lwzx %0,%1,%2\n\t"
+ "eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset),
+ "m" (*((volatile unsigned char *)base+offset)));
+ return val;
+}
+
+static __inline__ unsigned int
+xf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset)
+{
+ register unsigned int val;
+ __asm__ __volatile__(
+ "lwbrx %0,%1,%2\n\t"
+ "eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset),
+ "m" (*((volatile unsigned char *)base+offset)));
+ return val;
+}
+
+static __inline__ void
+xf86WriteMmioNB8(__volatile__ void *base, const unsigned long offset,
+ const unsigned char val)
+{
+ __asm__ __volatile__(
+ "stbx %1,%2,%3\n\t"
+ : "=m" (*((volatile unsigned char *)base+offset))
+ : "r" (val), "b" (base), "r" (offset));
+}
+
+static __inline__ void
+xf86WriteMmioNB16Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned short val)
+{
+ __asm__ __volatile__(
+ "sthbrx %1,%2,%3\n\t"
+ : "=m" (*((volatile unsigned char *)base+offset))
+ : "r" (val), "b" (base), "r" (offset));
+}
+
+static __inline__ void
+xf86WriteMmioNB16Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned short val)
+{
+ __asm__ __volatile__(
+ "sthx %1,%2,%3\n\t"
+ : "=m" (*((volatile unsigned char *)base+offset))
+ : "r" (val), "b" (base), "r" (offset));
+}
+
+static __inline__ void
+xf86WriteMmioNB32Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ __asm__ __volatile__(
+ "stwbrx %1,%2,%3\n\t"
+ : "=m" (*((volatile unsigned char *)base+offset))
+ : "r" (val), "b" (base), "r" (offset));
+}
+
+static __inline__ void
+xf86WriteMmioNB32Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ __asm__ __volatile__(
+ "stwx %1,%2,%3\n\t"
+ : "=m" (*((volatile unsigned char *)base+offset))
+ : "r" (val), "b" (base), "r" (offset));
+}
+
+static __inline__ void
+xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
+ const unsigned char val)
+{
+ xf86WriteMmioNB8(base, offset, val);
+ eieio();
+}
+
+static __inline__ void
+xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned short val)
+{
+ xf86WriteMmioNB16Le(base, offset, val);
+ eieio();
+}
+
+static __inline__ void
+xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned short val)
+{
+ xf86WriteMmioNB16Be(base, offset, val);
+ eieio();
+}
+
+static __inline__ void
+xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ xf86WriteMmioNB32Le(base, offset, val);
+ eieio();
+}
+
+static __inline__ void
+xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ xf86WriteMmioNB32Be(base, offset, val);
+ eieio();
+}
+
+
+static __inline__ void
+outb(unsigned short port, unsigned char value)
+{
+ if(ioBase == MAP_FAILED) return;
+ xf86WriteMmio8((void *)ioBase, port, value);
+}
+
+static __inline__ void
+outw(unsigned short port, unsigned short value)
+{
+ if(ioBase == MAP_FAILED) return;
+ xf86WriteMmio16Le((void *)ioBase, port, value);
+}
+
+static __inline__ void
+outl(unsigned short port, unsigned int value)
+{
+ if(ioBase == MAP_FAILED) return;
+ xf86WriteMmio32Le((void *)ioBase, port, value);
+}
+
+static __inline__ unsigned int
+inb(unsigned short port)
+{
+ if(ioBase == MAP_FAILED) return 0;
+ return xf86ReadMmio8((void *)ioBase, port);
+}
+
+static __inline__ unsigned int
+inw(unsigned short port)
+{
+ if(ioBase == MAP_FAILED) return 0;
+ return xf86ReadMmio16Le((void *)ioBase, port);
+}
+
+static __inline__ unsigned int
+inl(unsigned short port)
+{
+ if(ioBase == MAP_FAILED) return 0;
+ return xf86ReadMmio32Le((void *)ioBase, port);
+}
+
+#elif defined(__arm__) && defined(__linux__)
+
+/* for Linux on ARM, we use the LIBC inx/outx routines */
+/* note that the appropriate setup via "ioperm" needs to be done */
+/* *before* any inx/outx is done. */
+
+#include <sys/io.h>
+
+static __inline__ void
+xf_outb(unsigned short port, unsigned char val)
+{
+ outb(val, port);
+}
+
+static __inline__ void
+xf_outw(unsigned short port, unsigned short val)
+{
+ outw(val, port);
+}
+
+static __inline__ void
+xf_outl(unsigned short port, unsigned int val)
+{
+ outl(val, port);
+}
+
+#define outb xf_outb
+#define outw xf_outw
+#define outl xf_outl
+
+# else /* ix86 */
+
+# if !defined(__SUNPRO_C)
+# if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__m32r__)
+# ifdef GCCUSESGAS
+
+/*
+ * If gcc uses gas rather than the native assembler, the syntax of these
+ * inlines has to be different. DHD
+ */
+
+static __inline__ void
+outb(unsigned short port, unsigned char val)
+{
+ __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
+}
+
+
+static __inline__ void
+outw(unsigned short port, unsigned short val)
+{
+ __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
+}
+
+static __inline__ void
+outl(unsigned short port, unsigned int val)
+{
+ __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
+}
+
+static __inline__ unsigned int
+inb(unsigned short port)
+{
+ unsigned char ret;
+ __asm__ __volatile__("inb %1,%0" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+static __inline__ unsigned int
+inw(unsigned short port)
+{
+ unsigned short ret;
+ __asm__ __volatile__("inw %1,%0" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+static __inline__ unsigned int
+inl(unsigned short port)
+{
+ unsigned int ret;
+ __asm__ __volatile__("inl %1,%0" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+# else /* GCCUSESGAS */
+
+static __inline__ void
+outb(unsigned short port, unsigned char val)
+{
+ __asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port));
+}
+
+static __inline__ void
+outw(unsigned short port, unsigned short val)
+{
+ __asm__ __volatile__("out%W0 (%1)" : :"a" (val), "d" (port));
+}
+
+static __inline__ void
+outl(unsigned short port, unsigned int val)
+{
+ __asm__ __volatile__("out%L0 (%1)" : :"a" (val), "d" (port));
+}
+
+static __inline__ unsigned int
+inb(unsigned short port)
+{
+ unsigned char ret;
+ __asm__ __volatile__("in%B0 (%1)" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+static __inline__ unsigned int
+inw(unsigned short port)
+{
+ unsigned short ret;
+ __asm__ __volatile__("in%W0 (%1)" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+static __inline__ unsigned int
+inl(unsigned short port)
+{
+ unsigned int ret;
+ __asm__ __volatile__("in%L0 (%1)" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+# endif /* GCCUSESGAS */
+
+# else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__m32r__) */
+
+static __inline__ void
+outb(unsigned short port, unsigned char val)
+{
+}
+
+static __inline__ void
+outw(unsigned short port, unsigned short val)
+{
+}
+
+static __inline__ void
+outl(unsigned short port, unsigned int val)
+{
+}
+
+static __inline__ unsigned int
+inb(unsigned short port)
+{
+ return 0;
+}
+
+static __inline__ unsigned int
+inw(unsigned short port)
+{
+ return 0;
+}
+
+static __inline__ unsigned int
+inl(unsigned short port)
+{
+ return 0;
+}
+
+# endif /* FAKEIT */
+# endif /* __SUNPRO_C */
+
+# endif /* ix86 */
+
+# else /* !GNUC */
+# if defined(__STDC__) && (__STDC__ == 1)
+# ifndef asm
+# define asm __asm
+# endif
+# endif
+# ifndef SCO325
+# if defined(__UNIXWARE__)
+# /* avoid including <sys/types.h> for <sys/inline.h> on UnixWare */
+# define ushort unsigned short
+# define ushort_t unsigned short
+# define ulong unsigned long
+# define ulong_t unsigned long
+# define uint_t unsigned int
+# define uchar_t unsigned char
+# endif /* __UNIXWARE__ */
+# if !defined(__SUNPRO_C) && !defined(_MSC_VER)
+# include <sys/inline.h>
+# endif
+# else
+# include "scoasm.h"
+# endif
+# if (!defined(__HIGHC__) && !defined(__SUNPRO_C) && !defined(_MSC_VER)) || \
+ defined(__USLC__)
+# pragma asm partial_optimization outl
+# pragma asm partial_optimization outw
+# pragma asm partial_optimization outb
+# pragma asm partial_optimization inl
+# pragma asm partial_optimization inw
+# pragma asm partial_optimization inb
+# endif
+# endif /* __GNUC__ */
+
+# endif /* NO_INLINE */
+
+# ifdef __alpha__
+/* entry points for Mmio memory access routines */
+extern _X_EXPORT int (*xf86ReadMmio8)(void *, unsigned long);
+extern _X_EXPORT int (*xf86ReadMmio16)(void *, unsigned long);
+# ifndef STANDALONE_MMIO
+extern _X_EXPORT int (*xf86ReadMmio32)(void *, unsigned long);
+# else
+/* Some DRI 3D drivers need MMIO_IN32. */
+static __inline__ int
+xf86ReadMmio32(void *Base, unsigned long Offset)
+{
+ mem_barrier();
+ return *(volatile unsigned int*)((unsigned long)Base+(Offset));
+}
+# endif
+extern _X_EXPORT void (*xf86WriteMmio8)(int, void *, unsigned long);
+extern _X_EXPORT void (*xf86WriteMmio16)(int, void *, unsigned long);
+extern _X_EXPORT void (*xf86WriteMmio32)(int, void *, unsigned long);
+extern _X_EXPORT void (*xf86WriteMmioNB8)(int, void *, unsigned long);
+extern _X_EXPORT void (*xf86WriteMmioNB16)(int, void *, unsigned long);
+extern _X_EXPORT void (*xf86WriteMmioNB32)(int, void *, unsigned long);
+extern _X_EXPORT void xf86SlowBCopyFromBus(unsigned char *, unsigned char *, int);
+extern _X_EXPORT void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int);
+
+/* Some macros to hide the system dependencies for MMIO accesses */
+/* Changed to kill noise generated by gcc's -Wcast-align */
+# define MMIO_IN8(base, offset) (*xf86ReadMmio8)(base, offset)
+# define MMIO_IN16(base, offset) (*xf86ReadMmio16)(base, offset)
+# ifndef STANDALONE_MMIO
+# define MMIO_IN32(base, offset) (*xf86ReadMmio32)(base, offset)
+# else
+# define MMIO_IN32(base, offset) xf86ReadMmio32(base, offset)
+# endif
+
+# define MMIO_OUT32(base, offset, val) \
+ do { \
+ write_mem_barrier(); \
+ *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val); \
+ } while (0)
+# define MMIO_ONB32(base, offset, val) \
+ *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
+
+# define MMIO_OUT8(base, offset, val) \
+ (*xf86WriteMmio8)((CARD8)(val), base, offset)
+# define MMIO_OUT16(base, offset, val) \
+ (*xf86WriteMmio16)((CARD16)(val), base, offset)
+# define MMIO_ONB8(base, offset, val) \
+ (*xf86WriteMmioNB8)((CARD8)(val), base, offset)
+# define MMIO_ONB16(base, offset, val) \
+ (*xf86WriteMmioNB16)((CARD16)(val), base, offset)
+# define MMIO_MOVE32(base, offset, val) \
+ MMIO_OUT32(base, offset, val)
+
+# elif defined(__powerpc__)
+ /*
+ * we provide byteswapping and no byteswapping functions here
+ * with byteswapping as default,
+ * drivers that don't need byteswapping should define PPC_MMIO_IS_BE
+ */
+# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
+# define MMIO_OUT8(base, offset, val) \
+ xf86WriteMmio8(base, offset, (CARD8)(val))
+# define MMIO_ONB8(base, offset, val) \
+ xf86WriteMmioNB8(base, offset, (CARD8)(val))
+
+# if defined(PPC_MMIO_IS_BE) /* No byteswapping */
+# define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
+# define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
+# define MMIO_OUT16(base, offset, val) \
+ xf86WriteMmio16Be(base, offset, (CARD16)(val))
+# define MMIO_OUT32(base, offset, val) \
+ xf86WriteMmio32Be(base, offset, (CARD32)(val))
+# define MMIO_ONB16(base, offset, val) \
+ xf86WriteMmioNB16Be(base, offset, (CARD16)(val))
+# define MMIO_ONB32(base, offset, val) \
+ xf86WriteMmioNB32Be(base, offset, (CARD32)(val))
+# else /* byteswapping is the default */
+# define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset)
+# define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset)
+# define MMIO_OUT16(base, offset, val) \
+ xf86WriteMmio16Le(base, offset, (CARD16)(val))
+# define MMIO_OUT32(base, offset, val) \
+ xf86WriteMmio32Le(base, offset, (CARD32)(val))
+# define MMIO_ONB16(base, offset, val) \
+ xf86WriteMmioNB16Le(base, offset, (CARD16)(val))
+# define MMIO_ONB32(base, offset, val) \
+ xf86WriteMmioNB32Le(base, offset, (CARD32)(val))
+# endif
+
+# define MMIO_MOVE32(base, offset, val) \
+ xf86WriteMmio32Be(base, offset, (CARD32)(val))
+
+# elif defined(__sparc__) || defined(sparc) || defined(__sparc)
+ /*
+ * Like powerpc, we provide byteswapping and no byteswapping functions
+ * here with byteswapping as default, drivers that don't need byteswapping
+ * should define SPARC_MMIO_IS_BE (perhaps create a generic macro so that we
+ * do not need to use PPC_MMIO_IS_BE and the sparc one in all the same places
+ * of drivers?).
+ */
+# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
+# define MMIO_OUT8(base, offset, val) \
+ xf86WriteMmio8(base, offset, (CARD8)(val))
+# define MMIO_ONB8(base, offset, val) \
+ xf86WriteMmio8NB(base, offset, (CARD8)(val))
+
+# if defined(SPARC_MMIO_IS_BE) /* No byteswapping */
+# define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
+# define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
+# define MMIO_OUT16(base, offset, val) \
+ xf86WriteMmio16Be(base, offset, (CARD16)(val))
+# define MMIO_OUT32(base, offset, val) \
+ xf86WriteMmio32Be(base, offset, (CARD32)(val))
+# define MMIO_ONB16(base, offset, val) \
+ xf86WriteMmio16BeNB(base, offset, (CARD16)(val))
+# define MMIO_ONB32(base, offset, val) \
+ xf86WriteMmio32BeNB(base, offset, (CARD32)(val))
+# else /* byteswapping is the default */
+# define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset)
+# define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset)
+# define MMIO_OUT16(base, offset, val) \
+ xf86WriteMmio16Le(base, offset, (CARD16)(val))
+# define MMIO_OUT32(base, offset, val) \
+ xf86WriteMmio32Le(base, offset, (CARD32)(val))
+# define MMIO_ONB16(base, offset, val) \
+ xf86WriteMmio16LeNB(base, offset, (CARD16)(val))
+# define MMIO_ONB32(base, offset, val) \
+ xf86WriteMmio32LeNB(base, offset, (CARD32)(val))
+# endif
+
+# define MMIO_MOVE32(base, offset, val) \
+ xf86WriteMmio32Be(base, offset, (CARD32)(val))
+
+# else /* !__alpha__ && !__powerpc__ && !__sparc__ */
+
+# define MMIO_IN8(base, offset) \
+ *(volatile CARD8 *)(((CARD8*)(base)) + (offset))
+# define MMIO_IN16(base, offset) \
+ *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset))
+# define MMIO_IN32(base, offset) \
+ *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset))
+# define MMIO_OUT8(base, offset, val) \
+ *(volatile CARD8 *)(((CARD8*)(base)) + (offset)) = (val)
+# define MMIO_OUT16(base, offset, val) \
+ *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
+# define MMIO_OUT32(base, offset, val) \
+ *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
+# define MMIO_ONB8(base, offset, val) MMIO_OUT8(base, offset, val)
+# define MMIO_ONB16(base, offset, val) MMIO_OUT16(base, offset, val)
+# define MMIO_ONB32(base, offset, val) MMIO_OUT32(base, offset, val)
+
+# define MMIO_MOVE32(base, offset, val) MMIO_OUT32(base, offset, val)
+
+# endif /* __alpha__ */
+
+/*
+ * With Intel, the version in os-support/misc/SlowBcopy.s is used.
+ * This avoids port I/O during the copy (which causes problems with
+ * some hardware).
+ */
+# ifdef __alpha__
+# define slowbcopy_tobus(src,dst,count) xf86SlowBCopyToBus(src,dst,count)
+# define slowbcopy_frombus(src,dst,count) xf86SlowBCopyFromBus(src,dst,count)
+# else /* __alpha__ */
+# define slowbcopy_tobus(src,dst,count) xf86SlowBcopy(src,dst,count)
+# define slowbcopy_frombus(src,dst,count) xf86SlowBcopy(src,dst,count)
+# endif /* __alpha__ */
+
+#endif /* _COMPILER_H */
diff --git a/xorg-server/hw/xwin/InitInput.c b/xorg-server/hw/xwin/InitInput.c
index 1e9bcad7a..51f7a923e 100644
--- a/xorg-server/hw/xwin/InitInput.c
+++ b/xorg-server/hw/xwin/InitInput.c
@@ -32,7 +32,7 @@
#include "win.h"
#include "dixstruct.h"
#include "inputstr.h"
-
+#include <unistd.h>
/*
* Local function prototypes
@@ -67,6 +67,13 @@ extern winDispatchProcPtr winProcQueryTreeOrig;
#endif
+void InputDevicesClosed(void)
+{
+ g_pwinPointer=NULL;
+ g_pwinKeyboard=NULL;
+}
+
+
/* Called from dix/devices.c */
/*
* All of our keys generate up and down transition notifications,
@@ -91,15 +98,7 @@ LegalModifier (unsigned int uiKey, DeviceIntPtr pDevice)
void
ProcessInputEvents (void)
{
-#if 0
- ErrorF ("ProcessInputEvents\n");
-#endif
-
mieqProcessInputEvents ();
-
-#if 0
- ErrorF ("ProcessInputEvents - returning\n");
-#endif
}
@@ -114,9 +113,7 @@ void DDXRingBell(int volume, int pitch, int duration)
void
InitInput (int argc, char *argv[])
{
-#if CYGDEBUG
winDebug ("InitInput\n");
-#endif
#ifdef XWIN_CLIPBOARD
/*
@@ -167,7 +164,5 @@ InitInput (int argc, char *argv[])
}
#endif
-#if CYGDEBUG
winDebug ("InitInput - returning\n");
-#endif
}
diff --git a/xorg-server/hw/xwin/InitOutput.c b/xorg-server/hw/xwin/InitOutput.c
index 8fd82d087..616490b94 100644
--- a/xorg-server/hw/xwin/InitOutput.c
+++ b/xorg-server/hw/xwin/InitOutput.c
@@ -1,1118 +1,1148 @@
-/*
-
-Copyright 1993, 1998 The Open Group
-Copyright (C) Colin Harrison 2005-2008
-
-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.
-
-*/
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-#include "winmsg.h"
-#include "winconfig.h"
-#include "winprefs.h"
-#ifdef XWIN_CLIPBOARD
-#include "X11/Xlocale.h"
-#endif
-#ifdef DPMSExtension
-#include "dpmsproc.h"
-#endif
-#ifdef __CYGWIN__
-#include <mntent.h>
-#endif
-#if defined(WIN32)
-#include "xkbsrv.h"
-#endif
-#ifdef RELOCATE_PROJECTROOT
-#include <shlobj.h>
-typedef HRESULT (*SHGETFOLDERPATHPROC)(
- HWND hwndOwner,
- int nFolder,
- HANDLE hToken,
- DWORD dwFlags,
- LPTSTR pszPath
-);
-#endif
-
-
-/*
- * References to external symbols
- */
-
-extern int g_iNumScreens;
-extern winScreenInfo g_ScreenInfo[];
-extern int g_iLastScreen;
-extern char * g_pszCommandLine;
-extern Bool g_fSilentFatalError;
-
-extern char * g_pszLogFile;
-extern Bool g_fLogFileChanged;
-extern int g_iLogVerbose;
-Bool g_fLogInited;
-
-extern Bool g_fXdmcpEnabled;
-extern Bool g_fAuthEnabled;
-#ifdef HAS_DEVWINDOWS
-extern int g_fdMessageQueue;
-#endif
-extern const char * g_pszQueryHost;
-extern HINSTANCE g_hInstance;
-
-#ifdef XWIN_CLIPBOARD
-extern Bool g_fUnicodeClipboard;
-extern Bool g_fClipboardLaunched;
-extern Bool g_fClipboardStarted;
-extern pthread_t g_ptClipboardProc;
-extern HWND g_hwndClipboard;
-extern Bool g_fClipboard;
-#endif
-
-extern HMODULE g_hmodDirectDraw;
-extern FARPROC g_fpDirectDrawCreate;
-extern FARPROC g_fpDirectDrawCreateClipper;
-
-extern HMODULE g_hmodCommonControls;
-extern FARPROC g_fpTrackMouseEvent;
-extern Bool g_fNoHelpMessageBox;
-extern Bool g_fSilentDupError;
-
-
-/*
- * Function prototypes
- */
-
-#ifdef XWIN_CLIPBOARD
-static void
-winClipboardShutdown (void);
-#endif
-
-#if defined(DDXOSVERRORF)
-void
-OsVendorVErrorF (const char *pszFormat, va_list va_args);
-#endif
-
-void
-winInitializeDefaultScreens (void);
-
-static Bool
-winCheckDisplayNumber (void);
-
-void
-winLogCommandLine (int argc, char *argv[]);
-
-void
-winLogVersionInfo (void);
-
-Bool
-winValidateArgs (void);
-
-#ifdef RELOCATE_PROJECTROOT
-const char *
-winGetBaseDir(void);
-#endif
-
-/*
- * For the depth 24 pixmap we default to 32 bits per pixel, but
- * we change this pixmap format later if we detect that the display
- * is going to be running at 24 bits per pixel.
- *
- * FIXME: On second thought, don't DIBs only support 32 bits per pixel?
- * DIBs are the underlying bitmap used for DirectDraw surfaces, so it
- * seems that all pixmap formats with depth 24 would be 32 bits per pixel.
- * Confirm whether depth 24 DIBs can have 24 bits per pixel, then remove/keep
- * the bits per pixel adjustment and update this comment to reflect the
- * situation. Harold Hunt - 2002/07/02
- */
-
-static PixmapFormatRec g_PixmapFormats[] = {
- { 1, 1, BITMAP_SCANLINE_PAD },
- { 4, 8, BITMAP_SCANLINE_PAD },
- { 8, 8, BITMAP_SCANLINE_PAD },
- { 15, 16, BITMAP_SCANLINE_PAD },
- { 16, 16, BITMAP_SCANLINE_PAD },
- { 24, 32, BITMAP_SCANLINE_PAD },
-#ifdef RENDER
- { 32, 32, BITMAP_SCANLINE_PAD }
-#endif
-};
-
-const int NUMFORMATS = sizeof (g_PixmapFormats) / sizeof (g_PixmapFormats[0]);
-
-#ifdef XWIN_CLIPBOARD
-static void
-winClipboardShutdown (void)
-{
- /* Close down clipboard resources */
- if (g_fClipboard && g_fClipboardLaunched && g_fClipboardStarted)
- {
- /* Synchronously destroy the clipboard window */
- if (g_hwndClipboard != NULL)
- {
- SendMessage (g_hwndClipboard, WM_DESTROY, 0, 0);
- /* NOTE: g_hwndClipboard is set to NULL in winclipboardthread.c */
- }
- else
- return;
-
- /* Wait for the clipboard thread to exit */
- pthread_join (g_ptClipboardProc, NULL);
-
- g_fClipboardLaunched = FALSE;
- g_fClipboardStarted = FALSE;
-
- winDebug ("winClipboardShutdown - Clipboard thread has exited.\n");
- }
-}
-#endif
-
-
-#if defined(DDXBEFORERESET)
-/*
- * Called right before KillAllClients when the server is going to reset,
- * allows us to shutdown our seperate threads cleanly.
- */
-
-void
-ddxBeforeReset (void)
-{
- winDebug ("ddxBeforeReset - Hello\n");
-
-#ifdef XWIN_CLIPBOARD
- winClipboardShutdown ();
-#endif
-}
-#endif
-
-
-/* See Porting Layer Definition - p. 57 */
-void
-ddxGiveUp (void)
-{
- int i;
-
-#if CYGDEBUG
- winDebug ("ddxGiveUp\n");
-#endif
-
- /* Perform per-screen deinitialization */
- for (i = 0; i < g_iNumScreens; ++i)
- {
- /* Delete the tray icon */
- if (!g_ScreenInfo[i].fNoTrayIcon && g_ScreenInfo[i].pScreen)
- winDeleteNotifyIcon (winGetScreenPriv (g_ScreenInfo[i].pScreen));
- }
-
-#ifdef XWIN_MULTIWINDOW
- /* Notify the worker threads we're exiting */
- winDeinitMultiWindowWM ();
-#endif
-
-#ifdef HAS_DEVWINDOWS
- /* Close our handle to our message queue */
- if (g_fdMessageQueue != WIN_FD_INVALID)
- {
- /* Close /dev/windows */
- close (g_fdMessageQueue);
-
- /* Set the file handle to invalid */
- g_fdMessageQueue = WIN_FD_INVALID;
- }
-#endif
-
- if (!g_fLogInited) {
- LogInit (g_pszLogFile, NULL);
- g_fLogInited = TRUE;
- }
- LogClose ();
-
- /*
- * At this point we aren't creating any new screens, so
- * we are guaranteed to not need the DirectDraw functions.
- */
- if (g_hmodDirectDraw != NULL)
- {
- FreeLibrary (g_hmodDirectDraw);
- g_hmodDirectDraw = NULL;
- g_fpDirectDrawCreate = NULL;
- g_fpDirectDrawCreateClipper = NULL;
- }
-
- /* Unload our TrackMouseEvent funtion pointer */
- if (g_hmodCommonControls != NULL)
- {
- FreeLibrary (g_hmodCommonControls);
- g_hmodCommonControls = NULL;
- g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;
- }
-
- /* Free concatenated command line */
- if (g_pszCommandLine)
- {
- free (g_pszCommandLine);
- g_pszCommandLine = NULL;
- }
-
- /* Remove our keyboard hook if it is installed */
- winRemoveKeyboardHookLL ();
-
- /* Tell Windows that we want to end the app */
- PostQuitMessage (0);
-}
-
-
-/* See Porting Layer Definition - p. 57 */
-void
-AbortDDX (void)
-{
-#if CYGDEBUG
- winDebug ("AbortDDX\n");
-#endif
- ddxGiveUp ();
-}
-
-#ifdef __CYGWIN__
-/* hasmntopt is currently not implemented for cygwin */
-static const char *winCheckMntOpt(const struct mntent *mnt, const char *opt)
-{
- const char *s;
- size_t len;
- if (mnt == NULL)
- return NULL;
- if (opt == NULL)
- return NULL;
- if (mnt->mnt_opts == NULL)
- return NULL;
-
- len = strlen(opt);
- s = strstr(mnt->mnt_opts, opt);
- if (s == NULL)
- return NULL;
- if ((s == mnt->mnt_opts || *(s-1) == ',') && (s[len] == 0 || s[len] == ','))
- return (char *)opt;
- return NULL;
-}
-
-static void
-winCheckMount(void)
-{
- FILE *mnt;
- struct mntent *ent;
-
- enum { none = 0, sys_root, user_root, sys_tmp, user_tmp }
- level = none, curlevel;
- BOOL binary = TRUE;
-
- mnt = setmntent("/etc/mtab", "r");
- if (mnt == NULL)
- {
- ErrorF("setmntent failed");
- return;
- }
-
- while ((ent = getmntent(mnt)) != NULL)
- {
- BOOL system = (winCheckMntOpt(ent, "user") != NULL);
- BOOL root = (strcmp(ent->mnt_dir, "/") == 0);
- BOOL tmp = (strcmp(ent->mnt_dir, "/tmp") == 0);
-
- if (system)
- {
- if (root)
- curlevel = sys_root;
- else if (tmp)
- curlevel = sys_tmp;
- else
- continue;
- }
- else
- {
- if (root)
- curlevel = user_root;
- else if (tmp)
- curlevel = user_tmp;
- else
- continue;
- }
-
- if (curlevel <= level)
- continue;
- level = curlevel;
-
- if ((winCheckMntOpt(ent, "binary") == NULL) ||
- (winCheckMntOpt(ent, "binmode") == NULL))
- binary = 0;
- else
- binary = 1;
- }
-
- if (endmntent(mnt) != 1)
- {
- ErrorF("endmntent failed");
- return;
- }
-
- if (!binary)
- winMsg(X_WARNING, "/tmp mounted in textmode\n");
-}
-#else
-static void
-winCheckMount(void)
-{
-}
-#endif
-
-#ifdef RELOCATE_PROJECTROOT
-const char *
-winGetBaseDir(void)
-{
- static BOOL inited = FALSE;
- static char buffer[MAX_PATH];
- if (!inited)
- {
- char *fendptr;
- HMODULE module = GetModuleHandle(NULL);
- DWORD size = GetModuleFileName(module, buffer, sizeof(buffer));
- if (sizeof(buffer) > 0)
- buffer[sizeof(buffer)-1] = 0;
-
- fendptr = buffer + size;
- while (fendptr > buffer)
- {
- if (*fendptr == '\\' || *fendptr == '/')
- {
- *fendptr = 0;
- break;
- }
- fendptr--;
- }
- inited = TRUE;
- }
- return buffer;
-}
-#endif
-
-static void
-winFixupPaths (void)
-{
- BOOL changed_fontpath = FALSE;
- MessageType font_from = X_DEFAULT;
-#ifdef RELOCATE_PROJECTROOT
- const char *basedir = winGetBaseDir();
- size_t basedirlen = strlen(basedir);
-#endif
-
-#ifdef READ_FONTDIRS
- {
- /* Open fontpath configuration file */
- FILE *fontdirs = fopen(ETCX11DIR "/font-dirs", "rt");
- if (fontdirs != NULL)
- {
- char buffer[256];
- int needs_sep = TRUE;
- int comment_block = FALSE;
-
- /* get defautl fontpath */
- char *fontpath = xstrdup(defaultFontPath);
- size_t size = strlen(fontpath);
-
- /* read all lines */
- while (!feof(fontdirs))
- {
- size_t blen;
- char *hashchar;
- char *str;
- int has_eol = FALSE;
-
- /* read one line */
- str = fgets(buffer, sizeof(buffer), fontdirs);
- if (str == NULL) /* stop on error or eof */
- break;
-
- if (strchr(str, '\n') != NULL)
- has_eol = TRUE;
-
- /* check if block is continued comment */
- if (comment_block)
- {
- /* ignore all input */
- *str = 0;
- blen = 0;
- if (has_eol) /* check if line ended in this block */
- comment_block = FALSE;
- }
- else
- {
- /* find comment character. ignore all trailing input */
- hashchar = strchr(str, '#');
- if (hashchar != NULL)
- {
- *hashchar = 0;
- if (!has_eol) /* mark next block as continued comment */
- comment_block = TRUE;
- }
- }
-
- /* strip whitespaces from beginning */
- while (*str == ' ' || *str == '\t')
- str++;
-
- /* get size, strip whitespaces from end */
- blen = strlen(str);
- while (blen > 0 && (str[blen-1] == ' ' ||
- str[blen-1] == '\t' || str[blen-1] == '\n'))
- {
- str[--blen] = 0;
- }
-
- /* still something left to add? */
- if (blen > 0)
- {
- size_t newsize = size + blen;
- /* reserve one character more for ',' */
- if (needs_sep)
- newsize++;
-
- /* allocate memory */
- if (fontpath == NULL)
- fontpath = malloc(newsize+1);
- else
- fontpath = realloc(fontpath, newsize+1);
-
- /* add separator */
- if (needs_sep)
- {
- fontpath[size] = ',';
- size++;
- needs_sep = FALSE;
- }
-
- /* mark next line as new entry */
- if (has_eol)
- needs_sep = TRUE;
-
- /* add block */
- strncpy(fontpath + size, str, blen);
- fontpath[newsize] = 0;
- size = newsize;
- }
- }
-
- /* cleanup */
- fclose(fontdirs);
- defaultFontPath = xstrdup(fontpath);
- free(fontpath);
- changed_fontpath = TRUE;
- font_from = X_CONFIG;
- }
- }
-#endif /* READ_FONTDIRS */
-#ifdef RELOCATE_PROJECTROOT
- {
- const char *libx11dir = PROJECTROOT "/lib/X11";
- size_t libx11dir_len = strlen(libx11dir);
- char *newfp = NULL;
- size_t newfp_len = 0;
- const char *endptr, *ptr, *oldptr = defaultFontPath;
-
- endptr = oldptr + strlen(oldptr);
- ptr = strchr(oldptr, ',');
- if (ptr == NULL)
- ptr = endptr;
- while (ptr != NULL)
- {
- size_t oldfp_len = (ptr - oldptr);
- size_t newsize = oldfp_len;
- char *newpath = malloc(newsize + 1);
- strncpy(newpath, oldptr, newsize);
- newpath[newsize] = 0;
-
-
- if (strncmp(libx11dir, newpath, libx11dir_len) == 0)
- {
- char *compose;
- newsize = newsize - libx11dir_len + basedirlen;
- compose = malloc(newsize + 1);
- strcpy(compose, basedir);
- strncat(compose, newpath + libx11dir_len, newsize - basedirlen);
- compose[newsize] = 0;
- free(newpath);
- newpath = compose;
- }
-
- oldfp_len = newfp_len;
- if (oldfp_len > 0)
- newfp_len ++; /* space for separator */
- newfp_len += newsize;
-
- if (newfp == NULL)
- newfp = malloc(newfp_len + 1);
- else
- newfp = realloc(newfp, newfp_len + 1);
-
- if (oldfp_len > 0)
- {
- strcpy(newfp + oldfp_len, ",");
- oldfp_len++;
- }
- strcpy(newfp + oldfp_len, newpath);
-
- free(newpath);
-
- if (*ptr == 0)
- {
- oldptr = ptr;
- ptr = NULL;
- } else
- {
- oldptr = ptr + 1;
- ptr = strchr(oldptr, ',');
- if (ptr == NULL)
- ptr = endptr;
- }
- }
-
- defaultFontPath = xstrdup(newfp);
- free(newfp);
- changed_fontpath = TRUE;
- }
-#endif /* RELOCATE_PROJECTROOT */
- if (changed_fontpath)
- winMsg (font_from, "FontPath set to \"%s\"\n", defaultFontPath);
-
-#ifdef RELOCATE_PROJECTROOT
- if (getenv("XKEYSYMDB") == NULL)
- {
- char buffer[MAX_PATH];
- snprintf(buffer, sizeof(buffer), "XKEYSYMDB=%s\\XKeysymDB",
- basedir);
- buffer[sizeof(buffer)-1] = 0;
- putenv(buffer);
- }
- if (getenv("XERRORDB") == NULL)
- {
- char buffer[MAX_PATH];
- snprintf(buffer, sizeof(buffer), "XERRORDB=%s\\XErrorDB",
- basedir);
- buffer[sizeof(buffer)-1] = 0;
- putenv(buffer);
- }
- if (getenv("XLOCALEDIR") == NULL)
- {
- char buffer[MAX_PATH];
- snprintf(buffer, sizeof(buffer), "XLOCALEDIR=%s\\locale",
- basedir);
- buffer[sizeof(buffer)-1] = 0;
- putenv(buffer);
- }
- if (getenv("HOME") == NULL)
- {
- HMODULE shfolder;
- SHGETFOLDERPATHPROC shgetfolderpath = NULL;
- char buffer[MAX_PATH + 5];
- strncpy(buffer, "HOME=", 5);
-
- /* Try to load SHGetFolderPath from shfolder.dll and shell32.dll */
-
- shfolder = LoadLibrary("shfolder.dll");
- /* fallback to shell32.dll */
- if (shfolder == NULL)
- shfolder = LoadLibrary("shell32.dll");
-
- /* resolve SHGetFolderPath */
- if (shfolder != NULL)
- shgetfolderpath = (SHGETFOLDERPATHPROC)GetProcAddress(shfolder, "SHGetFolderPathA");
-
- /* query appdata directory */
- if (shgetfolderpath &&
- shgetfolderpath(NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, NULL, 0,
- buffer + 5) == 0)
- {
- putenv(buffer);
- } else
- {
- winMsg (X_ERROR, "Can not determine HOME directory\n");
- }
- if (shfolder != NULL)
- FreeLibrary(shfolder);
- }
- if (!g_fLogFileChanged) {
- static char buffer[MAX_PATH];
- DWORD size = GetTempPath(sizeof(buffer), buffer);
- if (size && size < sizeof(buffer))
- {
- snprintf(buffer + size, sizeof(buffer) - size,
- "XWin.%s.log", display);
- buffer[sizeof(buffer)-1] = 0;
- g_pszLogFile = buffer;
- winMsg (X_DEFAULT, "Logfile set to \"%s\"\n", g_pszLogFile);
- }
- }
- {
- static char xkbbasedir[MAX_PATH];
-
- snprintf(xkbbasedir, sizeof(xkbbasedir), "%s\\xkb", basedir);
- if (sizeof(xkbbasedir) > 0)
- xkbbasedir[sizeof(xkbbasedir)-1] = 0;
- XkbBaseDirectory = xkbbasedir;
- XkbBinDirectory = basedir;
- }
-#endif /* RELOCATE_PROJECTROOT */
-}
-
-void
-OsVendorInit (void)
-{
- /* Re-initialize global variables on server reset */
- winInitializeGlobals ();
-
- LogInit (NULL, NULL);
- LogSetParameter (XLOG_VERBOSITY, g_iLogVerbose);
-
- winFixupPaths();
-
-#ifdef DDXOSVERRORF
- if (!OsVendorVErrorFProc)
- OsVendorVErrorFProc = OsVendorVErrorF;
-#endif
-
- if (!g_fLogInited) {
- /* keep this order. If LogInit fails it calls Abort which then calls
- * ddxGiveUp where LogInit is called again and creates an infinite
- * recursion. If we set g_fLogInited to TRUE before the init we
- * avoid the second call
- */
- g_fLogInited = TRUE;
- LogInit (g_pszLogFile, NULL);
- }
- LogSetParameter (XLOG_FLUSH, 1);
- LogSetParameter (XLOG_VERBOSITY, g_iLogVerbose);
- LogSetParameter (XLOG_FILE_VERBOSITY, g_iLogVerbose);
-
- /* Log the version information */
- if (serverGeneration == 1)
- winLogVersionInfo ();
-
- winCheckMount();
-
- /* Add a default screen if no screens were specified */
- if (g_iNumScreens == 0)
- {
- winDebug ("OsVendorInit - Creating bogus screen 0\n");
-
- /*
- * We need to initialize default screens if no arguments
- * were processed. Otherwise, the default screens would
- * already have been initialized by ddxProcessArgument ().
- */
- winInitializeDefaultScreens ();
-
- /*
- * Add a screen 0 using the defaults set by
- * winInitializeDefaultScreens () and any additional parameters
- * processed by ddxProcessArgument ().
- */
- g_iNumScreens = 1;
- g_iLastScreen = 0;
-
- /* We have to flag this as an explicit screen, even though it isn't */
- g_ScreenInfo[0].fExplicitScreen = TRUE;
- }
-}
-
-
-static void
-winUseMsg (void)
-{
- ErrorF ("-depth bits_per_pixel\n"
- "\tSpecify an optional bitdepth to use in fullscreen mode\n"
- "\twith a DirectDraw engine.\n");
-
- ErrorF ("-emulate3buttons [timeout]\n"
- "\tEmulate 3 button mouse with an optional timeout in\n"
- "\tmilliseconds.\n");
-
- ErrorF ("-engine engine_type_id\n"
- "\tOverride the server's automatically selected engine type:\n"
- "\t\t1 - Shadow GDI\n"
- "\t\t2 - Shadow DirectDraw\n"
- "\t\t4 - Shadow DirectDraw4 Non-Locking\n"
-#ifdef XWIN_NATIVEGDI
- "\t\t16 - Native GDI - experimental\n"
-#endif
- );
-
- ErrorF ("-fullscreen\n"
- "\tRun the server in fullscreen mode.\n");
-
- ErrorF ("-refresh rate_in_Hz\n"
- "\tSpecify an optional refresh rate to use in fullscreen mode\n"
- "\twith a DirectDraw engine.\n");
-
- ErrorF ("-screen scr_num [width height [x y] | [[WxH[+X+Y]][@m]] ]\n"
- "\tEnable screen scr_num and optionally specify a width and\n"
- "\theight and initial position for that screen. Additionally\n"
- "\ta monitor number can be specified to start the server on,\n"
- "\tat which point, all coordinates become relative to that\n"
- "\tmonitor (Not for Windows NT4 and 95). Examples:\n"
- "\t -screen 0 800x600+100+100@2 ; 2nd monitor offset 100,100 size 800x600\n"
- "\t -screen 0 1024x768@3 ; 3rd monitor size 1024x768\n"
- "\t -screen 0 @1 ; on 1st monitor using its full resolution (the default)\n");
-
- ErrorF ("-lesspointer\n"
- "\tHide the windows mouse pointer when it is over an inactive\n"
- "\t" PROJECT_NAME " window. This prevents ghost cursors appearing where\n"
- "\tthe Windows cursor is drawn overtop of the X cursor\n");
-
- ErrorF ("-nodecoration\n"
- "\tDo not draw a window border, title bar, etc. Windowed\n"
- "\tmode only.\n");
-
-#ifdef XWIN_MULTIWINDOWEXTWM
- ErrorF ("-mwextwm\n"
- "\tRun the server in multi-window external window manager mode.\n");
-
- ErrorF ("-internalwm\n"
- "\tRun the internal window manager.\n");
-#endif
-
- ErrorF ("-rootless\n"
- "\tRun the server in rootless mode.\n");
-
-#ifdef XWIN_MULTIWINDOW
- ErrorF ("-multiwindow\n"
- "\tRun the server in multi-window mode.\n");
-#endif
-
- ErrorF ("-multiplemonitors\n"
- "\tEXPERIMENTAL: Use the entire virtual screen if multiple\n"
- "\tmonitors are present.\n");
-
-#ifdef XWIN_CLIPBOARD
- ErrorF ("-[no]clipboard\n"
- "\tEnable [disable] the clipboard integration. Default is enabled.\n");
-
- ErrorF ("-nounicodeclipboard\n"
- "\tDo not use Unicode clipboard even if NT-based platform.\n");
-#endif
-
- ErrorF ("-scrollbars\n"
- "\tIn windowed mode, allow screens bigger than the Windows desktop.\n"
- "\tMoreover, if the window has decorations, one can now resize\n"
- "\tit.\n");
-
- ErrorF ("-[no]trayicon\n"
- "\tDo not create a tray icon. Default is to create one\n"
- "\ticon per screen. You can globally disable tray icons with\n"
- "\t-notrayicon, then enable it for specific screens with\n"
- "\t-trayicon for those screens.\n");
-
- ErrorF ("-clipupdates num_boxes\n"
- "\tUse a clipping region to constrain shadow update blits to\n"
- "\tthe updated region when num_boxes, or more, are in the\n"
- "\tupdated region. Currently supported only by `-engine 1'.\n");
-
-#ifdef XWIN_EMULATEPSEUDO
- ErrorF ("-emulatepseudo\n"
- "\tCreate a depth 8 PseudoColor visual when running in\n"
- "\tdepths 15, 16, 24, or 32, collectively known as TrueColor\n"
- "\tdepths. The PseudoColor visual does not have correct colors,\n"
- "\tand it may crash, but it at least allows you to run your\n"
- "\tapplication in TrueColor modes.\n");
-#endif
-
- ErrorF ("-[no]unixkill\n"
- "\tCtrl+Alt+Backspace exits the X Server.\n");
-
- ErrorF ("-[no]winkill\n"
- "\tAlt+F4 exits the X Server.\n");
-
-#ifdef XWIN_XF86CONFIG
- ErrorF ("-config\n"
- "\tSpecify a configuration file.\n");
-
- ErrorF ("-keyboard\n"
- "\tSpecify a keyboard device from the configuration file.\n");
-#endif
-
- ErrorF ("-xkbrules XKBRules\n"
- "\tEquivalent to XKBRules in XF86Config files.\n");
-
- ErrorF ("-xkbmodel XKBModel\n"
- "\tEquivalent to XKBModel in XF86Config files.\n");
-
- ErrorF ("-xkblayout XKBLayout\n"
- "\tEquivalent to XKBLayout in XF86Config files.\n"
- "\tFor example: -xkblayout de\n");
-
- ErrorF ("-xkbvariant XKBVariant\n"
- "\tEquivalent to XKBVariant in XF86Config files.\n"
- "\tFor example: -xkbvariant nodeadkeys\n");
-
- ErrorF ("-xkboptions XKBOptions\n"
- "\tEquivalent to XKBOptions in XF86Config files.\n");
-
- ErrorF ("-logfile filename\n"
- "\tWrite logmessages to <filename> instead of /tmp/Xwin.log.\n");
-
- ErrorF ("-logverbose verbosity\n"
- "\tSet the verbosity of logmessages. [NOTE: Only a few messages\n"
- "\trespect the settings yet]\n"
- "\t\t0 - only print fatal error.\n"
- "\t\t1 - print additional configuration information.\n"
- "\t\t2 - print additional runtime information [default].\n"
- "\t\t3 - print debugging and tracing information.\n");
-
- ErrorF ("-[no]keyhook\n"
- "\tGrab special windows key combinations like Alt-Tab or the Menu "
- "key.\n These keys are discarded by default.\n");
-
- ErrorF ("-swcursor\n"
- "\tDisable the usage of the windows cursor and use the X11 software "
- "cursor instead\n");
-}
-
-/* See Porting Layer Definition - p. 57 */
-void
-ddxUseMsg(void)
-{
- /* Set a flag so that FatalError won't give duplicate warning message */
- g_fSilentFatalError = TRUE;
-
- winUseMsg();
-
- /* Log file will not be opened for UseMsg unless we open it now */
- if (!g_fLogInited) {
- LogInit (g_pszLogFile, NULL);
- g_fLogInited = TRUE;
- }
- LogClose ();
-
- /* Notify user where UseMsg text can be found.*/
- if (!g_fNoHelpMessageBox)
- winMessageBoxF ("The " PROJECT_NAME " help text has been printed to "
- "/tmp/XWin.log.\n"
- "Please open /tmp/XWin.log to read the help text.\n",
- MB_ICONINFORMATION);
-}
-
-/* See Porting Layer Definition - p. 20 */
-/*
- * Do any global initialization, then initialize each screen.
- *
- * NOTE: We use ddxProcessArgument, so we don't need to touch argc and argv
- */
-
-void
-InitOutput (ScreenInfo *screenInfo, int argc, char *argv[])
-{
- int i;
-
- /* Log the command line */
- winLogCommandLine (argc, argv);
-
-#if CYGDEBUG
- winDebug ("InitOutput\n");
-#endif
-
- /* Validate command-line arguments */
- if (serverGeneration == 1 && !winValidateArgs ())
- {
- FatalError ("InitOutput - Invalid command-line arguments found. "
- "Exiting.\n");
- }
-
- /* Check for duplicate invocation on same display number.*/
- if (serverGeneration == 1 && !winCheckDisplayNumber ())
- {
- if (g_fSilentDupError)
- g_fSilentFatalError = TRUE;
- FatalError ("InitOutput - Duplicate invocation on display "
- "number: %s. Exiting.\n", display);
- }
-
-#ifdef XWIN_XF86CONFIG
- /* Try to read the xorg.conf-style configuration file */
- if (!winReadConfigfile ())
- winErrorFVerb (1, "InitOutput - Error reading config file\n");
-#else
- winMsg(X_INFO, "xorg.conf is not supported\n");
- winMsg(X_INFO, "See http://x.cygwin.com/docs/faq/cygwin-x-faq.html "
- "for more information\n");
- winConfigFiles ();
-#endif
-
- /* Load preferences from XWinrc file */
- LoadPreferences();
-
- /* Setup global screen info parameters */
- screenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
- screenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
- screenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
- screenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
- screenInfo->numPixmapFormats = NUMFORMATS;
-
- /* Describe how we want common pixmap formats padded */
- for (i = 0; i < NUMFORMATS; i++)
- {
- screenInfo->formats[i] = g_PixmapFormats[i];
- }
-
- /* Load pointers to DirectDraw functions */
- winGetDDProcAddresses ();
-
- /* Detect supported engines */
- winDetectSupportedEngines ();
-
- /* Load common controls library */
- g_hmodCommonControls = LoadLibraryEx ("comctl32.dll", NULL, 0);
-
- /* Load TrackMouseEvent function pointer */
- g_fpTrackMouseEvent = GetProcAddress (g_hmodCommonControls,
- "_TrackMouseEvent");
- if (g_fpTrackMouseEvent == NULL)
- {
- winErrorFVerb (1, "InitOutput - Could not get pointer to function\n"
- "\t_TrackMouseEvent in comctl32.dll. Try installing\n"
- "\tInternet Explorer 3.0 or greater if you have not\n"
- "\talready.\n");
-
- /* Free the library since we won't need it */
- FreeLibrary (g_hmodCommonControls);
- g_hmodCommonControls = NULL;
-
- /* Set function pointer to point to no operation function */
- g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;
- }
-
- /* Store the instance handle */
- g_hInstance = GetModuleHandle (NULL);
-
- /* Initialize each screen */
- for (i = 0; i < g_iNumScreens; ++i)
- {
- /* Initialize the screen */
- if (-1 == AddScreen (winScreenInit, argc, argv))
- {
- FatalError ("InitOutput - Couldn't add screen %d", i);
- }
- }
-
-#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
-
- /* Generate a cookie used by internal clients for authorization */
- if (g_fXdmcpEnabled || g_fAuthEnabled)
- winGenerateAuthorization ();
-
- /* Perform some one time initialization */
- if (1 == serverGeneration)
- {
- /*
- * setlocale applies to all threads in the current process.
- * Apply locale specified in LANG environment variable.
- */
- setlocale (LC_ALL, "");
- }
-#endif
-
-#if CYGDEBUG || YES
- winDebug ("InitOutput - Returning.\n");
-#endif
-}
-
-
-/*
- * winCheckDisplayNumber - Check if another instance of Cygwin/X is
- * already running on the same display number. If no one exists,
- * make a mutex to prevent new instances from running on the same display.
- *
- * return FALSE if the display number is already used.
- */
-
-static Bool
-winCheckDisplayNumber (void)
-{
- int nDisp;
- HANDLE mutex;
- char name[MAX_PATH];
- char * pszPrefix = '\0';
- OSVERSIONINFO osvi = {0};
-
- /* Check display range */
- nDisp = atoi (display);
- if (nDisp < 0 || nDisp > 65535)
- {
- ErrorF ("winCheckDisplayNumber - Bad display number: %d\n", nDisp);
- return FALSE;
- }
-
- /* Set first character of mutex name to null */
- name[0] = '\0';
-
- /* Get operating system version information */
- osvi.dwOSVersionInfoSize = sizeof (osvi);
- GetVersionEx (&osvi);
-
- /* Want a mutex shared among all terminals on NT > 4.0 */
- if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT
- && osvi.dwMajorVersion >= 5)
- {
- pszPrefix = "Global\\";
- }
-
- /* Setup Cygwin/X specific part of name */
- snprintf (name, sizeof(name), "%sCYGWINX_DISPLAY:%d", pszPrefix, nDisp);
-
- /* Windows automatically releases the mutex when this process exits */
- mutex = CreateMutex (NULL, FALSE, name);
- if (!mutex)
- {
- LPVOID lpMsgBuf;
-
- /* Display a fancy error message */
- FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- GetLastError (),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &lpMsgBuf,
- 0, NULL);
- ErrorF ("winCheckDisplayNumber - CreateMutex failed: %s\n",
- (LPSTR)lpMsgBuf);
- LocalFree (lpMsgBuf);
-
- return FALSE;
- }
- if (GetLastError () == ERROR_ALREADY_EXISTS)
- {
- ErrorF ("winCheckDisplayNumber - "
- PROJECT_NAME " is already running on display %d\n",
- nDisp);
- return FALSE;
- }
-
- return TRUE;
-}
+/*
+
+Copyright 1993, 1998 The Open Group
+Copyright (C) Colin Harrison 2005-2008
+
+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.
+
+*/
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "winmsg.h"
+#include "winconfig.h"
+#include "winprefs.h"
+#ifdef XWIN_CLIPBOARD
+#include "X11/Xlocale.h"
+#endif
+#ifdef DPMSExtension
+#include "dpmsproc.h"
+#endif
+#ifdef __CYGWIN__
+#include <mntent.h>
+#endif
+#if defined(WIN32)
+#include "xkbsrv.h"
+#endif
+
+#ifdef RELOCATE_PROJECTROOT
+#undef Status
+#include <shlobj.h>
+typedef HRESULT (__stdcall * SHGETFOLDERPATHPROC)(
+ HWND hwndOwner,
+ int nFolder,
+ HANDLE hToken,
+ DWORD dwFlags,
+ LPSTR pszPath
+);
+#endif
+
+
+/*
+ * References to external symbols
+ */
+
+extern int g_iNumScreens;
+extern winScreenInfo g_ScreenInfo[];
+extern int g_iLastScreen;
+extern char * g_pszCommandLine;
+extern Bool g_fSilentFatalError;
+
+extern const char * g_pszLogFile;
+extern Bool g_fLogFileChanged;
+extern int g_iLogVerbose;
+Bool g_fLogInited;
+
+extern Bool g_fXdmcpEnabled;
+extern Bool g_fAuthEnabled;
+#ifdef HAS_DEVWINDOWS
+extern int g_fdMessageQueue;
+#endif
+extern const char * g_pszQueryHost;
+extern HINSTANCE g_hInstance;
+
+#ifdef XWIN_CLIPBOARD
+extern Bool g_fUnicodeClipboard;
+extern Bool g_fClipboardLaunched;
+extern Bool g_fClipboardStarted;
+extern pthread_t g_ptClipboardProc;
+extern HWND g_hwndClipboard;
+extern Bool g_fClipboard;
+#endif
+
+extern HMODULE g_hmodDirectDraw;
+extern FARPROC g_fpDirectDrawCreate;
+extern FARPROC g_fpDirectDrawCreateClipper;
+
+extern HMODULE g_hmodCommonControls;
+extern FARPROC g_fpTrackMouseEvent;
+extern Bool g_fNoHelpMessageBox;
+extern Bool g_fSilentDupError;
+
+
+/*
+ * Function prototypes
+ */
+
+#ifdef XWIN_CLIPBOARD
+static void
+winClipboardShutdown (void);
+#endif
+
+#if defined(DDXOSVERRORF)
+void
+OsVendorVErrorF (const char *pszFormat, va_list va_args);
+#endif
+
+void
+winInitializeDefaultScreens (void);
+
+static Bool
+winCheckDisplayNumber (void);
+
+void
+winLogCommandLine (int argc, char *argv[]);
+
+void
+winLogVersionInfo (void);
+
+Bool
+winValidateArgs (void);
+
+#ifdef RELOCATE_PROJECTROOT
+const char *
+winGetBaseDir(void);
+#endif
+
+static
+void glx_debugging(void);
+
+/*
+ * For the depth 24 pixmap we default to 32 bits per pixel, but
+ * we change this pixmap format later if we detect that the display
+ * is going to be running at 24 bits per pixel.
+ *
+ * FIXME: On second thought, don't DIBs only support 32 bits per pixel?
+ * DIBs are the underlying bitmap used for DirectDraw surfaces, so it
+ * seems that all pixmap formats with depth 24 would be 32 bits per pixel.
+ * Confirm whether depth 24 DIBs can have 24 bits per pixel, then remove/keep
+ * the bits per pixel adjustment and update this comment to reflect the
+ * situation. Harold Hunt - 2002/07/02
+ */
+
+static PixmapFormatRec g_PixmapFormats[] = {
+ { 1, 1, BITMAP_SCANLINE_PAD },
+ { 4, 8, BITMAP_SCANLINE_PAD },
+ { 8, 8, BITMAP_SCANLINE_PAD },
+ { 15, 16, BITMAP_SCANLINE_PAD },
+ { 16, 16, BITMAP_SCANLINE_PAD },
+ { 24, 32, BITMAP_SCANLINE_PAD },
+#ifdef RENDER
+ { 32, 32, BITMAP_SCANLINE_PAD }
+#endif
+};
+
+const int NUMFORMATS = sizeof (g_PixmapFormats) / sizeof (g_PixmapFormats[0]);
+
+#ifdef XWIN_CLIPBOARD
+static void
+winClipboardShutdown (void)
+{
+ /* Close down clipboard resources */
+ if (g_fClipboard && g_fClipboardLaunched && g_fClipboardStarted)
+ {
+ /* Synchronously destroy the clipboard window */
+ if (g_hwndClipboard != NULL)
+ {
+ SendMessage (g_hwndClipboard, WM_DESTROY, 0, 0);
+ /* NOTE: g_hwndClipboard is set to NULL in winclipboardthread.c */
+ }
+ else
+ return;
+
+ /* Wait for the clipboard thread to exit */
+ pthread_join (g_ptClipboardProc, NULL);
+
+ winDebug ("winClipboardShutdown - Clipboard thread has exited.\n");
+ }
+}
+#endif
+
+
+#if defined(DDXBEFORERESET)
+/*
+ * Called right before KillAllClients when the server is going to reset,
+ * allows us to shutdown our seperate threads cleanly.
+ */
+
+void
+ddxBeforeReset (void)
+{
+ winDebug ("ddxBeforeReset - Hello\n");
+
+#ifdef XWIN_CLIPBOARD
+ winClipboardShutdown ();
+#endif
+}
+#endif
+
+
+/* See Porting Layer Definition - p. 57 */
+void
+ddxGiveUp (void)
+{
+ int i;
+
+ winDebug ("ddxGiveUp\n");
+
+ /* Perform per-screen deinitialization */
+ for (i = 0; i < g_iNumScreens; ++i)
+ {
+ /* Delete the tray icon */
+ if (!g_ScreenInfo[i].fNoTrayIcon && g_ScreenInfo[i].pScreen)
+ winDeleteNotifyIcon (winGetScreenPriv (g_ScreenInfo[i].pScreen));
+ }
+
+#ifdef XWIN_MULTIWINDOW
+ /* Notify the worker threads we're exiting */
+ winDeinitMultiWindowWM ();
+#endif
+
+#ifdef HAS_DEVWINDOWS
+ /* Close our handle to our message queue */
+ if (g_fdMessageQueue != WIN_FD_INVALID)
+ {
+ /* Close /dev/windows */
+ close (g_fdMessageQueue);
+
+ /* Set the file handle to invalid */
+ g_fdMessageQueue = WIN_FD_INVALID;
+ }
+#endif
+
+ if (!g_fLogInited) {
+ g_pszLogFile = LogInit (g_pszLogFile, NULL);
+ g_fLogInited = TRUE;
+ }
+ LogClose ();
+
+ /*
+ * At this point we aren't creating any new screens, so
+ * we are guaranteed to not need the DirectDraw functions.
+ */
+ if (g_hmodDirectDraw != NULL)
+ {
+ FreeLibrary (g_hmodDirectDraw);
+ g_hmodDirectDraw = NULL;
+ g_fpDirectDrawCreate = NULL;
+ g_fpDirectDrawCreateClipper = NULL;
+ }
+
+ /* Unload our TrackMouseEvent funtion pointer */
+ if (g_hmodCommonControls != NULL)
+ {
+ FreeLibrary (g_hmodCommonControls);
+ g_hmodCommonControls = NULL;
+ g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;
+ }
+
+ /* Free concatenated command line */
+ if (g_pszCommandLine)
+ {
+ free (g_pszCommandLine);
+ g_pszCommandLine = NULL;
+ }
+
+ /* Remove our keyboard hook if it is installed */
+ winRemoveKeyboardHookLL ();
+
+ /* Tell Windows that we want to end the app */
+ PostQuitMessage (0);
+}
+
+
+/* See Porting Layer Definition - p. 57 */
+void
+AbortDDX (void)
+{
+ winDebug ("AbortDDX\n");
+ ddxGiveUp ();
+}
+
+#ifdef __CYGWIN__
+/* hasmntopt is currently not implemented for cygwin */
+static const char *winCheckMntOpt(const struct mntent *mnt, const char *opt)
+{
+ const char *s;
+ size_t len;
+ if (mnt == NULL)
+ return NULL;
+ if (opt == NULL)
+ return NULL;
+ if (mnt->mnt_opts == NULL)
+ return NULL;
+
+ len = strlen(opt);
+ s = strstr(mnt->mnt_opts, opt);
+ if (s == NULL)
+ return NULL;
+ if ((s == mnt->mnt_opts || *(s-1) == ',') && (s[len] == 0 || s[len] == ','))
+ return (char *)opt;
+ return NULL;
+}
+
+static void
+winCheckMount(void)
+{
+ FILE *mnt;
+ struct mntent *ent;
+
+ enum { none = 0, sys_root, user_root, sys_tmp, user_tmp }
+ level = none, curlevel;
+ BOOL binary = TRUE;
+
+ mnt = setmntent("/etc/mtab", "r");
+ if (mnt == NULL)
+ {
+ ErrorF("setmntent failed");
+ return;
+ }
+
+ while ((ent = getmntent(mnt)) != NULL)
+ {
+ BOOL system = (winCheckMntOpt(ent, "user") != NULL);
+ BOOL root = (strcmp(ent->mnt_dir, "/") == 0);
+ BOOL tmp = (strcmp(ent->mnt_dir, "/tmp") == 0);
+
+ if (system)
+ {
+ if (root)
+ curlevel = sys_root;
+ else if (tmp)
+ curlevel = sys_tmp;
+ else
+ continue;
+ }
+ else
+ {
+ if (root)
+ curlevel = user_root;
+ else if (tmp)
+ curlevel = user_tmp;
+ else
+ continue;
+ }
+
+ if (curlevel <= level)
+ continue;
+ level = curlevel;
+
+ if ((winCheckMntOpt(ent, "binary") == NULL) ||
+ (winCheckMntOpt(ent, "binmode") == NULL))
+ binary = 0;
+ else
+ binary = 1;
+ }
+
+ if (endmntent(mnt) != 1)
+ {
+ ErrorF("endmntent failed");
+ return;
+ }
+
+#ifdef WINDBG
+ if (!binary)
+ winDebug("/tmp mounted in textmode\n");
+#endif
+}
+#else
+static void
+winCheckMount(void)
+{
+}
+#endif
+
+#ifdef RELOCATE_PROJECTROOT
+const char *
+winGetBaseDir(void)
+{
+ static BOOL inited = FALSE;
+ static char buffer[MAX_PATH];
+ if (!inited)
+ {
+ char *fendptr;
+ HMODULE module = GetModuleHandle(NULL);
+ DWORD size = GetModuleFileName(module, buffer, sizeof(buffer));
+ if (sizeof(buffer) > 0)
+ buffer[sizeof(buffer)-1] = 0;
+
+ fendptr = buffer + size;
+ while (fendptr > buffer)
+ {
+ if (*fendptr == '\\' || *fendptr == '/')
+ {
+ *fendptr = 0;
+ break;
+ }
+ fendptr--;
+ }
+ inited = TRUE;
+ }
+ return buffer;
+}
+#endif
+
+static void
+winFixupPaths (void)
+{
+ BOOL changed_fontpath = FALSE;
+ MessageType font_from = X_DEFAULT;
+#ifdef RELOCATE_PROJECTROOT
+ const char *basedir = winGetBaseDir();
+ size_t basedirlen = strlen(basedir);
+#endif
+
+#ifdef READ_FONTDIRS
+ {
+ /* Open fontpath configuration file */
+#if defined WIN32 && defined __MINGW32__
+ static Bool once = False;
+ char buffer[MAX_PATH];
+ snprintf(buffer, sizeof(buffer), "%s\\font-dirs", basedir);
+ buffer[sizeof(buffer)-1] = 0;
+ FILE *fontdirs = fopen(buffer, "rt");
+ if (once) fontdirs = NULL;
+ else once = True;
+#else
+ FILE *fontdirs = fopen(ETCX11DIR "/font-dirs", "rt");
+#endif
+ if (fontdirs != NULL)
+ {
+ char buffer[256];
+ int needs_sep = TRUE;
+ int comment_block = FALSE;
+
+ /* get defautl fontpath */
+ char *fontpath = xstrdup(defaultFontPath);
+ size_t size = strlen(fontpath);
+
+ /* read all lines */
+ while (!feof(fontdirs))
+ {
+ size_t blen;
+ char *hashchar;
+ char *str;
+ int has_eol = FALSE;
+
+ /* read one line */
+ str = fgets(buffer, sizeof(buffer), fontdirs);
+ if (str == NULL) /* stop on error or eof */
+ break;
+
+ if (strchr(str, '\n') != NULL)
+ has_eol = TRUE;
+
+ /* check if block is continued comment */
+ if (comment_block)
+ {
+ /* ignore all input */
+ *str = 0;
+ blen = 0;
+ if (has_eol) /* check if line ended in this block */
+ comment_block = FALSE;
+ }
+ else
+ {
+ /* find comment character. ignore all trailing input */
+ hashchar = strchr(str, '#');
+ if (hashchar != NULL)
+ {
+ *hashchar = 0;
+ if (!has_eol) /* mark next block as continued comment */
+ comment_block = TRUE;
+ }
+ }
+
+ /* strip whitespaces from beginning */
+ while (*str == ' ' || *str == '\t')
+ str++;
+
+ /* get size, strip whitespaces from end */
+ blen = strlen(str);
+ while (blen > 0 && (str[blen-1] == ' ' ||
+ str[blen-1] == '\t' || str[blen-1] == '\n'))
+ {
+ str[--blen] = 0;
+ }
+
+ /* still something left to add? */
+ if (blen > 0)
+ {
+ size_t newsize = size + blen;
+ /* reserve one character more for ',' */
+ if (needs_sep)
+ newsize++;
+
+ /* allocate memory */
+ if (fontpath == NULL)
+ fontpath = malloc(newsize+1);
+ else
+ fontpath = realloc(fontpath, newsize+1);
+
+ /* add separator */
+ if (needs_sep)
+ {
+ fontpath[size] = ',';
+ size++;
+ needs_sep = FALSE;
+ }
+
+ /* mark next line as new entry */
+ if (has_eol)
+ needs_sep = TRUE;
+
+ /* add block */
+ strncpy(fontpath + size, str, blen);
+ fontpath[newsize] = 0;
+ size = newsize;
+ }
+ }
+
+ /* cleanup */
+ fclose(fontdirs);
+ defaultFontPath = xstrdup(fontpath);
+ free(fontpath);
+ changed_fontpath = TRUE;
+ font_from = X_CONFIG;
+ }
+ }
+#endif /* READ_FONTDIRS */
+#ifdef RELOCATE_PROJECTROOT
+ {
+ const char *libx11dir = PROJECTROOT "/lib/X11";
+ size_t libx11dir_len = strlen(libx11dir);
+ char *newfp = NULL;
+ size_t newfp_len = 0;
+ const char *endptr, *ptr, *oldptr = defaultFontPath;
+
+ endptr = oldptr + strlen(oldptr);
+ ptr = strchr(oldptr, ',');
+ if (ptr == NULL)
+ ptr = endptr;
+ while (ptr != NULL)
+ {
+ size_t oldfp_len = (ptr - oldptr);
+ size_t newsize = oldfp_len;
+ char *newpath = malloc(newsize + 1);
+ strncpy(newpath, oldptr, newsize);
+ newpath[newsize] = 0;
+
+
+ if (strncmp(libx11dir, newpath, libx11dir_len) == 0)
+ {
+ char *compose;
+ newsize = newsize - libx11dir_len + basedirlen;
+ compose = malloc(newsize + 1);
+ strcpy(compose, basedir);
+ strncat(compose, newpath + libx11dir_len, newsize - basedirlen);
+ compose[newsize] = 0;
+ free(newpath);
+ newpath = compose;
+ }
+
+ oldfp_len = newfp_len;
+ if (oldfp_len > 0)
+ newfp_len ++; /* space for separator */
+ newfp_len += newsize;
+
+ if (newfp == NULL)
+ newfp = malloc(newfp_len + 1);
+ else
+ newfp = realloc(newfp, newfp_len + 1);
+
+ if (oldfp_len > 0)
+ {
+ strcpy(newfp + oldfp_len, ",");
+ oldfp_len++;
+ }
+ strcpy(newfp + oldfp_len, newpath);
+
+ free(newpath);
+
+ if (*ptr == 0)
+ {
+ oldptr = ptr;
+ ptr = NULL;
+ } else
+ {
+ oldptr = ptr + 1;
+ ptr = strchr(oldptr, ',');
+ if (ptr == NULL)
+ ptr = endptr;
+ }
+ }
+
+ defaultFontPath = xstrdup(newfp);
+ free(newfp);
+ changed_fontpath = TRUE;
+ }
+#endif /* RELOCATE_PROJECTROOT */
+ if (changed_fontpath)
+ winDebug ("FontPath set to \"%s\"\n", defaultFontPath);
+
+#ifdef RELOCATE_PROJECTROOT
+ if (getenv("XKEYSYMDB") == NULL)
+ {
+ char buffer[MAX_PATH];
+ snprintf(buffer, sizeof(buffer), "XKEYSYMDB=%s\\XKeysymDB",
+ basedir);
+ buffer[sizeof(buffer)-1] = 0;
+ putenv(buffer);
+ }
+ if (getenv("XERRORDB") == NULL)
+ {
+ char buffer[MAX_PATH];
+ snprintf(buffer, sizeof(buffer), "XERRORDB=%s\\XErrorDB",
+ basedir);
+ buffer[sizeof(buffer)-1] = 0;
+ putenv(buffer);
+ }
+ if (getenv("XLOCALEDIR") == NULL)
+ {
+ char buffer[MAX_PATH];
+ snprintf(buffer, sizeof(buffer), "XLOCALEDIR=%s\\locale",
+ basedir);
+ buffer[sizeof(buffer)-1] = 0;
+ putenv(buffer);
+ }
+ if (getenv("XHOSTPREFIX") == NULL)
+ {
+ char buffer[MAX_PATH];
+ snprintf(buffer, sizeof(buffer), "XHOSTPREFIX=%s\\X",
+ basedir);
+ buffer[sizeof(buffer)-1] = 0;
+ putenv(buffer);
+ }
+ if (getenv("HOME") == NULL)
+ {
+ HMODULE shfolder;
+ SHGETFOLDERPATHPROC shgetfolderpath = NULL;
+ char buffer[MAX_PATH + 5];
+ strncpy(buffer, "HOME=", 5);
+
+ /* Try to load SHGetFolderPath from shfolder.dll and shell32.dll */
+
+ shfolder = LoadLibrary("shfolder.dll");
+ /* fallback to shell32.dll */
+ if (shfolder == NULL)
+ shfolder = LoadLibrary("shell32.dll");
+
+ /* resolve SHGetFolderPath */
+ if (shfolder != NULL)
+ shgetfolderpath = (SHGETFOLDERPATHPROC)GetProcAddress(shfolder, "SHGetFolderPathA");
+
+ /* query appdata directory */
+ if (shgetfolderpath &&
+ shgetfolderpath(NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, NULL, 0,
+ buffer + 5) == 0)
+ {
+ putenv(buffer);
+ } else
+ {
+ ErrorF ("Can not determine HOME directory\n");
+ }
+ if (shfolder != NULL)
+ FreeLibrary(shfolder);
+ }
+ if (!g_fLogFileChanged) {
+ static char buffer[MAX_PATH];
+ DWORD size = GetTempPath(sizeof(buffer), buffer);
+ if (size && size < sizeof(buffer))
+ {
+ snprintf(buffer + size, sizeof(buffer) - size,
+ "VCXSrv.%s.log", display);
+ buffer[sizeof(buffer)-1] = 0;
+ g_pszLogFile = buffer;
+ GetLongPathName(buffer, buffer, MAX_PATH);
+ winDebug ("Logfile set to \"%s\"\n", g_pszLogFile);
+ }
+ }
+ {
+ static char xkbbasedir[MAX_PATH];
+
+ snprintf(xkbbasedir, sizeof(xkbbasedir), "%s\\xkbdata", basedir);
+ if (sizeof(xkbbasedir) > 0)
+ xkbbasedir[sizeof(xkbbasedir)-1] = 0;
+ XkbBaseDirectory = xkbbasedir;
+ XkbBinDirectory = basedir;
+ }
+#endif /* RELOCATE_PROJECTROOT */
+}
+
+void
+OsVendorInit (void)
+{
+ /* Re-initialize global variables on server reset */
+ winInitializeGlobals ();
+
+ winFixupPaths();
+
+#ifdef DDXOSVERRORF
+ if (!OsVendorVErrorFProc)
+ OsVendorVErrorFProc = OsVendorVErrorF;
+#endif
+
+ if (!g_fLogInited) {
+ /* keep this order. If LogInit fails it calls Abort which then calls
+ * ddxGiveUp where LogInit is called again and creates an infinite
+ * recursion. If we set g_fLogInited to TRUE before the init we
+ * avoid the second call
+ */
+ g_fLogInited = TRUE;
+ g_pszLogFile = LogInit (g_pszLogFile, NULL);
+ }
+ LogSetParameter (XLOG_FLUSH, 1);
+ LogSetParameter (XLOG_VERBOSITY, g_iLogVerbose);
+ LogSetParameter (XLOG_FILE_VERBOSITY, g_iLogVerbose);
+
+ /* Log the version information */
+ if (serverGeneration == 1)
+ winLogVersionInfo ();
+
+ winCheckMount();
+
+ /* Add a default screen if no screens were specified */
+ if (g_iNumScreens == 0)
+ {
+ winDebug ("OsVendorInit - Creating bogus screen 0\n");
+
+ /*
+ * We need to initialize default screens if no arguments
+ * were processed. Otherwise, the default screens would
+ * already have been initialized by ddxProcessArgument ().
+ */
+ winInitializeDefaultScreens ();
+
+ /*
+ * Add a screen 0 using the defaults set by
+ * winInitializeDefaultScreens () and any additional parameters
+ * processed by ddxProcessArgument ().
+ */
+ g_iNumScreens = 1;
+ g_iLastScreen = 0;
+
+ /* We have to flag this as an explicit screen, even though it isn't */
+ g_ScreenInfo[0].fExplicitScreen = TRUE;
+ }
+}
+
+
+static void
+winUseMsg (void)
+{
+ ErrorF ("-depth bits_per_pixel\n"
+ "\tSpecify an optional bitdepth to use in fullscreen mode\n"
+ "\twith a DirectDraw engine.\n");
+
+ ErrorF ("-emulate3buttons [timeout]\n"
+ "\tEmulate 3 button mouse with an optional timeout in\n"
+ "\tmilliseconds.\n");
+
+ ErrorF ("-engine engine_type_id\n"
+ "\tOverride the server's automatically selected engine type:\n"
+ "\t\t1 - Shadow GDI\n"
+ "\t\t2 - Shadow DirectDraw\n"
+ "\t\t4 - Shadow DirectDraw4 Non-Locking\n"
+#ifdef XWIN_NATIVEGDI
+ "\t\t16 - Native GDI - experimental\n"
+#endif
+ );
+
+ ErrorF ("-fullscreen\n"
+ "\tRun the server in fullscreen mode.\n");
+
+ ErrorF ("-refresh rate_in_Hz\n"
+ "\tSpecify an optional refresh rate to use in fullscreen mode\n"
+ "\twith a DirectDraw engine.\n");
+
+ ErrorF ("-screen scr_num [width height [x y] | [[WxH[+X+Y]][@m]] ]\n"
+ "\tEnable screen scr_num and optionally specify a width and\n"
+ "\theight and initial position for that screen. Additionally\n"
+ "\ta monitor number can be specified to start the server on,\n"
+ "\tat which point, all coordinates become relative to that\n"
+ "\tmonitor (Not for Windows NT4 and 95). Examples:\n"
+ "\t -screen 0 800x600+100+100@2 ; 2nd monitor offset 100,100 size 800x600\n"
+ "\t -screen 0 1024x768@3 ; 3rd monitor size 1024x768\n"
+ "\t -screen 0 @1 ; on 1st monitor using its full resolution (the default)\n");
+
+ ErrorF ("-lesspointer\n"
+ "\tHide the windows mouse pointer when it is over an inactive\n"
+ "\t" PROJECT_NAME " window. This prevents ghost cursors appearing where\n"
+ "\tthe Windows cursor is drawn overtop of the X cursor\n");
+
+ ErrorF ("-nodecoration\n"
+ "\tDo not draw a window border, title bar, etc. Windowed\n"
+ "\tmode only.\n");
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+ ErrorF ("-mwextwm\n"
+ "\tRun the server in multi-window external window manager mode.\n");
+
+ ErrorF ("-internalwm\n"
+ "\tRun the internal window manager.\n");
+#endif
+
+ ErrorF ("-rootless\n"
+ "\tRun the server in rootless mode.\n");
+
+#ifdef XWIN_MULTIWINDOW
+ ErrorF ("-multiwindow\n"
+ "\tRun the server in multi-window mode.\n");
+#endif
+
+ ErrorF ("-multiplemonitors\n"
+ "\tEXPERIMENTAL: Use the entire virtual screen if multiple\n"
+ "\tmonitors are present.\n");
+
+#ifdef XWIN_CLIPBOARD
+ ErrorF ("-[no]clipboard\n"
+ "\tEnable [disable] the clipboard integration. Default is enabled.\n");
+
+ ErrorF ("-nounicodeclipboard\n"
+ "\tDo not use Unicode clipboard even if NT-based platform.\n");
+#endif
+
+ ErrorF ("-scrollbars\n"
+ "\tIn windowed mode, allow screens bigger than the Windows desktop.\n"
+ "\tMoreover, if the window has decorations, one can now resize\n"
+ "\tit.\n");
+
+ ErrorF ("-[no]trayicon\n"
+ "\tDo not create a tray icon. Default is to create one\n"
+ "\ticon per screen. You can globally disable tray icons with\n"
+ "\t-notrayicon, then enable it for specific screens with\n"
+ "\t-trayicon for those screens.\n");
+
+ ErrorF ("-clipupdates num_boxes\n"
+ "\tUse a clipping region to constrain shadow update blits to\n"
+ "\tthe updated region when num_boxes, or more, are in the\n"
+ "\tupdated region. Currently supported only by `-engine 1'.\n");
+
+#ifdef XWIN_EMULATEPSEUDO
+ ErrorF ("-emulatepseudo\n"
+ "\tCreate a depth 8 PseudoColor visual when running in\n"
+ "\tdepths 15, 16, 24, or 32, collectively known as TrueColor\n"
+ "\tdepths. The PseudoColor visual does not have correct colors,\n"
+ "\tand it may crash, but it at least allows you to run your\n"
+ "\tapplication in TrueColor modes.\n");
+#endif
+
+ ErrorF ("-[no]unixkill\n"
+ "\tCtrl+Alt+Backspace exits the X Server.\n");
+
+ ErrorF ("-[no]winkill\n"
+ "\tAlt+F4 exits the X Server.\n");
+
+#ifdef XWIN_XF86CONFIG
+ ErrorF ("-config\n"
+ "\tSpecify a configuration file.\n");
+
+ ErrorF ("-keyboard\n"
+ "\tSpecify a keyboard device from the configuration file.\n");
+#endif
+
+ ErrorF ("-xkbrules XKBRules\n"
+ "\tEquivalent to XKBRules in XF86Config files.\n");
+
+ ErrorF ("-xkbmodel XKBModel\n"
+ "\tEquivalent to XKBModel in XF86Config files.\n");
+
+ ErrorF ("-xkblayout XKBLayout\n"
+ "\tEquivalent to XKBLayout in XF86Config files.\n"
+ "\tFor example: -xkblayout de\n");
+
+ ErrorF ("-xkbvariant XKBVariant\n"
+ "\tEquivalent to XKBVariant in XF86Config files.\n"
+ "\tFor example: -xkbvariant nodeadkeys\n");
+
+ ErrorF ("-xkboptions XKBOptions\n"
+ "\tEquivalent to XKBOptions in XF86Config files.\n");
+
+ ErrorF ("-logfile filename\n"
+ "\tWrite logmessages to <filename>.\n");
+
+ ErrorF ("-logverbose verbosity\n"
+ "\tSet the verbosity of logmessages. [NOTE: Only a few messages\n"
+ "\trespect the settings yet]\n"
+ "\t\t0 - only print fatal error.\n"
+ "\t\t1 - print additional configuration information.\n"
+ "\t\t2 - print additional runtime information [default].\n"
+ "\t\t3 - print debugging and tracing information.\n");
+
+ ErrorF ("-[no]keyhook\n"
+ "\tGrab special windows key combinations like Alt-Tab or the Menu "
+ "key.\n These keys are discarded by default.\n");
+
+ ErrorF ("-swcursor\n"
+ "\tDisable the usage of the windows cursor and use the X11 software "
+ "cursor instead\n");
+}
+
+/* See Porting Layer Definition - p. 57 */
+void
+ddxUseMsg(void)
+{
+ /* Set a flag so that FatalError won't give duplicate warning message */
+ g_fSilentFatalError = TRUE;
+
+ winUseMsg();
+
+ /* Log file will not be opened for UseMsg unless we open it now */
+ if (!g_fLogInited) {
+ g_pszLogFile = LogInit (g_pszLogFile, NULL);
+ g_fLogInited = TRUE;
+ }
+ LogClose ();
+
+ /* Notify user where UseMsg text can be found.*/
+ if (!g_fNoHelpMessageBox)
+ winMessageBoxF ("The " PROJECT_NAME " help text has been printed to "
+ "%s.\n"
+ "Please open %s to read the help text.\n",
+ MB_ICONINFORMATION, g_pszLogFile, g_pszLogFile);
+}
+
+/* See Porting Layer Definition - p. 20 */
+/*
+ * Do any global initialization, then initialize each screen.
+ *
+ * NOTE: We use ddxProcessArgument, so we don't need to touch argc and argv
+ */
+
+void
+InitOutput (ScreenInfo *screenInfo, int argc, char *argv[])
+{
+ int i;
+
+ /* Log the command line */
+ winLogCommandLine (argc, argv);
+
+ winDebug ("InitOutput\n");
+
+ /* Validate command-line arguments */
+ if (serverGeneration == 1 && !winValidateArgs ())
+ {
+ FatalError ("InitOutput - Invalid command-line arguments found. "
+ "Exiting.\n");
+ }
+
+ /* Check for duplicate invocation on same display number.*/
+ if (serverGeneration == 1 && !winCheckDisplayNumber ())
+ {
+ if (g_fSilentDupError)
+ g_fSilentFatalError = TRUE;
+ FatalError ("InitOutput - Duplicate invocation on display "
+ "number: %s. Exiting.\n", display);
+ }
+
+#ifdef XWIN_XF86CONFIG
+ /* Try to read the xorg.conf-style configuration file */
+ if (!winReadConfigfile ())
+ ErrorF ("InitOutput - Error reading config file\n");
+#else
+ winConfigFiles ();
+#endif
+
+ /* Load preferences from XWinrc file */
+ LoadPreferences();
+
+ /* Setup global screen info parameters */
+ screenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
+ screenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+ screenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+ screenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
+ screenInfo->numPixmapFormats = NUMFORMATS;
+
+ /* Describe how we want common pixmap formats padded */
+ for (i = 0; i < NUMFORMATS; i++)
+ {
+ screenInfo->formats[i] = g_PixmapFormats[i];
+ }
+
+ /* Load pointers to DirectDraw functions */
+ winGetDDProcAddresses ();
+
+ /* Detect supported engines */
+ winDetectSupportedEngines ();
+
+ /* Load common controls library */
+ g_hmodCommonControls = LoadLibraryEx ("comctl32.dll", NULL, 0);
+
+ /* Load TrackMouseEvent function pointer */
+ g_fpTrackMouseEvent = GetProcAddress (g_hmodCommonControls,
+ "_TrackMouseEvent");
+ if (g_fpTrackMouseEvent == NULL)
+ {
+ ErrorF ("InitOutput - Could not get pointer to function\n"
+ "\t_TrackMouseEvent in comctl32.dll. Try installing\n"
+ "\tInternet Explorer 3.0 or greater if you have not\n"
+ "\talready.\n");
+
+ /* Free the library since we won't need it */
+ FreeLibrary (g_hmodCommonControls);
+ g_hmodCommonControls = NULL;
+
+ /* Set function pointer to point to no operation function */
+ g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;
+ }
+
+ /* Store the instance handle */
+ g_hInstance = GetModuleHandle (NULL);
+
+ /* Initialize each screen */
+ for (i = 0; i < g_iNumScreens; ++i)
+ {
+ /* Initialize the screen */
+ if (-1 == AddScreen (winScreenInit, argc, argv))
+ {
+ FatalError ("InitOutput - Couldn't add screen %d", i);
+ }
+ }
+
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+
+ /* Generate a cookie used by internal clients for authorization */
+ if (g_fXdmcpEnabled || g_fAuthEnabled)
+ winGenerateAuthorization ();
+
+ /* Perform some one time initialization */
+ if (1 == serverGeneration)
+ {
+ /*
+ * setlocale applies to all threads in the current process.
+ * Apply locale specified in LANG environment variable.
+ */
+ setlocale (LC_ALL, "");
+
+ glx_debugging();
+ }
+#endif
+
+ winDebug ("InitOutput - Returning.\n");
+}
+
+
+/*
+ * winCheckDisplayNumber - Check if another instance of Cygwin/X is
+ * already running on the same display number. If no one exists,
+ * make a mutex to prevent new instances from running on the same display.
+ *
+ * return FALSE if the display number is already used.
+ */
+
+static Bool
+winCheckDisplayNumber (void)
+{
+ int nDisp;
+ HANDLE mutex;
+ char name[MAX_PATH];
+ char * pszPrefix = '\0';
+ OSVERSIONINFO osvi = {0};
+
+ /* Check display range */
+ nDisp = atoi (display);
+ if (nDisp < 0 || nDisp > 59535)
+ {
+ ErrorF ("winCheckDisplayNumber - Bad display number: %d\n", nDisp);
+ return FALSE;
+ }
+
+ /* Set first character of mutex name to null */
+ name[0] = '\0';
+
+ /* Get operating system version information */
+ osvi.dwOSVersionInfoSize = sizeof (osvi);
+ GetVersionEx (&osvi);
+
+ /* Want a mutex shared among all terminals on NT > 4.0 */
+ if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT
+ && osvi.dwMajorVersion >= 5)
+ {
+ pszPrefix = "Global\\";
+ }
+
+ /* Setup Cygwin/X specific part of name */
+ snprintf (name, sizeof(name), "%sCYGWINX_DISPLAY:%d", pszPrefix, nDisp);
+
+ /* Windows automatically releases the mutex when this process exits */
+ mutex = CreateMutex (NULL, FALSE, name);
+ if (!mutex)
+ {
+ LPVOID lpMsgBuf;
+
+ /* Display a fancy error message */
+ FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError (),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &lpMsgBuf,
+ 0, NULL);
+ ErrorF ("winCheckDisplayNumber - CreateMutex failed: %s\n",
+ (LPSTR)lpMsgBuf);
+ LocalFree (lpMsgBuf);
+
+ return FALSE;
+ }
+ if (GetLastError () == ERROR_ALREADY_EXISTS)
+ {
+ ErrorF ("winCheckDisplayNumber - "
+ "VCXsrv, Xming or Cygwin/X is already running on display %d\n",
+ nDisp);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* GLX debugging helpers */
+#include <../glx/glapi.h>
+
+static
+void warn_func(void * p1, const char *format, ...) {
+ va_list v;
+ va_start(v, format);
+ vfprintf(stderr, format, v);
+ va_end(v);
+ fprintf(stderr,"\n");
+}
+
+static
+void glx_debugging(void)
+{
+ _glapi_set_warning_func(warn_func);
+ _glapi_noop_enable_warnings(TRUE);
+}
diff --git a/xorg-server/hw/xwin/XWin.rc b/xorg-server/hw/xwin/XWin.rc
index df2664dca..6b4970fdb 100644
--- a/xorg-server/hw/xwin/XWin.rc
+++ b/xorg-server/hw/xwin/XWin.rc
@@ -1,108 +1,102 @@
-/*
- *Copyright (C) 2002-2004 Harold L Hunt II All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, 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 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 HAROLD L HUNT II 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 Harold L Hunt II
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from Harold L Hunt II.
- *
- * Authors: Harold L Hunt II
- */
-
-#include "windows.h"
-#include "winresource.h"
-
-/*
- * Dialogs
- */
-
-/* About */
-ABOUT_BOX DIALOGEX 32, 32, 240, 105
-STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_TABSTOP | DS_CENTERMOUSE
-CAPTION "About " PROJECT_NAME
-FONT 8, "MS Sans Serif"
-BEGIN
- CONTROL PROJECT_NAME " Website", ID_ABOUT_WEBSITE, "Button",
- BS_OWNERDRAW | WS_TABSTOP, 30, 45, 75, 15
- CONTROL "Change Log", ID_ABOUT_CHANGELOG, "Button",
- BS_OWNERDRAW | WS_TABSTOP, 135, 45, 75, 15
- CONTROL "User's Guide", ID_ABOUT_UG, "Button",
- BS_OWNERDRAW | WS_TABSTOP, 30, 65, 75, 15
- CONTROL "FAQ", ID_ABOUT_FAQ, "Button",
- BS_OWNERDRAW | WS_TABSTOP, 135, 65, 75, 15
-
- DEFPUSHBUTTON "&OK", IDOK, 95, 85, 50, 15
-
- CTEXT PROJECT_NAME " X Server. Use the links below to learn more about the " PROJECT_NAME " project.", IDC_STATIC, 5, 5, 230, 35
-END
-
-
-/* Depth change */
-
-DEPTH_CHANGE_BOX DIALOGEX 32, 32, 180, 100
-STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | DS_CENTERMOUSE
-FONT 8, "MS Sans Serif"
-CAPTION PROJECT_NAME
-BEGIN
- DEFPUSHBUTTON "Dismiss", IDOK, 66, 80, 50, 14
- CTEXT PROJECT_NAME, IDC_STATIC, 40, 12, 100, 8
- CTEXT "Disruptive screen configuration change.", IDC_STATIC, 7, 40, 166, 8
- CTEXT "Restore previous resolution to use " PROJECT_NAME ".", IDC_STATIC, 7, 52, 166, 8
-END
-
-
-/* Exit */
-
-EXIT_DIALOG DIALOGEX 32, 32, 180, 78
-STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_TABSTOP | DS_CENTERMOUSE
-FONT 8, "MS Sans Serif"
-CAPTION "Exit " PROJECT_NAME "?"
-BEGIN
- PUSHBUTTON "E&xit", IDOK, 55, 56, 30, 14
- DEFPUSHBUTTON "&Cancel", IDCANCEL, 95, 56, 30, 14
- CTEXT "E&xiting will close all screens running on this display.", IDC_STATIC, 7, 12, 166, 8
- CTEXT "No information about connected clients available.", IDC_CLIENTS_CONNECTED, 7, 24, 166, 8
- CTEXT "Proceed with shutdown of this display/server?", IDC_STATIC, 7, 36, 166, 8
-END
-
-
-/*
- * Menus
- */
-
-IDM_TRAYICON_MENU MENU
-BEGIN
- POPUP "TRAYICON_MENU"
- BEGIN
- MENUITEM "&Hide Root Window", ID_APP_HIDE_ROOT
- MENUITEM "&About...", ID_APP_ABOUT
- MENUITEM SEPARATOR
- MENUITEM "E&xit", ID_APP_EXIT
- END
-END
-
-
-/*
- * Icons
- */
-
-IDI_XWIN ICON "X.ico"
+/*
+ *Copyright (C) 2002-2004 Harold L Hunt II All Rights Reserved.
+ *Copyright (C) 2008 Yaakov Selkowitz All Rights Reserved
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, 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 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 HAROLD L HUNT II 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 names of the authors
+ *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 authors.
+ *
+ * Authors: Harold L Hunt II, Yaakov Selkowitz
+ */
+
+#include <windows.h>
+#include "winresource.h"
+#include "xwin-config.h"
+
+/*
+ * Dialogs
+ */
+
+/* About */
+ABOUT_BOX DIALOGEX 32, 32, 260, 95
+STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_TABSTOP | DS_CENTERMOUSE
+CAPTION "About VcXsrv"
+FONT 8, "MS Shell Dlg 2"
+BEGIN
+ CONTROL IDI_XWIN, IDC_STATIC, "Static", SS_ICON, 8, 8, 32, 32
+ LTEXT "VcXsrv X Server ", IDC_STATIC, 36, 8, 220, 8
+ LTEXT "Version 1.7.99.2 (13 Nov 2009)", IDC_STATIC, 36, 18, 220, 8
+ DEFPUSHBUTTON "OK", IDOK, 105, 75, 50, 15
+END
+
+
+/* Depth change */
+
+DEPTH_CHANGE_BOX DIALOGEX 32, 32, 180, 100
+STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | DS_CENTERMOUSE
+FONT 8, "MS Shell Dlg 2"
+CAPTION "VcXsrv"
+BEGIN
+ DEFPUSHBUTTON "Dismiss", IDOK, 66, 80, 50, 14
+ CTEXT "VcXsrv", IDC_STATIC, 40, 12, 100, 8
+ CTEXT "Disruptive screen configuration change.", IDC_STATIC, 7, 40, 166, 8
+ CTEXT "Restore previous resolution to use VcXsrv.", IDC_STATIC, 7, 52, 166, 8
+END
+
+
+/* Exit */
+
+EXIT_DIALOG DIALOGEX 32, 32, 180, 78
+STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_TABSTOP | DS_CENTERMOUSE
+FONT 8, "MS Shell Dlg 2"
+CAPTION "Exit VcXsrv?"
+BEGIN
+ PUSHBUTTON "E&xit", IDOK, 55, 56, 30, 14
+ DEFPUSHBUTTON "&Cancel", IDCANCEL, 95, 56, 30, 14
+ CTEXT "E&xiting will close all screens running on this display.", IDC_STATIC, 7, 12, 166, 8
+ CTEXT "No information about connected clients available.", IDC_CLIENTS_CONNECTED, 7, 24, 166, 8
+ CTEXT "Proceed with shutdown of this display/server?", IDC_STATIC, 7, 36, 166, 8
+END
+
+
+/*
+ * Menus
+ */
+
+IDM_TRAYICON_MENU MENU
+BEGIN
+ POPUP "TRAYICON_MENU"
+ BEGIN
+ MENUITEM "&Hide Root Window", ID_APP_HIDE_ROOT
+ MENUITEM "&About...", ID_APP_ABOUT
+ MENUITEM SEPARATOR
+ MENUITEM "E&xit...", ID_APP_EXIT
+ END
+END
+
+
+/*
+ * Icons
+ */
+
+IDI_XWIN ICON "X.ico"
diff --git a/xorg-server/hw/xwin/ddraw.h b/xorg-server/hw/xwin/ddraw.h
deleted file mode 100644
index 2eb7c2674..000000000
--- a/xorg-server/hw/xwin/ddraw.h
+++ /dev/null
@@ -1,2106 +0,0 @@
-#ifndef __XWIN_DDRAW_H
-#define __XWIN_DDRAW_H
-
-#include <winnt.h>
-#include <wingdi.h>
-#include <objbase.h>
-
-#if defined(NONAMELESSUNION) && !defined(DUMMYUNIONNAME1)
-#define DUMMYUNIONNAME1 u1
-#endif
-
-#define ICOM_CALL_( xfn, p, args) (p)->lpVtbl->xfn args
-
-# ifdef UNICODE
-# define WINELIB_NAME_AW(func) func##W
-# else
-# define WINELIB_NAME_AW(func) func##A
-# endif /* UNICODE */
-#define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* defined(__cplusplus) */
-
-#ifndef DIRECTDRAW_VERSION
-#define DIRECTDRAW_VERSION 0x0700
-#endif /* DIRECTDRAW_VERSION */
-
-/*****************************************************************************
- * Predeclare the interfaces
- */
-DEFINE_GUID( CLSID_DirectDraw, 0xD7B70EE0,0x4340,0x11CF,0xB0,0x63,0x00,0x20,0xAF,0xC2,0xCD,0x35 );
-DEFINE_GUID( CLSID_DirectDraw7, 0x3C305196,0x50DB,0x11D3,0x9C,0xFE,0x00,0xC0,0x4F,0xD9,0x30,0xC5 );
-DEFINE_GUID( CLSID_DirectDrawClipper, 0x593817A0,0x7DB3,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xb9,0x33,0x56 );
-DEFINE_GUID( IID_IDirectDraw, 0x6C14DB80,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 );
-DEFINE_GUID( IID_IDirectDraw2, 0xB3A6F3E0,0x2B43,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xB9,0x33,0x56 );
-DEFINE_GUID( IID_IDirectDraw4, 0x9c59509a,0x39bd,0x11d1,0x8c,0x4a,0x00,0xc0,0x4f,0xd9,0x30,0xc5 );
-DEFINE_GUID( IID_IDirectDraw7, 0x15e65ec0,0x3b9c,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b );
-DEFINE_GUID( IID_IDirectDrawSurface, 0x6C14DB81,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 );
-DEFINE_GUID( IID_IDirectDrawSurface2, 0x57805885,0x6eec,0x11cf,0x94,0x41,0xa8,0x23,0x03,0xc1,0x0e,0x27 );
-DEFINE_GUID( IID_IDirectDrawSurface3, 0xDA044E00,0x69B2,0x11D0,0xA1,0xD5,0x00,0xAA,0x00,0xB8,0xDF,0xBB );
-DEFINE_GUID( IID_IDirectDrawSurface4, 0x0B2B8630,0xAD35,0x11D0,0x8E,0xA6,0x00,0x60,0x97,0x97,0xEA,0x5B );
-DEFINE_GUID( IID_IDirectDrawSurface7, 0x06675a80,0x3b9b,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b );
-DEFINE_GUID( IID_IDirectDrawPalette, 0x6C14DB84,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 );
-DEFINE_GUID( IID_IDirectDrawClipper, 0x6C14DB85,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 );
-DEFINE_GUID( IID_IDirectDrawColorControl,0x4B9F0EE0,0x0D7E,0x11D0,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8 );
-DEFINE_GUID( IID_IDirectDrawGammaControl,0x69C11C3E,0xB46B,0x11D1,0xAD,0x7A,0x00,0xC0,0x4F,0xC2,0x9B,0x4E );
-
-typedef struct IDirectDraw *LPDIRECTDRAW;
-typedef struct IDirectDraw2 *LPDIRECTDRAW2;
-typedef struct IDirectDraw4 *LPDIRECTDRAW4;
-typedef struct IDirectDraw7 *LPDIRECTDRAW7;
-typedef struct IDirectDrawClipper *LPDIRECTDRAWCLIPPER;
-typedef struct IDirectDrawPalette *LPDIRECTDRAWPALETTE;
-typedef struct IDirectDrawSurface *LPDIRECTDRAWSURFACE;
-typedef struct IDirectDrawSurface2 *LPDIRECTDRAWSURFACE2;
-typedef struct IDirectDrawSurface3 *LPDIRECTDRAWSURFACE3;
-typedef struct IDirectDrawSurface4 *LPDIRECTDRAWSURFACE4;
-typedef struct IDirectDrawSurface7 *LPDIRECTDRAWSURFACE7;
-typedef struct IDirectDrawColorControl *LPDIRECTDRAWCOLORCONTROL;
-typedef struct IDirectDrawGammaControl *LPDIRECTDRAWGAMMACONTROL;
-
-
-#define DDENUMRET_CANCEL 0
-#define DDENUMRET_OK 1
-
-#define DD_OK 0
-
-
-#define _FACDD 0x876
-#define MAKE_DDHRESULT( code ) MAKE_HRESULT( 1, _FACDD, code )
-
-#define DDERR_ALREADYINITIALIZED MAKE_DDHRESULT( 5 )
-#define DDERR_CANNOTATTACHSURFACE MAKE_DDHRESULT( 10 )
-#define DDERR_CANNOTDETACHSURFACE MAKE_DDHRESULT( 20 )
-#define DDERR_CURRENTLYNOTAVAIL MAKE_DDHRESULT( 40 )
-#define DDERR_EXCEPTION MAKE_DDHRESULT( 55 )
-#define DDERR_GENERIC E_FAIL
-#define DDERR_HEIGHTALIGN MAKE_DDHRESULT( 90 )
-#define DDERR_INCOMPATIBLEPRIMARY MAKE_DDHRESULT( 95 )
-#define DDERR_INVALIDCAPS MAKE_DDHRESULT( 100 )
-#define DDERR_INVALIDCLIPLIST MAKE_DDHRESULT( 110 )
-#define DDERR_INVALIDMODE MAKE_DDHRESULT( 120 )
-#define DDERR_INVALIDOBJECT MAKE_DDHRESULT( 130 )
-#define DDERR_INVALIDPARAMS E_INVALIDARG
-#define DDERR_INVALIDPIXELFORMAT MAKE_DDHRESULT( 145 )
-#define DDERR_INVALIDRECT MAKE_DDHRESULT( 150 )
-#define DDERR_LOCKEDSURFACES MAKE_DDHRESULT( 160 )
-#define DDERR_NO3D MAKE_DDHRESULT( 170 )
-#define DDERR_NOALPHAHW MAKE_DDHRESULT( 180 )
-#define DDERR_NOSTEREOHARDWARE MAKE_DDHRESULT( 181 )
-#define DDERR_NOSURFACELEFT MAKE_DDHRESULT( 182 )
-#define DDERR_NOCLIPLIST MAKE_DDHRESULT( 205 )
-#define DDERR_NOCOLORCONVHW MAKE_DDHRESULT( 210 )
-#define DDERR_NOCOOPERATIVELEVELSET MAKE_DDHRESULT( 212 )
-#define DDERR_NOCOLORKEY MAKE_DDHRESULT( 215 )
-#define DDERR_NOCOLORKEYHW MAKE_DDHRESULT( 220 )
-#define DDERR_NODIRECTDRAWSUPPORT MAKE_DDHRESULT( 222 )
-#define DDERR_NOEXCLUSIVEMODE MAKE_DDHRESULT( 225 )
-#define DDERR_NOFLIPHW MAKE_DDHRESULT( 230 )
-#define DDERR_NOGDI MAKE_DDHRESULT( 240 )
-#define DDERR_NOMIRRORHW MAKE_DDHRESULT( 250 )
-#define DDERR_NOTFOUND MAKE_DDHRESULT( 255 )
-#define DDERR_NOOVERLAYHW MAKE_DDHRESULT( 260 )
-#define DDERR_OVERLAPPINGRECTS MAKE_DDHRESULT( 270 )
-#define DDERR_NORASTEROPHW MAKE_DDHRESULT( 280 )
-#define DDERR_NOROTATIONHW MAKE_DDHRESULT( 290 )
-#define DDERR_NOSTRETCHHW MAKE_DDHRESULT( 310 )
-#define DDERR_NOT4BITCOLOR MAKE_DDHRESULT( 316 )
-#define DDERR_NOT4BITCOLORINDEX MAKE_DDHRESULT( 317 )
-#define DDERR_NOT8BITCOLOR MAKE_DDHRESULT( 320 )
-#define DDERR_NOTEXTUREHW MAKE_DDHRESULT( 330 )
-#define DDERR_NOVSYNCHW MAKE_DDHRESULT( 335 )
-#define DDERR_NOZBUFFERHW MAKE_DDHRESULT( 340 )
-#define DDERR_NOZOVERLAYHW MAKE_DDHRESULT( 350 )
-#define DDERR_OUTOFCAPS MAKE_DDHRESULT( 360 )
-#define DDERR_OUTOFMEMORY E_OUTOFMEMORY
-#define DDERR_OUTOFVIDEOMEMORY MAKE_DDHRESULT( 380 )
-#define DDERR_OVERLAYCANTCLIP MAKE_DDHRESULT( 382 )
-#define DDERR_OVERLAYCOLORKEYONLYONEACTIVE MAKE_DDHRESULT( 384 )
-#define DDERR_PALETTEBUSY MAKE_DDHRESULT( 387 )
-#define DDERR_COLORKEYNOTSET MAKE_DDHRESULT( 400 )
-#define DDERR_SURFACEALREADYATTACHED MAKE_DDHRESULT( 410 )
-#define DDERR_SURFACEALREADYDEPENDENT MAKE_DDHRESULT( 420 )
-#define DDERR_SURFACEBUSY MAKE_DDHRESULT( 430 )
-#define DDERR_CANTLOCKSURFACE MAKE_DDHRESULT( 435 )
-#define DDERR_SURFACEISOBSCURED MAKE_DDHRESULT( 440 )
-#define DDERR_SURFACELOST MAKE_DDHRESULT( 450 )
-#define DDERR_SURFACENOTATTACHED MAKE_DDHRESULT( 460 )
-#define DDERR_TOOBIGHEIGHT MAKE_DDHRESULT( 470 )
-#define DDERR_TOOBIGSIZE MAKE_DDHRESULT( 480 )
-#define DDERR_TOOBIGWIDTH MAKE_DDHRESULT( 490 )
-#define DDERR_UNSUPPORTED E_NOTIMPL
-#define DDERR_UNSUPPORTEDFORMAT MAKE_DDHRESULT( 510 )
-#define DDERR_UNSUPPORTEDMASK MAKE_DDHRESULT( 520 )
-#define DDERR_INVALIDSTREAM MAKE_DDHRESULT( 521 )
-#define DDERR_VERTICALBLANKINPROGRESS MAKE_DDHRESULT( 537 )
-#define DDERR_WASSTILLDRAWING MAKE_DDHRESULT( 540 )
-#define DDERR_DDSCAPSCOMPLEXREQUIRED MAKE_DDHRESULT( 542 )
-#define DDERR_XALIGN MAKE_DDHRESULT( 560 )
-#define DDERR_INVALIDDIRECTDRAWGUID MAKE_DDHRESULT( 561 )
-#define DDERR_DIRECTDRAWALREADYCREATED MAKE_DDHRESULT( 562 )
-#define DDERR_NODIRECTDRAWHW MAKE_DDHRESULT( 563 )
-#define DDERR_PRIMARYSURFACEALREADYEXISTS MAKE_DDHRESULT( 564 )
-#define DDERR_NOEMULATION MAKE_DDHRESULT( 565 )
-#define DDERR_REGIONTOOSMALL MAKE_DDHRESULT( 566 )
-#define DDERR_CLIPPERISUSINGHWND MAKE_DDHRESULT( 567 )
-#define DDERR_NOCLIPPERATTACHED MAKE_DDHRESULT( 568 )
-#define DDERR_NOHWND MAKE_DDHRESULT( 569 )
-#define DDERR_HWNDSUBCLASSED MAKE_DDHRESULT( 570 )
-#define DDERR_HWNDALREADYSET MAKE_DDHRESULT( 571 )
-#define DDERR_NOPALETTEATTACHED MAKE_DDHRESULT( 572 )
-#define DDERR_NOPALETTEHW MAKE_DDHRESULT( 573 )
-#define DDERR_BLTFASTCANTCLIP MAKE_DDHRESULT( 574 )
-#define DDERR_NOBLTHW MAKE_DDHRESULT( 575 )
-#define DDERR_NODDROPSHW MAKE_DDHRESULT( 576 )
-#define DDERR_OVERLAYNOTVISIBLE MAKE_DDHRESULT( 577 )
-#define DDERR_NOOVERLAYDEST MAKE_DDHRESULT( 578 )
-#define DDERR_INVALIDPOSITION MAKE_DDHRESULT( 579 )
-#define DDERR_NOTAOVERLAYSURFACE MAKE_DDHRESULT( 580 )
-#define DDERR_EXCLUSIVEMODEALREADYSET MAKE_DDHRESULT( 581 )
-#define DDERR_NOTFLIPPABLE MAKE_DDHRESULT( 582 )
-#define DDERR_CANTDUPLICATE MAKE_DDHRESULT( 583 )
-#define DDERR_NOTLOCKED MAKE_DDHRESULT( 584 )
-#define DDERR_CANTCREATEDC MAKE_DDHRESULT( 585 )
-#define DDERR_NODC MAKE_DDHRESULT( 586 )
-#define DDERR_WRONGMODE MAKE_DDHRESULT( 587 )
-#define DDERR_IMPLICITLYCREATED MAKE_DDHRESULT( 588 )
-#define DDERR_NOTPALETTIZED MAKE_DDHRESULT( 589 )
-#define DDERR_UNSUPPORTEDMODE MAKE_DDHRESULT( 590 )
-#define DDERR_NOMIPMAPHW MAKE_DDHRESULT( 591 )
-#define DDERR_INVALIDSURFACETYPE MAKE_DDHRESULT( 592 )
-#define DDERR_NOOPTIMIZEHW MAKE_DDHRESULT( 600 )
-#define DDERR_NOTLOADED MAKE_DDHRESULT( 601 )
-#define DDERR_NOFOCUSWINDOW MAKE_DDHRESULT( 602 )
-#define DDERR_NOTONMIPMAPSUBLEVEL MAKE_DDHRESULT( 603 )
-#define DDERR_DCALREADYCREATED MAKE_DDHRESULT( 620 )
-#define DDERR_NONONLOCALVIDMEM MAKE_DDHRESULT( 630 )
-#define DDERR_CANTPAGELOCK MAKE_DDHRESULT( 640 )
-#define DDERR_CANTPAGEUNLOCK MAKE_DDHRESULT( 660 )
-#define DDERR_NOTPAGELOCKED MAKE_DDHRESULT( 680 )
-#define DDERR_MOREDATA MAKE_DDHRESULT( 690 )
-#define DDERR_EXPIRED MAKE_DDHRESULT( 691 )
-#define DDERR_TESTFINISHED MAKE_DDHRESULT( 692 )
-#define DDERR_NEWMODE MAKE_DDHRESULT( 693 )
-#define DDERR_D3DNOTINITIALIZED MAKE_DDHRESULT( 694 )
-#define DDERR_VIDEONOTACTIVE MAKE_DDHRESULT( 695 )
-#define DDERR_NOMONITORINFORMATION MAKE_DDHRESULT( 696 )
-#define DDERR_NODRIVERSUPPORT MAKE_DDHRESULT( 697 )
-#define DDERR_DEVICEDOESNTOWNSURFACE MAKE_DDHRESULT( 699 )
-#define DDERR_NOTINITIALIZED CO_E_NOTINITIALIZED
-
-/* dwFlags for Blt* */
-#define DDBLT_ALPHADEST 0x00000001
-#define DDBLT_ALPHADESTCONSTOVERRIDE 0x00000002
-#define DDBLT_ALPHADESTNEG 0x00000004
-#define DDBLT_ALPHADESTSURFACEOVERRIDE 0x00000008
-#define DDBLT_ALPHAEDGEBLEND 0x00000010
-#define DDBLT_ALPHASRC 0x00000020
-#define DDBLT_ALPHASRCCONSTOVERRIDE 0x00000040
-#define DDBLT_ALPHASRCNEG 0x00000080
-#define DDBLT_ALPHASRCSURFACEOVERRIDE 0x00000100
-#define DDBLT_ASYNC 0x00000200
-#define DDBLT_COLORFILL 0x00000400
-#define DDBLT_DDFX 0x00000800
-#define DDBLT_DDROPS 0x00001000
-#define DDBLT_KEYDEST 0x00002000
-#define DDBLT_KEYDESTOVERRIDE 0x00004000
-#define DDBLT_KEYSRC 0x00008000
-#define DDBLT_KEYSRCOVERRIDE 0x00010000
-#define DDBLT_ROP 0x00020000
-#define DDBLT_ROTATIONANGLE 0x00040000
-#define DDBLT_ZBUFFER 0x00080000
-#define DDBLT_ZBUFFERDESTCONSTOVERRIDE 0x00100000
-#define DDBLT_ZBUFFERDESTOVERRIDE 0x00200000
-#define DDBLT_ZBUFFERSRCCONSTOVERRIDE 0x00400000
-#define DDBLT_ZBUFFERSRCOVERRIDE 0x00800000
-#define DDBLT_WAIT 0x01000000
-#define DDBLT_DEPTHFILL 0x02000000
-#define DDBLT_DONOTWAIT 0x08000000
-
-/* dwTrans for BltFast */
-#define DDBLTFAST_NOCOLORKEY 0x00000000
-#define DDBLTFAST_SRCCOLORKEY 0x00000001
-#define DDBLTFAST_DESTCOLORKEY 0x00000002
-#define DDBLTFAST_WAIT 0x00000010
-#define DDBLTFAST_DONOTWAIT 0x00000020
-
-/* dwFlags for Flip */
-#define DDFLIP_WAIT 0x00000001
-#define DDFLIP_EVEN 0x00000002 /* only valid for overlay */
-#define DDFLIP_ODD 0x00000004 /* only valid for overlay */
-#define DDFLIP_NOVSYNC 0x00000008
-#define DDFLIP_STEREO 0x00000010
-#define DDFLIP_DONOTWAIT 0x00000020
-
-/* dwFlags for GetBltStatus */
-#define DDGBS_CANBLT 0x00000001
-#define DDGBS_ISBLTDONE 0x00000002
-
-/* dwFlags for IDirectDrawSurface7::GetFlipStatus */
-#define DDGFS_CANFLIP 1L
-#define DDGFS_ISFLIPDONE 2L
-
-/* dwFlags for IDirectDrawSurface7::SetPrivateData */
-#define DDSPD_IUNKNOWNPTR 1L
-#define DDSPD_VOLATILE 2L
-
-/* DDSCAPS.dwCaps */
-/* reserved1, was 3d capable */
-#define DDSCAPS_RESERVED1 0x00000001
-/* surface contains alpha information */
-#define DDSCAPS_ALPHA 0x00000002
-/* this surface is a backbuffer */
-#define DDSCAPS_BACKBUFFER 0x00000004
-/* complex surface structure */
-#define DDSCAPS_COMPLEX 0x00000008
-/* part of surface flipping structure */
-#define DDSCAPS_FLIP 0x00000010
-/* this surface is the frontbuffer surface */
-#define DDSCAPS_FRONTBUFFER 0x00000020
-/* this is a plain offscreen surface */
-#define DDSCAPS_OFFSCREENPLAIN 0x00000040
-/* overlay */
-#define DDSCAPS_OVERLAY 0x00000080
-/* palette objects can be created and attached to us */
-#define DDSCAPS_PALETTE 0x00000100
-/* primary surface (the one the user looks at currently)(right eye)*/
-#define DDSCAPS_PRIMARYSURFACE 0x00000200
-/* primary surface for left eye */
-#define DDSCAPS_PRIMARYSURFACELEFT 0x00000400
-/* surface exists in systemmemory */
-#define DDSCAPS_SYSTEMMEMORY 0x00000800
-/* surface can be used as a texture */
-#define DDSCAPS_TEXTURE 0x00001000
-/* surface may be destination for 3d rendering */
-#define DDSCAPS_3DDEVICE 0x00002000
-/* surface exists in videomemory */
-#define DDSCAPS_VIDEOMEMORY 0x00004000
-/* surface changes immediately visible */
-#define DDSCAPS_VISIBLE 0x00008000
-/* write only surface */
-#define DDSCAPS_WRITEONLY 0x00010000
-/* zbuffer surface */
-#define DDSCAPS_ZBUFFER 0x00020000
-/* has its own DC */
-#define DDSCAPS_OWNDC 0x00040000
-/* surface should be able to receive live video */
-#define DDSCAPS_LIVEVIDEO 0x00080000
-/* should be able to have a hw codec decompress stuff into it */
-#define DDSCAPS_HWCODEC 0x00100000
-/* mode X (320x200 or 320x240) surface */
-#define DDSCAPS_MODEX 0x00200000
-/* one mipmap surface (1 level) */
-#define DDSCAPS_MIPMAP 0x00400000
-#define DDSCAPS_RESERVED2 0x00800000
-/* memory allocation delayed until Load() */
-#define DDSCAPS_ALLOCONLOAD 0x04000000
-/* Indicates that the surface will receive data from a video port */
-#define DDSCAPS_VIDEOPORT 0x08000000
-/* surface is in local videomemory */
-#define DDSCAPS_LOCALVIDMEM 0x10000000
-/* surface is in nonlocal videomemory */
-#define DDSCAPS_NONLOCALVIDMEM 0x20000000
-/* surface is a standard VGA mode surface (NOT ModeX) */
-#define DDSCAPS_STANDARDVGAMODE 0x40000000
-/* optimized? surface */
-#define DDSCAPS_OPTIMIZED 0x80000000
-
-typedef struct _DDSCAPS {
- DWORD dwCaps; /* capabilities of surface wanted */
-} DDSCAPS,*LPDDSCAPS;
-
-/* DDSCAPS2.dwCaps2 */
-/* indicates the surface will receive data from a video port using
- deinterlacing hardware. */
-#define DDSCAPS2_HARDWAREDEINTERLACE 0x00000002
-/* indicates the surface will be locked very frequently. */
-#define DDSCAPS2_HINTDYNAMIC 0x00000004
-/* indicates surface can be re-ordered or retiled on load() */
-#define DDSCAPS2_HINTSTATIC 0x00000008
-/* indicates surface to be managed by directdraw/direct3D */
-#define DDSCAPS2_TEXTUREMANAGE 0x00000010
-/* reserved bits */
-#define DDSCAPS2_RESERVED1 0x00000020
-#define DDSCAPS2_RESERVED2 0x00000040
-/* indicates surface will never be locked again */
-#define DDSCAPS2_OPAQUE 0x00000080
-/* set at CreateSurface() time to indicate antialising will be used */
-#define DDSCAPS2_HINTANTIALIASING 0x00000100
-/* set at CreateSurface() time to indicate cubic environment map */
-#define DDSCAPS2_CUBEMAP 0x00000200
-/* face flags for cube maps */
-#define DDSCAPS2_CUBEMAP_POSITIVEX 0x00000400
-#define DDSCAPS2_CUBEMAP_NEGATIVEX 0x00000800
-#define DDSCAPS2_CUBEMAP_POSITIVEY 0x00001000
-#define DDSCAPS2_CUBEMAP_NEGATIVEY 0x00002000
-#define DDSCAPS2_CUBEMAP_POSITIVEZ 0x00004000
-#define DDSCAPS2_CUBEMAP_NEGATIVEZ 0x00008000
-/* specifies all faces of a cube for CreateSurface() */
-#define DDSCAPS2_CUBEMAP_ALLFACES ( DDSCAPS2_CUBEMAP_POSITIVEX |\
- DDSCAPS2_CUBEMAP_NEGATIVEX |\
- DDSCAPS2_CUBEMAP_POSITIVEY |\
- DDSCAPS2_CUBEMAP_NEGATIVEY |\
- DDSCAPS2_CUBEMAP_POSITIVEZ |\
- DDSCAPS2_CUBEMAP_NEGATIVEZ )
-/* set for mipmap sublevels on DirectX7 and later. ignored by CreateSurface() */
-#define DDSCAPS2_MIPMAPSUBLEVEL 0x00010000
-/* indicates texture surface to be managed by Direct3D *only* */
-#define DDSCAPS2_D3DTEXTUREMANAGE 0x00020000
-/* indicates managed surface that can safely be lost */
-#define DDSCAPS2_DONOTPERSIST 0x00040000
-/* indicates surface is part of a stereo flipping chain */
-#define DDSCAPS2_STEREOSURFACELEFT 0x00080000
-
-typedef struct _DDSCAPS2 {
- DWORD dwCaps; /* capabilities of surface wanted */
- DWORD dwCaps2; /* additional capabilities */
- DWORD dwCaps3; /* reserved capabilities */
- DWORD dwCaps4; /* more reserved capabilities */
-} DDSCAPS2,*LPDDSCAPS2;
-
-#define DD_ROP_SPACE (256/32) /* space required to store ROP array */
-
-typedef struct _DDCAPS_DX7 /* DirectX 7 version of caps struct */
-{
- DWORD dwSize; /* size of the DDDRIVERCAPS structure */
- DWORD dwCaps; /* driver specific capabilities */
- DWORD dwCaps2; /* more driver specific capabilites */
- DWORD dwCKeyCaps; /* color key capabilities of the surface */
- DWORD dwFXCaps; /* driver specific stretching and effects capabilites */
- DWORD dwFXAlphaCaps; /* alpha driver specific capabilities */
- DWORD dwPalCaps; /* palette capabilities */
- DWORD dwSVCaps; /* stereo vision capabilities */
- DWORD dwAlphaBltConstBitDepths; /* DDBD_2,4,8 */
- DWORD dwAlphaBltPixelBitDepths; /* DDBD_1,2,4,8 */
- DWORD dwAlphaBltSurfaceBitDepths; /* DDBD_1,2,4,8 */
- DWORD dwAlphaOverlayConstBitDepths; /* DDBD_2,4,8 */
- DWORD dwAlphaOverlayPixelBitDepths; /* DDBD_1,2,4,8 */
- DWORD dwAlphaOverlaySurfaceBitDepths; /* DDBD_1,2,4,8 */
- DWORD dwZBufferBitDepths; /* DDBD_8,16,24,32 */
- DWORD dwVidMemTotal; /* total amount of video memory */
- DWORD dwVidMemFree; /* amount of free video memory */
- DWORD dwMaxVisibleOverlays; /* maximum number of visible overlays */
- DWORD dwCurrVisibleOverlays; /* current number of visible overlays */
- DWORD dwNumFourCCCodes; /* number of four cc codes */
- DWORD dwAlignBoundarySrc; /* source rectangle alignment */
- DWORD dwAlignSizeSrc; /* source rectangle byte size */
- DWORD dwAlignBoundaryDest; /* dest rectangle alignment */
- DWORD dwAlignSizeDest; /* dest rectangle byte size */
- DWORD dwAlignStrideAlign; /* stride alignment */
- DWORD dwRops[DD_ROP_SPACE]; /* ROPS supported */
- DDSCAPS ddsOldCaps; /* old DDSCAPS - superceded for DirectX6+ */
- DWORD dwMinOverlayStretch; /* minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwMaxOverlayStretch; /* maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwMinLiveVideoStretch; /* minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwMaxLiveVideoStretch; /* maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwMinHwCodecStretch; /* minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwMaxHwCodecStretch; /* maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwReserved1;
- DWORD dwReserved2;
- DWORD dwReserved3;
- DWORD dwSVBCaps; /* driver specific capabilities for System->Vmem blts */
- DWORD dwSVBCKeyCaps; /* driver color key capabilities for System->Vmem blts */
- DWORD dwSVBFXCaps; /* driver FX capabilities for System->Vmem blts */
- DWORD dwSVBRops[DD_ROP_SPACE];/* ROPS supported for System->Vmem blts */
- DWORD dwVSBCaps; /* driver specific capabilities for Vmem->System blts */
- DWORD dwVSBCKeyCaps; /* driver color key capabilities for Vmem->System blts */
- DWORD dwVSBFXCaps; /* driver FX capabilities for Vmem->System blts */
- DWORD dwVSBRops[DD_ROP_SPACE];/* ROPS supported for Vmem->System blts */
- DWORD dwSSBCaps; /* driver specific capabilities for System->System blts */
- DWORD dwSSBCKeyCaps; /* driver color key capabilities for System->System blts */
- DWORD dwSSBFXCaps; /* driver FX capabilities for System->System blts */
- DWORD dwSSBRops[DD_ROP_SPACE];/* ROPS supported for System->System blts */
- DWORD dwMaxVideoPorts; /* maximum number of usable video ports */
- DWORD dwCurrVideoPorts; /* current number of video ports used */
- DWORD dwSVBCaps2; /* more driver specific capabilities for System->Vmem blts */
- DWORD dwNLVBCaps; /* driver specific capabilities for non-local->local vidmem blts */
- DWORD dwNLVBCaps2; /* more driver specific capabilities non-local->local vidmem blts */
- DWORD dwNLVBCKeyCaps; /* driver color key capabilities for non-local->local vidmem blts */
- DWORD dwNLVBFXCaps; /* driver FX capabilities for non-local->local blts */
- DWORD dwNLVBRops[DD_ROP_SPACE]; /* ROPS supported for non-local->local blts */
- DDSCAPS2 ddsCaps; /* surface capabilities */
-} DDCAPS_DX7,*LPDDCAPS_DX7;
-
-typedef struct _DDCAPS_DX6 /* DirectX 6 version of caps struct */
-{
- DWORD dwSize; /* size of the DDDRIVERCAPS structure */
- DWORD dwCaps; /* driver specific capabilities */
- DWORD dwCaps2; /* more driver specific capabilites */
- DWORD dwCKeyCaps; /* color key capabilities of the surface */
- DWORD dwFXCaps; /* driver specific stretching and effects capabilites */
- DWORD dwFXAlphaCaps; /* alpha driver specific capabilities */
- DWORD dwPalCaps; /* palette capabilities */
- DWORD dwSVCaps; /* stereo vision capabilities */
- DWORD dwAlphaBltConstBitDepths; /* DDBD_2,4,8 */
- DWORD dwAlphaBltPixelBitDepths; /* DDBD_1,2,4,8 */
- DWORD dwAlphaBltSurfaceBitDepths; /* DDBD_1,2,4,8 */
- DWORD dwAlphaOverlayConstBitDepths; /* DDBD_2,4,8 */
- DWORD dwAlphaOverlayPixelBitDepths; /* DDBD_1,2,4,8 */
- DWORD dwAlphaOverlaySurfaceBitDepths; /* DDBD_1,2,4,8 */
- DWORD dwZBufferBitDepths; /* DDBD_8,16,24,32 */
- DWORD dwVidMemTotal; /* total amount of video memory */
- DWORD dwVidMemFree; /* amount of free video memory */
- DWORD dwMaxVisibleOverlays; /* maximum number of visible overlays */
- DWORD dwCurrVisibleOverlays; /* current number of visible overlays */
- DWORD dwNumFourCCCodes; /* number of four cc codes */
- DWORD dwAlignBoundarySrc; /* source rectangle alignment */
- DWORD dwAlignSizeSrc; /* source rectangle byte size */
- DWORD dwAlignBoundaryDest; /* dest rectangle alignment */
- DWORD dwAlignSizeDest; /* dest rectangle byte size */
- DWORD dwAlignStrideAlign; /* stride alignment */
- DWORD dwRops[DD_ROP_SPACE]; /* ROPS supported */
- DDSCAPS ddsOldCaps; /* old DDSCAPS - superceded for DirectX6+ */
- DWORD dwMinOverlayStretch; /* minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwMaxOverlayStretch; /* maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwMinLiveVideoStretch; /* minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwMaxLiveVideoStretch; /* maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwMinHwCodecStretch; /* minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwMaxHwCodecStretch; /* maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwReserved1;
- DWORD dwReserved2;
- DWORD dwReserved3;
- DWORD dwSVBCaps; /* driver specific capabilities for System->Vmem blts */
- DWORD dwSVBCKeyCaps; /* driver color key capabilities for System->Vmem blts */
- DWORD dwSVBFXCaps; /* driver FX capabilities for System->Vmem blts */
- DWORD dwSVBRops[DD_ROP_SPACE];/* ROPS supported for System->Vmem blts */
- DWORD dwVSBCaps; /* driver specific capabilities for Vmem->System blts */
- DWORD dwVSBCKeyCaps; /* driver color key capabilities for Vmem->System blts */
- DWORD dwVSBFXCaps; /* driver FX capabilities for Vmem->System blts */
- DWORD dwVSBRops[DD_ROP_SPACE];/* ROPS supported for Vmem->System blts */
- DWORD dwSSBCaps; /* driver specific capabilities for System->System blts */
- DWORD dwSSBCKeyCaps; /* driver color key capabilities for System->System blts */
- DWORD dwSSBFXCaps; /* driver FX capabilities for System->System blts */
- DWORD dwSSBRops[DD_ROP_SPACE];/* ROPS supported for System->System blts */
- DWORD dwMaxVideoPorts; /* maximum number of usable video ports */
- DWORD dwCurrVideoPorts; /* current number of video ports used */
- DWORD dwSVBCaps2; /* more driver specific capabilities for System->Vmem blts */
- DWORD dwNLVBCaps; /* driver specific capabilities for non-local->local vidmem blts */
- DWORD dwNLVBCaps2; /* more driver specific capabilities non-local->local vidmem blts */
- DWORD dwNLVBCKeyCaps; /* driver color key capabilities for non-local->local vidmem blts */
- DWORD dwNLVBFXCaps; /* driver FX capabilities for non-local->local blts */
- DWORD dwNLVBRops[DD_ROP_SPACE]; /* ROPS supported for non-local->local blts */
- /* and one new member for DirectX 6 */
- DDSCAPS2 ddsCaps; /* surface capabilities */
-} DDCAPS_DX6,*LPDDCAPS_DX6;
-
-typedef struct _DDCAPS_DX5 /* DirectX5 version of caps struct */
-{
- DWORD dwSize; /* size of the DDDRIVERCAPS structure */
- DWORD dwCaps; /* driver specific capabilities */
- DWORD dwCaps2; /* more driver specific capabilites */
- DWORD dwCKeyCaps; /* color key capabilities of the surface */
- DWORD dwFXCaps; /* driver specific stretching and effects capabilites */
- DWORD dwFXAlphaCaps; /* alpha driver specific capabilities */
- DWORD dwPalCaps; /* palette capabilities */
- DWORD dwSVCaps; /* stereo vision capabilities */
- DWORD dwAlphaBltConstBitDepths; /* DDBD_2,4,8 */
- DWORD dwAlphaBltPixelBitDepths; /* DDBD_1,2,4,8 */
- DWORD dwAlphaBltSurfaceBitDepths; /* DDBD_1,2,4,8 */
- DWORD dwAlphaOverlayConstBitDepths; /* DDBD_2,4,8 */
- DWORD dwAlphaOverlayPixelBitDepths; /* DDBD_1,2,4,8 */
- DWORD dwAlphaOverlaySurfaceBitDepths; /* DDBD_1,2,4,8 */
- DWORD dwZBufferBitDepths; /* DDBD_8,16,24,32 */
- DWORD dwVidMemTotal; /* total amount of video memory */
- DWORD dwVidMemFree; /* amount of free video memory */
- DWORD dwMaxVisibleOverlays; /* maximum number of visible overlays */
- DWORD dwCurrVisibleOverlays; /* current number of visible overlays */
- DWORD dwNumFourCCCodes; /* number of four cc codes */
- DWORD dwAlignBoundarySrc; /* source rectangle alignment */
- DWORD dwAlignSizeSrc; /* source rectangle byte size */
- DWORD dwAlignBoundaryDest; /* dest rectangle alignment */
- DWORD dwAlignSizeDest; /* dest rectangle byte size */
- DWORD dwAlignStrideAlign; /* stride alignment */
- DWORD dwRops[DD_ROP_SPACE]; /* ROPS supported */
- DDSCAPS ddsCaps; /* DDSCAPS structure has all the general capabilities */
- DWORD dwMinOverlayStretch; /* minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwMaxOverlayStretch; /* maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwMinLiveVideoStretch; /* minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwMaxLiveVideoStretch; /* maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwMinHwCodecStretch; /* minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwMaxHwCodecStretch; /* maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwReserved1;
- DWORD dwReserved2;
- DWORD dwReserved3;
- DWORD dwSVBCaps; /* driver specific capabilities for System->Vmem blts */
- DWORD dwSVBCKeyCaps; /* driver color key capabilities for System->Vmem blts */
- DWORD dwSVBFXCaps; /* driver FX capabilities for System->Vmem blts */
- DWORD dwSVBRops[DD_ROP_SPACE];/* ROPS supported for System->Vmem blts */
- DWORD dwVSBCaps; /* driver specific capabilities for Vmem->System blts */
- DWORD dwVSBCKeyCaps; /* driver color key capabilities for Vmem->System blts */
- DWORD dwVSBFXCaps; /* driver FX capabilities for Vmem->System blts */
- DWORD dwVSBRops[DD_ROP_SPACE];/* ROPS supported for Vmem->System blts */
- DWORD dwSSBCaps; /* driver specific capabilities for System->System blts */
- DWORD dwSSBCKeyCaps; /* driver color key capabilities for System->System blts */
- DWORD dwSSBFXCaps; /* driver FX capabilities for System->System blts */
- DWORD dwSSBRops[DD_ROP_SPACE];/* ROPS supported for System->System blts */
- /* the following are the new DirectX 5 members */
- DWORD dwMaxVideoPorts; /* maximum number of usable video ports */
- DWORD dwCurrVideoPorts; /* current number of video ports used */
- DWORD dwSVBCaps2; /* more driver specific capabilities for System->Vmem blts */
- DWORD dwNLVBCaps; /* driver specific capabilities for non-local->local vidmem blts */
- DWORD dwNLVBCaps2; /* more driver specific capabilities non-local->local vidmem blts */
- DWORD dwNLVBCKeyCaps; /* driver color key capabilities for non-local->local vidmem blts */
- DWORD dwNLVBFXCaps; /* driver FX capabilities for non-local->local blts */
- DWORD dwNLVBRops[DD_ROP_SPACE]; /* ROPS supported for non-local->local blts */
-} DDCAPS_DX5,*LPDDCAPS_DX5;
-
-typedef struct _DDCAPS_DX3 /* DirectX3 version of caps struct */
-{
- DWORD dwSize; /* size of the DDDRIVERCAPS structure */
- DWORD dwCaps; /* driver specific capabilities */
- DWORD dwCaps2; /* more driver specific capabilites */
- DWORD dwCKeyCaps; /* color key capabilities of the surface */
- DWORD dwFXCaps; /* driver specific stretching and effects capabilites */
- DWORD dwFXAlphaCaps; /* alpha driver specific capabilities */
- DWORD dwPalCaps; /* palette capabilities */
- DWORD dwSVCaps; /* stereo vision capabilities */
- DWORD dwAlphaBltConstBitDepths; /* DDBD_2,4,8 */
- DWORD dwAlphaBltPixelBitDepths; /* DDBD_1,2,4,8 */
- DWORD dwAlphaBltSurfaceBitDepths; /* DDBD_1,2,4,8 */
- DWORD dwAlphaOverlayConstBitDepths; /* DDBD_2,4,8 */
- DWORD dwAlphaOverlayPixelBitDepths; /* DDBD_1,2,4,8 */
- DWORD dwAlphaOverlaySurfaceBitDepths; /* DDBD_1,2,4,8 */
- DWORD dwZBufferBitDepths; /* DDBD_8,16,24,32 */
- DWORD dwVidMemTotal; /* total amount of video memory */
- DWORD dwVidMemFree; /* amount of free video memory */
- DWORD dwMaxVisibleOverlays; /* maximum number of visible overlays */
- DWORD dwCurrVisibleOverlays; /* current number of visible overlays */
- DWORD dwNumFourCCCodes; /* number of four cc codes */
- DWORD dwAlignBoundarySrc; /* source rectangle alignment */
- DWORD dwAlignSizeSrc; /* source rectangle byte size */
- DWORD dwAlignBoundaryDest; /* dest rectangle alignment */
- DWORD dwAlignSizeDest; /* dest rectangle byte size */
- DWORD dwAlignStrideAlign; /* stride alignment */
- DWORD dwRops[DD_ROP_SPACE]; /* ROPS supported */
- DDSCAPS ddsCaps; /* DDSCAPS structure has all the general capabilities */
- DWORD dwMinOverlayStretch; /* minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwMaxOverlayStretch; /* maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwMinLiveVideoStretch; /* minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwMaxLiveVideoStretch; /* maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwMinHwCodecStretch; /* minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwMaxHwCodecStretch; /* maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
- DWORD dwReserved1;
- DWORD dwReserved2;
- DWORD dwReserved3;
- DWORD dwSVBCaps; /* driver specific capabilities for System->Vmem blts */
- DWORD dwSVBCKeyCaps; /* driver color key capabilities for System->Vmem blts */
- DWORD dwSVBFXCaps; /* driver FX capabilities for System->Vmem blts */
- DWORD dwSVBRops[DD_ROP_SPACE];/* ROPS supported for System->Vmem blts */
- DWORD dwVSBCaps; /* driver specific capabilities for Vmem->System blts */
- DWORD dwVSBCKeyCaps; /* driver color key capabilities for Vmem->System blts */
- DWORD dwVSBFXCaps; /* driver FX capabilities for Vmem->System blts */
- DWORD dwVSBRops[DD_ROP_SPACE];/* ROPS supported for Vmem->System blts */
- DWORD dwSSBCaps; /* driver specific capabilities for System->System blts */
- DWORD dwSSBCKeyCaps; /* driver color key capabilities for System->System blts */
- DWORD dwSSBFXCaps; /* driver FX capabilities for System->System blts */
- DWORD dwSSBRops[DD_ROP_SPACE];/* ROPS supported for System->System blts */
- DWORD dwReserved4;
- DWORD dwReserved5;
- DWORD dwReserved6;
-} DDCAPS_DX3,*LPDDCAPS_DX3;
-
-/* set caps struct according to DIRECTDRAW_VERSION */
-
-#if DIRECTDRAW_VERSION <= 0x300
-typedef DDCAPS_DX3 DDCAPS;
-#elif DIRECTDRAW_VERSION <= 0x500
-typedef DDCAPS_DX5 DDCAPS;
-#elif DIRECTDRAW_VERSION <= 0x600
-typedef DDCAPS_DX6 DDCAPS;
-#else
-typedef DDCAPS_DX7 DDCAPS;
-#endif
-
-typedef DDCAPS *LPDDCAPS;
-
-/* DDCAPS.dwCaps */
-#define DDCAPS_3D 0x00000001
-#define DDCAPS_ALIGNBOUNDARYDEST 0x00000002
-#define DDCAPS_ALIGNSIZEDEST 0x00000004
-#define DDCAPS_ALIGNBOUNDARYSRC 0x00000008
-#define DDCAPS_ALIGNSIZESRC 0x00000010
-#define DDCAPS_ALIGNSTRIDE 0x00000020
-#define DDCAPS_BLT 0x00000040
-#define DDCAPS_BLTQUEUE 0x00000080
-#define DDCAPS_BLTFOURCC 0x00000100
-#define DDCAPS_BLTSTRETCH 0x00000200
-#define DDCAPS_GDI 0x00000400
-#define DDCAPS_OVERLAY 0x00000800
-#define DDCAPS_OVERLAYCANTCLIP 0x00001000
-#define DDCAPS_OVERLAYFOURCC 0x00002000
-#define DDCAPS_OVERLAYSTRETCH 0x00004000
-#define DDCAPS_PALETTE 0x00008000
-#define DDCAPS_PALETTEVSYNC 0x00010000
-#define DDCAPS_READSCANLINE 0x00020000
-#define DDCAPS_STEREOVIEW 0x00040000
-#define DDCAPS_VBI 0x00080000
-#define DDCAPS_ZBLTS 0x00100000
-#define DDCAPS_ZOVERLAYS 0x00200000
-#define DDCAPS_COLORKEY 0x00400000
-#define DDCAPS_ALPHA 0x00800000
-#define DDCAPS_COLORKEYHWASSIST 0x01000000
-#define DDCAPS_NOHARDWARE 0x02000000
-#define DDCAPS_BLTCOLORFILL 0x04000000
-#define DDCAPS_BANKSWITCHED 0x08000000
-#define DDCAPS_BLTDEPTHFILL 0x10000000
-#define DDCAPS_CANCLIP 0x20000000
-#define DDCAPS_CANCLIPSTRETCHED 0x40000000
-#define DDCAPS_CANBLTSYSMEM 0x80000000
-
-/* DDCAPS.dwCaps2 */
-#define DDCAPS2_CERTIFIED 0x00000001
-#define DDCAPS2_NO2DDURING3DSCENE 0x00000002
-#define DDCAPS2_VIDEOPORT 0x00000004
-#define DDCAPS2_AUTOFLIPOVERLAY 0x00000008
-#define DDCAPS2_CANBOBINTERLEAVED 0x00000010
-#define DDCAPS2_CANBOBNONINTERLEAVED 0x00000020
-#define DDCAPS2_COLORCONTROLOVERLAY 0x00000040
-#define DDCAPS2_COLORCONTROLPRIMARY 0x00000080
-#define DDCAPS2_CANDROPZ16BIT 0x00000100
-#define DDCAPS2_NONLOCALVIDMEM 0x00000200
-#define DDCAPS2_NONLOCALVIDMEMCAPS 0x00000400
-#define DDCAPS2_NOPAGELOCKREQUIRED 0x00000800
-#define DDCAPS2_WIDESURFACES 0x00001000
-#define DDCAPS2_CANFLIPODDEVEN 0x00002000
-#define DDCAPS2_CANBOBHARDWARE 0x00004000
-#define DDCAPS2_COPYFOURCC 0x00008000
-#define DDCAPS2_PRIMARYGAMMA 0x00020000
-#define DDCAPS2_CANRENDERWINDOWED 0x00080000
-#define DDCAPS2_CANCALIBRATEGAMMA 0x00100000
-#define DDCAPS2_FLIPINTERVAL 0x00200000
-#define DDCAPS2_FLIPNOVSYNC 0x00400000
-#define DDCAPS2_CANMANAGETEXTURE 0x00800000
-#define DDCAPS2_TEXMANINNONLOCALVIDMEM 0x01000000
-#define DDCAPS2_STEREO 0x02000000
-#define DDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL 0x04000000
-
-
-/* Set/Get Colour Key Flags */
-#define DDCKEY_COLORSPACE 0x00000001 /* Struct is single colour space */
-#define DDCKEY_DESTBLT 0x00000002 /* To be used as dest for blt */
-#define DDCKEY_DESTOVERLAY 0x00000004 /* To be used as dest for CK overlays */
-#define DDCKEY_SRCBLT 0x00000008 /* To be used as src for blt */
-#define DDCKEY_SRCOVERLAY 0x00000010 /* To be used as src for CK overlays */
-
-typedef struct _DDCOLORKEY
-{
- DWORD dwColorSpaceLowValue;/* low boundary of color space that is to
- * be treated as Color Key, inclusive
- */
- DWORD dwColorSpaceHighValue;/* high boundary of color space that is
- * to be treated as Color Key, inclusive
- */
-} DDCOLORKEY,*LPDDCOLORKEY;
-
-/* ddCKEYCAPS bits */
-#define DDCKEYCAPS_DESTBLT 0x00000001
-#define DDCKEYCAPS_DESTBLTCLRSPACE 0x00000002
-#define DDCKEYCAPS_DESTBLTCLRSPACEYUV 0x00000004
-#define DDCKEYCAPS_DESTBLTYUV 0x00000008
-#define DDCKEYCAPS_DESTOVERLAY 0x00000010
-#define DDCKEYCAPS_DESTOVERLAYCLRSPACE 0x00000020
-#define DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV 0x00000040
-#define DDCKEYCAPS_DESTOVERLAYONEACTIVE 0x00000080
-#define DDCKEYCAPS_DESTOVERLAYYUV 0x00000100
-#define DDCKEYCAPS_SRCBLT 0x00000200
-#define DDCKEYCAPS_SRCBLTCLRSPACE 0x00000400
-#define DDCKEYCAPS_SRCBLTCLRSPACEYUV 0x00000800
-#define DDCKEYCAPS_SRCBLTYUV 0x00001000
-#define DDCKEYCAPS_SRCOVERLAY 0x00002000
-#define DDCKEYCAPS_SRCOVERLAYCLRSPACE 0x00004000
-#define DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV 0x00008000
-#define DDCKEYCAPS_SRCOVERLAYONEACTIVE 0x00010000
-#define DDCKEYCAPS_SRCOVERLAYYUV 0x00020000
-#define DDCKEYCAPS_NOCOSTOVERLAY 0x00040000
-
-typedef struct _DDPIXELFORMAT {
- DWORD dwSize; /* 0: size of structure */
- DWORD dwFlags; /* 4: pixel format flags */
- DWORD dwFourCC; /* 8: (FOURCC code) */
- union {
- DWORD dwRGBBitCount; /* C: how many bits per pixel */
- DWORD dwYUVBitCount; /* C: how many bits per pixel */
- DWORD dwZBufferBitDepth; /* C: how many bits for z buffers */
- DWORD dwAlphaBitDepth; /* C: how many bits for alpha channels*/
- DWORD dwLuminanceBitCount;
- DWORD dwBumpBitCount;
- } DUMMYUNIONNAME1;
- union {
- DWORD dwRBitMask; /* 10: mask for red bit*/
- DWORD dwYBitMask; /* 10: mask for Y bits*/
- DWORD dwStencilBitDepth;
- DWORD dwLuminanceBitMask;
- DWORD dwBumpDuBitMask;
- } DUMMYUNIONNAME2;
- union {
- DWORD dwGBitMask; /* 14: mask for green bits*/
- DWORD dwUBitMask; /* 14: mask for U bits*/
- DWORD dwZBitMask;
- DWORD dwBumpDvBitMask;
- } DUMMYUNIONNAME3;
- union {
- DWORD dwBBitMask; /* 18: mask for blue bits*/
- DWORD dwVBitMask; /* 18: mask for V bits*/
- DWORD dwStencilBitMask;
- DWORD dwBumpLuminanceBitMask;
- } DUMMYUNIONNAME4;
- union {
- DWORD dwRGBAlphaBitMask; /* 1C: mask for alpha channel */
- DWORD dwYUVAlphaBitMask; /* 1C: mask for alpha channel */
- DWORD dwLuminanceAlphaBitMask;
- DWORD dwRGBZBitMask; /* 1C: mask for Z channel */
- DWORD dwYUVZBitMask; /* 1C: mask for Z channel */
- } DUMMYUNIONNAME5;
- /* 20: next structure */
-} DDPIXELFORMAT,*LPDDPIXELFORMAT;
-
-/* DDCAPS.dwFXCaps */
-#define DDFXCAPS_BLTALPHA 0x00000001
-#define DDFXCAPS_OVERLAYALPHA 0x00000004
-#define DDFXCAPS_BLTARITHSTRETCHYN 0x00000010
-#define DDFXCAPS_BLTARITHSTRETCHY 0x00000020
-#define DDFXCAPS_BLTMIRRORLEFTRIGHT 0x00000040
-#define DDFXCAPS_BLTMIRRORUPDOWN 0x00000080
-#define DDFXCAPS_BLTROTATION 0x00000100
-#define DDFXCAPS_BLTROTATION90 0x00000200
-#define DDFXCAPS_BLTSHRINKX 0x00000400
-#define DDFXCAPS_BLTSHRINKXN 0x00000800
-#define DDFXCAPS_BLTSHRINKY 0x00001000
-#define DDFXCAPS_BLTSHRINKYN 0x00002000
-#define DDFXCAPS_BLTSTRETCHX 0x00004000
-#define DDFXCAPS_BLTSTRETCHXN 0x00008000
-#define DDFXCAPS_BLTSTRETCHY 0x00010000
-#define DDFXCAPS_BLTSTRETCHYN 0x00020000
-#define DDFXCAPS_OVERLAYARITHSTRETCHY 0x00040000
-#define DDFXCAPS_OVERLAYARITHSTRETCHYN 0x00000008
-#define DDFXCAPS_OVERLAYSHRINKX 0x00080000
-#define DDFXCAPS_OVERLAYSHRINKXN 0x00100000
-#define DDFXCAPS_OVERLAYSHRINKY 0x00200000
-#define DDFXCAPS_OVERLAYSHRINKYN 0x00400000
-#define DDFXCAPS_OVERLAYSTRETCHX 0x00800000
-#define DDFXCAPS_OVERLAYSTRETCHXN 0x01000000
-#define DDFXCAPS_OVERLAYSTRETCHY 0x02000000
-#define DDFXCAPS_OVERLAYSTRETCHYN 0x04000000
-#define DDFXCAPS_OVERLAYMIRRORLEFTRIGHT 0x08000000
-#define DDFXCAPS_OVERLAYMIRRORUPDOWN 0x10000000
-
-#define DDFXCAPS_OVERLAYFILTER DDFXCAPS_OVERLAYARITHSTRETCHY
-
-/* DDCAPS.dwFXAlphaCaps */
-#define DDFXALPHACAPS_BLTALPHAEDGEBLEND 0x00000001
-#define DDFXALPHACAPS_BLTALPHAPIXELS 0x00000002
-#define DDFXALPHACAPS_BLTALPHAPIXELSNEG 0x00000004
-#define DDFXALPHACAPS_BLTALPHASURFACES 0x00000008
-#define DDFXALPHACAPS_BLTALPHASURFACESNEG 0x00000010
-#define DDFXALPHACAPS_OVERLAYALPHAEDGEBLEND 0x00000020
-#define DDFXALPHACAPS_OVERLAYALPHAPIXELS 0x00000040
-#define DDFXALPHACAPS_OVERLAYALPHAPIXELSNEG 0x00000080
-#define DDFXALPHACAPS_OVERLAYALPHASURFACES 0x00000100
-#define DDFXALPHACAPS_OVERLAYALPHASURFACESNEG 0x00000200
-
-/* DDCAPS.dwPalCaps */
-#define DDPCAPS_4BIT 0x00000001
-#define DDPCAPS_8BITENTRIES 0x00000002
-#define DDPCAPS_8BIT 0x00000004
-#define DDPCAPS_INITIALIZE 0x00000008
-#define DDPCAPS_PRIMARYSURFACE 0x00000010
-#define DDPCAPS_PRIMARYSURFACELEFT 0x00000020
-#define DDPCAPS_ALLOW256 0x00000040
-#define DDPCAPS_VSYNC 0x00000080
-#define DDPCAPS_1BIT 0x00000100
-#define DDPCAPS_2BIT 0x00000200
-#define DDPCAPS_ALPHA 0x00000400
-
-/* DDCAPS.dwSVCaps */
-/* the first 4 of these are now obsolete */
-#if DIRECTDRAW_VERSION >= 0x700 /* FIXME: I'm not sure when this switch occured */
-#define DDSVCAPS_RESERVED1 0x00000001
-#define DDSVCAPS_RESERVED2 0x00000002
-#define DDSVCAPS_RESERVED3 0x00000004
-#define DDSVCAPS_RESERVED4 0x00000008
-#else
-#define DDSVCAPS_ENIGMA 0x00000001
-#define DDSVCAPS_FLICKER 0x00000002
-#define DDSVCAPS_REDBLUE 0x00000004
-#define DDSVCAPS_SPLIT 0x00000008
-#endif
-#define DDSVCAPS_STEREOSEQUENTIAL 0x00000010
-
-/* BitDepths */
-#define DDBD_1 0x00004000
-#define DDBD_2 0x00002000
-#define DDBD_4 0x00001000
-#define DDBD_8 0x00000800
-#define DDBD_16 0x00000400
-#define DDBD_24 0x00000200
-#define DDBD_32 0x00000100
-
-/* DDOVERLAYFX.dwDDFX */
-#define DDOVERFX_ARITHSTRETCHY 0x00000001
-#define DDOVERFX_MIRRORLEFTRIGHT 0x00000002
-#define DDOVERFX_MIRRORUPDOWN 0x00000004
-
-/* UpdateOverlay flags */
-#define DDOVER_ALPHADEST 0x00000001
-#define DDOVER_ALPHADESTCONSTOVERRIDE 0x00000002
-#define DDOVER_ALPHADESTNEG 0x00000004
-#define DDOVER_ALPHADESTSURFACEOVERRIDE 0x00000008
-#define DDOVER_ALPHAEDGEBLEND 0x00000010
-#define DDOVER_ALPHASRC 0x00000020
-#define DDOVER_ALPHASRCCONSTOVERRIDE 0x00000040
-#define DDOVER_ALPHASRCNEG 0x00000080
-#define DDOVER_ALPHASRCSURFACEOVERRIDE 0x00000100
-#define DDOVER_HIDE 0x00000200
-#define DDOVER_KEYDEST 0x00000400
-#define DDOVER_KEYDESTOVERRIDE 0x00000800
-#define DDOVER_KEYSRC 0x00001000
-#define DDOVER_KEYSRCOVERRIDE 0x00002000
-#define DDOVER_SHOW 0x00004000
-#define DDOVER_ADDDIRTYRECT 0x00008000
-#define DDOVER_REFRESHDIRTYRECTS 0x00010000
-#define DDOVER_REFRESHALL 0x00020000
-#define DDOVER_DDFX 0x00080000
-#define DDOVER_AUTOFLIP 0x00100000
-#define DDOVER_BOB 0x00200000
-#define DDOVER_OVERRIDEBOBWEAVE 0x00400000
-#define DDOVER_INTERLEAVED 0x00800000
-
-/* DDCOLORKEY.dwFlags */
-#define DDPF_ALPHAPIXELS 0x00000001
-#define DDPF_ALPHA 0x00000002
-#define DDPF_FOURCC 0x00000004
-#define DDPF_PALETTEINDEXED4 0x00000008
-#define DDPF_PALETTEINDEXEDTO8 0x00000010
-#define DDPF_PALETTEINDEXED8 0x00000020
-#define DDPF_RGB 0x00000040
-#define DDPF_COMPRESSED 0x00000080
-#define DDPF_RGBTOYUV 0x00000100
-#define DDPF_YUV 0x00000200
-#define DDPF_ZBUFFER 0x00000400
-#define DDPF_PALETTEINDEXED1 0x00000800
-#define DDPF_PALETTEINDEXED2 0x00001000
-#define DDPF_ZPIXELS 0x00002000
-#define DDPF_STENCILBUFFER 0x00004000
-#define DDPF_ALPHAPREMULT 0x00008000
-#define DDPF_LUMINANCE 0x00020000
-#define DDPF_BUMPLUMINANCE 0x00040000
-#define DDPF_BUMPDUDV 0x00080000
-
-/* SetCooperativeLevel dwFlags */
-#define DDSCL_FULLSCREEN 0x00000001
-#define DDSCL_ALLOWREBOOT 0x00000002
-#define DDSCL_NOWINDOWCHANGES 0x00000004
-#define DDSCL_NORMAL 0x00000008
-#define DDSCL_EXCLUSIVE 0x00000010
-#define DDSCL_ALLOWMODEX 0x00000040
-#define DDSCL_SETFOCUSWINDOW 0x00000080
-#define DDSCL_SETDEVICEWINDOW 0x00000100
-#define DDSCL_CREATEDEVICEWINDOW 0x00000200
-#define DDSCL_MULTITHREADED 0x00000400
-#define DDSCL_FPUSETUP 0x00000800
-#define DDSCL_FPUPRESERVE 0x00001000
-
-
-/* DDSURFACEDESC.dwFlags */
-#define DDSD_CAPS 0x00000001
-#define DDSD_HEIGHT 0x00000002
-#define DDSD_WIDTH 0x00000004
-#define DDSD_PITCH 0x00000008
-#define DDSD_BACKBUFFERCOUNT 0x00000020
-#define DDSD_ZBUFFERBITDEPTH 0x00000040
-#define DDSD_ALPHABITDEPTH 0x00000080
-#define DDSD_LPSURFACE 0x00000800
-#define DDSD_PIXELFORMAT 0x00001000
-#define DDSD_CKDESTOVERLAY 0x00002000
-#define DDSD_CKDESTBLT 0x00004000
-#define DDSD_CKSRCOVERLAY 0x00008000
-#define DDSD_CKSRCBLT 0x00010000
-#define DDSD_MIPMAPCOUNT 0x00020000
-#define DDSD_REFRESHRATE 0x00040000
-#define DDSD_LINEARSIZE 0x00080000
-#define DDSD_TEXTURESTAGE 0x00100000
-#define DDSD_FVF 0x00200000
-#define DDSD_SRCVBHANDLE 0x00400000
-#define DDSD_ALL 0x007ff9ee
-
-/* EnumSurfaces flags */
-#define DDENUMSURFACES_ALL 0x00000001
-#define DDENUMSURFACES_MATCH 0x00000002
-#define DDENUMSURFACES_NOMATCH 0x00000004
-#define DDENUMSURFACES_CANBECREATED 0x00000008
-#define DDENUMSURFACES_DOESEXIST 0x00000010
-
-/* SetDisplayMode flags */
-#define DDSDM_STANDARDVGAMODE 0x00000001
-
-/* EnumDisplayModes flags */
-#define DDEDM_REFRESHRATES 0x00000001
-#define DDEDM_STANDARDVGAMODES 0x00000002
-
-/* WaitForVerticalDisplay flags */
-
-#define DDWAITVB_BLOCKBEGIN 0x00000001
-#define DDWAITVB_BLOCKBEGINEVENT 0x00000002
-#define DDWAITVB_BLOCKEND 0x00000004
-
-typedef struct _DDSURFACEDESC
-{
- DWORD dwSize; /* 0: size of the DDSURFACEDESC structure*/
- DWORD dwFlags; /* 4: determines what fields are valid*/
- DWORD dwHeight; /* 8: height of surface to be created*/
- DWORD dwWidth; /* C: width of input surface*/
- union {
- LONG lPitch; /* 10: distance to start of next line (return value only)*/
- DWORD dwLinearSize;
- } DUMMYUNIONNAME1;
- DWORD dwBackBufferCount;/* 14: number of back buffers requested*/
- union {
- DWORD dwMipMapCount;/* 18:number of mip-map levels requested*/
- DWORD dwZBufferBitDepth;/*18: depth of Z buffer requested*/
- DWORD dwRefreshRate;/* 18:refresh rate (used when display mode is described)*/
- } DUMMYUNIONNAME2;
- DWORD dwAlphaBitDepth;/* 1C:depth of alpha buffer requested*/
- DWORD dwReserved; /* 20:reserved*/
- LPVOID lpSurface; /* 24:pointer to the associated surface memory*/
- DDCOLORKEY ddckCKDestOverlay;/* 28: CK for dest overlay use*/
- DDCOLORKEY ddckCKDestBlt; /* 30: CK for destination blt use*/
- DDCOLORKEY ddckCKSrcOverlay;/* 38: CK for source overlay use*/
- DDCOLORKEY ddckCKSrcBlt; /* 40: CK for source blt use*/
- DDPIXELFORMAT ddpfPixelFormat;/* 48: pixel format description of the surface*/
- DDSCAPS ddsCaps; /* 68: direct draw surface caps */
-} DDSURFACEDESC,*LPDDSURFACEDESC;
-
-typedef struct _DDSURFACEDESC2
-{
- DWORD dwSize; /* 0: size of the DDSURFACEDESC structure*/
- DWORD dwFlags; /* 4: determines what fields are valid*/
- DWORD dwHeight; /* 8: height of surface to be created*/
- DWORD dwWidth; /* C: width of input surface*/
- union {
- LONG lPitch; /*10: distance to start of next line (return value only)*/
- DWORD dwLinearSize; /*10: formless late-allocated optimized surface size */
- } DUMMYUNIONNAME1;
- DWORD dwBackBufferCount;/* 14: number of back buffers requested*/
- union {
- DWORD dwMipMapCount;/* 18:number of mip-map levels requested*/
- DWORD dwRefreshRate;/* 18:refresh rate (used when display mode is described)*/
- DWORD dwSrcVBHandle;/* 18:source used in VB::Optimize */
- } DUMMYUNIONNAME2;
- DWORD dwAlphaBitDepth;/* 1C:depth of alpha buffer requested*/
- DWORD dwReserved; /* 20:reserved*/
- LPVOID lpSurface; /* 24:pointer to the associated surface memory*/
- union {
- DDCOLORKEY ddckCKDestOverlay; /* 28: CK for dest overlay use*/
- DWORD dwEmptyFaceColor; /* 28: color for empty cubemap faces */
- } DUMMYUNIONNAME3;
- DDCOLORKEY ddckCKDestBlt; /* 30: CK for destination blt use*/
- DDCOLORKEY ddckCKSrcOverlay;/* 38: CK for source overlay use*/
- DDCOLORKEY ddckCKSrcBlt; /* 40: CK for source blt use*/
-
- union {
- DDPIXELFORMAT ddpfPixelFormat;/* 48: pixel format description of the surface*/
- DWORD dwFVF; /* 48: vertex format description of vertex buffers */
- } DUMMYUNIONNAME4;
- DDSCAPS2 ddsCaps; /* 68: DDraw surface caps */
- DWORD dwTextureStage; /* 78: stage in multitexture cascade */
-} DDSURFACEDESC2,*LPDDSURFACEDESC2;
-
-/* DDCOLORCONTROL.dwFlags */
-#define DDCOLOR_BRIGHTNESS 0x00000001
-#define DDCOLOR_CONTRAST 0x00000002
-#define DDCOLOR_HUE 0x00000004
-#define DDCOLOR_SATURATION 0x00000008
-#define DDCOLOR_SHARPNESS 0x00000010
-#define DDCOLOR_GAMMA 0x00000020
-#define DDCOLOR_COLORENABLE 0x00000040
-
-typedef struct {
- DWORD dwSize;
- DWORD dwFlags;
- LONG lBrightness;
- LONG lContrast;
- LONG lHue;
- LONG lSaturation;
- LONG lSharpness;
- LONG lGamma;
- LONG lColorEnable;
- DWORD dwReserved1;
-} DDCOLORCONTROL,*LPDDCOLORCONTROL;
-
-typedef struct {
- WORD red[256];
- WORD green[256];
- WORD blue[256];
-} DDGAMMARAMP,*LPDDGAMMARAMP;
-
-typedef BOOL CALLBACK (*LPDDENUMCALLBACKA)(GUID *, LPSTR, LPSTR, LPVOID);
-typedef BOOL CALLBACK (*LPDDENUMCALLBACKW)(GUID *, LPWSTR, LPWSTR, LPVOID);
-DECL_WINELIB_TYPE_AW(LPDDENUMCALLBACK)
-
-typedef HRESULT CALLBACK (*LPDDENUMMODESCALLBACK)(LPDDSURFACEDESC, LPVOID);
-typedef HRESULT CALLBACK (*LPDDENUMMODESCALLBACK2)(LPDDSURFACEDESC2, LPVOID);
-typedef HRESULT CALLBACK (*LPDDENUMSURFACESCALLBACK)(LPDIRECTDRAWSURFACE, LPDDSURFACEDESC, LPVOID);
-typedef HRESULT CALLBACK (*LPDDENUMSURFACESCALLBACK2)(LPDIRECTDRAWSURFACE4, LPDDSURFACEDESC2, LPVOID);
-typedef HRESULT CALLBACK (*LPDDENUMSURFACESCALLBACK7)(LPDIRECTDRAWSURFACE7, LPDDSURFACEDESC2, LPVOID);
-
-typedef BOOL CALLBACK (*LPDDENUMCALLBACKEXA)(GUID *, LPSTR, LPSTR, LPVOID, HMONITOR);
-typedef BOOL CALLBACK (*LPDDENUMCALLBACKEXW)(GUID *, LPWSTR, LPWSTR, LPVOID, HMONITOR);
-DECL_WINELIB_TYPE_AW(LPDDENUMCALLBACKEX)
-
-HRESULT WINAPI DirectDrawEnumerateExA( LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags);
-HRESULT WINAPI DirectDrawEnumerateExW( LPDDENUMCALLBACKEXW lpCallback, LPVOID lpContext, DWORD dwFlags);
-#define DirectDrawEnumerateEx WINELIB_NAME_AW(DirectDrawEnumerateEx)
-
-/* flags for DirectDrawEnumerateEx */
-#define DDENUM_ATTACHEDSECONDARYDEVICES 0x00000001
-#define DDENUM_DETACHEDSECONDARYDEVICES 0x00000002
-#define DDENUM_NONDISPLAYDEVICES 0x00000004
-
-/* flags for DirectDrawCreate or IDirectDraw::Initialize */
-#define DDCREATE_HARDWAREONLY 1L
-#define DDCREATE_EMULATIONONLY 2L
-
-typedef struct _DDBLTFX
-{
- DWORD dwSize; /* size of structure */
- DWORD dwDDFX; /* FX operations */
- DWORD dwROP; /* Win32 raster operations */
- DWORD dwDDROP; /* Raster operations new for DirectDraw */
- DWORD dwRotationAngle; /* Rotation angle for blt */
- DWORD dwZBufferOpCode; /* ZBuffer compares */
- DWORD dwZBufferLow; /* Low limit of Z buffer */
- DWORD dwZBufferHigh; /* High limit of Z buffer */
- DWORD dwZBufferBaseDest; /* Destination base value */
- DWORD dwZDestConstBitDepth; /* Bit depth used to specify Z constant for destination */
- union
- {
- DWORD dwZDestConst; /* Constant to use as Z buffer for dest */
- LPDIRECTDRAWSURFACE lpDDSZBufferDest; /* Surface to use as Z buffer for dest */
- } DUMMYUNIONNAME1;
- DWORD dwZSrcConstBitDepth; /* Bit depth used to specify Z constant for source */
- union
- {
- DWORD dwZSrcConst; /* Constant to use as Z buffer for src */
- LPDIRECTDRAWSURFACE lpDDSZBufferSrc; /* Surface to use as Z buffer for src */
- } DUMMYUNIONNAME2;
- DWORD dwAlphaEdgeBlendBitDepth; /* Bit depth used to specify constant for alpha edge blend */
- DWORD dwAlphaEdgeBlend; /* Alpha for edge blending */
- DWORD dwReserved;
- DWORD dwAlphaDestConstBitDepth; /* Bit depth used to specify alpha constant for destination */
- union
- {
- DWORD dwAlphaDestConst; /* Constant to use as Alpha Channel */
- LPDIRECTDRAWSURFACE lpDDSAlphaDest; /* Surface to use as Alpha Channel */
- } DUMMYUNIONNAME3;
- DWORD dwAlphaSrcConstBitDepth; /* Bit depth used to specify alpha constant for source */
- union
- {
- DWORD dwAlphaSrcConst; /* Constant to use as Alpha Channel */
- LPDIRECTDRAWSURFACE lpDDSAlphaSrc; /* Surface to use as Alpha Channel */
- } DUMMYUNIONNAME4;
- union
- {
- DWORD dwFillColor; /* color in RGB or Palettized */
- DWORD dwFillDepth; /* depth value for z-buffer */
- DWORD dwFillPixel; /* pixel val for RGBA or RGBZ */
- LPDIRECTDRAWSURFACE lpDDSPattern; /* Surface to use as pattern */
- } DUMMYUNIONNAME5;
- DDCOLORKEY ddckDestColorkey; /* DestColorkey override */
- DDCOLORKEY ddckSrcColorkey; /* SrcColorkey override */
-} DDBLTFX,*LPDDBLTFX;
-
-/* dwDDFX */
-/* arithmetic stretching along y axis */
-#define DDBLTFX_ARITHSTRETCHY 0x00000001
-/* mirror on y axis */
-#define DDBLTFX_MIRRORLEFTRIGHT 0x00000002
-/* mirror on x axis */
-#define DDBLTFX_MIRRORUPDOWN 0x00000004
-/* do not tear */
-#define DDBLTFX_NOTEARING 0x00000008
-/* 180 degrees clockwise rotation */
-#define DDBLTFX_ROTATE180 0x00000010
-/* 270 degrees clockwise rotation */
-#define DDBLTFX_ROTATE270 0x00000020
-/* 90 degrees clockwise rotation */
-#define DDBLTFX_ROTATE90 0x00000040
-/* dwZBufferLow and dwZBufferHigh specify limits to the copied Z values */
-#define DDBLTFX_ZBUFFERRANGE 0x00000080
-/* add dwZBufferBaseDest to every source z value before compare */
-#define DDBLTFX_ZBUFFERBASEDEST 0x00000100
-
-typedef struct _DDOVERLAYFX
-{
- DWORD dwSize; /* size of structure */
- DWORD dwAlphaEdgeBlendBitDepth; /* Bit depth used to specify constant for alpha edge blend */
- DWORD dwAlphaEdgeBlend; /* Constant to use as alpha for edge blend */
- DWORD dwReserved;
- DWORD dwAlphaDestConstBitDepth; /* Bit depth used to specify alpha constant for destination */
- union
- {
- DWORD dwAlphaDestConst; /* Constant to use as alpha channel for dest */
- LPDIRECTDRAWSURFACE lpDDSAlphaDest; /* Surface to use as alpha channel for dest */
- } DUMMYUNIONNAME1;
- DWORD dwAlphaSrcConstBitDepth; /* Bit depth used to specify alpha constant for source */
- union
- {
- DWORD dwAlphaSrcConst; /* Constant to use as alpha channel for src */
- LPDIRECTDRAWSURFACE lpDDSAlphaSrc; /* Surface to use as alpha channel for src */
- } DUMMYUNIONNAME2;
- DDCOLORKEY dckDestColorkey; /* DestColorkey override */
- DDCOLORKEY dckSrcColorkey; /* DestColorkey override */
- DWORD dwDDFX; /* Overlay FX */
- DWORD dwFlags; /* flags */
-} DDOVERLAYFX,*LPDDOVERLAYFX;
-
-typedef struct _DDBLTBATCH
-{
- LPRECT lprDest;
- LPDIRECTDRAWSURFACE lpDDSSrc;
- LPRECT lprSrc;
- DWORD dwFlags;
- LPDDBLTFX lpDDBltFx;
-} DDBLTBATCH,*LPDDBLTBATCH;
-
-#define MAX_DDDEVICEID_STRING 512
-
-typedef struct tagDDDEVICEIDENTIFIER {
- char szDriver[MAX_DDDEVICEID_STRING];
- char szDescription[MAX_DDDEVICEID_STRING];
- LARGE_INTEGER liDriverVersion;
- DWORD dwVendorId;
- DWORD dwDeviceId;
- DWORD dwSubSysId;
- DWORD dwRevision;
- GUID guidDeviceIdentifier;
-} DDDEVICEIDENTIFIER, * LPDDDEVICEIDENTIFIER;
-
-typedef struct tagDDDEVICEIDENTIFIER2 {
- char szDriver[MAX_DDDEVICEID_STRING]; /* user readable driver name */
- char szDescription[MAX_DDDEVICEID_STRING]; /* user readable description */
- LARGE_INTEGER liDriverVersion; /* driver version */
- DWORD dwVendorId; /* vendor ID, zero if unknown */
- DWORD dwDeviceId; /* chipset ID, zero if unknown */
- DWORD dwSubSysId; /* board ID, zero if unknown */
- DWORD dwRevision; /* chipset version, zero if unknown */
- GUID guidDeviceIdentifier; /* unique ID for this driver/chipset combination */
- DWORD dwWHQLLevel; /* Windows Hardware Quality Lab certification level */
-} DDDEVICEIDENTIFIER2, * LPDDDEVICEIDENTIFIER2;
-
-/*****************************************************************************
- * IDirectDrawPalette interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectDrawPalette
-DECLARE_INTERFACE_(IDirectDrawPalette,IUnknown)
-{
- STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE;
- STDMETHOD_(ULONG,AddRef)(THIS) PURE;
- STDMETHOD_(ULONG,Release)(THIS) PURE;
- STDMETHOD(GetCaps)(THIS_ LPDWORD lpdwCaps) PURE;
- STDMETHOD(GetEntries)(THIS_ DWORD dwFlags, DWORD dwBase, DWORD dwNumEntries, LPPALETTEENTRY lpEntries) PURE;
- STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW lpDD, DWORD dwFlags, LPPALETTEENTRY lpDDColorTable) PURE;
- STDMETHOD(SetEntries)(THIS_ DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries) PURE;
-};
-
- /*** IUnknown methods ***/
-#define IDirectDrawPalette_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
-#define IDirectDrawPalette_AddRef(p) ICOM_CALL_(AddRef,p,(p))
-#define IDirectDrawPalette_Release(p) ICOM_CALL_(Release,p,(p))
- /*** IDirectDrawPalette methods ***/
-#define IDirectDrawPalette_GetCaps(p,a) ICOM_CALL_(GetCaps,p,(p,a))
-#define IDirectDrawPalette_GetEntries(p,a,b,c,d) ICOM_CALL_(GetEntries,p,(p,a,b,c,d))
-#define IDirectDrawPalette_Initialize(p,a,b,c) ICOM_CALL_(Initialize,p,(p,a,b,c))
-#define IDirectDrawPalette_SetEntries(p,a,b,c,d) ICOM_CALL_(SetEntries,p,(p,a,b,c,d))
-
-
-/*****************************************************************************
- * IDirectDrawClipper interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectDrawClipper
-DECLARE_INTERFACE_(IDirectDrawClipper,IUnknown)
-{
- STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
- STDMETHOD_(ULONG,AddRef)(THIS) PURE;
- STDMETHOD_(ULONG,Release)(THIS) PURE;
- STDMETHOD(GetClipList)(THIS_ LPRECT lpRect, LPRGNDATA lpClipList, LPDWORD lpdwSize) PURE;
- STDMETHOD(GetHWnd)(THIS_ HWND* lphWnd) PURE;
- STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW lpDD, DWORD dwFlags) PURE;
- STDMETHOD(IsClipListChanged)(THIS_ BOOL* lpbChanged) PURE;
- STDMETHOD(SetClipList)(THIS_ LPRGNDATA lpClipList, DWORD dwFlags) PURE;
- STDMETHOD(SetHWnd)(THIS_ DWORD dwFlags, HWND hWnd) PURE;
-};
-
- /*** IUnknown methods ***/
-#define IDirectDrawClipper_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
-#define IDirectDrawClipper_AddRef(p) ICOM_CALL_(AddRef,p,(p))
-#define IDirectDrawClipper_Release(p) ICOM_CALL_(Release,p,(p))
- /*** IDirectDrawClipper methods ***/
-#define IDirectDrawClipper_GetClipList(p,a,b,c) ICOM_CALL_(GetClipList,p,(p,a,b,c))
-#define IDirectDrawClipper_GetHWnd(p,a) ICOM_CALL_(GetHWnd,p,(p,a))
-#define IDirectDrawClipper_Initialize(p,a,b) ICOM_CALL_(Initialize,p,(p,a,b))
-#define IDirectDrawClipper_IsClipListChanged(p,a) ICOM_CALL_(IsClipListChanged,p,(p,a))
-#define IDirectDrawClipper_SetClipList(p,a,b) ICOM_CALL_(SetClipList,p,(p,a,b))
-#define IDirectDrawClipper_SetHWnd(p,a,b) ICOM_CALL_(SetHWnd,p,(p,a,b))
-
-
-/*****************************************************************************
- * IDirectDraw interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectDraw
-DECLARE_INTERFACE_(IDirectDraw,IUnknown)
-{
- STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
- STDMETHOD_(ULONG,AddRef)(THIS) PURE;
- STDMETHOD_(ULONG,Release)(THIS) PURE;
- STDMETHOD(Compact)(THIS) PURE;
- STDMETHOD(CreateClipper)(THIS_ DWORD dwFlags, LPDIRECTDRAWCLIPPER* lplpDDClipper, IUnknown* pUnkOuter) PURE;
- STDMETHOD(CreatePalette)(THIS_ DWORD dwFlags, LPPALETTEENTRY lpColorTable, LPDIRECTDRAWPALETTE* lplpDDPalette, IUnknown* pUnkOuter) PURE;
- STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC lpDDSurfaceDesc, LPDIRECTDRAWSURFACE* lplpDDSurface, IUnknown* pUnkOuter) PURE;
- STDMETHOD(DuplicateSurface)(THIS_ LPDIRECTDRAWSURFACE lpDDSurface, LPDIRECTDRAWSURFACE* lplpDupDDSurface) PURE;
- STDMETHOD(EnumDisplayModes)(THIS_ DWORD dwFlags, LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMMODESCALLBACK lpEnumModesCallback) PURE;
- STDMETHOD(EnumSurfaces)(THIS_ DWORD dwFlags, LPDDSURFACEDESC lpDDSD, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback) PURE;
- STDMETHOD(FlipToGDISurface)(THIS) PURE;
- STDMETHOD(GetCaps)(THIS_ LPDDCAPS lpDDDriverCaps, LPDDCAPS lpDDHELCaps) PURE;
- STDMETHOD(GetDisplayMode)(THIS_ LPDDSURFACEDESC lpDDSurfaceDesc) PURE;
- STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD lpNumCodes, LPDWORD lpCodes) PURE;
- STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE* lplpGDIDDSurface) PURE;
- STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD lpdwFrequency) PURE;
- STDMETHOD(GetScanLine)(THIS_ LPDWORD lpdwScanLine) PURE;
- STDMETHOD(GetVerticalBlankStatus)(THIS_ BOOL* lpbIsInVB) PURE;
- STDMETHOD(Initialize)(THIS_ GUID* lpGUID) PURE;
- STDMETHOD(RestoreDisplayMode)(THIS) PURE;
- STDMETHOD(SetCooperativeLevel)(THIS_ HWND hWnd, DWORD dwFlags) PURE;
- STDMETHOD(SetDisplayMode)(THIS_ DWORD, DWORD, DWORD) PURE;
- STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD dwFlags, HANDLE hEvent) PURE;
-};
-
- /*** IUnknown methods ***/
-#define IDirectDraw_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
-#define IDirectDraw_AddRef(p) ICOM_CALL_(AddRef,p,(p))
-#define IDirectDraw_Release(p) ICOM_CALL_(Release,p,(p))
- /*** IDirectDraw methods ***/
-#define IDirectDraw_Compact(p) ICOM_CALL_(Compact,p,(p))
-#define IDirectDraw_CreateClipper(p,a,b,c) ICOM_CALL_(CreateClipper,p,(p,a,b,c))
-#define IDirectDraw_CreatePalette(p,a,b,c,d) ICOM_CALL_(CreatePalette,p,(p,a,b,c,d))
-#define IDirectDraw_CreateSurface(p,a,b,c) ICOM_CALL_(CreateSurface,p,(p,a,b,c))
-#define IDirectDraw_DuplicateSurface(p,a,b) ICOM_CALL_(DuplicateSurface,p,(p,a,b))
-#define IDirectDraw_EnumDisplayModes(p,a,b,c,d) ICOM_CALL_(EnumDisplayModes,p,(p,a,b,c,d))
-#define IDirectDraw_EnumSurfaces(p,a,b,c,d) ICOM_CALL_(EnumSurfaces,p,(p,a,b,c,d))
-#define IDirectDraw_FlipToGDISurface(p) ICOM_CALL_(FlipToGDISurface,p,(p))
-#define IDirectDraw_GetCaps(p,a,b) ICOM_CALL_(GetCaps,p,(p,a,b))
-#define IDirectDraw_GetDisplayMode(p,a) ICOM_CALL_(GetDisplayMode,p,(p,a))
-#define IDirectDraw_GetFourCCCodes(p,a,b) ICOM_CALL_(GetFourCCCodes,p,(p,a,b))
-#define IDirectDraw_GetGDISurface(p,a) ICOM_CALL_(GetGDISurface,p,(p,a))
-#define IDirectDraw_GetMonitorFrequency(p,a) ICOM_CALL_(GetMonitorFrequency,p,(p,a))
-#define IDirectDraw_GetScanLine(p,a) ICOM_CALL_(GetScanLine,p,(p,a))
-#define IDirectDraw_GetVerticalBlankStatus(p,a) ICOM_CALL_(GetVerticalBlankStatus,p,(p,a))
-#define IDirectDraw_Initialize(p,a) ICOM_CALL_(Initialize,p,(p,a))
-#define IDirectDraw_RestoreDisplayMode(p) ICOM_CALL_(RestoreDisplayMode,p,(p))
-#define IDirectDraw_SetCooperativeLevel(p,a,b) ICOM_CALL_(SetCooperativeLevel,p,(p,a,b))
-#define IDirectDraw_SetDisplayMode(p,a,b,c) ICOM_CALL_(SetDisplayMode,p,(p,a,b,c))
-#define IDirectDraw_WaitForVerticalBlank(p,a,b) ICOM_CALL_(WaitForVerticalBlank,p,(p,a,b))
-
-
-/* flags for Lock() */
-#define DDLOCK_SURFACEMEMORYPTR 0x00000000
-#define DDLOCK_WAIT 0x00000001
-#define DDLOCK_EVENT 0x00000002
-#define DDLOCK_READONLY 0x00000010
-#define DDLOCK_WRITEONLY 0x00000020
-#define DDLOCK_NOSYSLOCK 0x00000800
-
-
-/*****************************************************************************
- * IDirectDraw2 interface
- */
-/* Note: IDirectDraw2 cannot derive from IDirectDraw because the number of
- * arguments of SetDisplayMode has changed !
- */
-#undef INTERFACE
-#define INTERFACE IDirectDraw2
-DECLARE_INTERFACE_(IDirectDraw2,IUnknown)
-{
- STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
- STDMETHOD_(ULONG,AddRef)(THIS) PURE;
- STDMETHOD_(ULONG,Release)(THIS) PURE;
- STDMETHOD(Compact)(THIS) PURE;
- STDMETHOD(CreateClipper)(THIS_ DWORD dwFlags, LPDIRECTDRAWCLIPPER* lplpDDClipper, IUnknown* pUnkOuter) PURE;
- STDMETHOD(CreatePalette)(THIS_ DWORD dwFlags, LPPALETTEENTRY lpColorTable, LPDIRECTDRAWPALETTE* lplpDDPalette, IUnknown* pUnkOuter) PURE;
- STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC lpDDSurfaceDesc, LPDIRECTDRAWSURFACE2* lplpDDSurface, IUnknown* pUnkOuter) PURE;
- STDMETHOD(DuplicateSurface)(THIS_ LPDIRECTDRAWSURFACE2 lpDDSurface, LPDIRECTDRAWSURFACE2* lplpDupDDSurface) PURE;
- STDMETHOD(EnumDisplayModes)(THIS_ DWORD dwFlags, LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMMODESCALLBACK lpEnumModesCallback) PURE;
- STDMETHOD(EnumSurfaces)(THIS_ DWORD dwFlags, LPDDSURFACEDESC lpDDSD, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback) PURE;
- STDMETHOD(FlipToGDISurface)(THIS) PURE;
- STDMETHOD(GetCaps)(THIS_ LPDDCAPS lpDDDriverCaps, LPDDCAPS lpDDHELCaps) PURE;
- STDMETHOD(GetDisplayMode)(THIS_ LPDDSURFACEDESC lpDDSurfaceDesc) PURE;
- STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD lpNumCodes, LPDWORD lpCodes) PURE;
- STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE2* lplpGDIDDSurface) PURE;
- STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD lpdwFrequency) PURE;
- STDMETHOD(GetScanLine)(THIS_ LPDWORD lpdwScanLine) PURE;
- STDMETHOD(GetVerticalBlankStatus)(THIS_ BOOL* lpbIsInVB) PURE;
- STDMETHOD(Initialize)(THIS_ GUID* lpGUID) PURE;
- STDMETHOD(RestoreDisplayMode)(THIS) PURE;
- STDMETHOD(SetCooperativeLevel)(THIS_ HWND hWnd, DWORD dwFlags) PURE;
- STDMETHOD(SetDisplayMode)(THIS_ DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags) PURE;
- STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD dwFlags, HANDLE hEvent) PURE;
-
- STDMETHOD(GetAvailableVidMem)(THIS_ LPDDSCAPS lpDDCaps, LPDWORD lpdwTotal, LPDWORD lpdwFree) PURE;
-};
-
- /*** IUnknown methods ***/
-#define IDirectDraw2_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
-#define IDirectDraw2_AddRef(p) ICOM_CALL_(AddRef,p,(p))
-#define IDirectDraw2_Release(p) ICOM_CALL_(Release,p,(p))
- /*** IDirectDraw methods ***/
-#define IDirectDraw2_Compact(p) ICOM_CALL_(Compact,p,(p))
-#define IDirectDraw2_CreateClipper(p,a,b,c) ICOM_CALL_(CreateClipper,p,(p,a,b,c))
-#define IDirectDraw2_CreatePalette(p,a,b,c,d) ICOM_CALL_(CreatePalette,p,(p,a,b,c,d))
-#define IDirectDraw2_CreateSurface(p,a,b,c) ICOM_CALL_(CreateSurface,p,(p,a,b,c))
-#define IDirectDraw2_DuplicateSurface(p,a,b) ICOM_CALL_(DuplicateSurface,p,(p,a,b))
-#define IDirectDraw2_EnumDisplayModes(p,a,b,c,d) ICOM_CALL_(EnumDisplayModes,p,(p,a,b,c,d))
-#define IDirectDraw2_EnumSurfaces(p,a,b,c,d) ICOM_CALL_(EnumSurfaces,p,(p,a,b,c,d))
-#define IDirectDraw2_FlipToGDISurface(p) ICOM_CALL_(FlipToGDISurface,p,(p))
-#define IDirectDraw2_GetCaps(p,a,b) ICOM_CALL_(GetCaps,p,(p,a,b))
-#define IDirectDraw2_GetDisplayMode(p,a) ICOM_CALL_(GetDisplayMode,p,(p,a))
-#define IDirectDraw2_GetFourCCCodes(p,a,b) ICOM_CALL_(GetFourCCCodes,p,(p,a,b))
-#define IDirectDraw2_GetGDISurface(p,a) ICOM_CALL_(GetGDISurface,p,(p,a))
-#define IDirectDraw2_GetMonitorFrequency(p,a) ICOM_CALL_(GetMonitorFrequency,p,(p,a))
-#define IDirectDraw2_GetScanLine(p,a) ICOM_CALL_(GetScanLine,p,(p,a))
-#define IDirectDraw2_GetVerticalBlankStatus(p,a) ICOM_CALL_(GetVerticalBlankStatus,p,(p,a))
-#define IDirectDraw2_Initialize(p,a) ICOM_CALL_(Initialize,p,(p,a))
-#define IDirectDraw2_RestoreDisplayMode(p) ICOM_CALL_(RestoreDisplayMode,p,(p))
-#define IDirectDraw2_SetCooperativeLevel(p,a,b) ICOM_CALL_(SetCooperativeLevel,p,(p,a,b))
-#define IDirectDraw2_SetDisplayMode(p,a,b,c,d,e) ICOM_CALL_(SetDisplayMode,p,(p,a,b,c,d,e))
-#define IDirectDraw2_WaitForVerticalBlank(p,a,b) ICOM_CALL_(WaitForVerticalBlank,p,(p,a,b))
-/*** IDirectDraw2 methods ***/
-#define IDirectDraw2_GetAvailableVidMem(p,a,b,c) ICOM_CALL_(GetAvailableVidMem,p,(p,a,b,c))
-
-
-/*****************************************************************************
- * IDirectDraw4 interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectDraw4
-DECLARE_INTERFACE_(IDirectDraw4,IUnknown)
-{
- STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
- STDMETHOD_(ULONG,AddRef)(THIS) PURE;
- STDMETHOD_(ULONG,Release)(THIS) PURE;
- STDMETHOD(Compact)(THIS) PURE;
- STDMETHOD(CreateClipper)(THIS_ DWORD dwFlags, LPDIRECTDRAWCLIPPER* lplpDDClipper, IUnknown* pUnkOuter) PURE;
- STDMETHOD(CreatePalette)(THIS_ DWORD dwFlags, LPPALETTEENTRY lpColorTable, LPDIRECTDRAWPALETTE* lplpDDPalette, IUnknown* pUnkOuter) PURE;
- STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC2 lpDDSurfaceDesc, LPDIRECTDRAWSURFACE4* lplpDDSurface, IUnknown* pUnkOuter) PURE;
- STDMETHOD(DuplicateSurface)(THIS_ LPDIRECTDRAWSURFACE4 lpDDSurface, LPDIRECTDRAWSURFACE4* lplpDupDDSurface) PURE;
- STDMETHOD(EnumDisplayModes)(THIS_ DWORD dwFlags, LPDDSURFACEDESC2 lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMMODESCALLBACK2 lpEnumModesCallback) PURE;
- STDMETHOD(EnumSurfaces)(THIS_ DWORD dwFlags, LPDDSURFACEDESC2 lpDDSD, LPVOID lpContext, LPDDENUMSURFACESCALLBACK2 lpEnumSurfacesCallback) PURE;
- STDMETHOD(FlipToGDISurface)(THIS) PURE;
- STDMETHOD(GetCaps)(THIS_ LPDDCAPS lpDDDriverCaps, LPDDCAPS lpDDHELCaps) PURE;
- STDMETHOD(GetDisplayMode)(THIS_ LPDDSURFACEDESC2 lpDDSurfaceDesc) PURE;
- STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD lpNumCodes, LPDWORD lpCodes) PURE;
- STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE4* lplpGDIDDSurface) PURE;
- STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD lpdwFrequency) PURE;
- STDMETHOD(GetScanLine)(THIS_ LPDWORD lpdwScanLine) PURE;
- STDMETHOD(GetVerticalBlankStatus)(THIS_ BOOL* lpbIsInVB) PURE;
- STDMETHOD(Initialize)(THIS_ GUID* lpGUID) PURE;
- STDMETHOD(RestoreDisplayMode)(THIS) PURE;
- STDMETHOD(SetCooperativeLevel)(THIS_ HWND hWnd, DWORD dwFlags) PURE;
- STDMETHOD(SetDisplayMode)(THIS_ DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags) PURE;
- STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD dwFlags, HANDLE hEvent) PURE;
-
- STDMETHOD(GetAvailableVidMem)(THIS_ LPDDSCAPS2 lpDDCaps, LPDWORD lpdwTotal, LPDWORD lpdwFree) PURE;
-
- STDMETHOD(GetSurfaceFromDC)(THIS_ HDC , LPDIRECTDRAWSURFACE4* ) PURE;
- STDMETHOD(RestoreAllSurfaces)(THIS) PURE;
- STDMETHOD(TestCooperativeLevel)(THIS) PURE;
- STDMETHOD(GetDeviceIdentifier)(THIS_ LPDDDEVICEIDENTIFIER , DWORD ) PURE;
-};
-
- /*** IUnknown methods ***/
-#define IDirectDraw4_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
-#define IDirectDraw4_AddRef(p) ICOM_CALL_(AddRef,p,(p))
-#define IDirectDraw4_Release(p) ICOM_CALL_(Release,p,(p))
- /*** IDirectDraw methods ***/
-#define IDirectDraw4_Compact(p) ICOM_CALL_(Compact,p,(p))
-#define IDirectDraw4_CreateClipper(p,a,b,c) ICOM_CALL_(CreateClipper,p,(p,a,b,c))
-#define IDirectDraw4_CreatePalette(p,a,b,c,d) ICOM_CALL_(CreatePalette,p,(p,a,b,c,d))
-#define IDirectDraw4_CreateSurface(p,a,b,c) ICOM_CALL_(CreateSurface,p,(p,a,b,c))
-#define IDirectDraw4_DuplicateSurface(p,a,b) ICOM_CALL_(DuplicateSurface,p,(p,a,b))
-#define IDirectDraw4_EnumDisplayModes(p,a,b,c,d) ICOM_CALL_(EnumDisplayModes,p,(p,a,b,c,d))
-#define IDirectDraw4_EnumSurfaces(p,a,b,c,d) ICOM_CALL_(EnumSurfaces,p,(p,a,b,c,d))
-#define IDirectDraw4_FlipToGDISurface(p) ICOM_CALL_(FlipToGDISurface,p,(p))
-#define IDirectDraw4_GetCaps(p,a,b) ICOM_CALL_(GetCaps,p,(p,a,b))
-#define IDirectDraw4_GetDisplayMode(p,a) ICOM_CALL_(GetDisplayMode,p,(p,a))
-#define IDirectDraw4_GetFourCCCodes(p,a,b) ICOM_CALL_(GetFourCCCodes,p,(p,a,b))
-#define IDirectDraw4_GetGDISurface(p,a) ICOM_CALL_(GetGDISurface,p,(p,a))
-#define IDirectDraw4_GetMonitorFrequency(p,a) ICOM_CALL_(GetMonitorFrequency,p,(p,a))
-#define IDirectDraw4_GetScanLine(p,a) ICOM_CALL_(GetScanLine,p,(p,a))
-#define IDirectDraw4_GetVerticalBlankStatus(p,a) ICOM_CALL_(GetVerticalBlankStatus,p,(p,a))
-#define IDirectDraw4_Initialize(p,a) ICOM_CALL_(Initialize,p,(p,a))
-#define IDirectDraw4_RestoreDisplayMode(p) ICOM_CALL_(RestoreDisplayMode,p,(p))
-#define IDirectDraw4_SetCooperativeLevel(p,a,b) ICOM_CALL_(SetCooperativeLevel,p,(p,a,b))
-#define IDirectDraw4_SetDisplayMode(p,a,b,c,d,e) ICOM_CALL_(SetDisplayMode,p,(p,a,b,c,d,e))
-#define IDirectDraw4_WaitForVerticalBlank(p,a,b) ICOM_CALL_(WaitForVerticalBlank,p,(p,a,b))
-/*** IDirectDraw2 methods ***/
-#define IDirectDraw4_GetAvailableVidMem(p,a,b,c) ICOM_CALL_(GetAvailableVidMem,p,(p,a,b,c))
-/*** IDirectDraw4 methods ***/
-#define IDirectDraw4_GetSurfaceFromDC(p,a,b) ICOM_CALL_(GetSurfaceFromDC,p,(p,a,b))
-#define IDirectDraw4_RestoreAllSurfaces(pc) ICOM_CALL_(RestoreAllSurfaces,p,(p))
-#define IDirectDraw4_TestCooperativeLevel(p) ICOM_CALL_(TestCooperativeLevel,p,(p))
-#define IDirectDraw4_GetDeviceIdentifier(p,a,b) ICOM_CALL_(GetDeviceIdentifier,p,(p,a,b))
-
-
-/*****************************************************************************
- * IDirectDraw7 interface
- */
-/* Note: IDirectDraw7 cannot derive from IDirectDraw4; it is even documented
- * as not interchangeable with earlier DirectDraw interfaces.
- */
-#undef INTERFACE
-#define INTERFACE IDirectDraw7
-DECLARE_INTERFACE_(IDirectDraw7,IUnknown)
-{
- STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
- STDMETHOD_(ULONG,AddRef)(THIS) PURE;
- STDMETHOD_(ULONG,Release)(THIS) PURE;
- STDMETHOD(Compact)(THIS) PURE;
- STDMETHOD(CreateClipper)(THIS_ DWORD dwFlags, LPDIRECTDRAWCLIPPER* lplpDDClipper, IUnknown* pUnkOuter) PURE;
- STDMETHOD(CreatePalette)(THIS_ DWORD dwFlags, LPPALETTEENTRY lpColorTable, LPDIRECTDRAWPALETTE* lplpDDPalette, IUnknown* pUnkOuter) PURE;
- STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC2 lpDDSurfaceDesc, LPDIRECTDRAWSURFACE7* lplpDDSurface, IUnknown* pUnkOuter) PURE;
- STDMETHOD(DuplicateSurface)(THIS_ LPDIRECTDRAWSURFACE7 lpDDSurface, LPDIRECTDRAWSURFACE7* lplpDupDDSurface) PURE;
- STDMETHOD(EnumDisplayModes)(THIS_ DWORD dwFlags, LPDDSURFACEDESC2 lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMMODESCALLBACK2 lpEnumModesCallback) PURE;
- STDMETHOD(EnumSurfaces)(THIS_ DWORD dwFlags, LPDDSURFACEDESC2 lpDDSD, LPVOID lpContext, LPDDENUMSURFACESCALLBACK7 lpEnumSurfacesCallback) PURE;
- STDMETHOD(FlipToGDISurface)(THIS) PURE;
- STDMETHOD(GetCaps)(THIS_ LPDDCAPS lpDDDriverCaps, LPDDCAPS lpDDHELCaps) PURE;
- STDMETHOD(GetDisplayMode)(THIS_ LPDDSURFACEDESC2 lpDDSurfaceDesc) PURE;
- STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD lpNumCodes, LPDWORD lpCodes) PURE;
- STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE7* lplpGDIDDSurface) PURE;
- STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD lpdwFrequency) PURE;
- STDMETHOD(GetScanLine)(THIS_ LPDWORD lpdwScanLine) PURE;
- STDMETHOD(GetVerticalBlankStatus)(THIS_ BOOL* lpbIsInVB) PURE;
- STDMETHOD(Initialize)(THIS_ GUID* lpGUID) PURE;
- STDMETHOD(RestoreDisplayMode)(THIS) PURE;
- STDMETHOD(SetCooperativeLevel)(THIS_ HWND hWnd, DWORD dwFlags) PURE;
- STDMETHOD(SetDisplayMode)(THIS_ DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags) PURE;
- STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD dwFlags, HANDLE hEvent) PURE;
-
- STDMETHOD(GetAvailableVidMem)(THIS_ LPDDSCAPS2 lpDDCaps, LPDWORD lpdwTotal, LPDWORD lpdwFree) PURE;
-
- STDMETHOD(GetSurfaceFromDC)(THIS_ HDC , LPDIRECTDRAWSURFACE7* ) PURE;
- STDMETHOD(RestoreAllSurfaces)(THIS) PURE;
- STDMETHOD(TestCooperativeLevel)(THIS) PURE;
- STDMETHOD(GetDeviceIdentifier)(THIS_ LPDDDEVICEIDENTIFIER2 , DWORD ) PURE;
-
- STDMETHOD(StartModeTest)(THIS_ LPSIZE , DWORD , DWORD ) PURE;
- STDMETHOD(EvaluateMode)(THIS_ DWORD , DWORD * ) PURE;
-};
-
- /*** IUnknown methods ***/
-#define IDirectDraw7_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
-#define IDirectDraw7_AddRef(p) ICOM_CALL_(AddRef,p,(p))
-#define IDirectDraw7_Release(p) ICOM_CALL_(Release,p,(p))
- /*** IDirectDraw methods ***/
-#define IDirectDraw7_Compact(p) ICOM_CALL_(Compact,p,(p))
-#define IDirectDraw7_CreateClipper(p,a,b,c) ICOM_CALL_(CreateClipper,p,(p,a,b,c))
-#define IDirectDraw7_CreatePalette(p,a,b,c,d) ICOM_CALL_(CreatePalette,p,(p,a,b,c,d))
-#define IDirectDraw7_CreateSurface(p,a,b,c) ICOM_CALL_(CreateSurface,p,(p,a,b,c))
-#define IDirectDraw7_DuplicateSurface(p,a,b) ICOM_CALL_(DuplicateSurface,p,(p,a,b))
-#define IDirectDraw7_EnumDisplayModes(p,a,b,c,d) ICOM_CALL_(EnumDisplayModes,p,(p,a,b,c,d))
-#define IDirectDraw7_EnumSurfaces(p,a,b,c,d) ICOM_CALL_(EnumSurfaces,p,(p,a,b,c,d))
-#define IDirectDraw7_FlipToGDISurface(p) ICOM_CALL_(FlipToGDISurface,p,(p))
-#define IDirectDraw7_GetCaps(p,a,b) ICOM_CALL_(GetCaps,p,(p,a,b))
-#define IDirectDraw7_GetDisplayMode(p,a) ICOM_CALL_(GetDisplayMode,p,(p,a))
-#define IDirectDraw7_GetFourCCCodes(p,a,b) ICOM_CALL_(GetFourCCCodes,p,(p,a,b))
-#define IDirectDraw7_GetGDISurface(p,a) ICOM_CALL_(GetGDISurface,p,(p,a))
-#define IDirectDraw7_GetMonitorFrequency(p,a) ICOM_CALL_(GetMonitorFrequency,p,(p,a))
-#define IDirectDraw7_GetScanLine(p,a) ICOM_CALL_(GetScanLine,p,(p,a))
-#define IDirectDraw7_GetVerticalBlankStatus(p,a) ICOM_CALL_(GetVerticalBlankStatus,p,(p,a))
-#define IDirectDraw7_Initialize(p,a) ICOM_CALL_(Initialize,p,(p,a))
-#define IDirectDraw7_RestoreDisplayMode(p) ICOM_CALL_(RestoreDisplayMode,p,(p))
-#define IDirectDraw7_SetCooperativeLevel(p,a,b) ICOM_CALL_(SetCooperativeLevel,p,(p,a,b))
-#define IDirectDraw7_SetDisplayMode(p,a,b,c,d,e) ICOM_CALL_(SetDisplayMode,p,(p,a,b,c,d,e))
-#define IDirectDraw7_WaitForVerticalBlank(p,a,b) ICOM_CALL_(WaitForVerticalBlank,p,(p,a,b))
-/*** added in IDirectDraw2 ***/
-#define IDirectDraw7_GetAvailableVidMem(p,a,b,c) ICOM_CALL_(GetAvailableVidMem,p,(p,a,b,c))
-/*** added in IDirectDraw4 ***/
-#define IDirectDraw7_GetSurfaceFromDC(p,a,b) ICOM_CALL_(GetSurfaceFromDC,p,(p,a,b))
-#define IDirectDraw7_RestoreAllSurfaces(p) ICOM_CALL_(RestoreAllSurfaces,p,(p))
-#define IDirectDraw7_TestCooperativeLevel(p) ICOM_CALL_(TestCooperativeLevel,p,(p))
-#define IDirectDraw7_GetDeviceIdentifier(p,a,b) ICOM_CALL_(GetDeviceIdentifier,p,(p,a,b))
-/*** added in IDirectDraw 7 ***/
-#define IDirectDraw7_StartModeTest(p,a,b,c) ICOM_CALL_(StartModeTest,p,(p,a,b,c))
-#define IDirectDraw7_EvaluateMode(p,a,b) ICOM_CALL_(EvaluateMode,p,(p,a,b))
-
-
-/*****************************************************************************
- * IDirectDrawSurface interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectDrawSurface
-DECLARE_INTERFACE_(IDirectDrawSurface,IUnknown)
-{
- STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
- STDMETHOD_(ULONG,AddRef)(THIS) PURE;
- STDMETHOD_(ULONG,Release)(THIS) PURE;
- STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE lpDDSAttachedSurface) PURE;
- STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT lpRect) PURE;
- STDMETHOD(Blt)(THIS_ LPRECT lpDestRect, LPDIRECTDRAWSURFACE lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx) PURE;
- STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags) PURE;
- STDMETHOD(BltFast)(THIS_ DWORD dwX, DWORD dwY, LPDIRECTDRAWSURFACE lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwTrans) PURE;
- STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD dwFlags, LPDIRECTDRAWSURFACE lpDDSAttachedSurface) PURE;
- STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback) PURE;
- STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD dwFlags, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpfnCallback) PURE;
- STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE lpDDSurfaceTargetOverride, DWORD dwFlags) PURE;
- STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS lpDDSCaps, LPDIRECTDRAWSURFACE* lplpDDAttachedSurface) PURE;
- STDMETHOD(GetBltStatus)(THIS_ DWORD dwFlags) PURE;
- STDMETHOD(GetCaps)(THIS_ LPDDSCAPS lpDDSCaps) PURE;
- STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER* lplpDDClipper) PURE;
- STDMETHOD(GetColorKey)(THIS_ DWORD dwFlags, LPDDCOLORKEY lpDDColorKey) PURE;
- STDMETHOD(GetDC)(THIS_ HDC* lphDC) PURE;
- STDMETHOD(GetFlipStatus)(THIS_ DWORD dwFlags) PURE;
- STDMETHOD(GetOverlayPosition)(THIS_ LPLONG lplX, LPLONG lplY) PURE;
- STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE* lplpDDPalette) PURE;
- STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT lpDDPixelFormat) PURE;
- STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC lpDDSurfaceDesc) PURE;
- STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW lpDD, LPDDSURFACEDESC lpDDSurfaceDesc) PURE;
- STDMETHOD(IsLost)(THIS) PURE;
- STDMETHOD(Lock)(THIS_ LPRECT lpDestRect, LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent) PURE;
- STDMETHOD(ReleaseDC)(THIS_ HDC hDC) PURE;
- STDMETHOD(Restore)(THIS) PURE;
- STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER lpDDClipper) PURE;
- STDMETHOD(SetColorKey)(THIS_ DWORD dwFlags, LPDDCOLORKEY lpDDColorKey) PURE;
- STDMETHOD(SetOverlayPosition)(THIS_ LONG lX, LONG lY) PURE;
- STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE lpDDPalette) PURE;
- STDMETHOD(Unlock)(THIS_ LPVOID lpSurfaceData) PURE;
- STDMETHOD(UpdateOverlay)(THIS_ LPRECT lpSrcRect, LPDIRECTDRAWSURFACE lpDDDestSurface, LPRECT lpDestRect, DWORD dwFlags, LPDDOVERLAYFX lpDDOverlayFx) PURE;
- STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD dwFlags) PURE;
- STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD dwFlags, LPDIRECTDRAWSURFACE lpDDSReference) PURE;
-};
-
- /*** IUnknown methods ***/
-#define IDirectDrawSurface_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
-#define IDirectDrawSurface_AddRef(p) ICOM_CALL_(AddRef,p,(p))
-#define IDirectDrawSurface_Release(p) ICOM_CALL_(Release,p,(p))
- /*** IDirectDrawSurface methods ***/
-#define IDirectDrawSurface_AddAttachedSurface(p,a) ICOM_CALL_(AddAttachedSurface,p,(p,a))
-#define IDirectDrawSurface_AddOverlayDirtyRect(p,a) ICOM_CALL_(AddOverlayDirtyRect,p,(p,a))
-#define IDirectDrawSurface_Blt(p,a,b,c,d,e) ICOM_CALL_(Blt,p,(p,a,b,c,d,e))
-#define IDirectDrawSurface_BltBatch(p,a,b,c) ICOM_CALL_(BltBatch,p,(p,a,b,c))
-#define IDirectDrawSurface_BltFast(p,a,b,c,d,e) ICOM_CALL_(BltFast,p,(p,a,b,c,d,e))
-#define IDirectDrawSurface_DeleteAttachedSurface(p,a,b) ICOM_CALL_(DeleteAttachedSurface,p,(p,a,b))
-#define IDirectDrawSurface_EnumAttachedSurfaces(p,a,b) ICOM_CALL_(EnumAttachedSurfaces,p,(p,a,b))
-#define IDirectDrawSurface_EnumOverlayZOrders(p,a,b,c) ICOM_CALL_(EnumOverlayZOrders,p,(p,a,b,c))
-#define IDirectDrawSurface_Flip(p,a,b) ICOM_CALL_(Flip,p,(p,a,b))
-#define IDirectDrawSurface_GetAttachedSurface(p,a,b) ICOM_CALL_(GetAttachedSurface,p,(p,a,b))
-#define IDirectDrawSurface_GetBltStatus(p,a) ICOM_CALL_(GetBltStatus,p,(p,a))
-#define IDirectDrawSurface_GetCaps(p,a) ICOM_CALL_(GetCaps,p,(p,a))
-#define IDirectDrawSurface_GetClipper(p,a) ICOM_CALL_(GetClipper,p,(p,a))
-#define IDirectDrawSurface_GetColorKey(p,a,b) ICOM_CALL_(GetColorKey,p,(p,a,b))
-#define IDirectDrawSurface_GetDC(p,a) ICOM_CALL_(GetDC,p,(p,a))
-#define IDirectDrawSurface_GetFlipStatus(p,a) ICOM_CALL_(GetFlipStatus,p,(p,a))
-#define IDirectDrawSurface_GetOverlayPosition(p,a,b) ICOM_CALL_(GetOverlayPosition,p,(p,a,b))
-#define IDirectDrawSurface_GetPalette(p,a) ICOM_CALL_(GetPalette,p,(p,a))
-#define IDirectDrawSurface_GetPixelFormat(p,a) ICOM_CALL_(GetPixelFormat,p,(p,a))
-#define IDirectDrawSurface_GetSurfaceDesc(p,a) ICOM_CALL_(GetSurfaceDesc,p,(p,a))
-#define IDirectDrawSurface_Initialize(p,a,b) ICOM_CALL_(Initialize,p,(p,a,b))
-#define IDirectDrawSurface_IsLost(p) ICOM_CALL_(IsLost,p,(p))
-#define IDirectDrawSurface_Lock(p,a,b,c,d) ICOM_CALL_(Lock,p,(p,a,b,c,d))
-#define IDirectDrawSurface_ReleaseDC(p,a) ICOM_CALL_(ReleaseDC,p,(p,a))
-#define IDirectDrawSurface_Restore(p) ICOM_CALL_(Restore,p,(p))
-#define IDirectDrawSurface_SetClipper(p,a) ICOM_CALL_(SetClipper,p,(p,a))
-#define IDirectDrawSurface_SetColorKey(p,a,b) ICOM_CALL_(SetColorKey,p,(p,a,b))
-#define IDirectDrawSurface_SetOverlayPosition(p,a,b) ICOM_CALL_(SetOverlayPosition,p,(p,a,b))
-#define IDirectDrawSurface_SetPalette(p,a) ICOM_CALL_(SetPalette,p,(p,a))
-#define IDirectDrawSurface_Unlock(p,a) ICOM_CALL_(Unlock,p,(p,a))
-#define IDirectDrawSurface_UpdateOverlay(p,a,b,c,d,e) ICOM_CALL_(UpdateOverlay,p,(p,a,b,c,d,e))
-#define IDirectDrawSurface_UpdateOverlayDisplay(p,a) ICOM_CALL_(UpdateOverlayDisplay,p,(p,a))
-#define IDirectDrawSurface_UpdateOverlayZOrder(p,a,b) ICOM_CALL_(UpdateOverlayZOrder,p,(p,a,b))
-
-
-/*****************************************************************************
- * IDirectDrawSurface2 interface
- */
-/* Cannot inherit from IDirectDrawSurface because the LPDIRECTDRAWSURFACE parameters
- * have been converted to LPDIRECTDRAWSURFACE2.
- */
-#undef INTERFACE
-#define INTERFACE IDirectDrawSurface2
-DECLARE_INTERFACE_(IDirectDrawSurface2,IUnknown)
-{
- STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
- STDMETHOD_(ULONG,AddRef)(THIS) PURE;
- STDMETHOD_(ULONG,Release)(THIS) PURE;
- STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE2 lpDDSAttachedSurface) PURE;
- STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT lpRect) PURE;
- STDMETHOD(Blt)(THIS_ LPRECT lpDestRect, LPDIRECTDRAWSURFACE2 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx) PURE;
- STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags) PURE;
- STDMETHOD(BltFast)(THIS_ DWORD dwX, DWORD dwY, LPDIRECTDRAWSURFACE2 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwTrans) PURE;
- STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD dwFlags, LPDIRECTDRAWSURFACE2 lpDDSAttachedSurface) PURE;
- STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback) PURE;
- STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD dwFlags, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpfnCallback) PURE;
- STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE2 lpDDSurfaceTargetOverride, DWORD dwFlags) PURE;
- STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS lpDDSCaps, LPDIRECTDRAWSURFACE2* lplpDDAttachedSurface) PURE;
- STDMETHOD(GetBltStatus)(THIS_ DWORD dwFlags) PURE;
- STDMETHOD(GetCaps)(THIS_ LPDDSCAPS lpDDSCaps) PURE;
- STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER* lplpDDClipper) PURE;
- STDMETHOD(GetColorKey)(THIS_ DWORD dwFlags, LPDDCOLORKEY lpDDColorKey) PURE;
- STDMETHOD(GetDC)(THIS_ HDC* lphDC) PURE;
- STDMETHOD(GetFlipStatus)(THIS_ DWORD dwFlags) PURE;
- STDMETHOD(GetOverlayPosition)(THIS_ LPLONG lplX, LPLONG lplY) PURE;
- STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE* lplpDDPalette) PURE;
- STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT lpDDPixelFormat) PURE;
- STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC lpDDSurfaceDesc) PURE;
- STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW lpDD, LPDDSURFACEDESC lpDDSurfaceDesc) PURE;
- STDMETHOD(IsLost)(THIS) PURE;
- STDMETHOD(Lock)(THIS_ LPRECT lpDestRect, LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent) PURE;
- STDMETHOD(ReleaseDC)(THIS_ HDC hDC) PURE;
- STDMETHOD(Restore)(THIS) PURE;
- STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER lpDDClipper) PURE;
- STDMETHOD(SetColorKey)(THIS_ DWORD dwFlags, LPDDCOLORKEY lpDDColorKey) PURE;
- STDMETHOD(SetOverlayPosition)(THIS_ LONG lX, LONG lY) PURE;
- STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE lpDDPalette) PURE;
- STDMETHOD(Unlock)(THIS_ LPVOID lpSurfaceData) PURE;
- STDMETHOD(UpdateOverlay)(THIS_ LPRECT lpSrcRect, LPDIRECTDRAWSURFACE2 lpDDDestSurface, LPRECT lpDestRect, DWORD dwFlags, LPDDOVERLAYFX lpDDOverlayFx) PURE;
- STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD dwFlags) PURE;
- STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD dwFlags, LPDIRECTDRAWSURFACE2 lpDDSReference) PURE;
- /* added in v2 */
- STDMETHOD(GetDDInterface)(THIS_ LPVOID* lplpDD) PURE;
- STDMETHOD(PageLock)(THIS_ DWORD dwFlags) PURE;
- STDMETHOD(PageUnlock)(THIS_ DWORD dwFlags) PURE;
-};
-
- /*** IUnknown methods ***/
-#define IDirectDrawSurface2_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
-#define IDirectDrawSurface2_AddRef(p) ICOM_CALL_(AddRef,p,(p))
-#define IDirectDrawSurface2_Release(p) ICOM_CALL_(Release,p,(p))
-/*** IDirectDrawSurface methods (almost) ***/
-#define IDirectDrawSurface2_AddAttachedSurface(p,a) ICOM_CALL_(AddAttachedSurface,p,(p,a))
-#define IDirectDrawSurface2_AddOverlayDirtyRect(p,a) ICOM_CALL_(AddOverlayDirtyRect,p,(p,a))
-#define IDirectDrawSurface2_Blt(p,a,b,c,d,e) ICOM_CALL_(Blt,p,(p,a,b,c,d,e))
-#define IDirectDrawSurface2_BltBatch(p,a,b,c) ICOM_CALL_(BltBatch,p,(p,a,b,c))
-#define IDirectDrawSurface2_BltFast(p,a,b,c,d,e) ICOM_CALL_(BltFast,p,(p,a,b,c,d,e))
-#define IDirectDrawSurface2_DeleteAttachedSurface(p,a,b) ICOM_CALL_(DeleteAttachedSurface,p,(p,a,b))
-#define IDirectDrawSurface2_EnumAttachedSurfaces(p,a,b) ICOM_CALL_(EnumAttachedSurfaces,p,(p,a,b))
-#define IDirectDrawSurface2_EnumOverlayZOrders(p,a,b,c) ICOM_CALL_(EnumOverlayZOrders,p,(p,a,b,c))
-#define IDirectDrawSurface2_Flip(p,a,b) ICOM_CALL_(Flip,p,(p,a,b))
-#define IDirectDrawSurface2_GetAttachedSurface(p,a,b) ICOM_CALL_(GetAttachedSurface,p,(p,a,b))
-#define IDirectDrawSurface2_GetBltStatus(p,a) ICOM_CALL_(GetBltStatus,p,(p,a))
-#define IDirectDrawSurface2_GetCaps(p,a) ICOM_CALL_(GetCaps,p,(p,a))
-#define IDirectDrawSurface2_GetClipper(p,a) ICOM_CALL_(GetClipper,p,(p,a))
-#define IDirectDrawSurface2_GetColorKey(p,a,b) ICOM_CALL_(GetColorKey,p,(p,a,b))
-#define IDirectDrawSurface2_GetDC(p,a) ICOM_CALL_(GetDC,p,(p,a))
-#define IDirectDrawSurface2_GetFlipStatus(p,a) ICOM_CALL_(GetFlipStatus,p,(p,a))
-#define IDirectDrawSurface2_GetOverlayPosition(p,a,b) ICOM_CALL_(GetOverlayPosition,p,(p,a,b))
-#define IDirectDrawSurface2_GetPalette(p,a) ICOM_CALL_(GetPalette,p,(p,a))
-#define IDirectDrawSurface2_GetPixelFormat(p,a) ICOM_CALL_(GetPixelFormat,p,(p,a))
-#define IDirectDrawSurface2_GetSurfaceDesc(p,a) ICOM_CALL_(GetSurfaceDesc,p,(p,a))
-#define IDirectDrawSurface2_Initialize(p,a,b) ICOM_CALL_(Initialize,p,(p,a,b))
-#define IDirectDrawSurface2_IsLost(p) ICOM_CALL_(IsLost,p,(p))
-#define IDirectDrawSurface2_Lock(p,a,b,c,d) ICOM_CALL_(Lock,p,(p,a,b,c,d))
-#define IDirectDrawSurface2_ReleaseDC(p,a) ICOM_CALL_(ReleaseDC,p,(p,a))
-#define IDirectDrawSurface2_Restore(p) ICOM_CALL_(Restore,p,(p))
-#define IDirectDrawSurface2_SetClipper(p,a) ICOM_CALL_(SetClipper,p,(p,a))
-#define IDirectDrawSurface2_SetColorKey(p,a,b) ICOM_CALL_(SetColorKey,p,(p,a,b))
-#define IDirectDrawSurface2_SetOverlayPosition(p,a,b) ICOM_CALL_(SetOverlayPosition,p,(p,a,b))
-#define IDirectDrawSurface2_SetPalette(p,a) ICOM_CALL_(SetPalette,p,(p,a))
-#define IDirectDrawSurface2_Unlock(p,a) ICOM_CALL_(Unlock,p,(p,a))
-#define IDirectDrawSurface2_UpdateOverlay(p,a,b,c,d,e) ICOM_CALL_(UpdateOverlay,p,(p,a,b,c,d,e))
-#define IDirectDrawSurface2_UpdateOverlayDisplay(p,a) ICOM_CALL_(UpdateOverlayDisplay,p,(p,a))
-#define IDirectDrawSurface2_UpdateOverlayZOrder(p,a,b) ICOM_CALL_(UpdateOverlayZOrder,p,(p,a,b))
-/*** IDirectDrawSurface2 methods ***/
-#define IDirectDrawSurface2_GetDDInterface(p,a) ICOM_CALL_(GetDDInterface,p,(p,a))
-#define IDirectDrawSurface2_PageLock(p,a) ICOM_CALL_(PageLock,p,(p,a))
-#define IDirectDrawSurface2_PageUnlock(p,a) ICOM_CALL_(PageUnlock,p,(p,a))
-
-
-/*****************************************************************************
- * IDirectDrawSurface3 interface
- */
-/* Cannot inherit from IDirectDrawSurface2 because the LPDIRECTDRAWSURFACE2 parameters
- * have been converted to LPDIRECTDRAWSURFACE3.
- */
-#undef INTERFACE
-#define INTERFACE IDirectDrawSurface3
-DECLARE_INTERFACE_(IDirectDrawSurface3,IUnknown)
-{
- STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
- STDMETHOD_(ULONG,AddRef)(THIS) PURE;
- STDMETHOD_(ULONG,Release)(THIS) PURE;
- STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE3 lpDDSAttachedSurface) PURE;
- STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT lpRect) PURE;
- STDMETHOD(Blt)(THIS_ LPRECT lpDestRect, LPDIRECTDRAWSURFACE3 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx) PURE;
- STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags) PURE;
- STDMETHOD(BltFast)(THIS_ DWORD dwX, DWORD dwY, LPDIRECTDRAWSURFACE3 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwTrans) PURE;
- STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD dwFlags, LPDIRECTDRAWSURFACE3 lpDDSAttachedSurface) PURE;
- STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback) PURE;
- STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD dwFlags, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpfnCallback) PURE;
- STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE3 lpDDSurfaceTargetOverride, DWORD dwFlags) PURE;
- STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS lpDDSCaps, LPDIRECTDRAWSURFACE3* lplpDDAttachedSurface) PURE;
- STDMETHOD(GetBltStatus)(THIS_ DWORD dwFlags) PURE;
- STDMETHOD(GetCaps)(THIS_ LPDDSCAPS lpDDSCaps) PURE;
- STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER* lplpDDClipper) PURE;
- STDMETHOD(GetColorKey)(THIS_ DWORD dwFlags, LPDDCOLORKEY lpDDColorKey) PURE;
- STDMETHOD(GetDC)(THIS_ HDC* lphDC) PURE;
- STDMETHOD(GetFlipStatus)(THIS_ DWORD dwFlags) PURE;
- STDMETHOD(GetOverlayPosition)(THIS_ LPLONG lplX, LPLONG lplY) PURE;
- STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE* lplpDDPalette) PURE;
- STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT lpDDPixelFormat) PURE;
- STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC lpDDSurfaceDesc) PURE;
- STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW lpDD, LPDDSURFACEDESC lpDDSurfaceDesc) PURE;
- STDMETHOD(IsLost)(THIS) PURE;
- STDMETHOD(Lock)(THIS_ LPRECT lpDestRect, LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent) PURE;
- STDMETHOD(ReleaseDC)(THIS_ HDC hDC) PURE;
- STDMETHOD(Restore)(THIS) PURE;
- STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER lpDDClipper) PURE;
- STDMETHOD(SetColorKey)(THIS_ DWORD dwFlags, LPDDCOLORKEY lpDDColorKey) PURE;
- STDMETHOD(SetOverlayPosition)(THIS_ LONG lX, LONG lY) PURE;
- STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE lpDDPalette) PURE;
- STDMETHOD(Unlock)(THIS_ LPVOID lpSurfaceData) PURE;
- STDMETHOD(UpdateOverlay)(THIS_ LPRECT lpSrcRect, LPDIRECTDRAWSURFACE3 lpDDDestSurface, LPRECT lpDestRect, DWORD dwFlags, LPDDOVERLAYFX lpDDOverlayFx) PURE;
- STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD dwFlags) PURE;
- STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD dwFlags, LPDIRECTDRAWSURFACE3 lpDDSReference) PURE;
- /* added in v2 */
- STDMETHOD(GetDDInterface)(THIS_ LPVOID* lplpDD) PURE;
- STDMETHOD(PageLock)(THIS_ DWORD dwFlags) PURE;
- STDMETHOD(PageUnlock)(THIS_ DWORD dwFlags) PURE;
- /* added in v3 */
- STDMETHOD(SetSurfaceDesc)(THIS_ LPDDSURFACEDESC lpDDSD, DWORD dwFlags) PURE;
-};
-
- /*** IUnknown methods ***/
-#define IDirectDrawSurface3_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
-#define IDirectDrawSurface3_AddRef(p) ICOM_CALL_(AddRef,p,(p))
-#define IDirectDrawSurface3_Release(p) ICOM_CALL_(Release,p,(p))
-/*** IDirectDrawSurface methods (almost) ***/
-#define IDirectDrawSurface3_AddAttachedSurface(p,a) ICOM_CALL_(AddAttachedSurface,p,(p,a))
-#define IDirectDrawSurface3_AddOverlayDirtyRect(p,a) ICOM_CALL_(AddOverlayDirtyRect,p,(p,a))
-#define IDirectDrawSurface3_Blt(p,a,b,c,d,e) ICOM_CALL_(Blt,p,(p,a,b,c,d,e))
-#define IDirectDrawSurface3_BltBatch(p,a,b,c) ICOM_CALL_(BltBatch,p,(p,a,b,c))
-#define IDirectDrawSurface3_BltFast(p,a,b,c,d,e) ICOM_CALL_(BltFast,p,(p,a,b,c,d,e))
-#define IDirectDrawSurface3_DeleteAttachedSurface(p,a,b) ICOM_CALL_(DeleteAttachedSurface,p,(p,a,b))
-#define IDirectDrawSurface3_EnumAttachedSurfaces(p,a,b) ICOM_CALL_(EnumAttachedSurfaces,p,(p,a,b))
-#define IDirectDrawSurface3_EnumOverlayZOrders(p,a,b,c) ICOM_CALL_(EnumOverlayZOrders,p,(p,a,b,c))
-#define IDirectDrawSurface3_Flip(p,a,b) ICOM_CALL_(Flip,p,(p,a,b))
-#define IDirectDrawSurface3_GetAttachedSurface(p,a,b) ICOM_CALL_(GetAttachedSurface,p,(p,a,b))
-#define IDirectDrawSurface3_GetBltStatus(p,a) ICOM_CALL_(GetBltStatus,p,(p,a))
-#define IDirectDrawSurface3_GetCaps(p,a) ICOM_CALL_(GetCaps,p,(p,a))
-#define IDirectDrawSurface3_GetClipper(p,a) ICOM_CALL_(GetClipper,p,(p,a))
-#define IDirectDrawSurface3_GetColorKey(p,a,b) ICOM_CALL_(GetColorKey,p,(p,a,b))
-#define IDirectDrawSurface3_GetDC(p,a) ICOM_CALL_(GetDC,p,(p,a))
-#define IDirectDrawSurface3_GetFlipStatus(p,a) ICOM_CALL_(GetFlipStatus,p,(p,a))
-#define IDirectDrawSurface3_GetOverlayPosition(p,a,b) ICOM_CALL_(GetOverlayPosition,p,(p,a,b))
-#define IDirectDrawSurface3_GetPalette(p,a) ICOM_CALL_(GetPalette,p,(p,a))
-#define IDirectDrawSurface3_GetPixelFormat(p,a) ICOM_CALL_(GetPixelFormat,p,(p,a))
-#define IDirectDrawSurface3_GetSurfaceDesc(p,a) ICOM_CALL_(GetSurfaceDesc,p,(p,a))
-#define IDirectDrawSurface3_Initialize(p,a,b) ICOM_CALL_(Initialize,p,(p,a,b))
-#define IDirectDrawSurface3_IsLost(p) ICOM_CALL_(IsLost,p,(p))
-#define IDirectDrawSurface3_Lock(p,a,b,c,d) ICOM_CALL_(Lock,p,(p,a,b,c,d))
-#define IDirectDrawSurface3_ReleaseDC(p,a) ICOM_CALL_(ReleaseDC,p,(p,a))
-#define IDirectDrawSurface3_Restore(p) ICOM_CALL_(Restore,p,(p))
-#define IDirectDrawSurface3_SetClipper(p,a) ICOM_CALL_(SetClipper,p,(p,a))
-#define IDirectDrawSurface3_SetColorKey(p,a,b) ICOM_CALL_(SetColorKey,p,(p,a,b))
-#define IDirectDrawSurface3_SetOverlayPosition(p,a,b) ICOM_CALL_(SetOverlayPosition,p,(p,a,b))
-#define IDirectDrawSurface3_SetPalette(p,a) ICOM_CALL_(SetPalette,p,(p,a))
-#define IDirectDrawSurface3_Unlock(p,a) ICOM_CALL_(Unlock,p,(p,a))
-#define IDirectDrawSurface3_UpdateOverlay(p,a,b,c,d,e) ICOM_CALL_(UpdateOverlay,p,(p,a,b,c,d,e))
-#define IDirectDrawSurface3_UpdateOverlayDisplay(p,a) ICOM_CALL_(UpdateOverlayDisplay,p,(p,a))
-#define IDirectDrawSurface3_UpdateOverlayZOrder(p,a,b) ICOM_CALL_(UpdateOverlayZOrder,p,(p,a,b))
-/*** IDirectDrawSurface2 methods ***/
-#define IDirectDrawSurface3_GetDDInterface(p,a) ICOM_CALL_(GetDDInterface,p,(p,a))
-#define IDirectDrawSurface3_PageLock(p,a) ICOM_CALL_(PageLock,p,(p,a))
-#define IDirectDrawSurface3_PageUnlock(p,a) ICOM_CALL_(PageUnlock,p,(p,a))
-/*** IDirectDrawSurface3 methods ***/
-#define IDirectDrawSurface3_SetSurfaceDesc(p,a,b) ICOM_CALL_(SetSurfaceDesc,p,(p,a,b))
-
-
-/*****************************************************************************
- * IDirectDrawSurface4 interface
- */
-/* Cannot inherit from IDirectDrawSurface2 because DDSCAPS changed to DDSCAPS2.
- */
-#undef INTERFACE
-#define INTERFACE IDirectDrawSurface4
-DECLARE_INTERFACE_(IDirectDrawSurface4,IUnknown)
-{
- STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
- STDMETHOD_(ULONG,AddRef)(THIS) PURE;
- STDMETHOD_(ULONG,Release)(THIS) PURE;
- STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE4 lpDDSAttachedSurface) PURE;
- STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT lpRect) PURE;
- STDMETHOD(Blt)(THIS_ LPRECT lpDestRect, LPDIRECTDRAWSURFACE4 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx) PURE;
- STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags) PURE;
- STDMETHOD(BltFast)(THIS_ DWORD dwX, DWORD dwY, LPDIRECTDRAWSURFACE4 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwTrans) PURE;
- STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD dwFlags, LPDIRECTDRAWSURFACE4 lpDDSAttachedSurface) PURE;
- STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback) PURE;
- STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD dwFlags, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpfnCallback) PURE;
- STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE4 lpDDSurfaceTargetOverride, DWORD dwFlags) PURE;
- STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS2 lpDDSCaps, LPDIRECTDRAWSURFACE4* lplpDDAttachedSurface) PURE;
- STDMETHOD(GetBltStatus)(THIS_ DWORD dwFlags) PURE;
- STDMETHOD(GetCaps)(THIS_ LPDDSCAPS2 lpDDSCaps) PURE;
- STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER* lplpDDClipper) PURE;
- STDMETHOD(GetColorKey)(THIS_ DWORD dwFlags, LPDDCOLORKEY lpDDColorKey) PURE;
- STDMETHOD(GetDC)(THIS_ HDC* lphDC) PURE;
- STDMETHOD(GetFlipStatus)(THIS_ DWORD dwFlags) PURE;
- STDMETHOD(GetOverlayPosition)(THIS_ LPLONG lplX, LPLONG lplY) PURE;
- STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE* lplpDDPalette) PURE;
- STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT lpDDPixelFormat) PURE;
- STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC lpDDSurfaceDesc) PURE;
- STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW lpDD, LPDDSURFACEDESC lpDDSurfaceDesc) PURE;
- STDMETHOD(IsLost)(THIS) PURE;
- STDMETHOD(Lock)(THIS_ LPRECT lpDestRect, LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent) PURE;
- STDMETHOD(ReleaseDC)(THIS_ HDC hDC) PURE;
- STDMETHOD(Restore)(THIS) PURE;
- STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER lpDDClipper) PURE;
- STDMETHOD(SetColorKey)(THIS_ DWORD dwFlags, LPDDCOLORKEY lpDDColorKey) PURE;
- STDMETHOD(SetOverlayPosition)(THIS_ LONG lX, LONG lY) PURE;
- STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE lpDDPalette) PURE;
- STDMETHOD(Unlock)(THIS_ LPRECT lpSurfaceData) PURE;
- STDMETHOD(UpdateOverlay)(THIS_ LPRECT lpSrcRect, LPDIRECTDRAWSURFACE4 lpDDDestSurface, LPRECT lpDestRect, DWORD dwFlags, LPDDOVERLAYFX lpDDOverlayFx) PURE;
- STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD dwFlags) PURE;
- STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD dwFlags, LPDIRECTDRAWSURFACE4 lpDDSReference) PURE;
- /* added in v2 */
- STDMETHOD(GetDDInterface)(THIS_ LPVOID* lplpDD) PURE;
- STDMETHOD(PageLock)(THIS_ DWORD dwFlags) PURE;
- STDMETHOD(PageUnlock)(THIS_ DWORD dwFlags) PURE;
- /* added in v3 */
- STDMETHOD(SetSurfaceDesc)(THIS_ LPDDSURFACEDESC lpDDSD, DWORD dwFlags) PURE;
- /* added in v4 */
- STDMETHOD(SetPrivateData)(THIS_ REFGUID , LPVOID , DWORD , DWORD ) PURE;
- STDMETHOD(GetPrivateData)(THIS_ REFGUID , LPVOID , LPDWORD ) PURE;
- STDMETHOD(FreePrivateData)(THIS_ REFGUID ) PURE;
- STDMETHOD(GetUniquenessValue)(THIS_ LPDWORD ) PURE;
- STDMETHOD(ChangeUniquenessValue)(THIS) PURE;
-};
-
- /*** IUnknown methods ***/
-#define IDirectDrawSurface4_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
-#define IDirectDrawSurface4_AddRef(p) ICOM_CALL_(AddRef,p,(p))
-#define IDirectDrawSurface4_Release(p) ICOM_CALL_(Release,p,(p))
-/*** IDirectDrawSurface (almost) methods ***/
-#define IDirectDrawSurface4_AddAttachedSurface(p,a) ICOM_CALL_(AddAttachedSurface,p,(p,a))
-#define IDirectDrawSurface4_AddOverlayDirtyRect(p,a) ICOM_CALL_(AddOverlayDirtyRect,p,(p,a))
-#define IDirectDrawSurface4_Blt(p,a,b,c,d,e) ICOM_CALL_(Blt,p,(p,a,b,c,d,e))
-#define IDirectDrawSurface4_BltBatch(p,a,b,c) ICOM_CALL_(BltBatch,p,(p,a,b,c))
-#define IDirectDrawSurface4_BltFast(p,a,b,c,d,e) ICOM_CALL_(BltFast,p,(p,a,b,c,d,e))
-#define IDirectDrawSurface4_DeleteAttachedSurface(p,a,b) ICOM_CALL_(DeleteAttachedSurface,p,(p,a,b))
-#define IDirectDrawSurface4_EnumAttachedSurfaces(p,a,b) ICOM_CALL_(EnumAttachedSurfaces,p,(p,a,b))
-#define IDirectDrawSurface4_EnumOverlayZOrders(p,a,b,c) ICOM_CALL_(EnumOverlayZOrders,p,(p,a,b,c))
-#define IDirectDrawSurface4_Flip(p,a,b) ICOM_CALL_(Flip,p,(p,a,b))
-#define IDirectDrawSurface4_GetAttachedSurface(p,a,b) ICOM_CALL_(GetAttachedSurface,p,(p,a,b))
-#define IDirectDrawSurface4_GetBltStatus(p,a) ICOM_CALL_(GetBltStatus,p,(p,a))
-#define IDirectDrawSurface4_GetCaps(p,a) ICOM_CALL_(GetCaps,p,(p,a))
-#define IDirectDrawSurface4_GetClipper(p,a) ICOM_CALL_(GetClipper,p,(p,a))
-#define IDirectDrawSurface4_GetColorKey(p,a,b) ICOM_CALL_(GetColorKey,p,(p,a,b))
-#define IDirectDrawSurface4_GetDC(p,a) ICOM_CALL_(GetDC,p,(p,a))
-#define IDirectDrawSurface4_GetFlipStatus(p,a) ICOM_CALL_(GetFlipStatus,p,(p,a))
-#define IDirectDrawSurface4_GetOverlayPosition(p,a,b) ICOM_CALL_(GetOverlayPosition,p,(p,a,b))
-#define IDirectDrawSurface4_GetPalette(p,a) ICOM_CALL_(GetPalette,p,(p,a))
-#define IDirectDrawSurface4_GetPixelFormat(p,a) ICOM_CALL_(GetPixelFormat,p,(p,a))
-#define IDirectDrawSurface4_GetSurfaceDesc(p,a) ICOM_CALL_(GetSurfaceDesc,p,(p,a))
-#define IDirectDrawSurface4_Initialize(p,a,b) ICOM_CALL_(Initialize,p,(p,a,b))
-#define IDirectDrawSurface4_IsLost(p) ICOM_CALL_(IsLost,p,(p))
-#define IDirectDrawSurface4_Lock(p,a,b,c,d) ICOM_CALL_(Lock,p,(p,a,b,c,d))
-#define IDirectDrawSurface4_ReleaseDC(p,a) ICOM_CALL_(ReleaseDC,p,(p,a))
-#define IDirectDrawSurface4_Restore(p) ICOM_CALL_(Restore,p,(p))
-#define IDirectDrawSurface4_SetClipper(p,a) ICOM_CALL_(SetClipper,p,(p,a))
-#define IDirectDrawSurface4_SetColorKey(p,a,b) ICOM_CALL_(SetColorKey,p,(p,a,b))
-#define IDirectDrawSurface4_SetOverlayPosition(p,a,b) ICOM_CALL_(SetOverlayPosition,p,(p,a,b))
-#define IDirectDrawSurface4_SetPalette(p,a) ICOM_CALL_(SetPalette,p,(p,a))
-#define IDirectDrawSurface4_Unlock(p,a) ICOM_CALL_(Unlock,p,(p,a))
-#define IDirectDrawSurface4_UpdateOverlay(p,a,b,c,d,e) ICOM_CALL_(UpdateOverlay,p,(p,a,b,c,d,e))
-#define IDirectDrawSurface4_UpdateOverlayDisplay(p,a) ICOM_CALL_(UpdateOverlayDisplay,p,(p,a))
-#define IDirectDrawSurface4_UpdateOverlayZOrder(p,a,b) ICOM_CALL_(UpdateOverlayZOrder,p,(p,a,b))
-/*** IDirectDrawSurface2 methods ***/
-#define IDirectDrawSurface4_GetDDInterface(p,a) ICOM_CALL_(GetDDInterface,p,(p,a))
-#define IDirectDrawSurface4_PageLock(p,a) ICOM_CALL_(PageLock,p,(p,a))
-#define IDirectDrawSurface4_PageUnlock(p,a) ICOM_CALL_(PageUnlock,p,(p,a))
-/*** IDirectDrawSurface3 methods ***/
-#define IDirectDrawSurface4_SetSurfaceDesc(p,a,b) ICOM_CALL_(SetSurfaceDesc,p,(p,a,b))
-/*** IDirectDrawSurface4 methods ***/
-#define IDirectDrawSurface4_SetPrivateData(p,a,b,c,d) ICOM_CALL_(SetPrivateData,p,(p,a,b,c,d))
-#define IDirectDrawSurface4_GetPrivateData(p,a,b,c) ICOM_CALL_(GetPrivateData,p,(p,a,b,c))
-#define IDirectDrawSurface4_FreePrivateData(p,a) ICOM_CALL_(FreePrivateData,p,(p,a))
-#define IDirectDrawSurface4_GetUniquenessValue(p,a) ICOM_CALL_(GetUniquenessValue,p,(p,a))
-#define IDirectDrawSurface4_ChangeUniquenessValue(p) ICOM_CALL_(ChangeUniquenessValue,p,(p))
-
-
-/*****************************************************************************
- * IDirectDrawSurface7 interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectDrawSurface7
-DECLARE_INTERFACE_(IDirectDrawSurface7,IUnknown)
-{
- STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
- STDMETHOD_(ULONG,AddRef)(THIS) PURE;
- STDMETHOD_(ULONG,Release)(THIS) PURE;
- STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE7 lpDDSAttachedSurface) PURE;
- STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT lpRect) PURE;
- STDMETHOD(Blt)(THIS_ LPRECT lpDestRect, LPDIRECTDRAWSURFACE7 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx) PURE;
- STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags) PURE;
- STDMETHOD(BltFast)(THIS_ DWORD dwX, DWORD dwY, LPDIRECTDRAWSURFACE7 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwTrans) PURE;
- STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD dwFlags, LPDIRECTDRAWSURFACE7 lpDDSAttachedSurface) PURE;
- STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID lpContext, LPDDENUMSURFACESCALLBACK7 lpEnumSurfacesCallback) PURE;
- STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD dwFlags, LPVOID lpContext, LPDDENUMSURFACESCALLBACK7 lpfnCallback) PURE;
- STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE7 lpDDSurfaceTargetOverride, DWORD dwFlags) PURE;
- STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS2 lpDDSCaps, LPDIRECTDRAWSURFACE7* lplpDDAttachedSurface) PURE;
- STDMETHOD(GetBltStatus)(THIS_ DWORD dwFlags) PURE;
- STDMETHOD(GetCaps)(THIS_ LPDDSCAPS2 lpDDSCaps) PURE;
- STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER* lplpDDClipper) PURE;
- STDMETHOD(GetColorKey)(THIS_ DWORD dwFlags, LPDDCOLORKEY lpDDColorKey) PURE;
- STDMETHOD(GetDC)(THIS_ HDC* lphDC) PURE;
- STDMETHOD(GetFlipStatus)(THIS_ DWORD dwFlags) PURE;
- STDMETHOD(GetOverlayPosition)(THIS_ LPLONG lplX, LPLONG lplY) PURE;
- STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE* lplpDDPalette) PURE;
- STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT lpDDPixelFormat) PURE;
- STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC2 lpDDSurfaceDesc) PURE;
- STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW lpDD, LPDDSURFACEDESC2 lpDDSurfaceDesc) PURE;
- STDMETHOD(IsLost)(THIS) PURE;
- STDMETHOD(Lock)(THIS_ LPRECT lpDestRect, LPDDSURFACEDESC2 lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent) PURE;
- STDMETHOD(ReleaseDC)(THIS_ HDC hDC) PURE;
- STDMETHOD(Restore)(THIS) PURE;
- STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER lpDDClipper) PURE;
- STDMETHOD(SetColorKey)(THIS_ DWORD dwFlags, LPDDCOLORKEY lpDDColorKey) PURE;
- STDMETHOD(SetOverlayPosition)(THIS_ LONG lX, LONG lY) PURE;
- STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE lpDDPalette) PURE;
- STDMETHOD(Unlock)(THIS_ LPRECT lpSurfaceData) PURE;
- STDMETHOD(UpdateOverlay)(THIS_ LPRECT lpSrcRect, LPDIRECTDRAWSURFACE7 lpDDDestSurface, LPRECT lpDestRect, DWORD dwFlags, LPDDOVERLAYFX lpDDOverlayFx) PURE;
- STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD dwFlags) PURE;
- STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD dwFlags, LPDIRECTDRAWSURFACE7 lpDDSReference) PURE;
- /* added in v2 */
- STDMETHOD(GetDDInterface)(THIS_ LPVOID* lplpDD) PURE;
- STDMETHOD(PageLock)(THIS_ DWORD dwFlags) PURE;
- STDMETHOD(PageUnlock)(THIS_ DWORD dwFlags) PURE;
- /* added in v3 */
- STDMETHOD(SetSurfaceDesc)(THIS_ LPDDSURFACEDESC2 lpDDSD, DWORD dwFlags) PURE;
- /* added in v4 */
- STDMETHOD(SetPrivateData)(THIS_ REFGUID , LPVOID , DWORD , DWORD ) PURE;
- STDMETHOD(GetPrivateData)(THIS_ REFGUID , LPVOID , LPDWORD ) PURE;
- STDMETHOD(FreePrivateData)(THIS_ REFGUID ) PURE;
- STDMETHOD(GetUniquenessValue)(THIS_ LPDWORD ) PURE;
- STDMETHOD(ChangeUniquenessValue)(THIS) PURE;
- /* added in v7 */
- STDMETHOD(SetPriority)(THIS_ DWORD prio) PURE;
- STDMETHOD(GetPriority)(THIS_ LPDWORD prio) PURE;
- STDMETHOD(SetLOD)(THIS_ DWORD lod) PURE;
- STDMETHOD(GetLOD)(THIS_ LPDWORD lod) PURE;
-};
-
- /*** IUnknown methods ***/
-#define IDirectDrawSurface7_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
-#define IDirectDrawSurface7_AddRef(p) ICOM_CALL_(AddRef,p,(p))
-#define IDirectDrawSurface7_Release(p) ICOM_CALL_(Release,p,(p))
-/*** IDirectDrawSurface (almost) methods ***/
-#define IDirectDrawSurface7_AddAttachedSurface(p,a) ICOM_CALL_(AddAttachedSurface,p,(p,a))
-#define IDirectDrawSurface7_AddOverlayDirtyRect(p,a) ICOM_CALL_(AddOverlayDirtyRect,p,(p,a))
-#define IDirectDrawSurface7_Blt(p,a,b,c,d,e) ICOM_CALL_(Blt,p,(p,a,b,c,d,e))
-#define IDirectDrawSurface7_BltBatch(p,a,b,c) ICOM_CALL_(BltBatch,p,(p,a,b,c))
-#define IDirectDrawSurface7_BltFast(p,a,b,c,d,e) ICOM_CALL_(BltFast,p,(p,a,b,c,d,e))
-#define IDirectDrawSurface7_DeleteAttachedSurface(p,a,b) ICOM_CALL_(DeleteAttachedSurface,p,(p,a,b))
-#define IDirectDrawSurface7_EnumAttachedSurfaces(p,a,b) ICOM_CALL_(EnumAttachedSurfaces,p,(p,a,b))
-#define IDirectDrawSurface7_EnumOverlayZOrders(p,a,b,c) ICOM_CALL_(EnumOverlayZOrders,p,(p,a,b,c))
-#define IDirectDrawSurface7_Flip(p,a,b) ICOM_CALL_(Flip,p,(p,a,b))
-#define IDirectDrawSurface7_GetAttachedSurface(p,a,b) ICOM_CALL_(GetAttachedSurface,p,(p,a,b))
-#define IDirectDrawSurface7_GetBltStatus(p,a) ICOM_CALL_(GetBltStatus,p,(p,a))
-#define IDirectDrawSurface7_GetCaps(p,a) ICOM_CALL_(GetCaps,p,(p,a))
-#define IDirectDrawSurface7_GetClipper(p,a) ICOM_CALL_(GetClipper,p,(p,a))
-#define IDirectDrawSurface7_GetColorKey(p,a,b) ICOM_CALL_(GetColorKey,p,(p,a,b))
-#define IDirectDrawSurface7_GetDC(p,a) ICOM_CALL_(GetDC,p,(p,a))
-#define IDirectDrawSurface7_GetFlipStatus(p,a) ICOM_CALL_(GetFlipStatus,p,(p,a))
-#define IDirectDrawSurface7_GetOverlayPosition(p,a,b) ICOM_CALL_(GetOverlayPosition,p,(p,a,b))
-#define IDirectDrawSurface7_GetPalette(p,a) ICOM_CALL_(GetPalette,p,(p,a))
-#define IDirectDrawSurface7_GetPixelFormat(p,a) ICOM_CALL_(GetPixelFormat,p,(p,a))
-#define IDirectDrawSurface7_GetSurfaceDesc(p,a) ICOM_CALL_(GetSurfaceDesc,p,(p,a))
-#define IDirectDrawSurface7_Initialize(p,a,b) ICOM_CALL_(Initialize,p,(p,a,b))
-#define IDirectDrawSurface7_IsLost(p) ICOM_CALL_(IsLost,p,(p))
-#define IDirectDrawSurface7_Lock(p,a,b,c,d) ICOM_CALL_(Lock,p,(p,a,b,c,d))
-#define IDirectDrawSurface7_ReleaseDC(p,a) ICOM_CALL_(ReleaseDC,p,(p,a))
-#define IDirectDrawSurface7_Restore(p) ICOM_CALL_(Restore,p,(p))
-#define IDirectDrawSurface7_SetClipper(p,a) ICOM_CALL_(SetClipper,p,(p,a))
-#define IDirectDrawSurface7_SetColorKey(p,a,b) ICOM_CALL_(SetColorKey,p,(p,a,b))
-#define IDirectDrawSurface7_SetOverlayPosition(p,a,b) ICOM_CALL_(SetOverlayPosition,p,(p,a,b))
-#define IDirectDrawSurface7_SetPalette(p,a) ICOM_CALL_(SetPalette,p,(p,a))
-#define IDirectDrawSurface7_Unlock(p,a) ICOM_CALL_(Unlock,p,(p,a))
-#define IDirectDrawSurface7_UpdateOverlay(p,a,b,c,d,e) ICOM_CALL_(UpdateOverlay,p,(p,a,b,c,d,e))
-#define IDirectDrawSurface7_UpdateOverlayDisplay(p,a) ICOM_CALL_(UpdateOverlayDisplay,p,(p,a))
-#define IDirectDrawSurface7_UpdateOverlayZOrder(p,a,b) ICOM_CALL_(UpdateOverlayZOrder,p,(p,a,b))
-/*** IDirectDrawSurface2 methods ***/
-#define IDirectDrawSurface7_GetDDInterface(p,a) ICOM_CALL_(GetDDInterface,p,(p,a))
-#define IDirectDrawSurface7_PageLock(p,a) ICOM_CALL_(PageLock,p,(p,a))
-#define IDirectDrawSurface7_PageUnlock(p,a) ICOM_CALL_(PageUnlock,p,(p,a))
-/*** IDirectDrawSurface3 methods ***/
-#define IDirectDrawSurface7_SetSurfaceDesc(p,a,b) ICOM_CALL_(SetSurfaceDesc,p,(p,a,b))
-/*** IDirectDrawSurface4 methods ***/
-#define IDirectDrawSurface7_SetPrivateData(p,a,b,c,d) ICOM_CALL_(SetPrivateData,p,(p,a,b,c,d))
-#define IDirectDrawSurface7_GetPrivateData(p,a,b,c) ICOM_CALL_(GetPrivateData,p,(p,a,b,c))
-#define IDirectDrawSurface7_FreePrivateData(p,a) ICOM_CALL_(FreePrivateData,p,(p,a))
-#define IDirectDrawSurface7_GetUniquenessValue(p,a) ICOM_CALL_(GetUniquenessValue,p,(p,a))
-#define IDirectDrawSurface7_ChangeUniquenessValue(p) ICOM_CALL_(ChangeUniquenessValue,p,(p))
-/*** IDirectDrawSurface7 methods ***/
-#define IDirectDrawSurface7_SetPriority(p,a) ICOM_CALL_(SetPriority,p,(p,a))
-#define IDirectDrawSurface7_GetPriority(p,a) ICOM_CALL_(GetPriority,p,(p,a))
-#define IDirectDrawSurface7_SetLOD(p,a) ICOM_CALL_(SetLOD,p,(p,a))
-#define IDirectDrawSurface7_GetLOD(p,a) ICOM_CALL_(GetLOD,p,(p,a))
-
-/*****************************************************************************
- * IDirectDrawColorControl interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectDrawColorControl
-DECLARE_INTERFACE_(IDirectDrawColorControl,IUnknown)
-{
- STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
- STDMETHOD_(ULONG,AddRef)(THIS) PURE;
- STDMETHOD_(ULONG,Release)(THIS) PURE;
- STDMETHOD(GetColorControls)(THIS_ LPDDCOLORCONTROL lpColorControl) PURE;
- STDMETHOD(SetColorControls)(THIS_ LPDDCOLORCONTROL lpColorControl) PURE;
-};
-
- /*** IUnknown methods ***/
-#define IDirectDrawColorControl_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
-#define IDirectDrawColorControl_AddRef(p) ICOM_CALL_(AddRef,p,(p))
-#define IDirectDrawColorControl_Release(p) ICOM_CALL_(Release,p,(p))
- /*** IDirectDrawColorControl methods ***/
-#define IDirectDrawColorControl_GetColorControls(p,a) ICOM_CALL_(GetColorControls,p,(p,a))
-#define IDirectDrawColorControl_SetColorControls(p,a) ICOM_CALL_(SetColorControls,p,(p,a))
-
-/*****************************************************************************
- * IDirectDrawGammaControl interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectDrawGammaControl
-DECLARE_INTERFACE_(IDirectDrawGammaControl,IUnknown)
-{
- STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
- STDMETHOD_(ULONG,AddRef)(THIS) PURE;
- STDMETHOD_(ULONG,Release)(THIS) PURE;
- STDMETHOD(GetGammaRamp)(THIS_ DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp) PURE;
- STDMETHOD(SetGammaRamp)(THIS_ DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp) PURE;
-};
-
- /*** IUnknown methods ***/
-#define IDirectDrawGammaControl_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
-#define IDirectDrawGammaControl_AddRef(p) ICOM_CALL_(AddRef,p,(p))
-#define IDirectDrawGammaControl_Release(p) ICOM_CALL_(Release,p,(p))
- /*** IDirectDrawGammaControl methods ***/
-#define IDirectDrawGammaControl_GetGammaRamp(p,a,b) ICOM_CALL_(GetGammaRamp,p,(p,a,b))
-#define IDirectDrawGammaControl_SetGammaRamp(p,a,b) ICOM_CALL_(SetGammaRamp,p,(p,a,b))
-
-
-HRESULT WINAPI DirectDrawCreate(LPGUID,LPDIRECTDRAW*,LPUNKNOWN);
-HRESULT WINAPI DirectDrawCreateEx(LPGUID,LPVOID*,REFIID,LPUNKNOWN);
-HRESULT WINAPI DirectDrawEnumerateA(LPDDENUMCALLBACKA,LPVOID);
-HRESULT WINAPI DirectDrawEnumerateW(LPDDENUMCALLBACKW,LPVOID);
-#define DirectDrawEnumerate WINELIB_NAME_AW(DirectDrawEnumerate)
-HRESULT WINAPI DirectDrawCreateClipper(DWORD,LPDIRECTDRAWCLIPPER*,LPUNKNOWN);
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif /* defined(__cplusplus) */
-
-#endif /* __XWIN_DDRAW_H */
diff --git a/xorg-server/hw/xwin/makefile b/xorg-server/hw/xwin/makefile
new file mode 100644
index 000000000..5cd338954
--- /dev/null
+++ b/xorg-server/hw/xwin/makefile
@@ -0,0 +1,112 @@
+LIBRARY = libXWin
+
+SRCS_CLIPBOARD = \
+ winclipboardinit.c \
+ winclipboardtextconv.c \
+ winclipboardthread.c \
+ winclipboardunicode.c \
+ winclipboardwndproc.c \
+ winclipboardwrappers.c \
+ winclipboardxevents.c
+
+DEFINES += XWIN_CLIPBOARD
+
+SRCS_MULTIWINDOW = \
+ winmultiwindowshape.c \
+ winmultiwindowwindow.c \
+ winmultiwindowwm.c \
+ winmultiwindowwndproc.c
+
+DEFINES += XWIN_MULTIWINDOW
+
+#SRCS_MULTIWINDOWEXTWM = \
+# winwin32rootless.c \
+# winwin32rootlesswindow.c \
+# winwin32rootlesswndproc.c \
+# winwindowswm.c
+#DEFINES += XWIN_MULTIWINDOWEXTWM
+
+SRCS_NATIVEGDI = \
+ winclip.c \
+ winfillsp.c \
+ winfont.c \
+ wingc.c \
+ wingetsp.c \
+ winnativegdi.c \
+ winpixmap.c \
+ winpolyline.c \
+ winrop.c \
+ winsetsp.c
+DEFINES += XWIN_NATIVEGDI
+
+
+SRCS_RANDR = \
+ winrandr.c
+DEFINES += XWIN_RANDR RELOCATE_PROJECTROOT
+
+CSRCS = InitInput.c \
+ InitOutput.c \
+ winallpriv.c \
+ winauth.c \
+ winblock.c \
+ wincmap.c \
+ winconfig.c \
+ wincreatewnd.c \
+ wincursor.c \
+ windialogs.c \
+ winengine.c \
+ winerror.c \
+ winglobals.c \
+ winkeybd.c \
+ winkeyhook.c \
+ winmisc.c \
+ winmouse.c \
+ winmsg.c \
+ winmultiwindowclass.c \
+ winmultiwindowicons.c \
+ winprefs.c \
+ winprocarg.c \
+ winregistry.c \
+ winscrinit.c \
+ winshaddd.c \
+ winshadddnl.c \
+ winshadgdi.c \
+ wintrayicon.c \
+ winvalargs.c \
+ winwakeup.c \
+ winwindow.c \
+ winprefslex.c \
+ winprefsyacc.c \
+ winwndproc.c \
+ $(SRCS_RANDR) \
+ $(SRCS_CLIPBOARD) \
+ $(SRCS_MULTIWINDOW) \
+ $(SRCS_MULTIWINDOWEXTWM) \
+ $(SRCS_NATIVEGDI)
+
+
+DEFINES += YY_NO_UNISTD_H
+
+# XWin.rc \
+# $(top_srcdir)/Xext/dpmsstubs.c \
+# $(top_srcdir)/Xi/stubs.c \
+# $(top_srcdir)/mi/miinitext.c \
+# $(top_srcdir)/fb/fbcmap_mi.c \
+# $(SRCS_PRIMARYFB) \
+# $(SRCS_XV)
+
+INCLUDES += ..\..\miext\rootless
+
+#.rc.o:
+
+# $(WINDRES) --use-temp-file -i $< --input-format=rc -o $@ -O coff -I $(top_builddir)/include -DPROJECT_NAME=\"$(VENDOR_NAME_SHORT)\" -DPROJECT_VERSION=\"$(PACKAGE_VERSION)\" -DBUILD_DATE=\"$(BUILD_DATE)\"
+
+DEFINES += HAVE_XWIN_CONFIG_H BUILD_DATE=0-0-0000 PTW32_STATIC_LIB
+
+#CSRCS=winkeybd.c
+
+winprefslex.c: winprefslex.l winprefsyacc.h
+ flex -i -o$@ $<
+
+winprefsyacc.c winprefsyacc.h: winprefsyacc.y
+ bison -d -owinprefsyacc.c $<
diff --git a/xorg-server/hw/xwin/win.h b/xorg-server/hw/xwin/win.h
index 9ab8ed976..48f7d65f5 100644
--- a/xorg-server/hw/xwin/win.h
+++ b/xorg-server/hw/xwin/win.h
@@ -1,1460 +1,1429 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, 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 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 XFREE86 PROJECT 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 XFree86 Project
- *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 XFree86 Project.
- *
- * Authors: Dakshinamurthy Karra
- * Suhaib M Siddiqi
- * Peter Busch
- * Harold L Hunt II
- * Kensuke Matsuzaki
- */
-
-#ifndef _WIN_H_
-#define _WIN_H_
-
-#ifndef NO
-#define NO 0
-#endif
-#ifndef YES
-#define YES 1
-#endif
-
-/* Turn debug messages on or off */
-#ifndef CYGDEBUG
-#define CYGDEBUG NO
-#endif
-
-/* WM_XBUTTON Messages. They should go into w32api. */
-#ifndef WM_XBUTTONDOWN
-# define WM_XBUTTONDOWN 523
-#endif
-#ifndef WM_XBUTTONUP
-# define WM_XBUTTONUP 524
-#endif
-#ifndef WM_XBUTTONDBLCLK
-# define WM_XBUTTONDBLCLK 525
-#endif
-
-
-#define WIN_DEFAULT_BPP 0
-#define WIN_DEFAULT_WHITEPIXEL 255
-#define WIN_DEFAULT_BLACKPIXEL 0
-#define WIN_DEFAULT_LINEBIAS 0
-#define WIN_DEFAULT_E3B_TIME 50 /* milliseconds */
-#define WIN_DEFAULT_DPI 75
-#define WIN_DEFAULT_REFRESH 0
-#define WIN_DEFAULT_WIN_KILL TRUE
-#define WIN_DEFAULT_UNIX_KILL FALSE
-#define WIN_DEFAULT_CLIP_UPDATES_NBOXES 0
-#ifdef XWIN_EMULATEPSEUDO
-#define WIN_DEFAULT_EMULATE_PSEUDO FALSE
-#endif
-#define WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH FALSE
-
-#define WIN_DIB_MAXIMUM_SIZE 0x08000000 /* 16 MB on Windows 95, 98, Me */
-#define WIN_DIB_MAXIMUM_SIZE_MB (WIN_DIB_MAXIMUM_SIZE / 8 / 1024 / 1024)
-
-/*
- * Windows only supports 256 color palettes
- */
-#define WIN_NUM_PALETTE_ENTRIES 256
-
-/*
- * Number of times to call Restore in an attempt to restore the primary surface
- */
-#define WIN_REGAIN_SURFACE_RETRIES 1
-
-/*
- * Build a supported display depths mask by shifting one to the left
- * by the number of bits in the supported depth.
- */
-#define WIN_SUPPORTED_BPPS ( (1 << (32 - 1)) | (1 << (24 - 1)) \
- | (1 << (16 - 1)) | (1 << (15 - 1)) \
- | (1 << ( 8 - 1)))
-#define WIN_CHECK_DEPTH YES
-
-/*
- * Timer IDs for WM_TIMER
- */
-#define WIN_E3B_TIMER_ID 1
-#define WIN_POLLING_MOUSE_TIMER_ID 2
-
-#define MOUSE_POLLING_INTERVAL 50
-
-#define WIN_E3B_OFF -1
-#define WIN_FD_INVALID -1
-
-#define WIN_SERVER_NONE 0x0L /* 0 */
-#define WIN_SERVER_SHADOW_GDI 0x1L /* 1 */
-#define WIN_SERVER_SHADOW_DD 0x2L /* 2 */
-#define WIN_SERVER_SHADOW_DDNL 0x4L /* 4 */
-#ifdef XWIN_PRIMARYFB
-#define WIN_SERVER_PRIMARY_DD 0x8L /* 8 */
-#endif
-#ifdef XWIN_NATIVEGDI
-# define WIN_SERVER_NATIVE_GDI 0x10L /* 16 */
-#endif
-
-#define AltMapIndex Mod1MapIndex
-#define NumLockMapIndex Mod2MapIndex
-#define AltLangMapIndex Mod3MapIndex
-#define KanaMapIndex Mod4MapIndex
-#define ScrollLockMapIndex Mod5MapIndex
-
-#define WIN_MOD_LALT 0x00000001
-#define WIN_MOD_RALT 0x00000002
-#define WIN_MOD_LCONTROL 0x00000004
-#define WIN_MOD_RCONTROL 0x00000008
-
-#define WIN_24BPP_MASK_RED 0x00FF0000
-#define WIN_24BPP_MASK_GREEN 0x0000FF00
-#define WIN_24BPP_MASK_BLUE 0x000000FF
-
-#define WIN_MAX_KEYS_PER_KEY 4
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdio.h>
-
-#include <errno.h>
-#if defined(XWIN_MULTIWINDOWEXTWM) || defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
-#define HANDLE void *
-#include <pthread.h>
-#undef HANDLE
-#endif
-
-#ifdef HAS_MMAP
-#include <sys/mman.h>
-#ifndef MAP_FILE
-#define MAP_FILE 0
-#endif /* MAP_FILE */
-#endif /* HAS_MMAP */
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include <X11/Xos.h>
-#include <X11/Xprotostr.h>
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "pixmap.h"
-#include "region.h"
-#include "gcstruct.h"
-#include "colormap.h"
-#include "colormapst.h"
-#include "miscstruct.h"
-#include "servermd.h"
-#include "windowstr.h"
-#include "mi.h"
-#include "micmap.h"
-#include "mifillarc.h"
-#include "mifpoly.h"
-#include "mibstore.h"
-#include "input.h"
-#include "mipointer.h"
-#include "X11/keysym.h"
-#include "mibstore.h"
-#include "micoord.h"
-#include "dix.h"
-#include "miline.h"
-#include "shadow.h"
-#include "fb.h"
-#include "rootless.h"
-
-#ifdef RENDER
-#include "mipict.h"
-#include "picturestr.h"
-#endif
-
-#ifdef RANDR
-#include "randrstr.h"
-#endif
-
-/*
- * Windows headers
- */
-#include "winms.h"
-#include "./winresource.h"
-
-
-/*
- * Define Windows constants
- */
-
-#define WM_TRAYICON (WM_USER + 1000)
-#define WM_INIT_SYS_MENU (WM_USER + 1001)
-#define WM_GIVEUP (WM_USER + 1002)
-
-
-/* Local includes */
-#include "winwindow.h"
-#include "winmsg.h"
-
-
-/*
- * Debugging macros
- */
-
-#if CYGDEBUG
-#define DEBUG_MSG(str,...) \
-if (fDebugProcMsg) \
-{ \
- char *pszTemp; \
- int iLength; \
- pszTemp = Xprintf (str, ##__VA_ARGS__); \
- MessageBox (NULL, pszTemp, szFunctionName, MB_OK); \
- xfree (pszTemp); \
-}
-#else
-#define DEBUG_MSG(str,...)
-#endif
-
-#if CYGDEBUG
-#define DEBUG_FN_NAME(str) PTSTR szFunctionName = str
-#else
-#define DEBUG_FN_NAME(str)
-#endif
-
-#if CYGDEBUG || YES
-#define DEBUGVARS BOOL fDebugProcMsg = FALSE
-#else
-#define DEBUGVARS
-#endif
-
-#if CYGDEBUG || YES
-#define DEBUGPROC_MSG fDebugProcMsg = TRUE
-#else
-#define DEBUGPROC_MSG
-#endif
-
-#define PROFILEPOINT(point,thresh)\
-{\
-static unsigned int PROFPT##point = 0;\
-if (++PROFPT##point % thresh == 0)\
-ErrorF (#point ": PROFILEPOINT hit %u times\n", PROFPT##point);\
-}
-
-
-/* We use xor this macro for detecting toggle key state changes */
-#define WIN_XOR(a,b) ((!(a) && (b)) || ((a) && !(b)))
-
-#define DEFINE_ATOM_HELPER(func,atom_name) \
-static Atom func (void) { \
- static int generation; \
- static Atom atom; \
- if (generation != serverGeneration) { \
- generation = serverGeneration; \
- atom = MakeAtom (atom_name, strlen (atom_name), TRUE); \
- } \
- return atom; \
-}
-
-/*
- * Typedefs for engine dependent function pointers
- */
-
-typedef Bool (*winAllocateFBProcPtr)(ScreenPtr);
-
-typedef void (*winShadowUpdateProcPtr)(ScreenPtr, shadowBufPtr);
-
-typedef Bool (*winCloseScreenProcPtr)(int, ScreenPtr);
-
-typedef Bool (*winInitVisualsProcPtr)(ScreenPtr);
-
-typedef Bool (*winAdjustVideoModeProcPtr)(ScreenPtr);
-
-typedef Bool (*winCreateBoundingWindowProcPtr)(ScreenPtr);
-
-typedef Bool (*winFinishScreenInitProcPtr)(int, ScreenPtr, int, char **);
-
-typedef Bool (*winBltExposedRegionsProcPtr)(ScreenPtr);
-
-typedef Bool (*winActivateAppProcPtr)(ScreenPtr);
-
-typedef Bool (*winRedrawScreenProcPtr)(ScreenPtr pScreen);
-
-typedef Bool (*winRealizeInstalledPaletteProcPtr)(ScreenPtr pScreen);
-
-typedef Bool (*winInstallColormapProcPtr)(ColormapPtr pColormap);
-
-typedef Bool (*winStoreColorsProcPtr)(ColormapPtr pmap,
- int ndef, xColorItem *pdefs);
-
-typedef Bool (*winCreateColormapProcPtr)(ColormapPtr pColormap);
-
-typedef Bool (*winDestroyColormapProcPtr)(ColormapPtr pColormap);
-
-typedef Bool (*winHotKeyAltTabProcPtr)(ScreenPtr);
-
-typedef Bool (*winCreatePrimarySurfaceProcPtr)(ScreenPtr);
-
-typedef Bool (*winReleasePrimarySurfaceProcPtr)(ScreenPtr);
-
-typedef Bool (*winFinishCreateWindowsWindowProcPtr)(WindowPtr pWin);
-
-typedef Bool (*winCreateScreenResourcesProc)(ScreenPtr);
-
-/* Typedef for DIX wrapper functions */
-typedef int (*winDispatchProcPtr) (ClientPtr);
-
-
-/*
- * GC (graphics context) privates
- */
-
-typedef struct
-{
- HDC hdc;
- HDC hdcMem;
-} winPrivGCRec, *winPrivGCPtr;
-
-
-/*
- * Pixmap privates
- */
-
-typedef struct
-{
- HDC hdcSelected;
- HBITMAP hBitmap;
- BYTE *pbBits;
- DWORD dwScanlineBytes;
- BITMAPINFOHEADER *pbmih;
-} winPrivPixmapRec, *winPrivPixmapPtr;
-
-
-/*
- * Colormap privates
- */
-
-typedef struct
-{
- HPALETTE hPalette;
- LPDIRECTDRAWPALETTE lpDDPalette;
- RGBQUAD rgbColors[WIN_NUM_PALETTE_ENTRIES];
- PALETTEENTRY peColors[WIN_NUM_PALETTE_ENTRIES];
-} winPrivCmapRec, *winPrivCmapPtr;
-
-/*
- * Windows Cursor handling.
- */
-
-typedef struct {
- /* from GetSystemMetrics */
- int sm_cx;
- int sm_cy;
-
- BOOL visible;
- HCURSOR handle;
- QueryBestSizeProcPtr QueryBestSize;
- miPointerSpriteFuncPtr spriteFuncs;
-} winCursorRec;
-
-/*
- * Screen information structure that we need before privates are available
- * in the server startup sequence.
- */
-
-typedef struct
-{
- ScreenPtr pScreen;
-
- /* Did the user specify a height and width? */
- Bool fUserGaveHeightAndWidth;
-
- DWORD dwScreen;
- DWORD dwUserWidth;
- DWORD dwUserHeight;
- DWORD dwWidth;
- DWORD dwHeight;
- DWORD dwWidth_mm;
- DWORD dwHeight_mm;
- DWORD dwPaddedWidth;
-
- /* Did the user specify a screen position? */
- Bool fUserGavePosition;
- DWORD dwInitialX;
- DWORD dwInitialY;
-
- /*
- * dwStride is the number of whole pixels that occupy a scanline,
- * including those pixels that are not displayed. This is basically
- * a rounding up of the width.
- */
- DWORD dwStride;
-
- /* Offset of the screen in the window when using scrollbars */
- DWORD dwXOffset;
- DWORD dwYOffset;
-
- DWORD dwBPP;
- DWORD dwDepth;
- DWORD dwRefreshRate;
- char *pfb;
- DWORD dwEngine;
- DWORD dwEnginePreferred;
- DWORD dwClipUpdatesNBoxes;
-#ifdef XWIN_EMULATEPSEUDO
- Bool fEmulatePseudo;
-#endif
- Bool fFullScreen;
- Bool fDecoration;
-#ifdef XWIN_MULTIWINDOWEXTWM
- Bool fMWExtWM;
- Bool fInternalWM;
- Bool fAnotherWMRunning;
-#endif
- Bool fRootless;
-#ifdef XWIN_MULTIWINDOW
- Bool fMultiWindow;
-#endif
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- Bool fMultiMonitorOverride;
-#endif
- Bool fMultipleMonitors;
- Bool fLessPointer;
- Bool fScrollbars;
- Bool fNoTrayIcon;
- int iE3BTimeout;
- /* Windows (Alt+F4) and Unix (Ctrl+Alt+Backspace) Killkey */
- Bool fUseWinKillKey;
- Bool fUseUnixKillKey;
- Bool fIgnoreInput;
-
- /* Did the user explicitly set this screen? */
- Bool fExplicitScreen;
-} winScreenInfo, *winScreenInfoPtr;
-
-
-/*
- * Screen privates
- */
-
-typedef struct _winPrivScreenRec
-{
- winScreenInfoPtr pScreenInfo;
-
- Bool fEnabled;
- Bool fClosed;
- Bool fActive;
- Bool fBadDepth;
-
- int iDeltaZ;
-
- int iConnectedClients;
-
- CloseScreenProcPtr CloseScreen;
-
- DWORD dwRedMask;
- DWORD dwGreenMask;
- DWORD dwBlueMask;
- DWORD dwBitsPerRGB;
-
- DWORD dwModeKeyStates;
-
- /* Handle to icons that must be freed */
- HICON hiconNotifyIcon;
-
- /* Last width, height, and depth of the Windows display */
- DWORD dwLastWindowsWidth;
- DWORD dwLastWindowsHeight;
- DWORD dwLastWindowsBitsPixel;
-
- /* Palette management */
- ColormapPtr pcmapInstalled;
-
- /* Pointer to the root visual so we only have to look it up once */
- VisualPtr pRootVisual;
-
- /* 3 button emulation variables */
- int iE3BCachedPress;
- Bool fE3BFakeButton2Sent;
-
- /* Privates used by shadow fb GDI server */
- HBITMAP hbmpShadow;
- HDC hdcScreen;
- HDC hdcShadow;
- HWND hwndScreen;
-
- /* Privates used by shadow fb and primary fb DirectDraw servers */
- LPDIRECTDRAW pdd;
- LPDIRECTDRAWSURFACE2 pddsPrimary;
- LPDIRECTDRAW2 pdd2;
-
- /* Privates used by shadow fb DirectDraw server */
- LPDIRECTDRAWSURFACE2 pddsShadow;
- LPDDSURFACEDESC pddsdShadow;
-
- /* Privates used by primary fb DirectDraw server */
- LPDIRECTDRAWSURFACE2 pddsOffscreen;
- LPDDSURFACEDESC pddsdOffscreen;
- LPDDSURFACEDESC pddsdPrimary;
-
- /* Privates used by shadow fb DirectDraw Nonlocking server */
- LPDIRECTDRAW4 pdd4;
- LPDIRECTDRAWSURFACE4 pddsShadow4;
- LPDIRECTDRAWSURFACE4 pddsPrimary4;
- BOOL fRetryCreateSurface;
-
- /* Privates used by both shadow fb DirectDraw servers */
- LPDIRECTDRAWCLIPPER pddcPrimary;
-
-#ifdef XWIN_MULTIWINDOWEXTWM
- /* Privates used by multi-window external window manager */
- RootlessFrameID widTop;
- Bool fRestacking;
-#endif
-
-#ifdef XWIN_MULTIWINDOW
- /* Privates used by multi-window */
- pthread_t ptWMProc;
- pthread_t ptXMsgProc;
- void *pWMInfo;
-#endif
-
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- /* Privates used by both multi-window and rootless */
- Bool fRootWindowShown;
-#endif
-
-#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
- /* Privates used for any module running in a seperate thread */
- pthread_mutex_t pmServerStarted;
- Bool fServerStarted;
-#endif
-
- /* Engine specific functions */
- winAllocateFBProcPtr pwinAllocateFB;
- winShadowUpdateProcPtr pwinShadowUpdate;
- winCloseScreenProcPtr pwinCloseScreen;
- winInitVisualsProcPtr pwinInitVisuals;
- winAdjustVideoModeProcPtr pwinAdjustVideoMode;
- winCreateBoundingWindowProcPtr pwinCreateBoundingWindow;
- winFinishScreenInitProcPtr pwinFinishScreenInit;
- winBltExposedRegionsProcPtr pwinBltExposedRegions;
- winActivateAppProcPtr pwinActivateApp;
- winRedrawScreenProcPtr pwinRedrawScreen;
- winRealizeInstalledPaletteProcPtr pwinRealizeInstalledPalette;
- winInstallColormapProcPtr pwinInstallColormap;
- winStoreColorsProcPtr pwinStoreColors;
- winCreateColormapProcPtr pwinCreateColormap;
- winDestroyColormapProcPtr pwinDestroyColormap;
- winHotKeyAltTabProcPtr pwinHotKeyAltTab;
- winCreatePrimarySurfaceProcPtr pwinCreatePrimarySurface;
- winReleasePrimarySurfaceProcPtr pwinReleasePrimarySurface;
-
- winCreateScreenResourcesProc pwinCreateScreenResources;
-
-#ifdef XWIN_MULTIWINDOW
- /* Window Procedures for MultiWindow mode */
- winFinishCreateWindowsWindowProcPtr pwinFinishCreateWindowsWindow;
-#endif
-
- /* Window Procedures for Rootless mode */
- CreateWindowProcPtr CreateWindow;
- DestroyWindowProcPtr DestroyWindow;
- PositionWindowProcPtr PositionWindow;
- ChangeWindowAttributesProcPtr ChangeWindowAttributes;
- RealizeWindowProcPtr RealizeWindow;
- UnrealizeWindowProcPtr UnrealizeWindow;
- ValidateTreeProcPtr ValidateTree;
- PostValidateTreeProcPtr PostValidateTree;
- WindowExposuresProcPtr WindowExposures;
- CopyWindowProcPtr CopyWindow;
- ClearToBackgroundProcPtr ClearToBackground;
- ClipNotifyProcPtr ClipNotify;
- RestackWindowProcPtr RestackWindow;
- ReparentWindowProcPtr ReparentWindow;
- ResizeWindowProcPtr ResizeWindow;
- MoveWindowProcPtr MoveWindow;
- SetShapeProcPtr SetShape;
-
- winCursorRec cursor;
-} winPrivScreenRec;
-
-
-#ifdef XWIN_MULTIWINDOWEXTWM
-typedef struct {
- RootlessWindowPtr pFrame;
- HWND hWnd;
- int dwWidthBytes;
- BITMAPINFOHEADER *pbmihShadow;
- HBITMAP hbmpShadow;
- HDC hdcShadow;
- HDC hdcScreen;
- BOOL fResized;
- BOOL fRestackingNow;
- BOOL fClose;
- BOOL fMovingOrSizing;
- BOOL fDestroyed;//for debug
- char *pfb;
-} win32RootlessWindowRec, *win32RootlessWindowPtr;
-#endif
-
-
-typedef struct {
- pointer value;
- XID id;
-} WindowIDPairRec, *WindowIDPairPtr;
-
-
-/*
- * Extern declares for general global variables
- */
-
-extern winScreenInfo g_ScreenInfo[];
-extern miPointerScreenFuncRec g_winPointerCursorFuncs;
-extern DWORD g_dwEvents;
-#ifdef HAS_DEVWINDOWS
-extern int g_fdMessageQueue;
-#endif
-extern DevPrivateKey g_iScreenPrivateKey;
-extern DevPrivateKey g_iCmapPrivateKey;
-extern DevPrivateKey g_iGCPrivateKey;
-extern DevPrivateKey g_iPixmapPrivateKey;
-extern DevPrivateKey g_iWindowPrivateKey;
-extern unsigned long g_ulServerGeneration;
-extern DWORD g_dwEnginesSupported;
-extern HINSTANCE g_hInstance;
-extern int g_copyROP[];
-extern int g_patternROP[];
-extern const char * g_pszQueryHost;
-extern DeviceIntPtr g_pwinPointer;
-extern DeviceIntPtr g_pwinKeyboard;
-
-
-/*
- * Extern declares for dynamically loaded libraries and function pointers
- */
-
-extern HMODULE g_hmodDirectDraw;
-extern FARPROC g_fpDirectDrawCreate;
-extern FARPROC g_fpDirectDrawCreateClipper;
-
-extern HMODULE g_hmodCommonControls;
-extern FARPROC g_fpTrackMouseEvent;
-
-
-/*
- * Screen privates macros
- */
-
-#define winGetScreenPriv(pScreen) ((winPrivScreenPtr) \
- dixLookupPrivate(&(pScreen)->devPrivates, g_iScreenPrivateKey))
-
-#define winSetScreenPriv(pScreen,v) \
- dixSetPrivate(&(pScreen)->devPrivates, g_iScreenPrivateKey, v)
-
-#define winScreenPriv(pScreen) \
- winPrivScreenPtr pScreenPriv = winGetScreenPriv(pScreen)
-
-
-/*
- * Colormap privates macros
- */
-
-#define winGetCmapPriv(pCmap) ((winPrivCmapPtr) \
- dixLookupPrivate(&(pCmap)->devPrivates, g_iCmapPrivateKey))
-
-#define winSetCmapPriv(pCmap,v) \
- dixSetPrivate(&(pCmap)->devPrivates, g_iCmapPrivateKey, v)
-
-#define winCmapPriv(pCmap) \
- winPrivCmapPtr pCmapPriv = winGetCmapPriv(pCmap)
-
-
-/*
- * GC privates macros
- */
-
-#define winGetGCPriv(pGC) ((winPrivGCPtr) \
- dixLookupPrivate(&(pGC)->devPrivates, g_iGCPrivateKey))
-
-#define winSetGCPriv(pGC,v) \
- dixSetPrivate(&(pGC)->devPrivates, g_iGCPrivateKey, v)
-
-#define winGCPriv(pGC) \
- winPrivGCPtr pGCPriv = winGetGCPriv(pGC)
-
-
-/*
- * Pixmap privates macros
- */
-
-#define winGetPixmapPriv(pPixmap) ((winPrivPixmapPtr) \
- dixLookupPrivate(&(pPixmap)->devPrivates, g_iPixmapPrivateKey))
-
-#define winSetPixmapPriv(pPixmap,v) \
- dixLookupPrivate(&(pPixmap)->devPrivates, g_iPixmapPrivateKey, v)
-
-#define winPixmapPriv(pPixmap) \
- winPrivPixmapPtr pPixmapPriv = winGetPixmapPriv(pPixmap)
-
-
-/*
- * Window privates macros
- */
-
-#define winGetWindowPriv(pWin) ((winPrivWinPtr) \
- dixLookupPrivate(&(pWin)->devPrivates, g_iWindowPrivateKey))
-
-#define winSetWindowPriv(pWin,v) \
- dixLookupPrivate(&(pWin)->devPrivates, g_iWindowPrivateKey, v)
-
-#define winWindowPriv(pWin) \
- winPrivWinPtr pWinPriv = winGetWindowPriv(pWin)
-
-/*
- * wrapper macros
- */
-#define _WIN_WRAP(priv, real, mem, func) {\
- priv->mem = real->mem; \
- real->mem = func; \
-}
-
-#define _WIN_UNWRAP(priv, real, mem) {\
- real->mem = priv->mem; \
-}
-
-#define WIN_WRAP(mem, func) _WIN_WRAP(pScreenPriv, pScreen, mem, func)
-
-#define WIN_UNWRAP(mem) _WIN_UNWRAP(pScreenPriv, pScreen, mem)
-
-/*
- * BEGIN DDX and DIX Function Prototypes
- */
-
-
-/*
- * winallpriv.c
- */
-
-Bool
-winAllocatePrivates (ScreenPtr pScreen);
-
-Bool
-winInitCmapPrivates (ColormapPtr pCmap, int index);
-
-Bool
-winAllocateCmapPrivates (ColormapPtr pCmap);
-
-
-/*
- * winauth.c
- */
-
-#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
-Bool
-winGenerateAuthorization (void);
-void winSetAuthorization(void);
-#endif
-
-
-/*
- * winblock.c
- */
-
-void
-winBlockHandler (int nScreen,
- pointer pBlockData,
- pointer pTimeout,
- pointer pReadMask);
-
-
-#ifdef XWIN_NATIVEGDI
-/*
- * winclip.c
- */
-
-RegionPtr
-winPixmapToRegionNativeGDI (PixmapPtr pPix);
-#endif
-
-
-#ifdef XWIN_CLIPBOARD
-/*
- * winclipboardinit.c
- */
-
-Bool
-winInitClipboard (void);
-
-void
-winFixClipboardChain (void);
-#endif
-
-
-/*
- * wincmap.c
- */
-
-void
-winSetColormapFunctions (ScreenPtr pScreen);
-
-Bool
-winCreateDefColormap (ScreenPtr pScreen);
-
-
-/*
- * wincreatewnd.c
- */
-
-Bool
-winCreateBoundingWindowFullScreen (ScreenPtr pScreen);
-
-Bool
-winCreateBoundingWindowWindowed (ScreenPtr pScreen);
-
-
-/*
- * windialogs.c
- */
-
-void
-winDisplayExitDialog (winPrivScreenPtr pScreenPriv);
-
-void
-winDisplayDepthChangeDialog (winPrivScreenPtr pScreenPriv);
-
-void
-winDisplayAboutDialog (winPrivScreenPtr pScreenPriv);
-
-
-/*
- * winengine.c
- */
-
-void
-winDetectSupportedEngines (void);
-
-Bool
-winSetEngine (ScreenPtr pScreen);
-
-Bool
-winGetDDProcAddresses (void);
-
-
-/*
- * winerror.c
- */
-
-#ifdef DDXOSVERRORF
-void
-OSVenderVErrorF (const char *pszFormat, va_list va_args);
-#endif
-
-void
-winMessageBoxF (const char *pszError, UINT uType, ...);
-
-
-#ifdef XWIN_NATIVEGDI
-/*
- * winfillsp.c
- */
-
-void
-winFillSpansNativeGDI (DrawablePtr pDrawable,
- GCPtr pGC,
- int nSpans,
- DDXPointPtr pPoints,
- int *pWidths,
- int fSorted);
-#endif
-
-
-#ifdef XWIN_NATIVEGDI
-/*
- * winfont.c
- */
-
-Bool
-winRealizeFontNativeGDI (ScreenPtr pScreen, FontPtr pFont);
-
-Bool
-winUnrealizeFontNativeGDI (ScreenPtr pScreen, FontPtr pFont);
-#endif
-
-
-#ifdef XWIN_NATIVEGDI
-/*
- * wingc.c
- */
-
-Bool
-winCreateGCNativeGDI (GCPtr pGC);
-#endif
-
-
-#ifdef XWIN_NATIVEGDI
-/*
- * wingetsp.c
- */
-
-void
-winGetSpansNativeGDI (DrawablePtr pDrawable,
- int wMax,
- DDXPointPtr pPoints,
- int *pWidths,
- int nSpans,
- char *pDst);
-#endif
-
-
-/*
- * winglobals.c
- */
-
-void
-winInitializeGlobals (void);
-
-
-/*
- * winkeybd.c
- */
-
-void
-winTranslateKey (WPARAM wParam, LPARAM lParam, int *piScanCode);
-
-int
-winKeybdProc (DeviceIntPtr pDeviceInt, int iState);
-
-void
-winInitializeModeKeyStates (void);
-
-void
-winRestoreModeKeyStates (void);
-
-Bool
-winIsFakeCtrl_L (UINT message, WPARAM wParam, LPARAM lParam);
-
-void
-winKeybdReleaseKeys (void);
-
-void
-winSendKeyEvent (DWORD dwKey, Bool fDown);
-
-BOOL
-winCheckKeyPressed(WPARAM wParam, LPARAM lParam);
-
-void
-winFixShiftKeys (int iScanCode);
-
-/*
- * winkeyhook.c
- */
-
-Bool
-winInstallKeyboardHookLL (void);
-
-void
-winRemoveKeyboardHookLL (void);
-
-
-/*
- * winmisc.c
- */
-
-#ifdef XWIN_NATIVEGDI
-void
-winQueryBestSizeNativeGDI (int class, unsigned short *pWidth,
- unsigned short *pHeight, ScreenPtr pScreen);
-#endif
-
-CARD8
-winCountBits (DWORD dw);
-
-Bool
-winUpdateFBPointer (ScreenPtr pScreen, void *pbits);
-
-#ifdef XWIN_NATIVEGDI
-BOOL
-winPaintBackground (HWND hwnd, COLORREF colorref);
-#endif
-
-
-/*
- * winmouse.c
- */
-
-int
-winMouseProc (DeviceIntPtr pDeviceInt, int iState);
-
-int
-winMouseWheel (ScreenPtr pScreen, int iDeltaZ);
-
-void
-winMouseButtonsSendEvent (int iEventType, int iButton);
-
-int
-winMouseButtonsHandle (ScreenPtr pScreen,
- int iEventType, int iButton,
- WPARAM wParam);
-
-void
-winEnqueueMotion(int x, int y);
-
-#ifdef XWIN_NATIVEGDI
-/*
- * winnativegdi.c
- */
-
-HBITMAP
-winCreateDIBNativeGDI (int iWidth, int iHeight, int iDepth,
- BYTE **ppbBits, BITMAPINFO **ppbmi);
-
-Bool
-winSetEngineFunctionsNativeGDI (ScreenPtr pScreen);
-#endif
-
-
-#ifdef XWIN_PRIMARYFB
-/*
- * winpfbddd.c
- */
-
-Bool
-winSetEngineFunctionsPrimaryDD (ScreenPtr pScreen);
-#endif
-
-
-#ifdef XWIN_NATIVEGDI
-/*
- * winpixmap.c
- */
-
-PixmapPtr
-winCreatePixmapNativeGDI (ScreenPtr pScreen, int width, int height, int depth,
- unsigned usage_hint);
-
-Bool
-winDestroyPixmapNativeGDI (PixmapPtr pPixmap);
-
-Bool
-winModifyPixmapHeaderNativeGDI (PixmapPtr pPixmap,
- int iWidth, int iHeight,
- int iDepth,
- int iBitsPerPixel,
- int devKind,
- pointer pPixData);
-#endif
-
-#ifdef XWIN_NATIVEGDI
-/*
- * winpolyline.c
- */
-
-void
-winPolyLineNativeGDI (DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr ppt);
-#endif
-
-
-#ifdef XWIN_NATIVEGDI
-/*
- * winpushpxl.c
- */
-
-void
-winPushPixels (GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDrawable,
- int dx, int dy, int xOrg, int yOrg);
-#endif
-
-
-/*
- * winscrinit.c
- */
-
-Bool
-winScreenInit (int index,
- ScreenPtr pScreen,
- int argc, char **argv);
-
-Bool
-winFinishScreenInitFB (int index,
- ScreenPtr pScreen,
- int argc, char **argv);
-
-#if defined(XWIN_NATIVEGDI)
-Bool
-winFinishScreenInitNativeGDI (int index,
- ScreenPtr pScreen,
- int argc, char **argv);
-#endif
-
-
-#ifdef XWIN_NATIVEGDI
-/*
- * winsetsp.c
- */
-
-void
-winSetSpansNativeGDI (DrawablePtr pDrawable,
- GCPtr pGC,
- char *pSrc,
- DDXPointPtr pPoints,
- int *pWidth,
- int nSpans,
- int fSorted);
-#endif
-
-
-/*
- * winshaddd.c
- */
-
-Bool
-winSetEngineFunctionsShadowDD (ScreenPtr pScreen);
-
-
-/*
- * winshadddnl.c
- */
-
-Bool
-winSetEngineFunctionsShadowDDNL (ScreenPtr pScreen);
-
-
-/*
- * winshadgdi.c
- */
-
-Bool
-winSetEngineFunctionsShadowGDI (ScreenPtr pScreen);
-
-
-/*
- * winwakeup.c
- */
-
-void
-winWakeupHandler (int nScreen,
- pointer pWakeupData,
- unsigned long ulResult,
- pointer pReadmask);
-
-
-/*
- * winwindow.c
- */
-
-#ifdef XWIN_NATIVEGDI
-Bool
-winCreateWindowNativeGDI (WindowPtr pWin);
-
-Bool
-winDestroyWindowNativeGDI (WindowPtr pWin);
-
-Bool
-winPositionWindowNativeGDI (WindowPtr pWin, int x, int y);
-
-void
-winCopyWindowNativeGDI (WindowPtr pWin,
- DDXPointRec ptOldOrg,
- RegionPtr prgnSrc);
-
-Bool
-winChangeWindowAttributesNativeGDI (WindowPtr pWin, unsigned long mask);
-
-Bool
-winUnmapWindowNativeGDI (WindowPtr pWindow);
-
-Bool
-winMapWindowNativeGDI (WindowPtr pWindow);
-#endif
-
-Bool
-winCreateWindowRootless (WindowPtr pWindow);
-
-Bool
-winDestroyWindowRootless (WindowPtr pWindow);
-
-Bool
-winPositionWindowRootless (WindowPtr pWindow, int x, int y);
-
-Bool
-winChangeWindowAttributesRootless (WindowPtr pWindow, unsigned long mask);
-
-Bool
-winUnmapWindowRootless (WindowPtr pWindow);
-
-Bool
-winMapWindowRootless (WindowPtr pWindow);
-
-void
-winSetShapeRootless (WindowPtr pWindow);
-
-
-/*
- * winmultiwindowicons.c - Used by both multi-window and Win32Rootless
- */
-
-HICON
-winXIconToHICON (WindowPtr pWin, int iconSize);
-
-void
-winSelectIcons(WindowPtr pWin, HICON *pIcon, HICON *pSmallIcon);
-
-#ifdef XWIN_MULTIWINDOW
-/*
- * winmultiwindowshape.c
- */
-
-void
-winReshapeMultiWindow (WindowPtr pWin);
-
-void
-winSetShapeMultiWindow (WindowPtr pWindow);
-
-void
-winUpdateRgnMultiWindow (WindowPtr pWindow);
-#endif
-
-
-#ifdef XWIN_MULTIWINDOW
-/*
- * winmultiwindowwindow.c
- */
-
-Bool
-winCreateWindowMultiWindow (WindowPtr pWindow);
-
-Bool
-winDestroyWindowMultiWindow (WindowPtr pWindow);
-
-Bool
-winPositionWindowMultiWindow (WindowPtr pWindow, int x, int y);
-
-Bool
-winChangeWindowAttributesMultiWindow (WindowPtr pWindow, unsigned long mask);
-
-Bool
-winUnmapWindowMultiWindow (WindowPtr pWindow);
-
-Bool
-winMapWindowMultiWindow (WindowPtr pWindow);
-
-void
-winReparentWindowMultiWindow (WindowPtr pWin, WindowPtr pPriorParent);
-
-void
-winRestackWindowMultiWindow (WindowPtr pWin, WindowPtr pOldNextSib);
-
-void
-winReorderWindowsMultiWindow (void);
-
-void
-winResizeWindowMultiWindow (WindowPtr pWin, int x, int y, unsigned int w,
- unsigned int h, WindowPtr pSib);
-void
-winMoveWindowMultiWindow (WindowPtr pWin, int x, int y,
- WindowPtr pSib, VTKind kind);
-
-void
-winCopyWindowMultiWindow (WindowPtr pWin, DDXPointRec oldpt,
- RegionPtr oldRegion);
-
-XID
-winGetWindowID (WindowPtr pWin);
-
-int
-winAdjustXWindow (WindowPtr pWin, HWND hwnd);
-#endif
-
-
-#ifdef XWIN_MULTIWINDOW
-/*
- * winmultiwindowwndproc.c
- */
-
-LRESULT CALLBACK
-winTopLevelWindowProc (HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam);
-#endif
-
-
-/*
- * wintrayicon.c
- */
-
-void
-winInitNotifyIcon (winPrivScreenPtr pScreenPriv);
-
-void
-winDeleteNotifyIcon (winPrivScreenPtr pScreenPriv);
-
-LRESULT
-winHandleIconMessage (HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam,
- winPrivScreenPtr pScreenPriv);
-
-
-/*
- * winwndproc.c
- */
-
-LRESULT CALLBACK
-winWindowProc (HWND hWnd, UINT message,
- WPARAM wParam, LPARAM lParam);
-
-
-#ifdef XWIN_MULTIWINDOWEXTWM
-/*
- * winwin32rootless.c
- */
-
-Bool
-winMWExtWMCreateFrame (RootlessWindowPtr pFrame, ScreenPtr pScreen,
- int newX, int newY, RegionPtr pShape);
-
-void
-winMWExtWMDestroyFrame (RootlessFrameID wid);
-
-void
-winMWExtWMMoveFrame (RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY);
-
-void
-winMWExtWMResizeFrame (RootlessFrameID wid, ScreenPtr pScreen,
- int newX, int newY, unsigned int newW, unsigned int newH,
- unsigned int gravity);
-
-void
-winMWExtWMRestackFrame (RootlessFrameID wid, RootlessFrameID nextWid);
-
-void
-winMWExtWMReshapeFrame (RootlessFrameID wid, RegionPtr pShape);
-
-void
-winMWExtWMUnmapFrame (RootlessFrameID wid);
-
-void
-winMWExtWMStartDrawing (RootlessFrameID wid, char **pixelData, int *bytesPerRow);
-
-void
-winMWExtWMStopDrawing (RootlessFrameID wid, Bool flush);
-
-void
-winMWExtWMUpdateRegion (RootlessFrameID wid, RegionPtr pDamage);
-
-void
-winMWExtWMDamageRects (RootlessFrameID wid, int count, const BoxRec *rects,
- int shift_x, int shift_y);
-
-void
-winMWExtWMRootlessSwitchWindow (RootlessWindowPtr pFrame, WindowPtr oldWin);
-
-void
-winMWExtWMCopyBytes (unsigned int width, unsigned int height,
- const void *src, unsigned int srcRowBytes,
- void *dst, unsigned int dstRowBytes);
-
-void
-winMWExtWMFillBytes (unsigned int width, unsigned int height, unsigned int value,
- void *dst, unsigned int dstRowBytes);
-
-int
-winMWExtWMCompositePixels (unsigned int width, unsigned int height, unsigned int function,
- void *src[2], unsigned int srcRowBytes[2],
- void *mask, unsigned int maskRowBytes,
- void *dst[2], unsigned int dstRowBytes[2]);
-
-void
-winMWExtWMCopyWindow (RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
- int dx, int dy);
-#endif
-
-
-#ifdef XWIN_MULTIWINDOWEXTWM
-/*
- * winwin32rootlesswindow.c
- */
-
-void
-winMWExtWMReorderWindows (ScreenPtr pScreen);
-
-void
-winMWExtWMMoveXWindow (WindowPtr pWin, int x, int y);
-
-void
-winMWExtWMResizeXWindow (WindowPtr pWin, int w, int h);
-
-void
-winMWExtWMMoveResizeXWindow (WindowPtr pWin, int x, int y, int w, int h);
-
-void
-winMWExtWMUpdateIcon (Window id);
-
-void
-winMWExtWMUpdateWindowDecoration (win32RootlessWindowPtr pRLWinPriv,
- winScreenInfoPtr pScreenInfo);
-
-wBOOL CALLBACK
-winMWExtWMDecorateWindow (HWND hwnd, LPARAM lParam);
-
-Bool
-winIsInternalWMRunning (winScreenInfoPtr pScreenInfo);
-
-void
-winMWExtWMRestackWindows (ScreenPtr pScreen);
-#endif
-
-
-#ifdef XWIN_MULTIWINDOWEXTWM
-/*
- * winwin32rootlesswndproc.c
- */
-
-LRESULT CALLBACK
-winMWExtWMWindowProc (HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam);
-#endif
-
-
-/*
- * winwindowswm.c
- */
-
-void
-winWindowsWMSendEvent (int type, unsigned int mask, int which, int arg,
- Window window, int x, int y, int w, int h);
-
-void
-winWindowsWMExtensionInit (void);
-
-/*
- * wincursor.c
- */
-
-Bool
-winInitCursor (ScreenPtr pScreen);
-
-/*
- * END DDX and DIX Function Prototypes
- */
-
-#endif /* _WIN_H_ */
-
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, 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 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 XFREE86 PROJECT 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 XFree86 Project
+ *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 XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ * Kensuke Matsuzaki
+ */
+
+#ifndef _WIN_H_
+#define _WIN_H_
+
+#ifndef NO
+#define NO 0
+#endif
+#ifndef YES
+#define YES 1
+#endif
+
+/* WM_XBUTTON Messages. They should go into w32api. */
+#ifndef WM_XBUTTONDOWN
+# define WM_XBUTTONDOWN 523
+#endif
+#ifndef WM_XBUTTONUP
+# define WM_XBUTTONUP 524
+#endif
+#ifndef WM_XBUTTONDBLCLK
+# define WM_XBUTTONDBLCLK 525
+#endif
+
+
+#define WIN_DEFAULT_BPP 0
+#define WIN_DEFAULT_WHITEPIXEL 255
+#define WIN_DEFAULT_BLACKPIXEL 0
+#define WIN_DEFAULT_LINEBIAS 0
+#define WIN_DEFAULT_E3B_TIME 50 /* milliseconds */
+#define WIN_DEFAULT_DPI 75
+#define WIN_DEFAULT_REFRESH 0
+#define WIN_DEFAULT_WIN_KILL TRUE
+#define WIN_DEFAULT_UNIX_KILL FALSE
+#define WIN_DEFAULT_CLIP_UPDATES_NBOXES 0
+#ifdef XWIN_EMULATEPSEUDO
+#define WIN_DEFAULT_EMULATE_PSEUDO FALSE
+#endif
+#define WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH FALSE
+
+#define WIN_DIB_MAXIMUM_SIZE 0x08000000 /* 16 MB on Windows 95, 98, Me */
+#define WIN_DIB_MAXIMUM_SIZE_MB (WIN_DIB_MAXIMUM_SIZE / 8 / 1024 / 1024)
+
+/*
+ * Windows only supports 256 color palettes
+ */
+#define WIN_NUM_PALETTE_ENTRIES 256
+
+/*
+ * Number of times to call Restore in an attempt to restore the primary surface
+ */
+#define WIN_REGAIN_SURFACE_RETRIES 1
+
+/*
+ * Build a supported display depths mask by shifting one to the left
+ * by the number of bits in the supported depth.
+ */
+#define WIN_SUPPORTED_BPPS ( (1 << (32 - 1)) | (1 << (24 - 1)) \
+ | (1 << (16 - 1)) | (1 << (15 - 1)) \
+ | (1 << ( 8 - 1)))
+#define WIN_CHECK_DEPTH YES
+
+/*
+ * Timer IDs for WM_TIMER
+ */
+#define WIN_E3B_TIMER_ID 1
+#define WIN_POLLING_MOUSE_TIMER_ID 2
+
+#define MOUSE_POLLING_INTERVAL 50
+
+#define WIN_E3B_OFF -1
+#define WIN_FD_INVALID -1
+
+#define WIN_SERVER_NONE 0x0L /* 0 */
+#define WIN_SERVER_SHADOW_GDI 0x1L /* 1 */
+#define WIN_SERVER_SHADOW_DD 0x2L /* 2 */
+#define WIN_SERVER_SHADOW_DDNL 0x4L /* 4 */
+#ifdef XWIN_PRIMARYFB
+#define WIN_SERVER_PRIMARY_DD 0x8L /* 8 */
+#endif
+#ifdef XWIN_NATIVEGDI
+# define WIN_SERVER_NATIVE_GDI 0x10L /* 16 */
+#endif
+
+#define AltMapIndex Mod1MapIndex
+#define NumLockMapIndex Mod2MapIndex
+#define AltLangMapIndex Mod3MapIndex
+#define KanaMapIndex Mod4MapIndex
+#define ScrollLockMapIndex Mod5MapIndex
+
+#define WIN_MOD_LALT 0x00000001
+#define WIN_MOD_RALT 0x00000002
+#define WIN_MOD_LCONTROL 0x00000004
+#define WIN_MOD_RCONTROL 0x00000008
+
+#define WIN_24BPP_MASK_RED 0x00FF0000
+#define WIN_24BPP_MASK_GREEN 0x0000FF00
+#define WIN_24BPP_MASK_BLUE 0x000000FF
+
+#define WIN_MAX_KEYS_PER_KEY 4
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdio.h>
+
+#include <errno.h>
+#if defined(XWIN_MULTIWINDOWEXTWM) || defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+#define HANDLE void *
+#ifdef _MSC_VER
+typedef int pid_t;
+#endif
+#include <pthread.h>
+#undef HANDLE
+#endif
+
+#ifdef HAS_MMAP
+#include <sys/mman.h>
+#ifndef MAP_FILE
+#define MAP_FILE 0
+#endif /* MAP_FILE */
+#endif /* HAS_MMAP */
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xos.h>
+#include <X11/Xprotostr.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "pixmap.h"
+#include "region.h"
+#include "gcstruct.h"
+#include "colormap.h"
+#include "colormapst.h"
+#include "miscstruct.h"
+#include "servermd.h"
+#include "windowstr.h"
+#include "mi.h"
+#include "micmap.h"
+#include "mifillarc.h"
+#include "mifpoly.h"
+#include "mibstore.h"
+#include "input.h"
+#include "mipointer.h"
+#include "X11/keysym.h"
+#include "mibstore.h"
+#include "micoord.h"
+#include "dix.h"
+#include "miline.h"
+#include "shadow.h"
+#include "fb.h"
+#include "rootless.h"
+
+#ifdef RENDER
+#include "mipict.h"
+#include "picturestr.h"
+#endif
+
+#ifdef RANDR
+#include "randrstr.h"
+#endif
+
+/*
+ * Windows headers
+ */
+#include "winms.h"
+#include "./winresource.h"
+
+
+/*
+ * Define Windows constants
+ */
+
+#define WM_TRAYICON (WM_USER + 1000)
+#define WM_INIT_SYS_MENU (WM_USER + 1001)
+#define WM_GIVEUP (WM_USER + 1002)
+
+
+/* Local includes */
+#include "winwindow.h"
+#include "winmsg.h"
+
+#define PROFILEPOINT(point,thresh)\
+{\
+static unsigned int PROFPT##point = 0;\
+if (++PROFPT##point % thresh == 0)\
+ErrorF (#point ": PROFILEPOINT hit %u times\n", PROFPT##point);\
+}
+
+
+/* We use xor this macro for detecting toggle key state changes */
+#define WIN_XOR(a,b) ((!(a) && (b)) || ((a) && !(b)))
+
+#define DEFINE_ATOM_HELPER(func,atom_name) \
+static Atom func (void) { \
+ static int generation; \
+ static Atom atom; \
+ if (generation != serverGeneration) { \
+ generation = serverGeneration; \
+ atom = MakeAtom (atom_name, strlen (atom_name), TRUE); \
+ } \
+ return atom; \
+}
+
+/*
+ * Typedefs for engine dependent function pointers
+ */
+
+typedef Bool (*winAllocateFBProcPtr)(ScreenPtr);
+
+typedef void (*winShadowUpdateProcPtr)(ScreenPtr, shadowBufPtr);
+
+typedef Bool (*winCloseScreenProcPtr)(int, ScreenPtr);
+
+typedef Bool (*winInitVisualsProcPtr)(ScreenPtr);
+
+typedef Bool (*winAdjustVideoModeProcPtr)(ScreenPtr);
+
+typedef Bool (*winCreateBoundingWindowProcPtr)(ScreenPtr);
+
+typedef Bool (*winFinishScreenInitProcPtr)(int, ScreenPtr, int, char **);
+
+typedef Bool (*winBltExposedRegionsProcPtr)(ScreenPtr);
+
+typedef Bool (*winActivateAppProcPtr)(ScreenPtr);
+
+typedef Bool (*winRedrawScreenProcPtr)(ScreenPtr pScreen);
+
+typedef Bool (*winRealizeInstalledPaletteProcPtr)(ScreenPtr pScreen);
+
+typedef Bool (*winInstallColormapProcPtr)(ColormapPtr pColormap);
+
+typedef Bool (*winStoreColorsProcPtr)(ColormapPtr pmap,
+ int ndef, xColorItem *pdefs);
+
+typedef Bool (*winCreateColormapProcPtr)(ColormapPtr pColormap);
+
+typedef Bool (*winDestroyColormapProcPtr)(ColormapPtr pColormap);
+
+typedef Bool (*winHotKeyAltTabProcPtr)(ScreenPtr);
+
+typedef Bool (*winCreatePrimarySurfaceProcPtr)(ScreenPtr);
+
+typedef Bool (*winReleasePrimarySurfaceProcPtr)(ScreenPtr);
+
+typedef Bool (*winFinishCreateWindowsWindowProcPtr)(WindowPtr pWin);
+
+typedef Bool (*winCreateScreenResourcesProc)(ScreenPtr);
+
+/* Typedef for DIX wrapper functions */
+typedef int (*winDispatchProcPtr) (ClientPtr);
+
+
+/*
+ * GC (graphics context) privates
+ */
+
+typedef struct
+{
+ HDC hdc;
+ HDC hdcMem;
+} winPrivGCRec, *winPrivGCPtr;
+
+
+/*
+ * Pixmap privates
+ */
+
+typedef struct
+{
+ HDC hdcSelected;
+ HBITMAP hBitmap;
+ BYTE *pbBits;
+ DWORD dwScanlineBytes;
+ BITMAPINFOHEADER *pbmih;
+} winPrivPixmapRec, *winPrivPixmapPtr;
+
+
+/*
+ * Colormap privates
+ */
+
+typedef struct
+{
+ HPALETTE hPalette;
+ LPDIRECTDRAWPALETTE lpDDPalette;
+ RGBQUAD rgbColors[WIN_NUM_PALETTE_ENTRIES];
+ PALETTEENTRY peColors[WIN_NUM_PALETTE_ENTRIES];
+} winPrivCmapRec, *winPrivCmapPtr;
+
+/*
+ * Windows Cursor handling.
+ */
+
+typedef struct {
+ /* from GetSystemMetrics */
+ int sm_cx;
+ int sm_cy;
+
+ BOOL visible;
+ HCURSOR handle;
+ QueryBestSizeProcPtr QueryBestSize;
+ miPointerSpriteFuncPtr spriteFuncs;
+} winCursorRec;
+
+/*
+ * Screen information structure that we need before privates are available
+ * in the server startup sequence.
+ */
+
+typedef struct
+{
+ ScreenPtr pScreen;
+
+ /* Did the user specify a height and width? */
+ Bool fUserGaveHeightAndWidth;
+
+ DWORD dwScreen;
+ DWORD dwUserWidth;
+ DWORD dwUserHeight;
+ DWORD dwWidth;
+ DWORD dwHeight;
+ DWORD dwWidth_mm;
+ DWORD dwHeight_mm;
+ DWORD dwPaddedWidth;
+
+ /* Did the user specify a screen position? */
+ Bool fUserGavePosition;
+ DWORD dwInitialX;
+ DWORD dwInitialY;
+
+ /*
+ * dwStride is the number of whole pixels that occupy a scanline,
+ * including those pixels that are not displayed. This is basically
+ * a rounding up of the width.
+ */
+ DWORD dwStride;
+
+ /* Offset of the screen in the window when using scrollbars */
+ DWORD dwXOffset;
+ DWORD dwYOffset;
+
+ DWORD dwBPP;
+ DWORD dwDepth;
+ DWORD dwRefreshRate;
+ char *pfb;
+ DWORD dwEngine;
+ DWORD dwEnginePreferred;
+ DWORD dwClipUpdatesNBoxes;
+#ifdef XWIN_EMULATEPSEUDO
+ Bool fEmulatePseudo;
+#endif
+ Bool fFullScreen;
+ Bool fDecoration;
+#ifdef XWIN_MULTIWINDOWEXTWM
+ Bool fMWExtWM;
+ Bool fInternalWM;
+ Bool fAnotherWMRunning;
+#endif
+ Bool fRootless;
+#ifdef XWIN_MULTIWINDOW
+ Bool fMultiWindow;
+#endif
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ Bool fMultiMonitorOverride;
+#endif
+ Bool fMultipleMonitors;
+ Bool fLessPointer;
+ Bool fScrollbars;
+ Bool fNoTrayIcon;
+ int iE3BTimeout;
+ /* Windows (Alt+F4) and Unix (Ctrl+Alt+Backspace) Killkey */
+ Bool fUseWinKillKey;
+ Bool fUseUnixKillKey;
+ Bool fIgnoreInput;
+
+ /* Did the user explicitly set this screen? */
+ Bool fExplicitScreen;
+} winScreenInfo, *winScreenInfoPtr;
+
+
+/*
+ * Screen privates
+ */
+
+typedef struct _winPrivScreenRec
+{
+ winScreenInfoPtr pScreenInfo;
+
+ Bool fEnabled;
+ Bool fClosed;
+ Bool fActive;
+ Bool fBadDepth;
+
+ int iDeltaZ;
+
+ int iConnectedClients;
+
+ CloseScreenProcPtr CloseScreen;
+
+ DWORD dwRedMask;
+ DWORD dwGreenMask;
+ DWORD dwBlueMask;
+ DWORD dwBitsPerRGB;
+
+ DWORD dwModeKeyStates;
+
+ /* Handle to icons that must be freed */
+ HICON hiconNotifyIcon;
+
+ /* Last width, height, and depth of the Windows display */
+ DWORD dwLastWindowsWidth;
+ DWORD dwLastWindowsHeight;
+ DWORD dwLastWindowsBitsPixel;
+
+ /* Palette management */
+ ColormapPtr pcmapInstalled;
+
+ /* Pointer to the root visual so we only have to look it up once */
+ VisualPtr pRootVisual;
+
+ /* 3 button emulation variables */
+ int iE3BCachedPress;
+ Bool fE3BFakeButton2Sent;
+
+ /* Privates used by shadow fb GDI server */
+ HBITMAP hbmpShadow;
+ HDC hdcScreen;
+ HDC hdcShadow;
+ HWND hwndScreen;
+
+ /* Privates used by shadow fb and primary fb DirectDraw servers */
+ LPDIRECTDRAW pdd;
+ LPDIRECTDRAWSURFACE2 pddsPrimary;
+ LPDIRECTDRAW2 pdd2;
+
+ /* Privates used by shadow fb DirectDraw server */
+ LPDIRECTDRAWSURFACE2 pddsShadow;
+ LPDDSURFACEDESC pddsdShadow;
+
+ /* Privates used by primary fb DirectDraw server */
+ LPDIRECTDRAWSURFACE2 pddsOffscreen;
+ LPDDSURFACEDESC pddsdOffscreen;
+ LPDDSURFACEDESC pddsdPrimary;
+
+ /* Privates used by shadow fb DirectDraw Nonlocking server */
+ LPDIRECTDRAW4 pdd4;
+ LPDIRECTDRAWSURFACE4 pddsShadow4;
+ LPDIRECTDRAWSURFACE4 pddsPrimary4;
+ BOOL fRetryCreateSurface;
+
+ /* Privates used by both shadow fb DirectDraw servers */
+ LPDIRECTDRAWCLIPPER pddcPrimary;
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+ /* Privates used by multi-window external window manager */
+ RootlessFrameID widTop;
+ Bool fRestacking;
+#endif
+
+#ifdef XWIN_MULTIWINDOW
+ /* Privates used by multi-window */
+ pthread_t ptWMProc;
+ pthread_t ptXMsgProc;
+ void *pWMInfo;
+#endif
+
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ /* Privates used by both multi-window and rootless */
+ Bool fRootWindowShown;
+#endif
+
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+ /* Privates used for any module running in a seperate thread */
+ pthread_mutex_t pmServerStarted;
+ Bool fServerStarted;
+#endif
+
+ /* Engine specific functions */
+ winAllocateFBProcPtr pwinAllocateFB;
+ winShadowUpdateProcPtr pwinShadowUpdate;
+ winCloseScreenProcPtr pwinCloseScreen;
+ winInitVisualsProcPtr pwinInitVisuals;
+ winAdjustVideoModeProcPtr pwinAdjustVideoMode;
+ winCreateBoundingWindowProcPtr pwinCreateBoundingWindow;
+ winFinishScreenInitProcPtr pwinFinishScreenInit;
+ winBltExposedRegionsProcPtr pwinBltExposedRegions;
+ winActivateAppProcPtr pwinActivateApp;
+ winRedrawScreenProcPtr pwinRedrawScreen;
+ winRealizeInstalledPaletteProcPtr pwinRealizeInstalledPalette;
+ winInstallColormapProcPtr pwinInstallColormap;
+ winStoreColorsProcPtr pwinStoreColors;
+ winCreateColormapProcPtr pwinCreateColormap;
+ winDestroyColormapProcPtr pwinDestroyColormap;
+ winHotKeyAltTabProcPtr pwinHotKeyAltTab;
+ winCreatePrimarySurfaceProcPtr pwinCreatePrimarySurface;
+ winReleasePrimarySurfaceProcPtr pwinReleasePrimarySurface;
+
+ winCreateScreenResourcesProc pwinCreateScreenResources;
+
+#ifdef XWIN_MULTIWINDOW
+ /* Window Procedures for MultiWindow mode */
+ winFinishCreateWindowsWindowProcPtr pwinFinishCreateWindowsWindow;
+#endif
+
+ /* Window Procedures for Rootless mode */
+ CreateWindowProcPtr CreateWindow;
+ DestroyWindowProcPtr DestroyWindow;
+ PositionWindowProcPtr PositionWindow;
+ ChangeWindowAttributesProcPtr ChangeWindowAttributes;
+ RealizeWindowProcPtr RealizeWindow;
+ UnrealizeWindowProcPtr UnrealizeWindow;
+ ValidateTreeProcPtr ValidateTree;
+ PostValidateTreeProcPtr PostValidateTree;
+ WindowExposuresProcPtr WindowExposures;
+ CopyWindowProcPtr CopyWindow;
+ ClearToBackgroundProcPtr ClearToBackground;
+ ClipNotifyProcPtr ClipNotify;
+ RestackWindowProcPtr RestackWindow;
+ ReparentWindowProcPtr ReparentWindow;
+ ResizeWindowProcPtr ResizeWindow;
+ MoveWindowProcPtr MoveWindow;
+ SetShapeProcPtr SetShape;
+
+#ifdef XWIN_NATIVEGDI
+ RealizeFontProcPtr RealizeFont;
+ UnrealizeFontProcPtr UnrealizeFont;
+#endif
+
+ winCursorRec cursor;
+} winPrivScreenRec;
+
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+typedef struct {
+ RootlessWindowPtr pFrame;
+ HWND hWnd;
+ int dwWidthBytes;
+ BITMAPINFOHEADER *pbmihShadow;
+ HBITMAP hbmpShadow;
+ HDC hdcShadow;
+ HDC hdcScreen;
+ BOOL fResized;
+ BOOL fRestackingNow;
+ BOOL fClose;
+ BOOL fMovingOrSizing;
+ BOOL fDestroyed;//for debug
+ char *pfb;
+} win32RootlessWindowRec, *win32RootlessWindowPtr;
+#endif
+
+
+typedef struct {
+ pointer value;
+ XID id;
+} WindowIDPairRec, *WindowIDPairPtr;
+
+
+/*
+ * Extern declares for general global variables
+ */
+
+extern winScreenInfo g_ScreenInfo[];
+extern miPointerScreenFuncRec g_winPointerCursorFuncs;
+extern DWORD g_dwEvents;
+#ifdef HAS_DEVWINDOWS
+extern int g_fdMessageQueue;
+#endif
+extern DevPrivateKey g_iScreenPrivateKey;
+extern DevPrivateKey g_iCmapPrivateKey;
+extern DevPrivateKey g_iGCPrivateKey;
+extern DevPrivateKey g_iPixmapPrivateKey;
+extern DevPrivateKey g_iWindowPrivateKey;
+extern unsigned long g_ulServerGeneration;
+extern DWORD g_dwEnginesSupported;
+extern HINSTANCE g_hInstance;
+extern int g_copyROP[];
+extern int g_patternROP[];
+extern const char * g_pszQueryHost;
+extern DeviceIntPtr g_pwinPointer;
+extern DeviceIntPtr g_pwinKeyboard;
+
+
+/*
+ * Extern declares for dynamically loaded libraries and function pointers
+ */
+
+extern HMODULE g_hmodDirectDraw;
+extern FARPROC g_fpDirectDrawCreate;
+extern FARPROC g_fpDirectDrawCreateClipper;
+
+extern HMODULE g_hmodCommonControls;
+extern FARPROC g_fpTrackMouseEvent;
+
+
+/*
+ * Screen privates macros
+ */
+
+#define winGetScreenPriv(pScreen) ((winPrivScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, g_iScreenPrivateKey))
+
+#define winSetScreenPriv(pScreen,v) \
+ dixSetPrivate(&(pScreen)->devPrivates, g_iScreenPrivateKey, v)
+
+#define winScreenPriv(pScreen) \
+ winPrivScreenPtr pScreenPriv = winGetScreenPriv(pScreen)
+
+
+/*
+ * Colormap privates macros
+ */
+
+#define winGetCmapPriv(pCmap) ((winPrivCmapPtr) \
+ dixLookupPrivate(&(pCmap)->devPrivates, g_iCmapPrivateKey))
+
+#define winSetCmapPriv(pCmap,v) \
+ dixSetPrivate(&(pCmap)->devPrivates, g_iCmapPrivateKey, v)
+
+#define winCmapPriv(pCmap) \
+ winPrivCmapPtr pCmapPriv = winGetCmapPriv(pCmap)
+
+
+/*
+ * GC privates macros
+ */
+
+#define winGetGCPriv(pGC) ((winPrivGCPtr) \
+ dixLookupPrivate(&(pGC)->devPrivates, g_iGCPrivateKey))
+
+#define winSetGCPriv(pGC,v) \
+ dixSetPrivate(&(pGC)->devPrivates, g_iGCPrivateKey, v)
+
+#define winGCPriv(pGC) \
+ winPrivGCPtr pGCPriv = winGetGCPriv(pGC)
+
+
+/*
+ * Pixmap privates macros
+ */
+
+#define winGetPixmapPriv(pPixmap) ((winPrivPixmapPtr) \
+ dixLookupPrivate(&(pPixmap)->devPrivates, g_iPixmapPrivateKey))
+
+#define winSetPixmapPriv(pPixmap,v) \
+ dixLookupPrivate(&(pPixmap)->devPrivates, g_iPixmapPrivateKey, v)
+
+#define winPixmapPriv(pPixmap) \
+ winPrivPixmapPtr pPixmapPriv = winGetPixmapPriv(pPixmap)
+
+
+/*
+ * Window privates macros
+ */
+
+#define winGetWindowPriv(pWin) ((winPrivWinPtr) \
+ dixLookupPrivate(&(pWin)->devPrivates, g_iWindowPrivateKey))
+
+#define winSetWindowPriv(pWin,v) \
+ dixLookupPrivate(&(pWin)->devPrivates, g_iWindowPrivateKey, v)
+
+#define winWindowPriv(pWin) \
+ winPrivWinPtr pWinPriv = winGetWindowPriv(pWin)
+
+/*
+ * wrapper macros
+ */
+#define _WIN_WRAP(priv, real, mem, func) {\
+ priv->mem = real->mem; \
+ real->mem = func; \
+}
+
+#define _WIN_UNWRAP(priv, real, mem) {\
+ real->mem = priv->mem; \
+}
+
+#define WIN_WRAP(mem, func) _WIN_WRAP(pScreenPriv, pScreen, mem, func)
+
+#define WIN_UNWRAP(mem) _WIN_UNWRAP(pScreenPriv, pScreen, mem)
+
+/*
+ * BEGIN DDX and DIX Function Prototypes
+ */
+
+
+/*
+ * winallpriv.c
+ */
+
+Bool
+winAllocatePrivates (ScreenPtr pScreen);
+
+Bool
+winInitCmapPrivates (ColormapPtr pCmap, int index);
+
+Bool
+winAllocateCmapPrivates (ColormapPtr pCmap);
+
+
+/*
+ * winauth.c
+ */
+
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+Bool
+winGenerateAuthorization (void);
+void winSetAuthorization(void);
+#endif
+
+
+/*
+ * winblock.c
+ */
+
+void
+winBlockHandler (int nScreen,
+ pointer pBlockData,
+ pointer pTimeout,
+ pointer pReadMask);
+
+
+#ifdef XWIN_NATIVEGDI
+/*
+ * winclip.c
+ */
+
+RegionPtr
+winPixmapToRegionNativeGDI (PixmapPtr pPix);
+#endif
+
+
+#ifdef XWIN_CLIPBOARD
+/*
+ * winclipboardinit.c
+ */
+
+Bool
+winInitClipboard (void);
+
+void
+winFixClipboardChain (void);
+#endif
+
+
+/*
+ * wincmap.c
+ */
+
+void
+winSetColormapFunctions (ScreenPtr pScreen);
+
+Bool
+winCreateDefColormap (ScreenPtr pScreen);
+
+
+/*
+ * wincreatewnd.c
+ */
+
+Bool
+winCreateBoundingWindowFullScreen (ScreenPtr pScreen);
+
+Bool
+winCreateBoundingWindowWindowed (ScreenPtr pScreen);
+
+
+/*
+ * windialogs.c
+ */
+
+int
+GetLiveClients (winPrivScreenPtr pScreenPriv);
+
+void
+winDisplayExitDialog (winPrivScreenPtr pScreenPriv);
+
+void
+winDisplayDepthChangeDialog (winPrivScreenPtr pScreenPriv);
+
+void
+winDisplayAboutDialog (winPrivScreenPtr pScreenPriv);
+
+
+/*
+ * winengine.c
+ */
+
+void
+winDetectSupportedEngines (void);
+
+Bool
+winSetEngine (ScreenPtr pScreen);
+
+Bool
+winGetDDProcAddresses (void);
+
+
+/*
+ * winerror.c
+ */
+
+#ifdef DDXOSVERRORF
+void
+OSVenderVErrorF (const char *pszFormat, va_list va_args);
+#endif
+
+void
+winMessageBoxF (const char *pszError, UINT uType, ...);
+
+
+#ifdef XWIN_NATIVEGDI
+/*
+ * winfillsp.c
+ */
+
+void
+winFillSpansNativeGDI (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nSpans,
+ DDXPointPtr pPoints,
+ int *pWidths,
+ int fSorted);
+#endif
+
+
+#ifdef XWIN_NATIVEGDI
+/*
+ * winfont.c
+ */
+
+Bool
+winRealizeFontNativeGDI (ScreenPtr pScreen, FontPtr pFont);
+
+Bool
+winUnrealizeFontNativeGDI (ScreenPtr pScreen, FontPtr pFont);
+#endif
+
+
+#ifdef XWIN_NATIVEGDI
+/*
+ * wingc.c
+ */
+
+Bool
+winCreateGCNativeGDI (GCPtr pGC);
+#endif
+
+
+#ifdef XWIN_NATIVEGDI
+/*
+ * wingetsp.c
+ */
+
+void
+winGetSpansNativeGDI (DrawablePtr pDrawable,
+ int wMax,
+ DDXPointPtr pPoints,
+ int *pWidths,
+ int nSpans,
+ char *pDst);
+#endif
+
+
+/*
+ * winglobals.c
+ */
+
+void
+winInitializeGlobals (void);
+
+
+/*
+ * winkeybd.c
+ */
+
+void
+winTranslateKey (WPARAM wParam, LPARAM lParam, int *piScanCode);
+
+int
+winKeybdProc (DeviceIntPtr pDeviceInt, int iState);
+
+void
+winInitializeModeKeyStates (void);
+
+void
+winRestoreModeKeyStates (void);
+
+Bool
+winIsFakeCtrl_L (UINT message, WPARAM wParam, LPARAM lParam);
+
+void
+winKeybdReleaseKeys (void);
+
+void
+winSendKeyEvent (DWORD dwKey, Bool fDown);
+
+BOOL
+winCheckKeyPressed(WPARAM wParam, LPARAM lParam);
+
+void
+winFixShiftKeys (int iScanCode);
+
+/*
+ * winkeyhook.c
+ */
+
+Bool
+winInstallKeyboardHookLL (void);
+
+void
+winRemoveKeyboardHookLL (void);
+
+
+/*
+ * winmisc.c
+ */
+
+#ifdef XWIN_NATIVEGDI
+void
+winQueryBestSizeNativeGDI (int class, unsigned short *pWidth,
+ unsigned short *pHeight, ScreenPtr pScreen);
+#endif
+
+CARD8
+winCountBits (DWORD dw);
+
+Bool
+winUpdateFBPointer (ScreenPtr pScreen, void *pbits);
+
+#ifdef XWIN_NATIVEGDI
+BOOL
+winPaintBackground (HWND hwnd, COLORREF colorref);
+#endif
+
+
+/*
+ * winmouse.c
+ */
+
+int
+winMouseProc (DeviceIntPtr pDeviceInt, int iState);
+
+int
+winMouseWheel (ScreenPtr pScreen, int iDeltaZ);
+
+void
+winMouseButtonsSendEvent (int iEventType, int iButton);
+
+int
+winMouseButtonsHandle (ScreenPtr pScreen,
+ int iEventType, int iButton,
+ WPARAM wParam);
+
+void
+winEnqueueMotion(int x, int y);
+
+#ifdef XWIN_NATIVEGDI
+/*
+ * winnativegdi.c
+ */
+
+HBITMAP
+winCreateDIBNativeGDI (int iWidth, int iHeight, int iDepth,
+ BYTE **ppbBits, BITMAPINFO **ppbmi);
+
+Bool
+winSetEngineFunctionsNativeGDI (ScreenPtr pScreen);
+#endif
+
+
+#ifdef XWIN_PRIMARYFB
+/*
+ * winpfbddd.c
+ */
+
+Bool
+winSetEngineFunctionsPrimaryDD (ScreenPtr pScreen);
+#endif
+
+
+#ifdef XWIN_NATIVEGDI
+/*
+ * winpixmap.c
+ */
+
+PixmapPtr
+winCreatePixmapNativeGDI (ScreenPtr pScreen, int width, int height, int depth,
+ unsigned usage_hint);
+
+Bool
+winDestroyPixmapNativeGDI (PixmapPtr pPixmap);
+
+Bool
+winModifyPixmapHeaderNativeGDI (PixmapPtr pPixmap,
+ int iWidth, int iHeight,
+ int iDepth,
+ int iBitsPerPixel,
+ int devKind,
+ pointer pPixData);
+#endif
+
+#ifdef XWIN_NATIVEGDI
+/*
+ * winpolyline.c
+ */
+
+void
+winPolyLineNativeGDI (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ppt);
+#endif
+
+
+#ifdef XWIN_NATIVEGDI
+/*
+ * winpushpxl.c
+ */
+
+void
+winPushPixels (GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDrawable,
+ int dx, int dy, int xOrg, int yOrg);
+#endif
+
+
+/*
+ * winscrinit.c
+ */
+
+Bool
+winScreenInit (int index,
+ ScreenPtr pScreen,
+ int argc, char **argv);
+
+Bool
+winFinishScreenInitFB (int index,
+ ScreenPtr pScreen,
+ int argc, char **argv);
+
+#if defined(XWIN_NATIVEGDI)
+Bool
+winFinishScreenInitNativeGDI (int index,
+ ScreenPtr pScreen,
+ int argc, char **argv);
+#endif
+
+
+#ifdef XWIN_NATIVEGDI
+/*
+ * winsetsp.c
+ */
+
+void
+winSetSpansNativeGDI (DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *pSrc,
+ DDXPointPtr pPoints,
+ int *pWidth,
+ int nSpans,
+ int fSorted);
+#endif
+
+
+/*
+ * winshaddd.c
+ */
+
+Bool
+winSetEngineFunctionsShadowDD (ScreenPtr pScreen);
+
+
+/*
+ * winshadddnl.c
+ */
+
+Bool
+winSetEngineFunctionsShadowDDNL (ScreenPtr pScreen);
+
+
+/*
+ * winshadgdi.c
+ */
+
+Bool
+winSetEngineFunctionsShadowGDI (ScreenPtr pScreen);
+
+
+/*
+ * winwakeup.c
+ */
+
+void
+winWakeupHandler (int nScreen,
+ pointer pWakeupData,
+ unsigned long ulResult,
+ pointer pReadmask);
+
+
+/*
+ * winwindow.c
+ */
+
+#ifdef XWIN_NATIVEGDI
+Bool
+winCreateWindowNativeGDI (WindowPtr pWin);
+
+Bool
+winDestroyWindowNativeGDI (WindowPtr pWin);
+
+Bool
+winPositionWindowNativeGDI (WindowPtr pWin, int x, int y);
+
+void
+winCopyWindowNativeGDI (WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc);
+
+Bool
+winChangeWindowAttributesNativeGDI (WindowPtr pWin, unsigned long mask);
+
+Bool
+winUnmapWindowNativeGDI (WindowPtr pWindow);
+
+Bool
+winMapWindowNativeGDI (WindowPtr pWindow);
+#endif
+
+Bool
+winCreateWindowRootless (WindowPtr pWindow);
+
+Bool
+winDestroyWindowRootless (WindowPtr pWindow);
+
+Bool
+winPositionWindowRootless (WindowPtr pWindow, int x, int y);
+
+Bool
+winChangeWindowAttributesRootless (WindowPtr pWindow, unsigned long mask);
+
+Bool
+winUnmapWindowRootless (WindowPtr pWindow);
+
+Bool
+winMapWindowRootless (WindowPtr pWindow);
+
+void
+winSetShapeRootless (WindowPtr pWindow);
+
+
+/*
+ * winmultiwindowicons.c - Used by both multi-window and Win32Rootless
+ */
+
+HICON
+winXIconToHICON (WindowPtr pWin, int iconSize);
+
+void
+winSelectIcons(WindowPtr pWin, HICON *pIcon, HICON *pSmallIcon);
+
+#ifdef XWIN_MULTIWINDOW
+/*
+ * winmultiwindowshape.c
+ */
+
+void
+winReshapeMultiWindow (WindowPtr pWin);
+
+void
+winSetShapeMultiWindow (WindowPtr pWindow);
+
+void
+winUpdateRgnMultiWindow (WindowPtr pWindow);
+#endif
+
+
+#ifdef XWIN_MULTIWINDOW
+/*
+ * winmultiwindowwindow.c
+ */
+
+Bool
+winCreateWindowMultiWindow (WindowPtr pWindow);
+
+Bool
+winDestroyWindowMultiWindow (WindowPtr pWindow);
+
+Bool
+winPositionWindowMultiWindow (WindowPtr pWindow, int x, int y);
+
+Bool
+winChangeWindowAttributesMultiWindow (WindowPtr pWindow, unsigned long mask);
+
+Bool
+winUnmapWindowMultiWindow (WindowPtr pWindow);
+
+Bool
+winMapWindowMultiWindow (WindowPtr pWindow);
+
+void
+winReparentWindowMultiWindow (WindowPtr pWin, WindowPtr pPriorParent);
+
+void
+winRestackWindowMultiWindow (WindowPtr pWin, WindowPtr pOldNextSib);
+
+void
+winReorderWindowsMultiWindow (void);
+
+void
+winResizeWindowMultiWindow (WindowPtr pWin, int x, int y, unsigned int w,
+ unsigned int h, WindowPtr pSib);
+void
+winMoveWindowMultiWindow (WindowPtr pWin, int x, int y,
+ WindowPtr pSib, VTKind kind);
+
+void
+winCopyWindowMultiWindow (WindowPtr pWin, DDXPointRec oldpt,
+ RegionPtr oldRegion);
+
+XID
+winGetWindowID (WindowPtr pWin);
+
+int
+winAdjustXWindow (WindowPtr pWin, HWND hwnd);
+#endif
+
+
+#ifdef XWIN_MULTIWINDOW
+/*
+ * winmultiwindowwndproc.c
+ */
+
+LRESULT CALLBACK
+winTopLevelWindowProc (HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam);
+#endif
+
+
+/*
+ * wintrayicon.c
+ */
+
+void
+winInitNotifyIcon (winPrivScreenPtr pScreenPriv, Bool Modify);
+
+void
+winDeleteNotifyIcon (winPrivScreenPtr pScreenPriv);
+
+LRESULT
+winHandleIconMessage (HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam,
+ winPrivScreenPtr pScreenPriv);
+
+
+/*
+ * winwndproc.c
+ */
+
+LRESULT CALLBACK
+winWindowProc (HWND hWnd, UINT message,
+ WPARAM wParam, LPARAM lParam);
+
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+/*
+ * winwin32rootless.c
+ */
+
+Bool
+winMWExtWMCreateFrame (RootlessWindowPtr pFrame, ScreenPtr pScreen,
+ int newX, int newY, RegionPtr pShape);
+
+void
+winMWExtWMDestroyFrame (RootlessFrameID wid);
+
+void
+winMWExtWMMoveFrame (RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY);
+
+void
+winMWExtWMResizeFrame (RootlessFrameID wid, ScreenPtr pScreen,
+ int newX, int newY, unsigned int newW, unsigned int newH,
+ unsigned int gravity);
+
+void
+winMWExtWMRestackFrame (RootlessFrameID wid, RootlessFrameID nextWid);
+
+void
+winMWExtWMReshapeFrame (RootlessFrameID wid, RegionPtr pShape);
+
+void
+winMWExtWMUnmapFrame (RootlessFrameID wid);
+
+void
+winMWExtWMStartDrawing (RootlessFrameID wid, char **pixelData, int *bytesPerRow);
+
+void
+winMWExtWMStopDrawing (RootlessFrameID wid, Bool flush);
+
+void
+winMWExtWMUpdateRegion (RootlessFrameID wid, RegionPtr pDamage);
+
+void
+winMWExtWMDamageRects (RootlessFrameID wid, int count, const BoxRec *rects,
+ int shift_x, int shift_y);
+
+void
+winMWExtWMRootlessSwitchWindow (RootlessWindowPtr pFrame, WindowPtr oldWin);
+
+void
+winMWExtWMCopyBytes (unsigned int width, unsigned int height,
+ const void *src, unsigned int srcRowBytes,
+ void *dst, unsigned int dstRowBytes);
+
+void
+winMWExtWMFillBytes (unsigned int width, unsigned int height, unsigned int value,
+ void *dst, unsigned int dstRowBytes);
+
+int
+winMWExtWMCompositePixels (unsigned int width, unsigned int height, unsigned int function,
+ void *src[2], unsigned int srcRowBytes[2],
+ void *mask, unsigned int maskRowBytes,
+ void *dst[2], unsigned int dstRowBytes[2]);
+
+void
+winMWExtWMCopyWindow (RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
+ int dx, int dy);
+#endif
+
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+/*
+ * winwin32rootlesswindow.c
+ */
+
+void
+winMWExtWMReorderWindows (ScreenPtr pScreen);
+
+void
+winMWExtWMMoveXWindow (WindowPtr pWin, int x, int y);
+
+void
+winMWExtWMResizeXWindow (WindowPtr pWin, int w, int h);
+
+void
+winMWExtWMMoveResizeXWindow (WindowPtr pWin, int x, int y, int w, int h);
+
+void
+winMWExtWMUpdateIcon (Window id);
+
+void
+winMWExtWMUpdateWindowDecoration (win32RootlessWindowPtr pRLWinPriv,
+ winScreenInfoPtr pScreenInfo);
+
+wBOOL CALLBACK
+winMWExtWMDecorateWindow (HWND hwnd, LPARAM lParam);
+
+Bool
+winIsInternalWMRunning (winScreenInfoPtr pScreenInfo);
+
+void
+winMWExtWMRestackWindows (ScreenPtr pScreen);
+#endif
+
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+/*
+ * winwin32rootlesswndproc.c
+ */
+
+LRESULT CALLBACK
+winMWExtWMWindowProc (HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam);
+#endif
+
+
+/*
+ * winwindowswm.c
+ */
+
+void
+winWindowsWMSendEvent (int type, unsigned int mask, int which, int arg,
+ Window window, int x, int y, int w, int h);
+
+void
+winWindowsWMExtensionInit (void);
+
+/*
+ * wincursor.c
+ */
+
+Bool
+winInitCursor (ScreenPtr pScreen);
+
+/*
+ * END DDX and DIX Function Prototypes
+ */
+
+#endif /* _WIN_H_ */
+
diff --git a/xorg-server/hw/xwin/winallpriv.c b/xorg-server/hw/xwin/winallpriv.c
index 21ccd9b3b..3413ece53 100644
--- a/xorg-server/hw/xwin/winallpriv.c
+++ b/xorg-server/hw/xwin/winallpriv.c
@@ -48,11 +48,9 @@ winAllocatePrivates (ScreenPtr pScreen)
{
winPrivScreenPtr pScreenPriv;
-#if CYGDEBUG
winDebug ("winAllocateScreenPrivates - g_ulServerGeneration: %d "
"serverGeneration: %d\n",
g_ulServerGeneration, serverGeneration);
-#endif
/* We need a new slot for our privates if the screen gen has changed */
if (g_ulServerGeneration != serverGeneration)
@@ -111,9 +109,7 @@ winAllocatePrivates (ScreenPtr pScreen)
Bool
winInitCmapPrivates (ColormapPtr pcmap, int index)
{
-#if CYGDEBUG
winDebug ("winInitCmapPrivates\n");
-#endif
/*
* I see no way that this function can do anything useful
@@ -139,9 +135,7 @@ winAllocateCmapPrivates (ColormapPtr pCmap)
winPrivCmapPtr pCmapPriv;
static unsigned long s_ulPrivateGeneration = 0;
-#if CYGDEBUG
winDebug ("winAllocateCmapPrivates\n");
-#endif
/* Get a new privates index when the server generation changes */
if (s_ulPrivateGeneration != serverGeneration)
@@ -164,9 +158,7 @@ winAllocateCmapPrivates (ColormapPtr pCmap)
/* Save the cmap private pointer */
winSetCmapPriv (pCmap, pCmapPriv);
-#if CYGDEBUG
winDebug ("winAllocateCmapPrivates - Returning\n");
-#endif
return TRUE;
}
diff --git a/xorg-server/hw/xwin/winauth.c b/xorg-server/hw/xwin/winauth.c
index fcd1872da..fca6da086 100644
--- a/xorg-server/hw/xwin/winauth.c
+++ b/xorg-server/hw/xwin/winauth.c
@@ -1,202 +1,215 @@
-/*
- *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, 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 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 HAROLD L HUNT II 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 Harold L Hunt II
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from Harold L Hunt II.
- *
- * Authors: Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-
-#include "win.h"
-
-/* Includes for authorization */
-#include "securitysrv.h"
-
-
-/*
- * Constants
- */
-
-#define AUTH_NAME "MIT-MAGIC-COOKIE-1"
-
-
-/*
- * Locals
- */
-
-static XID g_authId = 0;
-static unsigned int g_uiAuthDataLen = 0;
-static char *g_pAuthData = NULL;
-
-/*
- * Code to generate a MIT-MAGIC-COOKIE-1, copied from under XCSECURITY
- */
-
-#ifndef XCSECURITY
-static
-void
-GenerateRandomData (int len, char *buf)
-{
- int fd;
-
- fd = open("/dev/urandom", O_RDONLY);
- read(fd, buf, len);
- close(fd);
-}
-
-
-static char cookie[16]; /* 128 bits */
-
-XID
-static MitGenerateCookie (
- unsigned data_length,
- char *data,
- XID id,
- unsigned *data_length_return,
- char **data_return)
-{
- int i = 0;
- int status;
-
- while (data_length--)
- {
- cookie[i++] += *data++;
- if (i >= sizeof (cookie)) i = 0;
- }
- GenerateRandomData(sizeof (cookie), cookie);
- status = MitAddCookie(sizeof (cookie), cookie, id);
- if (!status)
- {
- id = -1;
- }
- else
- {
- *data_return = cookie;
- *data_length_return = sizeof (cookie);
- }
- return id;
-}
-
-static
-XID
-GenerateAuthorization(
- unsigned name_length,
- char *name,
- unsigned data_length,
- char *data,
- unsigned *data_length_return,
- char **data_return)
-{
- return MitGenerateCookie(data_length, data,
- FakeClientID(0), data_length_return, data_return);
-}
-#endif
-
-/*
- * Generate authorization cookie for internal server clients
- */
-
-Bool
-winGenerateAuthorization ()
-{
- Bool fFreeAuth = FALSE;
- SecurityAuthorizationPtr pAuth = NULL;
-
- /* Call OS layer to generate authorization key */
- g_authId = GenerateAuthorization (strlen (AUTH_NAME),
- AUTH_NAME,
- 0,
- NULL,
- &g_uiAuthDataLen,
- &g_pAuthData);
- if ((XID) ~0L == g_authId)
- {
- ErrorF ("winGenerateAuthorization - GenerateAuthorization failed\n");
- goto auth_bailout;
- }
-
- else
- {
- winDebug("winGenerateAuthorization - GenerateAuthorization success!\n"
- "AuthDataLen: %d AuthData: %s\n",
- g_uiAuthDataLen, g_pAuthData);
- }
-
-#ifdef XCSECURITY
- /* Allocate structure for additional auth information */
- pAuth = (SecurityAuthorizationPtr)
- xalloc (sizeof (SecurityAuthorizationRec));
- if (!(pAuth))
- {
- ErrorF ("winGenerateAuthorization - Failed allocating "
- "SecurityAuthorizationPtr.\n");
- goto auth_bailout;
- }
-
- /* Fill in the auth fields */
- pAuth->id = g_authId;
- pAuth->timeout = 0; /* live for x seconds after refcnt == 0 */
- pAuth->group = None;
- pAuth->trustLevel = XSecurityClientTrusted;
- pAuth->refcnt = 1; /* this auth must stick around */
- pAuth->secondsRemaining = 0;
- pAuth->timer = NULL;
- pAuth->eventClients = NULL;
-
- /* Add the authorization to the server's auth list */
- if (!AddResource (g_authId,
- SecurityAuthorizationResType,
- pAuth))
- {
- ErrorF ("winGenerateAuthorization - AddResource failed for auth.\n");
- fFreeAuth = TRUE;
- goto auth_bailout;
- }
-
- /* Don't free the auth data, since it is still used internally */
- pAuth = NULL;
-#endif
-
- return TRUE;
-
- auth_bailout:
- if (fFreeAuth)
- xfree (pAuth);
-
- return FALSE;
-}
-
-/* Use our generated cookie for authentication */
-void
-winSetAuthorization(void)
-{
- XSetAuthorization (AUTH_NAME,
- strlen (AUTH_NAME),
- g_pAuthData,
- g_uiAuthDataLen);
-}
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, 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 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 HAROLD L HUNT II 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 Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+
+#include "win.h"
+
+/* Includes for authorization */
+#include "securitysrv.h"
+
+/*
+ * Constants
+ */
+
+#define AUTH_NAME "MIT-MAGIC-COOKIE-1"
+
+
+/*
+ * Locals
+ */
+
+static XID g_authId = 0;
+static unsigned int g_uiAuthDataLen = 0;
+static char *g_pAuthData = NULL;
+
+/*
+ * Code to generate a MIT-MAGIC-COOKIE-1, copied from under XCSECURITY
+ */
+
+
+
+#ifndef XCSECURITY
+static
+void
+GenerateRandomData (int len, char *buf)
+{
+ int fd;
+#ifdef _MSC_VER
+ static HANDLE hAdvApi32;
+ static BOOLEAN (_stdcall * RtlGenRandom)(void *,unsigned long);
+
+ if (!hAdvApi32)
+ {
+ hAdvApi32=LoadLibrary("advapi32.dll");
+ RtlGenRandom=(BOOLEAN (_stdcall *)(void*,unsigned long))GetProcAddress(hAdvApi32,"SystemFunction036");
+ }
+ RtlGenRandom(buf, len);
+#else
+ fd = open("/dev/urandom", O_RDONLY);
+ read(fd, buf, len);
+ close(fd);
+#endif
+}
+
+
+static char cookie[16]; /* 128 bits */
+
+XID
+static MitGenerateCookie (
+ unsigned data_length,
+ char *data,
+ XID id,
+ unsigned *data_length_return,
+ char **data_return)
+{
+ int i = 0;
+ int status;
+
+ while (data_length--)
+ {
+ cookie[i++] += *data++;
+ if (i >= sizeof (cookie)) i = 0;
+ }
+ GenerateRandomData(sizeof (cookie), cookie);
+ status = MitAddCookie(sizeof (cookie), cookie, id);
+ if (!status)
+ {
+ id = -1;
+ }
+ else
+ {
+ *data_return = cookie;
+ *data_length_return = sizeof (cookie);
+ }
+ return id;
+}
+
+static
+XID
+GenerateAuthorization(
+ unsigned name_length,
+ char *name,
+ unsigned data_length,
+ char *data,
+ unsigned *data_length_return,
+ char **data_return)
+{
+ return MitGenerateCookie(data_length, data,
+ FakeClientID(0), data_length_return, data_return);
+}
+#endif
+
+/*
+ * Generate authorization cookie for internal server clients
+ */
+
+Bool
+winGenerateAuthorization ()
+{
+ Bool fFreeAuth = FALSE;
+ SecurityAuthorizationPtr pAuth = NULL;
+
+ /* Call OS layer to generate authorization key */
+ g_authId = GenerateAuthorization (strlen (AUTH_NAME),
+ AUTH_NAME,
+ 0,
+ NULL,
+ &g_uiAuthDataLen,
+ &g_pAuthData);
+ if ((XID) ~0L == g_authId)
+ {
+ ErrorF ("winGenerateAuthorization - GenerateAuthorization failed\n");
+ goto auth_bailout;
+ }
+#ifdef WINDBG
+ else
+ {
+ winDebug("winGenerateAuthorization - GenerateAuthorization success!\n"
+ "AuthDataLen: %d AuthData: %s\n",
+ g_uiAuthDataLen, g_pAuthData);
+ }
+#endif
+
+#ifdef XCSECURITY
+ /* Allocate structure for additional auth information */
+ pAuth = (SecurityAuthorizationPtr)
+ xalloc (sizeof (SecurityAuthorizationRec));
+ if (!(pAuth))
+ {
+ ErrorF ("winGenerateAuthorization - Failed allocating "
+ "SecurityAuthorizationPtr.\n");
+ goto auth_bailout;
+ }
+
+ /* Fill in the auth fields */
+ pAuth->id = g_authId;
+ pAuth->timeout = 0; /* live for x seconds after refcnt == 0 */
+ pAuth->group = None;
+ pAuth->trustLevel = XSecurityClientTrusted;
+ pAuth->refcnt = 1; /* this auth must stick around */
+ pAuth->secondsRemaining = 0;
+ pAuth->timer = NULL;
+ pAuth->eventClients = NULL;
+
+ /* Add the authorization to the server's auth list */
+ if (!AddResource (g_authId,
+ SecurityAuthorizationResType,
+ pAuth))
+ {
+ ErrorF ("winGenerateAuthorization - AddResource failed for auth.\n");
+ fFreeAuth = TRUE;
+ goto auth_bailout;
+ }
+
+ /* Don't free the auth data, since it is still used internally */
+ pAuth = NULL;
+#endif
+
+ return TRUE;
+
+ auth_bailout:
+ if (fFreeAuth)
+ xfree (pAuth);
+
+ return FALSE;
+}
+
+/* Use our generated cookie for authentication */
+void
+winSetAuthorization(void)
+{
+ XSetAuthorization (AUTH_NAME,
+ strlen (AUTH_NAME),
+ g_pAuthData,
+ g_uiAuthDataLen);
+}
diff --git a/xorg-server/hw/xwin/winclip.c b/xorg-server/hw/xwin/winclip.c
index aab7d632d..cbbf08c59 100644
--- a/xorg-server/hw/xwin/winclip.c
+++ b/xorg-server/hw/xwin/winclip.c
@@ -37,6 +37,6 @@
RegionPtr
winPixmapToRegionNativeGDI (PixmapPtr pPix)
{
- ErrorF ("winPixmapToRegion()\n");
+ winDebug ("winPixmapToRegion()\n");
return NULL;
}
diff --git a/xorg-server/hw/xwin/winclipboard.h b/xorg-server/hw/xwin/winclipboard.h
index 089c2913b..9bf7c9c0e 100644
--- a/xorg-server/hw/xwin/winclipboard.h
+++ b/xorg-server/hw/xwin/winclipboard.h
@@ -34,7 +34,9 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
+#ifndef _MSC_VER
#include <unistd.h>
+#endif
#ifdef __CYGWIN__
#include <sys/select.h>
#else
@@ -43,6 +45,9 @@
#endif
#include <fcntl.h>
#include <setjmp.h>
+#ifdef _MSC_VER
+typedef int pid_t;
+#endif
#include <pthread.h>
/* X headers */
@@ -74,15 +79,13 @@
#define WM_WM_REINIT (WM_USER + 1)
+#include "winmsg.h"
+
/*
* References to external symbols
*/
extern char *display;
-extern void ErrorF (const char* /*f*/, ...);
-extern void winDebug (const char *format, ...);
-extern void winErrorFVerb (int verb, const char *format, ...);
-
/*
* winclipboardinit.c
@@ -145,5 +148,6 @@ int
winClipboardFlushXEvents (HWND hwnd,
int iWindow,
Display *pDisplay,
- Bool fUnicodeSupport);
+ Bool fUnicodeSupport,
+ Bool ClipboardOpened);
#endif
diff --git a/xorg-server/hw/xwin/winclipboardinit.c b/xorg-server/hw/xwin/winclipboardinit.c
index bec63ac8e..d451314fb 100644
--- a/xorg-server/hw/xwin/winclipboardinit.c
+++ b/xorg-server/hw/xwin/winclipboardinit.c
@@ -61,7 +61,7 @@ extern HWND g_hwndClipboard;
Bool
winInitClipboard (void)
{
- ErrorF ("winInitClipboard ()\n");
+ winDebug ("winInitClipboard ()\n");
/* Wrap some internal server functions */
if (ProcVector[X_SetSelectionOwner] != winProcSetSelectionOwner)
diff --git a/xorg-server/hw/xwin/winclipboardtextconv.c b/xorg-server/hw/xwin/winclipboardtextconv.c
index 400f560fa..487df81ef 100644
--- a/xorg-server/hw/xwin/winclipboardtextconv.c
+++ b/xorg-server/hw/xwin/winclipboardtextconv.c
@@ -1,155 +1,155 @@
-/*
- *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, 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 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 HAROLD L HUNT II 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 Harold L Hunt II
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from Harold L Hunt II.
- *
- * Authors: Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-void
-winClipboardDOStoUNIX (char *pszSrc, int iLength);
-void
-winClipboardUNIXtoDOS (unsigned char **ppszData, int iLength);
-
-/*
- * Convert \r\n to \n
- *
- * NOTE: This was heavily inspired by, Cygwin's
- * winsup/cygwin/fhandler.cc/fhandler_base::read ()
- */
-
-void
-winClipboardDOStoUNIX (char *pszSrc, int iLength)
-{
- char *pszDest = pszSrc;
- char *pszEnd = pszSrc + iLength;
-
- /* Loop until the last character */
- while (pszSrc < pszEnd)
- {
- /* Copy the current source character to current destination character */
- *pszDest = *pszSrc;
-
- /* Advance to the next source character */
- pszSrc++;
-
- /* Don't advance the destination character if we need to drop an \r */
- if (*pszDest != '\r' || *pszSrc != '\n')
- pszDest++;
- }
-
- /* Move the terminating null */
- *pszDest = '\0';
-}
-
-
-/*
- * Convert \n to \r\n
- */
-
-void
-winClipboardUNIXtoDOS (unsigned char **ppszData, int iLength)
-{
- int iNewlineCount = 0;
- unsigned char *pszSrc = *ppszData;
- unsigned char *pszEnd = pszSrc + iLength;
- unsigned char *pszDest = NULL, *pszDestBegin = NULL;
-
- winDebug("UNIXtoDOS () - Original data:'%s'\n", *ppszData);
-
- /* Count \n characters without leading \r */
- while (pszSrc < pszEnd)
- {
- /* Skip ahead two character if found set of \r\n */
- if (*pszSrc == '\r' && pszSrc + 1 < pszEnd && *(pszSrc + 1) == '\n')
- {
- pszSrc += 2;
- continue;
- }
-
- /* Increment the count if found naked \n */
- if (*pszSrc == '\n')
- {
- iNewlineCount++;
- }
-
- pszSrc++;
- }
-
- /* Return if no naked \n's */
- if (iNewlineCount == 0)
- return;
-
- /* Allocate a new string */
- pszDestBegin = pszDest = malloc (iLength + iNewlineCount + 1);
-
- /* Set source pointer to beginning of data string */
- pszSrc = *ppszData;
-
- /* Loop through all characters in source string */
- while (pszSrc < pszEnd)
- {
- /* Copy line endings that are already valid */
- if (*pszSrc == '\r' && pszSrc + 1 < pszEnd && *(pszSrc + 1) == '\n')
- {
- *pszDest = *pszSrc;
- *(pszDest + 1) = *(pszSrc + 1);
- pszDest += 2;
- pszSrc += 2;
- continue;
- }
-
- /* Add \r to naked \n's */
- if (*pszSrc == '\n')
- {
- *pszDest = '\r';
- *(pszDest + 1) = *pszSrc;
- pszDest += 2;
- pszSrc += 1;
- continue;
- }
-
- /* Copy normal characters */
- *pszDest = *pszSrc;
- pszSrc++;
- pszDest++;
- }
-
- /* Put terminating null at end of new string */
- *pszDest = '\0';
-
- /* Swap string pointers */
- free (*ppszData);
- *ppszData = pszDestBegin;
-
- winDebug("UNIXtoDOS () - Final string:'%s'\n", pszDestBegin);
-}
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, 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 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 HAROLD L HUNT II 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 Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+void
+winClipboardDOStoUNIX (char *pszSrc, int iLength);
+void
+winClipboardUNIXtoDOS (unsigned char **ppszData, int iLength);
+
+/*
+ * Convert \r\n to \n
+ *
+ * NOTE: This was heavily inspired by, Cygwin's
+ * winsup/cygwin/fhandler.cc/fhandler_base::read ()
+ */
+
+void
+winClipboardDOStoUNIX (char *pszSrc, int iLength)
+{
+ char *pszDest = pszSrc;
+ char *pszEnd = pszSrc + iLength;
+
+ /* Loop until the last character */
+ while (pszSrc < pszEnd)
+ {
+ /* Copy the current source character to current destination character */
+ *pszDest = *pszSrc;
+
+ /* Advance to the next source character */
+ pszSrc++;
+
+ /* Don't advance the destination character if we need to drop an \r */
+ if (*pszDest != '\r' || *pszSrc != '\n')
+ pszDest++;
+ }
+
+ /* Move the terminating null */
+ *pszDest = '\0';
+}
+
+
+/*
+ * Convert \n to \r\n
+ */
+
+void
+winClipboardUNIXtoDOS (unsigned char **ppszData, int iLength)
+{
+ int iNewlineCount = 0;
+ unsigned char *pszSrc = *ppszData;
+ unsigned char *pszEnd = pszSrc + iLength;
+ unsigned char *pszDest = NULL, *pszDestBegin = NULL;
+
+ winDebug("UNIXtoDOS () - Original data:'%s'\n", *ppszData);
+
+ /* Count \n characters without leading \r */
+ while (pszSrc < pszEnd)
+ {
+ /* Skip ahead two character if found set of \r\n */
+ if (*pszSrc == '\r' && pszSrc + 1 < pszEnd && *(pszSrc + 1) == '\n')
+ {
+ pszSrc += 2;
+ continue;
+ }
+
+ /* Increment the count if found naked \n */
+ if (*pszSrc == '\n')
+ {
+ iNewlineCount++;
+ }
+
+ pszSrc++;
+ }
+
+ /* Return if no naked \n's */
+ if (iNewlineCount == 0)
+ return;
+
+ /* Allocate a new string */
+ pszDestBegin = pszDest = malloc (iLength + iNewlineCount + 1);
+
+ /* Set source pointer to beginning of data string */
+ pszSrc = *ppszData;
+
+ /* Loop through all characters in source string */
+ while (pszSrc < pszEnd)
+ {
+ /* Copy line endings that are already valid */
+ if (*pszSrc == '\r' && pszSrc + 1 < pszEnd && *(pszSrc + 1) == '\n')
+ {
+ *pszDest = *pszSrc;
+ *(pszDest + 1) = *(pszSrc + 1);
+ pszDest += 2;
+ pszSrc += 2;
+ continue;
+ }
+
+ /* Add \r to naked \n's */
+ if (*pszSrc == '\n')
+ {
+ *pszDest = '\r';
+ *(pszDest + 1) = *pszSrc;
+ pszDest += 2;
+ pszSrc += 1;
+ continue;
+ }
+
+ /* Copy normal characters */
+ *pszDest = *pszSrc;
+ pszSrc++;
+ pszDest++;
+ }
+
+ /* Put terminating null at end of new string */
+ *pszDest = '\0';
+
+ /* Swap string pointers */
+ free (*ppszData);
+ *ppszData = pszDestBegin;
+
+ winDebug("UNIXtoDOS () - Final string:'%s'\n", pszDestBegin);
+}
diff --git a/xorg-server/hw/xwin/winclipboardthread.c b/xorg-server/hw/xwin/winclipboardthread.c
index e5b2dc1e0..80381ac51 100644
--- a/xorg-server/hw/xwin/winclipboardthread.c
+++ b/xorg-server/hw/xwin/winclipboardthread.c
@@ -1,463 +1,502 @@
-/*
- *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
- *Copyright (C) Colin Harrison 2005-2008
- *
- *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, 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 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 HAROLD L HUNT II 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 copyright holder(s)
- *and author(s) 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 copyright holder(s) and author(s).
- *
- * Authors: Harold L Hunt II
- * Colin Harrison
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include <sys/types.h>
-#include "winclipboard.h"
-#ifdef __CYGWIN__
-#include <errno.h>
-#endif
-#include "misc.h"
-
-
-/*
- * References to external symbols
- */
-
-extern Bool g_fUnicodeClipboard;
-extern unsigned long serverGeneration;
-extern Bool g_fClipboardStarted;
-extern HWND g_hwndClipboard;
-extern void *g_pClipboardDisplay;
-extern Window g_iClipboardWindow;
-
-
-/*
- * Global variables
- */
-
-static jmp_buf g_jmpEntry;
-Bool g_fUnicodeSupport = FALSE;
-Bool g_fUseUnicode = FALSE;
-
-
-/*
- * Local function prototypes
- */
-
-static int
-winClipboardErrorHandler (Display *pDisplay, XErrorEvent *pErr);
-
-static int
-winClipboardIOErrorHandler (Display *pDisplay);
-
-
-/*
- * Main thread function
- */
-
-void *
-winClipboardProc (void *pvNotUsed)
-{
- Atom atomClipboard, atomClipboardManager;
- int iReturn;
- HWND hwnd = NULL;
- int iConnectionNumber = 0;
-#ifdef HAS_DEVWINDOWS
- int fdMessageQueue = 0;
-#else
- struct timeval tvTimeout;
-#endif
- fd_set fdsRead;
- int iMaxDescriptor;
- Display *pDisplay = NULL;
- Window iWindow = None;
- int iRetries;
- Bool fUseUnicode;
- char szDisplay[512];
- int iSelectError;
-
- ErrorF ("winClipboardProc - Hello\n");
-
- /* Do we have Unicode support? */
- g_fUnicodeSupport = winClipboardDetectUnicodeSupport ();
-
- /* Do we use Unicode clipboard? */
- fUseUnicode = g_fUnicodeClipboard && g_fUnicodeSupport;
-
- /* Save the Unicode support flag in a global */
- g_fUseUnicode = fUseUnicode;
-
- /* Allow multiple threads to access Xlib */
- if (XInitThreads () == 0)
- {
- ErrorF ("winClipboardProc - XInitThreads failed.\n");
- pthread_exit (NULL);
- }
-
- /* See if X supports the current locale */
- if (XSupportsLocale () == False)
- {
- ErrorF ("winClipboardProc - Locale not supported by X. Exiting.\n");
- pthread_exit (NULL);
- }
-
- /* Set jump point for Error exits */
- iReturn = setjmp (g_jmpEntry);
-
- /* Check if we should continue operations */
- if (iReturn != WIN_JMP_ERROR_IO
- && iReturn != WIN_JMP_OKAY)
- {
- /* setjmp returned an unknown value, exit */
- ErrorF ("winClipboardProc - setjmp returned: %d exiting\n",
- iReturn);
- pthread_exit (NULL);
- }
- else if (iReturn == WIN_JMP_ERROR_IO)
- {
- /* TODO: Cleanup the Win32 window and free any allocated memory */
- ErrorF ("winClipboardProc - setjmp returned for IO Error Handler.\n");
- pthread_exit (NULL);
- }
-
- /* Use our generated cookie for authentication */
- winSetAuthorization();
-
- /* Set error handler */
- XSetErrorHandler (winClipboardErrorHandler);
- XSetIOErrorHandler (winClipboardIOErrorHandler);
-
- /* Initialize retry count */
- iRetries = 0;
-
- /* Setup the display connection string x */
- /*
- * NOTE: Always connect to screen 0 since we require that screen
- * numbers start at 0 and increase without gaps. We only need
- * to connect to one screen on the display to get events
- * for all screens on the display. That is why there is only
- * one clipboard client thread.
- */
- snprintf (szDisplay,
- 512,
- "127.0.0.1:%s.0",
- display);
-
- /* Print the display connection string */
- ErrorF ("winClipboardProc - DISPLAY=%s\n", szDisplay);
-
- /* Open the X display */
- do
- {
- pDisplay = XOpenDisplay (szDisplay);
- if (pDisplay == NULL)
- {
- ErrorF ("winClipboardProc - Could not open display, "
- "try: %d, sleeping: %d\n",
- iRetries + 1, WIN_CONNECT_DELAY);
- ++iRetries;
- sleep (WIN_CONNECT_DELAY);
- continue;
- }
- else
- break;
- }
- while (pDisplay == NULL && iRetries < WIN_CONNECT_RETRIES);
-
- /* Make sure that the display opened */
- if (pDisplay == NULL)
- {
- ErrorF ("winClipboardProc - Failed opening the display, giving up\n");
- pthread_exit (NULL);
- }
-
- /* Save the display in the screen privates */
- g_pClipboardDisplay = pDisplay;
-
- ErrorF ("winClipboardProc - XOpenDisplay () returned and "
- "successfully opened the display.\n");
-
- /* Get our connection number */
- iConnectionNumber = ConnectionNumber (pDisplay);
-
-#ifdef HAS_DEVWINDOWS
- /* Open a file descriptor for the windows message queue */
- fdMessageQueue = open (WIN_MSG_QUEUE_FNAME, O_RDONLY);
- if (fdMessageQueue == -1)
- {
- ErrorF ("winClipboardProc - Failed opening %s\n", WIN_MSG_QUEUE_FNAME);
- pthread_exit (NULL);
- }
-
- /* Find max of our file descriptors */
- iMaxDescriptor = max (fdMessageQueue, iConnectionNumber) + 1;
-#else
- iMaxDescriptor = iConnectionNumber + 1;
-#endif
-
- /* Create atoms */
- atomClipboard = XInternAtom (pDisplay, "CLIPBOARD", False);
- atomClipboardManager = XInternAtom (pDisplay, "CLIPBOARD_MANAGER", False);
-
- /* Create a messaging window */
- iWindow = XCreateSimpleWindow (pDisplay,
- DefaultRootWindow (pDisplay),
- 1, 1,
- 500, 500,
- 0,
- BlackPixel (pDisplay, 0),
- BlackPixel (pDisplay, 0));
- if (iWindow == 0)
- {
- ErrorF ("winClipboardProc - Could not create an X window.\n");
- pthread_exit (NULL);
- }
-
- /* Select event types to watch */
- if (XSelectInput (pDisplay,
- iWindow,
- PropertyChangeMask) == BadWindow)
- ErrorF ("winClipboardProc - XSelectInput generated BadWindow "
- "on messaging window\n");
-
- /* Save the window in the screen privates */
- g_iClipboardWindow = iWindow;
-
- /* Create Windows messaging window */
- hwnd = winClipboardCreateMessagingWindow ();
-
- /* Save copy of HWND in screen privates */
- g_hwndClipboard = hwnd;
-
- /* Assert ownership of selections if Win32 clipboard is owned */
- if (NULL != GetClipboardOwner ())
- {
- /* PRIMARY */
- iReturn = XSetSelectionOwner (pDisplay, XA_PRIMARY,
- iWindow, CurrentTime);
- if (iReturn == BadAtom || iReturn == BadWindow ||
- XGetSelectionOwner (pDisplay, XA_PRIMARY) != iWindow)
- {
- ErrorF ("winClipboardProc - Could not set PRIMARY owner\n");
- pthread_exit (NULL);
- }
-
- /* CLIPBOARD */
- iReturn = XSetSelectionOwner (pDisplay, atomClipboard,
- iWindow, CurrentTime);
- if (iReturn == BadAtom || iReturn == BadWindow ||
- XGetSelectionOwner (pDisplay, atomClipboard) != iWindow)
- {
- ErrorF ("winClipboardProc - Could not set CLIPBOARD owner\n");
- pthread_exit (NULL);
- }
- }
-
- /* Pre-flush X events */
- /*
- * NOTE: Apparently you'll freeze if you don't do this,
- * because there may be events in local data structures
- * already.
- */
- winClipboardFlushXEvents (hwnd,
- iWindow,
- pDisplay,
- fUseUnicode);
-
- /* Pre-flush Windows messages */
- if (!winClipboardFlushWindowsMessageQueue (hwnd))
- return 0;
-
- /* Signal that the clipboard client has started */
- g_fClipboardStarted = TRUE;
-
- /* Loop for X events */
- while (1)
- {
- /* Setup the file descriptor set */
- /*
- * NOTE: You have to do this before every call to select
- * because select modifies the mask to indicate
- * which descriptors are ready.
- */
- FD_ZERO (&fdsRead);
- FD_SET (iConnectionNumber, &fdsRead);
-#ifdef HAS_DEVWINDOWS
- FD_SET (fdMessageQueue, &fdsRead);
-#else
- tvTimeout.tv_sec = 0;
- tvTimeout.tv_usec = 100;
-#endif
-
- /* Wait for a Windows event or an X event */
- iReturn = select (iMaxDescriptor, /* Highest fds number */
- &fdsRead, /* Read mask */
- NULL, /* No write mask */
- NULL, /* No exception mask */
-#ifdef HAS_DEVWINDOWS
- NULL /* No timeout */
-#else
- &tvTimeout /* Set timeout */
-#endif
- );
-
-#ifndef HAS_WINSOCK
- iSelectError = errno;
-#else
- iSelectError = WSAGetLastError();
-#endif
-
- if (iReturn < 0)
- {
-#ifndef HAS_WINSOCK
- if (iSelectError == EINTR)
-#else
- if (iSelectError == WSAEINTR)
-#endif
- continue;
-
- ErrorF ("winClipboardProc - Call to select () failed: %d. "
- "Bailing.\n", iReturn);
- break;
- }
-
- /* Branch on which descriptor became active */
- if (FD_ISSET (iConnectionNumber, &fdsRead))
- {
- /* Process X events */
- /* Exit when we see that server is shutting down */
- iReturn = winClipboardFlushXEvents (hwnd,
- iWindow,
- pDisplay,
- fUseUnicode);
- if (WIN_XEVENTS_SHUTDOWN == iReturn)
- {
- ErrorF ("winClipboardProc - winClipboardFlushXEvents "
- "trapped shutdown event, exiting main loop.\n");
- break;
- }
- }
-
-#ifdef HAS_DEVWINDOWS
- /* Check for Windows event ready */
- if (FD_ISSET (fdMessageQueue, &fdsRead))
-#else
- if (1)
-#endif
- {
- /* Process Windows messages */
- if (!winClipboardFlushWindowsMessageQueue (hwnd))
- {
- ErrorF ("winClipboardProc - "
- "winClipboardFlushWindowsMessageQueue trapped "
- "WM_QUIT message, exiting main loop.\n");
- break;
- }
- }
- }
-
- /* Close our X window */
- if (pDisplay && iWindow)
- {
- iReturn = XDestroyWindow (pDisplay, iWindow);
- if (iReturn == BadWindow)
- ErrorF ("winClipboardProc - XDestroyWindow returned BadWindow.\n");
- else
- ErrorF ("winClipboardProc - XDestroyWindow succeeded.\n");
- }
-
-
-#ifdef HAS_DEVWINDOWS
- /* Close our Win32 message handle */
- if (fdMessageQueue)
- close (fdMessageQueue);
-#endif
-
-#if 0
- /*
- * FIXME: XCloseDisplay hangs if we call it, as of 2004/03/26. The
- * XSync and XSelectInput calls did not help.
- */
-
- /* Discard any remaining events */
- XSync (pDisplay, TRUE);
-
- /* Select event types to watch */
- XSelectInput (pDisplay,
- DefaultRootWindow (pDisplay),
- None);
-
- /* Close our X display */
- if (pDisplay)
- {
- XCloseDisplay (pDisplay);
- }
-#endif
-
- g_iClipboardWindow = None;
- g_pClipboardDisplay = NULL;
- g_hwndClipboard = NULL;
-
- return NULL;
-}
-
-
-/*
- * winClipboardErrorHandler - Our application specific error handler
- */
-
-static int
-winClipboardErrorHandler (Display *pDisplay, XErrorEvent *pErr)
-{
- char pszErrorMsg[100];
-
- XGetErrorText (pDisplay,
- pErr->error_code,
- pszErrorMsg,
- sizeof (pszErrorMsg));
- ErrorF ("winClipboardErrorHandler - ERROR: \n\t%s\n"
- "\tSerial: %d, Request Code: %d, Minor Code: %d\n",
- pszErrorMsg,
- pErr->serial,
- pErr->request_code,
- pErr->minor_code);
- return 0;
-}
-
-
-/*
- * winClipboardIOErrorHandler - Our application specific IO error handler
- */
-
-static int
-winClipboardIOErrorHandler (Display *pDisplay)
-{
- ErrorF ("\nwinClipboardIOErrorHandler!\n\n");
-
- /* Restart at the main entry point */
- longjmp (g_jmpEntry, WIN_JMP_ERROR_IO);
-
- return 0;
-}
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *Copyright (C) Colin Harrison 2005-2008
+ *
+ *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, 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 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 HAROLD L HUNT II 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 copyright holder(s)
+ *and author(s) 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 copyright holder(s) and author(s).
+ *
+ * Authors: Harold L Hunt II
+ * Colin Harrison
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include <sys/types.h>
+#include "winclipboard.h"
+#ifdef __CYGWIN__
+#include <errno.h>
+#endif
+#include "misc.h"
+#include "winmsg.h"
+
+#ifdef _MSC_VER
+#define snprintf _snprintf
+#endif
+
+/*
+ * References to external symbols
+ */
+
+extern Bool g_fUnicodeClipboard;
+extern unsigned long serverGeneration;
+extern Bool g_fClipboardLaunched;
+extern Bool g_fClipboardStarted;
+extern HWND g_hwndClipboard;
+extern void *g_pClipboardDisplay;
+extern Window g_iClipboardWindow;
+
+
+/*
+ * Global variables
+ */
+
+static jmp_buf g_jmpEntry;
+Bool g_fUnicodeSupport = FALSE;
+Bool g_fUseUnicode = FALSE;
+
+
+/*
+ * Local function prototypes
+ */
+
+static int
+winClipboardErrorHandler (Display *pDisplay, XErrorEvent *pErr);
+
+static int
+winClipboardIOErrorHandler (Display *pDisplay);
+
+
+/*
+ * Main thread function
+ */
+
+void *
+winClipboardProc (void *pvNotUsed)
+{
+ Atom atomClipboard, atomClipboardManager;
+ int iReturn;
+ HWND hwnd = NULL;
+ int iConnectionNumber = 0;
+#ifdef HAS_DEVWINDOWS
+ int fdMessageQueue = 0;
+#else
+ struct timeval tvTimeout;
+#endif
+ fd_set fdsRead;
+ int iMaxDescriptor;
+ Display *pDisplay = NULL;
+ Window iWindow = None;
+ int iRetries;
+ Bool fUseUnicode;
+ char szDisplay[512];
+ int iSelectError;
+
+ winDebug ("winClipboardProc - Hello\n");
+
+ /* Do we have Unicode support? */
+ g_fUnicodeSupport = winClipboardDetectUnicodeSupport ();
+
+ /* Do we use Unicode clipboard? */
+ fUseUnicode = g_fUnicodeClipboard && g_fUnicodeSupport;
+
+ /* Save the Unicode support flag in a global */
+ g_fUseUnicode = fUseUnicode;
+
+ /* See if X supports the current locale */
+ if (XSupportsLocale () == False)
+ {
+ ErrorF ("winClipboardProc - Locale not supported by X. Exiting.\n");
+ goto thread_errorexit;
+ }
+
+ /* Create Windows messaging window */
+ hwnd = winClipboardCreateMessagingWindow ();
+
+ /* Save copy of HWND in screen privates */
+ g_hwndClipboard = hwnd;
+
+ /* Set jump point for Error exits */
+ iReturn = setjmp (g_jmpEntry);
+
+ /* Check if we should continue operations */
+ if (iReturn != WIN_JMP_ERROR_IO
+ && iReturn != WIN_JMP_OKAY)
+ {
+ /* setjmp returned an unknown value, exit */
+ ErrorF ("winClipboardProc - setjmp returned: %d exiting\n",
+ iReturn);
+ goto thread_errorexit;
+ }
+ else if (iReturn == WIN_JMP_ERROR_IO)
+ {
+ /* TODO: Cleanup the Win32 window and free any allocated memory */
+ ErrorF ("winClipboardProc - setjmp returned for IO Error Handler.\n");
+ //goto thread_errorexit;
+ }
+
+ /* Use our generated cookie for authentication */
+ winSetAuthorization();
+
+ /* Set error handler */
+ XSetErrorHandler (winClipboardErrorHandler);
+ XSetIOErrorHandler (winClipboardIOErrorHandler);
+
+ /* Initialize retry count */
+ iRetries = 0;
+
+ /* Setup the display connection string x */
+ /*
+ * NOTE: Always connect to screen 0 since we require that screen
+ * numbers start at 0 and increase without gaps. We only need
+ * to connect to one screen on the display to get events
+ * for all screens on the display. That is why there is only
+ * one clipboard client thread.
+ */
+ snprintf (szDisplay,
+ 512,
+ "127.0.0.1:%s.0",
+ display);
+
+ /* Print the display connection string */
+ winDebug ("winClipboardProc - DISPLAY=%s\n", szDisplay);
+
+ /* Open the X display */
+ do
+ {
+ pDisplay = XOpenDisplay (szDisplay);
+ if (pDisplay == NULL)
+ {
+ ErrorF ("winClipboardProc - Could not open display, "
+ "try: %d, sleeping: %d\n",
+ iRetries + 1, WIN_CONNECT_DELAY);
+ ++iRetries;
+ sleep (WIN_CONNECT_DELAY);
+ continue;
+ }
+ else
+ break;
+ }
+ while (pDisplay == NULL && iRetries < WIN_CONNECT_RETRIES);
+
+ /* Make sure that the display opened */
+ if (pDisplay == NULL)
+ {
+ ErrorF ("winClipboardProc - Failed opening the display, giving up\n");
+ goto thread_errorexit;
+ }
+
+ /* Save the display in the screen privates */
+ g_pClipboardDisplay = pDisplay;
+
+ winDebug ("winClipboardProc - XOpenDisplay () returned and "
+ "successfully opened the display.\n");
+
+ /* Get our connection number */
+ iConnectionNumber = ConnectionNumber (pDisplay);
+
+ winDebug("Clipboard is using socket %d\n",iConnectionNumber);
+
+#ifdef HAS_DEVWINDOWS
+ /* Open a file descriptor for the windows message queue */
+ fdMessageQueue = open (WIN_MSG_QUEUE_FNAME, _O_RDONLY);
+ if (fdMessageQueue == -1)
+ {
+ ErrorF ("winClipboardProc - Failed opening %s\n", WIN_MSG_QUEUE_FNAME);
+ goto thread_errorexit;
+ }
+
+ /* Find max of our file descriptors */
+ iMaxDescriptor = max (fdMessageQueue, iConnectionNumber) + 1;
+#else
+ iMaxDescriptor = iConnectionNumber + 1;
+#endif
+
+ /* Create atoms */
+ atomClipboard = XInternAtom (pDisplay, "CLIPBOARD", False);
+ atomClipboardManager = XInternAtom (pDisplay, "CLIPBOARD_MANAGER", False);
+ XInternAtom (pDisplay, WIN_LOCAL_PROPERTY, False);
+ XInternAtom (pDisplay, "UTF8_STRING", False);
+ XInternAtom (pDisplay, "COMPOUND_TEXT", False);
+ XInternAtom (pDisplay, "TARGETS", False);
+
+ /* Create a messaging window */
+ iWindow = XCreateSimpleWindow (pDisplay,
+ DefaultRootWindow (pDisplay),
+ 1, 1,
+ 500, 500,
+ 0,
+ BlackPixel (pDisplay, 0),
+ BlackPixel (pDisplay, 0));
+ if (iWindow == 0)
+ {
+ ErrorF ("winClipboardProc - Could not create an X window.\n");
+ goto thread_errorexit;
+ }
+
+ /* Select event types to watch */
+ if (XSelectInput (pDisplay,
+ iWindow,
+ PropertyChangeMask) == BadWindow)
+ ErrorF ("winClipboardProc - XSelectInput generated BadWindow "
+ "on messaging window\n");
+
+ /* Save the window in the screen privates */
+ g_iClipboardWindow = iWindow;
+
+ /* Assert ownership of selections if Win32 clipboard is owned */
+ if (NULL != GetClipboardOwner ())
+ {
+ /* PRIMARY */
+ winDebug("winClipboardProc - asserted ownership.\n");
+ iReturn = XSetSelectionOwner (pDisplay, XA_PRIMARY,
+ iWindow, CurrentTime);
+ if (iReturn == BadAtom || iReturn == BadWindow /*||
+ XGetSelectionOwner (pDisplay, XA_PRIMARY) != iWindow*/)
+ {
+ ErrorF ("winClipboardProc - Could not set PRIMARY owner\n");
+ goto thread_errorexit;
+ }
+
+ /* CLIPBOARD */
+ iReturn = XSetSelectionOwner (pDisplay, atomClipboard,
+ iWindow, CurrentTime);
+ if (iReturn == BadAtom || iReturn == BadWindow /*||
+ XGetSelectionOwner (pDisplay, atomClipboard) != iWindow*/)
+ {
+ ErrorF ("winClipboardProc - Could not set CLIPBOARD owner\n");
+ goto thread_errorexit;
+ }
+ }
+ /* Pre-flush X events */
+ /*
+ * NOTE: Apparently you'll freeze if you don't do this,
+ * because there may be events in local data structures
+ * already.
+ */
+ /*winClipboardFlushXEvents (hwnd,
+ iWindow,
+ pDisplay,
+ fUseUnicode);
+ */
+ /* Pre-flush Windows messages */
+ winDebug ("Start flushing \n");
+ if (!winClipboardFlushWindowsMessageQueue (hwnd))
+ {
+ ErrorF ("winClipboardFlushWindowsMessageQueue - returned 0\n");
+ goto thread_errorexit;
+ }
+
+ winDebug ("winClipboardProc - Started\n");
+ /* Signal that the clipboard client has started */
+ g_fClipboardStarted = TRUE;
+
+ /* Loop for X events */
+ while (1)
+ {
+ /* Setup the file descriptor set */
+ /*
+ * NOTE: You have to do this before every call to select
+ * because select modifies the mask to indicate
+ * which descriptors are ready.
+ */
+ FD_ZERO (&fdsRead);
+ FD_SET (iConnectionNumber, &fdsRead);
+#ifdef HAS_DEVWINDOWS
+ FD_SET (fdMessageQueue, &fdsRead);
+#else
+ tvTimeout.tv_sec = 0;
+ tvTimeout.tv_usec = 100;
+#endif
+
+ /* Wait for a Windows event or an X event */
+ iReturn = select (iMaxDescriptor, /* Highest fds number */
+ &fdsRead, /* Read mask */
+ NULL, /* No write mask */
+ NULL, /* No exception mask */
+#ifdef HAS_DEVWINDOWS
+ NULL /* No timeout */
+#else
+ &tvTimeout /* Set timeout */
+#endif
+ );
+
+#ifndef HAS_WINSOCK
+ iSelectError = errno;
+#else
+ iSelectError = WSAGetLastError();
+#endif
+
+ if (iReturn < 0)
+ {
+#ifndef HAS_WINSOCK
+ if (iSelectError == EINTR)
+#else
+ if (iSelectError == WSAEINTR)
+#endif
+ continue;
+
+ ErrorF ("winClipboardProc - Call to select () failed: %d. "
+ "Bailing.\n", iReturn);
+ break;
+ }
+
+ /* Branch on which descriptor became active */
+// if (FD_ISSET (iConnectionNumber, &fdsRead))
+// { Also do it when no read since winClipboardFlushXEvents
+// is sending the output.
+ /* Process X events */
+ /* Exit when we see that server is shutting down */
+ iReturn = winClipboardFlushXEvents (hwnd,
+ iWindow,
+ pDisplay,
+ fUseUnicode,
+ FALSE
+ );
+ if (WIN_XEVENTS_SHUTDOWN == iReturn)
+ {
+ ErrorF ("winClipboardProc - winClipboardFlushXEvents "
+ "trapped shutdown event, exiting main loop.\n");
+ break;
+ }
+// }
+
+#ifdef HAS_DEVWINDOWS
+ /* Check for Windows event ready */
+ if (FD_ISSET (fdMessageQueue, &fdsRead))
+#else
+ if (1)
+#endif
+ {
+ /* Process Windows messages */
+ if (!winClipboardFlushWindowsMessageQueue (hwnd))
+ {
+ ErrorF ("winClipboardProc - "
+ "winClipboardFlushWindowsMessageQueue trapped "
+ "WM_QUIT message, exiting main loop.\n");
+ break;
+ }
+ }
+ }
+
+ /* Close our X window */
+ if (pDisplay && iWindow)
+ {
+ iReturn = XDestroyWindow (pDisplay, iWindow);
+ if (iReturn == BadWindow)
+ ErrorF ("winClipboardProc - XDestroyWindow returned BadWindow.\n");
+#ifdef WINDBG
+ else
+ winDebug ("winClipboardProc - XDestroyWindow succeeded.\n");
+#endif
+ }
+
+
+#ifdef HAS_DEVWINDOWS
+ /* Close our Win32 message handle */
+ if (fdMessageQueue)
+ close (fdMessageQueue);
+#endif
+
+#if 0
+ /*
+ * FIXME: XCloseDisplay hangs if we call it, as of 2004/03/26. The
+ * XSync and XSelectInput calls did not help.
+ */
+
+ /* Discard any remaining events */
+ XSync (pDisplay, TRUE);
+
+ /* Select event types to watch */
+ XSelectInput (pDisplay,
+ DefaultRootWindow (pDisplay),
+ None);
+
+ /* Close our X display */
+ if (pDisplay)
+ {
+ XCloseDisplay (pDisplay);
+ }
+#endif
+
+ g_iClipboardWindow = None;
+ g_pClipboardDisplay = NULL;
+ g_fClipboardLaunched = FALSE;
+ g_fClipboardStarted = FALSE;
+
+ return NULL;
+thread_errorexit:
+ if (g_pClipboardDisplay && g_iClipboardWindow)
+ {
+ iReturn = XDestroyWindow (g_pClipboardDisplay, g_iClipboardWindow);
+ if (iReturn == BadWindow)
+ ErrorF ("winClipboardProc - XDestroyWindow returned BadWindow.\n");
+#ifdef WINDBG
+ else
+ winDebug ("winClipboardProc - XDestroyWindow succeeded.\n");
+#endif
+ }
+ g_iClipboardWindow = None;
+ g_pClipboardDisplay = NULL;
+ g_fClipboardLaunched = FALSE;
+ g_fClipboardStarted = FALSE;
+ //pthread_exit (NULL);
+ winDebug ("Clipboard thread died.\n");
+ return NULL;
+}
+
+
+/*
+ * winClipboardErrorHandler - Our application specific error handler
+ */
+
+static int
+winClipboardErrorHandler (Display *pDisplay, XErrorEvent *pErr)
+{
+ char pszErrorMsg[100];
+
+ XGetErrorText (pDisplay,
+ pErr->error_code,
+ pszErrorMsg,
+ sizeof (pszErrorMsg));
+ ErrorF ("winClipboardErrorHandler - ERROR: \n\t%s\n"
+ " errorCode %d\n"
+ " serial %d\n"
+ " resourceID 0x%x\n"
+ " majorCode %d\n"
+ " minorCode %d\n"
+ , pszErrorMsg
+ , pErr->error_code
+ , pErr->serial
+ , pErr->resourceid
+ , pErr->request_code
+ , pErr->minor_code);
+ return 0;
+}
+
+
+/*
+ * winClipboardIOErrorHandler - Our application specific IO error handler
+ */
+
+static int
+winClipboardIOErrorHandler (Display *pDisplay)
+{
+ ErrorF ("\nwinClipboardIOErrorHandler!\n\n");
+
+ /* Restart at the main entry point */
+ longjmp (g_jmpEntry, WIN_JMP_ERROR_IO);
+
+ return 0;
+}
diff --git a/xorg-server/hw/xwin/winclipboardunicode.c b/xorg-server/hw/xwin/winclipboardunicode.c
index ba86915a4..947475509 100644
--- a/xorg-server/hw/xwin/winclipboardunicode.c
+++ b/xorg-server/hw/xwin/winclipboardunicode.c
@@ -43,25 +43,43 @@ Bool
winClipboardDetectUnicodeSupport (void)
{
Bool fReturn = FALSE;
- OSVERSIONINFO osvi = {0};
+ OSVERSIONINFOEX osvi = {0};
/* Get operating system version information */
osvi.dwOSVersionInfoSize = sizeof (osvi);
- GetVersionEx (&osvi);
+ GetVersionEx ((LPOSVERSIONINFO)&osvi);
/* Branch on platform ID */
switch (osvi.dwPlatformId)
{
case VER_PLATFORM_WIN32_NT:
- /* Unicode supported on NT only */
- ErrorF ("DetectUnicodeSupport - Windows NT/2000/XP\n");
- fReturn = TRUE;
+ if (osvi.dwMajorVersion >= 6)
+ {
+ if (osvi.wProductType == VER_NT_WORKSTATION)
+ winDebug ("OS: Windows Vista\n");
+ else
+ winDebug ("OS: Windows Server 2008\n");
+ fReturn = TRUE;
+ }
+ else if (osvi.dwMajorVersion == 5)
+ {
+ if (osvi.dwMinorVersion == 2)
+ {
+ winDebug ("OS: Windows 2003\n");
+ fReturn = TRUE;
+ }
+ else if (osvi.dwMinorVersion == 1)
+ {
+ winDebug ("OS: Windows XP\n");
+ fReturn = TRUE;
+ }
+ else if (osvi.dwMinorVersion == 0) winDebug ("OS: Windows 2000\n");
+ }
+ else if (osvi.dwMajorVersion <= 4) winDebug ("OS: Windows NT\n");
break;
case VER_PLATFORM_WIN32_WINDOWS:
- /* Unicode is not supported on non-NT */
- ErrorF ("DetectUnicodeSupport - Windows 95/98/Me\n");
- fReturn = FALSE;
+ winDebug ("OS: Windows 95/98/Me\n");
break;
}
diff --git a/xorg-server/hw/xwin/winclipboardwndproc.c b/xorg-server/hw/xwin/winclipboardwndproc.c
index 9394b04db..dbfc61e4e 100644
--- a/xorg-server/hw/xwin/winclipboardwndproc.c
+++ b/xorg-server/hw/xwin/winclipboardwndproc.c
@@ -1,629 +1,550 @@
-/*
- *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
- *Copyright (C) Colin Harrison 2005-2008
- *
- *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, 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 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 HAROLD L HUNT II 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 copyright holder(s)
- *and author(s) 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 copyright holder(s) and author(s).
- *
- * Authors: Harold L Hunt II
- * Colin Harrison
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include <sys/types.h>
-#include <sys/time.h>
-#include "winclipboard.h"
-#include "misc.h"
-
-/*
- * Constants
- */
-
-#define WIN_CLIPBOARD_PROP "cyg_clipboard_prop"
-#define WIN_POLL_TIMEOUT 1
-
-
-/*
- * References to external symbols
- */
-
-extern Bool g_fUseUnicode;
-extern Bool g_fUnicodeSupport;
-extern void *g_pClipboardDisplay;
-extern Window g_iClipboardWindow;
-extern Atom g_atomLastOwnedSelection;
-
-/* BPS - g_hwndClipboard needed for X app->Windows paste fix */
-extern HWND g_hwndClipboard;
-
-/*
- * Local function prototypes
- */
-
-static int
-winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
- Bool fUseUnicode, int iTimeoutSec);
-
-
-/*
- * Process X events up to specified timeout
- */
-
-static int
-winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
- Bool fUseUnicode, int iTimeoutSec)
-{
- int iConnNumber;
- struct timeval tv;
- int iReturn;
- DWORD dwStopTime = (GetTickCount () / 1000) + iTimeoutSec;
-
- /* We need to ensure that all pending events are processed */
- XSync (pDisplay, FALSE);
-
- /* Get our connection number */
- iConnNumber = ConnectionNumber (pDisplay);
-
- /* Loop for X events */
- while (1)
- {
- fd_set fdsRead;
-
- /* Setup the file descriptor set */
- FD_ZERO (&fdsRead);
- FD_SET (iConnNumber, &fdsRead);
-
- /* Adjust timeout */
- tv.tv_sec = dwStopTime - (GetTickCount () / 1000);
- tv.tv_usec = 0;
-
- /* Break out if no time left */
- if (tv.tv_sec < 0)
- return WIN_XEVENTS_SUCCESS;
-
- /* Wait for an X event */
- iReturn = select (iConnNumber + 1,/* Highest fds number */
- &fdsRead, /* Read mask */
- NULL, /* No write mask */
- NULL, /* No exception mask */
- &tv); /* No timeout */
- if (iReturn < 0)
- {
- ErrorF ("winProcessXEventsTimeout - Call to select () failed: %d. "
- "Bailing.\n", iReturn);
- break;
- }
-
- /* Branch on which descriptor became active */
- if (FD_ISSET (iConnNumber, &fdsRead))
- {
- /* Process X events */
- /* Exit when we see that server is shutting down */
- iReturn = winClipboardFlushXEvents (hwnd,
- iWindow,
- pDisplay,
- fUseUnicode);
- if (WIN_XEVENTS_NOTIFY == iReturn
- || WIN_XEVENTS_CONVERT == iReturn)
- {
- /* Bail out if convert or notify processed */
- return iReturn;
- }
- }
- }
-
- return WIN_XEVENTS_SUCCESS;
-}
-
-
-/*
- * Process a given Windows message
- */
-
-/* BPS - Define our own message, which we'll post to ourselves to facilitate
- * resetting the delayed rendering mechanism after each paste from X app to
- * Windows app. TODO - Perhaps move to win.h with the other WM_USER messages.
- */
-#define WM_USER_PASTE_COMPLETE (WM_USER + 1003)
-
-LRESULT CALLBACK
-winClipboardWindowProc (HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam)
-{
- static HWND s_hwndNextViewer;
- static Bool s_fCBCInitialized;
-
- /* Branch on message type */
- switch (message)
- {
- case WM_DESTROY:
- {
- winDebug ("winClipboardWindowProc - WM_DESTROY\n");
-
- /* Remove ourselves from the clipboard chain */
- ChangeClipboardChain (hwnd, s_hwndNextViewer);
-
- s_hwndNextViewer = NULL;
-
- PostQuitMessage (0);
- }
- return 0;
-
-
- case WM_CREATE:
- {
- HWND first, next;
- DWORD error_code = 0;
- winDebug ("winClipboardWindowProc - WM_CREATE\n");
-
- first = GetClipboardViewer(); /* Get handle to first viewer in chain. */
- if (first == hwnd) return 0; /* Make sure it's not us! */
- /* Add ourselves to the clipboard viewer chain */
- next = SetClipboardViewer (hwnd);
- error_code = GetLastError();
- if (SUCCEEDED(error_code) && (next == first)) /* SetClipboardViewer must have succeeded, and the handle */
- s_hwndNextViewer = next; /* it returned must have been the first window in the chain */
- else
- s_fCBCInitialized = FALSE;
- }
- return 0;
-
-
- case WM_CHANGECBCHAIN:
- {
- winDebug ("winClipboardWindowProc - WM_CHANGECBCHAIN: wParam(%x) "
- "lParam(%x) s_hwndNextViewer(%x)\n",
- wParam, lParam, s_hwndNextViewer);
-
- if ((HWND) wParam == s_hwndNextViewer)
- {
- s_hwndNextViewer = (HWND) lParam;
- if (s_hwndNextViewer == hwnd)
- {
- s_hwndNextViewer = NULL;
- winErrorFVerb (1, "winClipboardWindowProc - WM_CHANGECBCHAIN: "
- "attempted to set next window to ourselves.");
- }
- }
- else if (s_hwndNextViewer)
- SendMessage (s_hwndNextViewer, message,
- wParam, lParam);
-
- }
- winDebug ("winClipboardWindowProc - WM_CHANGECBCHAIN: Exit\n");
- return 0;
-
- case WM_WM_REINIT:
- {
- /* Ensure that we're in the clipboard chain. Some apps,
- * WinXP's remote desktop for one, don't play nice with the
- * chain. This message is called whenever we receive a
- * WM_ACTIVATEAPP message to ensure that we continue to
- * receive clipboard messages.
- *
- * It might be possible to detect if we're still in the chain
- * by calling SendMessage (GetClipboardViewer(),
- * WM_DRAWCLIPBOARD, 0, 0); and then seeing if we get the
- * WM_DRAWCLIPBOARD message. That, however, might be more
- * expensive than just putting ourselves back into the chain.
- */
-
- HWND first, next;
- DWORD error_code = 0;
- winDebug ("winClipboardWindowProc - WM_WM_REINIT: Enter\n");
-
- first = GetClipboardViewer(); /* Get handle to first viewer in chain. */
- if (first == hwnd) return 0; /* Make sure it's not us! */
- winDebug (" WM_WM_REINIT: Replacing us(%x) with %x at head "
- "of chain\n", hwnd, s_hwndNextViewer);
- s_fCBCInitialized = FALSE;
- ChangeClipboardChain (hwnd, s_hwndNextViewer);
- s_hwndNextViewer = NULL;
- s_fCBCInitialized = FALSE;
- winDebug (" WM_WM_REINIT: Putting us back at head of chain.\n");
- first = GetClipboardViewer(); /* Get handle to first viewer in chain. */
- if (first == hwnd) return 0; /* Make sure it's not us! */
- next = SetClipboardViewer (hwnd);
- error_code = GetLastError();
- if (SUCCEEDED(error_code) && (next == first)) /* SetClipboardViewer must have succeeded, and the handle */
- s_hwndNextViewer = next; /* it returned must have been the first window in the chain */
- else
- s_fCBCInitialized = FALSE;
- }
- winDebug ("winClipboardWindowProc - WM_WM_REINIT: Exit\n");
- return 0;
-
-
- case WM_DRAWCLIPBOARD:
- {
- static Atom atomClipboard;
- static int generation;
- static Bool s_fProcessingDrawClipboard = FALSE;
- Display *pDisplay = g_pClipboardDisplay;
- Window iWindow = g_iClipboardWindow;
- int iReturn;
-
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Enter\n");
-
- if (generation != serverGeneration)
- {
- generation = serverGeneration;
- atomClipboard = XInternAtom (pDisplay, "CLIPBOARD", False);
- }
-
- /*
- * We've occasionally seen a loop in the clipboard chain.
- * Try and fix it on the first hint of recursion.
- */
- if (! s_fProcessingDrawClipboard)
- {
- s_fProcessingDrawClipboard = TRUE;
- }
- else
- {
- /* Attempt to break the nesting by getting out of the chain, twice?, and then fix and bail */
- s_fCBCInitialized = FALSE;
- ChangeClipboardChain (hwnd, s_hwndNextViewer);
- winFixClipboardChain();
- winErrorFVerb (1, "winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "Nested calls detected. Re-initing.\n");
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
- s_fProcessingDrawClipboard = FALSE;
- return 0;
- }
-
- /* Bail on first message */
- if (!s_fCBCInitialized)
- {
- s_fCBCInitialized = TRUE;
- s_fProcessingDrawClipboard = FALSE;
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
- return 0;
- }
-
- /*
- * NOTE: We cannot bail out when NULL == GetClipboardOwner ()
- * because some applications deal with the clipboard in a manner
- * that causes the clipboard owner to be NULL when they are in
- * fact taking ownership. One example of this is the Win32
- * native compile of emacs.
- */
-
- /* Bail when we still own the clipboard */
- if (hwnd == GetClipboardOwner ())
- {
-
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "We own the clipboard, returning.\n");
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
- s_fProcessingDrawClipboard = FALSE;
- if (s_hwndNextViewer)
- SendMessage (s_hwndNextViewer, message, wParam, lParam);
- return 0;
- }
-
- /*
- * Do not take ownership of the X11 selections when something
- * other than CF_TEXT or CF_UNICODETEXT has been copied
- * into the Win32 clipboard.
- */
- if (!IsClipboardFormatAvailable (CF_TEXT)
- && !IsClipboardFormatAvailable (CF_UNICODETEXT))
- {
-
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "Clipboard does not contain CF_TEXT nor "
- "CF_UNICODETEXT.\n");
-
- /*
- * We need to make sure that the X Server has processed
- * previous XSetSelectionOwner messages.
- */
- XSync (pDisplay, FALSE);
-
- /* Release PRIMARY selection if owned */
- iReturn = XGetSelectionOwner (pDisplay, XA_PRIMARY);
- if (iReturn == g_iClipboardWindow)
- {
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "PRIMARY selection is owned by us.\n");
- XSetSelectionOwner (pDisplay,
- XA_PRIMARY,
- None,
- CurrentTime);
- }
- else if (BadWindow == iReturn || BadAtom == iReturn)
- winErrorFVerb (1, "winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "XGetSelection failed for PRIMARY: %d\n", iReturn);
-
- /* Release CLIPBOARD selection if owned */
- iReturn = XGetSelectionOwner (pDisplay,
- atomClipboard);
- if (iReturn == g_iClipboardWindow)
- {
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "CLIPBOARD selection is owned by us.\n");
- XSetSelectionOwner (pDisplay,
- atomClipboard,
- None,
- CurrentTime);
- }
- else if (BadWindow == iReturn || BadAtom == iReturn)
- winErrorFVerb (1, "winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "XGetSelection failed for CLIPBOARD: %d\n", iReturn);
-
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
- s_fProcessingDrawClipboard = FALSE;
- if (s_hwndNextViewer)
- SendMessage (s_hwndNextViewer, message, wParam, lParam);
- return 0;
- }
-
- /* Reassert ownership of PRIMARY */
- iReturn = XSetSelectionOwner (pDisplay,
- XA_PRIMARY,
- iWindow,
- CurrentTime);
- if (iReturn == BadAtom || iReturn == BadWindow ||
- XGetSelectionOwner (pDisplay, XA_PRIMARY) != iWindow)
- {
- winErrorFVerb (1, "winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "Could not reassert ownership of PRIMARY\n");
- }
- else
- {
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "Reasserted ownership of PRIMARY\n");
- }
-
- /* Reassert ownership of the CLIPBOARD */
- iReturn = XSetSelectionOwner (pDisplay,
- atomClipboard,
- iWindow,
- CurrentTime);
-
- if (iReturn == BadAtom || iReturn == BadWindow ||
- XGetSelectionOwner (pDisplay, atomClipboard) != iWindow)
- {
- winErrorFVerb (1, "winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "Could not reassert ownership of CLIPBOARD\n");
- }
- else
- {
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "Reasserted ownership of CLIPBOARD\n");
- }
-
- /* Flush the pending SetSelectionOwner event now */
- XFlush (pDisplay);
-
- s_fProcessingDrawClipboard = FALSE;
- }
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
- /* Pass the message on the next window in the clipboard viewer chain */
- if (s_hwndNextViewer)
- SendMessage (s_hwndNextViewer, message, wParam, lParam);
- return 0;
-
-
- case WM_DESTROYCLIPBOARD:
- /*
- * NOTE: Intentionally do nothing.
- * Changes in the Win32 clipboard are handled by WM_DRAWCLIPBOARD
- * above. We only process this message to conform to the specs
- * for delayed clipboard rendering in Win32. You might think
- * that we need to release ownership of the X11 selections, but
- * we do not, because a WM_DRAWCLIPBOARD message will closely
- * follow this message and reassert ownership of the X11
- * selections, handling the issue for us.
- */
- winDebug ("winClipboardWindowProc - WM_DESTROYCLIPBOARD - Ignored.\n");
- return 0;
-
- case WM_RENDERFORMAT:
- case WM_RENDERALLFORMATS:
- {
- int iReturn;
- Display *pDisplay = g_pClipboardDisplay;
- Window iWindow = g_iClipboardWindow;
- Bool fConvertToUnicode;
-
- winDebug ("winClipboardWindowProc - WM_RENDER*FORMAT - Hello.\n");
-
- /* Flag whether to convert to Unicode or not */
- if (message == WM_RENDERALLFORMATS)
- fConvertToUnicode = FALSE;
- else
- fConvertToUnicode = g_fUnicodeSupport && (CF_UNICODETEXT == wParam);
-
- /* Request the selection contents */
- iReturn = XConvertSelection (pDisplay,
- g_atomLastOwnedSelection,
- XInternAtom (pDisplay,
- "COMPOUND_TEXT", False),
- XInternAtom (pDisplay,
- "CYGX_CUT_BUFFER", False),
- iWindow,
- CurrentTime);
- if (iReturn == BadAtom || iReturn == BadWindow)
- {
- winErrorFVerb (1, "winClipboardWindowProc - WM_RENDER*FORMAT - "
- "XConvertSelection () failed\n");
- break;
- }
-
- /* Special handling for WM_RENDERALLFORMATS */
- if (message == WM_RENDERALLFORMATS)
- {
- /* We must open and empty the clipboard */
-
- /* Close clipboard if we have it open already */
- if (GetOpenClipboardWindow () == hwnd)
- {
- CloseClipboard ();
- }
-
- if (!OpenClipboard (hwnd))
- {
- winErrorFVerb (1, "winClipboardWindowProc - WM_RENDER*FORMATS - "
- "OpenClipboard () failed: %08x\n",
- GetLastError ());
- break;
- }
-
- if (!EmptyClipboard ())
- {
- winErrorFVerb (1, "winClipboardWindowProc - WM_RENDER*FORMATS - "
- "EmptyClipboard () failed: %08x\n",
- GetLastError ());
- break;
- }
- }
-
- /* Process the SelectionNotify event */
- iReturn = winProcessXEventsTimeout (hwnd,
- iWindow,
- pDisplay,
- fConvertToUnicode,
- WIN_POLL_TIMEOUT);
- if (WIN_XEVENTS_CONVERT == iReturn)
- {
- /*
- * The selection was offered for conversion first, so we have
- * to process a second SelectionNotify event to get the actual
- * data in the selection.
- */
- iReturn = winProcessXEventsTimeout (hwnd,
- iWindow,
- pDisplay,
- fConvertToUnicode,
- WIN_POLL_TIMEOUT);
- }
-
- /*
- * The last of the up-to two calls to winProcessXEventsTimeout
- * from above had better have seen a notify event, or else we
- * are dealing with a buggy or old X11 app. In these cases we
- * have to paste some fake data to the Win32 clipboard to
- * satisfy the requirement that we write something to it.
- */
- if (WIN_XEVENTS_NOTIFY != iReturn)
- {
- /* Paste no data, to satisfy required call to SetClipboardData */
- if (g_fUnicodeSupport)
- SetClipboardData (CF_UNICODETEXT, NULL);
- SetClipboardData (CF_TEXT, NULL);
-
- ErrorF("winClipboardWindowProc - timed out waiting for WIN_XEVENTS_NOTIFY\n");
- }
-
- /* BPS - Post ourselves a user message whose handler will reset the
- * delayed rendering mechanism after the paste is complete. This is
- * necessary because calling SetClipboardData() with a NULL argument
- * here will cause the data we just put on the clipboard to be lost!
- */
- PostMessage(g_hwndClipboard, WM_USER_PASTE_COMPLETE, 0, 0);
-
- /* Special handling for WM_RENDERALLFORMATS */
- if (message == WM_RENDERALLFORMATS)
- {
- /* We must close the clipboard */
-
- if (!CloseClipboard ())
- {
- winErrorFVerb (1, "winClipboardWindowProc - WM_RENDERALLFORMATS - "
- "CloseClipboard () failed: %08x\n",
- GetLastError ());
- break;
- }
- }
-
- winDebug ("winClipboardWindowProc - WM_RENDER*FORMAT - Returning.\n");
- return 0;
- }
- /* BPS - This WM_USER message is posted by us. It gives us the opportunity
- * to reset the delayed rendering mechanism after each and every paste
- * from an X app to a Windows app. Without such a mechanism, subsequent
- * changes of selection in the X app owning the selection are not
- * reflected in pastes into Windows apps, since Windows won't send us the
- * WM_RENDERFORMAT message unless someone has set changed data (or NULL)
- * on the clipboard. */
- case WM_USER_PASTE_COMPLETE:
- {
- if (hwnd != GetClipboardOwner ())
- /* In case we've lost the selection since posting the message */
- return 0;
- winDebug ("winClipboardWindowProc - WM_USER_PASTE_COMPLETE\n");
-
- /* Set up for another delayed rendering callback */
- OpenClipboard (g_hwndClipboard);
-
- /* Take ownership of the Windows clipboard */
- EmptyClipboard ();
-
- /* Advertise Unicode if we support it */
- if (g_fUnicodeSupport)
- SetClipboardData (CF_UNICODETEXT, NULL);
-
- /* Always advertise regular text */
- SetClipboardData (CF_TEXT, NULL);
-
- /* Release the clipboard */
- CloseClipboard ();
- }
- return 0;
- }
-
- /* Let Windows perform default processing for unhandled messages */
- return DefWindowProc (hwnd, message, wParam, lParam);
-}
-
-
-/*
- * Process any pending Windows messages
- */
-
-BOOL
-winClipboardFlushWindowsMessageQueue (HWND hwnd)
-{
- MSG msg;
-
- /* Flush the messaging window queue */
- /* NOTE: Do not pass the hwnd of our messaging window to PeekMessage,
- * as this will filter out many non-window-specific messages that
- * are sent to our thread, such as WM_QUIT.
- */
- while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
- {
- /* Dispatch the message if not WM_QUIT */
- if (msg.message == WM_QUIT)
- return FALSE;
- else
- DispatchMessage (&msg);
- }
-
- return TRUE;
-}
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *Copyright (C) Colin Harrison 2005-2008
+ *
+ *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, 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 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 HAROLD L HUNT II 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 copyright holder(s)
+ *and author(s) 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 copyright holder(s) and author(s).
+ *
+ * Authors: Harold L Hunt II
+ * Colin Harrison
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include <sys/types.h>
+#include <sys/time.h>
+#include "winclipboard.h"
+#include "misc.h"
+#include "winmsg.h"
+
+/*
+ * Constants
+ */
+
+#define WIN_CLIPBOARD_PROP "cyg_clipboard_prop"
+#define WIN_POLL_TIMEOUT 1
+
+/*
+ * References to external symbols
+ */
+
+extern Bool g_fUseUnicode;
+extern Bool g_fUnicodeSupport;
+extern void *g_pClipboardDisplay;
+extern Window g_iClipboardWindow;
+extern Atom g_atomLastOwnedSelection;
+extern Bool g_fClipboardStarted;
+/* BPS - g_hwndClipboard needed for X app->Windows paste fix */
+extern HWND g_hwndClipboard;
+
+/*
+ * Local function prototypes
+ */
+
+static int
+winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
+ Bool fUseUnicode, int iTimeoutSec);
+
+
+/*
+ * Process X events up to specified timeout
+ */
+
+static int
+winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
+ Bool fUseUnicode, int iTimeoutSec)
+{
+ int iConnNumber;
+ struct timeval tv;
+ int iReturn;
+ DWORD dwStopTime = (GetTickCount () / 1000) + iTimeoutSec;
+
+ /* Make sure the output messages are sent before waiting on a response. */
+ iReturn = winClipboardFlushXEvents (hwnd,
+ iWindow,
+ pDisplay,
+ fUseUnicode,
+ TRUE);
+ if (WIN_XEVENTS_NOTIFY == iReturn || WIN_XEVENTS_CONVERT == iReturn)
+ {
+ /* Bail out if convert or notify processed */
+ return iReturn;
+ }
+
+ /* Get our connection number */
+ iConnNumber = ConnectionNumber (pDisplay);
+
+ /* Loop for X events */
+ while (1)
+ {
+ fd_set fdsRead;
+
+ /* Setup the file descriptor set */
+ FD_ZERO (&fdsRead);
+ FD_SET (iConnNumber, &fdsRead);
+
+ /* Adjust timeout */
+ tv.tv_sec = dwStopTime - (GetTickCount () / 1000);
+ tv.tv_usec = 0;
+
+ /* Break out if no time left */
+ if (tv.tv_sec < 0)
+ return WIN_XEVENTS_SUCCESS;
+
+ /* Wait for an X event */
+ iReturn = select (iConnNumber + 1,/* Highest fds number */
+ &fdsRead, /* Read mask */
+ NULL, /* No write mask */
+ NULL, /* No exception mask */
+ &tv); /* No timeout */
+ if (iReturn < 0)
+ {
+ ErrorF ("winProcessXEventsTimeout - Call to select () failed: %d (%x). "
+ "Bailing.\n", iReturn, WSAGetLastError());
+ break;
+ }
+
+ /* Branch on which descriptor became active */
+ if (FD_ISSET (iConnNumber, &fdsRead))
+ {
+ /* Process X events */
+ /* Exit when we see that server is shutting down */
+ iReturn = winClipboardFlushXEvents (hwnd,
+ iWindow,
+ pDisplay,
+ fUseUnicode,
+ TRUE);
+ if (WIN_XEVENTS_NOTIFY == iReturn
+ || WIN_XEVENTS_CONVERT == iReturn)
+ {
+ /* Bail out if convert or notify processed */
+ return iReturn;
+ }
+ }
+ }
+
+ return WIN_XEVENTS_SUCCESS;
+}
+
+/*
+ * Process a given Windows message
+ */
+
+LRESULT CALLBACK
+winClipboardWindowProc (HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ static HWND s_hwndNextViewer;
+
+ /* Branch on message type */
+ switch (message)
+ {
+ case WM_DESTROY:
+ {
+ winDebug ("winClipboardWindowProc - WM_DESTROY\n");
+
+ /* Remove ourselves from the clipboard chain */
+ ChangeClipboardChain (hwnd, s_hwndNextViewer);
+
+ s_hwndNextViewer = NULL;
+ g_hwndClipboard = NULL;
+ PostQuitMessage (0);
+ }
+ return 0;
+
+
+ case WM_CREATE:
+ {
+ HWND first, next;
+ DWORD error_code = 0;
+ winDebug ("winClipboardWindowProc - WM_CREATE\n");
+
+ /* Add ourselves to the clipboard viewer chain */
+ s_hwndNextViewer = SetClipboardViewer (hwnd);
+ }
+ return 0;
+
+
+ case WM_CHANGECBCHAIN:
+ {
+ winDebug ("winClipboardWindowProc - WM_CHANGECBCHAIN: wParam(%x) "
+ "lParam(%x) s_hwndNextViewer(%x)\n",
+ wParam, lParam, s_hwndNextViewer);
+
+ if ((HWND) wParam == s_hwndNextViewer)
+ {
+ s_hwndNextViewer = (HWND) lParam;
+ }
+ else if (s_hwndNextViewer)
+ SendMessage (s_hwndNextViewer, message,
+ wParam, lParam);
+
+ }
+ winDebug ("winClipboardWindowProc - WM_CHANGECBCHAIN: Exit\n");
+ return 0;
+
+ case WM_WM_REINIT:
+ {
+ /* Ensure that we're in the clipboard chain. Some apps,
+ * WinXP's remote desktop for one, don't play nice with the
+ * chain. This message is called whenever we receive a
+ * WM_ACTIVATEAPP message to ensure that we continue to
+ * receive clipboard messages.
+ *
+ * It might be possible to detect if we're still in the chain
+ * by calling SendMessage (GetClipboardViewer(),
+ * WM_DRAWCLIPBOARD, 0, 0); and then seeing if we get the
+ * WM_DRAWCLIPBOARD message. That, however, might be more
+ * expensive than just putting ourselves back into the chain.
+ */
+
+ HWND first, next;
+ DWORD error_code = 0;
+ if (!g_hwndClipboard)
+ return 0;
+ winDebug ("winClipboardWindowProc - WM_WM_REINIT: Enter\n");
+
+ first = GetClipboardViewer(); /* Get handle to first viewer in chain. */
+ if (first != hwnd)
+ {
+ winDebug (" WM_WM_REINIT: Replacing us(%x) with %x at head "
+ "of chain\n", hwnd, s_hwndNextViewer);
+ ChangeClipboardChain (hwnd, s_hwndNextViewer);
+ winDebug (" WM_WM_REINIT: Putting us back at head of chain.\n");
+ s_hwndNextViewer = SetClipboardViewer (hwnd);
+ }
+ winDebug ("winClipboardWindowProc - WM_WM_REINIT: Exit\n");
+ }
+ return 0;
+
+
+ case WM_DRAWCLIPBOARD:
+ {
+ static Atom atomClipboard;
+ static int generation;
+ static Bool s_fProcessingDrawClipboard = FALSE;
+ Display *pDisplay = g_pClipboardDisplay;
+ Window iWindow = g_iClipboardWindow;
+ int iReturn;
+
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD 0x%x 0x%x 0x%x: Enter\n",hwnd,wParam,lParam);
+
+ if (!g_fClipboardStarted)
+ {
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit with no processing\n");
+ if (s_hwndNextViewer)
+ SendMessage (s_hwndNextViewer, message, wParam, lParam);
+ return 0;
+ }
+
+ if (generation != serverGeneration)
+ {
+ generation = serverGeneration;
+ atomClipboard = XInternAtom (pDisplay, "CLIPBOARD", False);
+ }
+
+ /*
+ * We've occasionally seen a loop in the clipboard chain.
+ * Try and fix it on the first hint of recursion.
+ */
+ if (! s_fProcessingDrawClipboard)
+ {
+ s_fProcessingDrawClipboard = TRUE;
+ }
+ else
+ {
+ /* Attempt to break the nesting by getting out of the chain, twice?, and then fix and bail */
+ ChangeClipboardChain (hwnd, s_hwndNextViewer);
+ winFixClipboardChain();
+ ErrorF ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "Nested calls detected. Re-initing.\n");
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
+ s_fProcessingDrawClipboard = FALSE;
+ return 0;
+ }
+
+ /*
+ * Do not take ownership of the X11 selections when something
+ * other than CF_TEXT or CF_UNICODETEXT has been copied
+ * into the Win32 clipboard.
+ */
+ if (!IsClipboardFormatAvailable (CF_TEXT)
+ && !IsClipboardFormatAvailable (CF_UNICODETEXT))
+ {
+
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "Clipboard does not contain CF_TEXT nor "
+ "CF_UNICODETEXT.\n");
+
+ /*
+ * We need to make sure that the X Server has processed
+ * previous XSetSelectionOwner messages.
+ */
+ XSync (pDisplay, FALSE);
+
+ /* Release PRIMARY selection if owned */
+ iReturn = XGetSelectionOwner (pDisplay, XA_PRIMARY);
+ if (iReturn == g_iClipboardWindow)
+ {
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "PRIMARY selection is owned by us.\n");
+ XSetSelectionOwner (pDisplay,
+ XA_PRIMARY,
+ None,
+ CurrentTime);
+ }
+ else if (BadWindow == iReturn || BadAtom == iReturn)
+ ErrorF ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "XGetSelection failed for PRIMARY: %d\n", iReturn);
+
+ /* Release CLIPBOARD selection if owned */
+ iReturn = XGetSelectionOwner (pDisplay,
+ atomClipboard);
+ if (iReturn == g_iClipboardWindow)
+ {
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "CLIPBOARD selection is owned by us.\n");
+ XSetSelectionOwner (pDisplay,
+ atomClipboard,
+ None,
+ CurrentTime);
+ }
+ else if (BadWindow == iReturn || BadAtom == iReturn)
+ ErrorF ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "XGetSelection failed for CLIPBOARD: %d\n", iReturn);
+
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
+ s_fProcessingDrawClipboard = FALSE;
+ if (s_hwndNextViewer)
+ SendMessage (s_hwndNextViewer, message, wParam, lParam);
+ return 0;
+ }
+ /* Only reassert ownership when we did not change the clipboard ourselves */
+ if (hwnd!=(HWND)wParam)
+ {
+ /* Reassert ownership of PRIMARY */
+ iReturn = XSetSelectionOwner (pDisplay,
+ XA_PRIMARY,
+ iWindow,
+ CurrentTime);
+ if (iReturn == BadAtom || iReturn == BadWindow ||
+ XGetSelectionOwner (pDisplay, XA_PRIMARY) != iWindow)
+ {
+ ErrorF ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "Could not reassert ownership of PRIMARY\n");
+ }
+ else
+ {
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "Reasserted ownership of PRIMARY\n");
+ }
+
+ /* Reassert ownership of the CLIPBOARD */
+ iReturn = XSetSelectionOwner (pDisplay,
+ atomClipboard,
+ iWindow,
+ CurrentTime);
+
+ if (iReturn == BadAtom || iReturn == BadWindow ||
+ XGetSelectionOwner (pDisplay, atomClipboard) != iWindow)
+ {
+ ErrorF ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "Could not reassert ownership of CLIPBOARD\n");
+ }
+ else
+ {
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "Reasserted ownership of CLIPBOARD\n");
+ }
+
+ /* Flush the pending SetSelectionOwner event now */
+ XFlush (pDisplay);
+ }
+
+ s_fProcessingDrawClipboard = FALSE;
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
+ /* Pass the message on the next window in the clipboard viewer chain */
+ if (s_hwndNextViewer)
+ SendMessage (s_hwndNextViewer, message, wParam, lParam);
+ return 0;
+
+ }
+
+ case WM_DESTROYCLIPBOARD:
+ /*
+ * NOTE: Intentionally do nothing.
+ * Changes in the Win32 clipboard are handled by WM_DRAWCLIPBOARD
+ * above. We only process this message to conform to the specs
+ * for delayed clipboard rendering in Win32. You might think
+ * that we need to release ownership of the X11 selections, but
+ * we do not, because a WM_DRAWCLIPBOARD message will closely
+ * follow this message and reassert ownership of the X11
+ * selections, handling the issue for us.
+ */
+ winDebug ("winClipboardWindowProc - WM_DESTROYCLIPBOARD - Ignored.\n");
+ return 0;
+
+ case WM_RENDERFORMAT:
+ case WM_RENDERALLFORMATS:
+ {
+ int iReturn;
+ Display *pDisplay = g_pClipboardDisplay;
+ Window iWindow = g_iClipboardWindow;
+ Bool fConvertToUnicode;
+
+ winDebug ("winClipboardWindowProc - WM_RENDER*FORMAT - Hello.\n");
+
+ /* Flag whether to convert to Unicode or not */
+ if (message == WM_RENDERALLFORMATS)
+ fConvertToUnicode = FALSE;
+ else
+ fConvertToUnicode = g_fUnicodeSupport && (CF_UNICODETEXT == wParam);
+
+ /* Request the selection contents */
+ iReturn = XConvertSelection (pDisplay,
+ g_atomLastOwnedSelection,
+ XInternAtom (pDisplay,
+ "COMPOUND_TEXT", False),
+ XInternAtom (pDisplay,
+ WIN_LOCAL_PROPERTY, False),
+ iWindow,
+ CurrentTime);
+ if (iReturn == BadAtom || iReturn == BadWindow)
+ {
+ ErrorF ("winClipboardWindowProc - WM_RENDER*FORMAT - "
+ "XConvertSelection () failed\n");
+ break;
+ }
+
+ /* Special handling for WM_RENDERALLFORMATS */
+ if (message == WM_RENDERALLFORMATS)
+ {
+ /* We must open and empty the clipboard */
+ if (!OpenClipboard (hwnd))
+ {
+ ErrorF ("winClipboardWindowProc - WM_RENDER*FORMATS - "
+ "OpenClipboard () failed: %08x\n",
+ GetLastError ());
+ break;
+ }
+
+ if (!EmptyClipboard ())
+ {
+ ErrorF ("winClipboardWindowProc - WM_RENDER*FORMATS - "
+ "EmptyClipboard () failed: %08x\n",
+ GetLastError ());
+ CloseClipboard ();
+ break;
+ }
+ }
+
+ /* Process the SelectionNotify event */
+ iReturn = winProcessXEventsTimeout (hwnd,
+ iWindow,
+ pDisplay,
+ fConvertToUnicode,
+ WIN_POLL_TIMEOUT);
+ if (WIN_XEVENTS_CONVERT == iReturn)
+ {
+ /*
+ * The selection was offered for conversion first, so we have
+ * to process a second SelectionNotify event to get the actual
+ * data in the selection.
+ */
+ winDebug("winClipboardWindowProc - Previous winProcessXEventsTimeout returned WIN_XEVENTS_CONVERT, calling it again\n");
+ iReturn = winProcessXEventsTimeout (hwnd,
+ iWindow,
+ pDisplay,
+ fConvertToUnicode,
+ WIN_POLL_TIMEOUT);
+ }
+
+ /*
+ * The last of the up-to two calls to winProcessXEventsTimeout
+ * from above had better have seen a notify event, or else we
+ * are dealing with a buggy or old X11 app. In these cases we
+ * have to paste some fake data to the Win32 clipboard to
+ * satisfy the requirement that we write something to it.
+ */
+ if (WIN_XEVENTS_NOTIFY != iReturn)
+ {
+ ErrorF("winClipboardWindowProc - winProcessXEventsTimeout should have returned WIN_XEVENTS_NOTIFY was %d\n",iReturn);
+ /* Paste no data, to satisfy required call to SetClipboardData */
+ if (g_fUnicodeSupport)
+ SetClipboardData (CF_UNICODETEXT, NULL);
+ SetClipboardData (CF_TEXT, NULL);
+
+ ErrorF("winClipboardWindowProc - timed out waiting for WIN_XEVENTS_NOTIFY\n");
+ }
+
+ /* Special handling for WM_RENDERALLFORMATS */
+ if (message == WM_RENDERALLFORMATS)
+ {
+ /* We must close the clipboard */
+
+ if (!CloseClipboard ())
+ {
+ ErrorF ("winClipboardWindowProc - WM_RENDERALLFORMATS - "
+ "CloseClipboard () failed: %08x\n",
+ GetLastError ());
+ break;
+ }
+ }
+
+ winDebug ("winClipboardWindowProc - WM_RENDER*FORMAT - Returning.\n");
+ return 0;
+ }
+ }
+
+ /* Let Windows perform default processing for unhandled messages */
+ return DefWindowProc (hwnd, message, wParam, lParam);
+}
+
+
+/*
+ * Process any pending Windows messages
+ */
+
+BOOL
+winClipboardFlushWindowsMessageQueue (HWND hwnd)
+{
+ MSG msg;
+
+ /* Flush the messaging window queue */
+ /* NOTE: Do not pass the hwnd of our messaging window to PeekMessage,
+ * as this will filter out many non-window-specific messages that
+ * are sent to our thread, such as WM_QUIT.
+ */
+ while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ /* Dispatch the message if not WM_QUIT */
+ if (msg.message == WM_QUIT)
+ return FALSE;
+ else
+ DispatchMessage (&msg);
+ }
+
+ return TRUE;
+}
diff --git a/xorg-server/hw/xwin/winclipboardwrappers.c b/xorg-server/hw/xwin/winclipboardwrappers.c
index 658d050d2..172365d27 100644
--- a/xorg-server/hw/xwin/winclipboardwrappers.c
+++ b/xorg-server/hw/xwin/winclipboardwrappers.c
@@ -1,527 +1,494 @@
-/*
- *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
- *Copyright (C) Colin Harrison 2005-2008
- *
- *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, 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 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 HAROLD L HUNT II 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 copyright holder(s)
- *and author(s) 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 copyright holder(s) and author(s).
- *
- * Authors: Harold L Hunt II
- * Colin Harrison
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-#include "dixstruct.h"
-#include <X11/Xatom.h>
-
-
-/*
- * Constants
- */
-
-#define CLIP_NUM_CALLS 4
-#define CLIP_NUM_SELECTIONS 2
-#define CLIP_OWN_PRIMARY 0
-#define CLIP_OWN_CLIPBOARD 1
-
-
-/*
- * Local function prototypes
- */
-
-DISPATCH_PROC(winProcEstablishConnection);
-DISPATCH_PROC(winProcQueryTree);
-DISPATCH_PROC(winProcSetSelectionOwner);
-
-
-/*
- * References to external symbols
- */
-
-extern Bool g_fUnicodeSupport;
-extern int g_iNumScreens;
-extern unsigned int g_uiAuthDataLen;
-extern char *g_pAuthData;
-extern Bool g_fXdmcpEnabled;
-extern Bool g_fClipboardLaunched;
-extern Bool g_fClipboardStarted;
-extern Bool g_fClipboard;
-extern Window g_iClipboardWindow;
-extern Atom g_atomLastOwnedSelection;
-extern HWND g_hwndClipboard;
-
-extern winDispatchProcPtr winProcEstablishConnectionOrig;
-extern winDispatchProcPtr winProcQueryTreeOrig;
-extern winDispatchProcPtr winProcSetSelectionOwnerOrig;
-
-
-/*
- * Wrapper for internal QueryTree function.
- * Hides the clipboard client when it is the only client remaining.
- */
-
-int
-winProcQueryTree (ClientPtr client)
-{
- int iReturn;
-
- ErrorF ("winProcQueryTree - Hello\n");
-
- /*
- * This procedure is only used for initialization.
- * We can unwrap the original procedure at this point
- * so that this function is no longer called until the
- * server resets and the function is wrapped again.
- */
- ProcVector[X_QueryTree] = winProcQueryTreeOrig;
-
- /*
- * Call original function and bail if it fails.
- * NOTE: We must do this first, since we need XdmcpOpenDisplay
- * to be called before we initialize our clipboard client.
- */
- iReturn = (*winProcQueryTreeOrig) (client);
- if (iReturn != 0)
- {
- ErrorF ("winProcQueryTree - ProcQueryTree failed, bailing.\n");
- return iReturn;
- }
-
- /* Make errors more obvious */
- winProcQueryTreeOrig = NULL;
-
- /* Do nothing if clipboard is not enabled */
- if (!g_fClipboard)
- {
- ErrorF ("winProcQueryTree - Clipboard is not enabled, "
- "returning.\n");
- return iReturn;
- }
-
- /* If the clipboard client has already been started, abort */
- if (g_fClipboardLaunched)
- {
- ErrorF ("winProcQueryTree - Clipboard client already "
- "launched, returning.\n");
- return iReturn;
- }
-
- /* Startup the clipboard client if clipboard mode is being used */
- if (g_fXdmcpEnabled && g_fClipboard)
- {
- /*
- * NOTE: The clipboard client is started here for a reason:
- * 1) Assume you are using XDMCP (e.g. XWin -query %hostname%)
- * 2) If the clipboard client attaches during X Server startup,
- * then it becomes the "magic client" that causes the X Server
- * to reset if it exits.
- * 3) XDMCP calls KillAllClients when it starts up.
- * 4) The clipboard client is a client, so it is killed.
- * 5) The clipboard client is the "magic client", so the X Server
- * resets itself.
- * 6) This repeats ad infinitum.
- * 7) We avoid this by waiting until at least one client (could
- * be XDM, could be another client) connects, which makes it
- * almost certain that the clipboard client will not connect
- * until after XDM when using XDMCP.
- * 8) Unfortunately, there is another problem.
- * 9) XDM walks the list of windows with XQueryTree,
- * killing any client it finds with a window.
- * 10)Thus, when using XDMCP we wait until the first call
- * to ProcQueryTree before we startup the clipboard client.
- * This should prevent XDM from finding the clipboard client,
- * since it has not yet created a window.
- * 11)Startup when not using XDMCP is handled in
- * winProcEstablishConnection.
- */
-
- /* Create the clipboard client thread */
- if (!winInitClipboard ())
- {
- ErrorF ("winProcQueryTree - winClipboardInit "
- "failed.\n");
- return iReturn;
- }
-
- ErrorF ("winProcQueryTree - winInitClipboard returned.\n");
- }
-
- /* Flag that clipboard client has been launched */
- g_fClipboardLaunched = TRUE;
-
- return iReturn;
-}
-
-
-/*
- * Wrapper for internal EstablishConnection function.
- * Initializes internal clients that must not be started until
- * an external client has connected.
- */
-
-int
-winProcEstablishConnection (ClientPtr client)
-{
- int iReturn;
- static int s_iCallCount = 0;
- static unsigned long s_ulServerGeneration = 0;
-
- if (s_iCallCount == 0 || s_iCallCount == CLIP_NUM_CALLS) ErrorF ("winProcEstablishConnection - Hello\n");
-
- /* Do nothing if clipboard is not enabled */
- if (!g_fClipboard)
- {
- ErrorF ("winProcEstablishConnection - Clipboard is not enabled, "
- "returning.\n");
-
- /* Unwrap the original function, call it, and return */
- InitialVector[2] = winProcEstablishConnectionOrig;
- iReturn = (*winProcEstablishConnectionOrig) (client);
- winProcEstablishConnectionOrig = NULL;
- return iReturn;
- }
-
- /* Watch for server reset */
- if (s_ulServerGeneration != serverGeneration)
- {
- /* Save new generation number */
- s_ulServerGeneration = serverGeneration;
-
- /* Reset call count */
- s_iCallCount = 0;
- }
-
- /* Increment call count */
- ++s_iCallCount;
-
- /* Wait for CLIP_NUM_CALLS when Xdmcp is enabled */
- if (g_fXdmcpEnabled
- && !g_fClipboardLaunched
- && s_iCallCount < CLIP_NUM_CALLS)
- {
- if (s_iCallCount == 1) ErrorF ("winProcEstablishConnection - Xdmcp, waiting to "
- "start clipboard client until %dth call", CLIP_NUM_CALLS);
- if (s_iCallCount == CLIP_NUM_CALLS - 1) ErrorF (".\n");
- else ErrorF (".");
- return (*winProcEstablishConnectionOrig) (client);
- }
-
- /*
- * This procedure is only used for initialization.
- * We can unwrap the original procedure at this point
- * so that this function is no longer called until the
- * server resets and the function is wrapped again.
- */
- InitialVector[2] = winProcEstablishConnectionOrig;
-
- /*
- * Call original function and bail if it fails.
- * NOTE: We must do this first, since we need XdmcpOpenDisplay
- * to be called before we initialize our clipboard client.
- */
- iReturn = (*winProcEstablishConnectionOrig) (client);
- if (iReturn != 0)
- {
- ErrorF ("winProcEstablishConnection - ProcEstablishConnection "
- "failed, bailing.\n");
- return iReturn;
- }
-
- /* Clear original function pointer */
- winProcEstablishConnectionOrig = NULL;
-
- /* If the clipboard client has already been started, abort */
- if (g_fClipboardLaunched)
- {
- ErrorF ("winProcEstablishConnection - Clipboard client already "
- "launched, returning.\n");
- return iReturn;
- }
-
- /* Startup the clipboard client if clipboard mode is being used */
- if (g_fClipboard)
- {
- /*
- * NOTE: The clipboard client is started here for a reason:
- * 1) Assume you are using XDMCP (e.g. XWin -query %hostname%)
- * 2) If the clipboard client attaches during X Server startup,
- * then it becomes the "magic client" that causes the X Server
- * to reset if it exits.
- * 3) XDMCP calls KillAllClients when it starts up.
- * 4) The clipboard client is a client, so it is killed.
- * 5) The clipboard client is the "magic client", so the X Server
- * resets itself.
- * 6) This repeats ad infinitum.
- * 7) We avoid this by waiting until at least one client (could
- * be XDM, could be another client) connects, which makes it
- * almost certain that the clipboard client will not connect
- * until after XDM when using XDMCP.
- * 8) Unfortunately, there is another problem.
- * 9) XDM walks the list of windows with XQueryTree,
- * killing any client it finds with a window.
- * 10)Thus, when using XDMCP we wait until CLIP_NUM_CALLS
- * to ProcEstablishCeonnection before we startup the clipboard
- * client. This should prevent XDM from finding the clipboard
- * client, since it has not yet created a window.
- */
-
- /* Create the clipboard client thread */
- if (!winInitClipboard ())
- {
- ErrorF ("winProcEstablishConnection - winClipboardInit "
- "failed.\n");
- return iReturn;
- }
-
- ErrorF ("winProcEstablishConnection - winInitClipboard returned.\n");
- }
-
- /* Flag that clipboard client has been launched */
- g_fClipboardLaunched = TRUE;
-
- return iReturn;
-}
-
-
-/*
- * Wrapper for internal SetSelectionOwner function.
- * Grabs ownership of Windows clipboard when X11 clipboard owner changes.
- */
-
-int
-winProcSetSelectionOwner (ClientPtr client)
-{
- int i;
- DrawablePtr pDrawable;
- WindowPtr pWindow = None;
- Bool fOwnedToNotOwned = FALSE;
- static Window s_iOwners[CLIP_NUM_SELECTIONS] = {None};
- static unsigned long s_ulServerGeneration = 0;
- REQUEST(xSetSelectionOwnerReq);
-
- REQUEST_SIZE_MATCH(xSetSelectionOwnerReq);
-
- winDebug("winProcSetSelectionOwner - Hello.\n");
-
- /* Watch for server reset */
- if (s_ulServerGeneration != serverGeneration)
- {
- /* Save new generation number */
- s_ulServerGeneration = serverGeneration;
-
- /* Initialize static variables */
- for (i = 0; i < CLIP_NUM_SELECTIONS; ++i)
- s_iOwners[i] = None;
- }
-
- /* Abort if clipboard not completely initialized yet */
- if (!g_fClipboardStarted)
- {
- /* ErrorF ("winProcSetSelectionOwner - Clipboard not yet started, "
- "aborting.\n"); */
- goto winProcSetSelectionOwner_Done;
- }
-
- /* Grab window if we have one */
- if (None != stuff->window)
- {
- /* Grab the Window from the request */
- int rc = dixLookupWindow(&pWindow, stuff->window, client, DixReadAccess);
- if (rc != Success) {
- ErrorF ("winProcSetSelectionOwner - Found BadWindow, aborting.\n");
- goto winProcSetSelectionOwner_Done;
- }
- }
-
- /* Now we either have a valid window or None */
-
- /* Save selection owners for monitored selections, ignore other selections */
- if (XA_PRIMARY == stuff->selection)
- {
- /* Look for owned -> not owned transition */
- if (None == stuff->window
- && None != s_iOwners[CLIP_OWN_PRIMARY])
- {
- fOwnedToNotOwned = TRUE;
-
- winDebug("winProcSetSelectionOwner - PRIMARY - Going from "
- "owned to not owned.\n");
-
- /* Adjust last owned selection */
- if (None != s_iOwners[CLIP_OWN_CLIPBOARD])
- g_atomLastOwnedSelection = MakeAtom ("CLIPBOARD", 9, TRUE);
- else
- g_atomLastOwnedSelection = None;
- }
-
- /* Save new selection owner or None */
- s_iOwners[CLIP_OWN_PRIMARY] = stuff->window;
-
- winDebug("winProcSetSelectionOwner - PRIMARY - Now owned by: %d\n",
- stuff->window);
- }
- else if (MakeAtom ("CLIPBOARD", 9, TRUE) == stuff->selection)
- {
- /* Look for owned -> not owned transition */
- if (None == stuff->window
- && None != s_iOwners[CLIP_OWN_CLIPBOARD])
- {
- fOwnedToNotOwned = TRUE;
-
- winDebug("winProcSetSelectionOwner - CLIPBOARD - Going from "
- "owned to not owned.\n");
-
- /* Adjust last owned selection */
- if (None != s_iOwners[CLIP_OWN_PRIMARY])
- g_atomLastOwnedSelection = XA_PRIMARY;
- else
- g_atomLastOwnedSelection = None;
- }
-
- /* Save new selection owner or None */
- s_iOwners[CLIP_OWN_CLIPBOARD] = stuff->window;
-
- winDebug("winProcSetSelectionOwner - CLIPBOARD - Now owned by: %d\n",
- stuff->window);
-
- }
- else
- goto winProcSetSelectionOwner_Done;
-
- /*
- * At this point, if one of the selections is still owned by the
- * clipboard manager then it should be marked as unowned since
- * we will be taking ownership of the Win32 clipboard.
- */
- if (g_iClipboardWindow == s_iOwners[CLIP_OWN_PRIMARY])
- s_iOwners[CLIP_OWN_PRIMARY] = None;
- if (g_iClipboardWindow == s_iOwners[CLIP_OWN_CLIPBOARD])
- s_iOwners[CLIP_OWN_CLIPBOARD] = None;
-
- /*
- * Handle case when selection is being disowned,
- * WM_DRAWCLIPBOARD did not do the disowning,
- * both monitored selections are no longer owned,
- * an owned to not owned transition was detected,
- * and we currently own the Win32 clipboard.
- */
- if (stuff->window == None
- && s_iOwners[CLIP_OWN_PRIMARY] == None
- && s_iOwners[CLIP_OWN_CLIPBOARD] == None
- && fOwnedToNotOwned
- && g_hwndClipboard != NULL
- && g_hwndClipboard == GetClipboardOwner ())
- {
- winDebug("winProcSetSelectionOwner - We currently own the "
- "clipboard and neither the PRIMARY nor the CLIPBOARD "
- "selections are owned, releasing ownership of Win32 "
- "clipboard.\n");
-
- /* Release ownership of the Windows clipboard */
- OpenClipboard (NULL);
- EmptyClipboard ();
- CloseClipboard ();
-
- goto winProcSetSelectionOwner_Done;
- }
-
- /* Abort if no window at this point */
- if (None == stuff->window)
- {
- winDebug("winProcSetSelectionOwner - No window, returning.\n");
- goto winProcSetSelectionOwner_Done;
- }
-
- /* Abort if invalid selection */
- if (!ValidAtom (stuff->selection))
- {
- ErrorF ("winProcSetSelectionOwner - Found BadAtom, aborting.\n");
- goto winProcSetSelectionOwner_Done;
- }
-
- /* Cast Window to Drawable */
- pDrawable = (DrawablePtr) pWindow;
-
- /* Abort if clipboard manager is owning the selection */
- if (pDrawable->id == g_iClipboardWindow)
- {
- winDebug("winProcSetSelectionOwner - We changed ownership, "
- "aborting.\n");
- goto winProcSetSelectionOwner_Done;
- }
-
- /* Abort if root window is taking ownership */
- if (pDrawable->id == 0)
- {
- ErrorF ("winProcSetSelectionOwner - Root window taking ownership, "
- "aborting\n");
- goto winProcSetSelectionOwner_Done;
- }
-
- /* Close clipboard if we have it open already */
- if (GetOpenClipboardWindow () == g_hwndClipboard)
- {
- CloseClipboard ();
- }
-
- /* Access the Windows clipboard */
- if (!OpenClipboard (g_hwndClipboard))
- {
- ErrorF ("winProcSetSelectionOwner - OpenClipboard () failed: %08x\n",
- (int) GetLastError ());
- goto winProcSetSelectionOwner_Done;
- }
-
- /* Take ownership of the Windows clipboard */
- if (!EmptyClipboard ())
- {
- ErrorF ("winProcSetSelectionOwner - EmptyClipboard () failed: %08x\n",
- (int) GetLastError ());
- goto winProcSetSelectionOwner_Done;
- }
-
- /* Advertise Unicode if we support it */
- if (g_fUnicodeSupport)
- SetClipboardData (CF_UNICODETEXT, NULL);
-
- /* Always advertise regular text */
- SetClipboardData (CF_TEXT, NULL);
-
- /* Save handle to last owned selection */
- g_atomLastOwnedSelection = stuff->selection;
-
- /* Release the clipboard */
- if (!CloseClipboard ())
- {
- ErrorF ("winProcSetSelectionOwner - CloseClipboard () failed: "
- "%08x\n",
- (int) GetLastError ());
- goto winProcSetSelectionOwner_Done;
- }
-
- winProcSetSelectionOwner_Done:
- return (*winProcSetSelectionOwnerOrig) (client);
-}
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *Copyright (C) Colin Harrison 2005-2008
+ *
+ *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, 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 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 HAROLD L HUNT II 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 copyright holder(s)
+ *and author(s) 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 copyright holder(s) and author(s).
+ *
+ * Authors: Harold L Hunt II
+ * Colin Harrison
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "dixstruct.h"
+#include <X11/Xatom.h>
+
+
+/*
+ * Constants
+ */
+
+#define CLIP_NUM_CALLS 4
+#define CLIP_NUM_SELECTIONS 2
+#define CLIP_OWN_PRIMARY 0
+#define CLIP_OWN_CLIPBOARD 1
+
+
+/*
+ * Local function prototypes
+ */
+
+DISPATCH_PROC(winProcEstablishConnection);
+DISPATCH_PROC(winProcQueryTree);
+DISPATCH_PROC(winProcSetSelectionOwner);
+
+
+/*
+ * References to external symbols
+ */
+
+extern Bool g_fUnicodeSupport;
+extern int g_iNumScreens;
+extern unsigned int g_uiAuthDataLen;
+extern char *g_pAuthData;
+extern Bool g_fXdmcpEnabled;
+extern Bool g_fClipboardLaunched;
+extern Bool g_fClipboardStarted;
+extern Bool g_fClipboard;
+extern Window g_iClipboardWindow;
+extern Atom g_atomLastOwnedSelection;
+extern HWND g_hwndClipboard;
+
+extern winDispatchProcPtr winProcEstablishConnectionOrig;
+extern winDispatchProcPtr winProcQueryTreeOrig;
+extern winDispatchProcPtr winProcSetSelectionOwnerOrig;
+
+
+/*
+ * Wrapper for internal QueryTree function.
+ * Hides the clipboard client when it is the only client remaining.
+ */
+
+int
+winProcQueryTree (ClientPtr client)
+{
+ int iReturn;
+
+ winDebug ("winProcQueryTree - Hello\n");
+
+ /*
+ * This procedure is only used for initialization.
+ * We can unwrap the original procedure at this point
+ * so that this function is no longer called until the
+ * server resets and the function is wrapped again.
+ */
+ ProcVector[X_QueryTree] = winProcQueryTreeOrig;
+
+ /*
+ * Call original function and bail if it fails.
+ * NOTE: We must do this first, since we need XdmcpOpenDisplay
+ * to be called before we initialize our clipboard client.
+ */
+ iReturn = (*winProcQueryTreeOrig) (client);
+ if (iReturn != 0)
+ {
+ ErrorF ("winProcQueryTree - ProcQueryTree failed, bailing.\n");
+ return iReturn;
+ }
+
+ /* Make errors more obvious */
+ winProcQueryTreeOrig = NULL;
+
+ /* Do nothing if clipboard is not enabled */
+ if (!g_fClipboard)
+ {
+ winDebug ("winProcQueryTree - Clipboard is not enabled, "
+ "returning.\n");
+ return iReturn;
+ }
+
+ /* If the clipboard client has already been started, abort */
+ if (g_fClipboardLaunched)
+ {
+ winDebug ("winProcQueryTree - Clipboard client already "
+ "launched, returning.\n");
+ return iReturn;
+ }
+
+ /* Startup the clipboard client if clipboard mode is being used */
+ if (g_fXdmcpEnabled && g_fClipboard)
+ {
+ /*
+ * NOTE: The clipboard client is started here for a reason:
+ * 1) Assume you are using XDMCP (e.g. XWin -query %hostname%)
+ * 2) If the clipboard client attaches during X Server startup,
+ * then it becomes the "magic client" that causes the X Server
+ * to reset if it exits.
+ * 3) XDMCP calls KillAllClients when it starts up.
+ * 4) The clipboard client is a client, so it is killed.
+ * 5) The clipboard client is the "magic client", so the X Server
+ * resets itself.
+ * 6) This repeats ad infinitum.
+ * 7) We avoid this by waiting until at least one client (could
+ * be XDM, could be another client) connects, which makes it
+ * almost certain that the clipboard client will not connect
+ * until after XDM when using XDMCP.
+ * 8) Unfortunately, there is another problem.
+ * 9) XDM walks the list of windows with XQueryTree,
+ * killing any client it finds with a window.
+ * 10)Thus, when using XDMCP we wait until the first call
+ * to ProcQueryTree before we startup the clipboard client.
+ * This should prevent XDM from finding the clipboard client,
+ * since it has not yet created a window.
+ * 11)Startup when not using XDMCP is handled in
+ * winProcEstablishConnection.
+ */
+
+ /* Create the clipboard client thread */
+ if (!winInitClipboard ())
+ {
+ ErrorF ("winProcQueryTree - winClipboardInit "
+ "failed.\n");
+ return iReturn;
+ }
+
+ winDebug ("winProcQueryTree - winInitClipboard returned.\n");
+ }
+
+ /* Flag that clipboard client has been launched */
+ g_fClipboardLaunched = TRUE;
+
+ return iReturn;
+}
+
+
+/*
+ * Wrapper for internal EstablishConnection function.
+ * Initializes internal clients that must not be started until
+ * an external client has connected.
+ */
+
+int
+winProcEstablishConnection (ClientPtr client)
+{
+ int iReturn;
+ static int s_iCallCount = 0;
+ static unsigned long s_ulServerGeneration = 0;
+
+ #ifdef WINDBG
+ if (s_iCallCount == 0 || s_iCallCount == CLIP_NUM_CALLS) winDebug ("winProcEstablishConnection - Hello\n");
+ #endif
+
+ /* Do nothing if clipboard is not enabled */
+ if (!g_fClipboard)
+ {
+ winDebug ("winProcEstablishConnection - Clipboard is not enabled, "
+ "returning.\n");
+
+ /* Unwrap the original function, call it, and return */
+ InitialVector[2] = winProcEstablishConnectionOrig;
+ iReturn = (*winProcEstablishConnectionOrig) (client);
+ winProcEstablishConnectionOrig = NULL;
+ return iReturn;
+ }
+
+ /* Watch for server reset */
+ if (s_ulServerGeneration != serverGeneration)
+ {
+ /* Save new generation number */
+ s_ulServerGeneration = serverGeneration;
+
+ /* Reset call count */
+ s_iCallCount = 0;
+ }
+
+ /* Increment call count */
+ ++s_iCallCount;
+
+ /* Wait for CLIP_NUM_CALLS when Xdmcp is enabled */
+ if (g_fXdmcpEnabled
+ && !g_fClipboardLaunched
+ && s_iCallCount < CLIP_NUM_CALLS)
+ {
+ #ifdef WINDBG
+ if (s_iCallCount == 1) winDebug ("winProcEstablishConnection - Xdmcp, waiting to "
+ "start clipboard client until %dth call", CLIP_NUM_CALLS);
+ if (s_iCallCount == CLIP_NUM_CALLS - 1) winDebug (".\n");
+ else winDebug (".");
+ #endif
+ return (*winProcEstablishConnectionOrig) (client);
+ }
+
+ /*
+ * This procedure is only used for initialization.
+ * We can unwrap the original procedure at this point
+ * so that this function is no longer called until the
+ * server resets and the function is wrapped again.
+ */
+ InitialVector[2] = winProcEstablishConnectionOrig;
+
+ /*
+ * Call original function and bail if it fails.
+ * NOTE: We must do this first, since we need XdmcpOpenDisplay
+ * to be called before we initialize our clipboard client.
+ */
+ iReturn = (*winProcEstablishConnectionOrig) (client);
+ if (iReturn != 0)
+ {
+ ErrorF ("winProcEstablishConnection - ProcEstablishConnection "
+ "failed, bailing.\n");
+ return iReturn;
+ }
+
+ /* Clear original function pointer */
+ winProcEstablishConnectionOrig = NULL;
+
+ /* If the clipboard client has already been started, abort */
+ if (g_fClipboardLaunched)
+ {
+ winDebug ("winProcEstablishConnection - Clipboard client already "
+ "launched, returning.\n");
+ return iReturn;
+ }
+
+ /* Startup the clipboard client if clipboard mode is being used */
+ if (g_fClipboard)
+ {
+ /*
+ * NOTE: The clipboard client is started here for a reason:
+ * 1) Assume you are using XDMCP (e.g. XWin -query %hostname%)
+ * 2) If the clipboard client attaches during X Server startup,
+ * then it becomes the "magic client" that causes the X Server
+ * to reset if it exits.
+ * 3) XDMCP calls KillAllClients when it starts up.
+ * 4) The clipboard client is a client, so it is killed.
+ * 5) The clipboard client is the "magic client", so the X Server
+ * resets itself.
+ * 6) This repeats ad infinitum.
+ * 7) We avoid this by waiting until at least one client (could
+ * be XDM, could be another client) connects, which makes it
+ * almost certain that the clipboard client will not connect
+ * until after XDM when using XDMCP.
+ * 8) Unfortunately, there is another problem.
+ * 9) XDM walks the list of windows with XQueryTree,
+ * killing any client it finds with a window.
+ * 10)Thus, when using XDMCP we wait until CLIP_NUM_CALLS
+ * to ProcEstablishCeonnection before we startup the clipboard
+ * client. This should prevent XDM from finding the clipboard
+ * client, since it has not yet created a window.
+ */
+
+ /* Create the clipboard client thread */
+ if (!winInitClipboard ())
+ {
+ ErrorF ("winProcEstablishConnection - winClipboardInit "
+ "failed.\n");
+ return iReturn;
+ }
+
+ winDebug ("winProcEstablishConnection - winInitClipboard returned.\n");
+ }
+
+ /* Flag that clipboard client has been launched */
+ g_fClipboardLaunched = TRUE;
+
+ return iReturn;
+}
+
+
+/*
+ * Wrapper for internal SetSelectionOwner function.
+ * Grabs ownership of Windows clipboard when X11 clipboard owner changes.
+ */
+int
+winProcSetSelectionOwner (ClientPtr client)
+{
+ int i;
+ DrawablePtr pDrawable;
+ WindowPtr pWindow = None;
+ static Window s_iOwners[CLIP_NUM_SELECTIONS] = {None};
+ static unsigned long s_ulServerGeneration = 0;
+ REQUEST(xSetSelectionOwnerReq);
+
+ REQUEST_SIZE_MATCH(xSetSelectionOwnerReq);
+
+ winDebug ("winProcSetSelectionOwner - Hello.\n");
+
+ /* Watch for server reset */
+ if (s_ulServerGeneration != serverGeneration)
+ {
+ /* Save new generation number */
+ s_ulServerGeneration = serverGeneration;
+
+ /* Initialize static variables */
+ for (i = 0; i < CLIP_NUM_SELECTIONS; ++i)
+ s_iOwners[i] = None;
+ }
+
+ /* Abort if clipboard not completely initialized yet */
+ if (!g_fClipboardStarted)
+ {
+ winDebug ("winProcSetSelectionOwner - Clipboard not yet started, "
+ "aborting.\n");
+ goto winProcSetSelectionOwner_Done;
+ }
+
+ /* Grab window if we have one */
+ if (None != stuff->window)
+ {
+ /* Grab the Window from the request */
+ int rc = dixLookupWindow(&pWindow, stuff->window, client, DixReadAccess);
+ if (rc != Success) {
+ ErrorF ("winProcSetSelectionOwner - Found BadWindow, aborting.\n");
+ goto winProcSetSelectionOwner_Done;
+ }
+ }
+
+ /* Now we either have a valid window or None */
+
+ /* Save selection owners for monitored selections, ignore other selections */
+ if (XA_PRIMARY == stuff->selection)
+ {
+ /* Look for owned -> not owned transition */
+ if (None == stuff->window
+ && None != s_iOwners[CLIP_OWN_PRIMARY])
+ {
+ winDebug ("winProcSetSelectionOwner - PRIMARY - Going from "
+ "owned to not owned.\n");
+
+ /* Adjust last owned selection */
+ if (None != s_iOwners[CLIP_OWN_CLIPBOARD])
+ g_atomLastOwnedSelection = MakeAtom ("CLIPBOARD", 9, TRUE);
+ else
+ g_atomLastOwnedSelection = None;
+ }
+
+ /* Save new selection owner or None */
+ s_iOwners[CLIP_OWN_PRIMARY] = stuff->window;
+
+ winDebug ("winProcSetSelectionOwner - PRIMARY - Now owned by: 0x%x (clipboard is 0x%x)\n",
+ stuff->window,g_iClipboardWindow);
+ }
+ else if (MakeAtom ("CLIPBOARD", 9, TRUE) == stuff->selection)
+ {
+ /* Look for owned -> not owned transition */
+ if (None == stuff->window
+ && None != s_iOwners[CLIP_OWN_CLIPBOARD])
+ {
+ winDebug ("winProcSetSelectionOwner - CLIPBOARD - Going from "
+ "owned to not owned.\n");
+
+ /* Adjust last owned selection */
+ if (None != s_iOwners[CLIP_OWN_PRIMARY])
+ g_atomLastOwnedSelection = XA_PRIMARY;
+ else
+ g_atomLastOwnedSelection = None;
+ }
+
+ /* Save new selection owner or None */
+ s_iOwners[CLIP_OWN_CLIPBOARD] = stuff->window;
+
+ winDebug ("winProcSetSelectionOwner - CLIPBOARD - Now owned by: 0x%x, clipboard is 0x%x\n",
+ stuff->window,g_iClipboardWindow);
+ }
+ else
+ goto winProcSetSelectionOwner_Done;
+
+ /*
+ * At this point, if one of the selections is still owned by the
+ * clipboard manager then it should be marked as unowned since
+ * we will be taking ownership of the Win32 clipboard.
+ */
+ if (g_iClipboardWindow == s_iOwners[CLIP_OWN_PRIMARY])
+ s_iOwners[CLIP_OWN_PRIMARY] = None;
+ if (g_iClipboardWindow == s_iOwners[CLIP_OWN_CLIPBOARD])
+ s_iOwners[CLIP_OWN_CLIPBOARD] = None;
+
+ /* Abort if no window at this point */
+ if (None == stuff->window)
+ {
+ winDebug ("winProcSetSelectionOwner - No window, returning.\n");
+ goto winProcSetSelectionOwner_Done;
+ }
+
+ /* Abort if invalid selection */
+ if (!ValidAtom (stuff->selection))
+ {
+ winDebug ("winProcSetSelectionOwner - Found BadAtom, aborting.\n");
+ goto winProcSetSelectionOwner_Done;
+ }
+
+ /* Cast Window to Drawable */
+ pDrawable = (DrawablePtr) pWindow;
+
+ /* Abort if clipboard manager is owning the selection */
+ if (pDrawable->id == g_iClipboardWindow)
+ {
+ winDebug ("winProcSetSelectionOwner - We changed ownership, "
+ "aborting.\n");
+ goto winProcSetSelectionOwner_Done;
+ }
+
+ /* Abort if root window is taking ownership */
+ if (pDrawable->id == 0)
+ {
+ winDebug ("winProcSetSelectionOwner - Root window taking ownership, "
+ "aborting\n");
+ goto winProcSetSelectionOwner_Done;
+ }
+
+ /* Access the Windows clipboard */
+ if (!OpenClipboard (g_hwndClipboard))
+ {
+ ErrorF ("winProcSetSelectionOwner - OpenClipboard () failed: %08x, hwnd: %08x\n",
+ (int) GetLastError (),g_hwndClipboard);
+ goto winProcSetSelectionOwner_Done;
+ }
+
+ /* Take ownership of the Windows clipboard */
+ if (!EmptyClipboard ())
+ {
+ ErrorF ("winProcSetSelectionOwner - EmptyClipboard () failed: %08x\n",
+ (int) GetLastError ());
+ CloseClipboard ();
+ goto winProcSetSelectionOwner_Done;
+ }
+
+ winDebug("winProcSetSelectionOwner - SetClipboardData NULL\n");
+
+ /* Advertise Unicode if we support it */
+ if (g_fUnicodeSupport)
+ SetClipboardData (CF_UNICODETEXT, NULL);
+
+ /* Always advertise regular text */
+ SetClipboardData (CF_TEXT, NULL);
+
+ /* Save handle to last owned selection */
+ g_atomLastOwnedSelection = stuff->selection;
+
+ /* Release the clipboard */
+ if (!CloseClipboard ())
+ {
+ ErrorF ("winProcSetSelectionOwner - CloseClipboard () failed: "
+ "%08x\n",
+ (int) GetLastError ());
+ goto winProcSetSelectionOwner_Done;
+ }
+
+winProcSetSelectionOwner_Done:
+ return (*winProcSetSelectionOwnerOrig) (client);
+}
diff --git a/xorg-server/hw/xwin/winclipboardxevents.c b/xorg-server/hw/xwin/winclipboardxevents.c
index ae8262ebf..363b0f6fd 100644
--- a/xorg-server/hw/xwin/winclipboardxevents.c
+++ b/xorg-server/hw/xwin/winclipboardxevents.c
@@ -1,802 +1,838 @@
-/*
- *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
- *Copyright (C) Colin Harrison 2005-2008
- *
- *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, 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 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 HAROLD L HUNT II 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 copyright holder(s)
- *and author(s) 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 copyright holder(s) and author(s).
- *
- * Authors: Harold L Hunt II
- * Colin Harrison
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "winclipboard.h"
-#include "misc.h"
-
-
-/*
- * References to external symbols
- */
-
-extern Bool g_fUnicodeSupport;
-
-
-/*
- * Process any pending X events
- */
-
-int
-winClipboardFlushXEvents (HWND hwnd,
- int iWindow,
- Display *pDisplay,
- Bool fUseUnicode)
-{
- static Atom atomLocalProperty;
- static Atom atomCompoundText;
- static Atom atomUTF8String;
- static Atom atomTargets;
- static int generation;
-
- if (generation != serverGeneration)
- {
- generation = serverGeneration;
- atomLocalProperty = XInternAtom (pDisplay, WIN_LOCAL_PROPERTY, False);
- atomUTF8String = XInternAtom (pDisplay, "UTF8_STRING", False);
- atomCompoundText = XInternAtom (pDisplay, "COMPOUND_TEXT", False);
- atomTargets = XInternAtom (pDisplay, "TARGETS", False);
- }
-
- /* Process all pending events */
- while (XPending (pDisplay))
- {
- XTextProperty xtpText = {0};
- XEvent event;
- XSelectionEvent eventSelection;
- unsigned long ulReturnBytesLeft;
- unsigned char *pszReturnData = NULL;
- char *pszGlobalData = NULL;
- int iReturn;
- HGLOBAL hGlobal = NULL;
- XICCEncodingStyle xiccesStyle;
- int iConvertDataLen = 0;
- char *pszConvertData = NULL;
- char *pszTextList[2] = {NULL};
- int iCount;
- char **ppszTextList = NULL;
- wchar_t *pwszUnicodeStr = NULL;
- int iUnicodeLen = 0;
- int iReturnDataLen = 0;
- int i;
- Bool fAbort = FALSE;
- Bool fCloseClipboard = FALSE;
- Bool fSetClipboardData = TRUE;
-
- /* Get the next event - will not block because one is ready */
- XNextEvent (pDisplay, &event);
-
- /* Branch on the event type */
- switch (event.type)
- {
- /*
- * SelectionRequest
- */
-
- case SelectionRequest:
- {
- char *pszAtomName = NULL;
- winDebug("SelectionRequest - target %d\n",
- event.xselectionrequest.target);
-
- pszAtomName = XGetAtomName (pDisplay,
- event.xselectionrequest.target);
- winDebug("SelectionRequest - Target atom name %s\n", pszAtomName);
- XFree (pszAtomName);
- pszAtomName = NULL;
- }
-
- /* Abort if invalid target type */
- if (event.xselectionrequest.target != XA_STRING
- && event.xselectionrequest.target != atomUTF8String
- && event.xselectionrequest.target != atomCompoundText
- && event.xselectionrequest.target != atomTargets)
- {
- /* Abort */
- fAbort = TRUE;
- goto winClipboardFlushXEvents_SelectionRequest_Done;
- }
-
- /* Handle targets type of request */
- if (event.xselectionrequest.target == atomTargets)
- {
- Atom atomTargetArr[] = {atomTargets,
- atomCompoundText,
- atomUTF8String,
- XA_STRING};
-
- /* Try to change the property */
- iReturn = XChangeProperty (pDisplay,
- event.xselectionrequest.requestor,
- event.xselectionrequest.property,
- XA_ATOM,
- 32,
- PropModeReplace,
- (unsigned char *) atomTargetArr,
- (sizeof (atomTargetArr)
- / sizeof (atomTargetArr[0])));
- if (iReturn == BadAlloc
- || iReturn == BadAtom
- || iReturn == BadMatch
- || iReturn == BadValue
- || iReturn == BadWindow)
- {
- ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
- "XChangeProperty failed: %d\n",
- iReturn);
- }
-
- /* Setup selection notify xevent */
- eventSelection.type = SelectionNotify;
- eventSelection.send_event = True;
- eventSelection.display = pDisplay;
- eventSelection.requestor = event.xselectionrequest.requestor;
- eventSelection.selection = event.xselectionrequest.selection;
- eventSelection.target = event.xselectionrequest.target;
- eventSelection.property = event.xselectionrequest.property;
- eventSelection.time = event.xselectionrequest.time;
-
- /*
- * Notify the requesting window that
- * the operation has completed
- */
- iReturn = XSendEvent (pDisplay,
- eventSelection.requestor,
- False,
- 0L,
- (XEvent *) &eventSelection);
- if (iReturn == BadValue || iReturn == BadWindow)
- {
- ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
- "XSendEvent () failed\n");
- }
- break;
- }
-
- /* Check that clipboard format is available */
- if (fUseUnicode
- && !IsClipboardFormatAvailable (CF_UNICODETEXT))
- {
- static int count; /* Hack to stop acroread spamming the log */
- static HWND lasthwnd; /* I've not seen any other client get here repeatedly? */
- if (hwnd != lasthwnd) count = 0;
- count++;
- if (count < 6) ErrorF ("winClipboardFlushXEvents - CF_UNICODETEXT is not "
- "available from Win32 clipboard. Aborting %d.\n", count);
- lasthwnd = hwnd;
-
- /* Abort */
- fAbort = TRUE;
- goto winClipboardFlushXEvents_SelectionRequest_Done;
- }
- else if (!fUseUnicode
- && !IsClipboardFormatAvailable (CF_TEXT))
- {
- ErrorF ("winClipboardFlushXEvents - CF_TEXT is not "
- "available from Win32 clipboard. Aborting.\n");
-
- /* Abort */
- fAbort = TRUE;
- goto winClipboardFlushXEvents_SelectionRequest_Done;
- }
-
- /* Close clipboard if we have it open already */
- if (GetOpenClipboardWindow () == hwnd)
- {
- CloseClipboard ();
- }
-
- /* Access the clipboard */
- if (!OpenClipboard (hwnd))
- {
- ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
- "OpenClipboard () failed: %08x\n",
- GetLastError ());
-
- /* Abort */
- fAbort = TRUE;
- goto winClipboardFlushXEvents_SelectionRequest_Done;
- }
-
- /* Indicate that clipboard was opened */
- fCloseClipboard = TRUE;
-
- /* Setup the string style */
- if (event.xselectionrequest.target == XA_STRING)
- xiccesStyle = XStringStyle;
-#ifdef X_HAVE_UTF8_STRING
- else if (event.xselectionrequest.target == atomUTF8String)
- xiccesStyle = XUTF8StringStyle;
-#endif
- else if (event.xselectionrequest.target == atomCompoundText)
- xiccesStyle = XCompoundTextStyle;
- else
- xiccesStyle = XStringStyle;
-
- /*
- * FIXME: Can't pass CF_UNICODETEXT on Windows 95/98/Me
- */
-
- /* Get a pointer to the clipboard text, in desired format */
- if (fUseUnicode)
- {
- /* Retrieve clipboard data */
- hGlobal = GetClipboardData (CF_UNICODETEXT);
- }
- else
- {
- /* Retrieve clipboard data */
- hGlobal = GetClipboardData (CF_TEXT);
- }
- if (!hGlobal)
- {
- ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
- "GetClipboardData () failed: %08x\n",
- GetLastError ());
-
- /* Abort */
- fAbort = TRUE;
- goto winClipboardFlushXEvents_SelectionRequest_Done;
- }
- pszGlobalData = (char *) GlobalLock (hGlobal);
-
- /* Convert the Unicode string to UTF8 (MBCS) */
- if (fUseUnicode)
- {
- iConvertDataLen = WideCharToMultiByte (CP_UTF8,
- 0,
- (LPCWSTR)pszGlobalData,
- -1,
- NULL,
- 0,
- NULL,
- NULL);
- /* NOTE: iConvertDataLen includes space for null terminator */
- pszConvertData = (char *) malloc (iConvertDataLen);
- WideCharToMultiByte (CP_UTF8,
- 0,
- (LPCWSTR)pszGlobalData,
- -1,
- pszConvertData,
- iConvertDataLen,
- NULL,
- NULL);
- }
- else
- {
- pszConvertData = strdup (pszGlobalData);
- iConvertDataLen = strlen (pszConvertData) + 1;
- }
-
- /* Convert DOS string to UNIX string */
- winClipboardDOStoUNIX (pszConvertData, strlen (pszConvertData));
-
- /* Setup our text list */
- pszTextList[0] = pszConvertData;
- pszTextList[1] = NULL;
-
- /* Initialize the text property */
- xtpText.value = NULL;
- xtpText.nitems = 0;
-
- /* Create the text property from the text list */
- if (fUseUnicode)
- {
-#ifdef X_HAVE_UTF8_STRING
- iReturn = Xutf8TextListToTextProperty (pDisplay,
- pszTextList,
- 1,
- xiccesStyle,
- &xtpText);
-#endif
- }
- else
- {
- iReturn = XmbTextListToTextProperty (pDisplay,
- pszTextList,
- 1,
- xiccesStyle,
- &xtpText);
- }
- if (iReturn == XNoMemory || iReturn == XLocaleNotSupported)
- {
- ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
- "X*TextListToTextProperty failed: %d\n",
- iReturn);
-
- /* Abort */
- fAbort = TRUE;
- goto winClipboardFlushXEvents_SelectionRequest_Done;
- }
-
- /* Free the converted string */
- free (pszConvertData);
- pszConvertData = NULL;
-
- /* Copy the clipboard text to the requesting window */
- iReturn = XChangeProperty (pDisplay,
- event.xselectionrequest.requestor,
- event.xselectionrequest.property,
- event.xselectionrequest.target,
- 8,
- PropModeReplace,
- xtpText.value,
- xtpText.nitems);
- if (iReturn == BadAlloc || iReturn == BadAtom
- || iReturn == BadMatch || iReturn == BadValue
- || iReturn == BadWindow)
- {
- ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
- "XChangeProperty failed: %d\n",
- iReturn);
-
- /* Abort */
- fAbort = TRUE;
- goto winClipboardFlushXEvents_SelectionRequest_Done;
- }
-
- /* Release the clipboard data */
- GlobalUnlock (hGlobal);
- pszGlobalData = NULL;
- fCloseClipboard = FALSE;
- CloseClipboard ();
-
- /* Clean up */
- XFree (xtpText.value);
- xtpText.value = NULL;
- xtpText.nitems = 0;
-
- /* Setup selection notify event */
- eventSelection.type = SelectionNotify;
- eventSelection.send_event = True;
- eventSelection.display = pDisplay;
- eventSelection.requestor = event.xselectionrequest.requestor;
- eventSelection.selection = event.xselectionrequest.selection;
- eventSelection.target = event.xselectionrequest.target;
- eventSelection.property = event.xselectionrequest.property;
- eventSelection.time = event.xselectionrequest.time;
-
- /* Notify the requesting window that the operation has completed */
- iReturn = XSendEvent (pDisplay,
- eventSelection.requestor,
- False,
- 0L,
- (XEvent *) &eventSelection);
- if (iReturn == BadValue || iReturn == BadWindow)
- {
- ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
- "XSendEvent () failed\n");
-
- /* Abort */
- fAbort = TRUE;
- goto winClipboardFlushXEvents_SelectionRequest_Done;
- }
-
- winClipboardFlushXEvents_SelectionRequest_Done:
- /* Free allocated resources */
- if (xtpText.value)
- {
- XFree (xtpText.value);
- xtpText.value = NULL;
- xtpText.nitems = 0;
- }
- if (pszConvertData)
- free (pszConvertData);
- if (hGlobal && pszGlobalData)
- GlobalUnlock (hGlobal);
-
- /*
- * Send a SelectionNotify event to the requesting
- * client when we abort.
- */
- if (fAbort)
- {
- /* Setup selection notify event */
- eventSelection.type = SelectionNotify;
- eventSelection.send_event = True;
- eventSelection.display = pDisplay;
- eventSelection.requestor = event.xselectionrequest.requestor;
- eventSelection.selection = event.xselectionrequest.selection;
- eventSelection.target = event.xselectionrequest.target;
- eventSelection.property = None;
- eventSelection.time = event.xselectionrequest.time;
-
- /* Notify the requesting window that the operation is complete */
- iReturn = XSendEvent (pDisplay,
- eventSelection.requestor,
- False,
- 0L,
- (XEvent *) &eventSelection);
- if (iReturn == BadValue || iReturn == BadWindow)
- {
- /*
- * Should not be a problem if XSendEvent fails because
- * the client may simply have exited.
- */
- ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
- "XSendEvent () failed for abort event.\n");
- }
- }
-
- /* Close clipboard if it was opened */
- if (fCloseClipboard)
- {
- fCloseClipboard = FALSE;
- CloseClipboard ();
- }
- break;
-
-
- /*
- * SelectionNotify
- */
-
- case SelectionNotify:
-
- winDebug ("winClipboardFlushXEvents - SelectionNotify\n");
- {
- char *pszAtomName;
- pszAtomName = XGetAtomName (pDisplay,
- event.xselection.selection);
-
- winDebug("winClipboardFlushXEvents - SelectionNotify - ATOM: %s\n",
- pszAtomName);
- XFree (pszAtomName);
- }
-
- /*
- * Request conversion of UTF8 and CompoundText targets.
- */
- if (event.xselection.property == None)
- {
- if (event.xselection.target == XA_STRING)
- {
- winDebug ("winClipboardFlushXEvents - SelectionNotify - "
- "XA_STRING\n");
-
- return WIN_XEVENTS_CONVERT;
- }
- else if (event.xselection.target == atomUTF8String)
- {
- winDebug("winClipboardFlushXEvents - SelectionNotify - "
- "Requesting conversion of UTF8 target.\n");
-
- XConvertSelection (pDisplay,
- event.xselection.selection,
- XA_STRING,
- atomLocalProperty,
- iWindow,
- CurrentTime);
-
- /* Process the ConvertSelection event */
- XFlush (pDisplay);
- return WIN_XEVENTS_CONVERT;
- }
-#ifdef X_HAVE_UTF8_STRING
- else if (event.xselection.target == atomCompoundText)
- {
- winDebug("winClipboardFlushXEvents - SelectionNotify - "
- "Requesting conversion of CompoundText target.\n");
-
- XConvertSelection (pDisplay,
- event.xselection.selection,
- atomUTF8String,
- atomLocalProperty,
- iWindow,
- CurrentTime);
-
- /* Process the ConvertSelection event */
- XFlush (pDisplay);
- return WIN_XEVENTS_CONVERT;
- }
-#endif
- else
- {
- ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
- "Unknown format. Cannot request conversion, "
- "aborting.\n");
- break;
- }
- }
-
- /* Retrieve the size of the stored data */
- iReturn = XGetWindowProperty (pDisplay,
- iWindow,
- atomLocalProperty,
- 0,
- 0, /* Don't get data, just size */
- False,
- AnyPropertyType,
- &xtpText.encoding,
- &xtpText.format,
- &xtpText.nitems,
- &ulReturnBytesLeft,
- &xtpText.value);
- if (iReturn != Success)
- {
- ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
- "XGetWindowProperty () failed, aborting: %d\n",
- iReturn);
- break;
- }
-
- winDebug("SelectionNotify - returned data %d left %d\n",
- xtpText.nitems, ulReturnBytesLeft);
-
- /* Request the selection data */
- iReturn = XGetWindowProperty (pDisplay,
- iWindow,
- atomLocalProperty,
- 0,
- ulReturnBytesLeft,
- False,
- AnyPropertyType,
- &xtpText.encoding,
- &xtpText.format,
- &xtpText.nitems,
- &ulReturnBytesLeft,
- &xtpText.value);
- if (iReturn != Success)
- {
- ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
- "XGetWindowProperty () failed, aborting: %d\n",
- iReturn);
- break;
- }
-
- {
- char *pszAtomName = NULL;
-
- winDebug("SelectionNotify - returned data %d left %d\n",
- xtpText.nitems, ulReturnBytesLeft);
- pszAtomName = XGetAtomName(pDisplay, xtpText.encoding);
- winDebug("Notify atom name %s\n", pszAtomName);
- XFree (pszAtomName);
- pszAtomName = NULL;
- }
-
- if (fUseUnicode)
- {
-#ifdef X_HAVE_UTF8_STRING
- /* Convert the text property to a text list */
- iReturn = Xutf8TextPropertyToTextList (pDisplay,
- &xtpText,
- &ppszTextList,
- &iCount);
-#endif
- }
- else
- {
- iReturn = XmbTextPropertyToTextList (pDisplay,
- &xtpText,
- &ppszTextList,
- &iCount);
- }
- if (iReturn == Success || iReturn > 0)
- {
- /* Conversion succeeded or some unconvertible characters */
- if (ppszTextList != NULL)
- {
- iReturnDataLen = 0;
- for (i = 0; i < iCount; i++)
- {
- iReturnDataLen += strlen(ppszTextList[i]);
- }
- pszReturnData = malloc (iReturnDataLen + 1);
- pszReturnData[0] = '\0';
- for (i = 0; i < iCount; i++)
- {
- strcat (pszReturnData, ppszTextList[i]);
- }
- }
- else
- {
- ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
- "X*TextPropertyToTextList list_return is NULL.\n");
- pszReturnData = malloc (1);
- pszReturnData[0] = '\0';
- }
- }
- else
- {
- ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
- "X*TextPropertyToTextList returned: ");
- switch (iReturn)
- {
- case XNoMemory:
- ErrorF ("XNoMemory\n");
- break;
- case XConverterNotFound:
- ErrorF ("XConverterNotFound\n");
- break;
- default:
- ErrorF ("%d", iReturn);
- break;
- }
- pszReturnData = malloc (1);
- pszReturnData[0] = '\0';
- }
-
- /* Free the data returned from XGetWindowProperty */
- if (ppszTextList)
- XFreeStringList (ppszTextList);
- ppszTextList = NULL;
- XFree (xtpText.value);
- xtpText.value = NULL;
- xtpText.nitems = 0;
-
- /* Convert the X clipboard string to DOS format */
- winClipboardUNIXtoDOS (&pszReturnData, strlen (pszReturnData));
-
- if (fUseUnicode)
- {
- /* Find out how much space needed to convert MBCS to Unicode */
- iUnicodeLen = MultiByteToWideChar (CP_UTF8,
- 0,
- pszReturnData,
- -1,
- NULL,
- 0);
-
- /* Allocate memory for the Unicode string */
- pwszUnicodeStr
- = (wchar_t*) malloc (sizeof (wchar_t) * (iUnicodeLen + 1));
- if (!pwszUnicodeStr)
- {
- ErrorF ("winClipboardFlushXEvents - SelectionNotify "
- "malloc failed for pwszUnicodeStr, aborting.\n");
-
- /* Abort */
- fAbort = TRUE;
- goto winClipboardFlushXEvents_SelectionNotify_Done;
- }
-
- /* Do the actual conversion */
- MultiByteToWideChar (CP_UTF8,
- 0,
- pszReturnData,
- -1,
- pwszUnicodeStr,
- iUnicodeLen);
-
- /* Allocate global memory for the X clipboard data */
- hGlobal = GlobalAlloc (GMEM_MOVEABLE,
- sizeof (wchar_t) * (iUnicodeLen + 1));
- }
- else
- {
- pszConvertData = strdup (pszReturnData);
- iConvertDataLen = strlen (pszConvertData) + 1;
-
- /* Allocate global memory for the X clipboard data */
- hGlobal = GlobalAlloc (GMEM_MOVEABLE, iConvertDataLen);
- }
-
- free (pszReturnData);
-
- /* Check that global memory was allocated */
- if (!hGlobal)
- {
- ErrorF ("winClipboardFlushXEvents - SelectionNotify "
- "GlobalAlloc failed, aborting: %ld\n",
- GetLastError ());
-
- /* Abort */
- fAbort = TRUE;
- goto winClipboardFlushXEvents_SelectionNotify_Done;
- }
-
- /* Obtain a pointer to the global memory */
- pszGlobalData = GlobalLock (hGlobal);
- if (pszGlobalData == NULL)
- {
- ErrorF ("winClipboardFlushXEvents - Could not lock global "
- "memory for clipboard transfer\n");
-
- /* Abort */
- fAbort = TRUE;
- goto winClipboardFlushXEvents_SelectionNotify_Done;
- }
-
- /* Copy the returned string into the global memory */
- if (fUseUnicode)
- {
- memcpy (pszGlobalData,
- pwszUnicodeStr,
- sizeof (wchar_t) * (iUnicodeLen + 1));
- free (pwszUnicodeStr);
- pwszUnicodeStr = NULL;
- }
- else
- {
- strcpy (pszGlobalData, pszConvertData);
- free (pszConvertData);
- pszConvertData = NULL;
- }
-
- /* Release the pointer to the global memory */
- GlobalUnlock (hGlobal);
- pszGlobalData = NULL;
-
- /* Push the selection data to the Windows clipboard */
- if (fUseUnicode)
- SetClipboardData (CF_UNICODETEXT, hGlobal);
- else
- SetClipboardData (CF_TEXT, hGlobal);
-
- /* Flag that SetClipboardData has been called */
- fSetClipboardData = FALSE;
-
- /*
- * NOTE: Do not try to free pszGlobalData, it is owned by
- * Windows after the call to SetClipboardData ().
- */
-
- winClipboardFlushXEvents_SelectionNotify_Done:
- /* Free allocated resources */
- if (ppszTextList)
- XFreeStringList (ppszTextList);
- if (xtpText.value)
- {
- XFree (xtpText.value);
- xtpText.value = NULL;
- xtpText.nitems = 0;
- }
- if (pszConvertData)
- free (pszConvertData);
- if (pwszUnicodeStr)
- free (pwszUnicodeStr);
- if (hGlobal && pszGlobalData)
- GlobalUnlock (hGlobal);
- if (fSetClipboardData && g_fUnicodeSupport)
- SetClipboardData (CF_UNICODETEXT, NULL);
- if (fSetClipboardData)
- SetClipboardData (CF_TEXT, NULL);
- return WIN_XEVENTS_NOTIFY;
-
- case SelectionClear:
- winDebug("SelectionClear - doing nothing\n");
- break;
-
- case PropertyNotify:
- break;
-
- default:
- ErrorF ("winClipboardFlushXEvents - unexpected event type %d\n", event.type);
- break;
- }
- }
-
- return WIN_XEVENTS_SUCCESS;
-}
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *Copyright (C) Colin Harrison 2005-2008
+ *
+ *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, 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 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 HAROLD L HUNT II 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 copyright holder(s)
+ *and author(s) 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 copyright holder(s) and author(s).
+ *
+ * Authors: Harold L Hunt II
+ * Colin Harrison
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "winclipboard.h"
+#include "misc.h"
+#include "winmsg.h"
+#include <unistd.h>
+
+/*
+ * References to external symbols
+ */
+
+extern Bool g_fUnicodeSupport;
+
+
+/*
+ * Process any pending X events
+ */
+
+int
+winClipboardFlushXEvents (HWND hwnd,
+ int iWindow,
+ Display *pDisplay,
+ Bool fUseUnicode,
+ Bool ClipboardOpened)
+{
+ static Atom atomLocalProperty;
+ static Atom atomCompoundText;
+ static Atom atomUTF8String;
+ static Atom atomTargets;
+ static int generation;
+
+ if (generation != serverGeneration)
+ {
+ generation = serverGeneration;
+ atomLocalProperty = XInternAtom (pDisplay, WIN_LOCAL_PROPERTY, False);
+ atomUTF8String = XInternAtom (pDisplay, "UTF8_STRING", False);
+ atomCompoundText = XInternAtom (pDisplay, "COMPOUND_TEXT", False);
+ atomTargets = XInternAtom (pDisplay, "TARGETS", False);
+ }
+
+ /* Process all pending events */
+ while (XPending (pDisplay))
+ {
+ XTextProperty xtpText = {0};
+ XEvent event;
+ XSelectionEvent eventSelection;
+ unsigned long ulReturnBytesLeft;
+ unsigned char *pszReturnData = NULL;
+ char *pszGlobalData = NULL;
+ int iReturn;
+ HGLOBAL hGlobal = NULL;
+ XICCEncodingStyle xiccesStyle;
+ int iConvertDataLen = 0;
+ char *pszConvertData = NULL;
+ char *pszTextList[2] = {NULL};
+ int iCount;
+ char **ppszTextList = NULL;
+ wchar_t *pwszUnicodeStr = NULL;
+ int iUnicodeLen = 0;
+ int iReturnDataLen = 0;
+ int i;
+ Bool fAbort = FALSE;
+ Bool fCloseClipboard = FALSE;
+ Bool fSetClipboardData = TRUE;
+
+ /* Get the next event - will not block because one is ready */
+ XNextEvent (pDisplay, &event);
+
+ winDebug ("Received event type %d\n",event.type);
+
+ /* Branch on the event type */
+ switch (event.type)
+ {
+ /*
+ * SelectionRequest
+ */
+
+ case SelectionRequest:
+#ifdef _DEBUG
+ {
+ char *pszAtomName = NULL;
+ winDebug("SelectionRequest - target %d\n",
+ event.xselectionrequest.target);
+
+ pszAtomName = XGetAtomName (pDisplay,
+ event.xselectionrequest.target);
+ winDebug("SelectionRequest - Target atom name %s\n", pszAtomName);
+ XFree (pszAtomName);
+ pszAtomName = NULL;
+ winDebug ("SelectionRequest - owner %d\n", event.xselectionrequest.owner);
+ winDebug ("SelectionRequest - requestor %d\n", event.xselectionrequest.requestor);
+ }
+#endif
+
+ /* Abort if invalid target type */
+ if (event.xselectionrequest.target != XA_STRING
+ && event.xselectionrequest.target != atomUTF8String
+ && event.xselectionrequest.target != atomCompoundText
+ && event.xselectionrequest.target != atomTargets)
+ {
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+
+ /* Handle targets type of request */
+ if (event.xselectionrequest.target == atomTargets)
+ {
+ Atom atomTargetArr[] = {atomTargets,
+ atomCompoundText,
+ atomUTF8String,
+ XA_STRING};
+
+ /* Try to change the property */
+ iReturn = XChangeProperty (pDisplay,
+ event.xselectionrequest.requestor,
+ event.xselectionrequest.property,
+ XA_ATOM,
+ 32,
+ PropModeReplace,
+ (unsigned char *) atomTargetArr,
+ (sizeof (atomTargetArr)
+ / sizeof (atomTargetArr[0])));
+ if (iReturn == BadAlloc
+ || iReturn == BadAtom
+ || iReturn == BadMatch
+ || iReturn == BadValue
+ || iReturn == BadWindow)
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
+ "XChangeProperty failed: %d\n",
+ iReturn);
+ }
+
+ /* Setup selection notify xevent */
+ eventSelection.type = SelectionNotify;
+ eventSelection.send_event = True;
+ eventSelection.display = pDisplay;
+ eventSelection.requestor = event.xselectionrequest.requestor;
+ eventSelection.selection = event.xselectionrequest.selection;
+ eventSelection.target = event.xselectionrequest.target;
+ eventSelection.property = event.xselectionrequest.property;
+ eventSelection.time = event.xselectionrequest.time;
+
+ /*
+ * Notify the requesting window that
+ * the operation has completed
+ */
+ iReturn = XSendEvent (pDisplay,
+ eventSelection.requestor,
+ False,
+ 0L,
+ (XEvent *) &eventSelection);
+ if (iReturn == BadValue || iReturn == BadWindow)
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
+ "XSendEvent () failed\n");
+ }
+ break;
+ }
+
+ /* Check that clipboard format is available */
+ if (fUseUnicode
+ && !IsClipboardFormatAvailable (CF_UNICODETEXT))
+ {
+ static int count; /* Hack to stop acroread spamming the log */
+ static HWND lasthwnd; /* I've not seen any other client get here repeatedly? */
+ if (hwnd != lasthwnd) count = 0;
+ count++;
+ if (count < 6) ErrorF ("winClipboardFlushXEvents - CF_UNICODETEXT is not "
+ "available from Win32 clipboard. Aborting %d.\n", count);
+ lasthwnd = hwnd;
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+ else if (!fUseUnicode
+ && !IsClipboardFormatAvailable (CF_TEXT))
+ {
+ ErrorF ("winClipboardFlushXEvents - CF_TEXT is not "
+ "available from Win32 clipboard. Aborting.\n");
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+
+ /* Access the clipboard */
+ if (!ClipboardOpened)
+ {
+ if (!OpenClipboard (hwnd))
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
+ "OpenClipboard () failed: %08x\n",
+ GetLastError ());
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+
+ /* Indicate that clipboard was opened */
+ fCloseClipboard = TRUE;
+ }
+ /* Setup the string style */
+ if (event.xselectionrequest.target == XA_STRING)
+ xiccesStyle = XStringStyle;
+#ifdef X_HAVE_UTF8_STRING
+ else if (event.xselectionrequest.target == atomUTF8String)
+ xiccesStyle = XUTF8StringStyle;
+#endif
+ else if (event.xselectionrequest.target == atomCompoundText)
+ xiccesStyle = XCompoundTextStyle;
+ else
+ xiccesStyle = XStringStyle;
+
+ /*
+ * FIXME: Can't pass CF_UNICODETEXT on Windows 95/98/Me
+ */
+
+ /* Get a pointer to the clipboard text, in desired format */
+ if (fUseUnicode)
+ {
+ /* Retrieve clipboard data */
+ hGlobal = GetClipboardData (CF_UNICODETEXT);
+ }
+ else
+ {
+ /* Retrieve clipboard data */
+ hGlobal = GetClipboardData (CF_TEXT);
+ }
+ if (!hGlobal)
+ {
+ if (GetLastError()==ERROR_CLIPBOARD_NOT_OPEN && ClipboardOpened)
+ {
+ ErrorF("We should not have received a SelectionRequest????\n"
+ "The owner is the clipboard, but in reality it was"
+ "an X window\n");
+ /* Set the owner to None */
+ XSetSelectionOwner (pDisplay, XA_PRIMARY, None, CurrentTime);
+ XSetSelectionOwner (pDisplay, XInternAtom (pDisplay, "CLIPBOARD", False), None, CurrentTime);
+ }
+ ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
+ "GetClipboardData () failed: %08x\n",
+ GetLastError ());
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+ pszGlobalData = (char *) GlobalLock (hGlobal);
+
+ /* Convert the Unicode string to UTF8 (MBCS) */
+ if (fUseUnicode)
+ {
+ iConvertDataLen = WideCharToMultiByte (CP_UTF8,
+ 0,
+ (LPCWSTR)pszGlobalData,
+ -1,
+ NULL,
+ 0,
+ NULL,
+ NULL);
+ /* NOTE: iConvertDataLen includes space for null terminator */
+ pszConvertData = (char *) malloc (iConvertDataLen);
+ WideCharToMultiByte (CP_UTF8,
+ 0,
+ (LPCWSTR)pszGlobalData,
+ -1,
+ pszConvertData,
+ iConvertDataLen,
+ NULL,
+ NULL);
+ }
+ else
+ {
+ pszConvertData = strdup (pszGlobalData);
+ iConvertDataLen = strlen (pszConvertData) + 1;
+ }
+
+ /* Convert DOS string to UNIX string */
+ winClipboardDOStoUNIX (pszConvertData, strlen (pszConvertData));
+
+ /* Setup our text list */
+ pszTextList[0] = pszConvertData;
+ pszTextList[1] = NULL;
+
+ /* Initialize the text property */
+ xtpText.value = NULL;
+ xtpText.nitems = 0;
+
+ /* Create the text property from the text list */
+ if (fUseUnicode)
+ {
+#ifdef X_HAVE_UTF8_STRING
+ iReturn = Xutf8TextListToTextProperty (pDisplay,
+ pszTextList,
+ 1,
+ xiccesStyle,
+ &xtpText);
+#endif
+ }
+ else
+ {
+ iReturn = XmbTextListToTextProperty (pDisplay,
+ pszTextList,
+ 1,
+ xiccesStyle,
+ &xtpText);
+ }
+ if (iReturn == XNoMemory || iReturn == XLocaleNotSupported)
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
+ "X*TextListToTextProperty failed: %d\n",
+ iReturn);
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+
+ /* Free the converted string */
+ free (pszConvertData);
+ pszConvertData = NULL;
+
+ /* Copy the clipboard text to the requesting window */
+ iReturn = XChangeProperty (pDisplay,
+ event.xselectionrequest.requestor,
+ event.xselectionrequest.property,
+ event.xselectionrequest.target,
+ 8,
+ PropModeReplace,
+ xtpText.value,
+ xtpText.nitems);
+ if (iReturn == BadAlloc || iReturn == BadAtom
+ || iReturn == BadMatch || iReturn == BadValue
+ || iReturn == BadWindow)
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
+ "XChangeProperty failed: %d\n",
+ iReturn);
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+
+ /* Release the clipboard data */
+ GlobalUnlock (hGlobal);
+ pszGlobalData = NULL;
+ if (fCloseClipboard)
+ {
+ fCloseClipboard = FALSE;
+ CloseClipboard ();
+ }
+ /* Clean up */
+ XFree (xtpText.value);
+ xtpText.value = NULL;
+ xtpText.nitems = 0;
+
+ /* Setup selection notify event */
+ eventSelection.type = SelectionNotify;
+ eventSelection.send_event = True;
+ eventSelection.display = pDisplay;
+ eventSelection.requestor = event.xselectionrequest.requestor;
+ eventSelection.selection = event.xselectionrequest.selection;
+ eventSelection.target = event.xselectionrequest.target;
+ eventSelection.property = event.xselectionrequest.property;
+ eventSelection.time = event.xselectionrequest.time;
+
+ /* Notify the requesting window that the operation has completed */
+ iReturn = XSendEvent (pDisplay,
+ eventSelection.requestor,
+ False,
+ 0L,
+ (XEvent *) &eventSelection);
+ if (iReturn == BadValue || iReturn == BadWindow)
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
+ "XSendEvent () failed\n");
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+
+ winClipboardFlushXEvents_SelectionRequest_Done:
+ /* Free allocated resources */
+ if (xtpText.value)
+ {
+ XFree (xtpText.value);
+ xtpText.value = NULL;
+ xtpText.nitems = 0;
+ }
+ if (pszConvertData)
+ free (pszConvertData);
+ if (hGlobal && pszGlobalData)
+ GlobalUnlock (hGlobal);
+
+ /*
+ * Send a SelectionNotify event to the requesting
+ * client when we abort.
+ */
+ if (fAbort)
+ {
+ /* Setup selection notify event */
+ eventSelection.type = SelectionNotify;
+ eventSelection.send_event = True;
+ eventSelection.display = pDisplay;
+ eventSelection.requestor = event.xselectionrequest.requestor;
+ eventSelection.selection = event.xselectionrequest.selection;
+ eventSelection.target = event.xselectionrequest.target;
+ eventSelection.property = None;
+ eventSelection.time = event.xselectionrequest.time;
+
+ /* Notify the requesting window that the operation is complete */
+ iReturn = XSendEvent (pDisplay,
+ eventSelection.requestor,
+ False,
+ 0L,
+ (XEvent *) &eventSelection);
+ if (iReturn == BadValue || iReturn == BadWindow)
+ {
+ /*
+ * Should not be a problem if XSendEvent fails because
+ * the client may simply have exited.
+ */
+ ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
+ "XSendEvent () failed for abort event.\n");
+ }
+ }
+
+ /* Close clipboard if it was opened */
+ if (fCloseClipboard)
+ {
+ fCloseClipboard = FALSE;
+ CloseClipboard ();
+ }
+ break;
+
+
+ /*
+ * SelectionNotify
+ */
+ case SelectionNotify:
+#ifdef _DEBUG
+ winDebug ("winClipboardFlushXEvents - SelectionNotify\n");
+ {
+ char *pszAtomName;
+ pszAtomName = XGetAtomName (pDisplay,
+ event.xselection.selection);
+
+ winDebug("winClipboardFlushXEvents - SelectionNotify - ATOM: %s\n",
+ pszAtomName);
+ winDebug ("SelectionNotify - requestor %d\n", event.xselectionrequest.requestor);
+ XFree (pszAtomName);
+ }
+#endif
+
+
+ /*
+ * Request conversion of UTF8 and CompoundText targets.
+ */
+ if (event.xselection.property == None)
+ {
+ if (event.xselection.target == XA_STRING)
+ {
+ winDebug ("winClipboardFlushXEvents - SelectionNotify - "
+ "XA_STRING\n");
+
+ return WIN_XEVENTS_CONVERT;
+ }
+ else if (event.xselection.target == atomUTF8String)
+ {
+ winDebug("winClipboardFlushXEvents - SelectionNotify - "
+ "Requesting conversion of UTF8 target.\n");
+
+ XConvertSelection (pDisplay,
+ event.xselection.selection,
+ XA_STRING,
+ atomLocalProperty,
+ iWindow,
+ CurrentTime);
+
+ /* Process the ConvertSelection event */
+ XFlush (pDisplay);
+ return WIN_XEVENTS_CONVERT;
+ }
+#ifdef X_HAVE_UTF8_STRING
+ else if (event.xselection.target == atomCompoundText)
+ {
+ winDebug("winClipboardFlushXEvents - SelectionNotify - "
+ "Requesting conversion of CompoundText target.\n");
+
+ XConvertSelection (pDisplay,
+ event.xselection.selection,
+ atomUTF8String,
+ atomLocalProperty,
+ iWindow,
+ CurrentTime);
+
+ /* Process the ConvertSelection event */
+ XFlush (pDisplay);
+ return WIN_XEVENTS_CONVERT;
+ }
+#endif
+ else
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
+ "Unknown format. Cannot request conversion, "
+ "aborting.\n");
+ break;
+ }
+ }
+
+ /* Retrieve the size of the stored data */
+ iReturn = XGetWindowProperty (pDisplay,
+ iWindow,
+ atomLocalProperty,
+ 0,
+ 0, /* Don't get data, just size */
+ False,
+ AnyPropertyType,
+ &xtpText.encoding,
+ &xtpText.format,
+ &xtpText.nitems,
+ &ulReturnBytesLeft,
+ &xtpText.value);
+ if (iReturn != Success)
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
+ "XGetWindowProperty () failed, aborting: %d\n",
+ iReturn);
+ break;
+ }
+
+ winDebug("SelectionNotify - returned data %d left %d\n",
+ xtpText.nitems, ulReturnBytesLeft);
+
+ /* Request the selection data */
+ iReturn = XGetWindowProperty (pDisplay,
+ iWindow,
+ atomLocalProperty,
+ 0,
+ ulReturnBytesLeft,
+ False,
+ AnyPropertyType,
+ &xtpText.encoding,
+ &xtpText.format,
+ &xtpText.nitems,
+ &ulReturnBytesLeft,
+ &xtpText.value);
+ if (iReturn != Success)
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
+ "XGetWindowProperty () failed, aborting: %d\n",
+ iReturn);
+ break;
+ }
+
+#ifdef WINDBG
+ {
+ char *pszAtomName = NULL;
+
+ winDebug("SelectionNotify - returned data %d left %d\n",
+ xtpText.nitems, ulReturnBytesLeft);
+ pszAtomName = XGetAtomName(pDisplay, xtpText.encoding);
+ winDebug("Notify atom name %s\n", pszAtomName);
+ XFree (pszAtomName);
+ pszAtomName = NULL;
+ }
+#endif
+
+ if (fUseUnicode)
+ {
+#ifdef X_HAVE_UTF8_STRING
+ /* Convert the text property to a text list */
+ iReturn = Xutf8TextPropertyToTextList (pDisplay,
+ &xtpText,
+ &ppszTextList,
+ &iCount);
+#endif
+ }
+ else
+ {
+ iReturn = XmbTextPropertyToTextList (pDisplay,
+ &xtpText,
+ &ppszTextList,
+ &iCount);
+ }
+ if (iReturn == Success || iReturn > 0)
+ {
+ /* Conversion succeeded or some unconvertible characters */
+ if (ppszTextList != NULL)
+ {
+ iReturnDataLen = 0;
+ for (i = 0; i < iCount; i++)
+ {
+ iReturnDataLen += strlen(ppszTextList[i]);
+ }
+ pszReturnData = (char *) malloc (iReturnDataLen + 1);
+ pszReturnData[0] = '\0';
+ for (i = 0; i < iCount; i++)
+ {
+ strcat (pszReturnData, ppszTextList[i]);
+ }
+ }
+ else
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
+ "X*TextPropertyToTextList list_return is NULL.\n");
+ pszReturnData = (char *) malloc (1);
+ pszReturnData[0] = '\0';
+ }
+ }
+ else
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
+ "X*TextPropertyToTextList returned: ");
+ switch (iReturn)
+ {
+ case XNoMemory:
+ ErrorF ("XNoMemory\n");
+ break;
+ case XConverterNotFound:
+ ErrorF ("XConverterNotFound\n");
+ break;
+ default:
+ ErrorF ("%d", iReturn);
+ break;
+ }
+ pszReturnData = (char *) malloc (1);
+ pszReturnData[0] = '\0';
+ }
+
+ /* Free the data returned from XGetWindowProperty */
+ if (ppszTextList)
+ XFreeStringList (ppszTextList);
+ ppszTextList = NULL;
+ XFree (xtpText.value);
+ xtpText.value = NULL;
+ xtpText.nitems = 0;
+
+ /* Convert the X clipboard string to DOS format */
+ winClipboardUNIXtoDOS ((unsigned char **)&pszReturnData, strlen (pszReturnData));
+
+ if (fUseUnicode)
+ {
+ /* Find out how much space needed to convert MBCS to Unicode */
+ iUnicodeLen = MultiByteToWideChar (CP_UTF8,
+ 0,
+ pszReturnData,
+ -1,
+ NULL,
+ 0);
+
+ /* Allocate memory for the Unicode string */
+ pwszUnicodeStr
+ = (wchar_t*) malloc (sizeof (wchar_t) * (iUnicodeLen + 1));
+ if (!pwszUnicodeStr)
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify "
+ "malloc failed for pwszUnicodeStr, aborting.\n");
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionNotify_Done;
+ }
+
+ /* Do the actual conversion */
+ MultiByteToWideChar (CP_UTF8,
+ 0,
+ pszReturnData,
+ -1,
+ pwszUnicodeStr,
+ iUnicodeLen);
+
+ /* Allocate global memory for the X clipboard data */
+ hGlobal = GlobalAlloc (GMEM_MOVEABLE,
+ sizeof (wchar_t) * (iUnicodeLen + 1));
+ }
+ else
+ {
+ pszConvertData = strdup (pszReturnData);
+ iConvertDataLen = strlen (pszConvertData) + 1;
+
+ /* Allocate global memory for the X clipboard data */
+ hGlobal = GlobalAlloc (GMEM_MOVEABLE, iConvertDataLen);
+ }
+
+ free (pszReturnData);
+
+ /* Check that global memory was allocated */
+ if (!hGlobal)
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify "
+ "GlobalAlloc failed, aborting: %ld\n",
+ GetLastError ());
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionNotify_Done;
+ }
+
+ /* Obtain a pointer to the global memory */
+ pszGlobalData = GlobalLock (hGlobal);
+ if (pszGlobalData == NULL)
+ {
+ ErrorF ("winClipboardFlushXEvents - Could not lock global "
+ "memory for clipboard transfer\n");
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionNotify_Done;
+ }
+
+ /* Copy the returned string into the global memory */
+ if (fUseUnicode)
+ {
+ memcpy (pszGlobalData,
+ pwszUnicodeStr,
+ sizeof (wchar_t) * (iUnicodeLen + 1));
+ free (pwszUnicodeStr);
+ pwszUnicodeStr = NULL;
+ }
+ else
+ {
+ strcpy (pszGlobalData, pszConvertData);
+ free (pszConvertData);
+ pszConvertData = NULL;
+ }
+
+ /* Release the pointer to the global memory */
+ GlobalUnlock (hGlobal);
+ pszGlobalData = NULL;
+
+ /* Push the selection data to the Windows clipboard */
+ if (fUseUnicode)
+ SetClipboardData (CF_UNICODETEXT, hGlobal);
+ else
+ SetClipboardData (CF_TEXT, hGlobal);
+
+ /* Flag that SetClipboardData has been called */
+ fSetClipboardData = FALSE;
+
+ /*
+ * NOTE: Do not try to free pszGlobalData, it is owned by
+ * Windows after the call to SetClipboardData ().
+ */
+
+ winClipboardFlushXEvents_SelectionNotify_Done:
+ /* Free allocated resources */
+ if (ppszTextList)
+ XFreeStringList (ppszTextList);
+ if (xtpText.value)
+ {
+ XFree (xtpText.value);
+ xtpText.value = NULL;
+ xtpText.nitems = 0;
+ }
+ if (pszConvertData)
+ free (pszConvertData);
+ if (pwszUnicodeStr)
+ free (pwszUnicodeStr);
+ if (hGlobal && pszGlobalData)
+ GlobalUnlock (hGlobal);
+ if (fSetClipboardData && g_fUnicodeSupport)
+ SetClipboardData (CF_UNICODETEXT, NULL);
+ if (fSetClipboardData)
+ SetClipboardData (CF_TEXT, NULL);
+ return WIN_XEVENTS_NOTIFY;
+
+ /*
+ * SelectionClear
+ */
+ case SelectionClear:
+#ifdef _DEBUG
+ winDebug ("SelectionClear - doing nothing\n");
+ {
+ char *pszAtomName;
+
+ pszAtomName = XGetAtomName (pDisplay,
+ event.xselection.selection);
+
+ winDebug ("SelectionClear - ATOM: %s\n",
+ pszAtomName);
+ winDebug ("SelectionClear - owner %d\n", event.xselectionrequest.owner);
+
+ XFree (pszAtomName);
+ }
+#endif
+ break;
+
+ case PropertyNotify:
+ break;
+
+ default:
+ ErrorF ("winClipboardFlushXEvents - unexpected event type %d\n", event.type);
+ break;
+ }
+ }
+
+ return WIN_XEVENTS_SUCCESS;
+}
diff --git a/xorg-server/hw/xwin/wincmap.c b/xorg-server/hw/xwin/wincmap.c
index 9da03888d..370a4c584 100644
--- a/xorg-server/hw/xwin/wincmap.c
+++ b/xorg-server/hw/xwin/wincmap.c
@@ -1,674 +1,622 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, 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 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 XFREE86 PROJECT 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 XFree86 Project
- *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 XFree86 Project.
- *
- * Authors: Dakshinamurthy Karra
- * Suhaib M Siddiqi
- * Peter Busch
- * Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-
-/*
- * Local prototypes
- */
-
-static int
-winListInstalledColormaps (ScreenPtr pScreen, Colormap *pmaps);
-
-static void
-winStoreColors (ColormapPtr pmap, int ndef, xColorItem *pdefs);
-
-static void
-winInstallColormap (ColormapPtr pmap);
-
-static void
-winUninstallColormap (ColormapPtr pmap);
-
-static void
-winResolveColor (unsigned short *pred,
- unsigned short *pgreen,
- unsigned short *pblue,
- VisualPtr pVisual);
-
-static Bool
-winCreateColormap (ColormapPtr pmap);
-
-static void
-winDestroyColormap (ColormapPtr pmap);
-
-static Bool
-winGetPaletteDIB (ScreenPtr pScreen, ColormapPtr pcmap);
-
-static Bool
-winGetPaletteDD (ScreenPtr pScreen, ColormapPtr pcmap);
-
-
-/*
- * Set screen functions for colormaps
- */
-
-void
-winSetColormapFunctions (ScreenPtr pScreen)
-{
- pScreen->CreateColormap = winCreateColormap;
- pScreen->DestroyColormap = winDestroyColormap;
- pScreen->InstallColormap = winInstallColormap;
- pScreen->UninstallColormap = winUninstallColormap;
- pScreen->ListInstalledColormaps = winListInstalledColormaps;
- pScreen->StoreColors = winStoreColors;
- pScreen->ResolveColor = winResolveColor;
-}
-
-
-/* See Porting Layer Definition - p. 30 */
-/*
- * Walk the list of installed colormaps, filling the pmaps list
- * with the resource ids of the installed maps, and return
- * a count of the total number of installed maps.
- */
-static int
-winListInstalledColormaps (ScreenPtr pScreen, Colormap *pmaps)
-{
- winScreenPriv(pScreen);
-
- /*
- * There will only be one installed colormap, so we only need
- * to return one id, and the count of installed maps will always
- * be one.
- */
- *pmaps = pScreenPriv->pcmapInstalled->mid;
- return 1;
-}
-
-
-/* See Porting Layer Definition - p. 30 */
-/* See Programming Windows - p. 663 */
-static void
-winInstallColormap (ColormapPtr pColormap)
-{
- ScreenPtr pScreen = pColormap->pScreen;
- winScreenPriv(pScreen);
- ColormapPtr oldpmap = pScreenPriv->pcmapInstalled;
-
-#if CYGDEBUG
- winDebug ("winInstallColormap\n");
-#endif
-
- /* Did the colormap actually change? */
- if (pColormap != oldpmap)
- {
-#if CYGDEBUG
- winDebug ("winInstallColormap - Colormap has changed, attempt "
- "to install.\n");
-#endif
-
- /* Was there a previous colormap? */
- if (oldpmap != (ColormapPtr) None)
- {
- /* There was a previous colormap; tell clients it is gone */
- WalkTree (pColormap->pScreen, TellLostMap, (char *)&oldpmap->mid);
- }
-
- /* Install new colormap */
- pScreenPriv->pcmapInstalled = pColormap;
- WalkTree (pColormap->pScreen, TellGainedMap, (char *)&pColormap->mid);
-
- /* Call the engine specific colormap install procedure */
- if (!((*pScreenPriv->pwinInstallColormap) (pColormap)))
- {
- winErrorFVerb (2, "winInstallColormap - Screen specific colormap install "
- "procedure failed. Continuing, but colors may be "
- "messed up from now on.\n");
- }
- }
-
- /* Save a pointer to the newly installed colormap */
- pScreenPriv->pcmapInstalled = pColormap;
-}
-
-
-/* See Porting Layer Definition - p. 30 */
-static void
-winUninstallColormap (ColormapPtr pmap)
-{
- winScreenPriv(pmap->pScreen);
- ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
-
-#if CYGDEBUG
- winDebug ("winUninstallColormap\n");
-#endif
-
- /* Is the colormap currently installed? */
- if (pmap != curpmap)
- {
- /* Colormap not installed, nothing to do */
- return;
- }
-
- /* Clear the installed colormap flag */
- pScreenPriv->pcmapInstalled = NULL;
-
- /*
- * NOTE: The default colormap does not get "uninstalled" before
- * it is destroyed.
- */
-
- /* Install the default cmap in place of the cmap to be uninstalled */
- if (pmap->mid != pmap->pScreen->defColormap)
- {
- dixLookupResourceByType((pointer) &curpmap, pmap->pScreen->defColormap,
- RT_COLORMAP, NullClient, DixUnknownAccess);
- (*pmap->pScreen->InstallColormap) (curpmap);
- }
-}
-
-
-/* See Porting Layer Definition - p. 30 */
-static void
-winStoreColors (ColormapPtr pmap,
- int ndef,
- xColorItem *pdefs)
-{
- ScreenPtr pScreen = pmap->pScreen;
- winScreenPriv(pScreen);
- winCmapPriv(pmap);
- int i;
- unsigned short nRed, nGreen, nBlue;
-
-#if CYGDEBUG
- if (ndef != 1)
- winDebug ("winStoreColors - ndef: %d\n",
- ndef);
-#endif
-
- /* Save the new colors in the colormap privates */
- for (i = 0; i < ndef; ++i)
- {
- /* Adjust the colors from the X color spec to the Windows color spec */
- nRed = pdefs[i].red >> 8;
- nGreen = pdefs[i].green >> 8;
- nBlue = pdefs[i].blue >> 8;
-
- /* Copy the colors to a palette entry table */
- pCmapPriv->peColors[pdefs[0].pixel + i].peRed = nRed;
- pCmapPriv->peColors[pdefs[0].pixel + i].peGreen = nGreen;
- pCmapPriv->peColors[pdefs[0].pixel + i].peBlue = nBlue;
-
- /* Copy the colors to a RGBQUAD table */
- pCmapPriv->rgbColors[pdefs[0].pixel + i].rgbRed = nRed;
- pCmapPriv->rgbColors[pdefs[0].pixel + i].rgbGreen = nGreen;
- pCmapPriv->rgbColors[pdefs[0].pixel + i].rgbBlue = nBlue;
-
-#if CYGDEBUG
- winDebug ("winStoreColors - nRed %d nGreen %d nBlue %d\n",
- nRed, nGreen, nBlue);
-#endif
- }
-
- /* Call the engine specific store colors procedure */
- if (!((pScreenPriv->pwinStoreColors) (pmap, ndef, pdefs)))
- {
- winErrorFVerb (2, "winStoreColors - Engine cpecific color storage procedure "
- "failed. Continuing, but colors may be messed up from now "
- "on.\n");
- }
-}
-
-
-/* See Porting Layer Definition - p. 30 */
-static void
-winResolveColor (unsigned short *pred,
- unsigned short *pgreen,
- unsigned short *pblue,
- VisualPtr pVisual)
-{
-#if CYGDEBUG
- winDebug ("winResolveColor ()\n");
-#endif
-
- miResolveColor (pred, pgreen, pblue, pVisual);
-}
-
-
-/* See Porting Layer Definition - p. 29 */
-static Bool
-winCreateColormap (ColormapPtr pmap)
-{
- winPrivCmapPtr pCmapPriv = NULL;
- ScreenPtr pScreen = pmap->pScreen;
- winScreenPriv(pScreen);
-
-#if CYGDEBUG
- winDebug ("winCreateColormap\n");
-#endif
-
- /* Allocate colormap privates */
- if (!winAllocateCmapPrivates (pmap))
- {
- ErrorF ("winCreateColorma - Couldn't allocate cmap privates\n");
- return FALSE;
- }
-
- /* Get a pointer to the newly allocated privates */
- pCmapPriv = winGetCmapPriv (pmap);
-
- /*
- * FIXME: This is some evil hackery to help in handling some X clients
- * that expect the top pixel to be white. This "help" only lasts until
- * some client overwrites the top colormap entry.
- *
- * We don't want to actually allocate the top entry, as that causes
- * problems with X clients that need 7 planes (128 colors) in the default
- * colormap, such as Magic 7.1.
- */
- pCmapPriv->rgbColors[WIN_NUM_PALETTE_ENTRIES - 1].rgbRed = 255;
- pCmapPriv->rgbColors[WIN_NUM_PALETTE_ENTRIES - 1].rgbGreen = 255;
- pCmapPriv->rgbColors[WIN_NUM_PALETTE_ENTRIES - 1].rgbBlue = 255;
- pCmapPriv->peColors[WIN_NUM_PALETTE_ENTRIES - 1].peRed = 255;
- pCmapPriv->peColors[WIN_NUM_PALETTE_ENTRIES - 1].peGreen = 255;
- pCmapPriv->peColors[WIN_NUM_PALETTE_ENTRIES - 1].peBlue = 255;
-
- /* Call the engine specific colormap initialization procedure */
- if (!((*pScreenPriv->pwinCreateColormap) (pmap)))
- {
- ErrorF ("winCreateColormap - Engine specific colormap creation "
- "procedure failed. Aborting.\n");
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-/* See Porting Layer Definition - p. 29, 30 */
-static void
-winDestroyColormap (ColormapPtr pColormap)
-{
- winScreenPriv(pColormap->pScreen);
- winCmapPriv(pColormap);
-
- /* Call the engine specific colormap destruction procedure */
- if (!((*pScreenPriv->pwinDestroyColormap) (pColormap)))
- {
- winErrorFVerb (2, "winDestroyColormap - Engine specific colormap destruction "
- "procedure failed. Continuing, but it is possible that memory "
- "was leaked, or that colors will be messed up from now on.\n");
- }
-
- /* Free the colormap privates */
- free (pCmapPriv);
- winSetCmapPriv (pColormap, NULL);
-
-#if CYGDEBUG
- winDebug ("winDestroyColormap - Returning\n");
-#endif
-}
-
-
-/*
- * Internal function to load the palette used by the Shadow DIB
- */
-
-static Bool
-winGetPaletteDIB (ScreenPtr pScreen, ColormapPtr pcmap)
-{
- winScreenPriv(pScreen);
- int i;
- Pixel pixel; /* Pixel == CARD32 */
- CARD16 nRed, nGreen, nBlue; /* CARD16 == unsigned short */
- UINT uiColorsRetrieved = 0;
- RGBQUAD rgbColors[WIN_NUM_PALETTE_ENTRIES];
-
- /* Get the color table for the screen */
- uiColorsRetrieved = GetDIBColorTable (pScreenPriv->hdcScreen,
- 0,
- WIN_NUM_PALETTE_ENTRIES,
- rgbColors);
- if (uiColorsRetrieved == 0)
- {
- ErrorF ("winGetPaletteDIB - Could not retrieve screen color table\n");
- return FALSE;
- }
-
-#if CYGDEBUG
- winDebug ("winGetPaletteDIB - Retrieved %d colors from DIB\n",
- uiColorsRetrieved);
-#endif
-
- /* Set the DIB color table to the default screen palette */
- if (SetDIBColorTable (pScreenPriv->hdcShadow,
- 0,
- uiColorsRetrieved,
- rgbColors) == 0)
- {
- ErrorF ("winGetPaletteDIB - SetDIBColorTable () failed\n");
- return FALSE;
- }
-
- /* Alloc each color in the DIB color table */
- for (i = 0; i < uiColorsRetrieved; ++i)
- {
- pixel = i;
-
- /* Extract the color values for current palette entry */
- nRed = rgbColors[i].rgbRed << 8;
- nGreen = rgbColors[i].rgbGreen << 8;
- nBlue = rgbColors[i].rgbBlue << 8;
-
-#if CYGDEBUG
- winDebug ("winGetPaletteDIB - Allocating a color: %d; "
- "%d %d %d\n",
- pixel, nRed, nGreen, nBlue);
-#endif
-
- /* Allocate a entry in the X colormap */
- if (AllocColor (pcmap,
- &nRed,
- &nGreen,
- &nBlue,
- &pixel,
- 0) != Success)
- {
- ErrorF ("winGetPaletteDIB - AllocColor () failed, pixel %d\n",
- i);
- return FALSE;
- }
-
- if (i != pixel
- || nRed != rgbColors[i].rgbRed
- || nGreen != rgbColors[i].rgbGreen
- || nBlue != rgbColors[i].rgbBlue)
- {
- winDebug ("winGetPaletteDIB - Got: %d; "
- "%d %d %d\n",
- (int) pixel, nRed, nGreen, nBlue);
- }
-
- /* FIXME: Not sure that this bit is needed at all */
- pcmap->red[i].co.local.red = nRed;
- pcmap->red[i].co.local.green = nGreen;
- pcmap->red[i].co.local.blue = nBlue;
- }
-
- /* System is using a colormap */
- /* Set the black and white pixel indices */
- pScreen->whitePixel = uiColorsRetrieved - 1;
- pScreen->blackPixel = 0;
-
- return TRUE;
-}
-
-
-/*
- * Internal function to load the standard system palette being used by DD
- */
-
-static Bool
-winGetPaletteDD (ScreenPtr pScreen, ColormapPtr pcmap)
-{
- int i;
- Pixel pixel; /* Pixel == CARD32 */
- CARD16 nRed, nGreen, nBlue; /* CARD16 == unsigned short */
- UINT uiSystemPaletteEntries;
- LPPALETTEENTRY ppeColors = NULL;
- HDC hdc = NULL;
-
- /* Get a DC to obtain the default palette */
- hdc = GetDC (NULL);
- if (hdc == NULL)
- {
- ErrorF ("winGetPaletteDD - Couldn't get a DC\n");
- return FALSE;
- }
-
- /* Get the number of entries in the system palette */
- uiSystemPaletteEntries = GetSystemPaletteEntries (hdc,
- 0, 0, NULL);
- if (uiSystemPaletteEntries == 0)
- {
- ErrorF ("winGetPaletteDD - Unable to determine number of "
- "system palette entries\n");
- return FALSE;
- }
-
-#if CYGDEBUG
- winDebug ("winGetPaletteDD - uiSystemPaletteEntries %d\n",
- uiSystemPaletteEntries);
-#endif
-
- /* Allocate palette entries structure */
- ppeColors = malloc (uiSystemPaletteEntries * sizeof (PALETTEENTRY));
- if (ppeColors == NULL)
- {
- ErrorF ("winGetPaletteDD - malloc () for colormap failed\n");
- return FALSE;
- }
-
- /* Get system palette entries */
- GetSystemPaletteEntries (hdc,
- 0, uiSystemPaletteEntries, ppeColors);
-
- /* Allocate an X colormap entry for every system palette entry */
- for (i = 0; i < uiSystemPaletteEntries; ++i)
- {
- pixel = i;
-
- /* Extract the color values for current palette entry */
- nRed = ppeColors[i].peRed << 8;
- nGreen = ppeColors[i].peGreen << 8;
- nBlue = ppeColors[i].peBlue << 8;
-#if CYGDEBUG
- winDebug ("winGetPaletteDD - Allocating a color: %d; "
- "%d %d %d\n",
- pixel, nRed, nGreen, nBlue);
-#endif
- if (AllocColor (pcmap,
- &nRed,
- &nGreen,
- &nBlue,
- &pixel,
- 0) != Success)
- {
- ErrorF ("winGetPaletteDD - AllocColor () failed, pixel %d\n",
- i);
- free (ppeColors);
- ppeColors = NULL;
- return FALSE;
- }
-
- pcmap->red[i].co.local.red = nRed;
- pcmap->red[i].co.local.green = nGreen;
- pcmap->red[i].co.local.blue = nBlue;
- }
-
- /* System is using a colormap */
- /* Set the black and white pixel indices */
- pScreen->whitePixel = uiSystemPaletteEntries - 1;
- pScreen->blackPixel = 0;
-
- /* Free colormap */
- if (ppeColors != NULL)
- {
- free (ppeColors);
- ppeColors = NULL;
- }
-
- /* Free the DC */
- if (hdc != NULL)
- {
- ReleaseDC (NULL, hdc);
- hdc = NULL;
- }
-
- return TRUE;
-}
-
-
-/*
- * Install the standard fb colormap, or the GDI colormap,
- * depending on the current screen depth.
- */
-
-Bool
-winCreateDefColormap (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- unsigned short zero = 0, ones = 0xFFFF;
- VisualPtr pVisual = pScreenPriv->pRootVisual;
- ColormapPtr pcmap = NULL;
- Pixel wp, bp;
-
-#if CYGDEBUG
- winDebug ("winCreateDefColormap\n");
-#endif
-
- /* Use standard fb colormaps for non palettized color modes */
- if (pScreenInfo->dwBPP > 8)
- {
- winDebug ("winCreateDefColormap - Deferring to " \
- "fbCreateDefColormap ()\n");
- return fbCreateDefColormap (pScreen);
- }
-
- /*
- * AllocAll for non-Dynamic visual classes,
- * AllocNone for Dynamic visual classes.
- */
-
- /*
- * Dynamic visual classes allow the colors of the color map
- * to be changed by clients.
- */
-
-#if CYGDEBUG
- winDebug ("winCreateDefColormap - defColormap: %d\n",
- pScreen->defColormap);
-#endif
-
- /* Allocate an X colormap, owned by client 0 */
- if (CreateColormap (pScreen->defColormap,
- pScreen,
- pVisual,
- &pcmap,
- (pVisual->class & DynamicClass) ? AllocNone : AllocAll,
- 0) != Success)
- {
- ErrorF ("winCreateDefColormap - CreateColormap failed\n");
- return FALSE;
- }
- if (pcmap == NULL)
- {
- ErrorF ("winCreateDefColormap - Colormap could not be created\n");
- return FALSE;
- }
-
-#if CYGDEBUG
- winDebug ("winCreateDefColormap - Created a colormap\n");
-#endif
-
- /* Branch on the visual class */
- if (!(pVisual->class & DynamicClass))
- {
- /* Branch on engine type */
- if (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI)
- {
- /* Load the colors being used by the Shadow DIB */
- if (!winGetPaletteDIB (pScreen, pcmap))
- {
- ErrorF ("winCreateDefColormap - Couldn't get DIB colors\n");
- return FALSE;
- }
- }
- else
- {
- /* Load the colors from the default system palette */
- if (!winGetPaletteDD (pScreen, pcmap))
- {
- ErrorF ("winCreateDefColormap - Couldn't get colors "
- "for DD\n");
- return FALSE;
- }
- }
- }
- else
- {
- wp = pScreen->whitePixel;
- bp = pScreen->blackPixel;
-
- /* Allocate a black and white pixel */
- if ((AllocColor (pcmap, &ones, &ones, &ones, &wp, 0) !=
- Success)
- ||
- (AllocColor (pcmap, &zero, &zero, &zero, &bp, 0) !=
- Success))
- {
- ErrorF ("winCreateDefColormap - Couldn't allocate bp or wp\n");
- return FALSE;
- }
-
- pScreen->whitePixel = wp;
- pScreen->blackPixel = bp;
-
-#if 0
- /* Have to reserve first 10 and last ten pixels in DirectDraw windowed */
- if (pScreenInfo->dwEngine != WIN_SERVER_SHADOW_GDI)
- {
- int k;
- Pixel p;
-
- for (k = 1; k < 10; ++k)
- {
- p = k;
- if (AllocColor (pcmap, &ones, &ones, &ones, &p, 0) != Success)
- FatalError ("Foo!\n");
- }
-
- for (k = 245; k < 255; ++k)
- {
- p = k;
- if (AllocColor (pcmap, &zero, &zero, &zero, &p, 0) != Success)
- FatalError ("Baz!\n");
- }
- }
-#endif
- }
-
- /* Install the created colormap */
- (*pScreen->InstallColormap)(pcmap);
-
-#if CYGDEBUG
- winDebug ("winCreateDefColormap - Returning\n");
-#endif
-
- return TRUE;
-}
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, 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 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 XFREE86 PROJECT 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 XFree86 Project
+ *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 XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+/*
+ * Local prototypes
+ */
+
+static int
+winListInstalledColormaps (ScreenPtr pScreen, Colormap *pmaps);
+
+static void
+winStoreColors (ColormapPtr pmap, int ndef, xColorItem *pdefs);
+
+static void
+winInstallColormap (ColormapPtr pmap);
+
+static void
+winUninstallColormap (ColormapPtr pmap);
+
+static void
+winResolveColor (unsigned short *pred,
+ unsigned short *pgreen,
+ unsigned short *pblue,
+ VisualPtr pVisual);
+
+static Bool
+winCreateColormap (ColormapPtr pmap);
+
+static void
+winDestroyColormap (ColormapPtr pmap);
+
+static Bool
+winGetPaletteDIB (ScreenPtr pScreen, ColormapPtr pcmap);
+
+static Bool
+winGetPaletteDD (ScreenPtr pScreen, ColormapPtr pcmap);
+
+
+/*
+ * Set screen functions for colormaps
+ */
+
+void
+winSetColormapFunctions (ScreenPtr pScreen)
+{
+ pScreen->CreateColormap = winCreateColormap;
+ pScreen->DestroyColormap = winDestroyColormap;
+ pScreen->InstallColormap = winInstallColormap;
+ pScreen->UninstallColormap = winUninstallColormap;
+ pScreen->ListInstalledColormaps = winListInstalledColormaps;
+ pScreen->StoreColors = winStoreColors;
+ pScreen->ResolveColor = winResolveColor;
+}
+
+
+/* See Porting Layer Definition - p. 30 */
+/*
+ * Walk the list of installed colormaps, filling the pmaps list
+ * with the resource ids of the installed maps, and return
+ * a count of the total number of installed maps.
+ */
+static int
+winListInstalledColormaps (ScreenPtr pScreen, Colormap *pmaps)
+{
+ winScreenPriv(pScreen);
+
+ /*
+ * There will only be one installed colormap, so we only need
+ * to return one id, and the count of installed maps will always
+ * be one.
+ */
+ *pmaps = pScreenPriv->pcmapInstalled->mid;
+ return 1;
+}
+
+
+/* See Porting Layer Definition - p. 30 */
+/* See Programming Windows - p. 663 */
+static void
+winInstallColormap (ColormapPtr pColormap)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ winScreenPriv(pScreen);
+ ColormapPtr oldpmap = pScreenPriv->pcmapInstalled;
+
+ winDebug ("winInstallColormap\n");
+
+ /* Did the colormap actually change? */
+ if (pColormap != oldpmap)
+ {
+ winDebug ("winInstallColormap - Colormap has changed, attempt "
+ "to install.\n");
+
+ /* Was there a previous colormap? */
+ if (oldpmap != (ColormapPtr) None)
+ {
+ /* There was a previous colormap; tell clients it is gone */
+ WalkTree (pColormap->pScreen, TellLostMap, (char *)&oldpmap->mid);
+ }
+
+ /* Install new colormap */
+ pScreenPriv->pcmapInstalled = pColormap;
+ WalkTree (pColormap->pScreen, TellGainedMap, (char *)&pColormap->mid);
+
+ /* Call the engine specific colormap install procedure */
+ if (!((*pScreenPriv->pwinInstallColormap) (pColormap)))
+ {
+ ErrorF ("winInstallColormap - Screen specific colormap install "
+ "procedure failed. Continuing, but colors may be "
+ "messed up from now on.\n");
+ }
+ }
+
+ /* Save a pointer to the newly installed colormap */
+ pScreenPriv->pcmapInstalled = pColormap;
+}
+
+
+/* See Porting Layer Definition - p. 30 */
+static void
+winUninstallColormap (ColormapPtr pmap)
+{
+ winScreenPriv(pmap->pScreen);
+ ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
+
+ winDebug ("winUninstallColormap\n");
+
+ /* Is the colormap currently installed? */
+ if (pmap != curpmap)
+ {
+ /* Colormap not installed, nothing to do */
+ return;
+ }
+
+ /* Clear the installed colormap flag */
+ pScreenPriv->pcmapInstalled = NULL;
+
+ /*
+ * NOTE: The default colormap does not get "uninstalled" before
+ * it is destroyed.
+ */
+
+ /* Install the default cmap in place of the cmap to be uninstalled */
+ if (pmap->mid != pmap->pScreen->defColormap)
+ {
+ dixLookupResourceByType((pointer) &curpmap, pmap->pScreen->defColormap,
+ RT_COLORMAP, NullClient, DixUnknownAccess);
+ (*pmap->pScreen->InstallColormap) (curpmap);
+ }
+}
+
+
+/* See Porting Layer Definition - p. 30 */
+static void
+winStoreColors (ColormapPtr pmap,
+ int ndef,
+ xColorItem *pdefs)
+{
+ ScreenPtr pScreen = pmap->pScreen;
+ winScreenPriv(pScreen);
+ winCmapPriv(pmap);
+ int i;
+ unsigned short nRed, nGreen, nBlue;
+
+#ifdef WINDBG
+ if (ndef != 1)
+ winDebug ("winStoreColors - ndef: %d\n",
+ ndef);
+#endif
+
+ /* Save the new colors in the colormap privates */
+ for (i = 0; i < ndef; ++i)
+ {
+ /* Adjust the colors from the X color spec to the Windows color spec */
+ nRed = pdefs[i].red >> 8;
+ nGreen = pdefs[i].green >> 8;
+ nBlue = pdefs[i].blue >> 8;
+
+ /* Copy the colors to a palette entry table */
+ pCmapPriv->peColors[pdefs[0].pixel + i].peRed = nRed;
+ pCmapPriv->peColors[pdefs[0].pixel + i].peGreen = nGreen;
+ pCmapPriv->peColors[pdefs[0].pixel + i].peBlue = nBlue;
+
+ /* Copy the colors to a RGBQUAD table */
+ pCmapPriv->rgbColors[pdefs[0].pixel + i].rgbRed = nRed;
+ pCmapPriv->rgbColors[pdefs[0].pixel + i].rgbGreen = nGreen;
+ pCmapPriv->rgbColors[pdefs[0].pixel + i].rgbBlue = nBlue;
+
+ winDebug ("winStoreColors - nRed %d nGreen %d nBlue %d\n",
+ nRed, nGreen, nBlue);
+ }
+
+ /* Call the engine specific store colors procedure */
+ if (!((pScreenPriv->pwinStoreColors) (pmap, ndef, pdefs)))
+ {
+ ErrorF ("winStoreColors - Engine cpecific color storage procedure "
+ "failed. Continuing, but colors may be messed up from now "
+ "on.\n");
+ }
+}
+
+
+/* See Porting Layer Definition - p. 30 */
+static void
+winResolveColor (unsigned short *pred,
+ unsigned short *pgreen,
+ unsigned short *pblue,
+ VisualPtr pVisual)
+{
+ winDebug ("winResolveColor ()\n");
+
+ miResolveColor (pred, pgreen, pblue, pVisual);
+}
+
+
+/* See Porting Layer Definition - p. 29 */
+static Bool
+winCreateColormap (ColormapPtr pmap)
+{
+ winPrivCmapPtr pCmapPriv = NULL;
+ ScreenPtr pScreen = pmap->pScreen;
+ winScreenPriv(pScreen);
+
+ winDebug ("winCreateColormap\n");
+
+ /* Allocate colormap privates */
+ if (!winAllocateCmapPrivates (pmap))
+ {
+ ErrorF ("winCreateColorma - Couldn't allocate cmap privates\n");
+ return FALSE;
+ }
+
+ /* Get a pointer to the newly allocated privates */
+ pCmapPriv = winGetCmapPriv (pmap);
+
+ /*
+ * FIXME: This is some evil hackery to help in handling some X clients
+ * that expect the top pixel to be white. This "help" only lasts until
+ * some client overwrites the top colormap entry.
+ *
+ * We don't want to actually allocate the top entry, as that causes
+ * problems with X clients that need 7 planes (128 colors) in the default
+ * colormap, such as Magic 7.1.
+ */
+ pCmapPriv->rgbColors[WIN_NUM_PALETTE_ENTRIES - 1].rgbRed = 255;
+ pCmapPriv->rgbColors[WIN_NUM_PALETTE_ENTRIES - 1].rgbGreen = 255;
+ pCmapPriv->rgbColors[WIN_NUM_PALETTE_ENTRIES - 1].rgbBlue = 255;
+ pCmapPriv->peColors[WIN_NUM_PALETTE_ENTRIES - 1].peRed = 255;
+ pCmapPriv->peColors[WIN_NUM_PALETTE_ENTRIES - 1].peGreen = 255;
+ pCmapPriv->peColors[WIN_NUM_PALETTE_ENTRIES - 1].peBlue = 255;
+
+ /* Call the engine specific colormap initialization procedure */
+ if (!((*pScreenPriv->pwinCreateColormap) (pmap)))
+ {
+ ErrorF ("winCreateColormap - Engine specific colormap creation "
+ "procedure failed. Aborting.\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/* See Porting Layer Definition - p. 29, 30 */
+static void
+winDestroyColormap (ColormapPtr pColormap)
+{
+ winScreenPriv(pColormap->pScreen);
+ winCmapPriv(pColormap);
+
+ /* Call the engine specific colormap destruction procedure */
+ if (!((*pScreenPriv->pwinDestroyColormap) (pColormap)))
+ {
+ ErrorF ("winDestroyColormap - Engine specific colormap destruction "
+ "procedure failed. Continuing, but it is possible that memory "
+ "was leaked, or that colors will be messed up from now on.\n");
+ }
+
+ /* Free the colormap privates */
+ free (pCmapPriv);
+ winSetCmapPriv (pColormap, NULL);
+
+ winDebug ("winDestroyColormap - Returning\n");
+}
+
+
+/*
+ * Internal function to load the palette used by the Shadow DIB
+ */
+
+static Bool
+winGetPaletteDIB (ScreenPtr pScreen, ColormapPtr pcmap)
+{
+ winScreenPriv(pScreen);
+ int i;
+ Pixel pixel; /* Pixel == CARD32 */
+ CARD16 nRed, nGreen, nBlue; /* CARD16 == unsigned short */
+ UINT uiColorsRetrieved = 0;
+ RGBQUAD rgbColors[WIN_NUM_PALETTE_ENTRIES];
+
+ /* Get the color table for the screen */
+ uiColorsRetrieved = GetDIBColorTable (pScreenPriv->hdcScreen,
+ 0,
+ WIN_NUM_PALETTE_ENTRIES,
+ rgbColors);
+ if (uiColorsRetrieved == 0)
+ {
+ ErrorF ("winGetPaletteDIB - Could not retrieve screen color table\n");
+ return FALSE;
+ }
+
+ winDebug ("winGetPaletteDIB - Retrieved %d colors from DIB\n",
+ uiColorsRetrieved);
+
+ /* Set the DIB color table to the default screen palette */
+ if (SetDIBColorTable (pScreenPriv->hdcShadow,
+ 0,
+ uiColorsRetrieved,
+ rgbColors) == 0)
+ {
+ ErrorF ("winGetPaletteDIB - SetDIBColorTable () failed\n");
+ return FALSE;
+ }
+
+ /* Alloc each color in the DIB color table */
+ for (i = 0; i < uiColorsRetrieved; ++i)
+ {
+ pixel = i;
+
+ /* Extract the color values for current palette entry */
+ nRed = rgbColors[i].rgbRed << 8;
+ nGreen = rgbColors[i].rgbGreen << 8;
+ nBlue = rgbColors[i].rgbBlue << 8;
+
+ winDebug ("winGetPaletteDIB - Allocating a color: %d; "
+ "%d %d %d\n",
+ pixel, nRed, nGreen, nBlue);
+
+ /* Allocate a entry in the X colormap */
+ if (AllocColor (pcmap,
+ &nRed,
+ &nGreen,
+ &nBlue,
+ &pixel,
+ 0) != Success)
+ {
+ ErrorF ("winGetPaletteDIB - AllocColor () failed, pixel %d\n",
+ i);
+ return FALSE;
+ }
+
+ if (i != pixel
+ || nRed != rgbColors[i].rgbRed
+ || nGreen != rgbColors[i].rgbGreen
+ || nBlue != rgbColors[i].rgbBlue)
+ {
+ winDebug ("winGetPaletteDIB - Got: %d; "
+ "%d %d %d\n",
+ (int) pixel, nRed, nGreen, nBlue);
+ }
+
+ /* FIXME: Not sure that this bit is needed at all */
+ pcmap->red[i].co.local.red = nRed;
+ pcmap->red[i].co.local.green = nGreen;
+ pcmap->red[i].co.local.blue = nBlue;
+ }
+
+ /* System is using a colormap */
+ /* Set the black and white pixel indices */
+ pScreen->whitePixel = uiColorsRetrieved - 1;
+ pScreen->blackPixel = 0;
+
+ return TRUE;
+}
+
+
+/*
+ * Internal function to load the standard system palette being used by DD
+ */
+
+static Bool
+winGetPaletteDD (ScreenPtr pScreen, ColormapPtr pcmap)
+{
+ int i;
+ Pixel pixel; /* Pixel == CARD32 */
+ CARD16 nRed, nGreen, nBlue; /* CARD16 == unsigned short */
+ UINT uiSystemPaletteEntries;
+ LPPALETTEENTRY ppeColors = NULL;
+ HDC hdc = NULL;
+
+ /* Get a DC to obtain the default palette */
+ hdc = GetDC (NULL);
+ if (hdc == NULL)
+ {
+ ErrorF ("winGetPaletteDD - Couldn't get a DC\n");
+ return FALSE;
+ }
+
+ /* Get the number of entries in the system palette */
+ uiSystemPaletteEntries = GetSystemPaletteEntries (hdc,
+ 0, 0, NULL);
+ if (uiSystemPaletteEntries == 0)
+ {
+ ErrorF ("winGetPaletteDD - Unable to determine number of "
+ "system palette entries\n");
+ return FALSE;
+ }
+
+ winDebug ("winGetPaletteDD - uiSystemPaletteEntries %d\n",
+ uiSystemPaletteEntries);
+
+ /* Allocate palette entries structure */
+ ppeColors = malloc (uiSystemPaletteEntries * sizeof (PALETTEENTRY));
+ if (ppeColors == NULL)
+ {
+ ErrorF ("winGetPaletteDD - malloc () for colormap failed\n");
+ return FALSE;
+ }
+
+ /* Get system palette entries */
+ GetSystemPaletteEntries (hdc,
+ 0, uiSystemPaletteEntries, ppeColors);
+
+ /* Allocate an X colormap entry for every system palette entry */
+ for (i = 0; i < uiSystemPaletteEntries; ++i)
+ {
+ pixel = i;
+
+ /* Extract the color values for current palette entry */
+ nRed = ppeColors[i].peRed << 8;
+ nGreen = ppeColors[i].peGreen << 8;
+ nBlue = ppeColors[i].peBlue << 8;
+ winDebug ("winGetPaletteDD - Allocating a color: %d; "
+ "%d %d %d\n",
+ pixel, nRed, nGreen, nBlue);
+ if (AllocColor (pcmap,
+ &nRed,
+ &nGreen,
+ &nBlue,
+ &pixel,
+ 0) != Success)
+ {
+ ErrorF ("winGetPaletteDD - AllocColor () failed, pixel %d\n",
+ i);
+ free (ppeColors);
+ ppeColors = NULL;
+ return FALSE;
+ }
+
+ pcmap->red[i].co.local.red = nRed;
+ pcmap->red[i].co.local.green = nGreen;
+ pcmap->red[i].co.local.blue = nBlue;
+ }
+
+ /* System is using a colormap */
+ /* Set the black and white pixel indices */
+ pScreen->whitePixel = uiSystemPaletteEntries - 1;
+ pScreen->blackPixel = 0;
+
+ /* Free colormap */
+ if (ppeColors != NULL)
+ {
+ free (ppeColors);
+ ppeColors = NULL;
+ }
+
+ /* Free the DC */
+ if (hdc != NULL)
+ {
+ ReleaseDC (NULL, hdc);
+ hdc = NULL;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Install the standard fb colormap, or the GDI colormap,
+ * depending on the current screen depth.
+ */
+
+Bool
+winCreateDefColormap (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ unsigned short zero = 0, ones = 0xFFFF;
+ VisualPtr pVisual = pScreenPriv->pRootVisual;
+ ColormapPtr pcmap = NULL;
+ Pixel wp, bp;
+
+ winDebug ("winCreateDefColormap\n");
+
+ /* Use standard fb colormaps for non palettized color modes */
+ if (pScreenInfo->dwBPP > 8)
+ {
+ winDebug ("winCreateDefColormap - Deferring to " \
+ "fbCreateDefColormap ()\n");
+ return fbCreateDefColormap (pScreen);
+ }
+
+ /*
+ * AllocAll for non-Dynamic visual classes,
+ * AllocNone for Dynamic visual classes.
+ */
+
+ /*
+ * Dynamic visual classes allow the colors of the color map
+ * to be changed by clients.
+ */
+
+ winDebug ("winCreateDefColormap - defColormap: %d\n",
+ pScreen->defColormap);
+
+ /* Allocate an X colormap, owned by client 0 */
+ if (CreateColormap (pScreen->defColormap,
+ pScreen,
+ pVisual,
+ &pcmap,
+ (pVisual->class & DynamicClass) ? AllocNone : AllocAll,
+ 0) != Success)
+ {
+ ErrorF ("winCreateDefColormap - CreateColormap failed\n");
+ return FALSE;
+ }
+ if (pcmap == NULL)
+ {
+ ErrorF ("winCreateDefColormap - Colormap could not be created\n");
+ return FALSE;
+ }
+
+ winDebug ("winCreateDefColormap - Created a colormap\n");
+
+ /* Branch on the visual class */
+ if (!(pVisual->class & DynamicClass))
+ {
+ /* Branch on engine type */
+ if (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI)
+ {
+ /* Load the colors being used by the Shadow DIB */
+ if (!winGetPaletteDIB (pScreen, pcmap))
+ {
+ ErrorF ("winCreateDefColormap - Couldn't get DIB colors\n");
+ return FALSE;
+ }
+ }
+ else
+ {
+ /* Load the colors from the default system palette */
+ if (!winGetPaletteDD (pScreen, pcmap))
+ {
+ ErrorF ("winCreateDefColormap - Couldn't get colors "
+ "for DD\n");
+ return FALSE;
+ }
+ }
+ }
+ else
+ {
+ wp = pScreen->whitePixel;
+ bp = pScreen->blackPixel;
+
+ /* Allocate a black and white pixel */
+ if ((AllocColor (pcmap, &ones, &ones, &ones, &wp, 0) !=
+ Success)
+ ||
+ (AllocColor (pcmap, &zero, &zero, &zero, &bp, 0) !=
+ Success))
+ {
+ ErrorF ("winCreateDefColormap - Couldn't allocate bp or wp\n");
+ return FALSE;
+ }
+
+ pScreen->whitePixel = wp;
+ pScreen->blackPixel = bp;
+
+ }
+
+ /* Install the created colormap */
+ (*pScreen->InstallColormap)(pcmap);
+
+ winDebug ("winCreateDefColormap - Returning\n");
+
+ return TRUE;
+}
diff --git a/xorg-server/hw/xwin/winconfig.c b/xorg-server/hw/xwin/winconfig.c
index 3e1908c90..0350e968b 100644
--- a/xorg-server/hw/xwin/winconfig.c
+++ b/xorg-server/hw/xwin/winconfig.c
@@ -129,11 +129,11 @@ winReadConfigfile ()
if (filename)
{
- winMsg (from, "Using config file: \"%s\"\n", filename);
+ winDebug ("Using config file: \"%s\"\n", filename);
}
else
{
- winMsg (X_ERROR, "Unable to locate/open config file");
+ ErrorF ("Unable to locate/open config file");
if (xf86ConfigFile)
ErrorF (": \"%s\"", xf86ConfigFile);
ErrorF ("\n");
@@ -141,7 +141,7 @@ winReadConfigfile ()
}
if ((g_xf86configptr = xf86readConfigFile ()) == NULL)
{
- winMsg (X_ERROR, "Problem parsing the config file\n");
+ ErrorF ("Problem parsing the config file\n");
return FALSE;
}
xf86closeConfigFile ();
@@ -154,13 +154,12 @@ winReadConfigfile ()
{
if (g_cmdline.screenname == NULL)
{
- winMsg (X_WARNING,
- "No Layout section. Using the first Screen section.\n");
+ winDebug ("No Layout section. Using the first Screen section.\n");
}
if (!configImpliedLayout (&g_winConfigLayout,
g_xf86configptr->conf_screen_lst))
{
- winMsg (X_ERROR, "Unable to determine the screen layout\n");
+ ErrorF ("Unable to determine the screen layout\n");
return FALSE;
}
}
@@ -180,7 +179,7 @@ winReadConfigfile ()
g_xf86configptr->conf_layout_lst,
dfltlayout))
{
- winMsg (X_ERROR, "Unable to determine the screen layout\n");
+ ErrorF ("Unable to determine the screen layout\n");
return FALSE;
}
}
@@ -190,7 +189,7 @@ winReadConfigfile ()
g_xf86configptr->conf_layout_lst,
NULL))
{
- winMsg (X_ERROR, "Unable to determine the screen layout\n");
+ ErrorF ("Unable to determine the screen layout\n");
return FALSE;
}
}
@@ -241,7 +240,7 @@ winConfigKeyboard (DeviceIntPtr pDevice)
case 3: g_winInfo.keyboard.delay = 1000; break;
}
g_winInfo.keyboard.rate = (kbd_speed>0)?kbd_speed:1;
- winMsgVerb(X_PROBED, 1, "Setting autorepeat to delay=%d, rate=%d\n",
+ winDebug("Setting autorepeat to delay=%d, rate=%d\n",
g_winInfo.keyboard.delay, g_winInfo.keyboard.rate);
}
}
@@ -267,12 +266,12 @@ winConfigKeyboard (DeviceIntPtr pDevice)
such as the lack of WM_KEYUP for Caps Lock key.
Loading US layout fixes this problem. */
if (LoadKeyboardLayout("00000409", KLF_ACTIVATE) != NULL)
- winMsg (X_INFO, "Loading US keyboard layout.\n");
+ winDebug("Loading US keyboard layout.\n");
else
- winMsg (X_ERROR, "LoadKeyboardLaout failed.\n");
+ ErrorF ("LoadKeyboardLaout failed.\n");
}
}
- winMsg (X_PROBED, "winConfigKeyboard - Layout: \"%s\" (%08x) \n",
+ winDebug ("winConfigKeyboard - Layout: \"%s\" (%08x) \n",
layoutName, layoutNum);
for (pLayout = winKBLayouts; pLayout->winlayout != -1; pLayout++)
@@ -283,9 +282,8 @@ winConfigKeyboard (DeviceIntPtr pDevice)
continue;
bfound = TRUE;
- winMsg (X_PROBED,
- "Using preset keyboard for \"%s\" (%x), type \"%d\"\n",
- pLayout->layoutname, pLayout->winlayout, keyboardType);
+ winDebug ("Using preset keyboard for \"%s\" (%x), type \"%d\"\n",
+ pLayout->layoutname, pLayout->winlayout, keyboardType);
g_winInfo.xkb.model = pLayout->xkbmodel;
g_winInfo.xkb.layout = pLayout->xkblayout;
@@ -310,8 +308,7 @@ winConfigKeyboard (DeviceIntPtr pDevice)
if (!RegOpenKey(HKEY_LOCAL_MACHINE, regpath, &regkey) &&
!RegQueryValueEx(regkey, "Layout Text", 0, NULL, lname, &namesize))
{
- winMsg (X_ERROR,
- "Keyboardlayout \"%s\" (%s) is unknown\n", lname, layoutName);
+ ErrorF ("Keyboardlayout \"%s\" (%s) is unknown\n", lname, layoutName);
}
/* Close registry key */
@@ -351,7 +348,7 @@ winConfigKeyboard (DeviceIntPtr pDevice)
{
if (kbd->inp_identifier)
- winMsg (kbdfrom, "Using keyboard \"%s\" as primary keyboard\n",
+ winDebug ("Using keyboard \"%s\" as primary keyboard\n",
kbd->inp_identifier);
if ((s = winSetStrOption(kbd->inp_option_lst, "AutoRepeat", NULL)))
@@ -362,12 +359,12 @@ winConfigKeyboard (DeviceIntPtr pDevice)
(g_winInfo.keyboard.rate == 0) ||
(1000 / g_winInfo.keyboard.rate) < 1)
{
- winErrorFVerb (2, "\"%s\" is not a valid AutoRepeat value", s);
+ ErrorF ("\"%s\" is not a valid AutoRepeat value", s);
xfree(s);
return FALSE;
}
xfree(s);
- winMsg (X_CONFIG, "AutoRepeat: %ld %ld\n",
+ winDebug ("AutoRepeat: %ld %ld\n",
g_winInfo.keyboard.delay, g_winInfo.keyboard.rate);
}
#endif
@@ -388,7 +385,7 @@ winConfigKeyboard (DeviceIntPtr pDevice)
if (s)
{
g_winInfo.xkb.rules = NULL_IF_EMPTY (s);
- winMsg (from, "XKB: rules: \"%s\"\n", s);
+ winDebug ("XKB: rules: \"%s\"\n", s);
}
s = NULL;
@@ -407,7 +404,7 @@ winConfigKeyboard (DeviceIntPtr pDevice)
if (s)
{
g_winInfo.xkb.model = NULL_IF_EMPTY (s);
- winMsg (from, "XKB: model: \"%s\"\n", s);
+ winDebug ("XKB: model: \"%s\"\n", s);
}
s = NULL;
@@ -426,7 +423,7 @@ winConfigKeyboard (DeviceIntPtr pDevice)
if (s)
{
g_winInfo.xkb.layout = NULL_IF_EMPTY (s);
- winMsg (from, "XKB: layout: \"%s\"\n", s);
+ winDebug ("XKB: layout: \"%s\"\n", s);
}
s = NULL;
@@ -445,7 +442,7 @@ winConfigKeyboard (DeviceIntPtr pDevice)
if (s)
{
g_winInfo.xkb.variant = NULL_IF_EMPTY (s);
- winMsg (from, "XKB: variant: \"%s\"\n", s);
+ winDebug ("XKB: variant: \"%s\"\n", s);
}
s = NULL;
@@ -464,7 +461,7 @@ winConfigKeyboard (DeviceIntPtr pDevice)
if (s)
{
g_winInfo.xkb.options = NULL_IF_EMPTY (s);
- winMsg (from, "XKB: options: \"%s\"\n", s);
+ winDebug ("XKB: options: \"%s\"\n", s);
}
#ifdef XWIN_XF86CONFIG
@@ -506,7 +503,7 @@ winConfigMouse (DeviceIntPtr pDevice)
if (mouse != NULL)
{
if (mouse->inp_identifier)
- winMsg (mousefrom, "Using pointer \"%s\" as primary pointer\n",
+ winDebug ("Using pointer \"%s\" as primary pointer\n",
mouse->inp_identifier);
g_winInfo.pointer.emulate3Buttons =
@@ -521,8 +518,8 @@ winConfigMouse (DeviceIntPtr pDevice)
}
else
{
- winMsg (X_ERROR, "No primary pointer configured\n");
- winMsg (X_DEFAULT, "Using compiletime defaults for pointer\n");
+ winDebug ("No primary pointer configured\n");
+ winDebug ("Using compiletime defaults for pointer\n");
}
return TRUE;
@@ -555,7 +552,7 @@ winConfigFiles ()
from = X_CONFIG;
defaultFontPath = xstrdup (filesptr->file_fontpath);
}
- winMsg (from, "FontPath set to \"%s\"\n", defaultFontPath);
+ winDebug ("FontPath set to \"%s\"\n", defaultFontPath);
return TRUE;
}
@@ -567,7 +564,7 @@ winConfigFiles (void)
if (g_cmdline.fontPath)
{
defaultFontPath = g_cmdline.fontPath;
- winMsg (X_CMDLINE, "FontPath set to \"%s\"\n", defaultFontPath);
+ winDebug("FontPath set to \"%s\"\n", defaultFontPath);
}
return TRUE;
@@ -747,8 +744,7 @@ ParseOptionValue (int scrnIndex, pointer options, OptionInfoPtr p)
case OPTV_INTEGER:
if (*s == '\0')
{
- winDrvMsg (scrnIndex, X_WARNING,
- "Option \"%s\" requires an integer value\n",
+ winDebug ( "Option \"%s\" requires an integer value\n",
p->name);
p->found = FALSE;
}
@@ -761,8 +757,7 @@ ParseOptionValue (int scrnIndex, pointer options, OptionInfoPtr p)
}
else
{
- winDrvMsg (scrnIndex, X_WARNING,
- "Option \"%s\" requires an integer value\n",
+ winDebug ( "Option \"%s\" requires an integer value\n",
p->name);
p->found = FALSE;
}
@@ -771,8 +766,7 @@ ParseOptionValue (int scrnIndex, pointer options, OptionInfoPtr p)
case OPTV_STRING:
if (*s == '\0')
{
- winDrvMsg (scrnIndex, X_WARNING,
- "Option \"%s\" requires an string value\n", p->name);
+ winDebug ( "Option \"%s\" requires an string value\n", p->name);
p->found = FALSE;
}
else
@@ -788,8 +782,7 @@ ParseOptionValue (int scrnIndex, pointer options, OptionInfoPtr p)
case OPTV_REAL:
if (*s == '\0')
{
- winDrvMsg (scrnIndex, X_WARNING,
- "Option \"%s\" requires a floating point value\n",
+ winDebug ( "Option \"%s\" requires a floating point value\n",
p->name);
p->found = FALSE;
}
@@ -802,8 +795,7 @@ ParseOptionValue (int scrnIndex, pointer options, OptionInfoPtr p)
}
else
{
- winDrvMsg (scrnIndex, X_WARNING,
- "Option \"%s\" requires a floating point value\n",
+ winDebug ( "Option \"%s\" requires a floating point value\n",
p->name);
p->found = FALSE;
}
@@ -816,16 +808,14 @@ ParseOptionValue (int scrnIndex, pointer options, OptionInfoPtr p)
}
else
{
- winDrvMsg (scrnIndex, X_WARNING,
- "Option \"%s\" requires a boolean value\n", p->name);
+ winDebug ( "Option \"%s\" requires a boolean value\n", p->name);
p->found = FALSE;
}
break;
case OPTV_FREQ:
if (*s == '\0')
{
- winDrvMsg (scrnIndex, X_WARNING,
- "Option \"%s\" requires a frequency value\n",
+ winDebug ( "Option \"%s\" requires a frequency value\n",
p->name);
p->found = FALSE;
}
@@ -847,8 +837,7 @@ ParseOptionValue (int scrnIndex, pointer options, OptionInfoPtr p)
units = 1000000;
else
{
- winDrvMsg (scrnIndex, X_WARNING,
- "Option \"%s\" requires a frequency value\n",
+ winDebug ( "Option \"%s\" requires a frequency value\n",
p->name);
p->found = FALSE;
}
@@ -857,8 +846,7 @@ ParseOptionValue (int scrnIndex, pointer options, OptionInfoPtr p)
}
else
{
- winDrvMsg (scrnIndex, X_WARNING,
- "Option \"%s\" requires a frequency value\n",
+ winDebug ( "Option \"%s\" requires a frequency value\n",
p->name);
p->found = FALSE;
}
@@ -876,12 +864,12 @@ ParseOptionValue (int scrnIndex, pointer options, OptionInfoPtr p)
}
if (p->found)
{
- winDrvMsgVerb (scrnIndex, X_CONFIG, 2, "Option \"%s\"", p->name);
+ winDebug ("Option \"%s\"", p->name);
if (!(p->type == OPTV_BOOLEAN && *s == 0))
{
- winErrorFVerb (2, " \"%s\"", s);
+ winDebug (" \"%s\"", s);
}
- winErrorFVerb (2, "\n");
+ winDebug ("\n");
}
}
else if (p->type == OPTV_BOOLEAN)
@@ -922,8 +910,7 @@ ParseOptionValue (int scrnIndex, pointer options, OptionInfoPtr p)
}
else
{
- winDrvMsg (scrnIndex, X_WARNING,
- "Option \"%s\" requires a boolean value\n", newn);
+ winDebug ( "Option \"%s\" requires a boolean value\n", newn);
p->found = FALSE;
}
}
@@ -933,12 +920,12 @@ ParseOptionValue (int scrnIndex, pointer options, OptionInfoPtr p)
}
if (p->found)
{
- winDrvMsgVerb (scrnIndex, X_CONFIG, 2, "Option \"%s\"", newn);
+ winDebug ("Option \"%s\"", newn);
if (*s != 0)
{
- winErrorFVerb (2, " \"%s\"", s);
+ winDebug (" \"%s\"", s);
}
- winErrorFVerb (2, "\n");
+ winDebug ("\n");
}
free (n);
}
diff --git a/xorg-server/hw/xwin/wincreatewnd.c b/xorg-server/hw/xwin/wincreatewnd.c
index 0c342e1ae..b684922aa 100644
--- a/xorg-server/hw/xwin/wincreatewnd.c
+++ b/xorg-server/hw/xwin/wincreatewnd.c
@@ -66,9 +66,7 @@ winCreateBoundingWindowFullScreen (ScreenPtr pScreen)
WNDCLASSEX wc;
char szTitle[256];
-#if CYGDEBUG
winDebug ("winCreateBoundingWindowFullScreen\n");
-#endif
/* Setup our window class */
wc.cbSize=sizeof(WNDCLASSEX);
@@ -95,13 +93,17 @@ winCreateBoundingWindowFullScreen (ScreenPtr pScreen)
g_pszQueryHost,
display,
(int) pScreenInfo->dwScreen);
- else
+ else
+ {
+ char HostName[256];
+ gethostname(HostName,256);
snprintf (szTitle,
sizeof (szTitle),
WINDOW_TITLE,
+ HostName,
display,
(int) pScreenInfo->dwScreen);
-
+ }
/* Create the window */
*phwnd = CreateWindowExA (0, /* Extended styles */
WINDOW_CLASS, /* Class name */
@@ -237,10 +239,8 @@ winCreateBoundingWindowWindowed (ScreenPtr pScreen)
if (pScreenInfo->fUserGaveHeightAndWidth)
{
/* User gave a desired height and width, try to accomodate */
-#if CYGDEBUG
winDebug ("winCreateBoundingWindowWindowed - User gave height "
"and width\n");
-#endif
/* Adjust the window width and height for borders and title bar */
if (pScreenInfo->fDecoration
@@ -253,16 +253,12 @@ winCreateBoundingWindowWindowed (ScreenPtr pScreen)
#endif
)
{
-#if CYGDEBUG
winDebug ("winCreateBoundingWindowWindowed - Window has decoration\n");
-#endif
/* Are we using scrollbars? */
if (pScreenInfo->fScrollbars)
{
-#if CYGDEBUG
winDebug ("winCreateBoundingWindowWindowed - Window has "
"scrollbars\n");
-#endif
iWidth += 2 * GetSystemMetrics (SM_CXSIZEFRAME);
iHeight += 2 * GetSystemMetrics (SM_CYSIZEFRAME)
@@ -270,10 +266,8 @@ winCreateBoundingWindowWindowed (ScreenPtr pScreen)
}
else
{
-#if CYGDEBUG
winDebug ("winCreateBoundingWindowWindowed - Window does not have "
"scrollbars\n");
-#endif
iWidth += 2 * GetSystemMetrics (SM_CXFIXEDFRAME);
iHeight += 2 * GetSystemMetrics (SM_CYFIXEDFRAME)
@@ -284,10 +278,8 @@ winCreateBoundingWindowWindowed (ScreenPtr pScreen)
else
{
/* By default, we are creating a window that is as large as possible */
-#if CYGDEBUG
winDebug ("winCreateBoundingWindowWindowed - User did not give "
"height and width\n");
-#endif
/* Defaults are wrong if we have multiple monitors */
if (pScreenInfo->fMultipleMonitors)
{
@@ -329,11 +321,9 @@ winCreateBoundingWindowWindowed (ScreenPtr pScreen)
if (iHeight >= (rcWorkArea.bottom - rcWorkArea.top))
iHeight = rcWorkArea.bottom - rcWorkArea.top;
-#if CYGDEBUG
winDebug ("winCreateBoundingWindowWindowed - Adjusted width: %d "\
"height: %d\n",
iWidth, iHeight);
-#endif
}
/* Set display and screen-specific tooltip text */
@@ -344,12 +334,17 @@ winCreateBoundingWindowWindowed (ScreenPtr pScreen)
g_pszQueryHost,
display,
(int) pScreenInfo->dwScreen);
- else
+ else
+ {
+ char HostName[256];
+ gethostname(HostName,256);
snprintf (szTitle,
sizeof (szTitle),
WINDOW_TITLE,
+ HostName,
display,
(int) pScreenInfo->dwScreen);
+ }
/* Create the window */
*phwnd = CreateWindowExA (0, /* Extended styles */
@@ -370,9 +365,7 @@ winCreateBoundingWindowWindowed (ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG
winDebug ("winCreateBoundingWindowWindowed - CreateWindowEx () returned\n");
-#endif
if (fForceShowWindow)
{
diff --git a/xorg-server/hw/xwin/wincursor.c b/xorg-server/hw/xwin/wincursor.c
index ce98162ef..32ee560df 100644
--- a/xorg-server/hw/xwin/wincursor.c
+++ b/xorg-server/hw/xwin/wincursor.c
@@ -45,10 +45,9 @@ extern Bool g_fSoftwareCursor;
#define BRIGHTNESS(x) (x##Red * 0.299 + x##Green * 0.587 + x##Blue * 0.114)
-#if 0
-# define WIN_DEBUG_MSG winDebug
-#else
-# define WIN_DEBUG_MSG(...)
+#ifdef _MSC_VER
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
/*
@@ -87,7 +86,7 @@ winPointerWarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
/* Don't ignore subsequent warps */
s_fInitialWarp = FALSE;
- winErrorFVerb (2, "winPointerWarpCursor - Discarding first warp: %d %d\n",
+ winDebug ("winPointerWarpCursor - Discarding first warp: %d %d\n",
x, y);
return;
@@ -172,7 +171,7 @@ winLoadCursor (ScreenPtr pScreen, CursorPtr pCursor, int screen)
BITMAPINFO *pbmi;
unsigned long *lpBits;
- WIN_DEBUG_MSG("winLoadCursor: Win32: %dx%d X11: %dx%d hotspot: %d,%d\n",
+ winDebug("winLoadCursor: Win32: %dx%d X11: %dx%d hotspot: %d,%d\n",
pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy,
pCursor->bits->width, pCursor->bits->height,
pCursor->bits->xhot, pCursor->bits->yhot
@@ -188,7 +187,7 @@ winLoadCursor (ScreenPtr pScreen, CursorPtr pCursor, int screen)
if (pScreenPriv->cursor.sm_cx < pCursor->bits->width ||
pScreenPriv->cursor.sm_cy < pCursor->bits->height)
{
- winErrorFVerb (2, "winLoadCursor - Windows requires %dx%d cursor\n"
+ ErrorF ("winLoadCursor - Windows requires %dx%d cursor\n"
"\tbut X requires %dx%d\n",
pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy,
pCursor->bits->width, pCursor->bits->height);
@@ -251,7 +250,7 @@ winLoadCursor (ScreenPtr pScreen, CursorPtr pCursor, int screen)
/* We have a truecolor alpha-blended cursor and can use it! */
if (pCursor->bits->argb)
{
- WIN_DEBUG_MSG("winLoadCursor: Trying truecolor alphablended cursor\n");
+ winDebug("winLoadCursor: Trying truecolor alphablended cursor\n");
memset (&bi, 0, sizeof (BITMAPV4HEADER));
bi.bV4Size = sizeof(BITMAPV4HEADER);
bi.bV4Width = pScreenPriv->cursor.sm_cx;
@@ -282,7 +281,7 @@ winLoadCursor (ScreenPtr pScreen, CursorPtr pCursor, int screen)
if (!lpBits)
{
/* Bicolor, use a palettized DIB */
- WIN_DEBUG_MSG("winLoadCursor: Trying two color cursor\n");
+ winDebug("winLoadCursor: Trying two color cursor\n");
pbmi = (BITMAPINFO*)&bi;
memset (pbmi, 0, sizeof (BITMAPINFOHEADER));
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
@@ -346,7 +345,7 @@ winLoadCursor (ScreenPtr pScreen, CursorPtr pCursor, int screen)
/* If one of the previous two methods gave us the bitmap we need, make a cursor */
if (lpBits)
{
- WIN_DEBUG_MSG("winLoadCursor: Creating bitmap cursor: hotspot %d,%d\n",
+ winDebug("winLoadCursor: Creating bitmap cursor: hotspot %d,%d\n",
pCursor->bits->xhot, pCursor->bits->yhot);
hAnd = NULL;
@@ -374,14 +373,14 @@ winLoadCursor (ScreenPtr pScreen, CursorPtr pCursor, int screen)
hCursor = (HCURSOR) CreateIconIndirect( &ii );
if (hCursor == NULL)
- winW32Error(2, "winLoadCursor - CreateIconIndirect failed:");
+ winW32Error("winLoadCursor - CreateIconIndirect failed:");
else
{
if (GetIconInfo(hCursor, &ii))
{
if (ii.fIcon)
{
- WIN_DEBUG_MSG("winLoadCursor: CreateIconIndirect returned no cursor. Trying again.\n");
+ winDebug("winLoadCursor: CreateIconIndirect returned no cursor. Trying again.\n");
DestroyCursor(hCursor);
@@ -391,7 +390,7 @@ winLoadCursor (ScreenPtr pScreen, CursorPtr pCursor, int screen)
hCursor = (HCURSOR) CreateIconIndirect( &ii );
if (hCursor == NULL)
- winW32Error(2, "winLoadCursor - CreateIconIndirect failed:");
+ winW32Error("winLoadCursor - CreateIconIndirect failed:");
}
/* GetIconInfo creates new bitmaps. Destroy them again */
if (ii.hbmMask)
@@ -417,7 +416,7 @@ winLoadCursor (ScreenPtr pScreen, CursorPtr pCursor, int screen)
pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy,
pAnd, pXor);
if (hCursor == NULL)
- winW32Error(2, "winLoadCursor - CreateCursor failed:");
+ winW32Error("winLoadCursor - CreateCursor failed:");
}
free (pAnd);
free (pXor);
@@ -472,7 +471,7 @@ winSetCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x, in
RECT rcClient;
BOOL bInhibit;
winScreenPriv(pScreen);
- WIN_DEBUG_MSG("winSetCursor: cursor=%p\n", pCursor);
+ winDebug("winSetCursor: cursor=%p\n", pCursor);
/* Inhibit changing the cursor if the mouse is not in a client area */
bInhibit = FALSE;
@@ -523,7 +522,7 @@ winSetCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x, in
}
pScreenPriv->cursor.handle =
winLoadCursor (pScreen, pCursor, pScreen->myNum);
- WIN_DEBUG_MSG("winSetCursor: handle=%p\n", pScreenPriv->cursor.handle);
+ winDebug("winSetCursor: handle=%p\n", pScreenPriv->cursor.handle);
if (!bInhibit)
SetCursor (pScreenPriv->cursor.handle);
@@ -558,7 +557,7 @@ static void
winDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScr)
{
winScreenPriv(pScr);
- return pScreenPriv->cursor.spriteFuncs->DeviceCursorCleanup(pDev, pScr);
+ pScreenPriv->cursor.spriteFuncs->DeviceCursorCleanup(pDev, pScr);
}
static miPointerSpriteFuncRec winSpriteFuncsRec = {
@@ -617,9 +616,11 @@ winInitCursor (ScreenPtr pScreen)
pPointPriv = (miPointerScreenPtr)
dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
+ if (pPointPriv)
+ {
pScreenPriv->cursor.spriteFuncs = pPointPriv->spriteFuncs;
pPointPriv->spriteFuncs = &winSpriteFuncsRec;
-
+ }
pScreenPriv->cursor.handle = NULL;
pScreenPriv->cursor.visible = FALSE;
diff --git a/xorg-server/hw/xwin/windialogs.c b/xorg-server/hw/xwin/windialogs.c
index 582b865f5..adbec19cb 100644
--- a/xorg-server/hw/xwin/windialogs.c
+++ b/xorg-server/hw/xwin/windialogs.c
@@ -1,787 +1,781 @@
-/*
- *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, 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 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 HAROLD L HUNT II 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 Harold L Hunt II
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from Harold L Hunt II.
- *
- * Authors: Harold L Hunt II
- * Earle F. Philhower III
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-#ifdef __CYGWIN__
-#include <sys/cygwin.h>
-#endif
-#include <shellapi.h>
-#include "winprefs.h"
-
-
-/*
- * References to external globals
- */
-
-extern Bool g_fCursor;
-extern HWND g_hDlgDepthChange;
-extern HWND g_hDlgExit;
-extern HWND g_hDlgAbout;
-extern WINPREFS pref;
-#ifdef XWIN_CLIPBOARD
-extern Bool g_fClipboardStarted;
-#endif
-extern Bool g_fSoftwareCursor;
-
-#if defined(XWIN_MULTIWINDOW)
-extern HICON g_hIconX;
-extern HICON g_hSmallIconX;
-#endif
-
-/*
- * Local function prototypes
- */
-
-static wBOOL CALLBACK
-winExitDlgProc (HWND hDialog, UINT message,
- WPARAM wParam, LPARAM lParam);
-
-static wBOOL CALLBACK
-winChangeDepthDlgProc (HWND hDialog, UINT message,
- WPARAM wParam, LPARAM lParam);
-
-static wBOOL CALLBACK
-winAboutDlgProc (HWND hDialog, UINT message,
- WPARAM wParam, LPARAM lParam);
-
-
-static void
-winDrawURLWindow (LPARAM lParam);
-
-static LRESULT CALLBACK
-winURLWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
-
-static void
-winOverrideURLButton (HWND hdlg, int id);
-
-static void
-winUnoverrideURLButton (HWND hdlg, int id);
-
-
-/*
- * Owner-draw a button as a URL
- */
-
-static void
-winDrawURLWindow (LPARAM lParam)
-{
- DRAWITEMSTRUCT *draw;
- char str[256];
- RECT rect;
- HFONT font;
- COLORREF crText;
-
- draw = (DRAWITEMSTRUCT *) lParam;
- GetWindowText (draw->hwndItem, str, sizeof(str));
- str[255] = 0;
- GetClientRect (draw->hwndItem, &rect);
-
- /* Color the button depending upon its state */
- if (draw->itemState & ODS_SELECTED)
- crText = RGB(128+64,0,0);
- else if (draw->itemState & ODS_FOCUS)
- crText = RGB(0,128+64,0);
- else
- crText = RGB(0,0,128+64);
- SetTextColor (draw->hDC, crText);
-
- /* Create underlined font 14 high, standard dialog font */
- font = CreateFont (-14, 0, 0, 0, FW_NORMAL, FALSE, TRUE, FALSE,
- 0, 0, 0, 0, 0, "MS Sans Serif");
- if (!font)
- {
- ErrorF ("winDrawURLWindow: Unable to create URL font, bailing.\n");
- return;
- }
- /* Draw it */
- SetBkMode (draw->hDC, OPAQUE);
- SelectObject (draw->hDC, font);
- DrawText (draw->hDC, str, strlen (str),&rect,DT_CENTER | DT_VCENTER);
- /* Delete the created font, replace it with stock font */
- DeleteObject (SelectObject (draw->hDC, GetStockObject (ANSI_VAR_FONT)));
-}
-
-
-/*
- * WndProc for overridden buttons
- */
-
-static LRESULT CALLBACK
-winURLWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- WNDPROC origCB = NULL;
- HCURSOR cursor;
-
- /* If it's a SetCursor message, tell it to the hand */
- if (msg==WM_SETCURSOR) {
- cursor = LoadCursor (NULL, IDC_HAND);
- if (cursor)
- SetCursor (cursor);
- return TRUE;
- }
- origCB = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- /* Otherwise fall through to original WndProc */
- if (origCB)
- return CallWindowProc (origCB, hwnd, msg, wParam, lParam);
- else
- return FALSE;
-}
-
-
-/*
- * Register and unregister the custom WndProc
- */
-
-static void
-winOverrideURLButton (HWND hwnd, int id)
-{
- WNDPROC origCB;
- origCB = (WNDPROC)SetWindowLongPtr(GetDlgItem (hwnd, id),
- GWLP_WNDPROC, (LONG_PTR)winURLWndProc);
- SetWindowLongPtr(GetDlgItem (hwnd, id), GWLP_USERDATA, (LONG_PTR)origCB);
-}
-
-static void
-winUnoverrideURLButton (HWND hwnd, int id)
-{
- WNDPROC origCB;
- origCB = (WNDPROC)SetWindowLongPtr(GetDlgItem (hwnd, id),
- GWLP_USERDATA, 0);
- if (origCB)
- SetWindowLongPtr(GetDlgItem (hwnd, id), GWLP_WNDPROC, (LONG_PTR)origCB);
-}
-
-
-/*
- * Center a dialog window in the desktop window
- * and set small and large icons to X icons.
- */
-
-static void
-winInitDialog (HWND hwndDlg)
-{
- HWND hwndDesk;
- RECT rc, rcDlg, rcDesk;
- HICON hIcon, hIconSmall;
-
- hwndDesk = GetParent (hwndDlg);
- if (!hwndDesk || IsIconic (hwndDesk))
- hwndDesk = GetDesktopWindow ();
-
- /* Remove minimize and maximize buttons */
- SetWindowLongPtr(hwndDlg, GWL_STYLE,
- GetWindowLongPtr(hwndDlg, GWL_STYLE)
- & ~(WS_MAXIMIZEBOX | WS_MINIMIZEBOX));
-
- /* Set Window not to show in the task bar */
- SetWindowLongPtr(hwndDlg, GWL_EXSTYLE,
- GetWindowLongPtr(hwndDlg, GWL_EXSTYLE) & ~WS_EX_APPWINDOW );
-
- /* Center dialog window in the screen. Not done for multi-monitor systems, where
- * it is likely to end up split across the screens. In that case, it appears
- * near the Tray icon.
- */
- if (GetSystemMetrics(SM_CMONITORS)>1) {
- /* Still need to refresh the frame change. */
- SetWindowPos (hwndDlg, HWND_TOPMOST, 0,0,0,0,
- SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
- } else {
- GetWindowRect (hwndDesk, &rcDesk);
- GetWindowRect (hwndDlg, &rcDlg);
- CopyRect (&rc, &rcDesk);
-
- OffsetRect (&rcDlg, -rcDlg.left, -rcDlg.top);
- OffsetRect (&rc, -rc.left, -rc.top);
- OffsetRect (&rc, -rcDlg.right, -rcDlg.bottom);
-
- SetWindowPos (hwndDlg,
- HWND_TOPMOST,
- rcDesk.left + (rc.right / 2),
- rcDesk.top + (rc.bottom / 2),
- 0, 0,
- SWP_NOSIZE | SWP_FRAMECHANGED);
- }
-
-#ifdef XWIN_MULTIWINDOW
- if (g_hIconX) hIcon=g_hIconX;
- else
-#endif
- hIcon = LoadIcon (g_hInstance, MAKEINTRESOURCE(IDI_XWIN));
-
-#ifdef XWIN_MULTIWINDOW
- if (g_hSmallIconX) hIconSmall=g_hSmallIconX;
- else
-#endif
- hIconSmall = LoadImage (g_hInstance,
- MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON,
- GetSystemMetrics(SM_CXSMICON),
- GetSystemMetrics(SM_CYSMICON),
- LR_SHARED);
-
- PostMessage (hwndDlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon);
- PostMessage (hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall);
-}
-
-
-/*
- * Display the Exit dialog box
- */
-
-void
-winDisplayExitDialog (winPrivScreenPtr pScreenPriv)
-{
- int i;
- int liveClients = 0;
-
- /* Count up running clients (clients[0] is serverClient) */
- for (i = 1; i < currentMaxClients; i++)
- if (clients[i] != NullClient)
- liveClients++;
-#if defined(XWIN_MULTIWINDOW)
- /* Count down server internal clients */
- if (pScreenPriv->pScreenInfo->fMultiWindow)
- liveClients -= 2; /* multiwindow window manager & XMsgProc */
-#endif
-#if defined(XWIN_CLIPBOARD)
- if (g_fClipboardStarted)
- liveClients--; /* clipboard manager */
-#endif
-
- /* A user reported that this sometimes drops below zero. just eye-candy. */
- if (liveClients < 0)
- liveClients = 0;
-
- /* Don't show the exit confirmation dialog if SilentExit & no clients,
- or ForceExit, is enabled */
- if ((pref.fSilentExit && liveClients <= 0) || pref.fForceExit)
- {
- if (g_hDlgExit != NULL)
- {
- DestroyWindow (g_hDlgExit);
- g_hDlgExit = NULL;
- }
- PostMessage (pScreenPriv->hwndScreen, WM_GIVEUP, 0, 0);
- return;
- }
-
- pScreenPriv->iConnectedClients = liveClients;
-
- /* Check if dialog already exists */
- if (g_hDlgExit != NULL)
- {
- /* Dialog box already exists, display it */
- ShowWindow (g_hDlgExit, SW_SHOWDEFAULT);
-
- /* User has lost the dialog. Show them where it is. */
- SetForegroundWindow (g_hDlgExit);
-
- return;
- }
-
- /* Create dialog box */
- g_hDlgExit = CreateDialogParam (g_hInstance,
- "EXIT_DIALOG",
- pScreenPriv->hwndScreen,
- winExitDlgProc,
- (int) pScreenPriv);
-
- /* Show the dialog box */
- ShowWindow (g_hDlgExit, SW_SHOW);
-
- /* Needed to get keyboard controls (tab, arrows, enter, esc) to work */
- SetForegroundWindow (g_hDlgExit);
-
- /* Set focus to the Cancel button */
- PostMessage (g_hDlgExit, WM_NEXTDLGCTL,
- GetDlgItem (g_hDlgExit, IDCANCEL), TRUE);
-}
-
-#define CONNECTED_CLIENTS_FORMAT "There %s currently %d client%s connected."
-
-
-/*
- * Exit dialog window procedure
- */
-
-static wBOOL CALLBACK
-winExitDlgProc (HWND hDialog, UINT message,
- WPARAM wParam, LPARAM lParam)
-{
- static winPrivScreenPtr s_pScreenPriv = NULL;
-
- /* Branch on message type */
- switch (message)
- {
- case WM_INITDIALOG:
- {
- char *pszConnectedClients;
-
- /* Store pointers to private structures for future use */
- s_pScreenPriv = (winPrivScreenPtr) lParam;
-
- winInitDialog (hDialog);
-
- /* Format the connected clients string */
- pszConnectedClients = Xprintf (CONNECTED_CLIENTS_FORMAT,
- (s_pScreenPriv->iConnectedClients == 1) ? "is" : "are",
- s_pScreenPriv->iConnectedClients,
- (s_pScreenPriv->iConnectedClients == 1) ? "" : "s");
- if (!pszConnectedClients)
- return TRUE;
-
-
-
- /* Set the number of connected clients */
- SetWindowText (GetDlgItem (hDialog, IDC_CLIENTS_CONNECTED),
- pszConnectedClients);
- xfree (pszConnectedClients);
- }
- return TRUE;
-
- case WM_COMMAND:
- switch (LOWORD (wParam))
- {
- case IDOK:
- /* Send message to call the GiveUp function */
- PostMessage (s_pScreenPriv->hwndScreen, WM_GIVEUP, 0, 0);
- DestroyWindow (g_hDlgExit);
- g_hDlgExit = NULL;
-
- /* Fix to make sure keyboard focus isn't trapped */
- PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
- return TRUE;
-
- case IDCANCEL:
- DestroyWindow (g_hDlgExit);
- g_hDlgExit = NULL;
-
- /* Fix to make sure keyboard focus isn't trapped */
- PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
- return TRUE;
- }
- break;
-
- case WM_MOUSEMOVE:
- case WM_NCMOUSEMOVE:
- /* Show the cursor if it is hidden */
- if (g_fSoftwareCursor && !g_fCursor)
- {
- g_fCursor = TRUE;
- ShowCursor (TRUE);
- }
- return TRUE;
-
- case WM_CLOSE:
- DestroyWindow (g_hDlgExit);
- g_hDlgExit = NULL;
-
- /* Fix to make sure keyboard focus isn't trapped */
- PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
- return TRUE;
- }
-
- return FALSE;
-}
-
-
-/*
- * Display the Depth Change dialog box
- */
-
-void
-winDisplayDepthChangeDialog (winPrivScreenPtr pScreenPriv)
-{
- /* Check if dialog already exists */
- if (g_hDlgDepthChange != NULL)
- {
- /* Dialog box already exists, display it */
- ShowWindow (g_hDlgDepthChange, SW_SHOWDEFAULT);
-
- /* User has lost the dialog. Show them where it is. */
- SetForegroundWindow (g_hDlgDepthChange);
-
- return;
- }
-
- /*
- * Display a notification to the user that the visual
- * will not be displayed until the Windows display depth
- * is restored to the original value.
- */
- g_hDlgDepthChange = CreateDialogParam (g_hInstance,
- "DEPTH_CHANGE_BOX",
- pScreenPriv->hwndScreen,
- winChangeDepthDlgProc,
- (int) pScreenPriv);
- /* Show the dialog box */
- ShowWindow (g_hDlgDepthChange, SW_SHOW);
-
- ErrorF ("winDisplayDepthChangeDialog - DialogBox returned: %d\n",
- (int) g_hDlgDepthChange);
- ErrorF ("winDisplayDepthChangeDialog - GetLastError: %d\n",
- (int) GetLastError ());
-
- /* Minimize the display window */
- ShowWindow (pScreenPriv->hwndScreen, SW_MINIMIZE);
-}
-
-
-/*
- * Process messages for the dialog that is displayed for
- * disruptive screen depth changes.
- */
-
-static wBOOL CALLBACK
-winChangeDepthDlgProc (HWND hwndDialog, UINT message,
- WPARAM wParam, LPARAM lParam)
-{
- static winPrivScreenPtr s_pScreenPriv = NULL;
- static winScreenInfo *s_pScreenInfo = NULL;
- static ScreenPtr s_pScreen = NULL;
-
-#if CYGDEBUG
- winDebug ("winChangeDepthDlgProc\n");
-#endif
-
- /* Branch on message type */
- switch (message)
- {
- case WM_INITDIALOG:
-#if CYGDEBUG
- winDebug ("winChangeDepthDlgProc - WM_INITDIALOG\n");
-#endif
-
- /* Store pointers to private structures for future use */
- s_pScreenPriv = (winPrivScreenPtr) lParam;
- s_pScreenInfo = s_pScreenPriv->pScreenInfo;
- s_pScreen = s_pScreenInfo->pScreen;
-
-#if CYGDEBUG
- winDebug ("winChangeDepthDlgProc - WM_INITDIALOG - s_pScreenPriv: %08x, "
- "s_pScreenInfo: %08x, s_pScreen: %08x\n",
- s_pScreenPriv, s_pScreenInfo, s_pScreen);
-#endif
-
-#if CYGDEBUG
- winDebug ("winChangeDepthDlgProc - WM_INITDIALOG - orig bpp: %d, "
- "last bpp: %d\n",
- s_pScreenInfo->dwBPP,
- s_pScreenPriv->dwLastWindowsBitsPixel);
-#endif
-
- winInitDialog( hwndDialog );
-
- return TRUE;
-
- case WM_DISPLAYCHANGE:
-#if CYGDEBUG
- winDebug ("winChangeDepthDlgProc - WM_DISPLAYCHANGE - orig bpp: %d, "
- "last bpp: %d, new bpp: %d\n",
- s_pScreenInfo->dwBPP,
- s_pScreenPriv->dwLastWindowsBitsPixel,
- wParam);
-#endif
-
- /* Dismiss the dialog if the display returns to the original depth */
- if (wParam == s_pScreenInfo->dwBPP)
- {
- ErrorF ("winChangeDelthDlgProc - wParam == s_pScreenInfo->dwBPP\n");
-
- /* Depth has been restored, dismiss dialog */
- DestroyWindow (g_hDlgDepthChange);
- g_hDlgDepthChange = NULL;
-
- /* Flag that we have a valid screen depth */
- s_pScreenPriv->fBadDepth = FALSE;
- }
- return TRUE;
-
- case WM_COMMAND:
- switch (LOWORD (wParam))
- {
- case IDOK:
- case IDCANCEL:
- ErrorF ("winChangeDepthDlgProc - WM_COMMAND - IDOK or IDCANCEL\n");
-
- /*
- * User dismissed the dialog, hide it until the
- * display mode is restored.
- */
- ShowWindow (g_hDlgDepthChange, SW_HIDE);
- return TRUE;
- }
- break;
-
- case WM_CLOSE:
- ErrorF ("winChangeDepthDlgProc - WM_CLOSE\n");
-
- DestroyWindow (g_hDlgAbout);
- g_hDlgAbout = NULL;
-
- /* Fix to make sure keyboard focus isn't trapped */
- PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
- return TRUE;
- }
-
- return FALSE;
-}
-
-
-/*
- * Display the About dialog box
- */
-
-void
-winDisplayAboutDialog (winPrivScreenPtr pScreenPriv)
-{
- /* Check if dialog already exists */
- if (g_hDlgAbout != NULL)
- {
- /* Dialog box already exists, display it */
- ShowWindow (g_hDlgAbout, SW_SHOWDEFAULT);
-
- /* User has lost the dialog. Show them where it is. */
- SetForegroundWindow (g_hDlgAbout);
-
- return;
- }
-
- /*
- * Display the about box
- */
- g_hDlgAbout = CreateDialogParam (g_hInstance,
- "ABOUT_BOX",
- pScreenPriv->hwndScreen,
- winAboutDlgProc,
- (int) pScreenPriv);
-
- /* Show the dialog box */
- ShowWindow (g_hDlgAbout, SW_SHOW);
-
- /* Needed to get keyboard controls (tab, arrows, enter, esc) to work */
- SetForegroundWindow (g_hDlgAbout);
-
- /* Set focus to the OK button */
- PostMessage (g_hDlgAbout, WM_NEXTDLGCTL,
- GetDlgItem (g_hDlgAbout, IDOK), TRUE);
-}
-
-
-/*
- * Process messages for the about dialog.
- */
-
-static wBOOL CALLBACK
-winAboutDlgProc (HWND hwndDialog, UINT message,
- WPARAM wParam, LPARAM lParam)
-{
- static winPrivScreenPtr s_pScreenPriv = NULL;
- static winScreenInfo *s_pScreenInfo = NULL;
- static ScreenPtr s_pScreen = NULL;
-
-#if CYGDEBUG
- winDebug ("winAboutDlgProc\n");
-#endif
-
- /* Branch on message type */
- switch (message)
- {
- case WM_INITDIALOG:
-#if CYGDEBUG
- winDebug ("winAboutDlgProc - WM_INITDIALOG\n");
-#endif
-
- /* Store pointers to private structures for future use */
- s_pScreenPriv = (winPrivScreenPtr) lParam;
- s_pScreenInfo = s_pScreenPriv->pScreenInfo;
- s_pScreen = s_pScreenInfo->pScreen;
-
- winInitDialog (hwndDialog);
-
- /* Override the URL buttons */
- winOverrideURLButton (hwndDialog, ID_ABOUT_CHANGELOG);
- winOverrideURLButton (hwndDialog, ID_ABOUT_WEBSITE);
- winOverrideURLButton (hwndDialog, ID_ABOUT_UG);
- winOverrideURLButton (hwndDialog, ID_ABOUT_FAQ);
-
- return TRUE;
-
- case WM_DRAWITEM:
- /* Draw the URL buttons as needed */
- winDrawURLWindow (lParam);
- return TRUE;
-
- case WM_MOUSEMOVE:
- case WM_NCMOUSEMOVE:
- /* Show the cursor if it is hidden */
- if (g_fSoftwareCursor && !g_fCursor)
- {
- g_fCursor = TRUE;
- ShowCursor (TRUE);
- }
- return TRUE;
-
- case WM_COMMAND:
- switch (LOWORD (wParam))
- {
- case IDOK:
- case IDCANCEL:
- ErrorF ("winAboutDlgProc - WM_COMMAND - IDOK or IDCANCEL\n");
-
- DestroyWindow (g_hDlgAbout);
- g_hDlgAbout = NULL;
-
- /* Fix to make sure keyboard focus isn't trapped */
- PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
-
- /* Restore window procedures for URL buttons */
- winUnoverrideURLButton (hwndDialog, ID_ABOUT_CHANGELOG);
- winUnoverrideURLButton (hwndDialog, ID_ABOUT_WEBSITE);
- winUnoverrideURLButton (hwndDialog, ID_ABOUT_UG);
- winUnoverrideURLButton (hwndDialog, ID_ABOUT_FAQ);
-
- return TRUE;
-
- case ID_ABOUT_CHANGELOG:
- {
- HINSTANCE iReturn;
-#ifdef __CYGWIN__
- const char * pszCygPath = "/usr/X11R6/share/doc/"
- "xorg-x11-xwin/changelog.html";
- char pszWinPath[MAX_PATH + 1];
-
- /* Convert the POSIX path to a Win32 path */
- cygwin_conv_to_win32_path (pszCygPath, pszWinPath);
-#else
- const char * pszWinPath = "http://x.cygwin.com/"
- "devel/server/changelog.html";
-#endif
-
- iReturn = ShellExecute (NULL,
- "open",
- pszWinPath,
- NULL,
- NULL,
- SW_MAXIMIZE);
- if (iReturn < 32)
- {
- ErrorF ("winAboutDlgProc - WM_COMMAND - ID_ABOUT_CHANGELOG - "
- "ShellExecute failed: %d\n",
- iReturn);
- }
- }
- return TRUE;
-
- case ID_ABOUT_WEBSITE:
- {
- const char * pszPath = "http://x.cygwin.com/";
- int iReturn;
-
- iReturn = ShellExecute (NULL,
- "open",
- pszPath,
- NULL,
- NULL,
- SW_MAXIMIZE);
- if (iReturn < 32)
- {
- ErrorF ("winAboutDlgProc - WM_COMMAND - ID_ABOUT_WEBSITE - "
- "ShellExecute failed: %d\n",
- iReturn);
- }
- }
- return TRUE;
-
- case ID_ABOUT_UG:
- {
- const char * pszPath = "http://x.cygwin.com/docs/ug/";
- int iReturn;
-
- iReturn = ShellExecute (NULL,
- "open",
- pszPath,
- NULL,
- NULL,
- SW_MAXIMIZE);
- if (iReturn < 32)
- {
- ErrorF ("winAboutDlgProc - WM_COMMAND - ID_ABOUT_UG - "
- "ShellExecute failed: %d\n",
- iReturn);
- }
- }
- return TRUE;
-
- case ID_ABOUT_FAQ:
- {
- const char * pszPath = "http://x.cygwin.com/docs/faq/";
- int iReturn;
-
- iReturn = ShellExecute (NULL,
- "open",
- pszPath,
- NULL,
- NULL,
- SW_MAXIMIZE);
- if (iReturn < 32)
- {
- ErrorF ("winAboutDlgProc - WM_COMMAND - ID_ABOUT_FAQ - "
- "ShellExecute failed: %d\n",
- iReturn);
- }
- }
- return TRUE;
- }
- break;
-
- case WM_CLOSE:
- ErrorF ("winAboutDlgProc - WM_CLOSE\n");
-
- DestroyWindow (g_hDlgAbout);
- g_hDlgAbout = NULL;
-
- /* Fix to make sure keyboard focus isn't trapped */
- PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
-
- /* Restore window procedures for URL buttons */
- winUnoverrideURLButton (hwndDialog, ID_ABOUT_CHANGELOG);
- winUnoverrideURLButton (hwndDialog, ID_ABOUT_WEBSITE);
- winUnoverrideURLButton (hwndDialog, ID_ABOUT_UG);
- winUnoverrideURLButton (hwndDialog, ID_ABOUT_FAQ);
-
- return TRUE;
- }
-
- return FALSE;
-}
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, 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 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 HAROLD L HUNT II 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 Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ * Earle F. Philhower III
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#ifdef __CYGWIN__
+#include <sys/cygwin.h>
+#endif
+#include <shellapi.h>
+#include "winprefs.h"
+
+
+/*
+ * References to external globals
+ */
+
+extern Bool g_fCursor;
+extern HWND g_hDlgDepthChange;
+extern HWND g_hDlgExit;
+extern HWND g_hDlgAbout;
+extern WINPREFS pref;
+#ifdef XWIN_CLIPBOARD
+extern Bool g_fClipboardStarted;
+#endif
+extern Bool g_fSoftwareCursor;
+
+#if defined(XWIN_MULTIWINDOW)
+extern HICON g_hIconX;
+extern HICON g_hSmallIconX;
+#endif
+
+/*
+ * Local function prototypes
+ */
+
+static wBOOL CALLBACK
+winExitDlgProc (HWND hDialog, UINT message,
+ WPARAM wParam, LPARAM lParam);
+
+static wBOOL CALLBACK
+winChangeDepthDlgProc (HWND hDialog, UINT message,
+ WPARAM wParam, LPARAM lParam);
+
+static wBOOL CALLBACK
+winAboutDlgProc (HWND hDialog, UINT message,
+ WPARAM wParam, LPARAM lParam);
+
+
+static void
+winDrawURLWindow (LPARAM lParam);
+
+static LRESULT CALLBACK
+winURLWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+
+static void
+winOverrideURLButton (HWND hdlg, int id);
+
+static void
+winUnoverrideURLButton (HWND hdlg, int id);
+
+
+/*
+ * Owner-draw a button as a URL
+ */
+
+static void
+winDrawURLWindow (LPARAM lParam)
+{
+ DRAWITEMSTRUCT *draw;
+ char str[256];
+ RECT rect;
+ HFONT font;
+ COLORREF crText;
+
+ draw = (DRAWITEMSTRUCT *) lParam;
+ GetWindowText (draw->hwndItem, str, sizeof(str));
+ str[255] = 0;
+ GetClientRect (draw->hwndItem, &rect);
+
+ /* Color the button depending upon its state */
+ if (draw->itemState & ODS_SELECTED)
+ crText = RGB(128+64,0,0);
+ else if (draw->itemState & ODS_FOCUS)
+ crText = RGB(0,128+64,0);
+ else
+ crText = RGB(0,0,128+64);
+ SetTextColor (draw->hDC, crText);
+
+ /* Create font 8 high, standard dialog font */
+ font = CreateFont (-8, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE,
+ 0, 0, 0, 0, 0, "MS Sans Serif");
+ if (!font)
+ {
+ ErrorF ("winDrawURLWindow: Unable to create URL font, bailing.\n");
+ return;
+ }
+ /* Draw it */
+ SetBkMode (draw->hDC, OPAQUE);
+ SelectObject (draw->hDC, font);
+ DrawText (draw->hDC, str, strlen (str),&rect,DT_CENTER | DT_VCENTER);
+ /* Delete the created font, replace it with stock font */
+ DeleteObject (SelectObject (draw->hDC, GetStockObject (ANSI_VAR_FONT)));
+}
+
+
+/*
+ * WndProc for overridden buttons
+ */
+
+static LRESULT CALLBACK
+winURLWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ WNDPROC origCB = NULL;
+ HCURSOR cursor;
+
+ /* If it's a SetCursor message, tell it to the hand */
+ if (msg==WM_SETCURSOR) {
+ cursor = LoadCursor (NULL, IDC_HAND);
+ if (cursor)
+ SetCursor (cursor);
+ return TRUE;
+ }
+ origCB = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ /* Otherwise fall through to original WndProc */
+ if (origCB)
+ return CallWindowProc (origCB, hwnd, msg, wParam, lParam);
+ else
+ return FALSE;
+}
+
+
+/*
+ * Register and unregister the custom WndProc
+ */
+
+static void
+winOverrideURLButton (HWND hwnd, int id)
+{
+ WNDPROC origCB;
+ origCB = (WNDPROC)SetWindowLongPtr(GetDlgItem (hwnd, id),
+ GWLP_WNDPROC, (LONG_PTR)winURLWndProc);
+ SetWindowLongPtr(GetDlgItem (hwnd, id), GWLP_USERDATA, (LONG_PTR)origCB);
+}
+
+static void
+winUnoverrideURLButton (HWND hwnd, int id)
+{
+ WNDPROC origCB;
+ origCB = (WNDPROC)SetWindowLongPtr(GetDlgItem (hwnd, id),
+ GWLP_USERDATA, 0);
+ if (origCB)
+ SetWindowLongPtr(GetDlgItem (hwnd, id), GWLP_WNDPROC, (LONG_PTR)origCB);
+}
+
+
+/*
+ * Center a dialog window in the desktop window
+ * and set small and large icons to X icons.
+ */
+
+static void
+winInitDialog (HWND hwndDlg)
+{
+ HWND hwndDesk;
+ RECT rc, rcDlg, rcDesk;
+ HICON hIcon, hIconSmall;
+
+ hwndDesk = GetParent (hwndDlg);
+ if (!hwndDesk || IsIconic (hwndDesk))
+ hwndDesk = GetDesktopWindow ();
+
+ /* Remove minimize and maximize buttons */
+ SetWindowLongPtr(hwndDlg, GWL_STYLE,
+ GetWindowLongPtr(hwndDlg, GWL_STYLE)
+ & ~(WS_MAXIMIZEBOX | WS_MINIMIZEBOX));
+
+ /* Set Window not to show in the task bar */
+ SetWindowLongPtr(hwndDlg, GWL_EXSTYLE,
+ GetWindowLongPtr(hwndDlg, GWL_EXSTYLE) & ~WS_EX_APPWINDOW );
+
+ /* Center dialog window in the screen. Not done for multi-monitor systems, where
+ * it is likely to end up split across the screens. In that case, it appears
+ * near the Tray icon.
+ */
+ if (GetSystemMetrics(SM_CMONITORS)>1) {
+ /* Still need to refresh the frame change. */
+ SetWindowPos (hwndDlg, HWND_TOP, 0,0,0,0,
+ SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
+ } else {
+ GetWindowRect (hwndDesk, &rcDesk);
+ GetWindowRect (hwndDlg, &rcDlg);
+ CopyRect (&rc, &rcDesk);
+
+ OffsetRect (&rcDlg, -rcDlg.left, -rcDlg.top);
+ OffsetRect (&rc, -rc.left, -rc.top);
+ OffsetRect (&rc, -rcDlg.right, -rcDlg.bottom);
+
+ SetWindowPos (hwndDlg,
+ HWND_TOPMOST,
+ rcDesk.left + (rc.right / 2),
+ rcDesk.top + (rc.bottom / 2),
+ 0, 0,
+ SWP_NOSIZE | SWP_FRAMECHANGED);
+ }
+
+#ifdef XWIN_MULTIWINDOW
+ if (g_hIconX) hIcon=g_hIconX;
+ else
+#endif
+ hIcon = LoadIcon (g_hInstance, MAKEINTRESOURCE(IDI_XWIN));
+
+#ifdef XWIN_MULTIWINDOW
+ if (g_hSmallIconX) hIconSmall=g_hSmallIconX;
+ else
+#endif
+ hIconSmall = LoadImage (g_hInstance,
+ MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON,
+ GetSystemMetrics(SM_CXSMICON),
+ GetSystemMetrics(SM_CYSMICON),
+ LR_SHARED);
+
+ PostMessage (hwndDlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon);
+ PostMessage (hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall);
+}
+
+
+int
+GetLiveClients (winPrivScreenPtr pScreenPriv)
+{
+ int i;
+ int liveClients = 0;
+
+ /* Count up running clients (clients[0] is serverClient) */
+ for (i = 1; i < currentMaxClients; i++)
+ if (clients[i] != NullClient)
+ liveClients++;
+#if defined(XWIN_MULTIWINDOW)
+ /* Count down server internal clients */
+ if (pScreenPriv->pScreenInfo->fMultiWindow)
+ liveClients -= 2; /* multiwindow window manager & XMsgProc */
+#endif
+#if defined(XWIN_CLIPBOARD)
+ if (g_fClipboardStarted)
+ liveClients--; /* clipboard manager */
+#endif
+
+ /* A user reported that this sometimes drops below zero. just eye-candy. */
+ if (liveClients < 0)
+ liveClients = 0;
+
+ pScreenPriv->iConnectedClients = liveClients;
+
+ return liveClients;
+}
+
+/*
+ * Display the Exit dialog box
+ */
+
+void
+winDisplayExitDialog (winPrivScreenPtr pScreenPriv)
+{
+ int liveClients = GetLiveClients(pScreenPriv);
+
+ /* Don't show the exit confirmation dialog if SilentExit & no clients,
+ or ForceExit, is enabled */
+ if ((pref.fSilentExit && liveClients <= 0) || pref.fForceExit)
+ {
+ if (g_hDlgExit != NULL)
+ {
+ DestroyWindow (g_hDlgExit);
+ g_hDlgExit = NULL;
+ }
+ PostMessage (pScreenPriv->hwndScreen, WM_GIVEUP, 0, 0);
+ return;
+ }
+
+ /* Check if dialog already exists */
+ if (g_hDlgExit != NULL)
+ {
+ /* Dialog box already exists, display it */
+ ShowWindow (g_hDlgExit, SW_SHOWDEFAULT);
+
+ /* User has lost the dialog. Show them where it is. */
+ SetForegroundWindow (g_hDlgExit);
+
+ return;
+ }
+
+ /* Create dialog box */
+ g_hDlgExit = CreateDialogParam (g_hInstance,
+ "EXIT_DIALOG",
+ pScreenPriv->hwndScreen,
+ winExitDlgProc,
+ (int) pScreenPriv);
+
+ /* Show the dialog box */
+ ShowWindow (g_hDlgExit, SW_SHOW);
+
+ /* Needed to get keyboard controls (tab, arrows, enter, esc) to work */
+ SetForegroundWindow (g_hDlgExit);
+
+ /* Set focus to the Cancel button */
+ PostMessage (g_hDlgExit, WM_NEXTDLGCTL,
+ (WPARAM)GetDlgItem (g_hDlgExit, IDCANCEL), TRUE);
+}
+
+#define CONNECTED_CLIENTS_FORMAT "There %s currently %d client%s connected."
+
+
+/*
+ * Exit dialog window procedure
+ */
+
+static wBOOL CALLBACK
+winExitDlgProc (HWND hDialog, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ static winPrivScreenPtr s_pScreenPriv = NULL;
+
+ /* Branch on message type */
+ switch (message)
+ {
+ case WM_INITDIALOG:
+ {
+ char *pszConnectedClients;
+
+ /* Store pointers to private structures for future use */
+ s_pScreenPriv = (winPrivScreenPtr) lParam;
+
+ winInitDialog (hDialog);
+
+ /* Format the connected clients string */
+ pszConnectedClients = Xprintf (CONNECTED_CLIENTS_FORMAT,
+ (s_pScreenPriv->iConnectedClients == 1) ? "is" : "are",
+ s_pScreenPriv->iConnectedClients,
+ (s_pScreenPriv->iConnectedClients == 1) ? "" : "s");
+ if (!pszConnectedClients)
+ return TRUE;
+
+
+
+ /* Set the number of connected clients */
+ SetWindowText (GetDlgItem (hDialog, IDC_CLIENTS_CONNECTED),
+ pszConnectedClients);
+ xfree (pszConnectedClients);
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD (wParam))
+ {
+ case IDOK:
+ /* Send message to call the GiveUp function */
+ PostMessage (s_pScreenPriv->hwndScreen, WM_GIVEUP, 0, 0);
+ DestroyWindow (g_hDlgExit);
+ g_hDlgExit = NULL;
+
+ /* Fix to make sure keyboard focus isn't trapped */
+ PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
+ return TRUE;
+
+ case IDCANCEL:
+ DestroyWindow (g_hDlgExit);
+ g_hDlgExit = NULL;
+
+ /* Fix to make sure keyboard focus isn't trapped */
+ PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
+ return TRUE;
+ }
+ break;
+
+ case WM_MOUSEMOVE:
+ case WM_NCMOUSEMOVE:
+ /* Show the cursor if it is hidden */
+ if (g_fSoftwareCursor && !g_fCursor)
+ {
+ g_fCursor = TRUE;
+ ShowCursor (TRUE);
+ }
+ return TRUE;
+
+ case WM_CLOSE:
+ DestroyWindow (g_hDlgExit);
+ g_hDlgExit = NULL;
+
+ /* Fix to make sure keyboard focus isn't trapped */
+ PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+/*
+ * Display the Depth Change dialog box
+ */
+
+void
+winDisplayDepthChangeDialog (winPrivScreenPtr pScreenPriv)
+{
+ /* Check if dialog already exists */
+ if (g_hDlgDepthChange != NULL)
+ {
+ /* Dialog box already exists, display it */
+ ShowWindow (g_hDlgDepthChange, SW_SHOWDEFAULT);
+
+ /* User has lost the dialog. Show them where it is. */
+ SetForegroundWindow (g_hDlgDepthChange);
+
+ return;
+ }
+
+ /*
+ * Display a notification to the user that the visual
+ * will not be displayed until the Windows display depth
+ * is restored to the original value.
+ */
+ g_hDlgDepthChange = CreateDialogParam (g_hInstance,
+ "DEPTH_CHANGE_BOX",
+ pScreenPriv->hwndScreen,
+ winChangeDepthDlgProc,
+ (int) pScreenPriv);
+ /* Show the dialog box */
+ ShowWindow (g_hDlgDepthChange, SW_SHOW);
+
+ winDebug ("winDisplayDepthChangeDialog - DialogBox returned: %d\n",
+ (int) g_hDlgDepthChange);
+ winDebug ("winDisplayDepthChangeDialog - GetLastError: %d\n",
+ (int) GetLastError ());
+
+ /* Minimize the display window */
+ ShowWindow (pScreenPriv->hwndScreen, SW_MINIMIZE);
+}
+
+
+/*
+ * Process messages for the dialog that is displayed for
+ * disruptive screen depth changes.
+ */
+
+static wBOOL CALLBACK
+winChangeDepthDlgProc (HWND hwndDialog, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ static winPrivScreenPtr s_pScreenPriv = NULL;
+ static winScreenInfo *s_pScreenInfo = NULL;
+ static ScreenPtr s_pScreen = NULL;
+
+ winDebug ("winChangeDepthDlgProc\n");
+
+ /* Branch on message type */
+ switch (message)
+ {
+ case WM_INITDIALOG:
+ winDebug ("winChangeDepthDlgProc - WM_INITDIALOG\n");
+
+ /* Store pointers to private structures for future use */
+ s_pScreenPriv = (winPrivScreenPtr) lParam;
+ s_pScreenInfo = s_pScreenPriv->pScreenInfo;
+ s_pScreen = s_pScreenInfo->pScreen;
+
+ winDebug ("winChangeDepthDlgProc - WM_INITDIALOG - s_pScreenPriv: %08x, "
+ "s_pScreenInfo: %08x, s_pScreen: %08x\n",
+ s_pScreenPriv, s_pScreenInfo, s_pScreen);
+
+ winDebug ("winChangeDepthDlgProc - WM_INITDIALOG - orig bpp: %d, "
+ "last bpp: %d\n",
+ s_pScreenInfo->dwBPP,
+ s_pScreenPriv->dwLastWindowsBitsPixel);
+
+ winInitDialog( hwndDialog );
+
+ return TRUE;
+
+ case WM_DISPLAYCHANGE:
+ winDebug ("winChangeDepthDlgProc - WM_DISPLAYCHANGE - orig bpp: %d, "
+ "last bpp: %d, new bpp: %d\n",
+ s_pScreenInfo->dwBPP,
+ s_pScreenPriv->dwLastWindowsBitsPixel,
+ wParam);
+
+ /* Dismiss the dialog if the display returns to the original depth */
+ if (wParam == s_pScreenInfo->dwBPP)
+ {
+ winDebug ("winChangeDelthDlgProc - wParam == s_pScreenInfo->dwBPP\n");
+
+ /* Depth has been restored, dismiss dialog */
+ DestroyWindow (g_hDlgDepthChange);
+ g_hDlgDepthChange = NULL;
+
+ /* Flag that we have a valid screen depth */
+ s_pScreenPriv->fBadDepth = FALSE;
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD (wParam))
+ {
+ case IDOK:
+ case IDCANCEL:
+ ErrorF ("winChangeDepthDlgProc - WM_COMMAND - IDOK or IDCANCEL\n");
+
+ /*
+ * User dismissed the dialog, hide it until the
+ * display mode is restored.
+ */
+ ShowWindow (g_hDlgDepthChange, SW_HIDE);
+ return TRUE;
+ }
+ break;
+
+ case WM_CLOSE:
+ winDebug ("winChangeDepthDlgProc - WM_CLOSE\n");
+
+ DestroyWindow (g_hDlgAbout);
+ g_hDlgAbout = NULL;
+
+ /* Fix to make sure keyboard focus isn't trapped */
+ PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+/*
+ * Display the About dialog box
+ */
+
+void
+winDisplayAboutDialog (winPrivScreenPtr pScreenPriv)
+{
+ /* Check if dialog already exists */
+ if (g_hDlgAbout != NULL)
+ {
+ /* Dialog box already exists, display it */
+ ShowWindow (g_hDlgAbout, SW_SHOWDEFAULT);
+
+ /* User has lost the dialog. Show them where it is. */
+ SetForegroundWindow (g_hDlgAbout);
+
+ return;
+ }
+
+ /*
+ * Display the about box
+ */
+ g_hDlgAbout = CreateDialogParam (g_hInstance,
+ "ABOUT_BOX",
+ pScreenPriv->hwndScreen,
+ winAboutDlgProc,
+ (int) pScreenPriv);
+
+ /* Show the dialog box */
+ ShowWindow (g_hDlgAbout, SW_SHOW);
+
+ /* Needed to get keyboard controls (tab, arrows, enter, esc) to work */
+ SetForegroundWindow (g_hDlgAbout);
+
+ /* Set focus to the OK button */
+ PostMessage (g_hDlgAbout, WM_NEXTDLGCTL,
+ (WPARAM)GetDlgItem (g_hDlgAbout, IDOK), TRUE);
+}
+
+
+/*
+ * Process messages for the about dialog.
+ */
+
+static wBOOL CALLBACK
+winAboutDlgProc (HWND hwndDialog, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ static winPrivScreenPtr s_pScreenPriv = NULL;
+ static winScreenInfo *s_pScreenInfo = NULL;
+ static ScreenPtr s_pScreen = NULL;
+
+ winDebug ("winAboutDlgProc\n");
+
+ /* Branch on message type */
+ switch (message)
+ {
+ case WM_INITDIALOG:
+ winDebug ("winAboutDlgProc - WM_INITDIALOG\n");
+
+ /* Store pointers to private structures for future use */
+ s_pScreenPriv = (winPrivScreenPtr) lParam;
+ s_pScreenInfo = s_pScreenPriv->pScreenInfo;
+ s_pScreen = s_pScreenInfo->pScreen;
+
+ winInitDialog (hwndDialog);
+
+ /* Override the URL buttons */
+ winOverrideURLButton (hwndDialog, ID_ABOUT_CHANGELOG);
+ winOverrideURLButton (hwndDialog, ID_ABOUT_WEBSITE);
+ winOverrideURLButton (hwndDialog, ID_ABOUT_UG);
+ winOverrideURLButton (hwndDialog, ID_ABOUT_FAQ);
+
+ return TRUE;
+
+ case WM_DRAWITEM:
+ /* Draw the URL buttons as needed */
+ winDrawURLWindow (lParam);
+ return TRUE;
+
+ case WM_MOUSEMOVE:
+ case WM_NCMOUSEMOVE:
+ /* Show the cursor if it is hidden */
+ if (g_fSoftwareCursor && !g_fCursor)
+ {
+ g_fCursor = TRUE;
+ ShowCursor (TRUE);
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD (wParam))
+ {
+ case IDOK:
+ case IDCANCEL:
+ winDebug ("winAboutDlgProc - WM_COMMAND - IDOK or IDCANCEL\n");
+
+ DestroyWindow (g_hDlgAbout);
+ g_hDlgAbout = NULL;
+
+ /* Fix to make sure keyboard focus isn't trapped */
+ PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
+
+ /* Restore window procedures for URL buttons */
+ winUnoverrideURLButton (hwndDialog, ID_ABOUT_CHANGELOG);
+ winUnoverrideURLButton (hwndDialog, ID_ABOUT_WEBSITE);
+ winUnoverrideURLButton (hwndDialog, ID_ABOUT_UG);
+ winUnoverrideURLButton (hwndDialog, ID_ABOUT_FAQ);
+
+ return TRUE;
+
+ case ID_ABOUT_CHANGELOG:
+ {
+ int iReturn;
+#ifdef __CYGWIN__
+ const char * pszCygPath = "/usr/X11R6/share/doc/"
+ "xorg-x11-xwin/changelog.html";
+ char pszWinPath[MAX_PATH + 1];
+
+ /* Convert the POSIX path to a Win32 path */
+ cygwin_conv_to_win32_path (pszCygPath, pszWinPath);
+#else
+ const char * pszWinPath = "http://x.cygwin.com/"
+ "devel/server/changelog.html";
+#endif
+
+ iReturn = (int)ShellExecute (NULL,
+ "open",
+ pszWinPath,
+ NULL,
+ NULL,
+ SW_MAXIMIZE);
+ if (iReturn < 32)
+ {
+ ErrorF ("winAboutDlgProc - WM_COMMAND - ID_ABOUT_CHANGELOG - "
+ "ShellExecute failed: %d\n",
+ iReturn);
+ }
+ }
+ return TRUE;
+
+ case ID_ABOUT_WEBSITE:
+ {
+ const char * pszPath = __VENDORDWEBSUPPORT__;
+ int iReturn;
+
+ iReturn = (int)ShellExecute (NULL,
+ "open",
+ pszPath,
+ NULL,
+ NULL,
+ SW_MAXIMIZE);
+ if (iReturn < 32)
+ {
+ ErrorF ("winAboutDlgProc - WM_COMMAND - ID_ABOUT_WEBSITE - "
+ "ShellExecute failed: %d\n",
+ iReturn);
+ }
+ }
+ return TRUE;
+
+ case ID_ABOUT_UG:
+ {
+ const char * pszPath = "http://x.cygwin.com/docs/ug/";
+ int iReturn;
+
+ iReturn = (int)ShellExecute (NULL,
+ "open",
+ pszPath,
+ NULL,
+ NULL,
+ SW_MAXIMIZE);
+ if (iReturn < 32)
+ {
+ ErrorF ("winAboutDlgProc - WM_COMMAND - ID_ABOUT_UG - "
+ "ShellExecute failed: %d\n",
+ iReturn);
+ }
+ }
+ return TRUE;
+
+ case ID_ABOUT_FAQ:
+ {
+ const char * pszPath = "http://x.cygwin.com/docs/faq/";
+ int iReturn;
+
+ iReturn = (int)ShellExecute (NULL,
+ "open",
+ pszPath,
+ NULL,
+ NULL,
+ SW_MAXIMIZE);
+ if (iReturn < 32)
+ {
+ ErrorF ("winAboutDlgProc - WM_COMMAND - ID_ABOUT_FAQ - "
+ "ShellExecute failed: %d\n",
+ iReturn);
+ }
+ }
+ return TRUE;
+ }
+ break;
+
+ case WM_CLOSE:
+ ErrorF ("winAboutDlgProc - WM_CLOSE\n");
+
+ DestroyWindow (g_hDlgAbout);
+ g_hDlgAbout = NULL;
+
+ /* Fix to make sure keyboard focus isn't trapped */
+ PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
+
+ /* Restore window procedures for URL buttons */
+ winUnoverrideURLButton (hwndDialog, ID_ABOUT_CHANGELOG);
+ winUnoverrideURLButton (hwndDialog, ID_ABOUT_WEBSITE);
+ winUnoverrideURLButton (hwndDialog, ID_ABOUT_UG);
+ winUnoverrideURLButton (hwndDialog, ID_ABOUT_FAQ);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
diff --git a/xorg-server/hw/xwin/winengine.c b/xorg-server/hw/xwin/winengine.c
index fb9aed8a0..fadd11b39 100644
--- a/xorg-server/hw/xwin/winengine.c
+++ b/xorg-server/hw/xwin/winengine.c
@@ -69,12 +69,12 @@ winDetectSupportedEngines (void)
{
case VER_PLATFORM_WIN32_NT:
/* Engine 4 is supported on NT only */
- winErrorFVerb (2, "winDetectSupportedEngines - Windows NT/2000/XP\n");
+ winDebug ("winDetectSupportedEngines - Windows NT/2000/XP\n");
break;
case VER_PLATFORM_WIN32_WINDOWS:
/* Engine 4 is supported on NT only */
- winErrorFVerb (2, "winDetectSupportedEngines - Windows 95/98/Me\n");
+ winDebug ("winDetectSupportedEngines - Windows 95/98/Me\n");
break;
}
@@ -100,13 +100,13 @@ winDetectSupportedEngines (void)
if (FAILED (ddrval))
{
/* No DirectDraw support */
- winErrorFVerb (2, "winDetectSupportedEngines - DirectDraw not installed\n");
+ winDebug ("winDetectSupportedEngines - DirectDraw not installed\n");
return;
}
else
{
/* We have DirectDraw */
- winErrorFVerb (2, "winDetectSupportedEngines - DirectDraw installed\n");
+ winDebug ("winDetectSupportedEngines - DirectDraw installed\n");
g_dwEnginesSupported |= WIN_SERVER_SHADOW_DD;
#ifdef XWIN_PRIMARYFB
@@ -114,7 +114,7 @@ winDetectSupportedEngines (void)
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
{
g_dwEnginesSupported |= WIN_SERVER_PRIMARY_DD;
- winErrorFVerb (2, "winDetectSupportedEngines - Allowing PrimaryDD\n");
+ winDebug ("winDetectSupportedEngines - Allowing PrimaryDD\n");
}
#endif
}
@@ -126,7 +126,7 @@ winDetectSupportedEngines (void)
if (SUCCEEDED (ddrval))
{
/* We have DirectDraw4 */
- winErrorFVerb (2, "winDetectSupportedEngines - DirectDraw4 installed\n");
+ winDebug ("winDetectSupportedEngines - DirectDraw4 installed\n");
g_dwEnginesSupported |= WIN_SERVER_SHADOW_DDNL;
}
@@ -137,7 +137,7 @@ winDetectSupportedEngines (void)
IDirectDraw_Release (lpdd);
}
- winErrorFVerb (2, "winDetectSupportedEngines - Returning, supported engines %08x\n",
+ winDebug ("winDetectSupportedEngines - Returning, supported engines %08x\n",
(unsigned int) g_dwEnginesSupported);
}
@@ -178,7 +178,7 @@ winSetEngine (ScreenPtr pScreen)
/* ShadowGDI is the only engine that supports windowed PseudoColor */
if (dwBPP == 8 && !pScreenInfo->fFullScreen)
{
- winErrorFVerb (2, "winSetEngine - Windowed && PseudoColor => ShadowGDI\n");
+ winDebug ("winSetEngine - Windowed && PseudoColor => ShadowGDI\n");
pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
/* Set engine function pointers */
@@ -200,7 +200,7 @@ winSetEngine (ScreenPtr pScreen)
#endif
)
{
- winErrorFVerb (2, "winSetEngine - Multi Window or Rootless => ShadowGDI\n");
+ winDebug ("winSetEngine - Multi Window or Rootless => ShadowGDI\n");
pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
/* Set engine function pointers */
@@ -211,7 +211,7 @@ winSetEngine (ScreenPtr pScreen)
/* If the user's choice is supported, we'll use that */
if (g_dwEnginesSupported & pScreenInfo->dwEnginePreferred)
{
- winErrorFVerb (2, "winSetEngine - Using user's preference: %d\n",
+ winDebug ("winSetEngine - Using user's preference: %d\n",
(int) pScreenInfo->dwEnginePreferred);
pScreenInfo->dwEngine = pScreenInfo->dwEnginePreferred;
@@ -246,7 +246,7 @@ winSetEngine (ScreenPtr pScreen)
/* ShadowDDNL has good performance, so why not */
if (g_dwEnginesSupported & WIN_SERVER_SHADOW_DDNL)
{
- winErrorFVerb (2, "winSetEngine - Using Shadow DirectDraw NonLocking\n");
+ winDebug ("winSetEngine - Using Shadow DirectDraw NonLocking\n");
pScreenInfo->dwEngine = WIN_SERVER_SHADOW_DDNL;
/* Set engine function pointers */
@@ -257,7 +257,7 @@ winSetEngine (ScreenPtr pScreen)
/* ShadowDD is next in line */
if (g_dwEnginesSupported & WIN_SERVER_SHADOW_DD)
{
- winErrorFVerb (2, "winSetEngine - Using Shadow DirectDraw\n");
+ winDebug ("winSetEngine - Using Shadow DirectDraw\n");
pScreenInfo->dwEngine = WIN_SERVER_SHADOW_DD;
/* Set engine function pointers */
@@ -268,7 +268,7 @@ winSetEngine (ScreenPtr pScreen)
/* ShadowGDI is next in line */
if (g_dwEnginesSupported & WIN_SERVER_SHADOW_GDI)
{
- winErrorFVerb (2, "winSetEngine - Using Shadow GDI DIB\n");
+ winDebug ("winSetEngine - Using Shadow GDI DIB\n");
pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
/* Set engine function pointers */
diff --git a/xorg-server/hw/xwin/winerror.c b/xorg-server/hw/xwin/winerror.c
index 72ee2cfb7..78ac15117 100644
--- a/xorg-server/hw/xwin/winerror.c
+++ b/xorg-server/hw/xwin/winerror.c
@@ -43,7 +43,8 @@
extern char * g_pszCommandLine;
extern char * g_pszLogFile;
extern Bool g_fSilentFatalError;
-
+extern Bool g_fSilentDupError;
+extern Bool g_fLogInited;
#ifdef DDXOSVERRORF
/* Prototype */
@@ -62,6 +63,24 @@ OsVendorVErrorF (const char *pszFormat, va_list va_args)
pthread_mutex_lock (&s_pmPrinting);
#endif
+ /*
+ If we want to silence it,
+ detect if we are going to abort due to duplication error
+ */
+ if (g_fSilentDupError)
+ {
+ if ((strcmp(pszFormat,
+ "InitOutput - Duplicate invocation on display "
+ "number: %s. Exiting.\n") == 0)
+ || (strcmp(pszFormat,
+ "Server is already active for display %s\n%s %s\n%s\n") == 0)
+ || (strcmp(pszFormat,
+ "MakeAllCOTSServerListeners: server already running\n") == 0))
+ {
+ g_fSilentFatalError = TRUE;
+ }
+ }
+
/* Print the error message to a log file, could be stderr */
LogVWrite (0, pszFormat, va_args);
@@ -87,6 +106,12 @@ OsVendorFatalError (void)
if (g_fSilentFatalError)
return;
+ if (!g_fLogInited) {
+ g_fLogInited = TRUE;
+ g_pszLogFile = LogInit (g_pszLogFile, NULL);
+ }
+ LogClose ();
+
winMessageBoxF (
"A fatal error has occurred and " PROJECT_NAME " will now exit.\n" \
"Please open %s for more information.\n",
diff --git a/xorg-server/hw/xwin/winfont.c b/xorg-server/hw/xwin/winfont.c
index af3e90da5..5a3011c0a 100644
--- a/xorg-server/hw/xwin/winfont.c
+++ b/xorg-server/hw/xwin/winfont.c
@@ -42,9 +42,7 @@ winRealizeFontNativeGDI (ScreenPtr pScreen, FontPtr pFont)
BOOL fResult = TRUE;
winScreenPriv(pScreen);
-#if CYGDEBUG
- winTrace ("winRealizeFont (%p, %p)\n", pScreen, pFont);
-#endif
+ winDebug ("winRealizeFont (%p, %p)\n", pScreen, pFont);
WIN_UNWRAP(RealizeFont);
if (pScreen->RealizeFont)
@@ -62,9 +60,7 @@ winUnrealizeFontNativeGDI (ScreenPtr pScreen, FontPtr pFont)
BOOL fResult = TRUE;
winScreenPriv(pScreen);
-#if CYGDEBUG
- winTrace ("winUnrealizeFont (%p, %p)\n", pScreen, pFont);
-#endif
+ winDebug ("winUnrealizeFont (%p, %p)\n", pScreen, pFont);
WIN_UNWRAP(UnrealizeFont);
if (pScreen->UnrealizeFont)
@@ -72,9 +68,5 @@ winUnrealizeFontNativeGDI (ScreenPtr pScreen, FontPtr pFont)
WIN_WRAP(UnrealizeFont, winUnrealizeFontNativeGDI);
return fResult;
-#if CYGDEBUG
- winDebug ("winUnrealizeFont()\n");
-#endif
- return TRUE;
}
#endif
diff --git a/xorg-server/hw/xwin/wingc.c b/xorg-server/hw/xwin/wingc.c
index 1f3775263..61ba78a54 100644
--- a/xorg-server/hw/xwin/wingc.c
+++ b/xorg-server/hw/xwin/wingc.c
@@ -41,47 +41,14 @@ winPushPixels (GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDrawable, int dx, int
* Local prototypes
*/
-#if 0
-static void
-winChangeGCNativeGDI (GCPtr pGC, unsigned long ulChanges);
-#endif
-
static void
winValidateGCNativeGDI (GCPtr pGC,
unsigned long changes,
DrawablePtr pDrawable);
-#if 0
-static void
-winCopyGCNativeGDI (GCPtr pGCsrc, unsigned long ulMask, GCPtr pGCdst);
-#endif
-
static void
winDestroyGCNativeGDI (GCPtr pGC);
-#if 0
-static void
-winChangeClipNativeGDI (GCPtr pGC, int nType, pointer pValue, int nRects);
-
-static void
-winDestroyClipNativeGDI (GCPtr pGC);
-
-static void
-winCopyClipNativeGDI (GCPtr pGCdst, GCPtr pGCsrc);
-#endif
-
-#if 0
-/* GC Handling Routines */
-const GCFuncs winGCFuncs = {
- winValidateGCNativeGDI,
- winChangeGCNativeGDI,
- winCopyGCNativeGDI,
- winDestroyGCNativeGDI,
- winChangeClipNativeGDI,
- winDestroyClipNativeGDI,
- winCopyClipNativeGDI,
-};
-#else
const GCFuncs winGCFuncs = {
winValidateGCNativeGDI,
miChangeGC,
@@ -91,7 +58,6 @@ const GCFuncs winGCFuncs = {
miDestroyClip,
miCopyClip,
};
-#endif
/* Drawing Primitives */
const GCOps winGCOps = {
@@ -112,13 +78,8 @@ const GCOps winGCOps = {
miPolyText16,
miImageText8,
miImageText16,
-#if 0
- winImageGlyphBltNativeGDI,
- winPolyGlyphBltNativeGDI,
-#else
miImageGlyphBlt,
miPolyGlyphBlt,
-#endif
miPushPixels,
};
@@ -132,10 +93,8 @@ winCreateGCNativeGDI (GCPtr pGC)
winPrivGCPtr pGCPriv = NULL;
winPrivScreenPtr pScreenPriv = NULL;
-#if 0
- ErrorF ("winCreateGCNativeGDI - depth: %d\n",
+ winDebug ("winCreateGCNativeGDI - depth: %d\n",
pGC->depth);
-#endif
pGC->clientClip = NULL;
pGC->clientClipType = CT_NONE;
@@ -166,19 +125,6 @@ winCreateGCNativeGDI (GCPtr pGC)
return TRUE;
}
-
-#if 0
-/* See Porting Layer Definition - p. 45 */
-static void
-winChangeGCNativeGDI (GCPtr pGC, unsigned long ulChanges)
-{
-#if 0
- ErrorF ("winChangeGCNativeGDI () - Doing nothing\n");
-#endif
-}
-#endif
-
-
static void
winValidateGCNativeGDI (GCPtr pGC,
unsigned long ulChanges,
@@ -192,16 +138,6 @@ winValidateGCNativeGDI (GCPtr pGC,
}
-#if 0
-/* See Porting Layer Definition - p. 46 */
-static void
-winCopyGCNativeGDI (GCPtr pGCsrc, unsigned long ulMask, GCPtr pGCdst)
-{
-
-}
-#endif
-
-
/* See Porting Layer Definition - p. 46 */
static void
winDestroyGCNativeGDI (GCPtr pGC)
@@ -229,28 +165,3 @@ winDestroyGCNativeGDI (GCPtr pGC)
/* Invalidate the GC privates pointer */
winSetGCPriv (pGC, NULL);
}
-
-#if 0
-/* See Porting Layer Definition - p. 46 */
-static void
-winChangeClipNativeGDI (GCPtr pGC, int nType, pointer pValue, int nRects)
-{
-
-}
-
-
-/* See Porting Layer Definition - p. 47 */
-static void
-winDestroyClipNativeGDI (GCPtr pGC)
-{
-
-}
-
-
-/* See Porting Layer Definition - p. 47 */
-static void
-winCopyClipNativeGDI (GCPtr pGCdst, GCPtr pGCsrc)
-{
-
-}
-#endif
diff --git a/xorg-server/hw/xwin/wingetsp.c b/xorg-server/hw/xwin/wingetsp.c
index 03f7f1012..e9c23881f 100644
--- a/xorg-server/hw/xwin/wingetsp.c
+++ b/xorg-server/hw/xwin/wingetsp.c
@@ -59,10 +59,8 @@ winGetSpansNativeGDI (DrawablePtr pDrawable,
switch (pDrawable->type)
{
case DRAWABLE_PIXMAP:
-#if 0
- ErrorF ("winGetSpans - DRAWABLE_PIXMAP %08x\n",
+ winDebug ("winGetSpans - DRAWABLE_PIXMAP %08x\n",
pDrawable);
-#endif
pPixmap = (PixmapPtr) pDrawable;
pPixmapPriv = winGetPixmapPriv (pPixmap);
@@ -107,12 +105,6 @@ winGetSpansNativeGDI (DrawablePtr pDrawable,
SelectObject (hdcMem, hbmpOrig);
DeleteObject (hbmpWindow);
-#if 0
- ErrorF ("(%dx%dx%d) (%d,%d) w: %d\n",
- pDrawable->width, pDrawable->height, pDrawable->depth,
- pPoint->x, pPoint->y, *piWidth);
-#endif
-
/* Calculate offset of next bit destination */
pDst += PixmapBytePad (*piWidth, pDrawable->depth);
}
@@ -126,9 +118,6 @@ winGetSpansNativeGDI (DrawablePtr pDrawable,
break;
case DRAWABLE_WINDOW:
-#if 0
- ErrorF ("winGetSpans - DRAWABLE_WINDOW\n");
-#endif
/* Open a memory HDC */
hdcMem = CreateCompatibleDC (NULL);
@@ -163,12 +152,6 @@ winGetSpansNativeGDI (DrawablePtr pDrawable,
DeleteObject (hbmpWindow);
-#if 0
- ErrorF ("(%dx%dx%d) (%d,%d) w: %d\n",
- pDrawable->width, pDrawable->height, pDrawable->depth,
- pPoint->x, pPoint->y, *piWidth);
-#endif
-
/* Calculate offset of next bit destination */
pDst += PixmapBytePad (*piWidth, pDrawable->depth);
}
diff --git a/xorg-server/hw/xwin/winglobals.c b/xorg-server/hw/xwin/winglobals.c
index 7bb4a602d..71a0e6a7e 100644
--- a/xorg-server/hw/xwin/winglobals.c
+++ b/xorg-server/hw/xwin/winglobals.c
@@ -1,146 +1,146 @@
-/*
- *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
- *Copyright (C) Colin Harrison 2005-2008
- *
- *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, 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 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 HAROLD L HUNT II 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 Harold L Hunt II
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from Harold L Hunt II.
- *
- * Authors: Harold L Hunt II
- * Colin Harrison
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-
-/*
- * General global variables
- */
-
-int g_iNumScreens = 0;
-winScreenInfo g_ScreenInfo[MAXSCREENS];
-int g_iLastScreen = -1;
-#ifdef HAS_DEVWINDOWS
-int g_fdMessageQueue = WIN_FD_INVALID;
-#endif
-static int g_iScreenPrivateKeyIndex;
-DevPrivateKey g_iScreenPrivateKey = &g_iScreenPrivateKeyIndex;
-static int g_iCmapPrivateKeyIndex;
-DevPrivateKey g_iCmapPrivateKey = &g_iCmapPrivateKeyIndex;
-static int g_iGCPrivateKeyIndex;
-DevPrivateKey g_iGCPrivateKey = &g_iGCPrivateKeyIndex;
-static int g_iPixmapPrivateKeyIndex;
-DevPrivateKey g_iPixmapPrivateKey = &g_iPixmapPrivateKeyIndex;
-static int g_iWindowPrivateKeyIndex;
-DevPrivateKey g_iWindowPrivateKey = &g_iWindowPrivateKeyIndex;
-unsigned long g_ulServerGeneration = 0;
-Bool g_fInitializedDefaultScreens = FALSE;
-DWORD g_dwEnginesSupported = 0;
-HINSTANCE g_hInstance = 0;
-HWND g_hDlgDepthChange = NULL;
-HWND g_hDlgExit = NULL;
-HWND g_hDlgAbout = NULL;
-const char * g_pszQueryHost = NULL;
-Bool g_fXdmcpEnabled = FALSE;
-Bool g_fAuthEnabled = FALSE;
-HICON g_hIconX = NULL;
-HICON g_hSmallIconX = NULL;
-#ifndef RELOCATE_PROJECTROOT
-char * g_pszLogFile = "/tmp/XWin.log";
-#else
-char * g_pszLogFile = "XWin.log";
-Bool g_fLogFileChanged = FALSE;
-#endif
-int g_iLogVerbose = 2;
-Bool g_fLogInited = FALSE;
-char * g_pszCommandLine = NULL;
-Bool g_fSilentFatalError = FALSE;
-DWORD g_dwCurrentThreadID = 0;
-Bool g_fKeyboardHookLL = FALSE;
-HHOOK g_hhookKeyboardLL = NULL;
-HWND g_hwndKeyboardFocus = NULL;
-Bool g_fNoHelpMessageBox = FALSE;
-Bool g_fSoftwareCursor = FALSE;
-Bool g_fSilentDupError = FALSE;
-
-
-/*
- * Global variables for dynamically loaded libraries and
- * their function pointers
- */
-
-HMODULE g_hmodDirectDraw = NULL;
-FARPROC g_fpDirectDrawCreate = NULL;
-FARPROC g_fpDirectDrawCreateClipper = NULL;
-
-HMODULE g_hmodCommonControls = NULL;
-FARPROC g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;
-
-
-#ifdef XWIN_CLIPBOARD
-/*
- * Wrapped DIX functions
- */
-winDispatchProcPtr winProcEstablishConnectionOrig = NULL;
-winDispatchProcPtr winProcQueryTreeOrig = NULL;
-winDispatchProcPtr winProcSetSelectionOwnerOrig = NULL;
-
-
-/*
- * Clipboard variables
- */
-
-Bool g_fUnicodeClipboard = TRUE;
-Bool g_fClipboard = TRUE;
-Bool g_fClipboardLaunched = FALSE;
-Bool g_fClipboardStarted = FALSE;
-pthread_t g_ptClipboardProc;
-HWND g_hwndClipboard = NULL;
-void *g_pClipboardDisplay = NULL;
-Window g_iClipboardWindow = None;
-Atom g_atomLastOwnedSelection = None;
-#endif
-
-
-/*
- * Re-initialize global variables that are invalidated
- * by a server reset.
- */
-
-void
-winInitializeGlobals (void)
-{
- g_dwCurrentThreadID = GetCurrentThreadId ();
- g_hwndKeyboardFocus = NULL;
-#ifdef XWIN_CLIPBOARD
- g_fClipboardLaunched = FALSE;
- g_fClipboardStarted = FALSE;
- g_iClipboardWindow = None;
- g_pClipboardDisplay = NULL;
- g_atomLastOwnedSelection = None;
- g_hwndClipboard = NULL;
-#endif
-}
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *Copyright (C) Colin Harrison 2005-2008
+ *
+ *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, 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 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 HAROLD L HUNT II 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 Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ * Colin Harrison
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+/*
+ * General global variables
+ */
+
+int g_iNumScreens = 0;
+winScreenInfo g_ScreenInfo[MAXSCREENS];
+int g_iLastScreen = -1;
+#ifdef HAS_DEVWINDOWS
+int g_fdMessageQueue = WIN_FD_INVALID;
+#endif
+static int g_iScreenPrivateKeyIndex;
+DevPrivateKey g_iScreenPrivateKey = &g_iScreenPrivateKeyIndex;
+static int g_iCmapPrivateKeyIndex;
+DevPrivateKey g_iCmapPrivateKey = &g_iCmapPrivateKeyIndex;
+static int g_iGCPrivateKeyIndex;
+DevPrivateKey g_iGCPrivateKey = &g_iGCPrivateKeyIndex;
+static int g_iPixmapPrivateKeyIndex;
+DevPrivateKey g_iPixmapPrivateKey = &g_iPixmapPrivateKeyIndex;
+static int g_iWindowPrivateKeyIndex;
+DevPrivateKey g_iWindowPrivateKey = &g_iWindowPrivateKeyIndex;
+unsigned long g_ulServerGeneration = 0;
+Bool g_fInitializedDefaultScreens = FALSE;
+DWORD g_dwEnginesSupported = 0;
+HINSTANCE g_hInstance = 0;
+HWND g_hDlgDepthChange = NULL;
+HWND g_hDlgExit = NULL;
+HWND g_hDlgAbout = NULL;
+const char * g_pszQueryHost = NULL;
+Bool g_fXdmcpEnabled = FALSE;
+Bool g_fAuthEnabled = FALSE;
+HICON g_hIconX = NULL;
+HICON g_hSmallIconX = NULL;
+#ifndef RELOCATE_PROJECTROOT
+char * g_pszLogFile = DEFAULT_LOGDIR "/XWin.%s.log";
+#else
+char * g_pszLogFile = "XWin.log";
+Bool g_fLogFileChanged = FALSE;
+#endif
+int g_iLogVerbose = 2;
+Bool g_fLogInited = FALSE;
+char * g_pszCommandLine = NULL;
+Bool g_fSilentFatalError = FALSE;
+DWORD g_dwCurrentThreadID = 0;
+Bool g_fKeyboardHookLL = FALSE;
+HHOOK g_hhookKeyboardLL = NULL;
+HWND g_hwndKeyboardFocus = NULL;
+Bool g_fNoHelpMessageBox = FALSE;
+Bool g_fSoftwareCursor = FALSE;
+Bool g_fSilentDupError = FALSE;
+
+
+/*
+ * Global variables for dynamically loaded libraries and
+ * their function pointers
+ */
+
+HMODULE g_hmodDirectDraw = NULL;
+FARPROC g_fpDirectDrawCreate = NULL;
+FARPROC g_fpDirectDrawCreateClipper = NULL;
+
+HMODULE g_hmodCommonControls = NULL;
+FARPROC g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;
+
+
+#ifdef XWIN_CLIPBOARD
+/*
+ * Wrapped DIX functions
+ */
+winDispatchProcPtr winProcEstablishConnectionOrig = NULL;
+winDispatchProcPtr winProcQueryTreeOrig = NULL;
+winDispatchProcPtr winProcSetSelectionOwnerOrig = NULL;
+
+
+/*
+ * Clipboard variables
+ */
+
+Bool g_fUnicodeClipboard = TRUE;
+Bool g_fClipboard = TRUE;
+Bool g_fClipboardLaunched = FALSE;
+Bool g_fClipboardStarted = FALSE;
+pthread_t g_ptClipboardProc;
+HWND g_hwndClipboard = NULL;
+void *g_pClipboardDisplay = NULL;
+Window g_iClipboardWindow = None;
+Atom g_atomLastOwnedSelection = None;
+#endif
+
+
+/*
+ * Re-initialize global variables that are invalidated
+ * by a server reset.
+ */
+
+void
+winInitializeGlobals (void)
+{
+ g_dwCurrentThreadID = GetCurrentThreadId ();
+ g_hwndKeyboardFocus = NULL;
+#ifdef XWIN_CLIPBOARD
+ g_fClipboardLaunched = FALSE;
+ g_fClipboardStarted = FALSE;
+ g_iClipboardWindow = None;
+ g_pClipboardDisplay = NULL;
+ g_atomLastOwnedSelection = None;
+ g_hwndClipboard = NULL;
+#endif
+}
diff --git a/xorg-server/hw/xwin/winkeybd.c b/xorg-server/hw/xwin/winkeybd.c
index 317f14dff..bb180dff2 100644
--- a/xorg-server/hw/xwin/winkeybd.c
+++ b/xorg-server/hw/xwin/winkeybd.c
@@ -1,613 +1,612 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, 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 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 XFREE86 PROJECT 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 XFree86 Project
- *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 XFree86 Project.
- *
- * Authors: Dakshinamurthy Karra
- * Suhaib M Siddiqi
- * Peter Busch
- * Harold L Hunt II
- */
-
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-#include "winkeybd.h"
-#include "winconfig.h"
-#include "winmsg.h"
-
-#include "xkbsrv.h"
-
-static Bool g_winKeyState[NUM_KEYCODES];
-
-/*
- * Local prototypes
- */
-
-static void
-winGetKeyMappings (KeySymsPtr pKeySyms, CARD8 *pModMap);
-
-static void
-winKeybdBell (int iPercent, DeviceIntPtr pDeviceInt,
- pointer pCtrl, int iClass);
-
-static void
-winKeybdCtrl (DeviceIntPtr pDevice, KeybdCtrl *pCtrl);
-
-
-/*
- * Translate a Windows WM_[SYS]KEY(UP/DOWN) message
- * into an ASCII scan code.
- *
- * We do this ourselves, rather than letting Windows handle it,
- * because Windows tends to munge the handling of special keys,
- * like AltGr on European keyboards.
- */
-
-void
-winTranslateKey (WPARAM wParam, LPARAM lParam, int *piScanCode)
-{
- int iKeyFixup = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 1];
- int iKeyFixupEx = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 2];
- int iParam = HIWORD (lParam);
- int iParamScanCode = LOBYTE (iParam);
-
-/* WM_ key messages faked by Vista speech recognition (WSR) don't have a
- * scan code.
- *
- * Vocola 3 (Rick Mohr's supplement to WSR) uses
- * System.Windows.Forms.SendKeys.SendWait(), which appears always to give a
- * scan code of 1
- */
- if (iParamScanCode <= 1)
- {
- if (VK_PRIOR <= wParam && wParam <= VK_DOWN)
- /* Trigger special case table to translate to extended
- * keycode, otherwise if num_lock is on, we can get keypad
- * numbers instead of navigation keys. */
- iParam |= KF_EXTENDED;
- else
- iParamScanCode = MapVirtualKeyEx(wParam,
- /*MAPVK_VK_TO_VSC*/0,
- GetKeyboardLayout(0));
- }
-
- /* Branch on special extended, special non-extended, or normal key */
- if ((iParam & KF_EXTENDED) && iKeyFixupEx)
- *piScanCode = iKeyFixupEx;
- else if (iKeyFixup)
- *piScanCode = iKeyFixup;
- else if (wParam == 0 && iParamScanCode == 0x70)
- *piScanCode = KEY_HKTG;
- else
- switch (iParamScanCode)
- {
- case 0x70:
- *piScanCode = KEY_HKTG;
- break;
- case 0x73:
- *piScanCode = KEY_BSlash2;
- break;
- default:
- *piScanCode = iParamScanCode;
- break;
- }
-}
-
-
-/*
- * We call this function from winKeybdProc when we are
- * initializing the keyboard.
- */
-
-static void
-winGetKeyMappings (KeySymsPtr pKeySyms, CARD8 *pModMap)
-{
- int i;
- KeySym *pMap = map;
- KeySym *pKeySym;
-
- /*
- * Initialize all key states to up... which may not be true
- * but it is close enough.
- */
- ZeroMemory (g_winKeyState, sizeof (g_winKeyState[0]) * NUM_KEYCODES);
-
- /* MAP_LENGTH is defined in Xserver/include/input.h to be 256 */
- for (i = 0; i < MAP_LENGTH; i++)
- pModMap[i] = NoSymbol; /* make sure it is restored */
-
- /* Loop through all valid entries in the key symbol table */
- for (pKeySym = pMap, i = MIN_KEYCODE;
- i < (MIN_KEYCODE + NUM_KEYCODES);
- i++, pKeySym += GLYPHS_PER_KEY)
- {
- switch (*pKeySym)
- {
- case XK_Shift_L:
- case XK_Shift_R:
- pModMap[i] = ShiftMask;
- break;
-
- case XK_Control_L:
- case XK_Control_R:
- pModMap[i] = ControlMask;
- break;
-
- case XK_Caps_Lock:
- pModMap[i] = LockMask;
- break;
-
- case XK_Alt_L:
- case XK_Alt_R:
- pModMap[i] = AltMask;
- break;
-
- case XK_Num_Lock:
- pModMap[i] = NumLockMask;
- break;
-
- case XK_Scroll_Lock:
- pModMap[i] = ScrollLockMask;
- break;
-
-#if 0
- case XK_Super_L:
- case XK_Super_R:
- pModMap[i] = Mod4Mask;
- break;
-#else
- /* Hirigana/Katakana toggle */
- case XK_Kana_Lock:
- case XK_Kana_Shift:
- pModMap[i] = KanaMask;
- break;
-#endif
-
- /* alternate toggle for multinational support */
- case XK_Mode_switch:
- pModMap[i] = AltLangMask;
- break;
- }
- }
-
- pKeySyms->map = (KeySym *) pMap;
- pKeySyms->mapWidth = GLYPHS_PER_KEY;
- pKeySyms->minKeyCode = MIN_KEYCODE;
- pKeySyms->maxKeyCode = MAX_KEYCODE;
-}
-
-
-/* Ring the keyboard bell (system speaker on PCs) */
-static void
-winKeybdBell (int iPercent, DeviceIntPtr pDeviceInt,
- pointer pCtrl, int iClass)
-{
- /*
- * We can't use Beep () here because it uses the PC speaker
- * on NT/2000. MessageBeep (MB_OK) will play the default system
- * sound on systems with a sound card or it will beep the PC speaker
- * on systems that do not have a sound card.
- */
- MessageBeep (MB_OK);
-}
-
-
-/* Change some keyboard configuration parameters */
-static void
-winKeybdCtrl (DeviceIntPtr pDevice, KeybdCtrl *pCtrl)
-{
-}
-
-
-/*
- * See Porting Layer Definition - p. 18
- * winKeybdProc is known as a DeviceProc.
- */
-
-int
-winKeybdProc (DeviceIntPtr pDeviceInt, int iState)
-{
- DevicePtr pDevice = (DevicePtr) pDeviceInt;
- XkbSrvInfoPtr xkbi;
- XkbControlsPtr ctrl;
-
- switch (iState)
- {
- case DEVICE_INIT:
- winConfigKeyboard (pDeviceInt);
-
- /* FIXME: Maybe we should use winGetKbdLeds () here? */
- defaultKeyboardControl.leds = g_winInfo.keyboard.leds;
-
- winErrorFVerb(2, "Rules = \"%s\" Model = \"%s\" Layout = \"%s\""
- " Variant = \"%s\" Options = \"%s\"\n",
- g_winInfo.xkb.rules ? g_winInfo.xkb.rules : "none",
- g_winInfo.xkb.model ? g_winInfo.xkb.model : "none",
- g_winInfo.xkb.layout ? g_winInfo.xkb.layout : "none",
- g_winInfo.xkb.variant ? g_winInfo.xkb.variant : "none",
- g_winInfo.xkb.options ? g_winInfo.xkb.options : "none");
-
- InitKeyboardDeviceStruct (pDeviceInt,
- &g_winInfo.xkb,
- winKeybdBell,
- winKeybdCtrl);
-
- xkbi = pDeviceInt->key->xkbInfo;
- if ((xkbi != NULL) && (xkbi->desc != NULL))
- {
- ctrl = xkbi->desc->ctrls;
- ctrl->repeat_delay = g_winInfo.keyboard.delay;
- ctrl->repeat_interval = 1000/g_winInfo.keyboard.rate;
- }
- else
- {
- winErrorFVerb (1, "winKeybdProc - Error initializing keyboard AutoRepeat\n");
- }
-
- break;
-
- case DEVICE_ON:
- pDevice->on = TRUE;
- break;
-
- case DEVICE_CLOSE:
- case DEVICE_OFF:
- pDevice->on = FALSE;
- break;
- }
-
- return Success;
-}
-
-
-/*
- * Detect current mode key states upon server startup.
- *
- * Simulate a press and release of any key that is currently
- * toggled.
- */
-
-void
-winInitializeModeKeyStates (void)
-{
- /* Restore NumLock */
- if (GetKeyState (VK_NUMLOCK) & 0x0001)
- {
- winSendKeyEvent (KEY_NumLock, TRUE);
- winSendKeyEvent (KEY_NumLock, FALSE);
- }
-
- /* Restore CapsLock */
- if (GetKeyState (VK_CAPITAL) & 0x0001)
- {
- winSendKeyEvent (KEY_CapsLock, TRUE);
- winSendKeyEvent (KEY_CapsLock, FALSE);
- }
-
- /* Restore ScrollLock */
- if (GetKeyState (VK_SCROLL) & 0x0001)
- {
- winSendKeyEvent (KEY_ScrollLock, TRUE);
- winSendKeyEvent (KEY_ScrollLock, FALSE);
- }
-
- /* Restore KanaLock */
- if (GetKeyState (VK_KANA) & 0x0001)
- {
- winSendKeyEvent (KEY_HKTG, TRUE);
- winSendKeyEvent (KEY_HKTG, FALSE);
- }
-}
-
-
-/*
- * Upon regaining the keyboard focus we must
- * resynchronize our internal mode key states
- * with the actual state of the keys.
- */
-
-void
-winRestoreModeKeyStates (void)
-{
- DWORD dwKeyState;
- BOOL processEvents = TRUE;
- unsigned short internalKeyStates;
-
- /* X server is being initialized */
- if (!inputInfo.keyboard)
- return;
-
- /* Only process events if the rootwindow is mapped. The keyboard events
- * will cause segfaults otherwise */
- if (WindowTable && WindowTable[0] && WindowTable[0]->mapped == FALSE)
- processEvents = FALSE;
-
- /* Force to process all pending events in the mi event queue */
- if (processEvents)
- mieqProcessInputEvents ();
-
- /* Read the mode key states of our X server */
- /* (stored in the virtual core keyboard) */
- internalKeyStates = XkbStateFieldFromRec(&inputInfo.keyboard->key->xkbInfo->state);
- winDebug("winRestoreModeKeyStates: state %d\n", internalKeyStates);
-
- /*
- * NOTE: The C XOR operator, ^, will not work here because it is
- * a bitwise operator, not a logical operator. C does not
- * have a logical XOR operator, so we use a macro instead.
- */
-
- /* Has the key state changed? */
- dwKeyState = GetKeyState (VK_NUMLOCK) & 0x0001;
- if (WIN_XOR (internalKeyStates & NumLockMask, dwKeyState))
- {
- winSendKeyEvent (KEY_NumLock, TRUE);
- winSendKeyEvent (KEY_NumLock, FALSE);
- }
-
- /* Has the key state changed? */
- dwKeyState = GetKeyState (VK_CAPITAL) & 0x0001;
- if (WIN_XOR (internalKeyStates & LockMask, dwKeyState))
- {
- winSendKeyEvent (KEY_CapsLock, TRUE);
- winSendKeyEvent (KEY_CapsLock, FALSE);
- }
-
- /* Has the key state changed? */
- dwKeyState = GetKeyState (VK_SCROLL) & 0x0001;
- if (WIN_XOR (internalKeyStates & ScrollLockMask, dwKeyState))
- {
- winSendKeyEvent (KEY_ScrollLock, TRUE);
- winSendKeyEvent (KEY_ScrollLock, FALSE);
- }
-
- /* Has the key state changed? */
- dwKeyState = GetKeyState (VK_KANA) & 0x0001;
- if (WIN_XOR (internalKeyStates & KanaMask, dwKeyState))
- {
- winSendKeyEvent (KEY_HKTG, TRUE);
- winSendKeyEvent (KEY_HKTG, FALSE);
- }
-}
-
-
-/*
- * Look for the lovely fake Control_L press/release generated by Windows
- * when AltGr is pressed/released on a non-U.S. keyboard.
- */
-
-Bool
-winIsFakeCtrl_L (UINT message, WPARAM wParam, LPARAM lParam)
-{
- MSG msgNext;
- LONG lTime;
- Bool fReturn;
-
- /*
- * Fake Ctrl_L presses will be followed by an Alt_R keypress
- * with the same timestamp as the Ctrl_L press.
- */
- if ((message == WM_KEYDOWN || message == WM_SYSKEYDOWN)
- && wParam == VK_CONTROL
- && (HIWORD (lParam) & KF_EXTENDED) == 0)
- {
- /* Got a Ctrl_L press */
-
- /* Get time of current message */
- lTime = GetMessageTime ();
-
- /* Look for fake Ctrl_L preceeding an Alt_R press. */
- fReturn = PeekMessage (&msgNext, NULL,
- WM_KEYDOWN, WM_SYSKEYDOWN,
- PM_NOREMOVE);
-
- /*
- * Try again if the first call fails.
- * NOTE: This usually happens when TweakUI is enabled.
- */
- if (!fReturn)
- {
- /* Voodoo to make sure that the Alt_R message has posted */
- Sleep (0);
-
- /* Look for fake Ctrl_L preceeding an Alt_R press. */
- fReturn = PeekMessage (&msgNext, NULL,
- WM_KEYDOWN, WM_SYSKEYDOWN,
- PM_NOREMOVE);
- }
- if (msgNext.message != WM_KEYDOWN && msgNext.message != WM_SYSKEYDOWN)
- fReturn = 0;
-
- /* Is next press an Alt_R with the same timestamp? */
- if (fReturn && msgNext.wParam == VK_MENU
- && msgNext.time == lTime
- && (HIWORD (msgNext.lParam) & KF_EXTENDED))
- {
- /*
- * Next key press is Alt_R with same timestamp as current
- * Ctrl_L message. Therefore, this Ctrl_L press is a fake
- * event, so discard it.
- */
- return TRUE;
- }
- }
-
- /*
- * Fake Ctrl_L releases will be followed by an Alt_R release
- * with the same timestamp as the Ctrl_L release.
- */
- if ((message == WM_KEYUP || message == WM_SYSKEYUP)
- && wParam == VK_CONTROL
- && (HIWORD (lParam) & KF_EXTENDED) == 0)
- {
- /* Got a Ctrl_L release */
-
- /* Get time of current message */
- lTime = GetMessageTime ();
-
- /* Look for fake Ctrl_L release preceeding an Alt_R release. */
- fReturn = PeekMessage (&msgNext, NULL,
- WM_KEYUP, WM_SYSKEYUP,
- PM_NOREMOVE);
-
- /*
- * Try again if the first call fails.
- * NOTE: This usually happens when TweakUI is enabled.
- */
- if (!fReturn)
- {
- /* Voodoo to make sure that the Alt_R message has posted */
- Sleep (0);
-
- /* Look for fake Ctrl_L release preceeding an Alt_R release. */
- fReturn = PeekMessage (&msgNext, NULL,
- WM_KEYUP, WM_SYSKEYUP,
- PM_NOREMOVE);
- }
-
- if (msgNext.message != WM_KEYUP && msgNext.message != WM_SYSKEYUP)
- fReturn = 0;
-
- /* Is next press an Alt_R with the same timestamp? */
- if (fReturn
- && (msgNext.message == WM_KEYUP
- || msgNext.message == WM_SYSKEYUP)
- && msgNext.wParam == VK_MENU
- && msgNext.time == lTime
- && (HIWORD (msgNext.lParam) & KF_EXTENDED))
- {
- /*
- * Next key release is Alt_R with same timestamp as current
- * Ctrl_L message. Therefore, this Ctrl_L release is a fake
- * event, so discard it.
- */
- return TRUE;
- }
- }
-
- /* Not a fake control left press/release */
- return FALSE;
-}
-
-
-/*
- * Lift any modifier keys that are pressed
- */
-
-void
-winKeybdReleaseKeys (void)
-{
- int i;
-
-#ifdef HAS_DEVWINDOWS
- /* Verify that the mi input system has been initialized */
- if (g_fdMessageQueue == WIN_FD_INVALID)
- return;
-#endif
-
- /* Loop through all keys */
- for (i = 0; i < NUM_KEYCODES; ++i)
- {
- /* Pop key if pressed */
- if (g_winKeyState[i])
- winSendKeyEvent (i, FALSE);
-
- /* Reset pressed flag for keys */
- g_winKeyState[i] = FALSE;
- }
-}
-
-
-/*
- * Take a raw X key code and send an up or down event for it.
- *
- * Thanks to VNC for inspiration, though it is a simple function.
- */
-
-void
-winSendKeyEvent (DWORD dwKey, Bool fDown)
-{
- EventListPtr events;
- int i, nevents;
-
- /*
- * When alt-tabing between screens we can get phantom key up messages
- * Here we only pass them through it we think we should!
- */
- if (g_winKeyState[dwKey] == FALSE && fDown == FALSE) return;
-
- /* Update the keyState map */
- g_winKeyState[dwKey] = fDown;
-
- GetEventList(&events);
- nevents = GetKeyboardEvents(events, g_pwinKeyboard, fDown ? KeyPress : KeyRelease, dwKey + MIN_KEYCODE);
-
- for (i = 0; i < nevents; i++)
- mieqEnqueue(g_pwinKeyboard, events[i].event);
-
-#if CYGDEBUG
- ErrorF("winSendKeyEvent: dwKey: %d, fDown: %d, nEvents %d\n",
- dwKey, fDown, nevents);
-#endif
-}
-
-BOOL winCheckKeyPressed(WPARAM wParam, LPARAM lParam)
-{
- switch (wParam)
- {
- case VK_CONTROL:
- if ((lParam & 0x1ff0000) == 0x11d0000 && g_winKeyState[KEY_RCtrl])
- return TRUE;
- if ((lParam & 0x1ff0000) == 0x01d0000 && g_winKeyState[KEY_LCtrl])
- return TRUE;
- break;
- case VK_SHIFT:
- if ((lParam & 0x1ff0000) == 0x0360000 && g_winKeyState[KEY_ShiftR])
- return TRUE;
- if ((lParam & 0x1ff0000) == 0x02a0000 && g_winKeyState[KEY_ShiftL])
- return TRUE;
- break;
- default:
- return TRUE;
- }
- return FALSE;
-}
-
-/* Only on shift release message is sent even if both are pressed.
- * Fix this here
- */
-void winFixShiftKeys (int iScanCode)
-{
- if (GetKeyState (VK_SHIFT) & 0x8000)
- return;
-
- if (iScanCode == KEY_ShiftL && g_winKeyState[KEY_ShiftR])
- winSendKeyEvent (KEY_ShiftR, FALSE);
- if (iScanCode == KEY_ShiftR && g_winKeyState[KEY_ShiftL])
- winSendKeyEvent (KEY_ShiftL, FALSE);
-}
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, 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 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 XFREE86 PROJECT 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 XFree86 Project
+ *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 XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ */
+
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "winkeybd.h"
+#include "winconfig.h"
+#include "winmsg.h"
+
+#include "xkbsrv.h"
+
+static Bool g_winKeyState[NUM_KEYCODES];
+
+/*
+ * Local prototypes
+ */
+
+static void
+winGetKeyMappings (KeySymsPtr pKeySyms, CARD8 *pModMap);
+
+static void
+winKeybdBell (int iPercent, DeviceIntPtr pDeviceInt,
+ pointer pCtrl, int iClass);
+
+static void
+winKeybdCtrl (DeviceIntPtr pDevice, KeybdCtrl *pCtrl);
+
+
+/*
+ * Translate a Windows WM_[SYS]KEY(UP/DOWN) message
+ * into an ASCII scan code.
+ *
+ * We do this ourselves, rather than letting Windows handle it,
+ * because Windows tends to munge the handling of special keys,
+ * like AltGr on European keyboards.
+ */
+
+void
+winTranslateKey (WPARAM wParam, LPARAM lParam, int *piScanCode)
+{
+ int iKeyFixup = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 1];
+ int iKeyFixupEx = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 2];
+ int iParam = HIWORD (lParam);
+ int iParamScanCode = LOBYTE (iParam);
+
+/* WM_ key messages faked by Vista speech recognition (WSR) don't have a
+ * scan code.
+ *
+ * Vocola 3 (Rick Mohr's supplement to WSR) uses
+ * System.Windows.Forms.SendKeys.SendWait(), which appears always to give a
+ * scan code of 1
+ */
+ if (iParamScanCode <= 1)
+ {
+ if (VK_PRIOR <= wParam && wParam <= VK_DOWN)
+ /* Trigger special case table to translate to extended
+ * keycode, otherwise if num_lock is on, we can get keypad
+ * numbers instead of navigation keys. */
+ iParam |= KF_EXTENDED;
+ else
+ iParamScanCode = MapVirtualKeyEx(wParam,
+ /*MAPVK_VK_TO_VSC*/0,
+ GetKeyboardLayout(0));
+ }
+
+ /* Branch on special extended, special non-extended, or normal key */
+ if ((iParam & KF_EXTENDED) && iKeyFixupEx)
+ *piScanCode = iKeyFixupEx;
+ else if (iKeyFixup)
+ *piScanCode = iKeyFixup;
+ else if (wParam == 0 && iParamScanCode == 0x70)
+ *piScanCode = KEY_HKTG;
+ else
+ switch (iParamScanCode)
+ {
+ case 0x70:
+ *piScanCode = KEY_HKTG;
+ break;
+ case 0x73:
+ *piScanCode = KEY_BSlash2;
+ break;
+ default:
+ *piScanCode = iParamScanCode;
+ break;
+ }
+}
+
+
+/*
+ * We call this function from winKeybdProc when we are
+ * initializing the keyboard.
+ */
+
+static void
+winGetKeyMappings (KeySymsPtr pKeySyms, CARD8 *pModMap)
+{
+ int i;
+ KeySym *pMap = map;
+ KeySym *pKeySym;
+
+ /*
+ * Initialize all key states to up... which may not be true
+ * but it is close enough.
+ */
+ ZeroMemory (g_winKeyState, sizeof (g_winKeyState[0]) * NUM_KEYCODES);
+
+ /* MAP_LENGTH is defined in Xserver/include/input.h to be 256 */
+ for (i = 0; i < MAP_LENGTH; i++)
+ pModMap[i] = NoSymbol; /* make sure it is restored */
+
+ /* Loop through all valid entries in the key symbol table */
+ for (pKeySym = pMap, i = MIN_KEYCODE;
+ i < (MIN_KEYCODE + NUM_KEYCODES);
+ i++, pKeySym += GLYPHS_PER_KEY)
+ {
+ switch (*pKeySym)
+ {
+ case XK_Shift_L:
+ case XK_Shift_R:
+ pModMap[i] = ShiftMask;
+ break;
+
+ case XK_Control_L:
+ case XK_Control_R:
+ pModMap[i] = ControlMask;
+ break;
+
+ case XK_Caps_Lock:
+ pModMap[i] = LockMask;
+ break;
+
+ case XK_Alt_L:
+ case XK_Alt_R:
+ pModMap[i] = AltMask;
+ break;
+
+ case XK_Num_Lock:
+ pModMap[i] = NumLockMask;
+ break;
+
+ case XK_Scroll_Lock:
+ pModMap[i] = ScrollLockMask;
+ break;
+
+#if 0
+ case XK_Super_L:
+ case XK_Super_R:
+ pModMap[i] = Mod4Mask;
+ break;
+#else
+ /* Hirigana/Katakana toggle */
+ case XK_Kana_Lock:
+ case XK_Kana_Shift:
+ pModMap[i] = KanaMask;
+ break;
+#endif
+
+ /* alternate toggle for multinational support */
+ case XK_Mode_switch:
+ pModMap[i] = AltLangMask;
+ break;
+ }
+ }
+
+ pKeySyms->map = (KeySym *) pMap;
+ pKeySyms->mapWidth = GLYPHS_PER_KEY;
+ pKeySyms->minKeyCode = MIN_KEYCODE;
+ pKeySyms->maxKeyCode = MAX_KEYCODE;
+}
+
+
+/* Ring the keyboard bell (system speaker on PCs) */
+static void
+winKeybdBell (int iPercent, DeviceIntPtr pDeviceInt,
+ pointer pCtrl, int iClass)
+{
+ /*
+ * We can't use Beep () here because it uses the PC speaker
+ * on NT/2000. MessageBeep (MB_OK) will play the default system
+ * sound on systems with a sound card or it will beep the PC speaker
+ * on systems that do not have a sound card.
+ */
+ MessageBeep (MB_OK);
+}
+
+
+/* Change some keyboard configuration parameters */
+static void
+winKeybdCtrl (DeviceIntPtr pDevice, KeybdCtrl *pCtrl)
+{
+}
+
+
+/*
+ * See Porting Layer Definition - p. 18
+ * winKeybdProc is known as a DeviceProc.
+ */
+
+int
+winKeybdProc (DeviceIntPtr pDeviceInt, int iState)
+{
+ DevicePtr pDevice = (DevicePtr) pDeviceInt;
+ XkbSrvInfoPtr xkbi;
+ XkbControlsPtr ctrl;
+
+ switch (iState)
+ {
+ case DEVICE_INIT:
+ winConfigKeyboard (pDeviceInt);
+
+ /* FIXME: Maybe we should use winGetKbdLeds () here? */
+ defaultKeyboardControl.leds = g_winInfo.keyboard.leds;
+
+ winDebug("Rules = \"%s\" Model = \"%s\" Layout = \"%s\""
+ " Variant = \"%s\" Options = \"%s\"\n",
+ g_winInfo.xkb.rules ? g_winInfo.xkb.rules : "none",
+ g_winInfo.xkb.model ? g_winInfo.xkb.model : "none",
+ g_winInfo.xkb.layout ? g_winInfo.xkb.layout : "none",
+ g_winInfo.xkb.variant ? g_winInfo.xkb.variant : "none",
+ g_winInfo.xkb.options ? g_winInfo.xkb.options : "none");
+
+ InitKeyboardDeviceStruct (pDeviceInt,
+ &g_winInfo.xkb,
+ winKeybdBell,
+ winKeybdCtrl);
+
+ xkbi = pDeviceInt->key->xkbInfo;
+ if ((xkbi != NULL) && (xkbi->desc != NULL))
+ {
+ ctrl = xkbi->desc->ctrls;
+ ctrl->repeat_delay = g_winInfo.keyboard.delay;
+ ctrl->repeat_interval = 1000/g_winInfo.keyboard.rate;
+ }
+ else
+ {
+ winDebug ("winKeybdProc - Error initializing keyboard AutoRepeat\n");
+ }
+
+ XkbSetExtension(pDeviceInt, ProcessKeyboardEvent);
+ break;
+
+ case DEVICE_ON:
+ pDevice->on = TRUE;
+ break;
+
+ case DEVICE_CLOSE:
+ case DEVICE_OFF:
+ pDevice->on = FALSE;
+ break;
+ }
+
+ return Success;
+}
+
+
+/*
+ * Detect current mode key states upon server startup.
+ *
+ * Simulate a press and release of any key that is currently
+ * toggled.
+ */
+
+void
+winInitializeModeKeyStates (void)
+{
+ /* Restore NumLock */
+ if (GetKeyState (VK_NUMLOCK) & 0x0001)
+ {
+ winSendKeyEvent (KEY_NumLock, TRUE);
+ winSendKeyEvent (KEY_NumLock, FALSE);
+ }
+
+ /* Restore CapsLock */
+ if (GetKeyState (VK_CAPITAL) & 0x0001)
+ {
+ winSendKeyEvent (KEY_CapsLock, TRUE);
+ winSendKeyEvent (KEY_CapsLock, FALSE);
+ }
+
+ /* Restore ScrollLock */
+ if (GetKeyState (VK_SCROLL) & 0x0001)
+ {
+ winSendKeyEvent (KEY_ScrollLock, TRUE);
+ winSendKeyEvent (KEY_ScrollLock, FALSE);
+ }
+
+ /* Restore KanaLock */
+ if (GetKeyState (VK_KANA) & 0x0001)
+ {
+ winSendKeyEvent (KEY_HKTG, TRUE);
+ winSendKeyEvent (KEY_HKTG, FALSE);
+ }
+}
+
+
+/*
+ * Upon regaining the keyboard focus we must
+ * resynchronize our internal mode key states
+ * with the actual state of the keys.
+ */
+
+void
+winRestoreModeKeyStates (void)
+{
+ DWORD dwKeyState;
+ BOOL processEvents = TRUE;
+ unsigned short internalKeyStates;
+
+ /* X server is being initialized */
+ if (!inputInfo.keyboard)
+ return;
+
+ /* Only process events if the rootwindow is mapped. The keyboard events
+ * will cause segfaults otherwise */
+ if (WindowTable && WindowTable[0] && WindowTable[0]->mapped == FALSE)
+ processEvents = FALSE;
+
+ /* Force to process all pending events in the mi event queue */
+ if (processEvents)
+ mieqProcessInputEvents ();
+
+ /* Read the mode key states of our X server */
+ /* (stored in the virtual core keyboard) */
+ internalKeyStates = XkbStateFieldFromRec(&inputInfo.keyboard->key->xkbInfo->state);
+ winDebug("winRestoreModeKeyStates: state %d\n", internalKeyStates);
+
+ /*
+ * NOTE: The C XOR operator, ^, will not work here because it is
+ * a bitwise operator, not a logical operator. C does not
+ * have a logical XOR operator, so we use a macro instead.
+ */
+
+ /* Has the key state changed? */
+ dwKeyState = GetKeyState (VK_NUMLOCK) & 0x0001;
+ if (WIN_XOR (internalKeyStates & NumLockMask, dwKeyState))
+ {
+ winSendKeyEvent (KEY_NumLock, TRUE);
+ winSendKeyEvent (KEY_NumLock, FALSE);
+ }
+
+ /* Has the key state changed? */
+ dwKeyState = GetKeyState (VK_CAPITAL) & 0x0001;
+ if (WIN_XOR (internalKeyStates & LockMask, dwKeyState))
+ {
+ winSendKeyEvent (KEY_CapsLock, TRUE);
+ winSendKeyEvent (KEY_CapsLock, FALSE);
+ }
+
+ /* Has the key state changed? */
+ dwKeyState = GetKeyState (VK_SCROLL) & 0x0001;
+ if (WIN_XOR (internalKeyStates & ScrollLockMask, dwKeyState))
+ {
+ winSendKeyEvent (KEY_ScrollLock, TRUE);
+ winSendKeyEvent (KEY_ScrollLock, FALSE);
+ }
+
+ /* Has the key state changed? */
+ dwKeyState = GetKeyState (VK_KANA) & 0x0001;
+ if (WIN_XOR (internalKeyStates & KanaMask, dwKeyState))
+ {
+ winSendKeyEvent (KEY_HKTG, TRUE);
+ winSendKeyEvent (KEY_HKTG, FALSE);
+ }
+}
+
+
+/*
+ * Look for the lovely fake Control_L press/release generated by Windows
+ * when AltGr is pressed/released on a non-U.S. keyboard.
+ */
+
+Bool
+winIsFakeCtrl_L (UINT message, WPARAM wParam, LPARAM lParam)
+{
+ MSG msgNext;
+ LONG lTime;
+ Bool fReturn;
+
+ /*
+ * Fake Ctrl_L presses will be followed by an Alt_R keypress
+ * with the same timestamp as the Ctrl_L press.
+ */
+ if ((message == WM_KEYDOWN || message == WM_SYSKEYDOWN)
+ && wParam == VK_CONTROL
+ && (HIWORD (lParam) & KF_EXTENDED) == 0)
+ {
+ /* Got a Ctrl_L press */
+
+ /* Get time of current message */
+ lTime = GetMessageTime ();
+
+ /* Look for fake Ctrl_L preceeding an Alt_R press. */
+ fReturn = PeekMessage (&msgNext, NULL,
+ WM_KEYDOWN, WM_SYSKEYDOWN,
+ PM_NOREMOVE);
+
+ /*
+ * Try again if the first call fails.
+ * NOTE: This usually happens when TweakUI is enabled.
+ */
+ if (!fReturn)
+ {
+ /* Voodoo to make sure that the Alt_R message has posted */
+ Sleep (0);
+
+ /* Look for fake Ctrl_L preceeding an Alt_R press. */
+ fReturn = PeekMessage (&msgNext, NULL,
+ WM_KEYDOWN, WM_SYSKEYDOWN,
+ PM_NOREMOVE);
+ }
+ if (msgNext.message != WM_KEYDOWN && msgNext.message != WM_SYSKEYDOWN)
+ fReturn = 0;
+
+ /* Is next press an Alt_R with the same timestamp? */
+ if (fReturn && msgNext.wParam == VK_MENU
+ && msgNext.time == lTime
+ && (HIWORD (msgNext.lParam) & KF_EXTENDED))
+ {
+ /*
+ * Next key press is Alt_R with same timestamp as current
+ * Ctrl_L message. Therefore, this Ctrl_L press is a fake
+ * event, so discard it.
+ */
+ return TRUE;
+ }
+ }
+
+ /*
+ * Fake Ctrl_L releases will be followed by an Alt_R release
+ * with the same timestamp as the Ctrl_L release.
+ */
+ if ((message == WM_KEYUP || message == WM_SYSKEYUP)
+ && wParam == VK_CONTROL
+ && (HIWORD (lParam) & KF_EXTENDED) == 0)
+ {
+ /* Got a Ctrl_L release */
+
+ /* Get time of current message */
+ lTime = GetMessageTime ();
+
+ /* Look for fake Ctrl_L release preceeding an Alt_R release. */
+ fReturn = PeekMessage (&msgNext, NULL,
+ WM_KEYUP, WM_SYSKEYUP,
+ PM_NOREMOVE);
+
+ /*
+ * Try again if the first call fails.
+ * NOTE: This usually happens when TweakUI is enabled.
+ */
+ if (!fReturn)
+ {
+ /* Voodoo to make sure that the Alt_R message has posted */
+ Sleep (0);
+
+ /* Look for fake Ctrl_L release preceeding an Alt_R release. */
+ fReturn = PeekMessage (&msgNext, NULL,
+ WM_KEYUP, WM_SYSKEYUP,
+ PM_NOREMOVE);
+ }
+
+ if (msgNext.message != WM_KEYUP && msgNext.message != WM_SYSKEYUP)
+ fReturn = 0;
+
+ /* Is next press an Alt_R with the same timestamp? */
+ if (fReturn
+ && (msgNext.message == WM_KEYUP
+ || msgNext.message == WM_SYSKEYUP)
+ && msgNext.wParam == VK_MENU
+ && msgNext.time == lTime
+ && (HIWORD (msgNext.lParam) & KF_EXTENDED))
+ {
+ /*
+ * Next key release is Alt_R with same timestamp as current
+ * Ctrl_L message. Therefore, this Ctrl_L release is a fake
+ * event, so discard it.
+ */
+ return TRUE;
+ }
+ }
+
+ /* Not a fake control left press/release */
+ return FALSE;
+}
+
+
+/*
+ * Lift any modifier keys that are pressed
+ */
+
+void
+winKeybdReleaseKeys (void)
+{
+ int i;
+
+#ifdef HAS_DEVWINDOWS
+ /* Verify that the mi input system has been initialized */
+ if (g_fdMessageQueue == WIN_FD_INVALID)
+ return;
+#endif
+
+ /* Loop through all keys */
+ for (i = 0; i < NUM_KEYCODES; ++i)
+ {
+ /* Pop key if pressed */
+ if (g_winKeyState[i])
+ winSendKeyEvent (i, FALSE);
+
+ /* Reset pressed flag for keys */
+ g_winKeyState[i] = FALSE;
+ }
+}
+
+
+/*
+ * Take a raw X key code and send an up or down event for it.
+ *
+ * Thanks to VNC for inspiration, though it is a simple function.
+ */
+
+void
+winSendKeyEvent (DWORD dwKey, Bool fDown)
+{
+ EventListPtr events;
+ int i, nevents;
+
+ /*
+ * When alt-tabing between screens we can get phantom key up messages
+ * Here we only pass them through it we think we should!
+ */
+ if (g_winKeyState[dwKey] == FALSE && fDown == FALSE) return;
+
+ /* Update the keyState map */
+ g_winKeyState[dwKey] = fDown;
+
+ GetEventList(&events);
+ nevents = GetKeyboardEvents(events, g_pwinKeyboard, fDown ? KeyPress : KeyRelease, dwKey + MIN_KEYCODE);
+
+ for (i = 0; i < nevents; i++)
+ mieqEnqueue(g_pwinKeyboard, (InternalEvent*)(events + i)->event);
+
+ winDebug("winSendKeyEvent: dwKey: %d, fDown: %d, nEvents %d\n",
+ dwKey, fDown, nevents);
+}
+
+BOOL winCheckKeyPressed(WPARAM wParam, LPARAM lParam)
+{
+ switch (wParam)
+ {
+ case VK_CONTROL:
+ if ((lParam & 0x1ff0000) == 0x11d0000 && g_winKeyState[KEY_RCtrl])
+ return TRUE;
+ if ((lParam & 0x1ff0000) == 0x01d0000 && g_winKeyState[KEY_LCtrl])
+ return TRUE;
+ break;
+ case VK_SHIFT:
+ if ((lParam & 0x1ff0000) == 0x0360000 && g_winKeyState[KEY_ShiftR])
+ return TRUE;
+ if ((lParam & 0x1ff0000) == 0x02a0000 && g_winKeyState[KEY_ShiftL])
+ return TRUE;
+ break;
+ default:
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/* Only on shift release message is sent even if both are pressed.
+ * Fix this here
+ */
+void winFixShiftKeys (int iScanCode)
+{
+ if (GetKeyState (VK_SHIFT) & 0x8000)
+ return;
+
+ if (iScanCode == KEY_ShiftL && g_winKeyState[KEY_ShiftR])
+ winSendKeyEvent (KEY_ShiftR, FALSE);
+ if (iScanCode == KEY_ShiftR && g_winKeyState[KEY_ShiftL])
+ winSendKeyEvent (KEY_ShiftL, FALSE);
+}
diff --git a/xorg-server/hw/xwin/winkeybd.h b/xorg-server/hw/xwin/winkeybd.h
index d0d6b9cad..8646bcec8 100644
--- a/xorg-server/hw/xwin/winkeybd.h
+++ b/xorg-server/hw/xwin/winkeybd.h
@@ -1,312 +1,314 @@
-#if !defined(WINKEYBD_H)
-#define WINKEYBD_H
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, 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 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 XFREE86 PROJECT 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 XFree86 Project
- *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 XFree86 Project.
- *
- * Authors: Harold L Hunt II
- */
-
-/*
- * We need symbols for the scan codes of keys.
- */
-#include "winkeynames.h"
-
-
-/*
- * Include the standard ASCII keymap.
- *
- * This header declares a static KeySym array called 'map'.
- */
-#include "winkeymap.h"
-
-#define WIN_KEYMAP_COLS 3
-
-/* Rows 160 through 165 correspond to software-generated codes, which
- * may not be associated with the appropriate scan code.
- */
-const int
-g_iKeyMap [] = {
- /* count Windows VK, ASCII, ASCII when extended VK */
- /* 0 */ 0, 0, 0,
- /* 1 */ 0, 0, 0,
- /* 2 */ 0, 0, 0,
- /* 3 */ VK_CANCEL, 0, KEY_Break,
- /* 4 */ 0, 0, 0,
- /* 5 */ 0, 0, 0,
- /* 6 */ 0, 0, 0,
- /* 7 */ 0, 0, 0,
- /* 8 */ 0, 0, 0,
- /* 9 */ 0, 0, 0,
- /* 10 */ 0, 0, 0,
- /* 11 */ 0, 0, 0,
- /* 12 */ 0, 0, 0,
- /* 13 */ VK_RETURN, 0, KEY_KP_Enter,
- /* 14 */ 0, 0, 0,
- /* 15 */ 0, 0, 0,
- /* 16 */ VK_SHIFT, 0, 0,
- /* 17 */ VK_CONTROL, 0, KEY_RCtrl,
- /* 18 */ VK_MENU, 0, KEY_AltLang,
- /* 19 */ VK_PAUSE, KEY_Pause, 0,
- /* 20 */ 0, 0, 0,
- /* 21 */ 0, 0, 0,
- /* 22 */ 0, 0, 0,
- /* 23 */ 0, 0, 0,
- /* 24 */ 0, 0, 0,
- /* 25 */ 0, 0, 0,
- /* 26 */ 0, 0, 0,
- /* 27 */ 0, 0, 0,
- /* 28 */ 0, 0, 0,
- /* 29 */ 0, 0, 0,
- /* 30 */ 0, 0, 0,
- /* 31 */ 0, 0, 0,
- /* 32 */ 0, 0, 0,
- /* 33 */ VK_PRIOR, 0, KEY_PgUp,
- /* 34 */ VK_NEXT, 0, KEY_PgDown,
- /* 35 */ VK_END, 0, KEY_End,
- /* 36 */ VK_HOME, 0, KEY_Home,
- /* 37 */ VK_LEFT, 0, KEY_Left,
- /* 38 */ VK_UP, 0, KEY_Up,
- /* 39 */ VK_RIGHT, 0, KEY_Right,
- /* 40 */ VK_DOWN, 0, KEY_Down,
- /* 41 */ 0, 0, 0,
- /* 42 */ 0, 0, 0,
- /* 43 */ 0, 0, 0,
- /* 44 */ VK_SNAPSHOT, 0, KEY_Print,
- /* 45 */ VK_INSERT, 0, KEY_Insert,
- /* 46 */ VK_DELETE, 0, KEY_Delete,
- /* 47 */ 0, 0, 0,
- /* 48 */ 0, 0, 0,
- /* 49 */ 0, 0, 0,
- /* 50 */ 0, 0, 0,
- /* 51 */ 0, 0, 0,
- /* 52 */ 0, 0, 0,
- /* 53 */ 0, 0, 0,
- /* 54 */ 0, 0, 0,
- /* 55 */ 0, 0, 0,
- /* 56 */ 0, 0, 0,
- /* 57 */ 0, 0, 0,
- /* 58 */ 0, 0, 0,
- /* 59 */ 0, 0, 0,
- /* 60 */ 0, 0, 0,
- /* 61 */ 0, 0, 0,
- /* 62 */ 0, 0, 0,
- /* 63 */ 0, 0, 0,
- /* 64 */ 0, 0, 0,
- /* 65 */ 0, 0, 0,
- /* 66 */ 0, 0, 0,
- /* 67 */ 0, 0, 0,
- /* 68 */ 0, 0, 0,
- /* 69 */ 0, 0, 0,
- /* 70 */ 0, 0, 0,
- /* 71 */ 0, 0, 0,
- /* 72 */ 0, 0, 0,
- /* 73 */ 0, 0, 0,
- /* 74 */ 0, 0, 0,
- /* 75 */ 0, 0, 0,
- /* 76 */ 0, 0, 0,
- /* 77 */ 0, 0, 0,
- /* 78 */ 0, 0, 0,
- /* 79 */ 0, 0, 0,
- /* 80 */ 0, 0, 0,
- /* 81 */ 0, 0, 0,
- /* 82 */ 0, 0, 0,
- /* 83 */ 0, 0, 0,
- /* 84 */ 0, 0, 0,
- /* 85 */ 0, 0, 0,
- /* 86 */ 0, 0, 0,
- /* 87 */ 0, 0, 0,
- /* 88 */ 0, 0, 0,
- /* 89 */ 0, 0, 0,
- /* 90 */ 0, 0, 0,
- /* 91 */ VK_LWIN, KEY_LMeta, 0,
- /* 92 */ VK_RWIN, KEY_RMeta, 0,
- /* 93 */ VK_APPS, KEY_Menu, 0,
- /* 94 */ 0, 0, 0,
- /* 95 */ 0, 0, 0,
- /* 96 */ 0, 0, 0,
- /* 97 */ 0, 0, 0,
- /* 98 */ 0, 0, 0,
- /* 99 */ 0, 0, 0,
- /* 100 */ 0, 0, 0,
- /* 101 */ 0, 0, 0,
- /* 102 */ 0, 0, 0,
- /* 103 */ 0, 0, 0,
- /* 104 */ 0, 0, 0,
- /* 105 */ 0, 0, 0,
- /* 106 */ 0, 0, 0,
- /* 107 */ 0, 0, 0,
- /* 108 */ 0, 0, 0,
- /* 109 */ 0, 0, 0,
- /* 110 */ 0, 0, 0,
- /* 111 */ VK_DIVIDE, 0, KEY_KP_Divide,
- /* 112 */ 0, 0, 0,
- /* 113 */ 0, 0, 0,
- /* 114 */ 0, 0, 0,
- /* 115 */ 0, 0, 0,
- /* 116 */ 0, 0, 0,
- /* 117 */ 0, 0, 0,
- /* 118 */ 0, 0, 0,
- /* 119 */ 0, 0, 0,
- /* 120 */ 0, 0, 0,
- /* 121 */ 0, 0, 0,
- /* 122 */ 0, 0, 0,
- /* 123 */ 0, 0, 0,
- /* 124 */ 0, 0, 0,
- /* 125 */ 0, 0, 0,
- /* 126 */ 0, 0, 0,
- /* 127 */ 0, 0, 0,
- /* 128 */ 0, 0, 0,
- /* 129 */ 0, 0, 0,
- /* 130 */ 0, 0, 0,
- /* 131 */ 0, 0, 0,
- /* 132 */ 0, 0, 0,
- /* 133 */ 0, 0, 0,
- /* 134 */ 0, 0, 0,
- /* 135 */ 0, 0, 0,
- /* 136 */ 0, 0, 0,
- /* 137 */ 0, 0, 0,
- /* 138 */ 0, 0, 0,
- /* 139 */ 0, 0, 0,
- /* 140 */ 0, 0, 0,
- /* 141 */ 0, 0, 0,
- /* 142 */ 0, 0, 0,
- /* 143 */ 0, 0, 0,
- /* 144 */ 0, 0, 0,
- /* 145 */ 0, 0, 0,
- /* 146 */ 0, 0, 0,
- /* 147 */ 0, 0, 0,
- /* 148 */ 0, 0, 0,
- /* 149 */ 0, 0, 0,
- /* 150 */ 0, 0, 0,
- /* 151 */ 0, 0, 0,
- /* 152 */ 0, 0, 0,
- /* 153 */ 0, 0, 0,
- /* 154 */ 0, 0, 0,
- /* 155 */ 0, 0, 0,
- /* 156 */ 0, 0, 0,
- /* 157 */ 0, 0, 0,
- /* 158 */ 0, 0, 0,
- /* 159 */ 0, 0, 0,
- /* 160 */ VK_LSHIFT, KEY_ShiftL, 0,
- /* 161 */ VK_RSHIFT, KEY_ShiftR, 0,
- /* 162 */ VK_LCONTROL, KEY_LCtrl, 0,
- /* 163 */ VK_RCONTROL, KEY_RCtrl, 0,
- /* 164 */ VK_LMENU, KEY_Alt, 0,
- /* 165 */ VK_RMENU, KEY_AltLang, 0,
- /* 166 */ 0, 0, 0,
- /* 167 */ 0, 0, 0,
- /* 168 */ 0, 0, 0,
- /* 169 */ 0, 0, 0,
- /* 170 */ 0, 0, 0,
- /* 171 */ 0, 0, 0,
- /* 172 */ 0, 0, 0,
- /* 173 */ 0, 0, 0,
- /* 174 */ 0, 0, 0,
- /* 175 */ 0, 0, 0,
- /* 176 */ 0, 0, 0,
- /* 177 */ 0, 0, 0,
- /* 178 */ 0, 0, 0,
- /* 179 */ 0, 0, 0,
- /* 180 */ 0, 0, 0,
- /* 181 */ 0, 0, 0,
- /* 182 */ 0, 0, 0,
- /* 183 */ 0, 0, 0,
- /* 184 */ 0, 0, 0,
- /* 185 */ 0, 0, 0,
- /* 186 */ 0, 0, 0,
- /* 187 */ 0, 0, 0,
- /* 188 */ 0, 0, 0,
- /* 189 */ 0, 0, 0,
- /* 190 */ 0, 0, 0,
- /* 191 */ 0, 0, 0,
- /* 192 */ 0, 0, 0,
- /* 193 */ 0, 0, 0,
- /* 194 */ 0, 0, 0,
- /* 195 */ 0, 0, 0,
- /* 196 */ 0, 0, 0,
- /* 197 */ 0, 0, 0,
- /* 198 */ 0, 0, 0,
- /* 199 */ 0, 0, 0,
- /* 200 */ 0, 0, 0,
- /* 201 */ 0, 0, 0,
- /* 202 */ 0, 0, 0,
- /* 203 */ 0, 0, 0,
- /* 204 */ 0, 0, 0,
- /* 205 */ 0, 0, 0,
- /* 206 */ 0, 0, 0,
- /* 207 */ 0, 0, 0,
- /* 208 */ 0, 0, 0,
- /* 209 */ 0, 0, 0,
- /* 210 */ 0, 0, 0,
- /* 211 */ 0, 0, 0,
- /* 212 */ 0, 0, 0,
- /* 213 */ 0, 0, 0,
- /* 214 */ 0, 0, 0,
- /* 215 */ 0, 0, 0,
- /* 216 */ 0, 0, 0,
- /* 217 */ 0, 0, 0,
- /* 218 */ 0, 0, 0,
- /* 219 */ 0, 0, 0,
- /* 220 */ 0, 0, 0,
- /* 221 */ 0, 0, 0,
- /* 222 */ 0, 0, 0,
- /* 223 */ 0, 0, 0,
- /* 224 */ 0, 0, 0,
- /* 225 */ 0, 0, 0,
- /* 226 */ 0, 0, 0,
- /* 227 */ 0, 0, 0,
- /* 228 */ 0, 0, 0,
- /* 229 */ 0, 0, 0,
- /* 230 */ 0, 0, 0,
- /* 231 */ 0, 0, 0,
- /* 232 */ 0, 0, 0,
- /* 233 */ 0, 0, 0,
- /* 234 */ 0, 0, 0,
- /* 235 */ 0, 0, 0,
- /* 236 */ 0, 0, 0,
- /* 237 */ 0, 0, 0,
- /* 238 */ 0, 0, 0,
- /* 239 */ 0, 0, 0,
- /* 240 */ 0, 0, 0,
- /* 241 */ 0, 0, 0,
- /* 242 */ 0, 0, 0,
- /* 243 */ 0, 0, 0,
- /* 244 */ 0, 0, 0,
- /* 245 */ 0, 0, 0,
- /* 246 */ 0, 0, 0,
- /* 247 */ 0, 0, 0,
- /* 248 */ 0, 0, 0,
- /* 249 */ 0, 0, 0,
- /* 250 */ 0, 0, 0,
- /* 251 */ 0, 0, 0,
- /* 252 */ 0, 0, 0,
- /* 253 */ 0, 0, 0,
- /* 254 */ 0, 0, 0,
- /* 255 */ 0, 0, 0
-};
-
-#endif /* WINKEYBD_H */
+#if !defined(WINKEYBD_H)
+#define WINKEYBD_H
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, 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 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 XFREE86 PROJECT 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 XFree86 Project
+ *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 XFree86 Project.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+/*
+ * We need symbols for the scan codes of keys.
+ */
+#include "winkeynames.h"
+
+
+/*
+ * Include the standard ASCII keymap.
+ *
+ * This header declares a static KeySym array called 'map'.
+ */
+#include "winkeymap.h"
+
+#define WIN_KEYMAP_COLS 3
+
+/* ASCII column, rows 33 through 40 are for Speech Recognition with
+ * num-lock asserted.
+ * Rows 160 through 165 correspond to software-generated codes, which
+ * may not be associated with the appropriate scan code/extended bit
+ */
+const int
+g_iKeyMap [] = {
+ /* count Windows VK, ASCII, ASCII when extended VK */
+ /* 0 */ 0, 0, 0,
+ /* 1 */ 0, 0, 0,
+ /* 2 */ 0, 0, 0,
+ /* 3 */ VK_CANCEL, 0, KEY_Break,
+ /* 4 */ 0, 0, 0,
+ /* 5 */ 0, 0, 0,
+ /* 6 */ 0, 0, 0,
+ /* 7 */ 0, 0, 0,
+ /* 8 */ 0, 0, 0,
+ /* 9 */ 0, 0, 0,
+ /* 10 */ 0, 0, 0,
+ /* 11 */ 0, 0, 0,
+ /* 12 */ 0, 0, 0,
+ /* 13 */ VK_RETURN, 0, KEY_KP_Enter,
+ /* 14 */ 0, 0, 0,
+ /* 15 */ 0, 0, 0,
+ /* 16 */ VK_SHIFT, 0, 0,
+ /* 17 */ VK_CONTROL, 0, KEY_RCtrl,
+ /* 18 */ VK_MENU, 0, KEY_AltLang,
+ /* 19 */ VK_PAUSE, KEY_Pause, 0,
+ /* 20 */ 0, 0, 0,
+ /* 21 */ 0, 0, 0,
+ /* 22 */ 0, 0, 0,
+ /* 23 */ 0, 0, 0,
+ /* 24 */ 0, 0, 0,
+ /* 25 */ 0, 0, 0,
+ /* 26 */ 0, 0, 0,
+ /* 27 */ 0, 0, 0,
+ /* 28 */ 0, 0, 0,
+ /* 29 */ 0, 0, 0,
+ /* 30 */ 0, 0, 0,
+ /* 31 */ 0, 0, 0,
+ /* 32 */ 0, 0, 0,
+ /* 33 */ VK_PRIOR, KEY_PgUp, KEY_PgUp,
+ /* 34 */ VK_NEXT, KEY_PgDown, KEY_PgDown,
+ /* 35 */ VK_END, KEY_End, KEY_End,
+ /* 36 */ VK_HOME, KEY_Home, KEY_Home,
+ /* 37 */ VK_LEFT, KEY_Left, KEY_Left,
+ /* 38 */ VK_UP, KEY_Up, KEY_Up,
+ /* 39 */ VK_RIGHT, KEY_Right, KEY_Right,
+ /* 40 */ VK_DOWN, KEY_Down, KEY_Down,
+ /* 41 */ 0, 0, 0,
+ /* 42 */ 0, 0, 0,
+ /* 43 */ 0, 0, 0,
+ /* 44 */ VK_SNAPSHOT, 0, KEY_Print,
+ /* 45 */ VK_INSERT, 0, KEY_Insert,
+ /* 46 */ VK_DELETE, 0, KEY_Delete,
+ /* 47 */ 0, 0, 0,
+ /* 48 */ 0, 0, 0,
+ /* 49 */ 0, 0, 0,
+ /* 50 */ 0, 0, 0,
+ /* 51 */ 0, 0, 0,
+ /* 52 */ 0, 0, 0,
+ /* 53 */ 0, 0, 0,
+ /* 54 */ 0, 0, 0,
+ /* 55 */ 0, 0, 0,
+ /* 56 */ 0, 0, 0,
+ /* 57 */ 0, 0, 0,
+ /* 58 */ 0, 0, 0,
+ /* 59 */ 0, 0, 0,
+ /* 60 */ 0, 0, 0,
+ /* 61 */ 0, 0, 0,
+ /* 62 */ 0, 0, 0,
+ /* 63 */ 0, 0, 0,
+ /* 64 */ 0, 0, 0,
+ /* 65 */ 0, 0, 0,
+ /* 66 */ 0, 0, 0,
+ /* 67 */ 0, 0, 0,
+ /* 68 */ 0, 0, 0,
+ /* 69 */ 0, 0, 0,
+ /* 70 */ 0, 0, 0,
+ /* 71 */ 0, 0, 0,
+ /* 72 */ 0, 0, 0,
+ /* 73 */ 0, 0, 0,
+ /* 74 */ 0, 0, 0,
+ /* 75 */ 0, 0, 0,
+ /* 76 */ 0, 0, 0,
+ /* 77 */ 0, 0, 0,
+ /* 78 */ 0, 0, 0,
+ /* 79 */ 0, 0, 0,
+ /* 80 */ 0, 0, 0,
+ /* 81 */ 0, 0, 0,
+ /* 82 */ 0, 0, 0,
+ /* 83 */ 0, 0, 0,
+ /* 84 */ 0, 0, 0,
+ /* 85 */ 0, 0, 0,
+ /* 86 */ 0, 0, 0,
+ /* 87 */ 0, 0, 0,
+ /* 88 */ 0, 0, 0,
+ /* 89 */ 0, 0, 0,
+ /* 90 */ 0, 0, 0,
+ /* 91 */ VK_LWIN, KEY_LMeta, 0,
+ /* 92 */ VK_RWIN, KEY_RMeta, 0,
+ /* 93 */ VK_APPS, KEY_Menu, 0,
+ /* 94 */ 0, 0, 0,
+ /* 95 */ 0, 0, 0,
+ /* 96 */ 0, 0, 0,
+ /* 97 */ 0, 0, 0,
+ /* 98 */ 0, 0, 0,
+ /* 99 */ 0, 0, 0,
+ /* 100 */ 0, 0, 0,
+ /* 101 */ 0, 0, 0,
+ /* 102 */ 0, 0, 0,
+ /* 103 */ 0, 0, 0,
+ /* 104 */ 0, 0, 0,
+ /* 105 */ 0, 0, 0,
+ /* 106 */ 0, 0, 0,
+ /* 107 */ 0, 0, 0,
+ /* 108 */ 0, 0, 0,
+ /* 109 */ 0, 0, 0,
+ /* 110 */ 0, 0, 0,
+ /* 111 */ VK_DIVIDE, 0, KEY_KP_Divide,
+ /* 112 */ 0, 0, 0,
+ /* 113 */ 0, 0, 0,
+ /* 114 */ 0, 0, 0,
+ /* 115 */ 0, 0, 0,
+ /* 116 */ 0, 0, 0,
+ /* 117 */ 0, 0, 0,
+ /* 118 */ 0, 0, 0,
+ /* 119 */ 0, 0, 0,
+ /* 120 */ 0, 0, 0,
+ /* 121 */ 0, 0, 0,
+ /* 122 */ 0, 0, 0,
+ /* 123 */ 0, 0, 0,
+ /* 124 */ 0, 0, 0,
+ /* 125 */ 0, 0, 0,
+ /* 126 */ 0, 0, 0,
+ /* 127 */ 0, 0, 0,
+ /* 128 */ 0, 0, 0,
+ /* 129 */ 0, 0, 0,
+ /* 130 */ 0, 0, 0,
+ /* 131 */ 0, 0, 0,
+ /* 132 */ 0, 0, 0,
+ /* 133 */ 0, 0, 0,
+ /* 134 */ 0, 0, 0,
+ /* 135 */ 0, 0, 0,
+ /* 136 */ 0, 0, 0,
+ /* 137 */ 0, 0, 0,
+ /* 138 */ 0, 0, 0,
+ /* 139 */ 0, 0, 0,
+ /* 140 */ 0, 0, 0,
+ /* 141 */ 0, 0, 0,
+ /* 142 */ 0, 0, 0,
+ /* 143 */ 0, 0, 0,
+ /* 144 */ 0, 0, 0,
+ /* 145 */ 0, 0, 0,
+ /* 146 */ 0, 0, 0,
+ /* 147 */ 0, 0, 0,
+ /* 148 */ 0, 0, 0,
+ /* 149 */ 0, 0, 0,
+ /* 150 */ 0, 0, 0,
+ /* 151 */ 0, 0, 0,
+ /* 152 */ 0, 0, 0,
+ /* 153 */ 0, 0, 0,
+ /* 154 */ 0, 0, 0,
+ /* 155 */ 0, 0, 0,
+ /* 156 */ 0, 0, 0,
+ /* 157 */ 0, 0, 0,
+ /* 158 */ 0, 0, 0,
+ /* 159 */ 0, 0, 0,
+ /* 160 */ VK_LSHIFT, KEY_ShiftL, KEY_ShiftL,
+ /* 161 */ VK_RSHIFT, KEY_ShiftR, KEY_ShiftR,
+ /* 162 */ VK_LCONTROL, KEY_LCtrl, KEY_LCtrl,
+ /* 163 */ VK_RCONTROL, KEY_RCtrl, KEY_RCtrl,
+ /* 164 */ VK_LMENU, KEY_Alt, KEY_Alt,
+ /* 165 */ VK_RMENU, KEY_AltLang, KEY_AltLang,
+ /* 166 */ 0, 0, 0,
+ /* 167 */ 0, 0, 0,
+ /* 168 */ 0, 0, 0,
+ /* 169 */ 0, 0, 0,
+ /* 170 */ 0, 0, 0,
+ /* 171 */ 0, 0, 0,
+ /* 172 */ 0, 0, 0,
+ /* 173 */ 0, 0, 0,
+ /* 174 */ 0, 0, 0,
+ /* 175 */ 0, 0, 0,
+ /* 176 */ 0, 0, 0,
+ /* 177 */ 0, 0, 0,
+ /* 178 */ 0, 0, 0,
+ /* 179 */ 0, 0, 0,
+ /* 180 */ 0, 0, 0,
+ /* 181 */ 0, 0, 0,
+ /* 182 */ 0, 0, 0,
+ /* 183 */ 0, 0, 0,
+ /* 184 */ 0, 0, 0,
+ /* 185 */ 0, 0, 0,
+ /* 186 */ 0, 0, 0,
+ /* 187 */ 0, 0, 0,
+ /* 188 */ 0, 0, 0,
+ /* 189 */ 0, 0, 0,
+ /* 190 */ 0, 0, 0,
+ /* 191 */ 0, 0, 0,
+ /* 192 */ 0, 0, 0,
+ /* 193 */ 0, 0, 0,
+ /* 194 */ 0, 0, 0,
+ /* 195 */ 0, 0, 0,
+ /* 196 */ 0, 0, 0,
+ /* 197 */ 0, 0, 0,
+ /* 198 */ 0, 0, 0,
+ /* 199 */ 0, 0, 0,
+ /* 200 */ 0, 0, 0,
+ /* 201 */ 0, 0, 0,
+ /* 202 */ 0, 0, 0,
+ /* 203 */ 0, 0, 0,
+ /* 204 */ 0, 0, 0,
+ /* 205 */ 0, 0, 0,
+ /* 206 */ 0, 0, 0,
+ /* 207 */ 0, 0, 0,
+ /* 208 */ 0, 0, 0,
+ /* 209 */ 0, 0, 0,
+ /* 210 */ 0, 0, 0,
+ /* 211 */ 0, 0, 0,
+ /* 212 */ 0, 0, 0,
+ /* 213 */ 0, 0, 0,
+ /* 214 */ 0, 0, 0,
+ /* 215 */ 0, 0, 0,
+ /* 216 */ 0, 0, 0,
+ /* 217 */ 0, 0, 0,
+ /* 218 */ 0, 0, 0,
+ /* 219 */ 0, 0, 0,
+ /* 220 */ 0, 0, 0,
+ /* 221 */ 0, 0, 0,
+ /* 222 */ 0, 0, 0,
+ /* 223 */ 0, 0, 0,
+ /* 224 */ 0, 0, 0,
+ /* 225 */ 0, 0, 0,
+ /* 226 */ 0, 0, 0,
+ /* 227 */ 0, 0, 0,
+ /* 228 */ 0, 0, 0,
+ /* 229 */ 0, 0, 0,
+ /* 230 */ 0, 0, 0,
+ /* 231 */ 0, 0, 0,
+ /* 232 */ 0, 0, 0,
+ /* 233 */ 0, 0, 0,
+ /* 234 */ 0, 0, 0,
+ /* 235 */ 0, 0, 0,
+ /* 236 */ 0, 0, 0,
+ /* 237 */ 0, 0, 0,
+ /* 238 */ 0, 0, 0,
+ /* 239 */ 0, 0, 0,
+ /* 240 */ 0, 0, 0,
+ /* 241 */ 0, 0, 0,
+ /* 242 */ 0, 0, 0,
+ /* 243 */ 0, 0, 0,
+ /* 244 */ 0, 0, 0,
+ /* 245 */ 0, 0, 0,
+ /* 246 */ 0, 0, 0,
+ /* 247 */ 0, 0, 0,
+ /* 248 */ 0, 0, 0,
+ /* 249 */ 0, 0, 0,
+ /* 250 */ 0, 0, 0,
+ /* 251 */ 0, 0, 0,
+ /* 252 */ 0, 0, 0,
+ /* 253 */ 0, 0, 0,
+ /* 254 */ 0, 0, 0,
+ /* 255 */ 0, 0, 0
+};
+
+#endif /* WINKEYBD_H */
diff --git a/xorg-server/hw/xwin/winkeyhook.c b/xorg-server/hw/xwin/winkeyhook.c
index 2d6ed18b7..82e30df88 100644
--- a/xorg-server/hw/xwin/winkeyhook.c
+++ b/xorg-server/hw/xwin/winkeyhook.c
@@ -94,9 +94,6 @@ winKeyboardMessageHookLL (int iCode, WPARAM wParam, LPARAM lParam)
/* Pass keystrokes on to our main message loop */
if (iCode == HC_ACTION)
{
-#if 0
- ErrorF ("vkCode: %08x\tscanCode: %08x\n", p->vkCode, p->scanCode);
-#endif
switch (wParam)
{
diff --git a/xorg-server/hw/xwin/winlayouts.h b/xorg-server/hw/xwin/winlayouts.h
index d1d21a12d..193cc1a41 100644
--- a/xorg-server/hw/xwin/winlayouts.h
+++ b/xorg-server/hw/xwin/winlayouts.h
@@ -61,6 +61,7 @@ WinKBLayoutRec winKBLayouts[] =
{ 0x40b, -1, "pc105", "fi", NULL, NULL, "Finnish"},
{ 0x40c, -1, "pc105", "fr", NULL, NULL, "French (Standard)"},
{ 0x80c, -1, "pc105", "be", NULL, NULL, "French (Belgian)"},
+ {0x1080c, -1, "pc105", "be", NULL, NULL, "Belgian (Comma)"},
{ 0xc0c, -1, "pc105", "ca", "fr", NULL, "French (Canada)"},
{ 0x100c, -1, "pc105", "ch", "fr", NULL, "French (Switzerland)"},
{ 0x40d, -1, "pc105", "il", NULL, NULL, "Hebrew"},
@@ -163,6 +164,7 @@ Support ID XKB Language
Finnish (with Sami)
X 0x040c fr French (Standard)
X 0x080c be French (Belgian)
+ X 0x1080c be Belgian (Comma)
. 0x0c0c French (Canadian)
French (Canadian, Legacy)
Canadian (Multilingual)
diff --git a/xorg-server/hw/xwin/winmisc.c b/xorg-server/hw/xwin/winmisc.c
index 8e6698118..a5a2d3d1c 100644
--- a/xorg-server/hw/xwin/winmisc.c
+++ b/xorg-server/hw/xwin/winmisc.c
@@ -44,7 +44,7 @@ void
winQueryBestSizeNativeGDI (int class, unsigned short *pWidth,
unsigned short *pHeight, ScreenPtr pScreen)
{
- ErrorF ("winQueryBestSizeNativeGDI\n");
+ winDebug ("winQueryBestSizeNativeGDI\n");
}
#endif
diff --git a/xorg-server/hw/xwin/winmouse.c b/xorg-server/hw/xwin/winmouse.c
index 342f20d56..c5069d630 100644
--- a/xorg-server/hw/xwin/winmouse.c
+++ b/xorg-server/hw/xwin/winmouse.c
@@ -1,388 +1,385 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, 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 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 XFREE86 PROJECT 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 XFree86 Project
- *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 XFree86 Project.
- *
- * Authors: Dakshinamurthy Karra
- * Suhaib M Siddiqi
- * Peter Busch
- * Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-#if defined(XFree86Server)
-#include "inputstr.h"
-#include "exevents.h" /* for button/axes labels */
-#include "xserver-properties.h"
-
-/* Peek the internal button mapping */
-static CARD8 const *g_winMouseButtonMap = NULL;
-#endif
-
-
-/*
- * Local prototypes
- */
-
-static void
-winMouseCtrl (DeviceIntPtr pDevice, PtrCtrl *pCtrl);
-
-
-static void
-winMouseCtrl (DeviceIntPtr pDevice, PtrCtrl *pCtrl)
-{
-}
-
-
-/*
- * See Porting Layer Definition - p. 18
- * This is known as a DeviceProc
- */
-
-int
-winMouseProc (DeviceIntPtr pDeviceInt, int iState)
-{
- int lngMouseButtons, i;
- int lngWheelEvents = 2;
- CARD8 *map;
- DevicePtr pDevice = (DevicePtr) pDeviceInt;
- Atom *btn_labels;
- Atom axes_labels[2];
-
- switch (iState)
- {
- case DEVICE_INIT:
- /* Get number of mouse buttons */
- lngMouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS);
-
- /* Mapping of windows events to X events:
- * LEFT:1 MIDDLE:2 RIGHT:3
- * SCROLL_UP:4 SCROLL_DOWN:5
- * XBUTTON 1:6 XBUTTON 2:7 ...
- *
- * To map scroll wheel correctly we need at least the 3 normal buttons
- */
- if (lngMouseButtons < 3)
- lngMouseButtons = 3;
- winMsg(X_PROBED, "%d mouse buttons found\n", lngMouseButtons);
-
- /* allocate memory:
- * number of buttons + 2x mouse wheel event + 1 extra (offset for map)
- */
- map = malloc(sizeof(CARD8) * (lngMouseButtons + lngWheelEvents + 1));
-
- /* initalize button map */
- map[0] = 0;
- for (i=1; i <= lngMouseButtons + lngWheelEvents; i++)
- map[i] = i;
-
- btn_labels = calloc((lngMouseButtons + lngWheelEvents), sizeof(Atom));
- btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
- btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
- btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
- btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
- btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
-
- axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
- axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
-
- InitPointerDeviceStruct (pDevice,
- map,
- lngMouseButtons + lngWheelEvents,
- btn_labels,
- winMouseCtrl,
- GetMotionHistorySize(),
- 2,
- axes_labels);
- free(map);
- free(btn_labels);
-
-#if defined(XFree86Server)
- g_winMouseButtonMap = pDeviceInt->button->map;
-#endif
- break;
-
- case DEVICE_ON:
- pDevice->on = TRUE;
- break;
-
- case DEVICE_CLOSE:
-#if defined(XFree86Server)
- g_winMouseButtonMap = NULL;
-#endif
- case DEVICE_OFF:
- pDevice->on = FALSE;
- break;
- }
- return Success;
-}
-
-
-/* Handle the mouse wheel */
-int
-winMouseWheel (ScreenPtr pScreen, int iDeltaZ)
-{
- winScreenPriv(pScreen);
- int button; /* Button4 or Button5 */
-
- /* Button4 = WheelUp */
- /* Button5 = WheelDown */
-
- /* Do we have any previous delta stored? */
- if ((pScreenPriv->iDeltaZ > 0
- && iDeltaZ > 0)
- || (pScreenPriv->iDeltaZ < 0
- && iDeltaZ < 0))
- {
- /* Previous delta and of same sign as current delta */
- iDeltaZ += pScreenPriv->iDeltaZ;
- pScreenPriv->iDeltaZ = 0;
- }
- else
- {
- /*
- * Previous delta of different sign, or zero.
- * We will set it to zero for either case,
- * as blindly setting takes just as much time
- * as checking, then setting if necessary :)
- */
- pScreenPriv->iDeltaZ = 0;
- }
-
- /*
- * Only process this message if the wheel has moved further than
- * WHEEL_DELTA
- */
- if (iDeltaZ >= WHEEL_DELTA || (-1 * iDeltaZ) >= WHEEL_DELTA)
- {
- pScreenPriv->iDeltaZ = 0;
-
- /* Figure out how many whole deltas of the wheel we have */
- iDeltaZ /= WHEEL_DELTA;
- }
- else
- {
- /*
- * Wheel has not moved past WHEEL_DELTA threshold;
- * we will store the wheel delta until the threshold
- * has been reached.
- */
- pScreenPriv->iDeltaZ = iDeltaZ;
- return 0;
- }
-
- /* Set the button to indicate up or down wheel delta */
- if (iDeltaZ > 0)
- {
- button = Button4;
- }
- else
- {
- button = Button5;
- }
-
- /*
- * Flip iDeltaZ to positive, if negative,
- * because always need to generate a *positive* number of
- * button clicks for the Z axis.
- */
- if (iDeltaZ < 0)
- {
- iDeltaZ *= -1;
- }
-
- /* Generate X input messages for each wheel delta we have seen */
- while (iDeltaZ--)
- {
- /* Push the wheel button */
- winMouseButtonsSendEvent (ButtonPress, button);
-
- /* Release the wheel button */
- winMouseButtonsSendEvent (ButtonRelease, button);
- }
-
- return 0;
-}
-
-
-/*
- * Enqueue a mouse button event
- */
-
-void
-winMouseButtonsSendEvent (int iEventType, int iButton)
-{
- EventListPtr events;
- int i, nevents;
-
-#if defined(XFree86Server)
- if (g_winMouseButtonMap)
- iButton = g_winMouseButtonMap[iButton];
-#endif
-
- GetEventList(&events);
- nevents = GetPointerEvents(events, g_pwinPointer, iEventType, iButton,
- POINTER_RELATIVE, 0, 0, NULL);
-
- for (i = 0; i < nevents; i++)
- mieqEnqueue(g_pwinPointer, events[i].event);
-
-#if CYGDEBUG
- ErrorF("winMouseButtonsSendEvent: iEventType: %d, iButton: %d, nEvents %d\n",
- iEventType, iButton, nevents);
-#endif
-}
-
-
-/*
- * Decide what to do with a Windows mouse message
- */
-
-int
-winMouseButtonsHandle (ScreenPtr pScreen,
- int iEventType, int iButton,
- WPARAM wParam)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Send button events right away if emulate 3 buttons is off */
- if (pScreenInfo->iE3BTimeout == WIN_E3B_OFF)
- {
- /* Emulate 3 buttons is off, send the button event */
- winMouseButtonsSendEvent (iEventType, iButton);
- return 0;
- }
-
- /* Emulate 3 buttons is on, let the fun begin */
- if (iEventType == ButtonPress
- && pScreenPriv->iE3BCachedPress == 0
- && !pScreenPriv->fE3BFakeButton2Sent)
- {
- /*
- * Button was pressed, no press is cached,
- * and there is no fake button 2 release pending.
- */
-
- /* Store button press type */
- pScreenPriv->iE3BCachedPress = iButton;
-
- /*
- * Set a timer to send this button press if the other button
- * is not pressed within the timeout time.
- */
- SetTimer (pScreenPriv->hwndScreen,
- WIN_E3B_TIMER_ID,
- pScreenInfo->iE3BTimeout,
- NULL);
- }
- else if (iEventType == ButtonPress
- && pScreenPriv->iE3BCachedPress != 0
- && pScreenPriv->iE3BCachedPress != iButton
- && !pScreenPriv->fE3BFakeButton2Sent)
- {
- /*
- * Button press is cached, other button was pressed,
- * and there is no fake button 2 release pending.
- */
-
- /* Mouse button was cached and other button was pressed */
- KillTimer (pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID);
- pScreenPriv->iE3BCachedPress = 0;
-
- /* Send fake middle button */
- winMouseButtonsSendEvent (ButtonPress, Button2);
-
- /* Indicate that a fake middle button event was sent */
- pScreenPriv->fE3BFakeButton2Sent = TRUE;
- }
- else if (iEventType == ButtonRelease
- && pScreenPriv->iE3BCachedPress == iButton)
- {
- /*
- * Cached button was released before timer ran out,
- * and before the other mouse button was pressed.
- */
- KillTimer (pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID);
- pScreenPriv->iE3BCachedPress = 0;
-
- /* Send cached press, then send release */
- winMouseButtonsSendEvent (ButtonPress, iButton);
- winMouseButtonsSendEvent (ButtonRelease, iButton);
- }
- else if (iEventType == ButtonRelease
- && pScreenPriv->fE3BFakeButton2Sent
- && !(wParam & MK_LBUTTON)
- && !(wParam & MK_RBUTTON))
- {
- /*
- * Fake button 2 was sent and both mouse buttons have now been released
- */
- pScreenPriv->fE3BFakeButton2Sent = FALSE;
-
- /* Send middle mouse button release */
- winMouseButtonsSendEvent (ButtonRelease, Button2);
- }
- else if (iEventType == ButtonRelease
- && pScreenPriv->iE3BCachedPress == 0
- && !pScreenPriv->fE3BFakeButton2Sent)
- {
- /*
- * Button was release, no button is cached,
- * and there is no fake button 2 release is pending.
- */
- winMouseButtonsSendEvent (ButtonRelease, iButton);
- }
-
- return 0;
-}
-
-/**
- * Enqueue a motion event.
- *
- * XXX: miPointerMove does exactly this, but is static :-( (and uses a static buffer)
- *
- */
-void winEnqueueMotion(int x, int y)
-{
- int i, nevents;
- int valuators[2];
- EventListPtr events;
-
- miPointerSetPosition(g_pwinPointer, &x, &y);
- valuators[0] = x;
- valuators[1] = y;
-
- GetEventList(&events);
- nevents = GetPointerEvents(events, g_pwinPointer, MotionNotify, 0,
- POINTER_ABSOLUTE | POINTER_SCREEN, 0, 2, valuators);
-
- for (i = 0; i < nevents; i++)
- mieqEnqueue(g_pwinPointer, events[i].event);
-}
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, 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 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 XFREE86 PROJECT 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 XFree86 Project
+ *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 XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+#ifdef XKB
+#ifndef XKB_IN_SERVER
+#define XKB_IN_SERVER
+#endif
+#include <xkbsrv.h>
+#endif
+
+#include "inputstr.h"
+#include "exevents.h" /* for button/axes labels */
+#include "xserver-properties.h"
+
+/* Peek the internal button mapping */
+static CARD8 const *g_winMouseButtonMap = NULL;
+
+
+/*
+ * Local prototypes
+ */
+
+static void
+winMouseCtrl (DeviceIntPtr pDevice, PtrCtrl *pCtrl);
+
+
+static void
+winMouseCtrl (DeviceIntPtr pDevice, PtrCtrl *pCtrl)
+{
+}
+
+
+/*
+ * See Porting Layer Definition - p. 18
+ * This is known as a DeviceProc
+ */
+
+int
+winMouseProc (DeviceIntPtr pDeviceInt, int iState)
+{
+ int lngMouseButtons, i;
+ int lngWheelEvents = 2;
+ CARD8 *map;
+ DevicePtr pDevice = (DevicePtr) pDeviceInt;
+ Atom *btn_labels;
+ Atom axes_labels[2];
+
+ switch (iState)
+ {
+ case DEVICE_INIT:
+ /* Get number of mouse buttons */
+ lngMouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS);
+
+ /* Mapping of windows events to X events:
+ * LEFT:1 MIDDLE:2 RIGHT:3
+ * SCROLL_UP:4 SCROLL_DOWN:5
+ * XBUTTON 1:6 XBUTTON 2:7 ...
+ *
+ * To map scroll wheel correctly we need at least the 3 normal buttons
+ */
+ if (lngMouseButtons < 3)
+ lngMouseButtons = 3;
+ winDebug("%d mouse buttons found\n", lngMouseButtons);
+
+ /* allocate memory:
+ * number of buttons + 2x mouse wheel event + 1 extra (offset for map)
+ */
+ map = malloc(sizeof(CARD8) * (lngMouseButtons + lngWheelEvents + 1));
+
+ /* initalize button map */
+ map[0] = 0;
+ for (i=1; i <= lngMouseButtons + lngWheelEvents; i++)
+ map[i] = i;
+
+ btn_labels = calloc((lngMouseButtons + lngWheelEvents), sizeof(Atom));
+ btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
+ btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
+ btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
+ btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
+ btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
+
+ axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
+ axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+
+ InitPointerDeviceStruct (pDevice,
+ map,
+ lngMouseButtons + lngWheelEvents,
+ btn_labels,
+ winMouseCtrl,
+ GetMotionHistorySize(),
+ 2,
+ axes_labels);
+ free(map);
+ free(btn_labels);
+
+ g_winMouseButtonMap = pDeviceInt->button->map;
+ break;
+
+ case DEVICE_ON:
+ pDevice->on = TRUE;
+ break;
+
+ case DEVICE_CLOSE:
+ g_winMouseButtonMap = NULL;
+ case DEVICE_OFF:
+ pDevice->on = FALSE;
+ break;
+ }
+ return Success;
+}
+
+
+/* Handle the mouse wheel */
+int
+winMouseWheel (ScreenPtr pScreen, int iDeltaZ)
+{
+ winScreenPriv(pScreen);
+ int button; /* Button4 or Button5 */
+
+ /* Button4 = WheelUp */
+ /* Button5 = WheelDown */
+
+ /* Do we have any previous delta stored? */
+ if ((pScreenPriv->iDeltaZ > 0
+ && iDeltaZ > 0)
+ || (pScreenPriv->iDeltaZ < 0
+ && iDeltaZ < 0))
+ {
+ /* Previous delta and of same sign as current delta */
+ iDeltaZ += pScreenPriv->iDeltaZ;
+ pScreenPriv->iDeltaZ = 0;
+ }
+ else
+ {
+ /*
+ * Previous delta of different sign, or zero.
+ * We will set it to zero for either case,
+ * as blindly setting takes just as much time
+ * as checking, then setting if necessary :)
+ */
+ pScreenPriv->iDeltaZ = 0;
+ }
+
+ /*
+ * Only process this message if the wheel has moved further than
+ * WHEEL_DELTA
+ */
+ if (iDeltaZ >= WHEEL_DELTA || (-1 * iDeltaZ) >= WHEEL_DELTA)
+ {
+ pScreenPriv->iDeltaZ = 0;
+
+ /* Figure out how many whole deltas of the wheel we have */
+ iDeltaZ /= WHEEL_DELTA;
+ }
+ else
+ {
+ /*
+ * Wheel has not moved past WHEEL_DELTA threshold;
+ * we will store the wheel delta until the threshold
+ * has been reached.
+ */
+ pScreenPriv->iDeltaZ = iDeltaZ;
+ return 0;
+ }
+
+ /* Set the button to indicate up or down wheel delta */
+ if (iDeltaZ > 0)
+ {
+ button = Button4;
+ }
+ else
+ {
+ button = Button5;
+ }
+
+ /*
+ * Flip iDeltaZ to positive, if negative,
+ * because always need to generate a *positive* number of
+ * button clicks for the Z axis.
+ */
+ if (iDeltaZ < 0)
+ {
+ iDeltaZ *= -1;
+ }
+
+ /* Generate X input messages for each wheel delta we have seen */
+ while (iDeltaZ--)
+ {
+ /* Push the wheel button */
+ winMouseButtonsSendEvent (ButtonPress, button);
+
+ /* Release the wheel button */
+ winMouseButtonsSendEvent (ButtonRelease, button);
+ }
+
+ return 0;
+}
+
+
+/*
+ * Enqueue a mouse button event
+ */
+
+void
+winMouseButtonsSendEvent (int iEventType, int iButton)
+{
+ EventListPtr events;
+ int i, nevents;
+
+ if (g_winMouseButtonMap)
+ iButton = g_winMouseButtonMap[iButton];
+
+ GetEventList(&events);
+ nevents = GetPointerEvents(events, g_pwinPointer, iEventType, iButton,
+ POINTER_RELATIVE, 0, 0, NULL);
+
+ for (i = 0; i < nevents; i++)
+ mieqEnqueue(g_pwinPointer, (InternalEvent*)(events + i)->event);
+
+ winDebug("winMouseButtonsSendEvent: iEventType: %d, iButton: %d, nEvents %d\n",
+ iEventType, iButton, nevents);
+}
+
+
+/*
+ * Decide what to do with a Windows mouse message
+ */
+
+int
+winMouseButtonsHandle (ScreenPtr pScreen,
+ int iEventType, int iButton,
+ WPARAM wParam)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Send button events right away if emulate 3 buttons is off */
+ if (pScreenInfo->iE3BTimeout == WIN_E3B_OFF)
+ {
+ /* Emulate 3 buttons is off, send the button event */
+ winMouseButtonsSendEvent (iEventType, iButton);
+ return 0;
+ }
+
+ /* Emulate 3 buttons is on, let the fun begin */
+ if (iEventType == ButtonPress
+ && pScreenPriv->iE3BCachedPress == 0
+ && !pScreenPriv->fE3BFakeButton2Sent)
+ {
+ /*
+ * Button was pressed, no press is cached,
+ * and there is no fake button 2 release pending.
+ */
+
+ /* Store button press type */
+ pScreenPriv->iE3BCachedPress = iButton;
+
+ /*
+ * Set a timer to send this button press if the other button
+ * is not pressed within the timeout time.
+ */
+ SetTimer (pScreenPriv->hwndScreen,
+ WIN_E3B_TIMER_ID,
+ pScreenInfo->iE3BTimeout,
+ NULL);
+ }
+ else if (iEventType == ButtonPress
+ && pScreenPriv->iE3BCachedPress != 0
+ && pScreenPriv->iE3BCachedPress != iButton
+ && !pScreenPriv->fE3BFakeButton2Sent)
+ {
+ /*
+ * Button press is cached, other button was pressed,
+ * and there is no fake button 2 release pending.
+ */
+
+ /* Mouse button was cached and other button was pressed */
+ KillTimer (pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID);
+ pScreenPriv->iE3BCachedPress = 0;
+
+ /* Send fake middle button */
+ winMouseButtonsSendEvent (ButtonPress, Button2);
+
+ /* Indicate that a fake middle button event was sent */
+ pScreenPriv->fE3BFakeButton2Sent = TRUE;
+ }
+ else if (iEventType == ButtonRelease
+ && pScreenPriv->iE3BCachedPress == iButton)
+ {
+ /*
+ * Cached button was released before timer ran out,
+ * and before the other mouse button was pressed.
+ */
+ KillTimer (pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID);
+ pScreenPriv->iE3BCachedPress = 0;
+
+ /* Send cached press, then send release */
+ winMouseButtonsSendEvent (ButtonPress, iButton);
+ winMouseButtonsSendEvent (ButtonRelease, iButton);
+ }
+ else if (iEventType == ButtonRelease
+ && pScreenPriv->fE3BFakeButton2Sent
+ && !(wParam & MK_LBUTTON)
+ && !(wParam & MK_RBUTTON))
+ {
+ /*
+ * Fake button 2 was sent and both mouse buttons have now been released
+ */
+ pScreenPriv->fE3BFakeButton2Sent = FALSE;
+
+ /* Send middle mouse button release */
+ winMouseButtonsSendEvent (ButtonRelease, Button2);
+ }
+ else if (iEventType == ButtonRelease
+ && pScreenPriv->iE3BCachedPress == 0
+ && !pScreenPriv->fE3BFakeButton2Sent)
+ {
+ /*
+ * Button was release, no button is cached,
+ * and there is no fake button 2 release is pending.
+ */
+ winMouseButtonsSendEvent (ButtonRelease, iButton);
+ }
+
+ return 0;
+}
+
+/**
+ * Enqueue a motion event.
+ *
+ * XXX: miPointerMove does exactly this, but is static :-( (and uses a static buffer)
+ *
+ */
+void winEnqueueMotion(int x, int y)
+{
+ int i, nevents;
+ int valuators[2];
+ EventListPtr events;
+
+ miPointerSetPosition(g_pwinPointer, &x, &y);
+ valuators[0] = x;
+ valuators[1] = y;
+
+ GetEventList(&events);
+ nevents = GetPointerEvents(events, g_pwinPointer, MotionNotify, 0,
+ POINTER_ABSOLUTE | POINTER_SCREEN, 0, 2, valuators);
+
+ for (i = 0; i < nevents; i++)
+ mieqEnqueue(g_pwinPointer, (InternalEvent*)(events + i)->event);
+}
diff --git a/xorg-server/hw/xwin/winmsg.c b/xorg-server/hw/xwin/winmsg.c
index d0464f71b..a77fde299 100644
--- a/xorg-server/hw/xwin/winmsg.c
+++ b/xorg-server/hw/xwin/winmsg.c
@@ -33,71 +33,12 @@
#endif
#include "win.h"
#include "winmsg.h"
-#if CYGDEBUG
+#ifdef WINDBG
#include "winmessages.h"
#endif
#include <stdarg.h>
-void winVMsg (int, MessageType, int verb, const char *, va_list);
-
-void
-winVMsg (int scrnIndex, MessageType type, int verb, const char *format,
- va_list ap)
-{
- LogVMessageVerb(type, verb, format, ap);
-}
-
-
-void
-winDrvMsg (int scrnIndex, MessageType type, const char *format, ...)
-{
- va_list ap;
- va_start (ap, format);
- LogVMessageVerb(type, 0, format, ap);
- va_end (ap);
-}
-
-
-void
-winMsg (MessageType type, const char *format, ...)
-{
- va_list ap;
- va_start (ap, format);
- LogVMessageVerb(type, 1, format, ap);
- va_end (ap);
-}
-
-
-void
-winDrvMsgVerb (int scrnIndex, MessageType type, int verb, const char *format,
- ...)
-{
- va_list ap;
- va_start (ap, format);
- LogVMessageVerb(type, verb, format, ap);
- va_end (ap);
-}
-
-
-void
-winMsgVerb (MessageType type, int verb, const char *format, ...)
-{
- va_list ap;
- va_start (ap, format);
- LogVMessageVerb(type, verb, format, ap);
- va_end (ap);
-}
-
-
-void
-winErrorFVerb (int verb, const char *format, ...)
-{
- va_list ap;
- va_start (ap, format);
- LogVMessageVerb(X_NONE, verb, format, ap);
- va_end (ap);
-}
-
+#ifdef WINDBG
void
winDebug (const char *format, ...)
{
@@ -106,24 +47,16 @@ winDebug (const char *format, ...)
LogVMessageVerb(X_NONE, 3, format, ap);
va_end (ap);
}
+#endif
void
-winTrace (const char *format, ...)
-{
- va_list ap;
- va_start (ap, format);
- LogVMessageVerb(X_NONE, 10, format, ap);
- va_end (ap);
-}
-
-void
-winW32Error(int verb, const char *msg)
+winW32Error(const char *msg)
{
- winW32ErrorEx(verb, msg, GetLastError());
+ winW32ErrorEx(msg, GetLastError());
}
void
-winW32ErrorEx(int verb, const char *msg, DWORD errorcode)
+winW32ErrorEx(const char *msg, DWORD errorcode)
{
LPVOID buffer;
if (!FormatMessage(
@@ -137,16 +70,17 @@ winW32ErrorEx(int verb, const char *msg, DWORD errorcode)
0,
NULL ))
{
- winErrorFVerb(verb, "Unknown error in FormatMessage!\n");
+ ErrorF(msg);
+ ErrorF("Unknown error in FormatMessage!\n");
}
else
{
- winErrorFVerb(verb, "%s %s", msg, (char *)buffer);
+ ErrorF("%s %s", msg, (char *)buffer);
LocalFree(buffer);
}
}
-#if CYGDEBUG
+#ifdef WINDBG
void winDebugWin32Message(const char* function, HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static int force = 0;
@@ -172,8 +106,4 @@ void winDebugWin32Message(const char* function, HWND hwnd, UINT message, WPARAM
}
}
}
-#else
-void winDebugWin32Message(const char* function, HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
-}
#endif
diff --git a/xorg-server/hw/xwin/winmsg.h b/xorg-server/hw/xwin/winmsg.h
index 611dd6962..ecee86994 100644
--- a/xorg-server/hw/xwin/winmsg.h
+++ b/xorg-server/hw/xwin/winmsg.h
@@ -33,18 +33,19 @@
/*
* Function prototypes
*/
+
+#include "os.h"
-void winDrvMsgVerb (int scrnIndex,
- MessageType type, int verb, const char *format, ...);
-void winDrvMsg (int scrnIndex, MessageType type, const char *format, ...);
-void winMsgVerb (MessageType type, int verb, const char *format, ...);
-void winMsg (MessageType type, const char *format, ...);
+#if !defined(_MSC_VER) || defined(_DEBUG)
+#define WINDBG
void winDebug (const char *format, ...);
-void winTrace (const char *format, ...);
-
-void winErrorFVerb (int verb, const char *format, ...);
-void winW32Error(int verb, const char *message);
-void winW32ErrorEx(int verb, const char *message, DWORD errorcode);
void winDebugWin32Message(const char* function, HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
+#else
+#define winDebug(...)
+#define winDebugWin32Message(...)
+#endif
+
+void winW32Error(const char *message);
+void winW32ErrorEx(const char *message, DWORD errorcode);
#endif
diff --git a/xorg-server/hw/xwin/winmultiwindowicons.c b/xorg-server/hw/xwin/winmultiwindowicons.c
index cb27d2fe3..89acf72be 100644
--- a/xorg-server/hw/xwin/winmultiwindowicons.c
+++ b/xorg-server/hw/xwin/winmultiwindowicons.c
@@ -1,649 +1,649 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, 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 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 XFREE86 PROJECT 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 XFree86 Project
- *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 XFree86 Project.
- *
- * Authors: Earle F. Philhower, III
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-#include "dixevents.h"
-#include "winmultiwindowclass.h"
-#include "winprefs.h"
-
-#include "propertyst.h"
-
-#include "propertyst.h"
-#include "windowstr.h"
-
-/*
- * External global variables
- */
-
-extern HICON g_hIconX;
-extern HICON g_hSmallIconX;
-
-
-/*
- * Prototypes for local functions
- */
-
-static void
-winScaleXBitmapToWindows (int iconSize, int effBPP,
- PixmapPtr pixmap, unsigned char *image);
-
-
-/*
- * Scale an X icon bitmap into a Windoze icon bitmap
- */
-
-static void
-winScaleXBitmapToWindows (int iconSize,
- int effBPP,
- PixmapPtr pixmap,
- unsigned char *image)
-{
- int row, column, effXBPP, effXDepth;
- unsigned char *outPtr;
- char *iconData = 0;
- int stride, xStride;
- float factX, factY;
- int posX, posY;
- unsigned char *ptr;
- unsigned int zero;
- unsigned int color;
-
- effXBPP = BitsPerPixel(pixmap->drawable.depth);
- effXDepth = pixmap->drawable.depth;
-
- if (pixmap->drawable.bitsPerPixel == 15)
- effXBPP = 16;
-
- if (pixmap->drawable.depth == 15)
- effXDepth = 16;
-
- /* Need 16-bit aligned rows for DDBitmaps */
- stride = ((iconSize * effBPP + 15) & (~15)) / 8;
- xStride = PixmapBytePad (pixmap->drawable.width, pixmap->drawable.depth);
- if (stride == 0 || xStride == 0)
- {
- ErrorF ("winScaleXBitmapToWindows - stride or xStride is zero. "
- "Bailing.\n");
- return;
- }
-
- /* Allocate memory for icon data */
- iconData = malloc (xStride * pixmap->drawable.height);
- if (!iconData)
- {
- ErrorF ("winScaleXBitmapToWindows - malloc failed for iconData. "
- "Bailing.\n");
- return;
- }
-
- /* Get icon data */
- miGetImage ((DrawablePtr) &(pixmap->drawable), 0, 0,
- pixmap->drawable.width, pixmap->drawable.height,
- ZPixmap, 0xffffffff, iconData);
-
- /* Keep aspect ratio */
- factX = ((float)pixmap->drawable.width) / ((float)iconSize);
- factY = ((float)pixmap->drawable.height) / ((float)iconSize);
- if (factX > factY)
- factY = factX;
- else
- factX = factY;
-
- /* Out-of-bounds, fill icon with zero */
- zero = 0;
-
- for (row = 0; row < iconSize; row++)
- {
- outPtr = image + stride * row;
- for (column = 0; column < iconSize; column++)
- {
- posX = factX * column;
- posY = factY * row;
-
- ptr = (unsigned char*) iconData + posY*xStride;
- if (effXBPP == 1)
- {
- ptr += posX / 8;
-
- /* Out of X icon bounds, leave space blank */
- if (posX >= pixmap->drawable.width
- || posY >= pixmap->drawable.height)
- ptr = (unsigned char *) &zero;
-
- if ((*ptr) & (1 << (posX & 7)))
- switch (effBPP)
- {
- case 32:
- *(outPtr++) = 0;
- case 24:
- *(outPtr++) = 0;
- case 16:
- *(outPtr++) = 0;
- case 8:
- *(outPtr++) = 0;
- break;
- case 1:
- outPtr[column / 8] &= ~(1 << (7 - (column & 7)));
- break;
- }
- else
- switch (effBPP)
- {
- case 32:
- *(outPtr++) = 255;
- *(outPtr++) = 255;
- *(outPtr++) = 255;
- *(outPtr++) = 0;
- break;
- case 24:
- *(outPtr++) = 255;
- case 16:
- *(outPtr++) = 255;
- case 8:
- *(outPtr++) = 255;
- break;
- case 1:
- outPtr[column / 8] |= (1 << (7 - (column & 7)));
- break;
- }
- }
- else if (effXDepth == 24 || effXDepth == 32)
- {
- ptr += posX * (effXBPP / 8);
-
- /* Out of X icon bounds, leave space blank */
- if (posX >= pixmap->drawable.width
- || posY >= pixmap->drawable.height)
- ptr = (unsigned char *) &zero;
- color = (((*ptr) << 16)
- + ((*(ptr + 1)) << 8)
- + ((*(ptr + 2)) << 0));
- switch (effBPP)
- {
- case 32:
- *(outPtr++) = *(ptr++); /* b */
- *(outPtr++) = *(ptr++); /* g */
- *(outPtr++) = *(ptr++); /* r */
- *(outPtr++) = (effXDepth == 32) ? *(ptr++) : 0x0; /* alpha */
- break;
- case 24:
- *(outPtr++) = *(ptr++);
- *(outPtr++) = *(ptr++);
- *(outPtr++) = *(ptr++);
- break;
- case 16:
- color = ((((*ptr) >> 2) << 10)
- + (((*(ptr + 1)) >> 2) << 5)
- + (((*(ptr + 2)) >> 2)));
- *(outPtr++) = (color >> 8);
- *(outPtr++) = (color & 255);
- break;
- case 8:
- color = (((*ptr))) + (((*(ptr + 1)))) + (((*(ptr + 2))));
- color /= 3;
- *(outPtr++) = color;
- break;
- case 1:
- if (color)
- outPtr[column / 8] |= (1 << (7 - (column & 7)));
- else
- outPtr[column / 8] &= ~(1 << (7 - (column & 7)));
- }
- }
- else if (effXDepth == 16)
- {
- ptr += posX * (effXBPP / 8);
-
- /* Out of X icon bounds, leave space blank */
- if (posX >= pixmap->drawable.width
- || posY >= pixmap->drawable.height)
- ptr = (unsigned char *) &zero;
- color = ((*ptr) << 8) + (*(ptr + 1));
- switch (effBPP)
- {
- case 32:
- *(outPtr++) = (color & 31) << 2;
- *(outPtr++) = ((color >> 5) & 31) << 2;
- *(outPtr++) = ((color >> 10) & 31) << 2;
- *(outPtr++) = 0; /* resvd */
- break;
- case 24:
- *(outPtr++) = (color & 31) << 2;
- *(outPtr++) = ((color >> 5) & 31) << 2;
- *(outPtr++) = ((color >> 10) & 31) << 2;
- break;
- case 16:
- *(outPtr++) = *(ptr++);
- *(outPtr++) = *(ptr++);
- break;
- case 8:
- *(outPtr++) = (((color & 31)
- + ((color >> 5) & 31)
- + ((color >> 10) & 31)) / 3) << 2;
- break;
- case 1:
- if (color)
- outPtr[column / 8] |= (1 << (7 - (column & 7)));
- else
- outPtr[column / 8] &= ~(1 << (7 - (column & 7)));
- break;
- } /* end switch(effbpp) */
- } /* end if effxbpp==16) */
- } /* end for column */
- } /* end for row */
- free (iconData);
-}
-
-static HICON
-NetWMToWinIconAlpha(uint32_t *icon)
-{
- int width = icon[0];
- int height = icon[1];
- uint32_t *pixels = &icon[2];
- HICON result;
- HDC hdc = GetDC(NULL);
- uint32_t *DIB_pixels;
- ICONINFO ii = {TRUE};
- BITMAPV4HEADER bmh = {sizeof(bmh)};
-
- /* Define an ARGB pixel format used for Color+Alpha icons */
- bmh.bV4Width = width;
- bmh.bV4Height = -height; /* Invert the image */
- bmh.bV4Planes = 1;
- bmh.bV4BitCount = 32;
- bmh.bV4V4Compression = BI_BITFIELDS;
- bmh.bV4AlphaMask = 0xFF000000;
- bmh.bV4RedMask = 0x00FF0000;
- bmh.bV4GreenMask = 0x0000FF00;
- bmh.bV4BlueMask = 0x000000FF;
-
- ii.hbmColor = CreateDIBSection(hdc, (BITMAPINFO*)&bmh,
- DIB_RGB_COLORS, (void**)&DIB_pixels, NULL, 0);
- ReleaseDC(NULL, hdc);
- ii.hbmMask = CreateBitmap(width, height, 1, 1, NULL);
- memcpy(DIB_pixels, pixels, height*width*4);
-
- /* CreateIconIndirect() traditionally required DDBitmaps */
- /* Systems from WinXP accept 32-bit ARGB DIBitmaps with full 8-bit alpha support */
- /* The icon is created with a DIB + empty DDB mask (an MS example does the same) */
- result = CreateIconIndirect(&ii);
-
- DeleteObject(ii.hbmColor);
- DeleteObject(ii.hbmMask);
-
- winDebug("NetWMToWinIconAlpha - %d x %d = %p\n", icon[0], icon[1], result);
- return result;
-}
-
-static HICON
-NetWMToWinIconThreshold(uint32_t *icon)
-{
- int width = icon[0];
- int height = icon[1];
- uint32_t *pixels = &icon[2];
- int row, col;
- HICON result;
- ICONINFO ii = {TRUE};
-
- HDC hdc = GetDC(NULL);
- HDC xorDC = CreateCompatibleDC(hdc);
- HDC andDC = CreateCompatibleDC(hdc);
- ii.hbmColor = CreateCompatibleBitmap(hdc, width, height);
- ii.hbmMask = CreateCompatibleBitmap(hdc, width, height);
- ReleaseDC(NULL, hdc);
- SelectObject(xorDC, ii.hbmColor);
- SelectObject(andDC, ii.hbmMask);
-
- for (row = 0; row < height; row++) {
- for (col = 0; col < width; col++) {
- if ((*pixels & 0xFF000000) > 31<<24) { /* 31 alpha threshold, i.e. opaque above, transparent below */
- SetPixelV(xorDC, col, row, RGB(((char*)pixels)[2], ((char*)pixels)[1],
- ((char*)pixels)[0]));
- SetPixelV(andDC, col, row, RGB(0, 0, 0)); /* black mask */
- }
- else {
- SetPixelV(xorDC, col, row, RGB(0, 0, 0));
- SetPixelV(andDC, col, row, RGB(255, 255, 255)); /* white mask */
- }
- pixels++;
- }
- }
- DeleteDC(xorDC);
- DeleteDC(andDC);
-
- result = CreateIconIndirect(&ii);
-
- DeleteObject(ii.hbmColor);
- DeleteObject(ii.hbmMask );
-
- winDebug("NetWMToWinIconThreshold - %d x %d = %p\n", icon[0], icon[1], result);
- return result;
-}
-
-static HICON
-NetWMToWinIcon(int bpp, uint32_t *icon)
-{
- static Bool hasIconAlphaChannel = FALSE;
- static BOOL versionChecked = FALSE;
-
- if (!versionChecked)
- {
- OSVERSIONINFOEX osvi = {0};
- ULONGLONG dwlConditionMask = 0;
-
- osvi.dwOSVersionInfoSize = sizeof (osvi);
- osvi.dwMajorVersion = 5;
- osvi.dwMinorVersion = 1;
-
- /* Windows versions later than XP have icon alpha channel suport, 2000 does not */
- VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
- VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
- hasIconAlphaChannel = VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask);
- versionChecked = TRUE;
-
- ErrorF("OS has icon alpha channel support: %s\n", hasIconAlphaChannel ? "yes" : "no");
- }
-
- if (hasIconAlphaChannel && (bpp==32))
- return NetWMToWinIconAlpha(icon);
- else
- return NetWMToWinIconThreshold(icon);
-}
-
-static pointer
-GetWindowProp(WindowPtr pWin, Atom name, long int *size_return)
-{
- struct _Window *pwin;
- struct _Property *prop;
-
- if (!pWin || !name) {
- ErrorF ("GetWindowProp - pWin or name was NULL\n");
- return 0;
- }
- pwin = (struct _Window*) pWin;
- if (!pwin->optional) return NULL;
- for (prop = (struct _Property *) pwin->optional->userProps;
- prop;
- prop=prop->next){
- if (prop->propertyName == name) {
- *size_return=prop->size;
- return prop->data;
- }
- }
- return NULL;
-}
-
-/*
- * Attempt to create a custom icon from the WM_HINTS bitmaps
- */
-
-HICON
-winXIconToHICON (WindowPtr pWin, int iconSize)
-{
- unsigned char *mask, *image, *imageMask;
- unsigned char *dst, *src;
- PixmapPtr iconPtr;
- PixmapPtr maskPtr;
- int planes, bpp, effBPP, stride, maskStride, i;
- int biggest_size = 0;
- HDC hDC;
- ICONINFO ii;
- WinXWMHints hints;
- HICON hIcon = NULL;
- uint32_t *biggest_icon = NULL;
-
- /* Try to get _NET_WM_ICON icons first */
- static Atom _XA_NET_WM_ICON;
- static int generation;
- uint32_t *icon, *icon_data = NULL;
- long int size=0;
-
- hDC = GetDC (GetDesktopWindow ());
- planes = GetDeviceCaps (hDC, PLANES);
- bpp = GetDeviceCaps (hDC, BITSPIXEL);
- ReleaseDC (GetDesktopWindow (), hDC);
-
- if (generation != serverGeneration) {
- generation = serverGeneration;
- _XA_NET_WM_ICON = MakeAtom("_NET_WM_ICON", 12, TRUE);
- }
-
- if (_XA_NET_WM_ICON) icon_data = GetWindowProp(pWin, _XA_NET_WM_ICON, &size);
- if (icon_data)
- {
- for(icon = icon_data;
- icon < &icon_data[size] && *icon;
- icon = &icon[icon[0]*icon[1]+2])
- {
- if (icon[0]==iconSize && icon[1]==iconSize)
- return NetWMToWinIcon(bpp, icon);
- /* Find the biggest icon and let Windows scale the size */
- else if (biggest_size < icon[0])
- {
- biggest_icon = icon;
- biggest_size = icon[0];
- }
- }
- if (biggest_icon)
- return NetWMToWinIcon(bpp, biggest_icon);
- }
- winDebug("winXIconToHICON - pWin %x: no suitable NetIcon\n",(int)pWin, iconSize);
-
- winMultiWindowGetWMHints (pWin, &hints);
- if (!hints.icon_pixmap) return NULL;
-
- dixLookupResourceByType((pointer) &iconPtr, hints.icon_pixmap, RT_PIXMAP,
- NullClient, DixUnknownAccess);
-
- if (!iconPtr) return NULL;
-
- /* 15 BPP is really 16BPP as far as we care */
- if (bpp == 15)
- effBPP = 16;
- else
- effBPP = bpp;
-
- /* Need 16-bit aligned rows for DDBitmaps */
- stride = ((iconSize * effBPP + 15) & (~15)) / 8;
-
- /* Mask is 1-bit deep */
- maskStride = ((iconSize * 1 + 15) & (~15)) / 8;
-
- image = malloc (stride * iconSize);
- imageMask = malloc (stride * iconSize);
- /* Default to a completely black mask */
- mask = calloc (maskStride, iconSize);
-
- winScaleXBitmapToWindows (iconSize, effBPP, iconPtr, image);
- dixLookupResourceByType((pointer) &maskPtr, hints.icon_mask, RT_PIXMAP,
- NullClient, DixUnknownAccess);
-
- if (maskPtr)
- {
- winScaleXBitmapToWindows (iconSize, 1, maskPtr, mask);
-
- winScaleXBitmapToWindows (iconSize, effBPP, maskPtr, imageMask);
-
- /* Now we need to set all bits of the icon which are not masked */
- /* on to 0 because Color is really an XOR, not an OR function */
- dst = image;
- src = imageMask;
-
- for (i = 0; i < (stride * iconSize); i++)
- if ((*(src++)))
- *(dst++) = 0;
- else
- dst++;
- }
-
- ii.fIcon = TRUE;
- ii.xHotspot = 0; /* ignored */
- ii.yHotspot = 0; /* ignored */
-
- /* Create Win32 mask from pixmap shape */
- ii.hbmMask = CreateBitmap (iconSize, iconSize, planes, 1, mask);
-
- /* Create Win32 bitmap from pixmap */
- ii.hbmColor = CreateBitmap (iconSize, iconSize, planes, bpp, image);
-
- /* Merge Win32 mask and bitmap into icon */
- hIcon = CreateIconIndirect (&ii);
-
- /* Release Win32 mask and bitmap */
- DeleteObject (ii.hbmMask);
- DeleteObject (ii.hbmColor);
-
- /* Free X mask and bitmap */
- free (mask);
- free (image);
- free (imageMask);
-
- return hIcon;
-}
-
-
-
-/*
- * Change the Windows window icon
- */
-
-#ifdef XWIN_MULTIWINDOW
-void
-winUpdateIcon (Window id)
-{
- WindowPtr pWin;
- HICON hIcon, hIconSmall=NULL, hIconOld;
-
- dixLookupResourceByType((pointer) &pWin, id, RT_WINDOW, NullClient, DixUnknownAccess);
- if (pWin)
- {
- winWindowPriv(pWin);
- if (pWinPriv->hWnd) {
- hIcon = winOverrideIcon ((unsigned long)pWin);
- if (!hIcon) {
- hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXICON));
- if (!hIcon) {
- hIcon = g_hIconX;
- hIconSmall = g_hSmallIconX;
- } else {
- /* Leave undefined if not found */
- hIconSmall = winXIconToHICON (pWin, GetSystemMetrics(SM_CXSMICON));
- }
- }
-
- /* Set the large icon */
- hIconOld = (HICON) SendMessage (pWinPriv->hWnd,
- WM_SETICON, ICON_BIG, (LPARAM) hIcon);
-
- /* Delete the icon if its not the default */
- winDestroyIcon(hIconOld);
-
- /* Same for the small icon */
- hIconOld = (HICON) SendMessage (pWinPriv->hWnd,
- WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall);
- winDestroyIcon(hIconOld);
- }
- }
-}
-
-void winInitGlobalIcons (void)
-{
- int sm_cx = GetSystemMetrics(SM_CXICON);
- int sm_cxsm = GetSystemMetrics(SM_CXSMICON);
- /* Load default X icon in case it's not ready yet */
- if (!g_hIconX)
- {
- g_hIconX = winOverrideDefaultIcon(sm_cx);
- g_hSmallIconX = winOverrideDefaultIcon(sm_cxsm);
- }
-
- if (!g_hIconX)
- {
- g_hIconX = (HICON)LoadImage (g_hInstance,
- MAKEINTRESOURCE(IDI_XWIN),
- IMAGE_ICON,
- GetSystemMetrics(SM_CXICON),
- GetSystemMetrics(SM_CYICON),
- 0);
- g_hSmallIconX = (HICON)LoadImage (g_hInstance,
- MAKEINTRESOURCE(IDI_XWIN),
- IMAGE_ICON,
- GetSystemMetrics(SM_CXSMICON),
- GetSystemMetrics(SM_CYSMICON),
- LR_DEFAULTSIZE);
- }
-}
-
-void winSelectIcons(WindowPtr pWin, HICON *pIcon, HICON *pSmallIcon)
-{
- HICON hIcon, hSmallIcon;
-
- winInitGlobalIcons();
-
- /* Try and get the icon from WM_HINTS */
- hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXICON));
- hSmallIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXSMICON));
-
- /* If we got the small, but not the large one swap them */
- if (!hIcon && hSmallIcon)
- {
- hIcon = hSmallIcon;
- hSmallIcon = NULL;
- }
-
- /* Use default X icon if no icon loaded from WM_HINTS */
- if (!hIcon) {
- hIcon = g_hIconX;
- hSmallIcon = g_hSmallIconX;
- }
-
- if (pIcon)
- *pIcon = hIcon;
- else
- winDestroyIcon(hIcon);
- if (pSmallIcon)
- *pSmallIcon = hSmallIcon;
- else
- winDestroyIcon(hSmallIcon);
-}
-
-void winDestroyIcon(HICON hIcon)
-{
- /* Delete the icon if its not the default */
- if (hIcon &&
- hIcon != g_hIconX &&
- hIcon != g_hSmallIconX &&
- !winIconIsOverride((unsigned long)hIcon))
- DestroyIcon (hIcon);
-}
-#endif
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, 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 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 XFREE86 PROJECT 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 XFree86 Project
+ *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 XFree86 Project.
+ *
+ * Authors: Earle F. Philhower, III
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "dixevents.h"
+#include "winmultiwindowclass.h"
+#include "winprefs.h"
+
+#include "propertyst.h"
+
+#include "propertyst.h"
+#include "windowstr.h"
+
+/*
+ * External global variables
+ */
+
+extern HICON g_hIconX;
+extern HICON g_hSmallIconX;
+
+
+/*
+ * Prototypes for local functions
+ */
+
+static void
+winScaleXBitmapToWindows (int iconSize, int effBPP,
+ PixmapPtr pixmap, unsigned char *image);
+
+
+/*
+ * Scale an X icon bitmap into a Windoze icon bitmap
+ */
+
+static void
+winScaleXBitmapToWindows (int iconSize,
+ int effBPP,
+ PixmapPtr pixmap,
+ unsigned char *image)
+{
+ int row, column, effXBPP, effXDepth;
+ unsigned char *outPtr;
+ char *iconData = 0;
+ int stride, xStride;
+ float factX, factY;
+ int posX, posY;
+ unsigned char *ptr;
+ unsigned int zero;
+ unsigned int color;
+
+ effXBPP = BitsPerPixel(pixmap->drawable.depth);
+ effXDepth = pixmap->drawable.depth;
+
+ if (pixmap->drawable.bitsPerPixel == 15)
+ effXBPP = 16;
+
+ if (pixmap->drawable.depth == 15)
+ effXDepth = 16;
+
+ /* Need 16-bit aligned rows for DDBitmaps */
+ stride = ((iconSize * effBPP + 15) & (~15)) / 8;
+ xStride = PixmapBytePad (pixmap->drawable.width, pixmap->drawable.depth);
+ if (stride == 0 || xStride == 0)
+ {
+ ErrorF ("winScaleXBitmapToWindows - stride or xStride is zero. "
+ "Bailing.\n");
+ return;
+ }
+
+ /* Allocate memory for icon data */
+ iconData = malloc (xStride * pixmap->drawable.height);
+ if (!iconData)
+ {
+ ErrorF ("winScaleXBitmapToWindows - malloc failed for iconData. "
+ "Bailing.\n");
+ return;
+ }
+
+ /* Get icon data */
+ miGetImage ((DrawablePtr) &(pixmap->drawable), 0, 0,
+ pixmap->drawable.width, pixmap->drawable.height,
+ ZPixmap, 0xffffffff, iconData);
+
+ /* Keep aspect ratio */
+ factX = ((float)pixmap->drawable.width) / ((float)iconSize);
+ factY = ((float)pixmap->drawable.height) / ((float)iconSize);
+ if (factX > factY)
+ factY = factX;
+ else
+ factX = factY;
+
+ /* Out-of-bounds, fill icon with zero */
+ zero = 0;
+
+ for (row = 0; row < iconSize; row++)
+ {
+ outPtr = image + stride * row;
+ for (column = 0; column < iconSize; column++)
+ {
+ posX = factX * column;
+ posY = factY * row;
+
+ ptr = (unsigned char*) iconData + posY*xStride;
+ if (effXBPP == 1)
+ {
+ ptr += posX / 8;
+
+ /* Out of X icon bounds, leave space blank */
+ if (posX >= pixmap->drawable.width
+ || posY >= pixmap->drawable.height)
+ ptr = (unsigned char *) &zero;
+
+ if ((*ptr) & (1 << (posX & 7)))
+ switch (effBPP)
+ {
+ case 32:
+ *(outPtr++) = 0;
+ case 24:
+ *(outPtr++) = 0;
+ case 16:
+ *(outPtr++) = 0;
+ case 8:
+ *(outPtr++) = 0;
+ break;
+ case 1:
+ outPtr[column / 8] &= ~(1 << (7 - (column & 7)));
+ break;
+ }
+ else
+ switch (effBPP)
+ {
+ case 32:
+ *(outPtr++) = 255;
+ *(outPtr++) = 255;
+ *(outPtr++) = 255;
+ *(outPtr++) = 0;
+ break;
+ case 24:
+ *(outPtr++) = 255;
+ case 16:
+ *(outPtr++) = 255;
+ case 8:
+ *(outPtr++) = 255;
+ break;
+ case 1:
+ outPtr[column / 8] |= (1 << (7 - (column & 7)));
+ break;
+ }
+ }
+ else if (effXDepth == 24 || effXDepth == 32)
+ {
+ ptr += posX * (effXBPP / 8);
+
+ /* Out of X icon bounds, leave space blank */
+ if (posX >= pixmap->drawable.width
+ || posY >= pixmap->drawable.height)
+ ptr = (unsigned char *) &zero;
+ color = (((*ptr) << 16)
+ + ((*(ptr + 1)) << 8)
+ + ((*(ptr + 2)) << 0));
+ switch (effBPP)
+ {
+ case 32:
+ *(outPtr++) = *(ptr++); /* b */
+ *(outPtr++) = *(ptr++); /* g */
+ *(outPtr++) = *(ptr++); /* r */
+ *(outPtr++) = (effXDepth == 32) ? *(ptr++) : 0x0; /* alpha */
+ break;
+ case 24:
+ *(outPtr++) = *(ptr++);
+ *(outPtr++) = *(ptr++);
+ *(outPtr++) = *(ptr++);
+ break;
+ case 16:
+ color = ((((*ptr) >> 2) << 10)
+ + (((*(ptr + 1)) >> 2) << 5)
+ + (((*(ptr + 2)) >> 2)));
+ *(outPtr++) = (color >> 8);
+ *(outPtr++) = (color & 255);
+ break;
+ case 8:
+ color = (((*ptr))) + (((*(ptr + 1)))) + (((*(ptr + 2))));
+ color /= 3;
+ *(outPtr++) = color;
+ break;
+ case 1:
+ if (color)
+ outPtr[column / 8] |= (1 << (7 - (column & 7)));
+ else
+ outPtr[column / 8] &= ~(1 << (7 - (column & 7)));
+ }
+ }
+ else if (effXDepth == 16)
+ {
+ ptr += posX * (effXBPP / 8);
+
+ /* Out of X icon bounds, leave space blank */
+ if (posX >= pixmap->drawable.width
+ || posY >= pixmap->drawable.height)
+ ptr = (unsigned char *) &zero;
+ color = ((*ptr) << 8) + (*(ptr + 1));
+ switch (effBPP)
+ {
+ case 32:
+ *(outPtr++) = (color & 31) << 2;
+ *(outPtr++) = ((color >> 5) & 31) << 2;
+ *(outPtr++) = ((color >> 10) & 31) << 2;
+ *(outPtr++) = 0; /* resvd */
+ break;
+ case 24:
+ *(outPtr++) = (color & 31) << 2;
+ *(outPtr++) = ((color >> 5) & 31) << 2;
+ *(outPtr++) = ((color >> 10) & 31) << 2;
+ break;
+ case 16:
+ *(outPtr++) = *(ptr++);
+ *(outPtr++) = *(ptr++);
+ break;
+ case 8:
+ *(outPtr++) = (((color & 31)
+ + ((color >> 5) & 31)
+ + ((color >> 10) & 31)) / 3) << 2;
+ break;
+ case 1:
+ if (color)
+ outPtr[column / 8] |= (1 << (7 - (column & 7)));
+ else
+ outPtr[column / 8] &= ~(1 << (7 - (column & 7)));
+ break;
+ } /* end switch(effbpp) */
+ } /* end if effxbpp==16) */
+ } /* end for column */
+ } /* end for row */
+ free (iconData);
+}
+
+static HICON
+NetWMToWinIconAlpha(uint32_t *icon)
+{
+ int width = icon[0];
+ int height = icon[1];
+ uint32_t *pixels = &icon[2];
+ HICON result;
+ HDC hdc = GetDC(NULL);
+ uint32_t *DIB_pixels;
+ ICONINFO ii = {TRUE};
+ BITMAPV4HEADER bmh = {sizeof(bmh)};
+
+ /* Define an ARGB pixel format used for Color+Alpha icons */
+ bmh.bV4Width = width;
+ bmh.bV4Height = -height; /* Invert the image */
+ bmh.bV4Planes = 1;
+ bmh.bV4BitCount = 32;
+ bmh.bV4V4Compression = BI_BITFIELDS;
+ bmh.bV4AlphaMask = 0xFF000000;
+ bmh.bV4RedMask = 0x00FF0000;
+ bmh.bV4GreenMask = 0x0000FF00;
+ bmh.bV4BlueMask = 0x000000FF;
+
+ ii.hbmColor = CreateDIBSection(hdc, (BITMAPINFO*)&bmh,
+ DIB_RGB_COLORS, (void**)&DIB_pixels, NULL, 0);
+ ReleaseDC(NULL, hdc);
+ ii.hbmMask = CreateBitmap(width, height, 1, 1, NULL);
+ memcpy(DIB_pixels, pixels, height*width*4);
+
+ /* CreateIconIndirect() traditionally required DDBitmaps */
+ /* Systems from WinXP accept 32-bit ARGB DIBitmaps with full 8-bit alpha support */
+ /* The icon is created with a DIB + empty DDB mask (an MS example does the same) */
+ result = CreateIconIndirect(&ii);
+
+ DeleteObject(ii.hbmColor);
+ DeleteObject(ii.hbmMask);
+
+ winDebug("NetWMToWinIconAlpha - %d x %d = %p\n", icon[0], icon[1], result);
+ return result;
+}
+
+static HICON
+NetWMToWinIconThreshold(uint32_t *icon)
+{
+ int width = icon[0];
+ int height = icon[1];
+ uint32_t *pixels = &icon[2];
+ int row, col;
+ HICON result;
+ ICONINFO ii = {TRUE};
+
+ HDC hdc = GetDC(NULL);
+ HDC xorDC = CreateCompatibleDC(hdc);
+ HDC andDC = CreateCompatibleDC(hdc);
+ ii.hbmColor = CreateCompatibleBitmap(hdc, width, height);
+ ii.hbmMask = CreateCompatibleBitmap(hdc, width, height);
+ ReleaseDC(NULL, hdc);
+ SelectObject(xorDC, ii.hbmColor);
+ SelectObject(andDC, ii.hbmMask);
+
+ for (row = 0; row < height; row++) {
+ for (col = 0; col < width; col++) {
+ if ((*pixels & 0xFF000000) > 31<<24) { /* 31 alpha threshold, i.e. opaque above, transparent below */
+ SetPixelV(xorDC, col, row, RGB(((char*)pixels)[2], ((char*)pixels)[1],
+ ((char*)pixels)[0]));
+ SetPixelV(andDC, col, row, RGB(0, 0, 0)); /* black mask */
+ }
+ else {
+ SetPixelV(xorDC, col, row, RGB(0, 0, 0));
+ SetPixelV(andDC, col, row, RGB(255, 255, 255)); /* white mask */
+ }
+ pixels++;
+ }
+ }
+ DeleteDC(xorDC);
+ DeleteDC(andDC);
+
+ result = CreateIconIndirect(&ii);
+
+ DeleteObject(ii.hbmColor);
+ DeleteObject(ii.hbmMask );
+
+ winDebug("NetWMToWinIconThreshold - %d x %d = %p\n", icon[0], icon[1], result);
+ return result;
+}
+
+static HICON
+NetWMToWinIcon(int bpp, uint32_t *icon)
+{
+ static Bool hasIconAlphaChannel = FALSE;
+ static BOOL versionChecked = FALSE;
+
+ if (!versionChecked)
+ {
+ OSVERSIONINFOEX osvi = {0};
+ ULONGLONG dwlConditionMask = 0;
+
+ osvi.dwOSVersionInfoSize = sizeof (osvi);
+ osvi.dwMajorVersion = 5;
+ osvi.dwMinorVersion = 1;
+
+ /* Windows versions later than XP have icon alpha channel suport, 2000 does not */
+ VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
+ VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
+ hasIconAlphaChannel = VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask);
+ versionChecked = TRUE;
+
+ winDebug("OS has icon alpha channel support: %s\n", hasIconAlphaChannel ? "yes" : "no");
+ }
+
+ if (hasIconAlphaChannel && (bpp==32))
+ return NetWMToWinIconAlpha(icon);
+ else
+ return NetWMToWinIconThreshold(icon);
+}
+
+static pointer
+GetWindowProp(WindowPtr pWin, Atom name, long int *size_return)
+{
+ struct _Window *pwin;
+ struct _Property *prop;
+
+ if (!pWin || !name) {
+ ErrorF ("GetWindowProp - pWin or name was NULL\n");
+ return 0;
+ }
+ pwin = (struct _Window*) pWin;
+ if (!pwin->optional) return NULL;
+ for (prop = (struct _Property *) pwin->optional->userProps;
+ prop;
+ prop=prop->next){
+ if (prop->propertyName == name) {
+ *size_return=prop->size;
+ return prop->data;
+ }
+ }
+ return NULL;
+}
+
+/*
+ * Attempt to create a custom icon from the WM_HINTS bitmaps
+ */
+
+HICON
+winXIconToHICON (WindowPtr pWin, int iconSize)
+{
+ unsigned char *mask, *image, *imageMask;
+ unsigned char *dst, *src;
+ PixmapPtr iconPtr;
+ PixmapPtr maskPtr;
+ int planes, bpp, effBPP, stride, maskStride, i;
+ int biggest_size = 0;
+ HDC hDC;
+ ICONINFO ii;
+ WinXWMHints hints;
+ HICON hIcon = NULL;
+ uint32_t *biggest_icon = NULL;
+
+ /* Try to get _NET_WM_ICON icons first */
+ static Atom _XA_NET_WM_ICON;
+ static int generation;
+ uint32_t *icon, *icon_data = NULL;
+ long int size=0;
+
+ hDC = GetDC (GetDesktopWindow ());
+ planes = GetDeviceCaps (hDC, PLANES);
+ bpp = GetDeviceCaps (hDC, BITSPIXEL);
+ ReleaseDC (GetDesktopWindow (), hDC);
+
+ if (generation != serverGeneration) {
+ generation = serverGeneration;
+ _XA_NET_WM_ICON = MakeAtom("_NET_WM_ICON", 12, TRUE);
+ }
+
+ if (_XA_NET_WM_ICON) icon_data = GetWindowProp(pWin, _XA_NET_WM_ICON, &size);
+ if (icon_data)
+ {
+ for(icon = icon_data;
+ icon < &icon_data[size] && *icon;
+ icon = &icon[icon[0]*icon[1]+2])
+ {
+ if (icon[0]==iconSize && icon[1]==iconSize)
+ return NetWMToWinIcon(bpp, icon);
+ /* Find the biggest icon and let Windows scale the size */
+ else if (biggest_size < icon[0])
+ {
+ biggest_icon = icon;
+ biggest_size = icon[0];
+ }
+ }
+ if (biggest_icon)
+ return NetWMToWinIcon(bpp, biggest_icon);
+ }
+ winDebug("winXIconToHICON - pWin %x: no suitable NetIcon\n",(int)pWin, iconSize);
+
+ winMultiWindowGetWMHints (pWin, &hints);
+ if (!hints.icon_pixmap) return NULL;
+
+ dixLookupResourceByType((pointer) &iconPtr, hints.icon_pixmap, RT_PIXMAP,
+ NullClient, DixUnknownAccess);
+
+ if (!iconPtr) return NULL;
+
+ /* 15 BPP is really 16BPP as far as we care */
+ if (bpp == 15)
+ effBPP = 16;
+ else
+ effBPP = bpp;
+
+ /* Need 16-bit aligned rows for DDBitmaps */
+ stride = ((iconSize * effBPP + 15) & (~15)) / 8;
+
+ /* Mask is 1-bit deep */
+ maskStride = ((iconSize * 1 + 15) & (~15)) / 8;
+
+ image = malloc (stride * iconSize);
+ imageMask = malloc (stride * iconSize);
+ /* Default to a completely black mask */
+ mask = calloc (maskStride, iconSize);
+
+ winScaleXBitmapToWindows (iconSize, effBPP, iconPtr, image);
+ dixLookupResourceByType((pointer) &maskPtr, hints.icon_mask, RT_PIXMAP,
+ NullClient, DixUnknownAccess);
+
+ if (maskPtr)
+ {
+ winScaleXBitmapToWindows (iconSize, 1, maskPtr, mask);
+
+ winScaleXBitmapToWindows (iconSize, effBPP, maskPtr, imageMask);
+
+ /* Now we need to set all bits of the icon which are not masked */
+ /* on to 0 because Color is really an XOR, not an OR function */
+ dst = image;
+ src = imageMask;
+
+ for (i = 0; i < (stride * iconSize); i++)
+ if ((*(src++)))
+ *(dst++) = 0;
+ else
+ dst++;
+ }
+
+ ii.fIcon = TRUE;
+ ii.xHotspot = 0; /* ignored */
+ ii.yHotspot = 0; /* ignored */
+
+ /* Create Win32 mask from pixmap shape */
+ ii.hbmMask = CreateBitmap (iconSize, iconSize, planes, 1, mask);
+
+ /* Create Win32 bitmap from pixmap */
+ ii.hbmColor = CreateBitmap (iconSize, iconSize, planes, bpp, image);
+
+ /* Merge Win32 mask and bitmap into icon */
+ hIcon = CreateIconIndirect (&ii);
+
+ /* Release Win32 mask and bitmap */
+ DeleteObject (ii.hbmMask);
+ DeleteObject (ii.hbmColor);
+
+ /* Free X mask and bitmap */
+ free (mask);
+ free (image);
+ free (imageMask);
+
+ return hIcon;
+}
+
+
+
+/*
+ * Change the Windows window icon
+ */
+
+#ifdef XWIN_MULTIWINDOW
+void
+winUpdateIcon (Window id)
+{
+ WindowPtr pWin;
+ HICON hIcon, hIconSmall=NULL, hIconOld;
+
+ dixLookupResourceByType((pointer) &pWin, id, RT_WINDOW, NullClient, DixUnknownAccess);
+ if (pWin)
+ {
+ winWindowPriv(pWin);
+ if (pWinPriv->hWnd) {
+ hIcon = winOverrideIcon ((unsigned long)pWin);
+ if (!hIcon) {
+ hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXICON));
+ if (!hIcon) {
+ hIcon = g_hIconX;
+ hIconSmall = g_hSmallIconX;
+ } else {
+ /* Leave undefined if not found */
+ hIconSmall = winXIconToHICON (pWin, GetSystemMetrics(SM_CXSMICON));
+ }
+ }
+
+ /* Set the large icon */
+ hIconOld = (HICON) SendMessage (pWinPriv->hWnd,
+ WM_SETICON, ICON_BIG, (LPARAM) hIcon);
+
+ /* Delete the icon if its not the default */
+ winDestroyIcon(hIconOld);
+
+ /* Same for the small icon */
+ hIconOld = (HICON) SendMessage (pWinPriv->hWnd,
+ WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall);
+ winDestroyIcon(hIconOld);
+ }
+ }
+}
+
+void winInitGlobalIcons (void)
+{
+ int sm_cx = GetSystemMetrics(SM_CXICON);
+ int sm_cxsm = GetSystemMetrics(SM_CXSMICON);
+ /* Load default X icon in case it's not ready yet */
+ if (!g_hIconX)
+ {
+ g_hIconX = winOverrideDefaultIcon(sm_cx);
+ g_hSmallIconX = winOverrideDefaultIcon(sm_cxsm);
+ }
+
+ if (!g_hIconX)
+ {
+ g_hIconX = (HICON)LoadImage (g_hInstance,
+ MAKEINTRESOURCE(IDI_XWIN),
+ IMAGE_ICON,
+ GetSystemMetrics(SM_CXICON),
+ GetSystemMetrics(SM_CYICON),
+ 0);
+ g_hSmallIconX = (HICON)LoadImage (g_hInstance,
+ MAKEINTRESOURCE(IDI_XWIN),
+ IMAGE_ICON,
+ GetSystemMetrics(SM_CXSMICON),
+ GetSystemMetrics(SM_CYSMICON),
+ LR_DEFAULTSIZE);
+ }
+}
+
+void winSelectIcons(WindowPtr pWin, HICON *pIcon, HICON *pSmallIcon)
+{
+ HICON hIcon, hSmallIcon;
+
+ winInitGlobalIcons();
+
+ /* Try and get the icon from WM_HINTS */
+ hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXICON));
+ hSmallIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXSMICON));
+
+ /* If we got the small, but not the large one swap them */
+ if (!hIcon && hSmallIcon)
+ {
+ hIcon = hSmallIcon;
+ hSmallIcon = NULL;
+ }
+
+ /* Use default X icon if no icon loaded from WM_HINTS */
+ if (!hIcon) {
+ hIcon = g_hIconX;
+ hSmallIcon = g_hSmallIconX;
+ }
+
+ if (pIcon)
+ *pIcon = hIcon;
+ else
+ winDestroyIcon(hIcon);
+ if (pSmallIcon)
+ *pSmallIcon = hSmallIcon;
+ else
+ winDestroyIcon(hSmallIcon);
+}
+
+void winDestroyIcon(HICON hIcon)
+{
+ /* Delete the icon if its not the default */
+ if (hIcon &&
+ hIcon != g_hIconX &&
+ hIcon != g_hSmallIconX &&
+ !winIconIsOverride((unsigned long)hIcon))
+ DestroyIcon (hIcon);
+}
+#endif
diff --git a/xorg-server/hw/xwin/winmultiwindowshape.c b/xorg-server/hw/xwin/winmultiwindowshape.c
index 44007027a..168a50b47 100644
--- a/xorg-server/hw/xwin/winmultiwindowshape.c
+++ b/xorg-server/hw/xwin/winmultiwindowshape.c
@@ -46,9 +46,7 @@ winSetShapeMultiWindow (WindowPtr pWin)
ScreenPtr pScreen = pWin->drawable.pScreen;
winScreenPriv(pScreen);
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winSetShapeMultiWindow - pWin: %08x\n", pWin);
-#endif
+ winDebug ("winSetShapeMultiWindow - pWin: %08x\n", pWin);
WIN_UNWRAP(SetShape);
(*pScreen->SetShape)(pWin);
@@ -71,6 +69,9 @@ winUpdateRgnMultiWindow (WindowPtr pWin)
{
SetWindowRgn (winGetWindowPriv(pWin)->hWnd,
winGetWindowPriv(pWin)->hRgn, TRUE);
+
+ /* The system now owns the region specified by the region handle and delete it when it is no longer needed. */
+ winGetWindowPriv(pWin)->hRgn = NULL;
}
@@ -87,9 +88,7 @@ winReshapeMultiWindow (WindowPtr pWin)
HRGN hRgn, hRgnRect;
winWindowPriv(pWin);
-#if CYGDEBUG
winDebug ("winReshape ()\n");
-#endif
/* Bail if the window is the root window */
if (pWin->parent == NULL)
@@ -206,3 +205,14 @@ winReshapeMultiWindow (WindowPtr pWin)
return;
}
+
+void
+winShapeRgnUpdateMultiwindow(HWND hwnd)
+{
+ WindowPtr pWin = GetProp (hwnd, WIN_WINDOW_PROP);
+ if (pWin)
+ {
+ winReshapeMultiWindow(pWin);
+ winUpdateRgnMultiWindow(pWin);
+ }
+}
diff --git a/xorg-server/hw/xwin/winmultiwindowwindow.c b/xorg-server/hw/xwin/winmultiwindowwindow.c
index 8b91296f7..26f8a2e41 100644
--- a/xorg-server/hw/xwin/winmultiwindowwindow.c
+++ b/xorg-server/hw/xwin/winmultiwindowwindow.c
@@ -1,994 +1,891 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *Copyright (C) Colin Harrison 2005-2008
- *
- *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, 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 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 XFREE86 PROJECT 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 XFree86 Project
- *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 XFree86 Project.
- *
- * Authors: Kensuke Matsuzaki
- * Earle F. Philhower, III
- * Harold L Hunt II
- * Colin Harrison
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-#include "dixevents.h"
-#include "winmultiwindowclass.h"
-#include "winprefs.h"
-
-/*
- * External global variables
- */
-
-extern HICON g_hIconX;
-extern HICON g_hSmallIconX;
-extern HWND g_hDlgDepthChange;
-
-/*
- * Prototypes for local functions
- */
-
-void
-winCreateWindowsWindow (WindowPtr pWin);
-
-static void
-winDestroyWindowsWindow (WindowPtr pWin);
-
-static void
-winUpdateWindowsWindow (WindowPtr pWin);
-
-static void
-winFindWindow (pointer value, XID id, pointer cdata);
-
-static
-void winInitMultiWindowClass(void)
-{
- static wATOM atomXWinClass=0;
- WNDCLASSEX wcx;
-
- if (atomXWinClass==0)
- {
- /* Setup our window class */
- wcx.cbSize=sizeof(WNDCLASSEX);
- wcx.style = CS_HREDRAW | CS_VREDRAW;
- wcx.lpfnWndProc = winTopLevelWindowProc;
- wcx.cbClsExtra = 0;
- wcx.cbWndExtra = 0;
- wcx.hInstance = g_hInstance;
- wcx.hIcon = g_hIconX;
- wcx.hCursor = 0;
- wcx.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
- wcx.lpszMenuName = NULL;
- wcx.lpszClassName = WINDOW_CLASS_X;
- wcx.hIconSm = g_hSmallIconX;
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winCreateWindowsWindow - Creating class: %s\n", WINDOW_CLASS_X);
-#endif
-
- atomXWinClass = RegisterClassEx (&wcx);
- }
-}
-
-/*
- * CreateWindow - See Porting Layer Definition - p. 37
- */
-
-Bool
-winCreateWindowMultiWindow (WindowPtr pWin)
-{
- Bool fResult = TRUE;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
- winScreenPriv(pScreen);
-
-#if CYGMULTIWINDOW_DEBUG
- winTrace ("winCreateWindowMultiWindow - pWin: %p\n", pWin);
-#endif
-
- WIN_UNWRAP(CreateWindow);
- fResult = (*pScreen->CreateWindow) (pWin);
- WIN_WRAP(CreateWindow, winCreateWindowMultiWindow);
-
- /* Initialize some privates values */
- pWinPriv->hRgn = NULL;
- pWinPriv->hWnd = NULL;
- pWinPriv->pScreenPriv = winGetScreenPriv(pWin->drawable.pScreen);
- pWinPriv->fXKilled = FALSE;
-
- return fResult;
-}
-
-
-/*
- * DestroyWindow - See Porting Layer Definition - p. 37
- */
-
-Bool
-winDestroyWindowMultiWindow (WindowPtr pWin)
-{
- Bool fResult = TRUE;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
- winScreenPriv(pScreen);
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winDestroyWindowMultiWindow - pWin: %p\n", pWin);
-#endif
-
- WIN_UNWRAP(DestroyWindow);
- fResult = (*pScreen->DestroyWindow)(pWin);
- WIN_WRAP(DestroyWindow, winDestroyWindowMultiWindow);
-
- /* Flag that the window has been destroyed */
- pWinPriv->fXKilled = TRUE;
-
- /* Kill the MS Windows window associated with this window */
- winDestroyWindowsWindow (pWin);
-
- return fResult;
-}
-
-
-/*
- * PositionWindow - See Porting Layer Definition - p. 37
- *
- * This function adjusts the position and size of Windows window
- * with respect to the underlying X window. This is the inverse
- * of winAdjustXWindow, which adjusts X window to Windows window.
- */
-
-Bool
-winPositionWindowMultiWindow (WindowPtr pWin, int x, int y)
-{
- Bool fResult = TRUE;
- int iX, iY, iWidth, iHeight;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
- winScreenPriv(pScreen);
-
- HWND hWnd = pWinPriv->hWnd;
- RECT rcNew;
- RECT rcOld;
-#if CYGMULTIWINDOW_DEBUG
- RECT rcClient;
- RECT *lpRc;
-#endif
- DWORD dwExStyle;
- DWORD dwStyle;
-
-#if CYGMULTIWINDOW_DEBUG
- winTrace ("winPositionWindowMultiWindow - pWin: %p\n", pWin);
-#endif
-
- WIN_UNWRAP(PositionWindow);
- fResult = (*pScreen->PositionWindow)(pWin, x, y);
- WIN_WRAP(PositionWindow, winPositionWindowMultiWindow);
-
-#if CYGWINDOWING_DEBUG
- ErrorF ("winPositionWindowMultiWindow: (x, y) = (%d, %d)\n",
- x, y);
-#endif
-
- /* Bail out if the Windows window handle is bad */
- if (!hWnd)
- {
-#if CYGWINDOWING_DEBUG
- ErrorF ("\timmediately return since hWnd is NULL\n");
-#endif
- return fResult;
- }
-
- /* Get the Windows window style and extended style */
- dwExStyle = GetWindowLongPtr (hWnd, GWL_EXSTYLE);
- dwStyle = GetWindowLongPtr (hWnd, GWL_STYLE);
-
- /* Get the X and Y location of the X window */
- iX = pWin->drawable.x + GetSystemMetrics (SM_XVIRTUALSCREEN);
- iY = pWin->drawable.y + GetSystemMetrics (SM_YVIRTUALSCREEN);
-
- /* Get the height and width of the X window */
- iWidth = pWin->drawable.width;
- iHeight = pWin->drawable.height;
-
- /* Store the origin, height, and width in a rectangle structure */
- SetRect (&rcNew, iX, iY, iX + iWidth, iY + iHeight);
-
-#if CYGMULTIWINDOW_DEBUG
- lpRc = &rcNew;
- ErrorF ("winPositionWindowMultiWindow - (%d ms)drawable (%d, %d)-(%d, %d)\n",
- GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom);
-#endif
-
- /*
- * Calculate the required size of the Windows window rectangle,
- * given the size of the Windows window client area.
- */
- AdjustWindowRectEx (&rcNew, dwStyle, FALSE, dwExStyle);
-
- /* Get a rectangle describing the old Windows window */
- GetWindowRect (hWnd, &rcOld);
-
-#if CYGMULTIWINDOW_DEBUG
- /* Get a rectangle describing the Windows window client area */
- GetClientRect (hWnd, &rcClient);
-
- lpRc = &rcNew;
- ErrorF ("winPositionWindowMultiWindow - (%d ms)rcNew (%d, %d)-(%d, %d)\n",
- GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom);
-
- lpRc = &rcOld;
- ErrorF ("winPositionWindowMultiWindow - (%d ms)rcOld (%d, %d)-(%d, %d)\n",
- GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom);
-
- lpRc = &rcClient;
- ErrorF ("(%d ms)rcClient (%d, %d)-(%d, %d)\n",
- GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom);
-#endif
-
- /* Check if the old rectangle and new rectangle are the same */
- if (!EqualRect (&rcNew, &rcOld))
- {
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winPositionWindowMultiWindow - Need to move\n");
-#endif
-
-#if CYGWINDOWING_DEBUG
- ErrorF ("\tMoveWindow to (%ld, %ld) - %ldx%ld\n", rcNew.left, rcNew.top,
- rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
-#endif
- /* Change the position and dimensions of the Windows window */
- MoveWindow (hWnd,
- rcNew.left, rcNew.top,
- rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
- TRUE);
- }
- else
- {
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winPositionWindowMultiWindow - Not need to move\n");
-#endif
- }
-
- return fResult;
-}
-
-
-/*
- * ChangeWindowAttributes - See Porting Layer Definition - p. 37
- */
-
-Bool
-winChangeWindowAttributesMultiWindow (WindowPtr pWin, unsigned long mask)
-{
- Bool fResult = TRUE;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winScreenPriv(pScreen);
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winChangeWindowAttributesMultiWindow - pWin: %08x\n", pWin);
-#endif
-
- WIN_UNWRAP(ChangeWindowAttributes);
- fResult = (*pScreen->ChangeWindowAttributes)(pWin, mask);
- WIN_WRAP(ChangeWindowAttributes, winChangeWindowAttributesMultiWindow);
-
- /*
- * NOTE: We do not currently need to do anything here.
- */
-
- return fResult;
-}
-
-
-/*
- * UnmapWindow - See Porting Layer Definition - p. 37
- * Also referred to as UnrealizeWindow
- */
-
-Bool
-winUnmapWindowMultiWindow (WindowPtr pWin)
-{
- Bool fResult = TRUE;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
- winScreenPriv(pScreen);
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winUnmapWindowMultiWindow - pWin: %08x\n", pWin);
-#endif
-
- WIN_UNWRAP(UnrealizeWindow);
- fResult = (*pScreen->UnrealizeWindow)(pWin);
- WIN_WRAP(UnrealizeWindow, winUnmapWindowMultiWindow);
-
- /* Flag that the window has been killed */
- pWinPriv->fXKilled = TRUE;
-
- /* Destroy the Windows window associated with this X window */
- winDestroyWindowsWindow (pWin);
-
- return fResult;
-}
-
-
-/*
- * MapWindow - See Porting Layer Definition - p. 37
- * Also referred to as RealizeWindow
- */
-
-Bool
-winMapWindowMultiWindow (WindowPtr pWin)
-{
- Bool fResult = TRUE;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
- winScreenPriv(pScreen);
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winMapWindowMultiWindow - pWin: %08x\n", pWin);
-#endif
-
- WIN_UNWRAP(RealizeWindow);
- fResult = (*pScreen->RealizeWindow)(pWin);
- WIN_WRAP(RealizeWindow, winMapWindowMultiWindow);
-
- /* Flag that this window has not been destroyed */
- pWinPriv->fXKilled = FALSE;
-
- /* Refresh/redisplay the Windows window associated with this X window */
- winUpdateWindowsWindow (pWin);
-
- /* Update the Windows window's shape */
- winReshapeMultiWindow (pWin);
- winUpdateRgnMultiWindow (pWin);
-
- return fResult;
-}
-
-
-/*
- * ReparentWindow - See Porting Layer Definition - p. 42
- */
-
-void
-winReparentWindowMultiWindow (WindowPtr pWin, WindowPtr pPriorParent)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winScreenPriv(pScreen);
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winReparentMultiWindow - pWin: %08x\n", pWin);
-#endif
-
- WIN_UNWRAP(ReparentWindow);
- if (pScreen->ReparentWindow)
- (*pScreen->ReparentWindow)(pWin, pPriorParent);
- WIN_WRAP(ReparentWindow, winReparentWindowMultiWindow);
-
- /* Update the Windows window associated with this X window */
- winUpdateWindowsWindow (pWin);
-}
-
-
-/*
- * RestackWindow - Shuffle the z-order of a window
- */
-
-void
-winRestackWindowMultiWindow (WindowPtr pWin, WindowPtr pOldNextSib)
-{
-#if 0
- WindowPtr pPrevWin;
- UINT uFlags;
- HWND hInsertAfter;
- HWND hWnd = NULL;
-#endif
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winScreenPriv(pScreen);
-
-#if CYGMULTIWINDOW_DEBUG || CYGWINDOWING_DEBUG
- winTrace ("winRestackMultiWindow - %08x\n", pWin);
-#endif
-
- WIN_UNWRAP(RestackWindow);
- if (pScreen->RestackWindow)
- (*pScreen->RestackWindow)(pWin, pOldNextSib);
- WIN_WRAP(RestackWindow, winRestackWindowMultiWindow);
-
-#if 1
- /*
- * Calling winReorderWindowsMultiWindow here means our window manager
- * (i.e. Windows Explorer) has initiative to determine Z order.
- */
- if (pWin->nextSib != pOldNextSib)
- winReorderWindowsMultiWindow ();
-#else
- /* Bail out if no window privates or window handle is invalid */
- if (!pWinPriv || !pWinPriv->hWnd)
- return;
-
- /* Get a pointer to our previous sibling window */
- pPrevWin = pWin->prevSib;
-
- /*
- * Look for a sibling window with
- * valid privates and window handle
- */
- while (pPrevWin
- && !winGetWindowPriv(pPrevWin)
- && !winGetWindowPriv(pPrevWin)->hWnd)
- pPrevWin = pPrevWin->prevSib;
-
- /* Check if we found a valid sibling */
- if (pPrevWin)
- {
- /* Valid sibling - get handle to insert window after */
- hInsertAfter = winGetWindowPriv(pPrevWin)->hWnd;
- uFlags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE;
-
- hWnd = GetNextWindow (pWinPriv->hWnd, GW_HWNDPREV);
-
- do
- {
- if (GetProp (hWnd, WIN_WINDOW_PROP))
- {
- if (hWnd == winGetWindowPriv(pPrevWin)->hWnd)
- {
- uFlags |= SWP_NOZORDER;
- }
- break;
- }
- hWnd = GetNextWindow (hWnd, GW_HWNDPREV);
- }
- while (hWnd);
- }
- else
- {
- /* No valid sibling - make this window the top window */
- hInsertAfter = HWND_TOP;
- uFlags = SWP_NOMOVE | SWP_NOSIZE;
- }
-
- /* Perform the restacking operation in Windows */
- SetWindowPos (pWinPriv->hWnd,
- hInsertAfter,
- 0, 0,
- 0, 0,
- uFlags);
-#endif
-}
-
-
-/*
- * winCreateWindowsWindow - Create a Windows window associated with an X window
- */
-
-void
-winCreateWindowsWindow (WindowPtr pWin)
-{
- int iX, iY;
- int iWidth;
- int iHeight;
- HWND hWnd;
- HWND hFore = NULL;
- winWindowPriv(pWin);
- HICON hIcon;
- HICON hIconSmall;
- winPrivScreenPtr pScreenPriv = pWinPriv->pScreenPriv;
- WinXSizeHints hints;
- WindowPtr pDaddy;
-
- winInitMultiWindowClass();
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winCreateWindowsWindow - pWin: %08x\n", pWin);
-#endif
-
- iX = pWin->drawable.x + GetSystemMetrics (SM_XVIRTUALSCREEN);
- iY = pWin->drawable.y + GetSystemMetrics (SM_YVIRTUALSCREEN);
-
- iWidth = pWin->drawable.width;
- iHeight = pWin->drawable.height;
-
- if (winMultiWindowGetTransientFor (pWin, &pDaddy))
- {
- if (pDaddy)
- {
- hFore = GetForegroundWindow();
- if (hFore && (pDaddy != (WindowPtr)GetProp(hFore, WIN_WID_PROP))) hFore = NULL;
- }
- }
- else
- {
- /* Default positions if none specified */
- if (!winMultiWindowGetWMNormalHints(pWin, &hints))
- hints.flags = 0;
- if (!(hints.flags & (USPosition|PPosition)) &&
- !pWin->overrideRedirect)
- {
- iX = CW_USEDEFAULT;
- iY = CW_USEDEFAULT;
- }
- }
-
- /* Create the window */
- /* Make it OVERLAPPED in create call since WS_POPUP doesn't support */
- /* CW_USEDEFAULT, change back to popup after creation */
- hWnd = CreateWindowExA (WS_EX_TOOLWINDOW, /* Extended styles */
- WINDOW_CLASS_X, /* Class name */
- WINDOW_TITLE_X, /* Window name */
- WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
- iX, /* Horizontal position */
- iY, /* Vertical position */
- iWidth, /* Right edge */
- iHeight, /* Bottom edge */
- hFore, /* Null or Parent window if transient*/
- (HMENU) NULL, /* No menu */
- GetModuleHandle (NULL), /* Instance handle */
- pWin); /* ScreenPrivates */
- if (hWnd == NULL)
- {
- ErrorF ("winCreateWindowsWindow - CreateWindowExA () failed: %d\n",
- (int) GetLastError ());
- }
- pWinPriv->hWnd = hWnd;
-
- /* Set application or .XWinrc defined Icons */
- winSelectIcons(pWin, &hIcon, &hIconSmall);
- if (hIcon) SendMessage (hWnd, WM_SETICON, ICON_BIG, (LPARAM) hIcon);
- if (hIconSmall) SendMessage (hWnd, WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall);
-
- /* Change style back to popup, already placed... */
- SetWindowLongPtr(hWnd, GWL_STYLE, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
- SetWindowPos (hWnd, 0, 0, 0, 0, 0,
- SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
- /* Make sure it gets the proper system menu for a WS_POPUP, too */
- GetSystemMenu (hWnd, TRUE);
-
- /* Cause any .XWinrc menus to be added in main WNDPROC */
- PostMessage (hWnd, WM_INIT_SYS_MENU, 0, 0);
-
- SetProp (hWnd, WIN_WID_PROP, (HANDLE) winGetWindowID(pWin));
-
- /* Flag that this Windows window handles its own activation */
- SetProp (hWnd, WIN_NEEDMANAGE_PROP, (HANDLE) 0);
-
- /* Call engine-specific create window procedure */
- (*pScreenPriv->pwinFinishCreateWindowsWindow) (pWin);
-}
-
-
-Bool winInDestroyWindowsWindow = FALSE;
-/*
- * winDestroyWindowsWindow - Destroy a Windows window associated
- * with an X window
- */
-static void
-winDestroyWindowsWindow (WindowPtr pWin)
-{
- MSG msg;
- winWindowPriv(pWin);
- BOOL oldstate = winInDestroyWindowsWindow;
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winDestroyWindowsWindow\n");
-#endif
-
- /* Bail out if the Windows window handle is invalid */
- if (pWinPriv->hWnd == NULL)
- return;
-
- winInDestroyWindowsWindow = TRUE;
-
- SetProp (pWinPriv->hWnd, WIN_WINDOW_PROP, NULL);
- /* Destroy the Windows window */
- DestroyWindow (pWinPriv->hWnd);
-
- /* Null our handle to the Window so referencing it will cause an error */
- pWinPriv->hWnd = NULL;
-
- /* Process all messages on our queue */
- while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
- {
- if (g_hDlgDepthChange == 0 || !IsDialogMessage (g_hDlgDepthChange, &msg))
- {
- DispatchMessage (&msg);
- }
- }
-
- winInDestroyWindowsWindow = oldstate;
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("-winDestroyWindowsWindow\n");
-#endif
-}
-
-
-/*
- * winUpdateWindowsWindow - Redisplay/redraw a Windows window
- * associated with an X window
- */
-
-static void
-winUpdateWindowsWindow (WindowPtr pWin)
-{
- winWindowPriv(pWin);
- HWND hWnd = pWinPriv->hWnd;
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winUpdateWindowsWindow\n");
-#endif
-
- /* Check if the Windows window's parents have been destroyed */
- if (pWin->parent != NULL
- && pWin->parent->parent == NULL
- && pWin->mapped)
- {
- /* Create the Windows window if it has been destroyed */
- if (hWnd == NULL)
- {
- winCreateWindowsWindow (pWin);
- assert (pWinPriv->hWnd != NULL);
- }
-
- /* Display the window without activating it */
- ShowWindow (pWinPriv->hWnd, SW_SHOWNOACTIVATE);
-
- /* Send first paint message */
- UpdateWindow (pWinPriv->hWnd);
- }
- else if (hWnd != NULL)
- {
- /* Destroy the Windows window if its parents are destroyed */
- winDestroyWindowsWindow (pWin);
- assert (pWinPriv->hWnd == NULL);
- }
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("-winUpdateWindowsWindow\n");
-#endif
-}
-
-
-/*
- * winGetWindowID -
- */
-
-XID
-winGetWindowID (WindowPtr pWin)
-{
- WindowIDPairRec wi = {pWin, 0};
- ClientPtr c = wClient(pWin);
-
- /* */
- FindClientResourcesByType (c, RT_WINDOW, winFindWindow, &wi);
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winGetWindowID - Window ID: %d\n", wi.id);
-#endif
-
- return wi.id;
-}
-
-
-/*
- * winFindWindow -
- */
-
-static void
-winFindWindow (pointer value, XID id, pointer cdata)
-{
- WindowIDPairPtr wi = (WindowIDPairPtr)cdata;
-
- if (value == wi->value)
- {
- wi->id = id;
- }
-}
-
-
-/*
- * winReorderWindowsMultiWindow -
- */
-
-void
-winReorderWindowsMultiWindow (void)
-{
- HWND hwnd = NULL;
- WindowPtr pWin = NULL;
- WindowPtr pWinSib = NULL;
- XID vlist[2];
- static Bool fRestacking = FALSE; /* Avoid recusive calls to this function */
- DWORD dwCurrentProcessID = GetCurrentProcessId ();
- DWORD dwWindowProcessID = 0;
-
-#if CYGMULTIWINDOW_DEBUG || CYGWINDOWING_DEBUG
- winTrace ("winReorderWindowsMultiWindow\n");
-#endif
-
- if (fRestacking)
- {
- /* It is a recusive call so immediately exit */
-#if CYGWINDOWING_DEBUG
- ErrorF ("winReorderWindowsMultiWindow - "
- "exit because fRestacking == TRUE\n");
-#endif
- return;
- }
- fRestacking = TRUE;
-
- /* Loop through top level Window windows, descending in Z order */
- for ( hwnd = GetTopWindow (NULL);
- hwnd;
- hwnd = GetNextWindow (hwnd, GW_HWNDNEXT) )
- {
- /* Don't take care of other Cygwin/X process's windows */
- GetWindowThreadProcessId (hwnd, &dwWindowProcessID);
-
- if ( GetProp (hwnd, WIN_WINDOW_PROP)
- && (dwWindowProcessID == dwCurrentProcessID)
- && !IsIconic (hwnd) ) /* ignore minimized windows */
- {
- pWinSib = pWin;
- pWin = GetProp (hwnd, WIN_WINDOW_PROP);
-
- if (!pWinSib)
- { /* 1st window - raise to the top */
- vlist[0] = Above;
-
- ConfigureWindow (pWin, CWStackMode, vlist, wClient(pWin));
- }
- else
- { /* 2nd or deeper windows - just below the previous one */
- vlist[0] = winGetWindowID (pWinSib);
- vlist[1] = Below;
-
- ConfigureWindow (pWin, CWSibling | CWStackMode,
- vlist, wClient(pWin));
- }
- }
- }
-
- fRestacking = FALSE;
-}
-
-
-/*
- * winMinimizeWindow - Minimize in response to WM_CHANGE_STATE
- */
-
-void
-winMinimizeWindow (Window id)
-{
- WindowPtr pWin;
- winPrivWinPtr pWinPriv;
-#ifdef XWIN_MULTIWINDOWEXTWM
- win32RootlessWindowPtr pRLWinPriv;
-#endif
- HWND hWnd;
- ScreenPtr pScreen = NULL;
- winPrivScreenPtr pScreenPriv = NULL;
- winScreenInfo *pScreenInfo = NULL;
-
-#if CYGWINDOWING_DEBUG
- ErrorF ("winMinimizeWindow\n");
-#endif
-
- dixLookupResourceByType((pointer) &pWin, id, RT_WINDOW, NullClient, DixUnknownAccess);
- if (!pWin)
- {
- ErrorF("%s: NULL pWin. Leaving\n", __FUNCTION__);
- return;
- }
-
- pScreen = pWin->drawable.pScreen;
- if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
- if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
-
-#ifdef XWIN_MULTIWINDOWEXTWM
- if (pScreenPriv && pScreenInfo->fInternalWM)
- {
- pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE);
- hWnd = pRLWinPriv->hWnd;
- }
- else
-#else
- if (pScreenPriv)
-#endif
- {
- pWinPriv = winGetWindowPriv (pWin);
- hWnd = pWinPriv->hWnd;
- }
-
- ShowWindow (hWnd, SW_MINIMIZE);
-}
-
-
-/*
- * CopyWindow - See Porting Layer Definition - p. 39
- */
-void
-winCopyWindowMultiWindow (WindowPtr pWin, DDXPointRec oldpt,
- RegionPtr oldRegion)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winScreenPriv(pScreen);
-
-#if CYGWINDOWING_DEBUG
- ErrorF ("CopyWindowMultiWindow\n");
-#endif
- WIN_UNWRAP(CopyWindow);
- (*pScreen->CopyWindow)(pWin, oldpt, oldRegion);
- WIN_WRAP(CopyWindow, winCopyWindowMultiWindow);
-}
-
-
-/*
- * MoveWindow - See Porting Layer Definition - p. 42
- */
-void
-winMoveWindowMultiWindow (WindowPtr pWin, int x, int y,
- WindowPtr pSib, VTKind kind)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winScreenPriv(pScreen);
-
-#if CYGWINDOWING_DEBUG
- ErrorF ("MoveWindowMultiWindow to (%d, %d)\n", x, y);
-#endif
-
- WIN_UNWRAP(MoveWindow);
- (*pScreen->MoveWindow)(pWin, x, y, pSib, kind);
- WIN_WRAP(MoveWindow, winMoveWindowMultiWindow);
-}
-
-
-/*
- * ResizeWindow - See Porting Layer Definition - p. 42
- */
-void
-winResizeWindowMultiWindow (WindowPtr pWin, int x, int y, unsigned int w,
- unsigned int h, WindowPtr pSib)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winScreenPriv(pScreen);
-
-#if CYGWINDOWING_DEBUG
- ErrorF ("ResizeWindowMultiWindow to (%d, %d) - %dx%d\n", x, y, w, h);
-#endif
- WIN_UNWRAP(ResizeWindow);
- (*pScreen->ResizeWindow)(pWin, x, y, w, h, pSib);
- WIN_WRAP(ResizeWindow, winResizeWindowMultiWindow);
-}
-
-
-/*
- * winAdjustXWindow
- *
- * Move and resize X window with respect to corresponding Windows window.
- * This is called from WM_MOVE/WM_SIZE handlers when the user performs
- * any windowing operation (move, resize, minimize, maximize, restore).
- *
- * The functionality is the inverse of winPositionWindowMultiWindow, which
- * adjusts Windows window with respect to X window.
- */
-int
-winAdjustXWindow (WindowPtr pWin, HWND hwnd)
-{
- RECT rcDraw; /* Rect made from pWin->drawable to be adjusted */
- RECT rcWin; /* The source: WindowRect from hwnd */
- DrawablePtr pDraw;
- XID vlist[4];
- LONG dX, dY, dW, dH, x, y;
- DWORD dwStyle, dwExStyle;
-
-#define WIDTH(rc) (rc.right - rc.left)
-#define HEIGHT(rc) (rc.bottom - rc.top)
-
-#if CYGWINDOWING_DEBUG
- ErrorF ("winAdjustXWindow\n");
-#endif
-
- if (IsIconic (hwnd))
- {
-#if CYGWINDOWING_DEBUG
- ErrorF ("\timmediately return because the window is iconized\n");
-#endif
- /*
- * If the Windows window is minimized, its WindowRect has
- * meaningless values so we don't adjust X window to it.
- */
- vlist[0] = 0;
- vlist[1] = 0;
- return ConfigureWindow (pWin, CWX | CWY, vlist, wClient(pWin));
- }
-
- pDraw = &pWin->drawable;
-
- /* Calculate the window rect from the drawable */
- x = pDraw->x + GetSystemMetrics (SM_XVIRTUALSCREEN);
- y = pDraw->y + GetSystemMetrics (SM_YVIRTUALSCREEN);
- SetRect (&rcDraw, x, y, x + pDraw->width, y + pDraw->height);
-#ifdef CYGMULTIWINDOW_DEBUG
- winDebug("\tDrawable extend {%d, %d, %d, %d}, {%d, %d}\n",
- rcDraw.left, rcDraw.top, rcDraw.right, rcDraw.bottom,
- rcDraw.right - rcDraw.left, rcDraw.bottom - rcDraw.top);
-#endif
- dwExStyle = GetWindowLongPtr (hwnd, GWL_EXSTYLE);
- dwStyle = GetWindowLongPtr (hwnd, GWL_STYLE);
-#ifdef CYGMULTIWINDOW_DEBUG
- winDebug("\tWindowStyle: %08x %08x\n", dwStyle, dwExStyle);
-#endif
- AdjustWindowRectEx (&rcDraw, dwStyle, FALSE, dwExStyle);
-
- /* The source of adjust */
- GetWindowRect (hwnd, &rcWin);
-#ifdef CYGMULTIWINDOW_DEBUG
- winDebug("\tWindow extend {%d, %d, %d, %d}, {%d, %d}\n",
- rcWin.left, rcWin.top, rcWin.right, rcWin.bottom,
- rcWin.right - rcWin.left, rcWin.bottom - rcWin.top);
- winDebug("\tDraw extend {%d, %d, %d, %d}, {%d, %d}\n",
- rcDraw.left, rcDraw.top, rcDraw.right, rcDraw.bottom,
- rcDraw.right - rcDraw.left, rcDraw.bottom - rcDraw.top);
-#endif
-
- if (EqualRect (&rcDraw, &rcWin)) {
- /* Bail if no adjust is needed */
-#if CYGWINDOWING_DEBUG
- ErrorF ("\treturn because already adjusted\n");
-#endif
- return 0;
- }
-
- /* Calculate delta values */
- dX = rcWin.left - rcDraw.left;
- dY = rcWin.top - rcDraw.top;
- dW = WIDTH(rcWin) - WIDTH(rcDraw);
- dH = HEIGHT(rcWin) - HEIGHT(rcDraw);
-
- /*
- * Adjust.
- * We may only need to move (vlist[0] and [1]), or only resize
- * ([2] and [3]) but currently we set all the parameters and leave
- * the decision to ConfigureWindow. The reason is code simplicity.
- */
- vlist[0] = pDraw->x + dX - wBorderWidth(pWin);
- vlist[1] = pDraw->y + dY - wBorderWidth(pWin);
- vlist[2] = pDraw->width + dW;
- vlist[3] = pDraw->height + dH;
-#if CYGWINDOWING_DEBUG
- ErrorF ("\tConfigureWindow to (%ld, %ld) - %ldx%ld\n", vlist[0], vlist[1],
- vlist[2], vlist[3]);
-#endif
- return ConfigureWindow (pWin, CWX | CWY | CWWidth | CWHeight,
- vlist, wClient(pWin));
-
-#undef WIDTH
-#undef HEIGHT
-}
-
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *Copyright (C) Colin Harrison 2005-2008
+ *
+ *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, 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 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 XFREE86 PROJECT 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 XFree86 Project
+ *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 XFree86 Project.
+ *
+ * Authors: Kensuke Matsuzaki
+ * Earle F. Philhower, III
+ * Harold L Hunt II
+ * Colin Harrison
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "dixevents.h"
+#include "winmultiwindowclass.h"
+#include "winprefs.h"
+
+/*
+ * External global variables
+ */
+
+extern HICON g_hIconX;
+extern HICON g_hSmallIconX;
+extern HWND g_hDlgDepthChange;
+
+/*
+ * Prototypes for local functions
+ */
+
+void
+winCreateWindowsWindow (WindowPtr pWin);
+
+static void
+winDestroyWindowsWindow (WindowPtr pWin);
+
+static void
+winUpdateWindowsWindow (WindowPtr pWin);
+
+static void
+winFindWindow (pointer value, XID id, pointer cdata);
+
+static
+void winInitMultiWindowClass(void)
+{
+ static wATOM atomXWinClass=0;
+ WNDCLASSEX wcx;
+
+ if (atomXWinClass==0)
+ {
+ /* Setup our window class */
+ wcx.cbSize=sizeof(WNDCLASSEX);
+ wcx.style = CS_HREDRAW | CS_VREDRAW;
+ wcx.lpfnWndProc = winTopLevelWindowProc;
+ wcx.cbClsExtra = 0;
+ wcx.cbWndExtra = 0;
+ wcx.hInstance = g_hInstance;
+ wcx.hIcon = g_hIconX;
+ wcx.hCursor = 0;
+ wcx.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
+ wcx.lpszMenuName = NULL;
+ wcx.lpszClassName = WINDOW_CLASS_X;
+ wcx.hIconSm = g_hSmallIconX;
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winCreateWindowsWindow - Creating class: %s\n", WINDOW_CLASS_X);
+#endif
+
+ atomXWinClass = RegisterClassEx (&wcx);
+ }
+}
+
+/*
+ * CreateWindow - See Porting Layer Definition - p. 37
+ */
+
+Bool
+winCreateWindowMultiWindow (WindowPtr pWin)
+{
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winCreateWindowMultiWindow - pWin: %p\n", pWin);
+#endif
+
+ WIN_UNWRAP(CreateWindow);
+ fResult = (*pScreen->CreateWindow) (pWin);
+ WIN_WRAP(CreateWindow, winCreateWindowMultiWindow);
+
+ /* Initialize some privates values */
+ pWinPriv->hRgn = NULL;
+ pWinPriv->hWnd = NULL;
+ pWinPriv->pScreenPriv = winGetScreenPriv(pWin->drawable.pScreen);
+ pWinPriv->fXKilled = FALSE;
+
+ return fResult;
+}
+
+
+/*
+ * DestroyWindow - See Porting Layer Definition - p. 37
+ */
+
+Bool
+winDestroyWindowMultiWindow (WindowPtr pWin)
+{
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winDestroyWindowMultiWindow - pWin: %p\n", pWin);
+#endif
+
+ WIN_UNWRAP(DestroyWindow);
+ fResult = (*pScreen->DestroyWindow)(pWin);
+ WIN_WRAP(DestroyWindow, winDestroyWindowMultiWindow);
+
+ /* Flag that the window has been destroyed */
+ pWinPriv->fXKilled = TRUE;
+
+ /* Kill the MS Windows window associated with this window */
+ winDestroyWindowsWindow (pWin);
+
+ return fResult;
+}
+
+
+/*
+ * PositionWindow - See Porting Layer Definition - p. 37
+ *
+ * This function adjusts the position and size of Windows window
+ * with respect to the underlying X window. This is the inverse
+ * of winAdjustXWindow, which adjusts X window to Windows window.
+ */
+
+Bool
+winPositionWindowMultiWindow (WindowPtr pWin, int x, int y)
+{
+ Bool fResult = TRUE;
+ int iX, iY, iWidth, iHeight;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+ HWND hWnd = pWinPriv->hWnd;
+ RECT rcNew;
+ RECT rcOld;
+#ifdef WINDBG
+ RECT rcClient;
+ RECT *lpRc;
+#endif
+ DWORD dwExStyle;
+ DWORD dwStyle;
+
+ winDebug ("winPositionWindowMultiWindow - pWin: %p\n", pWin);
+
+ WIN_UNWRAP(PositionWindow);
+ fResult = (*pScreen->PositionWindow)(pWin, x, y);
+ WIN_WRAP(PositionWindow, winPositionWindowMultiWindow);
+
+ winDebug ("winPositionWindowMultiWindow: (x, y) = (%d, %d)\n",
+ x, y);
+
+ /* Bail out if the Windows window handle is bad */
+ if (!hWnd)
+ {
+ winDebug ("\timmediately return since hWnd is NULL\n");
+ return fResult;
+ }
+
+ /* Get the Windows window style and extended style */
+ dwExStyle = GetWindowLongPtr (hWnd, GWL_EXSTYLE);
+ dwStyle = GetWindowLongPtr (hWnd, GWL_STYLE);
+
+ /* Get the X and Y location of the X window */
+ iX = pWin->drawable.x + GetSystemMetrics (SM_XVIRTUALSCREEN);
+ iY = pWin->drawable.y + GetSystemMetrics (SM_YVIRTUALSCREEN);
+
+ /* Get the height and width of the X window */
+ iWidth = pWin->drawable.width;
+ iHeight = pWin->drawable.height;
+
+ /* Store the origin, height, and width in a rectangle structure */
+ SetRect (&rcNew, iX, iY, iX + iWidth, iY + iHeight);
+
+#if CYGMULTIWINDOW_DEBUG
+ lpRc = &rcNew;
+ winDebug ("winPositionWindowMultiWindow - (%d ms)drawable (%d, %d)-(%d, %d)\n",
+ GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom);
+#endif
+
+ /*
+ * Calculate the required size of the Windows window rectangle,
+ * given the size of the Windows window client area.
+ */
+ AdjustWindowRectEx (&rcNew, dwStyle, FALSE, dwExStyle);
+
+ /* Get a rectangle describing the old Windows window */
+ GetWindowRect (hWnd, &rcOld);
+
+#if CYGMULTIWINDOW_DEBUG
+ /* Get a rectangle describing the Windows window client area */
+ GetClientRect (hWnd, &rcClient);
+
+ lpRc = &rcNew;
+ winDebug ("winPositionWindowMultiWindow - (%d ms)rcNew (%d, %d)-(%d, %d)\n",
+ GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom);
+
+ lpRc = &rcOld;
+ winDebug ("winPositionWindowMultiWindow - (%d ms)rcOld (%d, %d)-(%d, %d)\n",
+ GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom);
+
+ lpRc = &rcClient;
+ winDebug ("(%d ms)rcClient (%d, %d)-(%d, %d)\n",
+ GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom);
+#endif
+
+ /* Check if the old rectangle and new rectangle are the same */
+ if (!EqualRect (&rcNew, &rcOld))
+ {
+ winDebug ("winPositionWindowMultiWindow - Need to move\n");
+ winDebug ("\tMoveWindow to (%ld, %ld) - %ldx%ld\n", rcNew.left, rcNew.top,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
+
+ /* Change the position and dimensions of the Windows window */
+ MoveWindow (hWnd,
+ rcNew.left, rcNew.top,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
+ TRUE);
+ }
+ else
+ {
+ winDebug ("winPositionWindowMultiWindow - Not need to move\n");
+ }
+
+ return fResult;
+}
+
+
+/*
+ * ChangeWindowAttributes - See Porting Layer Definition - p. 37
+ */
+
+Bool
+winChangeWindowAttributesMultiWindow (WindowPtr pWin, unsigned long mask)
+{
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winScreenPriv(pScreen);
+
+ winDebug ("winChangeWindowAttributesMultiWindow - pWin: %08x\n", pWin);
+
+ WIN_UNWRAP(ChangeWindowAttributes);
+ fResult = (*pScreen->ChangeWindowAttributes)(pWin, mask);
+ WIN_WRAP(ChangeWindowAttributes, winChangeWindowAttributesMultiWindow);
+
+ /*
+ * NOTE: We do not currently need to do anything here.
+ */
+
+ return fResult;
+}
+
+
+/*
+ * UnmapWindow - See Porting Layer Definition - p. 37
+ * Also referred to as UnrealizeWindow
+ */
+
+Bool
+winUnmapWindowMultiWindow (WindowPtr pWin)
+{
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winUnmapWindowMultiWindow - pWin: %08x\n", pWin);
+#endif
+
+ WIN_UNWRAP(UnrealizeWindow);
+ fResult = (*pScreen->UnrealizeWindow)(pWin);
+ WIN_WRAP(UnrealizeWindow, winUnmapWindowMultiWindow);
+
+ /* Flag that the window has been killed */
+ pWinPriv->fXKilled = TRUE;
+
+ /* Destroy the Windows window associated with this X window */
+ winDestroyWindowsWindow (pWin);
+
+ return fResult;
+}
+
+
+/*
+ * MapWindow - See Porting Layer Definition - p. 37
+ * Also referred to as RealizeWindow
+ */
+
+Bool
+winMapWindowMultiWindow (WindowPtr pWin)
+{
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMapWindowMultiWindow - pWin: %08x\n", pWin);
+#endif
+
+ WIN_UNWRAP(RealizeWindow);
+ fResult = (*pScreen->RealizeWindow)(pWin);
+ WIN_WRAP(RealizeWindow, winMapWindowMultiWindow);
+
+ /* Flag that this window has not been destroyed */
+ pWinPriv->fXKilled = FALSE;
+
+ /* Refresh/redisplay the Windows window associated with this X window */
+ winUpdateWindowsWindow (pWin);
+
+ /* Update the Windows window's shape */
+ winReshapeMultiWindow (pWin);
+ winUpdateRgnMultiWindow (pWin);
+
+ return fResult;
+}
+
+
+/*
+ * ReparentWindow - See Porting Layer Definition - p. 42
+ */
+
+void
+winReparentWindowMultiWindow (WindowPtr pWin, WindowPtr pPriorParent)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winScreenPriv(pScreen);
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winReparentMultiWindow - pWin: %08x\n", pWin);
+#endif
+
+ WIN_UNWRAP(ReparentWindow);
+ if (pScreen->ReparentWindow)
+ (*pScreen->ReparentWindow)(pWin, pPriorParent);
+ WIN_WRAP(ReparentWindow, winReparentWindowMultiWindow);
+
+ /* Update the Windows window associated with this X window */
+ winUpdateWindowsWindow (pWin);
+}
+
+
+/*
+ * RestackWindow - Shuffle the z-order of a window
+ */
+
+void
+winRestackWindowMultiWindow (WindowPtr pWin, WindowPtr pOldNextSib)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winScreenPriv(pScreen);
+
+ winDebug ("winRestackMultiWindow - %08x\n", pWin);
+
+ WIN_UNWRAP(RestackWindow);
+ if (pScreen->RestackWindow)
+ (*pScreen->RestackWindow)(pWin, pOldNextSib);
+ WIN_WRAP(RestackWindow, winRestackWindowMultiWindow);
+
+ /*
+ * Calling winReorderWindowsMultiWindow here means our window manager
+ * (i.e. Windows Explorer) has initiative to determine Z order.
+ */
+ if (pWin->nextSib != pOldNextSib)
+ winReorderWindowsMultiWindow ();
+}
+
+
+/*
+ * winCreateWindowsWindow - Create a Windows window associated with an X window
+ */
+
+void
+winCreateWindowsWindow (WindowPtr pWin)
+{
+ int iX, iY;
+ int iWidth;
+ int iHeight;
+ HWND hWnd;
+ HWND hFore = NULL;
+ winWindowPriv(pWin);
+ HICON hIcon;
+ HICON hIconSmall;
+ winPrivScreenPtr pScreenPriv = pWinPriv->pScreenPriv;
+ WinXSizeHints hints;
+ WindowPtr pDaddy;
+
+ winInitMultiWindowClass();
+
+ winDebug ("winCreateWindowsWindow - pWin: %08x\n", pWin);
+
+ iX = pWin->drawable.x + GetSystemMetrics (SM_XVIRTUALSCREEN);
+ iY = pWin->drawable.y + GetSystemMetrics (SM_YVIRTUALSCREEN);
+
+ iWidth = pWin->drawable.width;
+ iHeight = pWin->drawable.height;
+
+ if (winMultiWindowGetTransientFor (pWin, &pDaddy))
+ {
+ if (pDaddy)
+ {
+ hFore = GetForegroundWindow();
+ if (hFore && (pDaddy != (WindowPtr)GetProp(hFore, WIN_WID_PROP))) hFore = NULL;
+ }
+ }
+ else
+ {
+ /* Default positions if none specified */
+ if (!winMultiWindowGetWMNormalHints(pWin, &hints))
+ hints.flags = 0;
+ if (!(hints.flags & (USPosition|PPosition)) &&
+ !pWin->overrideRedirect)
+ {
+ iX = CW_USEDEFAULT;
+ iY = CW_USEDEFAULT;
+ }
+ }
+
+ /* Create the window */
+ /* Make it OVERLAPPED in create call since WS_POPUP doesn't support */
+ /* CW_USEDEFAULT, change back to popup after creation */
+ hWnd = CreateWindowExA (WS_EX_TOOLWINDOW, /* Extended styles */
+ WINDOW_CLASS_X, /* Class name */
+ WINDOW_TITLE_X, /* Window name */
+ WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
+ iX, /* Horizontal position */
+ iY, /* Vertical position */
+ iWidth, /* Right edge */
+ iHeight, /* Bottom edge */
+ hFore, /* Null or Parent window if transient*/
+ (HMENU) NULL, /* No menu */
+ GetModuleHandle (NULL), /* Instance handle */
+ pWin); /* ScreenPrivates */
+ if (hWnd == NULL)
+ {
+ ErrorF ("winCreateWindowsWindow - CreateWindowExA () failed: %d\n",
+ (int) GetLastError ());
+ }
+ pWinPriv->hWnd = hWnd;
+
+ /* Set application or .XWinrc defined Icons */
+ winSelectIcons(pWin, &hIcon, &hIconSmall);
+ if (hIcon) SendMessage (hWnd, WM_SETICON, ICON_BIG, (LPARAM) hIcon);
+ if (hIconSmall) SendMessage (hWnd, WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall);
+
+ /* Change style back to popup, already placed... */
+ SetWindowLongPtr(hWnd, GWL_STYLE, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
+ SetWindowPos (hWnd, 0, 0, 0, 0, 0,
+ SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ /* Make sure it gets the proper system menu for a WS_POPUP, too */
+ GetSystemMenu (hWnd, TRUE);
+
+ /* Cause any .XWinrc menus to be added in main WNDPROC */
+ PostMessage (hWnd, WM_INIT_SYS_MENU, 0, 0);
+
+ SetProp (hWnd, WIN_WID_PROP, (HANDLE) winGetWindowID(pWin));
+
+ /* Flag that this Windows window handles its own activation */
+ SetProp (hWnd, WIN_NEEDMANAGE_PROP, (HANDLE) 0);
+
+ /* Call engine-specific create window procedure */
+ (*pScreenPriv->pwinFinishCreateWindowsWindow) (pWin);
+}
+
+
+Bool winInDestroyWindowsWindow = FALSE;
+/*
+ * winDestroyWindowsWindow - Destroy a Windows window associated
+ * with an X window
+ */
+static void
+winDestroyWindowsWindow (WindowPtr pWin)
+{
+ MSG msg;
+ winWindowPriv(pWin);
+ BOOL oldstate = winInDestroyWindowsWindow;
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winDestroyWindowsWindow\n");
+#endif
+
+ /* Bail out if the Windows window handle is invalid */
+ if (pWinPriv->hWnd == NULL)
+ return;
+
+ winInDestroyWindowsWindow = TRUE;
+
+ SetProp (pWinPriv->hWnd, WIN_WINDOW_PROP, NULL);
+ /* Destroy the Windows window */
+ DestroyWindow (pWinPriv->hWnd);
+
+ /* Null our handle to the Window so referencing it will cause an error */
+ pWinPriv->hWnd = NULL;
+
+ /* Process all messages on our queue */
+ while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ if (g_hDlgDepthChange == 0 || !IsDialogMessage (g_hDlgDepthChange, &msg))
+ {
+ DispatchMessage (&msg);
+ }
+ }
+
+ winInDestroyWindowsWindow = oldstate;
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("-winDestroyWindowsWindow\n");
+#endif
+}
+
+
+/*
+ * winUpdateWindowsWindow - Redisplay/redraw a Windows window
+ * associated with an X window
+ */
+
+static void
+winUpdateWindowsWindow (WindowPtr pWin)
+{
+ winWindowPriv(pWin);
+ HWND hWnd = pWinPriv->hWnd;
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winUpdateWindowsWindow\n");
+#endif
+
+ /* Check if the Windows window's parents have been destroyed */
+ if (pWin->parent != NULL
+ && pWin->parent->parent == NULL
+ && pWin->mapped)
+ {
+ /* Create the Windows window if it has been destroyed */
+ if (hWnd == NULL)
+ {
+ winCreateWindowsWindow (pWin);
+ assert (pWinPriv->hWnd != NULL);
+ }
+
+ /* Display the window without activating it */
+ ShowWindow (pWinPriv->hWnd, SW_SHOWNOACTIVATE);
+
+ /* Send first paint message */
+ UpdateWindow (pWinPriv->hWnd);
+ }
+ else if (hWnd != NULL)
+ {
+ /* Destroy the Windows window if its parents are destroyed */
+ winDestroyWindowsWindow (pWin);
+ assert (pWinPriv->hWnd == NULL);
+ }
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("-winUpdateWindowsWindow\n");
+#endif
+}
+
+
+/*
+ * winGetWindowID -
+ */
+
+XID
+winGetWindowID (WindowPtr pWin)
+{
+ WindowIDPairRec wi = {pWin, 0};
+ ClientPtr c = wClient(pWin);
+
+ /* */
+ FindClientResourcesByType (c, RT_WINDOW, winFindWindow, &wi);
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winGetWindowID - Window ID: %d\n", wi.id);
+#endif
+
+ return wi.id;
+}
+
+
+/*
+ * winFindWindow -
+ */
+
+static void
+winFindWindow (pointer value, XID id, pointer cdata)
+{
+ WindowIDPairPtr wi = (WindowIDPairPtr)cdata;
+
+ if (value == wi->value)
+ {
+ wi->id = id;
+ }
+}
+
+
+/*
+ * winReorderWindowsMultiWindow -
+ */
+
+void
+winReorderWindowsMultiWindow (void)
+{
+ HWND hwnd = NULL;
+ WindowPtr pWin = NULL;
+ WindowPtr pWinSib = NULL;
+ XID vlist[2];
+ static Bool fRestacking = FALSE; /* Avoid recusive calls to this function */
+ DWORD dwCurrentProcessID = GetCurrentProcessId ();
+ DWORD dwWindowProcessID = 0;
+
+ winDebug ("winReorderWindowsMultiWindow\n");
+
+ if (fRestacking)
+ {
+ /* It is a recusive call so immediately exit */
+ winDebug ("winReorderWindowsMultiWindow - "
+ "exit because fRestacking == TRUE\n");
+ return;
+ }
+ fRestacking = TRUE;
+
+ /* Loop through top level Window windows, descending in Z order */
+ for ( hwnd = GetTopWindow (NULL);
+ hwnd;
+ hwnd = GetNextWindow (hwnd, GW_HWNDNEXT) )
+ {
+ /* Don't take care of other Cygwin/X process's windows */
+ GetWindowThreadProcessId (hwnd, &dwWindowProcessID);
+
+ if ( GetProp (hwnd, WIN_WINDOW_PROP)
+ && (dwWindowProcessID == dwCurrentProcessID)
+ && !IsIconic (hwnd) ) /* ignore minimized windows */
+ {
+ pWinSib = pWin;
+ pWin = GetProp (hwnd, WIN_WINDOW_PROP);
+
+ if (!pWinSib)
+ { /* 1st window - raise to the top */
+ vlist[0] = Above;
+
+ ConfigureWindow (pWin, CWStackMode, vlist, wClient(pWin));
+ }
+ else
+ { /* 2nd or deeper windows - just below the previous one */
+ vlist[0] = winGetWindowID (pWinSib);
+ vlist[1] = Below;
+
+ ConfigureWindow (pWin, CWSibling | CWStackMode,
+ vlist, wClient(pWin));
+ }
+ }
+ }
+
+ fRestacking = FALSE;
+}
+
+
+/*
+ * winMinimizeWindow - Minimize in response to WM_CHANGE_STATE
+ */
+
+void
+winMinimizeWindow (Window id)
+{
+ WindowPtr pWin;
+ winPrivWinPtr pWinPriv;
+#ifdef XWIN_MULTIWINDOWEXTWM
+ win32RootlessWindowPtr pRLWinPriv;
+#endif
+ HWND hWnd;
+ ScreenPtr pScreen = NULL;
+ winPrivScreenPtr pScreenPriv = NULL;
+ winScreenInfo *pScreenInfo = NULL;
+
+ winDebug ("winMinimizeWindow\n");
+
+ dixLookupResourceByType((pointer) &pWin, id, RT_WINDOW, NullClient, DixUnknownAccess);
+ if (!pWin)
+ {
+ ErrorF("%s: NULL pWin. Leaving\n", __FUNCTION__);
+ return;
+ }
+
+ pScreen = pWin->drawable.pScreen;
+ if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
+ if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+ if (pScreenPriv && pScreenInfo->fInternalWM)
+ {
+ pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE);
+ hWnd = pRLWinPriv->hWnd;
+ }
+ else
+#else
+ if (pScreenPriv)
+#endif
+ {
+ pWinPriv = winGetWindowPriv (pWin);
+ hWnd = pWinPriv->hWnd;
+ }
+
+ ShowWindow (hWnd, SW_MINIMIZE);
+}
+
+
+/*
+ * CopyWindow - See Porting Layer Definition - p. 39
+ */
+void
+winCopyWindowMultiWindow (WindowPtr pWin, DDXPointRec oldpt,
+ RegionPtr oldRegion)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winScreenPriv(pScreen);
+
+ winDebug ("CopyWindowMultiWindow\n");
+
+ WIN_UNWRAP(CopyWindow);
+ (*pScreen->CopyWindow)(pWin, oldpt, oldRegion);
+ WIN_WRAP(CopyWindow, winCopyWindowMultiWindow);
+}
+
+
+/*
+ * MoveWindow - See Porting Layer Definition - p. 42
+ */
+void
+winMoveWindowMultiWindow (WindowPtr pWin, int x, int y,
+ WindowPtr pSib, VTKind kind)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winScreenPriv(pScreen);
+
+ winDebug ("MoveWindowMultiWindow to (%d, %d)\n", x, y);
+
+ WIN_UNWRAP(MoveWindow);
+ (*pScreen->MoveWindow)(pWin, x, y, pSib, kind);
+ WIN_WRAP(MoveWindow, winMoveWindowMultiWindow);
+}
+
+
+/*
+ * ResizeWindow - See Porting Layer Definition - p. 42
+ */
+void
+winResizeWindowMultiWindow (WindowPtr pWin, int x, int y, unsigned int w,
+ unsigned int h, WindowPtr pSib)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winScreenPriv(pScreen);
+
+ winDebug ("ResizeWindowMultiWindow to (%d, %d) - %dx%d\n", x, y, w, h);
+
+ WIN_UNWRAP(ResizeWindow);
+ (*pScreen->ResizeWindow)(pWin, x, y, w, h, pSib);
+ WIN_WRAP(ResizeWindow, winResizeWindowMultiWindow);
+}
+
+
+/*
+ * winAdjustXWindow
+ *
+ * Move and resize X window with respect to corresponding Windows window.
+ * This is called from WM_MOVE/WM_SIZE handlers when the user performs
+ * any windowing operation (move, resize, minimize, maximize, restore).
+ *
+ * The functionality is the inverse of winPositionWindowMultiWindow, which
+ * adjusts Windows window with respect to X window.
+ */
+int
+winAdjustXWindow (WindowPtr pWin, HWND hwnd)
+{
+ RECT rcDraw; /* Rect made from pWin->drawable to be adjusted */
+ RECT rcWin; /* The source: WindowRect from hwnd */
+ DrawablePtr pDraw;
+ XID vlist[4];
+ LONG dX, dY, dW, dH, x, y;
+ DWORD dwStyle, dwExStyle;
+
+#define WIDTH(rc) (rc.right - rc.left)
+#define HEIGHT(rc) (rc.bottom - rc.top)
+
+ winDebug ("winAdjustXWindow\n");
+
+ if (IsIconic (hwnd))
+ {
+ winDebug ("\timmediately return because the window is iconized\n");
+ /*
+ * If the Windows window is minimized, its WindowRect has
+ * meaningless values so we don't adjust X window to it.
+ */
+ vlist[0] = 0;
+ vlist[1] = 0;
+ return ConfigureWindow (pWin, CWX | CWY, vlist, wClient(pWin));
+ }
+
+ pDraw = &pWin->drawable;
+
+ /* Calculate the window rect from the drawable */
+ x = pDraw->x + GetSystemMetrics (SM_XVIRTUALSCREEN);
+ y = pDraw->y + GetSystemMetrics (SM_YVIRTUALSCREEN);
+ SetRect (&rcDraw, x, y, x + pDraw->width, y + pDraw->height);
+ winDebug("\tDrawable extend {%d, %d, %d, %d}, {%d, %d}\n",
+ rcDraw.left, rcDraw.top, rcDraw.right, rcDraw.bottom,
+ rcDraw.right - rcDraw.left, rcDraw.bottom - rcDraw.top);
+ dwExStyle = GetWindowLongPtr (hwnd, GWL_EXSTYLE);
+ dwStyle = GetWindowLongPtr (hwnd, GWL_STYLE);
+ winDebug("\tWindowStyle: %08x %08x\n", dwStyle, dwExStyle);
+ AdjustWindowRectEx (&rcDraw, dwStyle, FALSE, dwExStyle);
+
+ /* The source of adjust */
+ GetWindowRect (hwnd, &rcWin);
+ winDebug("\tWindow extend {%d, %d, %d, %d}, {%d, %d}\n",
+ rcWin.left, rcWin.top, rcWin.right, rcWin.bottom,
+ rcWin.right - rcWin.left, rcWin.bottom - rcWin.top);
+ winDebug("\tDraw extend {%d, %d, %d, %d}, {%d, %d}\n",
+ rcDraw.left, rcDraw.top, rcDraw.right, rcDraw.bottom,
+ rcDraw.right - rcDraw.left, rcDraw.bottom - rcDraw.top);
+
+ if (EqualRect (&rcDraw, &rcWin)) {
+ /* Bail if no adjust is needed */
+ winDebug ("\treturn because already adjusted\n");
+ return 0;
+ }
+
+ /* Calculate delta values */
+ dX = rcWin.left - rcDraw.left;
+ dY = rcWin.top - rcDraw.top;
+ dW = WIDTH(rcWin) - WIDTH(rcDraw);
+ dH = HEIGHT(rcWin) - HEIGHT(rcDraw);
+
+ /*
+ * Adjust.
+ * We may only need to move (vlist[0] and [1]), or only resize
+ * ([2] and [3]) but currently we set all the parameters and leave
+ * the decision to ConfigureWindow. The reason is code simplicity.
+ */
+ vlist[0] = pDraw->x + dX - wBorderWidth(pWin);
+ vlist[1] = pDraw->y + dY - wBorderWidth(pWin);
+ vlist[2] = pDraw->width + dW;
+ vlist[3] = pDraw->height + dH;
+ winDebug ("\tConfigureWindow to (%ld, %ld) - %ldx%ld\n", vlist[0], vlist[1],
+ vlist[2], vlist[3]);
+ return ConfigureWindow (pWin, CWX | CWY | CWWidth | CWHeight,
+ vlist, wClient(pWin));
+
+#undef WIDTH
+#undef HEIGHT
+}
+
diff --git a/xorg-server/hw/xwin/winmultiwindowwm.c b/xorg-server/hw/xwin/winmultiwindowwm.c
index 880ca6a1c..f4b396c48 100644
--- a/xorg-server/hw/xwin/winmultiwindowwm.c
+++ b/xorg-server/hw/xwin/winmultiwindowwm.c
@@ -1,1721 +1,1618 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *Copyright (C) Colin Harrison 2005-2009
- *
- *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, 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 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 XFREE86 PROJECT 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 XFree86 Project
- *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 XFree86 Project.
- *
- * Authors: Kensuke Matsuzaki
- * Colin Harrison
- */
-
-/* X headers */
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#ifdef __CYGWIN__
-#include <sys/select.h>
-#endif
-#include <fcntl.h>
-#include <setjmp.h>
-#define HANDLE void *
-#include <pthread.h>
-#undef HANDLE
-#include <X11/X.h>
-#include <X11/Xatom.h>
-#include <X11/Xlib.h>
-#include <X11/Xlocale.h>
-#include <X11/Xproto.h>
-#include <X11/Xutil.h>
-#include <X11/cursorfont.h>
-#include <X11/Xwindows.h>
-
-/* Local headers */
-#include "objbase.h"
-#include "ddraw.h"
-#include "winwindow.h"
-#include "winprefs.h"
-#include "window.h"
-#include "pixmapstr.h"
-#include "windowstr.h"
-
-#ifdef XWIN_MULTIWINDOWEXTWM
-#include <X11/extensions/windowswmstr.h>
-#else
-/* We need the native HWND atom for intWM, so for consistency use the
- same name as extWM would if we were building with enabled... */
-#define WINDOWSWM_NATIVE_HWND "_WINDOWSWM_NATIVE_HWND"
-#endif
-
-extern void winDebug(const char *format, ...);
-extern void winReshapeMultiWindow(WindowPtr pWin);
-extern void winUpdateRgnMultiWindow(WindowPtr pWin);
-
-#ifndef CYGDEBUG
-#define CYGDEBUG NO
-#endif
-
-/*
- * Constant defines
- */
-
-#define WIN_CONNECT_RETRIES 5
-#define WIN_CONNECT_DELAY 5
-#ifdef HAS_DEVWINDOWS
-# define WIN_MSG_QUEUE_FNAME "/dev/windows"
-#endif
-#define WIN_JMP_OKAY 0
-#define WIN_JMP_ERROR_IO 2
-
-/*
- * Local structures
- */
-
-typedef struct _WMMsgNodeRec {
- winWMMessageRec msg;
- struct _WMMsgNodeRec *pNext;
-} WMMsgNodeRec, *WMMsgNodePtr;
-
-typedef struct _WMMsgQueueRec {
- struct _WMMsgNodeRec *pHead;
- struct _WMMsgNodeRec *pTail;
- pthread_mutex_t pmMutex;
- pthread_cond_t pcNotEmpty;
- int nQueueSize;
-} WMMsgQueueRec, *WMMsgQueuePtr;
-
-typedef struct _WMInfo {
- Display *pDisplay;
- WMMsgQueueRec wmMsgQueue;
- Atom atmWmProtos;
- Atom atmWmDelete;
- Atom atmPrivMap;
- Bool fAllowOtherWM;
-} WMInfoRec, *WMInfoPtr;
-
-typedef struct _WMProcArgRec {
- DWORD dwScreen;
- WMInfoPtr pWMInfo;
- pthread_mutex_t *ppmServerStarted;
-} WMProcArgRec, *WMProcArgPtr;
-
-typedef struct _XMsgProcArgRec {
- Display *pDisplay;
- DWORD dwScreen;
- WMInfoPtr pWMInfo;
- pthread_mutex_t *ppmServerStarted;
- HWND hwndScreen;
-} XMsgProcArgRec, *XMsgProcArgPtr;
-
-
-/*
- * References to external symbols
- */
-
-extern char *display;
-extern void ErrorF (const char* /*f*/, ...);
-
-/*
- * Prototypes for local functions
- */
-
-static void
-PushMessage (WMMsgQueuePtr pQueue, WMMsgNodePtr pNode);
-
-static WMMsgNodePtr
-PopMessage (WMMsgQueuePtr pQueue, WMInfoPtr pWMInfo);
-
-static Bool
-InitQueue (WMMsgQueuePtr pQueue);
-
-static void
-GetWindowName (Display * pDpy, Window iWin, char **ppName);
-
-static int
-SendXMessage (Display *pDisplay, Window iWin, Atom atmType, long nData);
-
-static void
-UpdateName (WMInfoPtr pWMInfo, Window iWindow);
-
-static void*
-winMultiWindowWMProc (void* pArg);
-
-static int
-winMultiWindowWMErrorHandler (Display *pDisplay, XErrorEvent *pErr);
-
-static int
-winMultiWindowWMIOErrorHandler (Display *pDisplay);
-
-static void *
-winMultiWindowXMsgProc (void *pArg);
-
-static int
-winMultiWindowXMsgProcErrorHandler (Display *pDisplay, XErrorEvent *pErr);
-
-static int
-winMultiWindowXMsgProcIOErrorHandler (Display *pDisplay);
-
-static int
-winRedirectErrorHandler (Display *pDisplay, XErrorEvent *pErr);
-
-static void
-winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg);
-
-#if 0
-static void
-PreserveWin32Stack(WMInfoPtr pWMInfo, Window iWindow, UINT direction);
-#endif
-
-static Bool
-CheckAnotherWindowManager (Display *pDisplay, DWORD dwScreen);
-
-static void
-winApplyHints (Display *pDisplay, Window iWindow, HWND hWnd, HWND *zstyle);
-
-void
-winUpdateWindowPosition (HWND hWnd, Bool reshape, HWND *zstyle);
-
-/*
- * Local globals
- */
-
-static jmp_buf g_jmpWMEntry;
-static jmp_buf g_jmpXMsgProcEntry;
-static Bool g_shutdown = FALSE;
-static Bool redirectError = FALSE;
-static Bool g_fAnotherWMRunning = FALSE;
-
-/*
- * PushMessage - Push a message onto the queue
- */
-
-static void
-PushMessage (WMMsgQueuePtr pQueue, WMMsgNodePtr pNode)
-{
-
- /* Lock the queue mutex */
- pthread_mutex_lock (&pQueue->pmMutex);
-
- pNode->pNext = NULL;
-
- if (pQueue->pTail != NULL)
- {
- pQueue->pTail->pNext = pNode;
- }
- pQueue->pTail = pNode;
-
- if (pQueue->pHead == NULL)
- {
- pQueue->pHead = pNode;
- }
-
-
-#if 0
- switch (pNode->msg.msg)
- {
- case WM_WM_MOVE:
- ErrorF ("\tWM_WM_MOVE\n");
- break;
- case WM_WM_SIZE:
- ErrorF ("\tWM_WM_SIZE\n");
- break;
- case WM_WM_RAISE:
- ErrorF ("\tWM_WM_RAISE\n");
- break;
- case WM_WM_LOWER:
- ErrorF ("\tWM_WM_LOWER\n");
- break;
- case WM_WM_MAP:
- ErrorF ("\tWM_WM_MAP\n");
- break;
- case WM_WM_MAP2:
- ErrorF ("\tWM_WM_MAP2\n");
- break;
- case WM_WM_MAP3:
- ErrorF ("\tWM_WM_MAP3\n");
- break;
- case WM_WM_UNMAP:
- ErrorF ("\tWM_WM_UNMAP\n");
- break;
- case WM_WM_KILL:
- ErrorF ("\tWM_WM_KILL\n");
- break;
- case WM_WM_ACTIVATE:
- ErrorF ("\tWM_WM_ACTIVATE\n");
- break;
- default:
- ErrorF ("\tUnknown Message.\n");
- break;
- }
-#endif
-
- /* Increase the count of elements in the queue by one */
- ++(pQueue->nQueueSize);
-
- /* Release the queue mutex */
- pthread_mutex_unlock (&pQueue->pmMutex);
-
- /* Signal that the queue is not empty */
- pthread_cond_signal (&pQueue->pcNotEmpty);
-}
-
-
-#if CYGMULTIWINDOW_DEBUG
-/*
- * QueueSize - Return the size of the queue
- */
-
-static int
-QueueSize (WMMsgQueuePtr pQueue)
-{
- WMMsgNodePtr pNode;
- int nSize = 0;
-
- /* Loop through all elements in the queue */
- for (pNode = pQueue->pHead; pNode != NULL; pNode = pNode->pNext)
- ++nSize;
-
- return nSize;
-}
-#endif
-
-
-/*
- * PopMessage - Pop a message from the queue
- */
-
-static WMMsgNodePtr
-PopMessage (WMMsgQueuePtr pQueue, WMInfoPtr pWMInfo)
-{
- WMMsgNodePtr pNode;
-
- /* Lock the queue mutex */
- pthread_mutex_lock (&pQueue->pmMutex);
-
- /* Wait for --- */
- while (pQueue->pHead == NULL)
- {
- pthread_cond_wait (&pQueue->pcNotEmpty, &pQueue->pmMutex);
- }
-
- pNode = pQueue->pHead;
- if (pQueue->pHead != NULL)
- {
- pQueue->pHead = pQueue->pHead->pNext;
- }
-
- if (pQueue->pTail == pNode)
- {
- pQueue->pTail = NULL;
- }
-
- /* Drop the number of elements in the queue by one */
- --(pQueue->nQueueSize);
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("Queue Size %d %d\n", pQueue->nQueueSize, QueueSize(pQueue));
-#endif
-
- /* Release the queue mutex */
- pthread_mutex_unlock (&pQueue->pmMutex);
-
- return pNode;
-}
-
-
-#if 0
-/*
- * HaveMessage -
- */
-
-static Bool
-HaveMessage (WMMsgQueuePtr pQueue, UINT msg, Window iWindow)
-{
- WMMsgNodePtr pNode;
-
- for (pNode = pQueue->pHead; pNode != NULL; pNode = pNode->pNext)
- {
- if (pNode->msg.msg==msg && pNode->msg.iWindow==iWindow)
- return True;
- }
-
- return False;
-}
-#endif
-
-
-/*
- * InitQueue - Initialize the Window Manager message queue
- */
-
-static
-Bool
-InitQueue (WMMsgQueuePtr pQueue)
-{
- /* Check if the pQueue pointer is NULL */
- if (pQueue == NULL)
- {
- ErrorF ("InitQueue - pQueue is NULL. Exiting.\n");
- return FALSE;
- }
-
- /* Set the head and tail to NULL */
- pQueue->pHead = NULL;
- pQueue->pTail = NULL;
-
- /* There are no elements initially */
- pQueue->nQueueSize = 0;
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("InitQueue - Queue Size %d %d\n", pQueue->nQueueSize,
- QueueSize(pQueue));
-#endif
-
- ErrorF ("InitQueue - Calling pthread_mutex_init\n");
-
- /* Create synchronization objects */
- pthread_mutex_init (&pQueue->pmMutex, NULL);
-
- ErrorF ("InitQueue - pthread_mutex_init returned\n");
- ErrorF ("InitQueue - Calling pthread_cond_init\n");
-
- pthread_cond_init (&pQueue->pcNotEmpty, NULL);
-
- ErrorF ("InitQueue - pthread_cond_init returned\n");
-
- return TRUE;
-}
-
-
-/*
- * GetWindowName - Retrieve the title of an X Window
- */
-
-static void
-GetWindowName (Display *pDisplay, Window iWin, char **ppName)
-{
- int nResult, nNum;
- char **ppList;
- XTextProperty xtpName;
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("GetWindowName\n");
-#endif
-
- /* Intialize ppName to NULL */
- *ppName = NULL;
-
- /* Try to get --- */
- nResult = XGetWMName (pDisplay, iWin, &xtpName);
- if (!nResult || !xtpName.value || !xtpName.nitems)
- {
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("GetWindowName - XGetWMName failed. No name.\n");
-#endif
- return;
- }
-
- /* */
- if (xtpName.encoding == XA_STRING)
- {
- /* */
- if (xtpName.value)
- {
- int size = xtpName.nitems * (xtpName.format >> 3);
- *ppName = malloc(size + 1);
- strncpy(*ppName, xtpName.value, size);
- (*ppName)[size] = 0;
- XFree (xtpName.value);
- }
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("GetWindowName - XA_STRING %s\n", *ppName);
-#endif
- }
- else
- {
- if (XmbTextPropertyToTextList (pDisplay, &xtpName, &ppList, &nNum) >= Success && nNum > 0 && *ppList)
- {
- *ppName = strdup (*ppList);
- XFreeStringList (ppList);
- }
- XFree (xtpName.value);
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("GetWindowName - %s %s\n",
- XGetAtomName (pDisplay, xtpName.encoding), *ppName);
-#endif
- }
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("GetWindowName - Returning\n");
-#endif
-}
-
-
-/*
- * Send a message to the X server from the WM thread
- */
-
-static int
-SendXMessage (Display *pDisplay, Window iWin, Atom atmType, long nData)
-{
- XEvent e;
-
- /* Prepare the X event structure */
- e.type = ClientMessage;
- e.xclient.window = iWin;
- e.xclient.message_type = atmType;
- e.xclient.format = 32;
- e.xclient.data.l[0] = nData;
- e.xclient.data.l[1] = CurrentTime;
-
- /* Send the event to X */
- return XSendEvent (pDisplay, iWin, False, NoEventMask, &e);
-}
-
-
-/*
- * Updates the name of a HWND according to its X WM_NAME property
- */
-
-static void
-UpdateName (WMInfoPtr pWMInfo, Window iWindow)
-{
- char *pszName;
- Atom atmType;
- int fmtRet;
- unsigned long items, remain;
- HWND *retHwnd, hWnd;
- XWindowAttributes attr;
-
- hWnd = 0;
-
- /* See if we can get the cached HWND for this window... */
- if (XGetWindowProperty (pWMInfo->pDisplay,
- iWindow,
- pWMInfo->atmPrivMap,
- 0,
- 1,
- False,
- XA_INTEGER,//pWMInfo->atmPrivMap,
- &atmType,
- &fmtRet,
- &items,
- &remain,
- (unsigned char **) &retHwnd) == Success)
- {
- if (retHwnd)
- {
- hWnd = *retHwnd;
- XFree (retHwnd);
- }
- }
-
- /* Some sanity checks */
- if (!hWnd) return;
- if (!IsWindow (hWnd)) return;
-
- /* Set the Windows window name */
- GetWindowName (pWMInfo->pDisplay, iWindow, &pszName);
- if (pszName)
- {
- /* Get the window attributes */
- XGetWindowAttributes (pWMInfo->pDisplay,
- iWindow,
- &attr);
- if (!attr.override_redirect)
- {
- SetWindowText (hWnd, pszName);
- winUpdateIcon (iWindow);
- }
-
- free (pszName);
- }
-}
-
-
-#if 0
-/*
- * Fix up any differences between the X11 and Win32 window stacks
- * starting at the window passed in
- */
-static void
-PreserveWin32Stack(WMInfoPtr pWMInfo, Window iWindow, UINT direction)
-{
- Atom atmType;
- int fmtRet;
- unsigned long items, remain;
- HWND hWnd, *retHwnd;
- DWORD myWinProcID, winProcID;
- Window xWindow;
- WINDOWPLACEMENT wndPlace;
-
- hWnd = NULL;
- /* See if we can get the cached HWND for this window... */
- if (XGetWindowProperty (pWMInfo->pDisplay,
- iWindow,
- pWMInfo->atmPrivMap,
- 0,
- 1,
- False,
- XA_INTEGER,//pWMInfo->atmPrivMap,
- &atmType,
- &fmtRet,
- &items,
- &remain,
- (unsigned char **) &retHwnd) == Success)
- {
- if (retHwnd)
- {
- hWnd = *retHwnd;
- XFree (retHwnd);
- }
- }
-
- if (!hWnd) return;
-
- GetWindowThreadProcessId (hWnd, &myWinProcID);
- hWnd = GetNextWindow (hWnd, direction);
-
- while (hWnd) {
- GetWindowThreadProcessId (hWnd, &winProcID);
- if (winProcID == myWinProcID)
- {
- wndPlace.length = sizeof(WINDOWPLACEMENT);
- GetWindowPlacement (hWnd, &wndPlace);
- if ( !(wndPlace.showCmd==SW_HIDE ||
- wndPlace.showCmd==SW_MINIMIZE) )
- {
- xWindow = (Window)GetProp (hWnd, WIN_WID_PROP);
- if (xWindow)
- {
- if (direction==GW_HWNDPREV)
- XRaiseWindow (pWMInfo->pDisplay, xWindow);
- else
- XLowerWindow (pWMInfo->pDisplay, xWindow);
- }
- }
- }
- hWnd = GetNextWindow(hWnd, direction);
- }
-}
-#endif /* PreserveWin32Stack */
-
-
-/*
- * winMultiWindowWMProc
- */
-
-static void *
-winMultiWindowWMProc (void *pArg)
-{
- WMProcArgPtr pProcArg = (WMProcArgPtr)pArg;
- WMInfoPtr pWMInfo = pProcArg->pWMInfo;
-
- /* Initialize the Window Manager */
- winInitMultiWindowWM (pWMInfo, pProcArg);
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winMultiWindowWMProc ()\n");
-#endif
-
- /* Loop until we explicity break out */
- for (;;)
- {
- WMMsgNodePtr pNode;
-
- if(g_fAnotherWMRunning)/* Another Window manager exists. */
- {
- Sleep (1000);
- continue;
- }
-
- /* Pop a message off of our queue */
- pNode = PopMessage (&pWMInfo->wmMsgQueue, pWMInfo);
- if (pNode == NULL)
- {
- /* Bail if PopMessage returns without a message */
- /* NOTE: Remember that PopMessage is a blocking function. */
- ErrorF ("winMultiWindowWMProc - Queue is Empty? Exiting.\n");
- pthread_exit (NULL);
- }
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winMultiWindowWMProc - %d ms MSG: %d ID: %d\n",
- GetTickCount (), (int)pNode->msg.msg, (int)pNode->msg.dwID);
-#endif
-
- /* Branch on the message type */
- switch (pNode->msg.msg)
- {
-#if 0
- case WM_WM_MOVE:
- ErrorF ("\tWM_WM_MOVE\n");
- break;
-
- case WM_WM_SIZE:
- ErrorF ("\tWM_WM_SIZE\n");
- break;
-#endif
-
- case WM_WM_RAISE:
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("\tWM_WM_RAISE\n");
-#endif
- /* Raise the window */
- XRaiseWindow (pWMInfo->pDisplay, pNode->msg.iWindow);
-#if 0
- PreserveWin32Stack (pWMInfo, pNode->msg.iWindow, GW_HWNDPREV);
-#endif
- break;
-
- case WM_WM_LOWER:
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("\tWM_WM_LOWER\n");
-#endif
-
- /* Lower the window */
- XLowerWindow (pWMInfo->pDisplay, pNode->msg.iWindow);
- break;
-
- case WM_WM_MAP:
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("\tWM_WM_MAP\n");
-#endif
- /* Put a note as to the HWND associated with this Window */
- XChangeProperty (pWMInfo->pDisplay,
- pNode->msg.iWindow,
- pWMInfo->atmPrivMap,
- XA_INTEGER,//pWMInfo->atmPrivMap,
- 32,
- PropModeReplace,
- (unsigned char *) &(pNode->msg.hwndWindow),
- 1);
- UpdateName (pWMInfo, pNode->msg.iWindow);
- winUpdateIcon (pNode->msg.iWindow);
- break;
-
- case WM_WM_MAP2:
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("\tWM_WM_MAP2\n");
-#endif
- XChangeProperty (pWMInfo->pDisplay,
- pNode->msg.iWindow,
- pWMInfo->atmPrivMap,
- XA_INTEGER,//pWMInfo->atmPrivMap,
- 32,
- PropModeReplace,
- (unsigned char *) &(pNode->msg.hwndWindow),
- 1);
- break;
-
- case WM_WM_MAP3:
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("\tWM_WM_MAP3\n");
-#endif
- /* Put a note as to the HWND associated with this Window */
- XChangeProperty (pWMInfo->pDisplay,
- pNode->msg.iWindow,
- pWMInfo->atmPrivMap,
- XA_INTEGER,//pWMInfo->atmPrivMap,
- 32,
- PropModeReplace,
- (unsigned char *) &(pNode->msg.hwndWindow),
- 1);
- UpdateName (pWMInfo, pNode->msg.iWindow);
- winUpdateIcon (pNode->msg.iWindow);
- {
- HWND zstyle = HWND_NOTOPMOST;
- winApplyHints (pWMInfo->pDisplay, pNode->msg.iWindow, pNode->msg.hwndWindow, &zstyle);
- winUpdateWindowPosition (pNode->msg.hwndWindow, TRUE, &zstyle);
- }
- break;
-
- case WM_WM_UNMAP:
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("\tWM_WM_UNMAP\n");
-#endif
-
- /* Unmap the window */
- XUnmapWindow (pWMInfo->pDisplay, pNode->msg.iWindow);
- break;
-
- case WM_WM_KILL:
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("\tWM_WM_KILL\n");
-#endif
- {
- int i, n, found = 0;
- Atom *protocols;
-
- /* --- */
- if (XGetWMProtocols (pWMInfo->pDisplay,
- pNode->msg.iWindow,
- &protocols,
- &n))
- {
- for (i = 0; i < n; ++i)
- if (protocols[i] == pWMInfo->atmWmDelete)
- ++found;
-
- XFree (protocols);
- }
-
- /* --- */
- if (found)
- SendXMessage (pWMInfo->pDisplay,
- pNode->msg.iWindow,
- pWMInfo->atmWmProtos,
- pWMInfo->atmWmDelete);
- else
- XKillClient (pWMInfo->pDisplay,
- pNode->msg.iWindow);
- }
- break;
-
- case WM_WM_ACTIVATE:
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("\tWM_WM_ACTIVATE\n");
-#endif
-
- /* Set the input focus */
- XSetInputFocus (pWMInfo->pDisplay,
- pNode->msg.iWindow,
- RevertToPointerRoot,
- CurrentTime);
- break;
-
- case WM_WM_NAME_EVENT:
- UpdateName (pWMInfo, pNode->msg.iWindow);
- break;
-
- case WM_WM_HINTS_EVENT:
- winUpdateIcon (pNode->msg.iWindow);
- break;
-
- case WM_WM_CHANGE_STATE:
- /* Minimize the window in Windows */
- winMinimizeWindow (pNode->msg.iWindow);
- break;
-
- default:
- ErrorF ("winMultiWindowWMProc - Unknown Message. Exiting.\n");
- pthread_exit (NULL);
- break;
- }
-
- /* Free the retrieved message */
- free (pNode);
-
- /* Flush any pending events on our display */
- XFlush (pWMInfo->pDisplay);
- }
-
- /* Free the condition variable */
- pthread_cond_destroy (&pWMInfo->wmMsgQueue.pcNotEmpty);
-
- /* Free the mutex variable */
- pthread_mutex_destroy (&pWMInfo->wmMsgQueue.pmMutex);
-
- /* Free the passed-in argument */
- free (pProcArg);
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF("-winMultiWindowWMProc ()\n");
-#endif
- return NULL;
-}
-
-
-/*
- * X message procedure
- */
-
-static void *
-winMultiWindowXMsgProc (void *pArg)
-{
- winWMMessageRec msg;
- XMsgProcArgPtr pProcArg = (XMsgProcArgPtr) pArg;
- char pszDisplay[512];
- int iRetries;
- XEvent event;
- Atom atmWmName;
- Atom atmWmHints;
- Atom atmWmChange;
- int iReturn;
- XIconSize *xis;
-
- ErrorF ("winMultiWindowXMsgProc - Hello\n");
-
- /* Check that argument pointer is not invalid */
- if (pProcArg == NULL)
- {
- ErrorF ("winMultiWindowXMsgProc - pProcArg is NULL. Exiting.\n");
- pthread_exit (NULL);
- }
-
- ErrorF ("winMultiWindowXMsgProc - Calling pthread_mutex_lock ()\n");
-
- /* Grab the server started mutex - pause until we get it */
- iReturn = pthread_mutex_lock (pProcArg->ppmServerStarted);
- if (iReturn != 0)
- {
- ErrorF ("winMultiWindowXMsgProc - pthread_mutex_lock () failed: %d. "
- "Exiting.\n",
- iReturn);
- pthread_exit (NULL);
- }
-
- ErrorF ("winMultiWindowXMsgProc - pthread_mutex_lock () returned.\n");
-
- /* Allow multiple threads to access Xlib */
- if (XInitThreads () == 0)
- {
- ErrorF ("winMultiWindowXMsgProc - XInitThreads () failed. Exiting.\n");
- pthread_exit (NULL);
- }
-
- /* See if X supports the current locale */
- if (XSupportsLocale () == False)
- {
- ErrorF ("winMultiWindowXMsgProc - Locale not supported by X. "
- "Exiting.\n");
- pthread_exit (NULL);
- }
-
- /* Release the server started mutex */
- pthread_mutex_unlock (pProcArg->ppmServerStarted);
-
- ErrorF ("winMultiWindowXMsgProc - pthread_mutex_unlock () returned.\n");
-
- /* Set jump point for IO Error exits */
- iReturn = setjmp (g_jmpXMsgProcEntry);
-
- /* Check if we should continue operations */
- if (iReturn != WIN_JMP_ERROR_IO
- && iReturn != WIN_JMP_OKAY)
- {
- /* setjmp returned an unknown value, exit */
- ErrorF ("winInitMultiWindowXMsgProc - setjmp returned: %d. Exiting.\n",
- iReturn);
- pthread_exit (NULL);
- }
- else if (iReturn == WIN_JMP_ERROR_IO)
- {
- ErrorF ("winInitMultiWindowXMsgProc - Caught IO Error. Exiting.\n");
- pthread_exit (NULL);
- }
-
- /* Install our error handler */
- XSetErrorHandler (winMultiWindowXMsgProcErrorHandler);
- XSetIOErrorHandler (winMultiWindowXMsgProcIOErrorHandler);
-
- /* Setup the display connection string x */
- snprintf (pszDisplay,
- 512, "127.0.0.1:%s.%d", display, (int)pProcArg->dwScreen);
-
- /* Print the display connection string */
- ErrorF ("winMultiWindowXMsgProc - DISPLAY=%s\n", pszDisplay);
-
- /* Use our generated cookie for authentication */
- winSetAuthorization();
-
- /* Initialize retry count */
- iRetries = 0;
-
- /* Open the X display */
- do
- {
- /* Try to open the display */
- pProcArg->pDisplay = XOpenDisplay (pszDisplay);
- if (pProcArg->pDisplay == NULL)
- {
- ErrorF ("winMultiWindowXMsgProc - Could not open display, try: %d, "
- "sleeping: %d\n\f",
- iRetries + 1, WIN_CONNECT_DELAY);
- ++iRetries;
- sleep (WIN_CONNECT_DELAY);
- continue;
- }
- else
- break;
- }
- while (pProcArg->pDisplay == NULL && iRetries < WIN_CONNECT_RETRIES);
-
- /* Make sure that the display opened */
- if (pProcArg->pDisplay == NULL)
- {
- ErrorF ("winMultiWindowXMsgProc - Failed opening the display. "
- "Exiting.\n");
- pthread_exit (NULL);
- }
-
- ErrorF ("winMultiWindowXMsgProc - XOpenDisplay () returned and "
- "successfully opened the display.\n");
-
- /* Check if another window manager is already running */
- g_fAnotherWMRunning = CheckAnotherWindowManager (pProcArg->pDisplay, pProcArg->dwScreen);
-
- if (g_fAnotherWMRunning && !pProcArg->pWMInfo->fAllowOtherWM)
- {
- ErrorF ("winMultiWindowXMsgProc - "
- "another window manager is running. Exiting.\n");
- pthread_exit (NULL);
- }
-
- /* Set up the supported icon sizes */
- xis = XAllocIconSize ();
- if (xis)
- {
- xis->min_width = xis->min_height = 16;
- xis->max_width = xis->max_height = 48;
- xis->width_inc = xis->height_inc = 16;
- XSetIconSizes (pProcArg->pDisplay,
- RootWindow (pProcArg->pDisplay, pProcArg->dwScreen),
- xis,
- 1);
- XFree (xis);
- }
-
- atmWmName = XInternAtom (pProcArg->pDisplay,
- "WM_NAME",
- False);
- atmWmHints = XInternAtom (pProcArg->pDisplay,
- "WM_HINTS",
- False);
- atmWmChange = XInternAtom (pProcArg->pDisplay,
- "WM_CHANGE_STATE",
- False);
-
- /*
- iiimxcf had a bug until 2009-04-27, assuming that the
- WM_STATE atom exists, causing clients to fail with
- a BadAtom X error if it doesn't.
-
- Since this is on in the default Solaris 10 install,
- workaround this by making sure it does exist...
- */
- XInternAtom(pProcArg->pDisplay, "WM_STATE", 0);
-
- /* Loop until we explicitly break out */
- while (1)
- {
- if (g_shutdown)
- break;
-
- if (pProcArg->pWMInfo->fAllowOtherWM && !XPending (pProcArg->pDisplay))
- {
- if (CheckAnotherWindowManager (pProcArg->pDisplay, pProcArg->dwScreen))
- {
- if (!g_fAnotherWMRunning)
- {
- g_fAnotherWMRunning = TRUE;
- SendMessage(*(HWND*)pProcArg->hwndScreen, WM_UNMANAGE, 0, 0);
- }
- }
- else
- {
- if (g_fAnotherWMRunning)
- {
- g_fAnotherWMRunning = FALSE;
- SendMessage(*(HWND*)pProcArg->hwndScreen, WM_MANAGE, 0, 0);
- }
- }
- Sleep (500);
- continue;
- }
-
- /* Fetch next event */
- XNextEvent (pProcArg->pDisplay, &event);
-
- /* Branch on event type */
- if (event.type == CreateNotify)
- {
- XWindowAttributes attr;
-
- XSelectInput (pProcArg->pDisplay,
- event.xcreatewindow.window,
- PropertyChangeMask);
-
- /* Get the window attributes */
- XGetWindowAttributes (pProcArg->pDisplay,
- event.xcreatewindow.window,
- &attr);
-
- if (!attr.override_redirect)
- XSetWindowBorderWidth(pProcArg->pDisplay,
- event.xcreatewindow.window,
- 0);
- }
- else if (event.type == MapNotify)
- {
- /* Fake a reparentNotify event as SWT/Motif expects a
- Window Manager to reparent a top-level window when
- it is mapped and waits until they do.
-
- We don't actually need to reparent, as the frame is
- a native window, not an X window
-
- We do this on MapNotify, not MapRequest like a real
- Window Manager would, so we don't have do get involved
- in actually mapping the window via it's (non-existent)
- parent...
-
- See sourceware bugzilla #9848
- */
-
- XWindowAttributes attr;
- Window root;
- Window parent;
- Window *children;
- unsigned int nchildren;
-
- if (XGetWindowAttributes(event.xmap.display,
- event.xmap.window,
- &attr) &&
- XQueryTree(event.xmap.display,
- event.xmap.window,
- &root, &parent, &children, &nchildren))
- {
- if (children) XFree(children);
-
- /*
- It's a top-level window if the parent window is a root window
- Only non-override_redirect windows can get reparented
- */
- if ((attr.root == parent) && !event.xmap.override_redirect)
- {
- XEvent event_send;
-
- event_send.type = ReparentNotify;
- event_send.xreparent.event = event.xmap.window;
- event_send.xreparent.window = event.xmap.window;
- event_send.xreparent.parent = parent;
- event_send.xreparent.x = attr.x;
- event_send.xreparent.y = attr.y;
-
- XSendEvent(event.xmap.display,
- event.xmap.window,
- True, StructureNotifyMask,
- &event_send);
- }
- }
- }
- else if (event.type == PropertyNotify
- && event.xproperty.atom == atmWmName)
- {
- memset (&msg, 0, sizeof (msg));
-
- msg.msg = WM_WM_NAME_EVENT;
- msg.iWindow = event.xproperty.window;
-
- /* Other fields ignored */
- winSendMessageToWM (pProcArg->pWMInfo, &msg);
- }
- else if (event.type == PropertyNotify
- && event.xproperty.atom == atmWmHints)
- {
- memset (&msg, 0, sizeof (msg));
-
- msg.msg = WM_WM_HINTS_EVENT;
- msg.iWindow = event.xproperty.window;
-
- /* Other fields ignored */
- winSendMessageToWM (pProcArg->pWMInfo, &msg);
- }
- else if (event.type == ClientMessage
- && event.xclient.message_type == atmWmChange
- && event.xclient.data.l[0] == IconicState)
- {
- ErrorF ("winMultiWindowXMsgProc - WM_CHANGE_STATE - IconicState\n");
-
- memset (&msg, 0, sizeof (msg));
-
- msg.msg = WM_WM_CHANGE_STATE;
- msg.iWindow = event.xclient.window;
-
- winSendMessageToWM (pProcArg->pWMInfo, &msg);
- }
- }
-
- XCloseDisplay (pProcArg->pDisplay);
- pthread_exit (NULL);
- return NULL;
-}
-
-
-/*
- * winInitWM - Entry point for the X server to spawn
- * the Window Manager thread. Called from
- * winscrinit.c/winFinishScreenInitFB ().
- */
-
-Bool
-winInitWM (void **ppWMInfo,
- pthread_t *ptWMProc,
- pthread_t *ptXMsgProc,
- pthread_mutex_t *ppmServerStarted,
- int dwScreen,
- HWND hwndScreen,
- BOOL allowOtherWM)
-{
- WMProcArgPtr pArg = (WMProcArgPtr) malloc (sizeof(WMProcArgRec));
- WMInfoPtr pWMInfo = (WMInfoPtr) malloc (sizeof(WMInfoRec));
- XMsgProcArgPtr pXMsgArg = (XMsgProcArgPtr) malloc (sizeof(XMsgProcArgRec));
-
- /* Bail if the input parameters are bad */
- if (pArg == NULL || pWMInfo == NULL)
- {
- ErrorF ("winInitWM - malloc failed.\n");
- return FALSE;
- }
-
- /* Zero the allocated memory */
- ZeroMemory (pArg, sizeof (WMProcArgRec));
- ZeroMemory (pWMInfo, sizeof (WMInfoRec));
- ZeroMemory (pXMsgArg, sizeof (XMsgProcArgRec));
-
- /* Set a return pointer to the Window Manager info structure */
- *ppWMInfo = pWMInfo;
- pWMInfo->fAllowOtherWM = allowOtherWM;
-
- /* Setup the argument structure for the thread function */
- pArg->dwScreen = dwScreen;
- pArg->pWMInfo = pWMInfo;
- pArg->ppmServerStarted = ppmServerStarted;
-
- /* Intialize the message queue */
- if (!InitQueue (&pWMInfo->wmMsgQueue))
- {
- ErrorF ("winInitWM - InitQueue () failed.\n");
- return FALSE;
- }
-
- /* Spawn a thread for the Window Manager */
- if (pthread_create (ptWMProc, NULL, winMultiWindowWMProc, pArg))
- {
- /* Bail if thread creation failed */
- ErrorF ("winInitWM - pthread_create failed for Window Manager.\n");
- return FALSE;
- }
-
- /* Spawn the XNextEvent thread, will send messages to WM */
- pXMsgArg->dwScreen = dwScreen;
- pXMsgArg->pWMInfo = pWMInfo;
- pXMsgArg->ppmServerStarted = ppmServerStarted;
- pXMsgArg->hwndScreen = hwndScreen;
- if (pthread_create (ptXMsgProc, NULL, winMultiWindowXMsgProc, pXMsgArg))
- {
- /* Bail if thread creation failed */
- ErrorF ("winInitWM - pthread_create failed on XMSG.\n");
- return FALSE;
- }
-
-#if CYGDEBUG || YES
- winDebug ("winInitWM - Returning.\n");
-#endif
-
- return TRUE;
-}
-
-
-/*
- * Window manager thread - setup
- */
-
-static void
-winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg)
-{
- int iRetries = 0;
- char pszDisplay[512];
- int iReturn;
-
- ErrorF ("winInitMultiWindowWM - Hello\n");
-
- /* Check that argument pointer is not invalid */
- if (pProcArg == NULL)
- {
- ErrorF ("winInitMultiWindowWM - pProcArg is NULL. Exiting.\n");
- pthread_exit (NULL);
- }
-
- ErrorF ("winInitMultiWindowWM - Calling pthread_mutex_lock ()\n");
-
- /* Grab our garbage mutex to satisfy pthread_cond_wait */
- iReturn = pthread_mutex_lock (pProcArg->ppmServerStarted);
- if (iReturn != 0)
- {
- ErrorF ("winInitMultiWindowWM - pthread_mutex_lock () failed: %d. "
- "Exiting.\n",
- iReturn);
- pthread_exit (NULL);
- }
-
- ErrorF ("winInitMultiWindowWM - pthread_mutex_lock () returned.\n");
-
- /* Allow multiple threads to access Xlib */
- if (XInitThreads () == 0)
- {
- ErrorF ("winInitMultiWindowWM - XInitThreads () failed. Exiting.\n");
- pthread_exit (NULL);
- }
-
- /* See if X supports the current locale */
- if (XSupportsLocale () == False)
- {
- ErrorF ("winInitMultiWindowWM - Locale not supported by X. Exiting.\n");
- pthread_exit (NULL);
- }
-
- /* Release the server started mutex */
- pthread_mutex_unlock (pProcArg->ppmServerStarted);
-
- ErrorF ("winInitMultiWindowWM - pthread_mutex_unlock () returned.\n");
-
- /* Set jump point for IO Error exits */
- iReturn = setjmp (g_jmpWMEntry);
-
- /* Check if we should continue operations */
- if (iReturn != WIN_JMP_ERROR_IO
- && iReturn != WIN_JMP_OKAY)
- {
- /* setjmp returned an unknown value, exit */
- ErrorF ("winInitMultiWindowWM - setjmp returned: %d. Exiting.\n",
- iReturn);
- pthread_exit (NULL);
- }
- else if (iReturn == WIN_JMP_ERROR_IO)
- {
- ErrorF ("winInitMultiWindowWM - Caught IO Error. Exiting.\n");
- pthread_exit (NULL);
- }
-
- /* Install our error handler */
- XSetErrorHandler (winMultiWindowWMErrorHandler);
- XSetIOErrorHandler (winMultiWindowWMIOErrorHandler);
-
- /* Setup the display connection string x */
- snprintf (pszDisplay,
- 512,
- "127.0.0.1:%s.%d",
- display,
- (int) pProcArg->dwScreen);
-
- /* Print the display connection string */
- ErrorF ("winInitMultiWindowWM - DISPLAY=%s\n", pszDisplay);
-
- /* Use our generated cookie for authentication */
- winSetAuthorization();
-
- /* Open the X display */
- do
- {
- /* Try to open the display */
- pWMInfo->pDisplay = XOpenDisplay (pszDisplay);
- if (pWMInfo->pDisplay == NULL)
- {
- ErrorF ("winInitMultiWindowWM - Could not open display, try: %d, "
- "sleeping: %d\n\f",
- iRetries + 1, WIN_CONNECT_DELAY);
- ++iRetries;
- sleep (WIN_CONNECT_DELAY);
- continue;
- }
- else
- break;
- }
- while (pWMInfo->pDisplay == NULL && iRetries < WIN_CONNECT_RETRIES);
-
- /* Make sure that the display opened */
- if (pWMInfo->pDisplay == NULL)
- {
- ErrorF ("winInitMultiWindowWM - Failed opening the display. "
- "Exiting.\n");
- pthread_exit (NULL);
- }
-
- ErrorF ("winInitMultiWindowWM - XOpenDisplay () returned and "
- "successfully opened the display.\n");
-
-
- /* Create some atoms */
- pWMInfo->atmWmProtos = XInternAtom (pWMInfo->pDisplay,
- "WM_PROTOCOLS",
- False);
- pWMInfo->atmWmDelete = XInternAtom (pWMInfo->pDisplay,
- "WM_DELETE_WINDOW",
- False);
-
- pWMInfo->atmPrivMap = XInternAtom (pWMInfo->pDisplay,
- WINDOWSWM_NATIVE_HWND,
- False);
-
-
- if (1) {
- Cursor cursor = XCreateFontCursor (pWMInfo->pDisplay, XC_left_ptr);
- if (cursor)
- {
- XDefineCursor (pWMInfo->pDisplay, DefaultRootWindow(pWMInfo->pDisplay), cursor);
- XFreeCursor (pWMInfo->pDisplay, cursor);
- }
- }
-}
-
-
-/*
- * winSendMessageToWM - Send a message from the X thread to the WM thread
- */
-
-void
-winSendMessageToWM (void *pWMInfo, winWMMessagePtr pMsg)
-{
- WMMsgNodePtr pNode;
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winSendMessageToWM ()\n");
-#endif
-
- pNode = (WMMsgNodePtr)malloc(sizeof(WMMsgNodeRec));
- if (pNode != NULL)
- {
- memcpy (&pNode->msg, pMsg, sizeof(winWMMessageRec));
- PushMessage (&((WMInfoPtr)pWMInfo)->wmMsgQueue, pNode);
- }
-}
-
-
-/*
- * Window manager error handler
- */
-
-static int
-winMultiWindowWMErrorHandler (Display *pDisplay, XErrorEvent *pErr)
-{
- char pszErrorMsg[100];
-
- if (pErr->request_code == X_ChangeWindowAttributes
- && pErr->error_code == BadAccess)
- {
- ErrorF ("winMultiWindowWMErrorHandler - ChangeWindowAttributes "
- "BadAccess.\n");
- return 0;
- }
-
- XGetErrorText (pDisplay,
- pErr->error_code,
- pszErrorMsg,
- sizeof (pszErrorMsg));
- ErrorF ("winMultiWindowWMErrorHandler - ERROR: %s\n", pszErrorMsg);
-
- return 0;
-}
-
-
-/*
- * Window manager IO error handler
- */
-
-static int
-winMultiWindowWMIOErrorHandler (Display *pDisplay)
-{
- ErrorF ("\nwinMultiWindowWMIOErrorHandler!\n\n");
-
- if (g_shutdown)
- pthread_exit(NULL);
-
- /* Restart at the main entry point */
- longjmp (g_jmpWMEntry, WIN_JMP_ERROR_IO);
-
- return 0;
-}
-
-
-/*
- * X message procedure error handler
- */
-
-static int
-winMultiWindowXMsgProcErrorHandler (Display *pDisplay, XErrorEvent *pErr)
-{
- char pszErrorMsg[100];
-
- XGetErrorText (pDisplay,
- pErr->error_code,
- pszErrorMsg,
- sizeof (pszErrorMsg));
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winMultiWindowXMsgProcErrorHandler - ERROR: %s\n", pszErrorMsg);
-#endif
-
- return 0;
-}
-
-
-/*
- * X message procedure IO error handler
- */
-
-static int
-winMultiWindowXMsgProcIOErrorHandler (Display *pDisplay)
-{
- ErrorF ("\nwinMultiWindowXMsgProcIOErrorHandler!\n\n");
-
- /* Restart at the main entry point */
- longjmp (g_jmpXMsgProcEntry, WIN_JMP_ERROR_IO);
-
- return 0;
-}
-
-
-/*
- * Catch RedirectError to detect other window manager running
- */
-
-static int
-winRedirectErrorHandler (Display *pDisplay, XErrorEvent *pErr)
-{
- redirectError = TRUE;
- return 0;
-}
-
-
-/*
- * Check if another window manager is running
- */
-
-static Bool
-CheckAnotherWindowManager (Display *pDisplay, DWORD dwScreen)
-{
- /*
- Try to select the events which only one client at a time is allowed to select.
- If this causes an error, another window manager is already running...
- */
- redirectError = FALSE;
- XSetErrorHandler (winRedirectErrorHandler);
- XSelectInput(pDisplay, RootWindow (pDisplay, dwScreen),
- ResizeRedirectMask | SubstructureRedirectMask | ButtonPressMask);
- XSync (pDisplay, 0);
- XSetErrorHandler (winMultiWindowXMsgProcErrorHandler);
-
- /*
- Side effect: select the events we are actually interested in...
- */
- XSelectInput(pDisplay, RootWindow (pDisplay, dwScreen), SubstructureNotifyMask);
- XSync (pDisplay, 0);
- return redirectError;
-}
-
-/*
- * Notify the MWM thread we're exiting and not to reconnect
- */
-
-void
-winDeinitMultiWindowWM (void)
-{
- ErrorF ("winDeinitMultiWindowWM - Noting shutdown in progress\n");
- g_shutdown = TRUE;
-}
-
-/* Windows window styles */
-#define HINT_NOFRAME (1l<<0)
-#define HINT_BORDER (1L<<1)
-#define HINT_SIZEBOX (1l<<2)
-#define HINT_CAPTION (1l<<3)
-/* These two are used on their own */
-#define HINT_MAX (1L<<0)
-#define HINT_MIN (1L<<1)
-
-static void
-winApplyHints (Display *pDisplay, Window iWindow, HWND hWnd, HWND *zstyle)
-{
- static Atom windowState, motif_wm_hints, windowType;
- static Atom hiddenState, fullscreenState, belowState, aboveState;
- static Atom dockWindow;
- static int generation;
- Atom type, *pAtom = NULL;
- int format;
- unsigned long hint = 0, maxmin = 0, style, nitems = 0 , left = 0;
- WindowPtr pWin = GetProp (hWnd, WIN_WINDOW_PROP);
-
- if (!hWnd) return;
- if (!IsWindow (hWnd)) return;
-
- if (generation != serverGeneration) {
- generation = serverGeneration;
- windowState = XInternAtom(pDisplay, "_NET_WM_STATE", False);
- motif_wm_hints = XInternAtom(pDisplay, "_MOTIF_WM_HINTS", False);
- windowType = XInternAtom(pDisplay, "_NET_WM_WINDOW_TYPE", False);
- hiddenState = XInternAtom(pDisplay, "_NET_WM_STATE_HIDDEN", False);
- fullscreenState = XInternAtom(pDisplay, "_NET_WM_STATE_FULLSCREEN", False);
- belowState = XInternAtom(pDisplay, "_NET_WM_STATE_BELOW", False);
- aboveState = XInternAtom(pDisplay, "_NET_WM_STATE_ABOVE", False);
- dockWindow = XInternAtom(pDisplay, "_NET_WM_WINDOW_TYPE_DOCK", False);
- }
-
- if (XGetWindowProperty(pDisplay, iWindow, windowState, 0L,
- 1L, False, XA_ATOM, &type, &format,
- &nitems, &left, (unsigned char **)&pAtom) == Success)
- {
- if (pAtom && nitems == 1)
- {
- if (*pAtom == hiddenState) maxmin |= HINT_MIN;
- else if (*pAtom == fullscreenState) maxmin |= HINT_MAX;
- if (*pAtom == belowState) *zstyle = HWND_BOTTOM;
- else if (*pAtom == aboveState) *zstyle = HWND_TOPMOST;
- }
- if (pAtom) XFree(pAtom);
- }
-
- nitems = left = 0;
- MwmHints *mwm_hint = NULL;
- if (XGetWindowProperty(pDisplay, iWindow, motif_wm_hints, 0L,
- PropMwmHintsElements, False, motif_wm_hints, &type, &format,
- &nitems, &left, (unsigned char **)&mwm_hint) == Success)
- {
- if (mwm_hint && nitems == PropMwmHintsElements && (mwm_hint->flags & MwmHintsDecorations))
- {
- if (!mwm_hint->decorations) hint |= HINT_NOFRAME;
- else if (!(mwm_hint->decorations & MwmDecorAll))
- {
- if (mwm_hint->decorations & MwmDecorBorder) hint |= HINT_BORDER;
- if (mwm_hint->decorations & MwmDecorHandle) hint |= HINT_SIZEBOX;
- if (mwm_hint->decorations & MwmDecorTitle) hint |= HINT_CAPTION;
- }
- }
- if (mwm_hint) XFree(mwm_hint);
- }
-
- nitems = left = 0;
- pAtom = NULL;
- if (XGetWindowProperty(pDisplay, iWindow, windowType, 0L,
- 1L, False, XA_ATOM, &type, &format,
- &nitems, &left, (unsigned char **)&pAtom) == Success)
- {
- if (pAtom && nitems == 1)
- {
- if (*pAtom == dockWindow)
- {
- hint = (hint & ~HINT_NOFRAME) | HINT_SIZEBOX; /* Xming puts a sizebox on dock windows */
- *zstyle = HWND_TOPMOST;
- }
- }
- if (pAtom) XFree(pAtom);
- }
-
- /* Apply Styles, overriding hint settings from above */
- style = winOverrideStyle((unsigned long)pWin);
- if (style & STYLE_TOPMOST) *zstyle = HWND_TOPMOST;
- else if (style & STYLE_MAXIMIZE) maxmin = (hint & ~HINT_MIN) | HINT_MAX;
- else if (style & STYLE_MINIMIZE) maxmin = (hint & ~HINT_MAX) | HINT_MIN;
- else if (style & STYLE_BOTTOM) *zstyle = HWND_BOTTOM;
-
- if (maxmin & HINT_MAX) SendMessage(hWnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
- else if (maxmin & HINT_MIN) SendMessage(hWnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
-
- if (style & STYLE_NOTITLE)
- hint = (hint & ~HINT_NOFRAME & ~HINT_BORDER & ~HINT_CAPTION) | HINT_SIZEBOX;
- else if (style & STYLE_OUTLINE)
- hint = (hint & ~HINT_NOFRAME & ~HINT_SIZEBOX & ~HINT_CAPTION) | HINT_BORDER;
- else if (style & STYLE_NOFRAME)
- hint = (hint & ~HINT_BORDER & ~HINT_CAPTION & ~HINT_SIZEBOX) | HINT_NOFRAME;
-
- style = GetWindowLongPtr(hWnd, GWL_STYLE) & ~WS_CAPTION & ~WS_SIZEBOX; /* Just in case */
- if (!style) return;
- if (!hint) /* All on, but no resize of children is allowed */
- style = style | WS_CAPTION | (GetParent(hWnd) ? 0 : WS_SIZEBOX);
- else if (hint & HINT_NOFRAME); /* All off, so do nothing */
- else style = style | ((hint & HINT_BORDER) ? WS_BORDER : 0) |
- ((hint & HINT_SIZEBOX) ? (GetParent(hWnd) ? 0 : WS_SIZEBOX) : 0) |
- ((hint & HINT_CAPTION) ? WS_CAPTION : 0);
- SetWindowLongPtr (hWnd, GWL_STYLE, style);
-}
-
-void
-winUpdateWindowPosition (HWND hWnd, Bool reshape, HWND *zstyle)
-{
- int iX, iY, iWidth, iHeight;
- int iDx, iDy;
- RECT rcNew;
- WindowPtr pWin = GetProp (hWnd, WIN_WINDOW_PROP);
- DrawablePtr pDraw = NULL;
-
- if (!pWin) return;
- pDraw = &pWin->drawable;
- if (!pDraw) return;
-
- /* Get the X and Y location of the X window */
- iX = pWin->drawable.x + GetSystemMetrics (SM_XVIRTUALSCREEN);
- iY = pWin->drawable.y + GetSystemMetrics (SM_YVIRTUALSCREEN);
-
- /* Get the height and width of the X window */
- iWidth = pWin->drawable.width;
- iHeight = pWin->drawable.height;
-
- /* Setup a rectangle with the X window position and size */
- SetRect (&rcNew, iX, iY, iX + iWidth, iY + iHeight);
-
-#if 0
- ErrorF ("winUpdateWindowPosition - (%d, %d)-(%d, %d)\n",
- rcNew.left, rcNew.top,
- rcNew.right, rcNew.bottom);
-#endif
-
- AdjustWindowRectEx (&rcNew, GetWindowLongPtr (hWnd, GWL_STYLE), FALSE, WS_EX_APPWINDOW);
-
- /* Don't allow window decoration to disappear off to top-left as a result of this adjustment */
- if (rcNew.left < GetSystemMetrics(SM_XVIRTUALSCREEN))
- {
- iDx = GetSystemMetrics(SM_XVIRTUALSCREEN) - rcNew.left;
- rcNew.left += iDx;
- rcNew.right += iDx;
- }
-
- if (rcNew.top < GetSystemMetrics(SM_YVIRTUALSCREEN))
- {
- iDy = GetSystemMetrics(SM_YVIRTUALSCREEN) - rcNew.top;
- rcNew.top += iDy;
- rcNew.bottom += iDy;
- }
-
-#if 0
- ErrorF ("winUpdateWindowPosition - (%d, %d)-(%d, %d)\n",
- rcNew.left, rcNew.top,
- rcNew.right, rcNew.bottom);
-#endif
-
- /* Position the Windows window */
- SetWindowPos (hWnd, *zstyle, rcNew.left, rcNew.top,
- rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
- 0);
-
- if (reshape)
- {
- winReshapeMultiWindow(pWin);
- winUpdateRgnMultiWindow(pWin);
- }
-}
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *Copyright (C) Colin Harrison 2005-2009
+ *
+ *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, 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 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 XFREE86 PROJECT 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 XFree86 Project
+ *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 XFree86 Project.
+ *
+ * Authors: Kensuke Matsuzaki
+ * Colin Harrison
+ */
+
+/* X headers */
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#ifdef __CYGWIN__
+#include <sys/select.h>
+#endif
+#include <fcntl.h>
+#include <setjmp.h>
+#define HANDLE void *
+#ifdef _MSC_VER
+typedef int pid_t;
+#endif
+#include <pthread.h>
+#undef HANDLE
+#include <X11/X.h>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <X11/Xlocale.h>
+#include <X11/Xproto.h>
+#include <X11/Xutil.h>
+#include <X11/cursorfont.h>
+#include <X11/Xwindows.h>
+
+/* Local headers */
+#include "objbase.h"
+#include "ddraw.h"
+#include "winwindow.h"
+#include "winprefs.h"
+#include "window.h"
+#include "pixmapstr.h"
+#include "winmsg.h"
+#include "windowstr.h"
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+#include <X11/extensions/windowswmstr.h>
+#else
+/* We need the native HWND atom for intWM, so for consistency use the
+ same name as extWM would if we were building with enabled... */
+#define WINDOWSWM_NATIVE_HWND "_WINDOWSWM_NATIVE_HWND"
+#endif
+
+extern void winDebug(const char *format, ...);
+extern void winReshapeMultiWindow(WindowPtr pWin);
+extern void winUpdateRgnMultiWindow(WindowPtr pWin);
+
+/*
+ * Constant defines
+ */
+
+#define WIN_CONNECT_RETRIES 5
+#define WIN_CONNECT_DELAY 5
+#ifdef HAS_DEVWINDOWS
+# define WIN_MSG_QUEUE_FNAME "/dev/windows"
+#endif
+#define WIN_JMP_OKAY 0
+#define WIN_JMP_ERROR_IO 2
+
+/*
+ * Local structures
+ */
+
+typedef struct _WMMsgNodeRec {
+ winWMMessageRec msg;
+ struct _WMMsgNodeRec *pNext;
+} WMMsgNodeRec, *WMMsgNodePtr;
+
+typedef struct _WMMsgQueueRec {
+ struct _WMMsgNodeRec *pHead;
+ struct _WMMsgNodeRec *pTail;
+ pthread_mutex_t pmMutex;
+ pthread_cond_t pcNotEmpty;
+ int nQueueSize;
+} WMMsgQueueRec, *WMMsgQueuePtr;
+
+typedef struct _WMInfo {
+ Display *pDisplay;
+ WMMsgQueueRec wmMsgQueue;
+ Atom atmWmProtos;
+ Atom atmWmDelete;
+ Atom atmPrivMap;
+ Bool fAllowOtherWM;
+} WMInfoRec, *WMInfoPtr;
+
+typedef struct _WMProcArgRec {
+ DWORD dwScreen;
+ WMInfoPtr pWMInfo;
+ pthread_mutex_t *ppmServerStarted;
+} WMProcArgRec, *WMProcArgPtr;
+
+typedef struct _XMsgProcArgRec {
+ Display *pDisplay;
+ DWORD dwScreen;
+ WMInfoPtr pWMInfo;
+ pthread_mutex_t *ppmServerStarted;
+ HWND hwndScreen;
+} XMsgProcArgRec, *XMsgProcArgPtr;
+
+
+/*
+ * References to external symbols
+ */
+
+extern char *display;
+extern void ErrorF (const char* /*f*/, ...);
+
+/*
+ * Prototypes for local functions
+ */
+
+static void
+PushMessage (WMMsgQueuePtr pQueue, WMMsgNodePtr pNode);
+
+static WMMsgNodePtr
+PopMessage (WMMsgQueuePtr pQueue, WMInfoPtr pWMInfo);
+
+static Bool
+InitQueue (WMMsgQueuePtr pQueue);
+
+static void
+GetWindowName (Display * pDpy, Window iWin, wchar_t **ppName);
+
+static int
+SendXMessage (Display *pDisplay, Window iWin, Atom atmType, long nData);
+
+static void
+UpdateName (WMInfoPtr pWMInfo, Window iWindow);
+
+static void*
+winMultiWindowWMProc (void* pArg);
+
+static int
+winMultiWindowWMErrorHandler (Display *pDisplay, XErrorEvent *pErr);
+
+static int
+winMultiWindowWMIOErrorHandler (Display *pDisplay);
+
+static void *
+winMultiWindowXMsgProc (void *pArg);
+
+static int
+winMultiWindowXMsgProcErrorHandler (Display *pDisplay, XErrorEvent *pErr);
+
+static int
+winMultiWindowXMsgProcIOErrorHandler (Display *pDisplay);
+
+static int
+winRedirectErrorHandler (Display *pDisplay, XErrorEvent *pErr);
+
+static void
+winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg);
+
+static Bool
+CheckAnotherWindowManager (Display *pDisplay, DWORD dwScreen);
+
+static void
+winApplyHints (Display *pDisplay, Window iWindow, HWND hWnd, HWND *zstyle);
+
+void
+winUpdateWindowPosition (HWND hWnd, Bool reshape, HWND *zstyle);
+
+/*
+ * Local globals
+ */
+
+static jmp_buf g_jmpWMEntry;
+static jmp_buf g_jmpXMsgProcEntry;
+static Bool g_shutdown = FALSE;
+static Bool redirectError = FALSE;
+static Bool g_fAnotherWMRunning = FALSE;
+
+/*
+ * PushMessage - Push a message onto the queue
+ */
+
+static void
+PushMessage (WMMsgQueuePtr pQueue, WMMsgNodePtr pNode)
+{
+
+ /* Lock the queue mutex */
+ pthread_mutex_lock (&pQueue->pmMutex);
+
+ pNode->pNext = NULL;
+
+ if (pQueue->pTail != NULL)
+ {
+ pQueue->pTail->pNext = pNode;
+ }
+ pQueue->pTail = pNode;
+
+ if (pQueue->pHead == NULL)
+ {
+ pQueue->pHead = pNode;
+ }
+
+ /* Increase the count of elements in the queue by one */
+ ++(pQueue->nQueueSize);
+
+ /* Release the queue mutex */
+ pthread_mutex_unlock (&pQueue->pmMutex);
+
+ /* Signal that the queue is not empty */
+ pthread_cond_signal (&pQueue->pcNotEmpty);
+}
+
+
+#ifdef WINDBG
+/*
+ * QueueSize - Return the size of the queue
+ */
+
+static int
+QueueSize (WMMsgQueuePtr pQueue)
+{
+ WMMsgNodePtr pNode;
+ int nSize = 0;
+
+ /* Loop through all elements in the queue */
+ for (pNode = pQueue->pHead; pNode != NULL; pNode = pNode->pNext)
+ ++nSize;
+
+ return nSize;
+}
+#endif
+
+
+/*
+ * PopMessage - Pop a message from the queue
+ */
+
+static WMMsgNodePtr
+PopMessage (WMMsgQueuePtr pQueue, WMInfoPtr pWMInfo)
+{
+ WMMsgNodePtr pNode;
+
+ /* Lock the queue mutex */
+ pthread_mutex_lock (&pQueue->pmMutex);
+
+ /* Wait for --- */
+ while (pQueue->pHead == NULL)
+ {
+ pthread_cond_wait (&pQueue->pcNotEmpty, &pQueue->pmMutex);
+ }
+
+ pNode = pQueue->pHead;
+ if (pQueue->pHead != NULL)
+ {
+ pQueue->pHead = pQueue->pHead->pNext;
+ }
+
+ if (pQueue->pTail == pNode)
+ {
+ pQueue->pTail = NULL;
+ }
+
+ /* Drop the number of elements in the queue by one */
+ --(pQueue->nQueueSize);
+
+ winDebug ("Queue Size %d %d\n", pQueue->nQueueSize, QueueSize(pQueue));
+
+ /* Release the queue mutex */
+ pthread_mutex_unlock (&pQueue->pmMutex);
+
+ return pNode;
+}
+
+
+#if 0
+/*
+ * HaveMessage -
+ */
+
+static Bool
+HaveMessage (WMMsgQueuePtr pQueue, UINT msg, Window iWindow)
+{
+ WMMsgNodePtr pNode;
+
+ for (pNode = pQueue->pHead; pNode != NULL; pNode = pNode->pNext)
+ {
+ if (pNode->msg.msg==msg && pNode->msg.iWindow==iWindow)
+ return True;
+ }
+
+ return False;
+}
+#endif
+
+
+/*
+ * InitQueue - Initialize the Window Manager message queue
+ */
+
+static
+Bool
+InitQueue (WMMsgQueuePtr pQueue)
+{
+ /* Check if the pQueue pointer is NULL */
+ if (pQueue == NULL)
+ {
+ ErrorF ("InitQueue - pQueue is NULL. Exiting.\n");
+ return FALSE;
+ }
+
+ /* Set the head and tail to NULL */
+ pQueue->pHead = NULL;
+ pQueue->pTail = NULL;
+
+ /* There are no elements initially */
+ pQueue->nQueueSize = 0;
+
+ winDebug ("InitQueue - Queue Size %d %d\n", pQueue->nQueueSize,
+ QueueSize(pQueue));
+
+ winDebug ("InitQueue - Calling pthread_mutex_init\n");
+
+ /* Create synchronization objects */
+ pthread_mutex_init (&pQueue->pmMutex, NULL);
+
+ winDebug ("InitQueue - pthread_mutex_init returned\n");
+ winDebug ("InitQueue - Calling pthread_cond_init\n");
+
+ pthread_cond_init (&pQueue->pcNotEmpty, NULL);
+
+ winDebug ("InitQueue - pthread_cond_init returned\n");
+
+ return TRUE;
+}
+
+
+/*
+ * GetWindowName - Retrieve the title of an X Window
+ */
+
+static void
+GetWindowName (Display *pDisplay, Window iWin, wchar_t **ppName)
+{
+ int nResult, nNum;
+ char **ppList;
+ char *pszReturnData;
+ int iLen, i;
+ XTextProperty xtpName;
+
+ winDebug ("GetWindowName\n");
+
+ /* Intialize ppName to NULL */
+ *ppName = NULL;
+
+ /* Try to get --- */
+ nResult = XGetWMName (pDisplay, iWin, &xtpName);
+ if (!nResult || !xtpName.value || !xtpName.nitems)
+ {
+ ErrorF ("GetWindowName - XGetWMName failed. No name.\n");
+ return;
+ }
+
+ if (Xutf8TextPropertyToTextList (pDisplay, &xtpName, &ppList, &nNum) >= Success && nNum > 0 && *ppList)
+ {
+ iLen = 0;
+ for (i = 0; i < nNum; i++) iLen += strlen(ppList[i]);
+ pszReturnData = (char *) malloc (iLen + 1);
+ pszReturnData[0] = '\0';
+ for (i = 0; i < nNum; i++) strcat (pszReturnData, ppList[i]);
+ }
+ else
+ {
+ pszReturnData = (char *) malloc (1);
+ pszReturnData[0] = '\0';
+ }
+ iLen = MultiByteToWideChar (CP_UTF8, 0, pszReturnData, -1, NULL, 0);
+ *ppName = (wchar_t*)malloc(sizeof(wchar_t)*(iLen + 1));
+ MultiByteToWideChar (CP_UTF8, 0, pszReturnData, -1, *ppName, iLen);
+ XFree (xtpName.value);
+ if (ppList) XFreeStringList (ppList);
+ free (pszReturnData);
+
+ winDebug ("GetWindowName - Returning\n");
+}
+
+
+/*
+ * Send a message to the X server from the WM thread
+ */
+
+static int
+SendXMessage (Display *pDisplay, Window iWin, Atom atmType, long nData)
+{
+ XEvent e;
+
+ /* Prepare the X event structure */
+ e.type = ClientMessage;
+ e.xclient.window = iWin;
+ e.xclient.message_type = atmType;
+ e.xclient.format = 32;
+ e.xclient.data.l[0] = nData;
+ e.xclient.data.l[1] = CurrentTime;
+
+ /* Send the event to X */
+ return XSendEvent (pDisplay, iWin, False, NoEventMask, &e);
+}
+
+
+/*
+ * Updates the name of a HWND according to its X WM_NAME property
+ */
+
+static void
+UpdateName (WMInfoPtr pWMInfo, Window iWindow)
+{
+ wchar_t *pszName;
+ Atom atmType;
+ int fmtRet;
+ unsigned long items, remain;
+ HWND *retHwnd, hWnd;
+ XWindowAttributes attr;
+
+ hWnd = 0;
+
+ /* See if we can get the cached HWND for this window... */
+ if (XGetWindowProperty (pWMInfo->pDisplay,
+ iWindow,
+ pWMInfo->atmPrivMap,
+ 0,
+ 1,
+ False,
+ XA_INTEGER,//pWMInfo->atmPrivMap,
+ &atmType,
+ &fmtRet,
+ &items,
+ &remain,
+ (unsigned char **) &retHwnd) == Success)
+ {
+ if (retHwnd)
+ {
+ hWnd = *retHwnd;
+ XFree (retHwnd);
+ }
+ }
+
+ /* Some sanity checks */
+ if (!hWnd) return;
+ if (!IsWindow (hWnd)) return;
+
+ /* Set the Windows window name */
+ GetWindowName (pWMInfo->pDisplay, iWindow, &pszName);
+ if (pszName)
+ {
+ /* Get the window attributes */
+ XGetWindowAttributes (pWMInfo->pDisplay,
+ iWindow,
+ &attr);
+ if (!attr.override_redirect)
+ {
+ SetWindowTextW (hWnd, pszName);
+ winUpdateIcon (iWindow);
+ }
+
+ free (pszName);
+ }
+}
+
+
+#if 0
+/*
+ * Fix up any differences between the X11 and Win32 window stacks
+ * starting at the window passed in
+ */
+static void
+PreserveWin32Stack(WMInfoPtr pWMInfo, Window iWindow, UINT direction)
+{
+ Atom atmType;
+ int fmtRet;
+ unsigned long items, remain;
+ HWND hWnd, *retHwnd;
+ DWORD myWinProcID, winProcID;
+ Window xWindow;
+ WINDOWPLACEMENT wndPlace;
+
+ hWnd = NULL;
+ /* See if we can get the cached HWND for this window... */
+ if (XGetWindowProperty (pWMInfo->pDisplay,
+ iWindow,
+ pWMInfo->atmPrivMap,
+ 0,
+ 1,
+ False,
+ XA_INTEGER,//pWMInfo->atmPrivMap,
+ &atmType,
+ &fmtRet,
+ &items,
+ &remain,
+ (unsigned char **) &retHwnd) == Success)
+ {
+ if (retHwnd)
+ {
+ hWnd = *retHwnd;
+ XFree (retHwnd);
+ }
+ }
+
+ if (!hWnd) return;
+
+ GetWindowThreadProcessId (hWnd, &myWinProcID);
+ hWnd = GetNextWindow (hWnd, direction);
+
+ while (hWnd) {
+ GetWindowThreadProcessId (hWnd, &winProcID);
+ if (winProcID == myWinProcID)
+ {
+ wndPlace.length = sizeof(WINDOWPLACEMENT);
+ GetWindowPlacement (hWnd, &wndPlace);
+ if ( !(wndPlace.showCmd==SW_HIDE ||
+ wndPlace.showCmd==SW_MINIMIZE) )
+ {
+ xWindow = (Window)GetProp (hWnd, WIN_WID_PROP);
+ if (xWindow)
+ {
+ if (direction==GW_HWNDPREV)
+ XRaiseWindow (pWMInfo->pDisplay, xWindow);
+ else
+ XLowerWindow (pWMInfo->pDisplay, xWindow);
+ }
+ }
+ }
+ hWnd = GetNextWindow(hWnd, direction);
+ }
+}
+#endif /* PreserveWin32Stack */
+
+
+/*
+ * winMultiWindowWMProc
+ */
+
+static void *
+winMultiWindowWMProc (void *pArg)
+{
+ WMProcArgPtr pProcArg = (WMProcArgPtr)pArg;
+ WMInfoPtr pWMInfo = pProcArg->pWMInfo;
+
+ /* Initialize the Window Manager */
+ winInitMultiWindowWM (pWMInfo, pProcArg);
+
+ winDebug ("winMultiWindowWMProc ()\n");
+
+ /* Loop until we explicity break out */
+ for (;;)
+ {
+ WMMsgNodePtr pNode;
+
+ if(g_fAnotherWMRunning)/* Another Window manager exists. */
+ {
+ Sleep (1000);
+ continue;
+ }
+
+ /* Pop a message off of our queue */
+ pNode = PopMessage (&pWMInfo->wmMsgQueue, pWMInfo);
+ if (pNode == NULL)
+ {
+ /* Bail if PopMessage returns without a message */
+ /* NOTE: Remember that PopMessage is a blocking function. */
+ ErrorF ("winMultiWindowWMProc - Queue is Empty? Exiting.\n");
+ pthread_exit (NULL);
+ }
+
+ winDebug ("winMultiWindowWMProc - %d ms MSG: %d ID: %d\n",
+ GetTickCount (), (int)pNode->msg.msg, (int)pNode->msg.dwID);
+
+ /* Branch on the message type */
+ switch (pNode->msg.msg)
+ {
+ case WM_WM_RAISE:
+ winDebug ("\tWM_WM_RAISE\n");
+ /* Raise the window */
+ XRaiseWindow (pWMInfo->pDisplay, pNode->msg.iWindow);
+ break;
+
+ case WM_WM_LOWER:
+ winDebug ("\tWM_WM_LOWER\n");
+
+ /* Lower the window */
+ XLowerWindow (pWMInfo->pDisplay, pNode->msg.iWindow);
+ break;
+
+ case WM_WM_MAP:
+ winDebug ("\tWM_WM_MAP\n");
+ /* Put a note as to the HWND associated with this Window */
+ XChangeProperty (pWMInfo->pDisplay,
+ pNode->msg.iWindow,
+ pWMInfo->atmPrivMap,
+ XA_INTEGER,//pWMInfo->atmPrivMap,
+ 32,
+ PropModeReplace,
+ (unsigned char *) &(pNode->msg.hwndWindow),
+ 1);
+ UpdateName (pWMInfo, pNode->msg.iWindow);
+ winUpdateIcon (pNode->msg.iWindow);
+ {
+ HWND zstyle = HWND_NOTOPMOST;
+ winApplyHints (pWMInfo->pDisplay, pNode->msg.iWindow, pNode->msg.hwndWindow, &zstyle);
+ winUpdateWindowPosition (pNode->msg.hwndWindow, TRUE, &zstyle);
+ }
+ break;
+
+ case WM_WM_MAP2:
+ winDebug ("\tWM_WM_MAP2\n");
+
+ XChangeProperty (pWMInfo->pDisplay,
+ pNode->msg.iWindow,
+ pWMInfo->atmPrivMap,
+ XA_INTEGER,//pWMInfo->atmPrivMap,
+ 32,
+ PropModeReplace,
+ (unsigned char *) &(pNode->msg.hwndWindow),
+ 1);
+ break;
+
+ case WM_WM_MAP3:
+ winDebug ("\tWM_WM_MAP3\n");
+
+ /* Put a note as to the HWND associated with this Window */
+ XChangeProperty (pWMInfo->pDisplay,
+ pNode->msg.iWindow,
+ pWMInfo->atmPrivMap,
+ XA_INTEGER,//pWMInfo->atmPrivMap,
+ 32,
+ PropModeReplace,
+ (unsigned char *) &(pNode->msg.hwndWindow),
+ 1);
+ UpdateName (pWMInfo, pNode->msg.iWindow);
+ winUpdateIcon (pNode->msg.iWindow);
+ {
+ HWND zstyle = HWND_NOTOPMOST;
+ winApplyHints (pWMInfo->pDisplay, pNode->msg.iWindow, pNode->msg.hwndWindow, &zstyle);
+ winUpdateWindowPosition (pNode->msg.hwndWindow, TRUE, &zstyle);
+ }
+ break;
+
+ case WM_WM_UNMAP:
+ winDebug ("\tWM_WM_UNMAP\n");
+
+ /* Unmap the window */
+ XUnmapWindow (pWMInfo->pDisplay, pNode->msg.iWindow);
+ break;
+
+ case WM_WM_KILL:
+ winDebug ("\tWM_WM_KILL\n");
+ {
+ int i, n, found = 0;
+ Atom *protocols;
+
+ /* --- */
+ if (XGetWMProtocols (pWMInfo->pDisplay,
+ pNode->msg.iWindow,
+ &protocols,
+ &n))
+ {
+ for (i = 0; i < n; ++i)
+ if (protocols[i] == pWMInfo->atmWmDelete)
+ ++found;
+
+ XFree (protocols);
+ }
+
+ /* --- */
+ if (found)
+ SendXMessage (pWMInfo->pDisplay,
+ pNode->msg.iWindow,
+ pWMInfo->atmWmProtos,
+ pWMInfo->atmWmDelete);
+ else
+ XKillClient (pWMInfo->pDisplay,
+ pNode->msg.iWindow);
+ }
+ break;
+
+ case WM_WM_ACTIVATE:
+ winDebug ("\tWM_WM_ACTIVATE\n");
+
+ /* Set the input focus */
+ XSetInputFocus (pWMInfo->pDisplay,
+ pNode->msg.iWindow,
+ RevertToPointerRoot,
+ CurrentTime);
+ break;
+
+ case WM_WM_NAME_EVENT:
+ UpdateName (pWMInfo, pNode->msg.iWindow);
+ break;
+
+ case WM_WM_HINTS_EVENT:
+ winUpdateIcon (pNode->msg.iWindow);
+ break;
+
+ case WM_WM_CHANGE_STATE:
+ /* Minimize the window in Windows */
+ winMinimizeWindow (pNode->msg.iWindow);
+ break;
+
+ default:
+ ErrorF ("winMultiWindowWMProc - Unknown Message. Exiting.\n");
+ pthread_exit (NULL);
+ break;
+ }
+
+ /* Free the retrieved message */
+ free (pNode);
+
+ /* Flush any pending events on our display */
+ XFlush (pWMInfo->pDisplay);
+ }
+
+ /* Free the condition variable */
+ pthread_cond_destroy (&pWMInfo->wmMsgQueue.pcNotEmpty);
+
+ /* Free the mutex variable */
+ pthread_mutex_destroy (&pWMInfo->wmMsgQueue.pmMutex);
+
+ /* Free the passed-in argument */
+ free (pProcArg);
+
+ winDebug("-winMultiWindowWMProc ()\n");
+ return NULL;
+}
+
+
+/*
+ * X message procedure
+ */
+
+static void *
+winMultiWindowXMsgProc (void *pArg)
+{
+ winWMMessageRec msg;
+ XMsgProcArgPtr pProcArg = (XMsgProcArgPtr) pArg;
+ char pszDisplay[512];
+ int iRetries;
+ XEvent event;
+ Atom atmWmName;
+ Atom atmWmHints;
+ Atom atmWmChange;
+ int iReturn;
+ XIconSize *xis;
+
+ winDebug ("winMultiWindowXMsgProc - Hello\n");
+
+ /* Check that argument pointer is not invalid */
+ if (pProcArg == NULL)
+ {
+ ErrorF ("winMultiWindowXMsgProc - pProcArg is NULL. Exiting.\n");
+ pthread_exit (NULL);
+ }
+
+ winDebug ("winMultiWindowXMsgProc - Calling pthread_mutex_lock ()\n");
+
+ /* Grab the server started mutex - pause until we get it */
+ iReturn = pthread_mutex_lock (pProcArg->ppmServerStarted);
+ if (iReturn != 0)
+ {
+ ErrorF ("winMultiWindowXMsgProc - pthread_mutex_lock () failed: %d. "
+ "Exiting.\n",
+ iReturn);
+ pthread_exit (NULL);
+ }
+
+ winDebug ("winMultiWindowXMsgProc - pthread_mutex_lock () returned.\n");
+
+ /* See if X supports the current locale */
+ if (XSupportsLocale () == False)
+ {
+ ErrorF ("winMultiWindowXMsgProc - Locale not supported by X. "
+ "Exiting.\n");
+ pthread_exit (NULL);
+ }
+
+ /* Release the server started mutex */
+ pthread_mutex_unlock (pProcArg->ppmServerStarted);
+
+ winDebug ("winMultiWindowXMsgProc - pthread_mutex_unlock () returned.\n");
+
+ /* Set jump point for IO Error exits */
+ iReturn = setjmp (g_jmpXMsgProcEntry);
+
+ /* Check if we should continue operations */
+ if (iReturn != WIN_JMP_ERROR_IO
+ && iReturn != WIN_JMP_OKAY)
+ {
+ /* setjmp returned an unknown value, exit */
+ ErrorF ("winInitMultiWindowXMsgProc - setjmp returned: %d. Exiting.\n",
+ iReturn);
+ pthread_exit (NULL);
+ }
+ else if (iReturn == WIN_JMP_ERROR_IO)
+ {
+ ErrorF ("winInitMultiWindowXMsgProc - Caught IO Error. Exiting.\n");
+ pthread_exit (NULL);
+ }
+
+ /* Install our error handler */
+ XSetErrorHandler (winMultiWindowXMsgProcErrorHandler);
+ XSetIOErrorHandler (winMultiWindowXMsgProcIOErrorHandler);
+
+ /* Setup the display connection string x */
+ snprintf (pszDisplay,
+ 512, "127.0.0.1:%s.%d", display, (int)pProcArg->dwScreen);
+
+ /* Print the display connection string */
+ winDebug ("winMultiWindowXMsgProc - DISPLAY=%s\n", pszDisplay);
+
+ /* Use our generated cookie for authentication */
+ winSetAuthorization();
+
+ /* Initialize retry count */
+ iRetries = 0;
+
+ /* Open the X display */
+ do
+ {
+ /* Try to open the display */
+ pProcArg->pDisplay = XOpenDisplay (pszDisplay);
+ if (pProcArg->pDisplay == NULL)
+ {
+ winDebug ("winMultiWindowXMsgProc - Could not open display, try: %d, "
+ "sleeping: %d\n\f",
+ iRetries + 1, WIN_CONNECT_DELAY);
+ ++iRetries;
+ sleep (WIN_CONNECT_DELAY);
+ continue;
+ }
+ else
+ break;
+ }
+ while (pProcArg->pDisplay == NULL && iRetries < WIN_CONNECT_RETRIES);
+
+ /* Make sure that the display opened */
+ if (pProcArg->pDisplay == NULL)
+ {
+ ErrorF ("winMultiWindowXMsgProc - Failed opening the display. "
+ "Exiting.\n");
+ pthread_exit (NULL);
+ }
+
+ winDebug ("winMultiWindowXMsgProc - XOpenDisplay () returned and "
+ "successfully opened the display.\n");
+
+ /* Check if another window manager is already running */
+ g_fAnotherWMRunning = CheckAnotherWindowManager (pProcArg->pDisplay, pProcArg->dwScreen);
+
+ if (g_fAnotherWMRunning && !pProcArg->pWMInfo->fAllowOtherWM)
+ {
+ ErrorF ("winMultiWindowXMsgProc - "
+ "another window manager is running. Exiting.\n");
+ pthread_exit (NULL);
+ }
+
+ /* Set up the supported icon sizes */
+ xis = XAllocIconSize ();
+ if (xis)
+ {
+ xis->min_width = xis->min_height = 16;
+ xis->max_width = xis->max_height = 48;
+ xis->width_inc = xis->height_inc = 16;
+ XSetIconSizes (pProcArg->pDisplay,
+ RootWindow (pProcArg->pDisplay, pProcArg->dwScreen),
+ xis,
+ 1);
+ XFree (xis);
+ }
+
+ atmWmName = XInternAtom (pProcArg->pDisplay,
+ "WM_NAME",
+ False);
+ atmWmHints = XInternAtom (pProcArg->pDisplay,
+ "WM_HINTS",
+ False);
+ atmWmChange = XInternAtom (pProcArg->pDisplay,
+ "WM_CHANGE_STATE",
+ False);
+
+ /*
+ iiimxcf had a bug until 2009-04-27, assuming that the
+ WM_STATE atom exists, causing clients to fail with
+ a BadAtom X error if it doesn't.
+
+ Since this is on in the default Solaris 10 install,
+ workaround this by making sure it does exist...
+ */
+ XInternAtom(pProcArg->pDisplay, "WM_STATE", 0);
+
+ /* Loop until we explicitly break out */
+ while (1)
+ {
+ if (g_shutdown)
+ break;
+
+ if (pProcArg->pWMInfo->fAllowOtherWM && !XPending (pProcArg->pDisplay))
+ {
+ if (CheckAnotherWindowManager (pProcArg->pDisplay, pProcArg->dwScreen))
+ {
+ if (!g_fAnotherWMRunning)
+ {
+ g_fAnotherWMRunning = TRUE;
+ SendMessage(*(HWND*)pProcArg->hwndScreen, WM_UNMANAGE, 0, 0);
+ }
+ }
+ else
+ {
+ if (g_fAnotherWMRunning)
+ {
+ g_fAnotherWMRunning = FALSE;
+ SendMessage(*(HWND*)pProcArg->hwndScreen, WM_MANAGE, 0, 0);
+ }
+ }
+ Sleep (500);
+ continue;
+ }
+
+ /* Fetch next event */
+ XNextEvent (pProcArg->pDisplay, &event);
+
+ /* Branch on event type */
+ if (event.type == MapNotify /* CreateNotify */)
+ {
+ XWindowAttributes attr;
+
+ XSelectInput (pProcArg->pDisplay,
+ event.xcreatewindow.window,
+ PropertyChangeMask);
+
+ /* Get the window attributes */
+ XGetWindowAttributes (pProcArg->pDisplay,
+ event.xcreatewindow.window,
+ &attr);
+
+ if (!attr.override_redirect && attr.class != InputOnly)
+ XSetWindowBorderWidth(pProcArg->pDisplay,
+ event.xcreatewindow.window,
+ 0);
+ }
+ else if (event.type == MapNotify)
+ {
+ /* Fake a reparentNotify event as SWT/Motif expects a
+ Window Manager to reparent a top-level window when
+ it is mapped and waits until they do.
+
+ We don't actually need to reparent, as the frame is
+ a native window, not an X window
+
+ We do this on MapNotify, not MapRequest like a real
+ Window Manager would, so we don't have do get involved
+ in actually mapping the window via it's (non-existent)
+ parent...
+
+ See sourceware bugzilla #9848
+ */
+
+ XWindowAttributes attr;
+ Window root;
+ Window parent;
+ Window *children;
+ unsigned int nchildren;
+
+ if (XGetWindowAttributes(event.xmap.display,
+ event.xmap.window,
+ &attr) &&
+ XQueryTree(event.xmap.display,
+ event.xmap.window,
+ &root, &parent, &children, &nchildren))
+ {
+ if (children) XFree(children);
+
+ /*
+ It's a top-level window if the parent window is a root window
+ Only non-override_redirect windows can get reparented
+ */
+ if ((attr.root == parent) && !event.xmap.override_redirect)
+ {
+ XEvent event_send;
+
+ event_send.type = ReparentNotify;
+ event_send.xreparent.event = event.xmap.window;
+ event_send.xreparent.window = event.xmap.window;
+ event_send.xreparent.parent = parent;
+ event_send.xreparent.x = attr.x;
+ event_send.xreparent.y = attr.y;
+
+ XSendEvent(event.xmap.display,
+ event.xmap.window,
+ True, StructureNotifyMask,
+ &event_send);
+ }
+ }
+ }
+ else if (event.type == PropertyNotify
+ && event.xproperty.atom == atmWmName)
+ {
+ memset (&msg, 0, sizeof (msg));
+
+ msg.msg = WM_WM_NAME_EVENT;
+ msg.iWindow = event.xproperty.window;
+
+ /* Other fields ignored */
+ winSendMessageToWM (pProcArg->pWMInfo, &msg);
+ }
+ else if (event.type == PropertyNotify
+ && event.xproperty.atom == atmWmHints)
+ {
+ memset (&msg, 0, sizeof (msg));
+
+ msg.msg = WM_WM_HINTS_EVENT;
+ msg.iWindow = event.xproperty.window;
+
+ /* Other fields ignored */
+ winSendMessageToWM (pProcArg->pWMInfo, &msg);
+ }
+ else if (event.type == ClientMessage
+ && event.xclient.message_type == atmWmChange
+ && event.xclient.data.l[0] == IconicState)
+ {
+ winDebug ("winMultiWindowXMsgProc - WM_CHANGE_STATE - IconicState\n");
+
+ memset (&msg, 0, sizeof (msg));
+
+ msg.msg = WM_WM_CHANGE_STATE;
+ msg.iWindow = event.xclient.window;
+
+ winSendMessageToWM (pProcArg->pWMInfo, &msg);
+ }
+ }
+
+ XCloseDisplay (pProcArg->pDisplay);
+ pthread_exit (NULL);
+ return NULL;
+}
+
+
+/*
+ * winInitWM - Entry point for the X server to spawn
+ * the Window Manager thread. Called from
+ * winscrinit.c/winFinishScreenInitFB ().
+ */
+
+Bool
+winInitWM (void **ppWMInfo,
+ pthread_t *ptWMProc,
+ pthread_t *ptXMsgProc,
+ pthread_mutex_t *ppmServerStarted,
+ int dwScreen,
+ HWND hwndScreen,
+ BOOL allowOtherWM)
+{
+ WMProcArgPtr pArg = (WMProcArgPtr) malloc (sizeof(WMProcArgRec));
+ WMInfoPtr pWMInfo = (WMInfoPtr) malloc (sizeof(WMInfoRec));
+ XMsgProcArgPtr pXMsgArg = (XMsgProcArgPtr) malloc (sizeof(XMsgProcArgRec));
+
+ /* Bail if the input parameters are bad */
+ if (pArg == NULL || pWMInfo == NULL)
+ {
+ ErrorF ("winInitWM - malloc failed.\n");
+ return FALSE;
+ }
+
+ /* Zero the allocated memory */
+ ZeroMemory (pArg, sizeof (WMProcArgRec));
+ ZeroMemory (pWMInfo, sizeof (WMInfoRec));
+ ZeroMemory (pXMsgArg, sizeof (XMsgProcArgRec));
+
+ /* Set a return pointer to the Window Manager info structure */
+ *ppWMInfo = pWMInfo;
+ pWMInfo->fAllowOtherWM = allowOtherWM;
+
+ /* Setup the argument structure for the thread function */
+ pArg->dwScreen = dwScreen;
+ pArg->pWMInfo = pWMInfo;
+ pArg->ppmServerStarted = ppmServerStarted;
+
+ /* Intialize the message queue */
+ if (!InitQueue (&pWMInfo->wmMsgQueue))
+ {
+ ErrorF ("winInitWM - InitQueue () failed.\n");
+ return FALSE;
+ }
+
+ /* Spawn a thread for the Window Manager */
+ if (pthread_create (ptWMProc, NULL, winMultiWindowWMProc, pArg))
+ {
+ /* Bail if thread creation failed */
+ ErrorF ("winInitWM - pthread_create failed for Window Manager.\n");
+ return FALSE;
+ }
+
+ /* Spawn the XNextEvent thread, will send messages to WM */
+ pXMsgArg->dwScreen = dwScreen;
+ pXMsgArg->pWMInfo = pWMInfo;
+ pXMsgArg->ppmServerStarted = ppmServerStarted;
+ pXMsgArg->hwndScreen = hwndScreen;
+ if (pthread_create (ptXMsgProc, NULL, winMultiWindowXMsgProc, pXMsgArg))
+ {
+ /* Bail if thread creation failed */
+ ErrorF ("winInitWM - pthread_create failed on XMSG.\n");
+ return FALSE;
+ }
+
+ winDebug ("winInitWM - Returning.\n");
+
+ return TRUE;
+}
+
+
+/*
+ * Window manager thread - setup
+ */
+
+static void
+winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg)
+{
+ int iRetries = 0;
+ char pszDisplay[512];
+ int iReturn;
+
+ winDebug ("winInitMultiWindowWM - Hello\n");
+
+ /* Check that argument pointer is not invalid */
+ if (pProcArg == NULL)
+ {
+ ErrorF ("winInitMultiWindowWM - pProcArg is NULL. Exiting.\n");
+ pthread_exit (NULL);
+ }
+
+ winDebug ("winInitMultiWindowWM - Calling pthread_mutex_lock ()\n");
+
+ /* Grab our garbage mutex to satisfy pthread_cond_wait */
+ iReturn = pthread_mutex_lock (pProcArg->ppmServerStarted);
+ if (iReturn != 0)
+ {
+ ErrorF ("winInitMultiWindowWM - pthread_mutex_lock () failed: %d. "
+ "Exiting.\n",
+ iReturn);
+ pthread_exit (NULL);
+ }
+
+ winDebug ("winInitMultiWindowWM - pthread_mutex_lock () returned.\n");
+
+ /* See if X supports the current locale */
+ if (XSupportsLocale () == False)
+ {
+ ErrorF ("winInitMultiWindowWM - Locale not supported by X. Exiting.\n");
+ pthread_exit (NULL);
+ }
+
+ /* Release the server started mutex */
+ pthread_mutex_unlock (pProcArg->ppmServerStarted);
+
+ winDebug ("winInitMultiWindowWM - pthread_mutex_unlock () returned.\n");
+
+ /* Set jump point for IO Error exits */
+ iReturn = setjmp (g_jmpWMEntry);
+
+ /* Check if we should continue operations */
+ if (iReturn != WIN_JMP_ERROR_IO
+ && iReturn != WIN_JMP_OKAY)
+ {
+ /* setjmp returned an unknown value, exit */
+ ErrorF ("winInitMultiWindowWM - setjmp returned: %d. Exiting.\n",
+ iReturn);
+ pthread_exit (NULL);
+ }
+ else if (iReturn == WIN_JMP_ERROR_IO)
+ {
+ ErrorF ("winInitMultiWindowWM - Caught IO Error. Exiting.\n");
+ pthread_exit (NULL);
+ }
+
+ /* Install our error handler */
+ XSetErrorHandler (winMultiWindowWMErrorHandler);
+ XSetIOErrorHandler (winMultiWindowWMIOErrorHandler);
+
+ /* Setup the display connection string x */
+ snprintf (pszDisplay,
+ 512,
+ "127.0.0.1:%s.%d",
+ display,
+ (int) pProcArg->dwScreen);
+
+ /* Print the display connection string */
+ winDebug ("winInitMultiWindowWM - DISPLAY=%s\n", pszDisplay);
+
+ /* Use our generated cookie for authentication */
+ winSetAuthorization();
+
+ /* Open the X display */
+ do
+ {
+ /* Try to open the display */
+ pWMInfo->pDisplay = XOpenDisplay (pszDisplay);
+ if (pWMInfo->pDisplay == NULL)
+ {
+ ErrorF ("winInitMultiWindowWM - Could not open display, try: %d, "
+ "sleeping: %d\n\f",
+ iRetries + 1, WIN_CONNECT_DELAY);
+ ++iRetries;
+ sleep (WIN_CONNECT_DELAY);
+ continue;
+ }
+ else
+ break;
+ }
+ while (pWMInfo->pDisplay == NULL && iRetries < WIN_CONNECT_RETRIES);
+
+ /* Make sure that the display opened */
+ if (pWMInfo->pDisplay == NULL)
+ {
+ ErrorF ("winInitMultiWindowWM - Failed opening the display. "
+ "Exiting.\n");
+ pthread_exit (NULL);
+ }
+
+ winDebug ("winInitMultiWindowWM - XOpenDisplay () returned and "
+ "successfully opened the display.\n");
+
+
+ /* Create some atoms */
+ pWMInfo->atmWmProtos = XInternAtom (pWMInfo->pDisplay,
+ "WM_PROTOCOLS",
+ False);
+ pWMInfo->atmWmDelete = XInternAtom (pWMInfo->pDisplay,
+ "WM_DELETE_WINDOW",
+ False);
+
+ pWMInfo->atmPrivMap = XInternAtom (pWMInfo->pDisplay,
+ WINDOWSWM_NATIVE_HWND,
+ False);
+
+
+ if (1) {
+ Cursor cursor = XCreateFontCursor (pWMInfo->pDisplay, XC_left_ptr);
+ if (cursor)
+ {
+ XDefineCursor (pWMInfo->pDisplay, DefaultRootWindow(pWMInfo->pDisplay), cursor);
+ XFreeCursor (pWMInfo->pDisplay, cursor);
+ }
+ }
+}
+
+
+/*
+ * winSendMessageToWM - Send a message from the X thread to the WM thread
+ */
+
+void
+winSendMessageToWM (void *pWMInfo, winWMMessagePtr pMsg)
+{
+ WMMsgNodePtr pNode;
+
+ winDebug ("winSendMessageToWM ()\n");
+
+ pNode = (WMMsgNodePtr)malloc(sizeof(WMMsgNodeRec));
+ if (pNode != NULL)
+ {
+ memcpy (&pNode->msg, pMsg, sizeof(winWMMessageRec));
+ PushMessage (&((WMInfoPtr)pWMInfo)->wmMsgQueue, pNode);
+ }
+}
+
+
+/*
+ * Window manager error handler
+ */
+
+static int
+winMultiWindowWMErrorHandler (Display *pDisplay, XErrorEvent *pErr)
+{
+ char pszErrorMsg[100];
+
+ if (pErr->request_code == X_ChangeWindowAttributes
+ && pErr->error_code == BadAccess)
+ {
+ ErrorF ("winMultiWindowWMErrorHandler - ChangeWindowAttributes "
+ "BadAccess.\n");
+ return 0;
+ }
+
+ XGetErrorText (pDisplay,
+ pErr->error_code,
+ pszErrorMsg,
+ sizeof (pszErrorMsg));
+ ErrorF ("winMultiWindowWMErrorHandler - ERROR: %s\n"
+ " errorCode %d\n"
+ " serial %d\n"
+ " resourceID 0x%x\n"
+ " majorCode %d\n"
+ " minorCode %d\n"
+ , pszErrorMsg
+ , pErr->error_code
+ , pErr->serial
+ , pErr->resourceid
+ , pErr->request_code
+ , pErr->minor_code);
+
+ return 0;
+}
+
+
+/*
+ * Window manager IO error handler
+ */
+
+static int
+winMultiWindowWMIOErrorHandler (Display *pDisplay)
+{
+ ErrorF ("\nwinMultiWindowWMIOErrorHandler!\n\n");
+
+ if (g_shutdown)
+ pthread_exit(NULL);
+
+ /* Restart at the main entry point */
+ longjmp (g_jmpWMEntry, WIN_JMP_ERROR_IO);
+
+ return 0;
+}
+
+
+/*
+ * X message procedure error handler
+ */
+
+static int
+winMultiWindowXMsgProcErrorHandler (Display *pDisplay, XErrorEvent *pErr)
+{
+ char pszErrorMsg[100];
+
+ XGetErrorText (pDisplay,
+ pErr->error_code,
+ pszErrorMsg,
+ sizeof (pszErrorMsg));
+ ErrorF ("winMultiWindowXMsgProcErrorHandler - ERROR: %s\n"
+ " errorCode %d\n"
+ " serial %d\n"
+ " resourceID 0x%x\n"
+ " majorCode %d\n"
+ " minorCode %d\n"
+ , pszErrorMsg
+ , pErr->error_code
+ , pErr->serial
+ , pErr->resourceid
+ , pErr->request_code
+ , pErr->minor_code);
+
+ return 0;
+}
+
+
+/*
+ * X message procedure IO error handler
+ */
+
+static int
+winMultiWindowXMsgProcIOErrorHandler (Display *pDisplay)
+{
+ ErrorF ("\nwinMultiWindowXMsgProcIOErrorHandler!\n\n");
+
+ /* Restart at the main entry point */
+ longjmp (g_jmpXMsgProcEntry, WIN_JMP_ERROR_IO);
+
+ return 0;
+}
+
+
+/*
+ * Catch RedirectError to detect other window manager running
+ */
+
+static int
+winRedirectErrorHandler (Display *pDisplay, XErrorEvent *pErr)
+{
+ redirectError = TRUE;
+ return 0;
+}
+
+
+/*
+ * Check if another window manager is running
+ */
+
+static Bool
+CheckAnotherWindowManager (Display *pDisplay, DWORD dwScreen)
+{
+ /*
+ Try to select the events which only one client at a time is allowed to select.
+ If this causes an error, another window manager is already running...
+ */
+ redirectError = FALSE;
+ XSetErrorHandler (winRedirectErrorHandler);
+ XSelectInput(pDisplay, RootWindow (pDisplay, dwScreen),
+ ResizeRedirectMask | SubstructureRedirectMask | ButtonPressMask);
+ XSync (pDisplay, 0);
+ XSetErrorHandler (winMultiWindowXMsgProcErrorHandler);
+
+ /*
+ Side effect: select the events we are actually interested in...
+ */
+ XSelectInput(pDisplay, RootWindow (pDisplay, dwScreen), SubstructureNotifyMask);
+ XSync (pDisplay, 0);
+ return redirectError;
+}
+
+/*
+ * Notify the MWM thread we're exiting and not to reconnect
+ */
+
+void
+winDeinitMultiWindowWM (void)
+{
+ winDebug ("winDeinitMultiWindowWM - Noting shutdown in progress\n");
+ g_shutdown = TRUE;
+}
+
+/* Windows window styles */
+#define HINT_NOFRAME (1l<<0)
+#define HINT_BORDER (1L<<1)
+#define HINT_SIZEBOX (1l<<2)
+#define HINT_CAPTION (1l<<3)
+/* These two are used on their own */
+#define HINT_MAX (1L<<0)
+#define HINT_MIN (1L<<1)
+
+static void
+winApplyHints (Display *pDisplay, Window iWindow, HWND hWnd, HWND *zstyle)
+{
+ static Atom windowState, motif_wm_hints, windowType;
+ static Atom hiddenState, fullscreenState, belowState, aboveState;
+ static Atom dockWindow;
+ static int generation;
+ Atom type, *pAtom = NULL;
+ int format;
+ unsigned long hint = 0, maxmin = 0, style, nitems = 0 , left = 0;
+ WindowPtr pWin = GetProp (hWnd, WIN_WINDOW_PROP);
+ MwmHints *mwm_hint = NULL;
+
+ if (!hWnd) return;
+ if (!IsWindow (hWnd)) return;
+
+ if (generation != serverGeneration) {
+ generation = serverGeneration;
+ windowState = XInternAtom(pDisplay, "_NET_WM_STATE", False);
+ motif_wm_hints = XInternAtom(pDisplay, "_MOTIF_WM_HINTS", False);
+ windowType = XInternAtom(pDisplay, "_NET_WM_WINDOW_TYPE", False);
+ hiddenState = XInternAtom(pDisplay, "_NET_WM_STATE_HIDDEN", False);
+ fullscreenState = XInternAtom(pDisplay, "_NET_WM_STATE_FULLSCREEN", False);
+ belowState = XInternAtom(pDisplay, "_NET_WM_STATE_BELOW", False);
+ aboveState = XInternAtom(pDisplay, "_NET_WM_STATE_ABOVE", False);
+ dockWindow = XInternAtom(pDisplay, "_NET_WM_WINDOW_TYPE_DOCK", False);
+ }
+
+ if (XGetWindowProperty(pDisplay, iWindow, windowState, 0L,
+ 1L, False, XA_ATOM, &type, &format,
+ &nitems, &left, (unsigned char **)&pAtom) == Success)
+ {
+ if (pAtom && nitems == 1)
+ {
+ if (*pAtom == hiddenState) maxmin |= HINT_MIN;
+ else if (*pAtom == fullscreenState) maxmin |= HINT_MAX;
+ if (*pAtom == belowState) *zstyle = HWND_BOTTOM;
+ else if (*pAtom == aboveState) *zstyle = HWND_TOPMOST;
+ }
+ if (pAtom) XFree(pAtom);
+ }
+
+ nitems = left = 0;
+ if (XGetWindowProperty(pDisplay, iWindow, motif_wm_hints, 0L,
+ PropMwmHintsElements, False, motif_wm_hints, &type, &format,
+ &nitems, &left, (unsigned char **)&mwm_hint) == Success)
+ {
+ if (mwm_hint && nitems == PropMwmHintsElements && (mwm_hint->flags & MwmHintsDecorations))
+ {
+ if (!mwm_hint->decorations) hint |= HINT_NOFRAME;
+ else if (!(mwm_hint->decorations & MwmDecorAll))
+ {
+ if (mwm_hint->decorations & MwmDecorBorder) hint |= HINT_BORDER;
+ if (mwm_hint->decorations & MwmDecorHandle) hint |= HINT_SIZEBOX;
+ if (mwm_hint->decorations & MwmDecorTitle) hint |= HINT_CAPTION;
+ }
+ }
+ if (mwm_hint) XFree(mwm_hint);
+ }
+
+ nitems = left = 0;
+ pAtom = NULL;
+ if (XGetWindowProperty(pDisplay, iWindow, windowType, 0L,
+ 1L, False, XA_ATOM, &type, &format,
+ &nitems, &left, (unsigned char **)&pAtom) == Success)
+ {
+ if (pAtom && nitems == 1)
+ {
+ if (*pAtom == dockWindow)
+ {
+ hint = (hint & ~HINT_NOFRAME) | HINT_SIZEBOX; /* Xming puts a sizebox on dock windows */
+ *zstyle = HWND_TOPMOST;
+ }
+ }
+ if (pAtom) XFree(pAtom);
+ }
+
+ /* Apply Styles, overriding hint settings from above */
+ style = winOverrideStyle((unsigned long)pWin);
+ if (style & STYLE_TOPMOST) *zstyle = HWND_TOPMOST;
+ else if (style & STYLE_MAXIMIZE) maxmin = (hint & ~HINT_MIN) | HINT_MAX;
+ else if (style & STYLE_MINIMIZE) maxmin = (hint & ~HINT_MAX) | HINT_MIN;
+ else if (style & STYLE_BOTTOM) *zstyle = HWND_BOTTOM;
+
+ if (maxmin & HINT_MAX) SendMessage(hWnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
+ else if (maxmin & HINT_MIN) SendMessage(hWnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
+
+ if (style & STYLE_NOTITLE)
+ hint = (hint & ~HINT_NOFRAME & ~HINT_BORDER & ~HINT_CAPTION) | HINT_SIZEBOX;
+ else if (style & STYLE_OUTLINE)
+ hint = (hint & ~HINT_NOFRAME & ~HINT_SIZEBOX & ~HINT_CAPTION) | HINT_BORDER;
+ else if (style & STYLE_NOFRAME)
+ hint = (hint & ~HINT_BORDER & ~HINT_CAPTION & ~HINT_SIZEBOX) | HINT_NOFRAME;
+
+ style = GetWindowLongPtr(hWnd, GWL_STYLE) & ~WS_CAPTION & ~WS_SIZEBOX; /* Just in case */
+ if (!style) return;
+ if (!hint) /* All on, but no resize of children is allowed */
+ style = style | WS_CAPTION | (GetParent(hWnd) ? 0 : WS_SIZEBOX);
+ else if (hint & HINT_NOFRAME); /* All off, so do nothing */
+ else style = style | ((hint & HINT_BORDER) ? WS_BORDER : 0) |
+ ((hint & HINT_SIZEBOX) ? (GetParent(hWnd) ? 0 : WS_SIZEBOX) : 0) |
+ ((hint & HINT_CAPTION) ? WS_CAPTION : 0);
+ SetWindowLongPtr (hWnd, GWL_STYLE, style);
+}
+
+void
+winUpdateWindowPosition (HWND hWnd, Bool reshape, HWND *zstyle)
+{
+ int iX, iY, iWidth, iHeight;
+ int iDx, iDy;
+ RECT rcNew;
+ WindowPtr pWin = GetProp (hWnd, WIN_WINDOW_PROP);
+ DrawablePtr pDraw = NULL;
+
+ if (!pWin) return;
+ pDraw = &pWin->drawable;
+ if (!pDraw) return;
+
+ /* Get the X and Y location of the X window */
+ iX = pWin->drawable.x + GetSystemMetrics (SM_XVIRTUALSCREEN);
+ iY = pWin->drawable.y + GetSystemMetrics (SM_YVIRTUALSCREEN);
+
+ /* Get the height and width of the X window */
+ iWidth = pWin->drawable.width;
+ iHeight = pWin->drawable.height;
+
+ /* Setup a rectangle with the X window position and size */
+ SetRect (&rcNew, iX, iY, iX + iWidth, iY + iHeight);
+
+ AdjustWindowRectEx (&rcNew, GetWindowLongPtr (hWnd, GWL_STYLE), FALSE, WS_EX_APPWINDOW);
+
+ /* Don't allow window decoration to disappear off to top-left as a result of this adjustment */
+ if (rcNew.left < GetSystemMetrics(SM_XVIRTUALSCREEN))
+ {
+ iDx = GetSystemMetrics(SM_XVIRTUALSCREEN) - rcNew.left;
+ rcNew.left += iDx;
+ rcNew.right += iDx;
+ }
+
+ if (rcNew.top < GetSystemMetrics(SM_YVIRTUALSCREEN))
+ {
+ iDy = GetSystemMetrics(SM_YVIRTUALSCREEN) - rcNew.top;
+ rcNew.top += iDy;
+ rcNew.bottom += iDy;
+ }
+
+ /* Position the Windows window */
+ SetWindowPos (hWnd, *zstyle, rcNew.left, rcNew.top,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
+ 0);
+
+ if (reshape)
+ {
+ winReshapeMultiWindow(pWin);
+ winUpdateRgnMultiWindow(pWin);
+ }
+}
diff --git a/xorg-server/hw/xwin/winmultiwindowwndproc.c b/xorg-server/hw/xwin/winmultiwindowwndproc.c
index d14ceee9c..ef5f3114a 100644
--- a/xorg-server/hw/xwin/winmultiwindowwndproc.c
+++ b/xorg-server/hw/xwin/winmultiwindowwndproc.c
@@ -42,6 +42,13 @@
#include "winmsg.h"
#include "inputstr.h"
+#ifdef XKB
+#ifndef XKB_IN_SERVER
+#define XKB_IN_SERVER
+#endif
+#include <xkbsrv.h>
+#endif
+
/*
* External global variables
*/
@@ -331,9 +338,7 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
Bool needRestack = FALSE;
LRESULT ret;
-#if CYGDEBUG
winDebugWin32Message("winTopLevelWindowProc", hwnd, message, wParam, lParam);
-#endif
/* Check if the Windows window property for our X window pointer is valid */
if ((pWin = GetProp (hwnd, WIN_WINDOW_PROP)) != NULL)
@@ -366,31 +371,6 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
fWMMsgInitialized = TRUE;
-#if 0
- /*
- * Print some debugging information
- */
-
- ErrorF ("hWnd %08X\n", hwnd);
- ErrorF ("pWin %08X\n", pWin);
- ErrorF ("pDraw %08X\n", pDraw);
- ErrorF ("\ttype %08X\n", pWin->drawable.type);
- ErrorF ("\tclass %08X\n", pWin->drawable.class);
- ErrorF ("\tdepth %08X\n", pWin->drawable.depth);
- ErrorF ("\tbitsPerPixel %08X\n", pWin->drawable.bitsPerPixel);
- ErrorF ("\tid %08X\n", pWin->drawable.id);
- ErrorF ("\tx %08X\n", pWin->drawable.x);
- ErrorF ("\ty %08X\n", pWin->drawable.y);
- ErrorF ("\twidth %08X\n", pWin->drawable.width);
- ErrorF ("\thenght %08X\n", pWin->drawable.height);
- ErrorF ("\tpScreen %08X\n", pWin->drawable.pScreen);
- ErrorF ("\tserialNumber %08X\n", pWin->drawable.serialNumber);
- ErrorF ("g_iWindowPrivateKey %p\n", g_iWindowPrivateKey);
- ErrorF ("pWinPriv %08X\n", pWinPriv);
- ErrorF ("s_pScreenPriv %08X\n", s_pScreenPriv);
- ErrorF ("s_pScreenInfo %08X\n", s_pScreenInfo);
- ErrorF ("hwndScreen %08X\n", hwndScreen);
-#endif
}
/* Branch on message type */
@@ -425,7 +405,7 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
DeleteObject(hRgnWindow);
}
- SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)XMING_SIGNATURE);
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)VCXSRV_SIGNATURE);
return 0;
@@ -741,7 +721,7 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
if (wParam == VK_F4 && (GetKeyState (VK_MENU) & 0x8000))
break;
-#if CYGWINDOWING_DEBUG
+#ifdef WINDBG
if (wParam == VK_ESCAPE)
{
/* Place for debug: put any tests and dumps here */
@@ -752,27 +732,27 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
windPlace.length = sizeof (WINDOWPLACEMENT);
GetWindowPlacement (hwnd, &windPlace);
pRect = &windPlace.rcNormalPosition;
- ErrorF ("\nCYGWINDOWING Dump:\n"
+ winDebug ("\nCYGWINDOWING Dump:\n"
"\tdrawable: (%hd, %hd) - %hdx%hd\n", pDraw->x,
pDraw->y, pDraw->width, pDraw->height);
- ErrorF ("\twindPlace: (%ld, %ld) - %ldx%ld\n", pRect->left,
+ winDebug ("\twindPlace: (%ld, %ld) - %ldx%ld\n", pRect->left,
pRect->top, pRect->right - pRect->left,
pRect->bottom - pRect->top);
if (GetClientRect (hwnd, &rc))
{
pRect = &rc;
- ErrorF ("\tClientRect: (%ld, %ld) - %ldx%ld\n", pRect->left,
+ winDebug ("\tClientRect: (%ld, %ld) - %ldx%ld\n", pRect->left,
pRect->top, pRect->right - pRect->left,
pRect->bottom - pRect->top);
}
if (GetWindowRect (hwnd, &rc))
{
pRect = &rc;
- ErrorF ("\tWindowRect: (%ld, %ld) - %ldx%ld\n", pRect->left,
+ winDebug ("\tWindowRect: (%ld, %ld) - %ldx%ld\n", pRect->left,
pRect->top, pRect->right - pRect->left,
pRect->bottom - pRect->top);
}
- ErrorF ("\n");
+ winDebug ("\n");
}
#endif
@@ -847,7 +827,7 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
/* Branch on if the window was killed in X already */
if (pWinPriv && !pWinPriv->fXKilled)
{
- ErrorF ("winTopLevelWindowProc - WM_DESTROY - WM_WM_KILL\n");
+ winDebug ("winTopLevelWindowProc - WM_DESTROY - WM_WM_KILL\n");
/* Tell our Window Manager thread to kill the window */
wmMsg.msg = WM_WM_KILL;
@@ -900,12 +880,10 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
else /* It is an overridden window so make it top of Z stack */
{
HWND forHwnd = GetForegroundWindow();
-#if CYGWINDOWING_DEBUG
- ErrorF ("overridden window is shown\n");
-#endif
+ winDebug ("overridden window is shown\n");
if (forHwnd != NULL)
{
- if (GetWindowLongPtr(forHwnd, GWLP_USERDATA) & (LONG_PTR)XMING_SIGNATURE)
+ if (GetWindowLongPtr(forHwnd, GWLP_USERDATA) & (LONG_PTR)VCXSRV_SIGNATURE)
{
if (GetWindowLongPtr(forHwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)
SetWindowPos (hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
@@ -991,7 +969,7 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
case WM_SIZE:
/* see dix/window.c */
-#if CYGWINDOWING_DEBUG
+#ifdef WINDBG
{
char buf[64];
switch (wParam)
@@ -1008,24 +986,34 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
default:
strcpy(buf, "UNKNOWN_FLAG");
}
- ErrorF ("winTopLevelWindowProc - WM_SIZE to %dx%d (%s) - %d ms\n",
+ winDebug ("winTopLevelWindowProc - WM_SIZE to %dx%d (%s) - %d ms\n",
(int)LOWORD(lParam), (int)HIWORD(lParam), buf,
(int)(GetTickCount ()));
}
#endif
/* Adjust the X Window to the moved Windows window */
winAdjustXWindow (pWin, hwnd);
+ if (wParam == SIZE_MINIMIZED) winReorderWindowsMultiWindow();
return 0; /* end of WM_SIZE handler */
+ case WM_STYLECHANGED:
+ /* when the style changes, adjust the window size so the client area remains the same */
+ {
+ LONG x,y;
+ DrawablePtr pDraw = &pWin->drawable;
+ x = pDraw->x - wBorderWidth(pWin);
+ y = pDraw->y - wBorderWidth(pWin);
+ winPositionWindowMultiWindow(pWin, x, y);
+ }
+ return 0;
+
case WM_MOUSEACTIVATE:
/* Check if this window needs to be made active when clicked */
if (!GetProp (pWinPriv->hWnd, WIN_NEEDMANAGE_PROP))
{
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winTopLevelWindowProc - WM_MOUSEACTIVATE - "
+ winDebug ("winTopLevelWindowProc - WM_MOUSEACTIVATE - "
"MA_NOACTIVATE\n");
-#endif
/* */
return MA_NOACTIVATE;
diff --git a/xorg-server/hw/xwin/winnativegdi.c b/xorg-server/hw/xwin/winnativegdi.c
index 48a467a2c..f7e13a712 100644
--- a/xorg-server/hw/xwin/winnativegdi.c
+++ b/xorg-server/hw/xwin/winnativegdi.c
@@ -111,7 +111,7 @@ winCloseScreenNativeGDI (int nIndex, ScreenPtr pScreen)
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- ErrorF ("winCloseScreenNativeGDI - Freeing screen resources\n");
+ winDebug ("winCloseScreenNativeGDI - Freeing screen resources\n");
/* Flag that the screen is closed */
pScreenPriv->fClosed = TRUE;
@@ -125,7 +125,7 @@ winCloseScreenNativeGDI (int nIndex, ScreenPtr pScreen)
/* Delete the window property */
RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
- ErrorF ("winCloseScreenNativeGDI - Destroying window\n");
+ winDebug ("winCloseScreenNativeGDI - Destroying window\n");
/* Delete tray icon, if we have one */
if (!pScreenInfo->fNoTrayIcon)
@@ -151,7 +151,7 @@ winCloseScreenNativeGDI (int nIndex, ScreenPtr pScreen)
/* Free the screen privates for this screen */
free (pScreenPriv);
- ErrorF ("winCloseScreenNativeGDI - Returning\n");
+ winDebug ("winCloseScreenNativeGDI - Returning\n");
return TRUE;
}
@@ -210,7 +210,7 @@ winInitVisualsNativeGDI (ScreenPtr pScreen)
}
/* Tell the user how many bits per RGB we are using */
- ErrorF ("winInitVisualsNativeGDI - Using dwBitsPerRGB: %d\n",
+ winDebug ("winInitVisualsNativeGDI - Using dwBitsPerRGB: %d\n",
(int) pScreenPriv->dwBitsPerRGB);
/* Create a single visual according to the Windows screen depth */
@@ -233,7 +233,7 @@ winInitVisualsNativeGDI (ScreenPtr pScreen)
break;
case 8:
- ErrorF ("winInitVisuals - Calling miSetVisualTypesAndMasks\n");
+ winDebug ("winInitVisuals - Calling miSetVisualTypesAndMasks\n");
if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
StaticColorMask,
pScreenPriv->dwBitsPerRGB,
@@ -252,9 +252,7 @@ winInitVisualsNativeGDI (ScreenPtr pScreen)
return FALSE;
}
-#if 1
- ErrorF ("winInitVisualsNativeGDI - Returning\n");
-#endif
+ winDebug ("winInitVisualsNativeGDI - Returning\n");
return TRUE;
}
@@ -300,7 +298,7 @@ winAdjustVideoModeNativeGDI (ScreenPtr pScreen)
if (pScreenInfo->dwBPP == WIN_DEFAULT_BPP)
{
/* No -depth parameter passed, let the user know the depth being used */
- ErrorF ("winAdjustVideoModeNativeGDI - Using Windows display "
+ winDebug ("winAdjustVideoModeNativeGDI - Using Windows display "
"depth of %d bits per pixel, %d depth\n",
(int) dwBPP, (int) pScreenInfo->dwDepth);
@@ -310,7 +308,7 @@ winAdjustVideoModeNativeGDI (ScreenPtr pScreen)
else if (dwBPP != pScreenInfo->dwBPP)
{
/* Warn user if GDI depth is different than -depth parameter */
- ErrorF ("winAdjustVideoModeNativeGDI - Command line bpp: %d, "\
+ winDebug ("winAdjustVideoModeNativeGDI - Command line bpp: %d, "\
"using bpp: %d\n",
(int) pScreenInfo->dwBPP, (int) dwBPP);
diff --git a/xorg-server/hw/xwin/winpfbdd.c b/xorg-server/hw/xwin/winpfbdd.c
index 13fc1058d..6c0c2bffd 100644
--- a/xorg-server/hw/xwin/winpfbdd.c
+++ b/xorg-server/hw/xwin/winpfbdd.c
@@ -83,7 +83,7 @@ winAllocateFBPrimaryDD (ScreenPtr pScreen)
DDSURFACEDESC *pddsdOffscreen = NULL;
RECT rcClient;
- ErrorF ("winAllocateFBPrimaryDD\n");
+ winDebug ("winAllocateFBPrimaryDD\n");
/* Get client area location in screen coords */
GetClientRect (pScreenPriv->hwndScreen, &rcClient);
@@ -108,7 +108,7 @@ winAllocateFBPrimaryDD (ScreenPtr pScreen)
}
- ErrorF ("winAllocateFBPrimaryDD - Created and initialized DD\n");
+ winDebug ("winAllocateFBPrimaryDD - Created and initialized DD\n");
/* Are we windowed or fullscreen? */
if (pScreenInfo->fFullScreen)
@@ -159,7 +159,7 @@ winAllocateFBPrimaryDD (ScreenPtr pScreen)
FatalError ("winAllocateFBPrimaryDD - Could not create primary "
"surface %08x\n", (unsigned int) ddrval);
- ErrorF ("winAllocateFBPrimaryDD - Created primary\n");
+ winDebug ("winAllocateFBPrimaryDD - Created primary\n");
/* Allocate a DD surface description for our screen privates */
pddsdPrimary = pScreenPriv->pddsdPrimary
@@ -195,7 +195,7 @@ winAllocateFBPrimaryDD (ScreenPtr pScreen)
FatalError ("winAllocateFBPrimaryDD - Could not create shadow "
"surface\n");
- ErrorF ("winAllocateFBPrimaryDD - Created offscreen\n");
+ winDebug ("winAllocateFBPrimaryDD - Created offscreen\n");
/* Allocate a DD surface description for our screen privates */
pddsdOffscreen = pScreenPriv->pddsdOffscreen
@@ -206,7 +206,7 @@ winAllocateFBPrimaryDD (ScreenPtr pScreen)
ZeroMemory (pddsdOffscreen, sizeof (*pddsdOffscreen));
pddsdOffscreen->dwSize = sizeof (*pddsdOffscreen);
- ErrorF ("winAllocateFBPrimaryDD - Locking primary\n");
+ winDebug ("winAllocateFBPrimaryDD - Locking primary\n");
/* Lock the primary surface */
ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsPrimary,
@@ -218,7 +218,7 @@ winAllocateFBPrimaryDD (ScreenPtr pScreen)
FatalError ("winAllocateFBPrimaryDD - Could not lock "
"primary surface\n");
- ErrorF ("winAllocateFBPrimaryDD - Locked primary\n");
+ winDebug ("winAllocateFBPrimaryDD - Locked primary\n");
/* We don't know how to deal with anything other than RGB */
if (!(pddsdPrimary->ddpfPixelFormat.dwFlags & DDPF_RGB))
@@ -236,7 +236,7 @@ winAllocateFBPrimaryDD (ScreenPtr pScreen)
pScreenPriv->dwGreenMask = pddsdPrimary->ddpfPixelFormat.u3.dwGBitMask;
pScreenPriv->dwBlueMask = pddsdPrimary->ddpfPixelFormat.u4.dwBBitMask;
- ErrorF ("winAllocateFBPrimaryDD - Returning\n");
+ winDebug ("winAllocateFBPrimaryDD - Returning\n");
return TRUE;
}
@@ -255,7 +255,7 @@ winCloseScreenPrimaryDD (int nIndex, ScreenPtr pScreen)
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
Bool fReturn;
- ErrorF ("winCloseScreenPrimaryDD - Freeing screen resources\n");
+ winDebug ("winCloseScreenPrimaryDD - Freeing screen resources\n");
/* Flag that the screen is closed */
pScreenPriv->fClosed = TRUE;
@@ -351,7 +351,7 @@ winInitVisualsPrimaryDD (ScreenPtr pScreen)
else
pScreenPriv->dwBitsPerRGB = dwBlueBits;
- ErrorF ("winInitVisualsPrimaryDD - Masks: %08x %08x %08x bpRGB: %d\n",
+ winDebug ("winInitVisualsPrimaryDD - Masks: %08x %08x %08x bpRGB: %d\n",
(unsigned int) pScreenPriv->dwRedMask,
(unsigned int) pScreenPriv->dwGreenMask,
(unsigned int) pScreenPriv->dwBlueMask,
@@ -378,9 +378,7 @@ winInitVisualsPrimaryDD (ScreenPtr pScreen)
break;
case 8:
-#if CYGDEBUG
winDebug ("winInitVisuals - Calling miSetVisualTypesAndMasks\n");
-#endif /* CYGDEBUG */
if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
PseudoColorMask,
pScreenPriv->dwBitsPerRGB,
@@ -393,10 +391,8 @@ winInitVisualsPrimaryDD (ScreenPtr pScreen)
"miSetVisualTypesAndMasks failed\n");
return FALSE;
}
-#if CYGDEBUG
winDebug ("winInitVisualsPrimaryDD - Returned from "
"miSetVisualTypesAndMasks\n");
-#endif /* CYGDEBUG */
break;
default:
@@ -404,7 +400,7 @@ winInitVisualsPrimaryDD (ScreenPtr pScreen)
return FALSE;
}
- ErrorF ("winInitVisualsPrimaryDD - Returning\n");
+ winDebug ("winInitVisualsPrimaryDD - Returning\n");
return TRUE;
}
@@ -433,7 +429,7 @@ winAdjustVideoModePrimaryDD (ScreenPtr pScreen)
if (pScreenInfo->dwBPP == WIN_DEFAULT_BPP)
{
/* No -depth parameter passed, let the user know the depth being used */
- ErrorF ("winAdjustVideoModePrimaryDD - Using Windows display "
+ winDebug ("winAdjustVideoModePrimaryDD - Using Windows display "
"depth of %d bits per pixel\n", (int) dwBPP);
/* Use GDI's depth */
@@ -443,13 +439,13 @@ winAdjustVideoModePrimaryDD (ScreenPtr pScreen)
&& pScreenInfo->dwBPP != dwBPP)
{
/* FullScreen, and GDI depth differs from -depth parameter */
- ErrorF ("winAdjustVideoModePrimaryDD - FullScreen, using command "
+ winDebug ("winAdjustVideoModePrimaryDD - FullScreen, using command "
"line depth: %d\n", (int) pScreenInfo->dwBPP);
}
else if (dwBPP != pScreenInfo->dwBPP)
{
/* Windowed, and GDI depth differs from -depth parameter */
- ErrorF ("winAdjustVideoModePrimaryDD - Windowed, command line "
+ winDebug ("winAdjustVideoModePrimaryDD - Windowed, command line "
"depth: %d, using depth: %d\n",
(int) pScreenInfo->dwBPP, (int) dwBPP);
@@ -567,7 +563,7 @@ winHotKeyAltTabPrimaryDD (ScreenPtr pScreen)
RECT rcClient, rcSrc;
HRESULT ddrval = DD_OK;
- ErrorF ("\nwinHotKeyAltTabPrimaryDD\n\n");
+ winDebug ("\nwinHotKeyAltTabPrimaryDD\n\n");
/* Alt+Tab was pressed, we will lose focus very soon */
pScreenPriv->fActive = FALSE;
diff --git a/xorg-server/hw/xwin/winpixmap.c b/xorg-server/hw/xwin/winpixmap.c
index 050c71a7f..e5b36a000 100644
--- a/xorg-server/hw/xwin/winpixmap.c
+++ b/xorg-server/hw/xwin/winpixmap.c
@@ -70,11 +70,9 @@ winCreatePixmapNativeGDI (ScreenPtr pScreen,
return NullPixmap;
}
-#if CYGDEBUG
winDebug ("winCreatePixmap () - w %d h %d d %d uh %d bw %d\n",
iWidth, iHeight, iDepth, usage_hint,
PixmapBytePad (iWidth, iDepth));
-#endif
/* Setup pixmap values */
pPixmap->drawable.type = DRAWABLE_PIXMAP;
@@ -114,11 +112,9 @@ winCreatePixmapNativeGDI (ScreenPtr pScreen,
&pPixmapPriv->pbBits,
(BITMAPINFO **) &pPixmapPriv->pbmih);
-#if CYGDEBUG
winDebug ("winCreatePixmap () - Created a pixmap %08x, %dx%dx%d, for " \
"screen: %08x\n",
pPixmapPriv->hBitmap, iWidth, iHeight, iDepth, pScreen);
-#endif
return pPixmap;
}
@@ -135,9 +131,7 @@ winDestroyPixmapNativeGDI (PixmapPtr pPixmap)
{
winPrivPixmapPtr pPixmapPriv = NULL;
-#if CYGDEBUG
winDebug ("winDestroyPixmapNativeGDI ()\n");
-#endif
/* Bail early if there is not a pixmap to destroy */
if (pPixmap == NULL)
@@ -149,10 +143,8 @@ winDestroyPixmapNativeGDI (PixmapPtr pPixmap)
/* Get a handle to the pixmap privates */
pPixmapPriv = winGetPixmapPriv (pPixmap);
-#if CYGDEBUG
winDebug ("winDestroyPixmapNativeGDI - pPixmapPriv->hBitmap: %08x\n",
pPixmapPriv->hBitmap);
-#endif
/* Decrement reference count, return if nonzero */
--pPixmap->refcnt;
@@ -193,43 +185,3 @@ winModifyPixmapHeaderNativeGDI (PixmapPtr pPixmap,
return TRUE;
}
-
-#if 0
-/*
- * Not used yet.
- * See cfb/cfbpixmap.c
- */
-
-static void
-winXRotatePixmapNativeGDI (PixmapPtr pPix, int rw)
-{
- ErrorF ("winXRotatePixmap()\n");
- /* fill in this function, look at CFB */
-}
-
-
-/*
- * Not used yet.
- * See cfb/cfbpixmap.c
- */
-static void
-winYRotatePixmapNativeGDI (PixmapPtr pPix, int rh)
-{
- ErrorF ("winYRotatePixmap()\n");
- /* fill in this function, look at CFB */
-}
-
-
-/*
- * Not used yet.
- * See cfb/cfbpixmap.c
- */
-
-static void
-winCopyRotatePixmapNativeGDI (PixmapPtr psrcPix, PixmapPtr *ppdstPix,
- int xrot, int yrot)
-{
- ErrorF ("winCopyRotatePixmap()\n");
- /* fill in this function, look at CFB */
-}
-#endif
diff --git a/xorg-server/hw/xwin/winpolyline.c b/xorg-server/hw/xwin/winpolyline.c
index db9dd345b..bf98d73ec 100644
--- a/xorg-server/hw/xwin/winpolyline.c
+++ b/xorg-server/hw/xwin/winpolyline.c
@@ -45,7 +45,7 @@ winPolyLineNativeGDI (DrawablePtr pDrawable,
{
case LineSolid:
if (pGC->lineWidth == 0)
- return miZeroLine (pDrawable, pGC, mode, npt, ppt);
+ miZeroLine (pDrawable, pGC, mode, npt, ppt);
else
miWideLine (pDrawable, pGC, mode, npt, ppt);
break;
diff --git a/xorg-server/hw/xwin/winprefs.c b/xorg-server/hw/xwin/winprefs.c
index d5bceb928..7059ffd6d 100644
--- a/xorg-server/hw/xwin/winprefs.c
+++ b/xorg-server/hw/xwin/winprefs.c
@@ -387,8 +387,8 @@ HandleCustomWM_COMMAND (unsigned long hwndIn,
memset (&start, 0, sizeof (start));
start.cb = sizeof (start);
- start.dwFlags = STARTF_USESHOWWINDOW;
- start.wShowWindow = SW_HIDE;
+ //start.dwFlags = STARTF_USESHOWWINDOW;
+ //start.wShowWindow = SW_HIDE;
memset (&child, 0, sizeof (child));
@@ -399,7 +399,7 @@ HandleCustomWM_COMMAND (unsigned long hwndIn,
CloseHandle (child.hProcess);
}
else
- MessageBox(NULL, m->menuItem[j].param, "Mingrc Exec Command Error!", MB_OK | MB_ICONEXCLAMATION);
+ MessageBox(NULL, m->menuItem[j].param, "VcXsrv Exec Command Error!", MB_OK | MB_ICONEXCLAMATION);
}
return TRUE;
#endif
@@ -723,7 +723,7 @@ winIconIsOverride(unsigned hiconIn)
/*
- * Try and open ~/.XWinrc and /usr/X11R6/lib/X11/system.XWinrc
+ * Try and open ~/.XWinrc and system.XWinrc
* Load it into prefs structure for use by other functions
*/
void
@@ -753,7 +753,9 @@ LoadPreferences (void)
prefFile = fopen (fname, "r");
if (prefFile)
- ErrorF ("winPrefsLoadPreferences: %s\n", fname);
+ {
+ winDebug ("winPrefsLoadPreferences: %s\n", fname);
+ }
}
/* No home file found, check system default */
@@ -763,12 +765,14 @@ LoadPreferences (void)
#ifdef RELOCATE_PROJECTROOT
snprintf(buffer, sizeof(buffer), "%s\\system.XWinrc", winGetBaseDir());
#else
- strncpy(buffer, PROJECTROOT"/lib/X11/system.XWinrc", sizeof(buffer));
+ strncpy(buffer, SYSCONFDIR"/X11/system.XWinrc", sizeof(buffer));
#endif
buffer[sizeof(buffer)-1] = 0;
prefFile = fopen (buffer, "r");
if (prefFile)
- ErrorF ("winPrefsLoadPreferences: %s\n", buffer);
+ {
+ winDebug ("winPrefsLoadPreferences: %s\n", buffer);
+ }
}
/* If we could open it, then read the settings and close it */
diff --git a/xorg-server/hw/xwin/winprefs.h b/xorg-server/hw/xwin/winprefs.h
index 4daf47401..ccd771d72 100644
--- a/xorg-server/hw/xwin/winprefs.h
+++ b/xorg-server/hw/xwin/winprefs.h
@@ -1,189 +1,192 @@
-#if !defined(WINPREFS_H)
-#define WINPREFS_H
-/*
- * Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- * Copyright (C) Colin Harrison 2005-2008
- *
- * 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, 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 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 XFREE86 PROJECT 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 XFree86 Project
- * 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 XFree86 Project.
- *
- * Authors: Earle F. Philhower, III
- * Colin Harrison
- */
-
-/* Need Bool */
-#include <X11/Xdefs.h>
-/* Need TRUE */
-#include "misc.h"
-
-/* Need to know how long paths can be... */
-#include <limits.h>
-/* Xwindows redefines PATH_MAX to at least 1024 */
-#include <X11/Xwindows.h>
-
-#ifndef NAME_MAX
-#define NAME_MAX PATH_MAX
-#endif
-#define MENU_MAX 128 /* Maximum string length of a menu name or item */
-#define PARAM_MAX (4*PATH_MAX) /* Maximum length of a parameter to a MENU */
-
-
-/* Supported commands in a MENU {} statement */
-typedef enum MENUCOMMANDTYPE
-{
- CMD_EXEC, /* /bin/sh -c the parameter */
- CMD_MENU, /* Display a popup menu named param */
- CMD_SEPARATOR, /* Menu separator */
- CMD_ALWAYSONTOP, /* Toggle always-on-top mode */
- CMD_RELOAD /* Reparse the .XWINRC file */
-} MENUCOMMANDTYPE;
-
-#define STYLE_NONE (0L) /* Dummy the first entry */
-#define STYLE_NOTITLE (1L) /* Force window style no titlebar */
-#define STYLE_OUTLINE (1L<<1) /* Force window style just thin-line border */
-#define STYLE_NOFRAME (1L<<2) /* Force window style no frame */
-#define STYLE_TOPMOST (1L<<3) /* Open a window always-on-top */
-#define STYLE_MAXIMIZE (1L<<4) /* Open a window maximized */
-#define STYLE_MINIMIZE (1L<<5) /* Open a window minimized */
-#define STYLE_BOTTOM (1L<<6) /* Open a window at the bottom of the Z order */
-
-/* Where to place a system menu */
-typedef enum MENUPOSITION
-{
- AT_START, /* Place menu at the top of the system menu */
- AT_END /* Put it at the bottom of the menu (default) */
-} MENUPOSITION;
-
-/* Menu item definitions */
-typedef struct MENUITEM
-{
- char text[MENU_MAX+1]; /* To be displayed in menu */
- MENUCOMMANDTYPE cmd; /* What should it do? */
- char param[PARAM_MAX+1]; /* Any parameters? */
- unsigned long commandID; /* Windows WM_COMMAND ID assigned at runtime */
-} MENUITEM;
-
-/* A completely read in menu... */
-typedef struct MENUPARSED
-{
- char menuName[MENU_MAX+1]; /* What's it called in the text? */
- MENUITEM *menuItem; /* Array of items */
- int menuItems; /* How big's the array? */
-} MENUPARSED;
-
-/* To map between a window and a system menu to add for it */
-typedef struct SYSMENUITEM
-{
- char match[MENU_MAX+1]; /* String to look for to apply this sysmenu */
- char menuName[MENU_MAX+1]; /* Which menu to show? Used to set *menu */
- MENUPOSITION menuPos; /* Where to place it (ignored in root) */
-} SYSMENUITEM;
-
-/* To redefine icons for certain window types */
-typedef struct ICONITEM
-{
- char match[MENU_MAX+1]; /* What string to search for? */
- char iconFile[PATH_MAX+NAME_MAX+2]; /* Icon location, WIN32 path */
- HICON hicon; /* LoadImage() result */
-} ICONITEM;
-
-/* To redefine styles for certain window types */
-typedef struct STYLEITEM
-{
- char match[MENU_MAX+1]; /* What string to search for? */
- unsigned long type; /* What should it do? */
-} STYLEITEM;
-
-typedef struct WINPREFS
-{
- /* Menu information */
- MENUPARSED *menu; /* Array of created menus */
- int menuItems; /* How big? */
-
- /* Taskbar menu settings */
- char rootMenuName[MENU_MAX+1]; /* Menu for taskbar icon */
-
- /* System menu addition menus */
- SYSMENUITEM *sysMenu;
- int sysMenuItems;
-
- /* Which menu to add to unmatched windows? */
- char defaultSysMenuName[MENU_MAX+1];
- MENUPOSITION defaultSysMenuPos; /* Where to place it */
-
- /* Icon information */
- char iconDirectory[PATH_MAX+1]; /* Where do the .icos lie? (Win32 path) */
- char defaultIconName[NAME_MAX+1]; /* Replacement for x.ico */
- char trayIconName[NAME_MAX+1]; /* Replacement for tray icon */
-
- ICONITEM *icon;
- int iconItems;
-
- STYLEITEM *style;
- int styleItems;
-
- /* Force exit flag */
- Bool fForceExit;
-
- /* Silent exit flag */
- Bool fSilentExit;
-
-} WINPREFS;
-
-
-
-
-/* Functions */
-void
-LoadPreferences(void);
-
-void
-SetupRootMenu (unsigned long hmenuRoot);
-
-void
-SetupSysMenu (unsigned long hwndIn);
-
-void
-HandleCustomWM_INITMENU(unsigned long hwndIn,
- unsigned long hmenuIn);
-
-Bool
-HandleCustomWM_COMMAND (unsigned long hwndIn,
- int command);
-
-int
-winIconIsOverride (unsigned hiconIn);
-
-HICON
-winOverrideIcon (unsigned long longpWin);
-
-unsigned long
-winOverrideStyle (unsigned long longpWin);
-
-HICON
-winTaskbarIcon(void);
-
-HICON
-winOverrideDefaultIcon(int size);
-#endif
+#if !defined(WINPREFS_H)
+#define WINPREFS_H
+/*
+ * Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ * Copyright (C) Colin Harrison 2005-2008
+ *
+ * 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, 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 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 XFREE86 PROJECT 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 XFree86 Project
+ * 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 XFree86 Project.
+ *
+ * Authors: Earle F. Philhower, III
+ * Colin Harrison
+ */
+
+/* Need Bool */
+#include <X11/Xdefs.h>
+/* Need TRUE */
+#include "misc.h"
+
+/* Need to know how long paths can be... */
+#include <limits.h>
+/* Xwindows redefines PATH_MAX to at least 1024 */
+#include <X11/Xwindows.h>
+
+#ifndef NAME_MAX
+#define NAME_MAX PATH_MAX
+#endif
+#define MENU_MAX 128 /* Maximum string length of a menu name or item */
+#define PARAM_MAX (4*PATH_MAX) /* Maximum length of a parameter to a MENU */
+
+
+/* Supported commands in a MENU {} statement */
+typedef enum MENUCOMMANDTYPE
+{
+ CMD_EXEC, /* /bin/sh -c the parameter */
+ CMD_MENU, /* Display a popup menu named param */
+ CMD_SEPARATOR, /* Menu separator */
+ CMD_ALWAYSONTOP, /* Toggle always-on-top mode */
+ CMD_RELOAD /* Reparse the .XWINRC file */
+} MENUCOMMANDTYPE;
+
+#define STYLE_NONE (0L) /* Dummy the first entry */
+#define STYLE_NOTITLE (1L) /* Force window style no titlebar */
+#define STYLE_OUTLINE (1L<<1) /* Force window style just thin-line border */
+#define STYLE_NOFRAME (1L<<2) /* Force window style no frame */
+#define STYLE_TOPMOST (1L<<3) /* Open a window always-on-top */
+#define STYLE_MAXIMIZE (1L<<4) /* Open a window maximized */
+#define STYLE_MINIMIZE (1L<<5) /* Open a window minimized */
+#define STYLE_BOTTOM (1L<<6) /* Open a window at the bottom of the Z order */
+
+/* Where to place a system menu */
+typedef enum MENUPOSITION
+{
+ AT_START, /* Place menu at the top of the system menu */
+ AT_END /* Put it at the bottom of the menu (default) */
+} MENUPOSITION;
+
+/* Menu item definitions */
+typedef struct MENUITEM
+{
+ char text[MENU_MAX+1]; /* To be displayed in menu */
+ MENUCOMMANDTYPE cmd; /* What should it do? */
+ char param[PARAM_MAX+1]; /* Any parameters? */
+ unsigned long commandID; /* Windows WM_COMMAND ID assigned at runtime */
+} MENUITEM;
+
+/* A completely read in menu... */
+typedef struct MENUPARSED
+{
+ char menuName[MENU_MAX+1]; /* What's it called in the text? */
+ MENUITEM *menuItem; /* Array of items */
+ int menuItems; /* How big's the array? */
+} MENUPARSED;
+
+/* To map between a window and a system menu to add for it */
+typedef struct SYSMENUITEM
+{
+ char match[MENU_MAX+1]; /* String to look for to apply this sysmenu */
+ char menuName[MENU_MAX+1]; /* Which menu to show? Used to set *menu */
+ MENUPOSITION menuPos; /* Where to place it (ignored in root) */
+} SYSMENUITEM;
+
+/* To redefine icons for certain window types */
+typedef struct ICONITEM
+{
+ char match[MENU_MAX+1]; /* What string to search for? */
+ char iconFile[PATH_MAX+NAME_MAX+2]; /* Icon location, WIN32 path */
+ HICON hicon; /* LoadImage() result */
+} ICONITEM;
+
+/* To redefine styles for certain window types */
+typedef struct STYLEITEM
+{
+ char match[MENU_MAX+1]; /* What string to search for? */
+ unsigned long type; /* What should it do? */
+} STYLEITEM;
+
+typedef struct WINPREFS
+{
+ /* Menu information */
+ MENUPARSED *menu; /* Array of created menus */
+ int menuItems; /* How big? */
+
+ /* Taskbar menu settings */
+ char rootMenuName[MENU_MAX+1]; /* Menu for taskbar icon */
+
+ /* System menu addition menus */
+ SYSMENUITEM *sysMenu;
+ int sysMenuItems;
+
+ /* Which menu to add to unmatched windows? */
+ char defaultSysMenuName[MENU_MAX+1];
+ MENUPOSITION defaultSysMenuPos; /* Where to place it */
+
+ /* Icon information */
+ char iconDirectory[PATH_MAX+1]; /* Where do the .icos lie? (Win32 path) */
+ char defaultIconName[NAME_MAX+1]; /* Replacement for x.ico */
+ char trayIconName[NAME_MAX+1]; /* Replacement for tray icon */
+
+ ICONITEM *icon;
+ int iconItems;
+
+ STYLEITEM *style;
+ int styleItems;
+
+ /* Force exit flag */
+ Bool fForceExit;
+
+ /* Silent exit flag */
+ Bool fSilentExit;
+
+} WINPREFS;
+
+
+
+
+/* Functions */
+void
+LoadPreferences(void);
+
+void
+SetupRootMenu (unsigned long hmenuRoot);
+
+void
+SetupSysMenu (unsigned long hwndIn);
+
+void
+HandleCustomWM_INITMENU(unsigned long hwndIn,
+ unsigned long hmenuIn);
+
+Bool
+HandleCustomWM_COMMAND (unsigned long hwndIn,
+ int command);
+
+int
+winIconIsOverride (unsigned hiconIn);
+
+HICON
+winOverrideIcon (unsigned long longpWin);
+
+unsigned long
+winOverrideStyle (unsigned long longpWin);
+
+unsigned long
+winOverrideStyle (unsigned long longpWin);
+
+HICON
+winTaskbarIcon(void);
+
+HICON
+winOverrideDefaultIcon(int size);
+#endif
diff --git a/xorg-server/hw/xwin/winprefslex.c b/xorg-server/hw/xwin/winprefslex.c
deleted file mode 100644
index c55bd8310..000000000
--- a/xorg-server/hw/xwin/winprefslex.c
+++ /dev/null
@@ -1,2191 +0,0 @@
-
-#line 3 "winprefslex.c"
-
-#define YY_INT_ALIGNED short int
-
-/* A lexical scanner generated by flex */
-
-#define FLEX_SCANNER
-#define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 35
-#if YY_FLEX_SUBMINOR_VERSION > 0
-#define FLEX_BETA
-#endif
-
-/* First, we deal with platform-specific or compiler-specific issues. */
-
-/* begin standard C headers. */
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-
-/* end standard C headers. */
-
-/* flex integer type definitions */
-
-#ifndef FLEXINT_H
-#define FLEXINT_H
-
-/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
-
-#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-
-/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
- * if you want the limit (max/min) macros for int types.
- */
-#ifndef __STDC_LIMIT_MACROS
-#define __STDC_LIMIT_MACROS 1
-#endif
-
-#include <inttypes.h>
-typedef int8_t flex_int8_t;
-typedef uint8_t flex_uint8_t;
-typedef int16_t flex_int16_t;
-typedef uint16_t flex_uint16_t;
-typedef int32_t flex_int32_t;
-typedef uint32_t flex_uint32_t;
-#else
-typedef signed char flex_int8_t;
-typedef short int flex_int16_t;
-typedef int flex_int32_t;
-typedef unsigned char flex_uint8_t;
-typedef unsigned short int flex_uint16_t;
-typedef unsigned int flex_uint32_t;
-
-/* Limits of integral types. */
-#ifndef INT8_MIN
-#define INT8_MIN (-128)
-#endif
-#ifndef INT16_MIN
-#define INT16_MIN (-32767-1)
-#endif
-#ifndef INT32_MIN
-#define INT32_MIN (-2147483647-1)
-#endif
-#ifndef INT8_MAX
-#define INT8_MAX (127)
-#endif
-#ifndef INT16_MAX
-#define INT16_MAX (32767)
-#endif
-#ifndef INT32_MAX
-#define INT32_MAX (2147483647)
-#endif
-#ifndef UINT8_MAX
-#define UINT8_MAX (255U)
-#endif
-#ifndef UINT16_MAX
-#define UINT16_MAX (65535U)
-#endif
-#ifndef UINT32_MAX
-#define UINT32_MAX (4294967295U)
-#endif
-
-#endif /* ! C99 */
-
-#endif /* ! FLEXINT_H */
-
-#ifdef __cplusplus
-
-/* The "const" storage-class-modifier is valid. */
-#define YY_USE_CONST
-
-#else /* ! __cplusplus */
-
-/* C99 requires __STDC__ to be defined as 1. */
-#if defined (__STDC__)
-
-#define YY_USE_CONST
-
-#endif /* defined (__STDC__) */
-#endif /* ! __cplusplus */
-
-#ifdef YY_USE_CONST
-#define yyconst const
-#else
-#define yyconst
-#endif
-
-/* Returned upon end-of-file. */
-#define YY_NULL 0
-
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
- */
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
-
-/* Enter a start condition. This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN.
- */
-#define BEGIN (yy_start) = 1 + 2 *
-
-/* Translate the current start state into a value that can be later handed
- * to BEGIN to return to the state. The YYSTATE alias is for lex
- * compatibility.
- */
-#define YY_START (((yy_start) - 1) / 2)
-#define YYSTATE YY_START
-
-/* Action number for EOF rule of a given start state. */
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
-/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE yyrestart(yyin )
-
-#define YY_END_OF_BUFFER_CHAR 0
-
-/* Size of default input buffer. */
-#ifndef YY_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k.
- * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
- * Ditto for the __ia64__ case accordingly.
- */
-#define YY_BUF_SIZE 32768
-#else
-#define YY_BUF_SIZE 16384
-#endif /* __ia64__ */
-#endif
-
-/* The state buf must be large enough to hold one state per character in the main buffer.
- */
-#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
-
-#ifndef YY_TYPEDEF_YY_BUFFER_STATE
-#define YY_TYPEDEF_YY_BUFFER_STATE
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-#endif
-
-extern int yyleng;
-
-extern FILE *yyin, *yyout;
-
-#define EOB_ACT_CONTINUE_SCAN 0
-#define EOB_ACT_END_OF_FILE 1
-#define EOB_ACT_LAST_MATCH 2
-
- /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
- * access to the local variable yy_act. Since yyless() is a macro, it would break
- * existing scanners that call yyless() from OUTSIDE yylex.
- * One obvious solution it to make yy_act a global. I tried that, and saw
- * a 5% performance hit in a non-yylineno scanner, because yy_act is
- * normally declared as a register variable-- so it is not worth it.
- */
- #define YY_LESS_LINENO(n) \
- do { \
- int yyl;\
- for ( yyl = n; yyl < yyleng; ++yyl )\
- if ( yytext[yyl] == '\n' )\
- --yylineno;\
- }while(0)
-
-/* Return all but the first "n" matched characters back to the input stream. */
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- *yy_cp = (yy_hold_char); \
- YY_RESTORE_YY_MORE_OFFSET \
- (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
- YY_DO_BEFORE_ACTION; /* set up yytext again */ \
- } \
- while ( 0 )
-
-#define unput(c) yyunput( c, (yytext_ptr) )
-
-#ifndef YY_TYPEDEF_YY_SIZE_T
-#define YY_TYPEDEF_YY_SIZE_T
-typedef size_t yy_size_t;
-#endif
-
-#ifndef YY_STRUCT_YY_BUFFER_STATE
-#define YY_STRUCT_YY_BUFFER_STATE
-struct yy_buffer_state
- {
- FILE *yy_input_file;
-
- char *yy_ch_buf; /* input buffer */
- char *yy_buf_pos; /* current position in input buffer */
-
- /* Size of input buffer in bytes, not including room for EOB
- * characters.
- */
- yy_size_t yy_buf_size;
-
- /* Number of characters read into yy_ch_buf, not including EOB
- * characters.
- */
- int yy_n_chars;
-
- /* Whether we "own" the buffer - i.e., we know we created it,
- * and can realloc() it to grow it, and should free() it to
- * delete it.
- */
- int yy_is_our_buffer;
-
- /* Whether this is an "interactive" input source; if so, and
- * if we're using stdio for input, then we want to use getc()
- * instead of fread(), to make sure we stop fetching input after
- * each newline.
- */
- int yy_is_interactive;
-
- /* Whether we're considered to be at the beginning of a line.
- * If so, '^' rules will be active on the next match, otherwise
- * not.
- */
- int yy_at_bol;
-
- int yy_bs_lineno; /**< The line count. */
- int yy_bs_column; /**< The column count. */
-
- /* Whether to try to fill the input buffer when we reach the
- * end of it.
- */
- int yy_fill_buffer;
-
- int yy_buffer_status;
-
-#define YY_BUFFER_NEW 0
-#define YY_BUFFER_NORMAL 1
- /* When an EOF's been seen but there's still some text to process
- * then we mark the buffer as YY_EOF_PENDING, to indicate that we
- * shouldn't try reading from the input source any more. We might
- * still have a bunch of tokens to match, though, because of
- * possible backing-up.
- *
- * When we actually see the EOF, we change the status to "new"
- * (via yyrestart()), so that the user can continue scanning by
- * just pointing yyin at a new input file.
- */
-#define YY_BUFFER_EOF_PENDING 2
-
- };
-#endif /* !YY_STRUCT_YY_BUFFER_STATE */
-
-/* Stack of input buffers. */
-static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
-static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
-static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
-
-/* We provide macros for accessing buffer states in case in the
- * future we want to put the buffer states in a more general
- * "scanner state".
- *
- * Returns the top of the stack, or NULL.
- */
-#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
- ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
- : NULL)
-
-/* Same as previous macro, but useful when we know that the buffer stack is not
- * NULL or when we need an lvalue. For internal use only.
- */
-#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
-
-/* yy_hold_char holds the character lost when yytext is formed. */
-static char yy_hold_char;
-static int yy_n_chars; /* number of characters read into yy_ch_buf */
-int yyleng;
-
-/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
-static int yy_init = 0; /* whether we need to initialize */
-static int yy_start = 0; /* start state number */
-
-/* Flag which is used to allow yywrap()'s to do buffer switches
- * instead of setting up a fresh yyin. A bit of a hack ...
- */
-static int yy_did_buffer_switch_on_eof;
-
-void yyrestart (FILE *input_file );
-void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer );
-YY_BUFFER_STATE yy_create_buffer (FILE *file,int size );
-void yy_delete_buffer (YY_BUFFER_STATE b );
-void yy_flush_buffer (YY_BUFFER_STATE b );
-void yypush_buffer_state (YY_BUFFER_STATE new_buffer );
-void yypop_buffer_state (void );
-
-static void yyensure_buffer_stack (void );
-static void yy_load_buffer_state (void );
-static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
-
-#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
-
-YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
-YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
-YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );
-
-void *yyalloc (yy_size_t );
-void *yyrealloc (void *,yy_size_t );
-void yyfree (void * );
-
-#define yy_new_buffer yy_create_buffer
-
-#define yy_set_interactive(is_interactive) \
- { \
- if ( ! YY_CURRENT_BUFFER ){ \
- yyensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- yy_create_buffer(yyin,YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
- }
-
-#define yy_set_bol(at_bol) \
- { \
- if ( ! YY_CURRENT_BUFFER ){\
- yyensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- yy_create_buffer(yyin,YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
- }
-
-#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
-
-/* Begin user sect3 */
-
-typedef unsigned char YY_CHAR;
-
-FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
-
-typedef int yy_state_type;
-
-extern int yylineno;
-
-int yylineno = 1;
-
-extern char *yytext;
-#define yytext_ptr yytext
-
-static yy_state_type yy_get_previous_state (void );
-static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
-static int yy_get_next_buffer (void );
-static void yy_fatal_error (yyconst char msg[] );
-
-/* Done after the current pattern has been matched and before the
- * corresponding action - sets up yytext.
- */
-#define YY_DO_BEFORE_ACTION \
- (yytext_ptr) = yy_bp; \
- yyleng = (size_t) (yy_cp - yy_bp); \
- (yy_hold_char) = *yy_cp; \
- *yy_cp = '\0'; \
- (yy_c_buf_p) = yy_cp;
-
-#define YY_NUM_RULES 33
-#define YY_END_OF_BUFFER 34
-/* This struct is not used in this scanner,
- but its presence is necessary. */
-struct yy_trans_info
- {
- flex_int32_t yy_verify;
- flex_int32_t yy_nxt;
- };
-static yyconst flex_int16_t yy_accept[186] =
- { 0,
- 0, 0, 34, 32, 4, 3, 32, 32, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 29, 30, 32, 4, 32, 0, 32, 0, 1, 1,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 31, 31, 32, 0, 2, 2, 32, 32, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 32, 32, 32, 32, 23, 32, 32, 5, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
-
- 32, 22, 32, 32, 25, 32, 32, 8, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 32, 32, 32, 13, 32, 32, 32, 32, 32, 32,
- 32, 26, 32, 32, 32, 9, 32, 32, 32, 32,
- 21, 32, 32, 32, 32, 16, 14, 15, 32, 32,
- 32, 19, 10, 32, 32, 32, 32, 32, 11, 12,
- 17, 32, 32, 27, 32, 32, 32, 32, 20, 32,
- 32, 32, 32, 32, 28, 24, 7, 32, 32, 32,
- 32, 32, 6, 18, 0
- } ;
-
-static yyconst flex_int32_t yy_ec[256] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
- 1, 1, 4, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 1, 5, 6, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 7, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 8, 9, 10, 11, 12, 13,
- 14, 1, 15, 1, 1, 16, 17, 18, 19, 20,
- 1, 21, 22, 23, 24, 1, 25, 26, 27, 28,
- 1, 1, 1, 1, 1, 1, 29, 30, 31, 32,
-
- 33, 34, 35, 1, 36, 1, 1, 37, 38, 39,
- 40, 41, 1, 42, 43, 44, 45, 1, 46, 47,
- 48, 49, 50, 1, 51, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1
- } ;
-
-static yyconst flex_int32_t yy_meta[52] =
- { 0,
- 1, 2, 3, 3, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1
- } ;
-
-static yyconst flex_int16_t yy_base[193] =
- { 0,
- 0, 0, 373, 0, 370, 403, 50, 54, 363, 37,
- 35, 47, 35, 52, 55, 45, 41, 54, 83, 50,
- 0, 0, 0, 367, 74, 362, 97, 74, 403, 93,
- 100, 43, 93, 49, 98, 96, 90, 86, 95, 96,
- 124, 94, 102, 101, 101, 106, 96, 102, 105, 132,
- 0, 403, 146, 148, 403, 150, 147, 138, 134, 136,
- 136, 154, 153, 146, 150, 142, 152, 148, 155, 155,
- 153, 150, 166, 163, 163, 165, 172, 170, 171, 188,
- 193, 183, 190, 181, 0, 195, 190, 0, 191, 201,
- 188, 197, 205, 197, 194, 198, 209, 212, 212, 224,
-
- 218, 0, 220, 226, 0, 228, 231, 0, 232, 233,
- 232, 234, 233, 242, 242, 247, 233, 235, 240, 237,
- 253, 247, 250, 0, 258, 261, 255, 257, 274, 276,
- 277, 0, 272, 268, 280, 0, 269, 272, 277, 279,
- 0, 283, 287, 288, 289, 0, 0, 0, 284, 296,
- 297, 0, 0, 306, 302, 317, 301, 320, 0, 0,
- 0, 310, 317, 0, 314, 315, 313, 314, 0, 315,
- 319, 322, 324, 323, 0, 0, 0, 331, 326, 332,
- 330, 341, 0, 0, 403, 365, 386, 388, 391, 393,
- 396, 399
-
- } ;
-
-static yyconst flex_int16_t yy_def[193] =
- { 0,
- 185, 1, 185, 186, 185, 185, 187, 188, 186, 186,
- 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
- 186, 186, 186, 185, 187, 189, 188, 190, 185, 190,
- 191, 186, 186, 186, 186, 186, 186, 186, 186, 186,
- 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
- 186, 185, 191, 192, 185, 192, 186, 186, 186, 186,
- 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
- 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
- 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
- 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
-
- 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
- 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
- 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
- 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
- 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
- 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
- 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
- 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
- 186, 186, 186, 186, 0, 185, 185, 185, 185, 185,
- 185, 185
-
- } ;
-
-static yyconst flex_int16_t yy_nxt[455] =
- { 0,
- 4, 5, 6, 6, 7, 8, 9, 10, 11, 4,
- 12, 13, 4, 4, 14, 4, 15, 16, 17, 4,
- 18, 19, 20, 4, 4, 4, 4, 4, 10, 11,
- 4, 12, 13, 4, 4, 14, 4, 15, 16, 17,
- 4, 18, 19, 20, 4, 4, 4, 4, 4, 21,
- 22, 26, 32, 34, 23, 28, 29, 30, 35, 33,
- 36, 37, 38, 41, 42, 43, 39, 57, 49, 40,
- 50, 60, 44, 32, 34, 26, 29, 30, 51, 35,
- 33, 36, 37, 38, 41, 42, 43, 39, 57, 49,
- 40, 50, 60, 44, 45, 29, 30, 46, 28, 29,
-
- 30, 54, 55, 56, 58, 47, 61, 63, 64, 48,
- 62, 65, 66, 67, 59, 45, 70, 71, 46, 72,
- 73, 74, 75, 76, 77, 58, 47, 61, 63, 64,
- 48, 62, 65, 66, 67, 59, 68, 70, 71, 78,
- 72, 73, 74, 75, 76, 77, 69, 54, 55, 56,
- 55, 56, 55, 56, 79, 80, 81, 68, 82, 83,
- 78, 84, 85, 86, 87, 88, 89, 69, 90, 91,
- 92, 93, 94, 95, 96, 79, 80, 81, 97, 82,
- 83, 98, 84, 85, 86, 87, 88, 89, 99, 90,
- 91, 92, 93, 94, 95, 96, 100, 101, 102, 97,
-
- 103, 104, 98, 105, 106, 107, 109, 110, 111, 99,
- 112, 113, 114, 115, 116, 117, 108, 100, 101, 102,
- 118, 103, 104, 119, 105, 106, 107, 109, 110, 111,
- 120, 112, 113, 114, 115, 116, 117, 108, 121, 122,
- 123, 118, 124, 125, 119, 126, 127, 128, 129, 130,
- 131, 120, 132, 133, 134, 135, 136, 137, 138, 121,
- 122, 123, 139, 124, 125, 140, 126, 127, 128, 129,
- 130, 131, 141, 132, 133, 134, 135, 136, 137, 138,
- 142, 143, 144, 139, 145, 146, 140, 147, 148, 149,
- 150, 151, 152, 141, 153, 154, 155, 156, 158, 159,
-
- 160, 142, 143, 144, 157, 145, 146, 161, 147, 148,
- 149, 150, 151, 152, 162, 153, 154, 155, 156, 158,
- 159, 160, 163, 164, 165, 157, 166, 167, 161, 168,
- 169, 170, 171, 172, 173, 162, 174, 175, 176, 177,
- 178, 179, 180, 163, 164, 165, 181, 166, 167, 182,
- 168, 169, 170, 171, 172, 173, 183, 174, 175, 176,
- 177, 178, 179, 180, 184, 23, 52, 181, 24, 31,
- 182, 24, 185, 185, 185, 185, 185, 183, 185, 185,
- 185, 185, 185, 185, 185, 184, 25, 25, 27, 27,
- 27, 26, 26, 28, 28, 28, 53, 53, 53, 54,
-
- 54, 54, 3, 185, 185, 185, 185, 185, 185, 185,
- 185, 185, 185, 185, 185, 185, 185, 185, 185, 185,
- 185, 185, 185, 185, 185, 185, 185, 185, 185, 185,
- 185, 185, 185, 185, 185, 185, 185, 185, 185, 185,
- 185, 185, 185, 185, 185, 185, 185, 185, 185, 185,
- 185, 185, 185, 185
- } ;
-
-static yyconst flex_int16_t yy_chk[455] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 7, 10, 11, 7, 8, 8, 8, 12, 10,
- 13, 14, 15, 16, 17, 18, 15, 32, 20, 15,
- 20, 34, 18, 10, 11, 25, 28, 28, 25, 12,
- 10, 13, 14, 15, 16, 17, 18, 15, 32, 20,
- 15, 20, 34, 18, 19, 30, 30, 19, 27, 27,
-
- 27, 31, 31, 31, 33, 19, 35, 36, 37, 19,
- 35, 38, 39, 40, 33, 19, 42, 43, 19, 44,
- 45, 46, 47, 48, 49, 33, 19, 35, 36, 37,
- 19, 35, 38, 39, 40, 33, 41, 42, 43, 50,
- 44, 45, 46, 47, 48, 49, 41, 53, 53, 53,
- 54, 54, 56, 56, 57, 58, 59, 41, 60, 61,
- 50, 62, 63, 64, 65, 66, 67, 41, 68, 69,
- 70, 71, 72, 73, 74, 57, 58, 59, 75, 60,
- 61, 76, 62, 63, 64, 65, 66, 67, 77, 68,
- 69, 70, 71, 72, 73, 74, 78, 79, 80, 75,
-
- 81, 82, 76, 83, 84, 86, 87, 89, 90, 77,
- 91, 92, 93, 94, 95, 96, 86, 78, 79, 80,
- 97, 81, 82, 98, 83, 84, 86, 87, 89, 90,
- 99, 91, 92, 93, 94, 95, 96, 86, 100, 101,
- 103, 97, 104, 106, 98, 107, 109, 110, 111, 112,
- 113, 99, 114, 115, 116, 117, 118, 119, 120, 100,
- 101, 103, 121, 104, 106, 122, 107, 109, 110, 111,
- 112, 113, 123, 114, 115, 116, 117, 118, 119, 120,
- 125, 126, 127, 121, 128, 129, 122, 130, 131, 133,
- 134, 135, 137, 123, 138, 139, 140, 142, 143, 144,
-
- 145, 125, 126, 127, 142, 128, 129, 149, 130, 131,
- 133, 134, 135, 137, 150, 138, 139, 140, 142, 143,
- 144, 145, 151, 154, 155, 142, 156, 157, 149, 158,
- 162, 163, 165, 166, 167, 150, 168, 170, 171, 172,
- 173, 174, 178, 151, 154, 155, 179, 156, 157, 180,
- 158, 162, 163, 165, 166, 167, 181, 168, 170, 171,
- 172, 173, 174, 178, 182, 186, 26, 179, 24, 9,
- 180, 5, 3, 0, 0, 0, 0, 181, 0, 0,
- 0, 0, 0, 0, 0, 182, 187, 187, 188, 188,
- 188, 189, 189, 190, 190, 190, 191, 191, 191, 192,
-
- 192, 192, 185, 185, 185, 185, 185, 185, 185, 185,
- 185, 185, 185, 185, 185, 185, 185, 185, 185, 185,
- 185, 185, 185, 185, 185, 185, 185, 185, 185, 185,
- 185, 185, 185, 185, 185, 185, 185, 185, 185, 185,
- 185, 185, 185, 185, 185, 185, 185, 185, 185, 185,
- 185, 185, 185, 185
- } ;
-
-/* Table of booleans, true if rule could match eol. */
-static yyconst flex_int32_t yy_rule_can_match_eol[34] =
- { 0,
-1, 1, 1, 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, 0, 0, };
-
-static yy_state_type yy_last_accepting_state;
-static char *yy_last_accepting_cpos;
-
-extern int yy_flex_debug;
-int yy_flex_debug = 0;
-
-/* The intent behind this definition is that it'll catch
- * any uses of REJECT which flex missed.
- */
-#define REJECT reject_used_but_not_detected
-#define yymore() yymore_used_but_not_detected
-#define YY_MORE_ADJ 0
-#define YY_RESTORE_YY_MORE_OFFSET
-char *yytext;
-#line 1 "winprefslex.l"
-#line 2 "winprefslex.l"
-/*
- * Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- * Copyright (C) Colin Harrison 2005-2008
- *
- * 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, 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 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 XFREE86 PROJECT 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 XFree86 Project
- * 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 XFree86 Project.
- *
- * Authors: Earle F. Philhower, III
- * Colin Harrison
- */
-/* $XFree86: $ */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "winprefsyacc.h"
-
-extern YYSTYPE yylval;
-extern char *yytext;
-extern int yyparse(void);
-
-extern void ErrorF (const char* /*f*/, ...);
-
-int yylineno;
-
-/* Copy the parsed string, must be free()d in yacc parser */
-static char *makestr(char *str)
-{
- char *ptr;
- ptr = (char*)malloc (strlen(str)+1);
- if (!ptr)
- {
- ErrorF ("winMultiWindowLex:makestr() out of memory\n");
- exit (-1);
- }
- strcpy(ptr, str);
- return ptr;
-}
-
-#line 702 "winprefslex.c"
-
-#define INITIAL 0
-
-#ifndef YY_NO_UNISTD_H
-/* Special case for "unistd.h", since it is non-ANSI. We include it way
- * down here because we want the user's section 1 to have been scanned first.
- * The user has a chance to override it with an option.
- */
-#include <unistd.h>
-#endif
-
-#ifndef YY_EXTRA_TYPE
-#define YY_EXTRA_TYPE void *
-#endif
-
-static int yy_init_globals (void );
-
-/* Accessor methods to globals.
- These are made visible to non-reentrant scanners for convenience. */
-
-int yylex_destroy (void );
-
-int yyget_debug (void );
-
-void yyset_debug (int debug_flag );
-
-YY_EXTRA_TYPE yyget_extra (void );
-
-void yyset_extra (YY_EXTRA_TYPE user_defined );
-
-FILE *yyget_in (void );
-
-void yyset_in (FILE * in_str );
-
-FILE *yyget_out (void );
-
-void yyset_out (FILE * out_str );
-
-int yyget_leng (void );
-
-char *yyget_text (void );
-
-int yyget_lineno (void );
-
-void yyset_lineno (int line_number );
-
-/* Macros after this point can all be overridden by user definitions in
- * section 1.
- */
-
-#ifndef YY_SKIP_YYWRAP
-#ifdef __cplusplus
-extern "C" int yywrap (void );
-#else
-extern int yywrap (void );
-#endif
-#endif
-
- static void yyunput (int c,char *buf_ptr );
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int );
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * );
-#endif
-
-#ifndef YY_NO_INPUT
-
-#ifdef __cplusplus
-static int yyinput (void );
-#else
-static int input (void );
-#endif
-
-#endif
-
-/* Amount of stuff to slurp up with each read. */
-#ifndef YY_READ_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k */
-#define YY_READ_BUF_SIZE 16384
-#else
-#define YY_READ_BUF_SIZE 8192
-#endif /* __ia64__ */
-#endif
-
-/* Copy whatever the last rule matched to the standard output. */
-#ifndef ECHO
-/* This used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite().
- */
-#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
-#endif
-
-/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
- * is returned in "result".
- */
-#ifndef YY_INPUT
-#define YY_INPUT(buf,result,max_size) \
- if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
- { \
- int c = '*'; \
- size_t n; \
- for ( n = 0; n < max_size && \
- (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
- buf[n] = (char) c; \
- if ( c == '\n' ) \
- buf[n++] = (char) c; \
- if ( c == EOF && ferror( yyin ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- result = n; \
- } \
- else \
- { \
- errno=0; \
- while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
- { \
- if( errno != EINTR) \
- { \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- break; \
- } \
- errno=0; \
- clearerr(yyin); \
- } \
- }\
-\
-
-#endif
-
-/* No semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#ifndef yyterminate
-#define yyterminate() return YY_NULL
-#endif
-
-/* Number of entries by which start-condition stack grows. */
-#ifndef YY_START_STACK_INCR
-#define YY_START_STACK_INCR 25
-#endif
-
-/* Report a fatal error. */
-#ifndef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
-#endif
-
-/* end tables serialization structures and prototypes */
-
-/* Default declaration of generated scanner - a define so the user can
- * easily add parameters.
- */
-#ifndef YY_DECL
-#define YY_DECL_IS_OURS 1
-
-extern int yylex (void);
-
-#define YY_DECL int yylex (void)
-#endif /* !YY_DECL */
-
-/* Code executed at the beginning of each rule, after yytext and yyleng
- * have been set up.
- */
-#ifndef YY_USER_ACTION
-#define YY_USER_ACTION
-#endif
-
-/* Code executed at the end of each rule. */
-#ifndef YY_BREAK
-#define YY_BREAK break;
-#endif
-
-#define YY_RULE_SETUP \
- YY_USER_ACTION
-
-/** The main scanner function which does all the work.
- */
-YY_DECL
-{
- register yy_state_type yy_current_state;
- register char *yy_cp, *yy_bp;
- register int yy_act;
-
-#line 66 "winprefslex.l"
-
-#line 891 "winprefslex.c"
-
- if ( !(yy_init) )
- {
- (yy_init) = 1;
-
-#ifdef YY_USER_INIT
- YY_USER_INIT;
-#endif
-
- if ( ! (yy_start) )
- (yy_start) = 1; /* first start state */
-
- if ( ! yyin )
- yyin = stdin;
-
- if ( ! yyout )
- yyout = stdout;
-
- if ( ! YY_CURRENT_BUFFER ) {
- yyensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- yy_create_buffer(yyin,YY_BUF_SIZE );
- }
-
- yy_load_buffer_state( );
- }
-
- while ( 1 ) /* loops until end-of-file is reached */
- {
- yy_cp = (yy_c_buf_p);
-
- /* Support of yytext. */
- *yy_cp = (yy_hold_char);
-
- /* yy_bp points to the position in yy_ch_buf of the start of
- * the current run.
- */
- yy_bp = yy_cp;
-
- yy_current_state = (yy_start);
-yy_match:
- do
- {
- register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 186 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- ++yy_cp;
- }
- while ( yy_base[yy_current_state] != 403 );
-
-yy_find_action:
- yy_act = yy_accept[yy_current_state];
- if ( yy_act == 0 )
- { /* have to back up */
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
- yy_act = yy_accept[yy_current_state];
- }
-
- YY_DO_BEFORE_ACTION;
-
- if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
- {
- int yyl;
- for ( yyl = 0; yyl < yyleng; ++yyl )
- if ( yytext[yyl] == '\n' )
-
- yylineno++;
-;
- }
-
-do_action: /* This label is used only to access EOF actions. */
-
- switch ( yy_act )
- { /* beginning of action switch */
- case 0: /* must back up */
- /* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = (yy_hold_char);
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
- goto yy_find_action;
-
-case 1:
-/* rule 1 can match eol */
-YY_RULE_SETUP
-#line 67 "winprefslex.l"
-{ /* comment */ return NEWLINE; }
- YY_BREAK
-case 2:
-/* rule 2 can match eol */
-YY_RULE_SETUP
-#line 68 "winprefslex.l"
-{ /* comment */ return NEWLINE; }
- YY_BREAK
-case 3:
-/* rule 3 can match eol */
-YY_RULE_SETUP
-#line 69 "winprefslex.l"
-{ return NEWLINE; }
- YY_BREAK
-case 4:
-YY_RULE_SETUP
-#line 70 "winprefslex.l"
-{ /* ignore whitespace */ }
- YY_BREAK
-case 5:
-YY_RULE_SETUP
-#line 71 "winprefslex.l"
-{ return MENU; }
- YY_BREAK
-case 6:
-YY_RULE_SETUP
-#line 72 "winprefslex.l"
-{ return ICONDIRECTORY; }
- YY_BREAK
-case 7:
-YY_RULE_SETUP
-#line 73 "winprefslex.l"
-{ return DEFAULTICON; }
- YY_BREAK
-case 8:
-YY_RULE_SETUP
-#line 74 "winprefslex.l"
-{ return ICONS; }
- YY_BREAK
-case 9:
-YY_RULE_SETUP
-#line 75 "winprefslex.l"
-{ return STYLES; }
- YY_BREAK
-case 10:
-YY_RULE_SETUP
-#line 76 "winprefslex.l"
-{ return TOPMOST; }
- YY_BREAK
-case 11:
-YY_RULE_SETUP
-#line 77 "winprefslex.l"
-{ return MAXIMIZE; }
- YY_BREAK
-case 12:
-YY_RULE_SETUP
-#line 78 "winprefslex.l"
-{ return MINIMIZE; }
- YY_BREAK
-case 13:
-YY_RULE_SETUP
-#line 79 "winprefslex.l"
-{ return BOTTOM; }
- YY_BREAK
-case 14:
-YY_RULE_SETUP
-#line 80 "winprefslex.l"
-{ return NOTITLE; }
- YY_BREAK
-case 15:
-YY_RULE_SETUP
-#line 81 "winprefslex.l"
-{ return OUTLINE; }
- YY_BREAK
-case 16:
-YY_RULE_SETUP
-#line 82 "winprefslex.l"
-{ return NOFRAME; }
- YY_BREAK
-case 17:
-YY_RULE_SETUP
-#line 83 "winprefslex.l"
-{ return ROOTMENU; }
- YY_BREAK
-case 18:
-YY_RULE_SETUP
-#line 84 "winprefslex.l"
-{ return DEFAULTSYSMENU; }
- YY_BREAK
-case 19:
-YY_RULE_SETUP
-#line 85 "winprefslex.l"
-{ return SYSMENU; }
- YY_BREAK
-case 20:
-YY_RULE_SETUP
-#line 86 "winprefslex.l"
-{ return SEPARATOR; }
- YY_BREAK
-case 21:
-YY_RULE_SETUP
-#line 87 "winprefslex.l"
-{ return ATSTART; }
- YY_BREAK
-case 22:
-YY_RULE_SETUP
-#line 88 "winprefslex.l"
-{ return ATEND; }
- YY_BREAK
-case 23:
-YY_RULE_SETUP
-#line 89 "winprefslex.l"
-{ return EXEC; }
- YY_BREAK
-case 24:
-YY_RULE_SETUP
-#line 90 "winprefslex.l"
-{ return ALWAYSONTOP; }
- YY_BREAK
-case 25:
-YY_RULE_SETUP
-#line 91 "winprefslex.l"
-{ return DEBUG; }
- YY_BREAK
-case 26:
-YY_RULE_SETUP
-#line 92 "winprefslex.l"
-{ return RELOAD; }
- YY_BREAK
-case 27:
-YY_RULE_SETUP
-#line 93 "winprefslex.l"
-{ return TRAYICON; }
- YY_BREAK
-case 28:
-YY_RULE_SETUP
-#line 94 "winprefslex.l"
-{ return SILENTEXIT; }
- YY_BREAK
-case 29:
-YY_RULE_SETUP
-#line 95 "winprefslex.l"
-{ return LB; }
- YY_BREAK
-case 30:
-YY_RULE_SETUP
-#line 96 "winprefslex.l"
-{ return RB; }
- YY_BREAK
-case 31:
-YY_RULE_SETUP
-#line 97 "winprefslex.l"
-{ yylval.sVal = makestr(yytext+1); \
- yylval.sVal[strlen(yylval.sVal)-1] = 0; \
- return STRING; }
- YY_BREAK
-case 32:
-YY_RULE_SETUP
-#line 100 "winprefslex.l"
-{ yylval.sVal = makestr(yytext); \
- return STRING; }
- YY_BREAK
-case 33:
-YY_RULE_SETUP
-#line 102 "winprefslex.l"
-ECHO;
- YY_BREAK
-#line 1155 "winprefslex.c"
-case YY_STATE_EOF(INITIAL):
- yyterminate();
-
- case YY_END_OF_BUFFER:
- {
- /* Amount of text matched not including the EOB char. */
- int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
-
- /* Undo the effects of YY_DO_BEFORE_ACTION. */
- *yy_cp = (yy_hold_char);
- YY_RESTORE_YY_MORE_OFFSET
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
- {
- /* We're scanning a new file or input source. It's
- * possible that this happened because the user
- * just pointed yyin at a new source and called
- * yylex(). If so, then we have to assure
- * consistency between YY_CURRENT_BUFFER and our
- * globals. Here is the right place to do so, because
- * this is the first action (other than possibly a
- * back-up) that will match for the new input source.
- */
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
- }
-
- /* Note that here we test for yy_c_buf_p "<=" to the position
- * of the first EOB in the buffer, since yy_c_buf_p will
- * already have been incremented past the NUL character
- * (since all states make transitions on EOB to the
- * end-of-buffer state). Contrast this with the test
- * in input().
- */
- if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- { /* This was really a NUL. */
- yy_state_type yy_next_state;
-
- (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- /* Okay, we're now positioned to make the NUL
- * transition. We couldn't have
- * yy_get_previous_state() go ahead and do it
- * for us because it doesn't know how to deal
- * with the possibility of jamming (and we don't
- * want to build jamming into it because then it
- * will run more slowly).
- */
-
- yy_next_state = yy_try_NUL_trans( yy_current_state );
-
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
-
- if ( yy_next_state )
- {
- /* Consume the NUL. */
- yy_cp = ++(yy_c_buf_p);
- yy_current_state = yy_next_state;
- goto yy_match;
- }
-
- else
- {
- yy_cp = (yy_c_buf_p);
- goto yy_find_action;
- }
- }
-
- else switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_END_OF_FILE:
- {
- (yy_did_buffer_switch_on_eof) = 0;
-
- if ( yywrap( ) )
- {
- /* Note: because we've taken care in
- * yy_get_next_buffer() to have set up
- * yytext, we can now set up
- * yy_c_buf_p so that if some total
- * hoser (like flex itself) wants to
- * call the scanner after we return the
- * YY_NULL, it'll still work - another
- * YY_NULL will get returned.
- */
- (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
-
- yy_act = YY_STATE_EOF(YY_START);
- goto do_action;
- }
-
- else
- {
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
- }
- break;
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) =
- (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_match;
-
- case EOB_ACT_LAST_MATCH:
- (yy_c_buf_p) =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_find_action;
- }
- break;
- }
-
- default:
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--no action found" );
- } /* end of action switch */
- } /* end of scanning one token */
-} /* end of yylex */
-
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * Returns a code representing an action:
- * EOB_ACT_LAST_MATCH -
- * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- * EOB_ACT_END_OF_FILE - end of file
- */
-static int yy_get_next_buffer (void)
-{
- register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
- register char *source = (yytext_ptr);
- register int number_to_move, i;
- int ret_val;
-
- if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--end of buffer missed" );
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
- { /* Don't try to fill the buffer, so this is an EOF. */
- if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
- {
- /* We matched a single character, the EOB, so
- * treat this as a final EOF.
- */
- return EOB_ACT_END_OF_FILE;
- }
-
- else
- {
- /* We matched some text prior to the EOB, first
- * process it.
- */
- return EOB_ACT_LAST_MATCH;
- }
- }
-
- /* Try to read more data. */
-
- /* First move last chars to start of buffer. */
- number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
-
- for ( i = 0; i < number_to_move; ++i )
- *(dest++) = *(source++);
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
- /* don't do the read, it's not guaranteed to return an EOF,
- * just force an EOF
- */
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
-
- else
- {
- int num_to_read =
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
-
- while ( num_to_read <= 0 )
- { /* Not enough room in the buffer - grow it. */
-
- /* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
-
- int yy_c_buf_p_offset =
- (int) ((yy_c_buf_p) - b->yy_ch_buf);
-
- if ( b->yy_is_our_buffer )
- {
- int new_size = b->yy_buf_size * 2;
-
- if ( new_size <= 0 )
- b->yy_buf_size += b->yy_buf_size / 8;
- else
- b->yy_buf_size *= 2;
-
- b->yy_ch_buf = (char *)
- /* Include room in for 2 EOB chars. */
- yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
- }
- else
- /* Can't grow it, we don't own it. */
- b->yy_ch_buf = 0;
-
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR(
- "fatal error - scanner input buffer overflow" );
-
- (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
-
- num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
- number_to_move - 1;
-
- }
-
- if ( num_to_read > YY_READ_BUF_SIZE )
- num_to_read = YY_READ_BUF_SIZE;
-
- /* Read in more data. */
- YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
- (yy_n_chars), (size_t) num_to_read );
-
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- if ( (yy_n_chars) == 0 )
- {
- if ( number_to_move == YY_MORE_ADJ )
- {
- ret_val = EOB_ACT_END_OF_FILE;
- yyrestart(yyin );
- }
-
- else
- {
- ret_val = EOB_ACT_LAST_MATCH;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
- YY_BUFFER_EOF_PENDING;
- }
- }
-
- else
- ret_val = EOB_ACT_CONTINUE_SCAN;
-
- if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
- /* Extend the array by 50%, plus the number we really need. */
- yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
- if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
- }
-
- (yy_n_chars) += number_to_move;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
-
- (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
-
- return ret_val;
-}
-
-/* yy_get_previous_state - get the state just before the EOB char was reached */
-
- static yy_state_type yy_get_previous_state (void)
-{
- register yy_state_type yy_current_state;
- register char *yy_cp;
-
- yy_current_state = (yy_start);
-
- for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
- {
- register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 186 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- }
-
- return yy_current_state;
-}
-
-/* yy_try_NUL_trans - try to make a transition on the NUL character
- *
- * synopsis
- * next_state = yy_try_NUL_trans( current_state );
- */
- static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
-{
- register int yy_is_jam;
- register char *yy_cp = (yy_c_buf_p);
-
- register YY_CHAR yy_c = 1;
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 186 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- yy_is_jam = (yy_current_state == 185);
-
- return yy_is_jam ? 0 : yy_current_state;
-}
-
- static void yyunput (int c, register char * yy_bp )
-{
- register char *yy_cp;
-
- yy_cp = (yy_c_buf_p);
-
- /* undo effects of setting up yytext */
- *yy_cp = (yy_hold_char);
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- { /* need to shift things up to make room */
- /* +2 for EOB chars. */
- register int number_to_move = (yy_n_chars) + 2;
- register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
- register char *source =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
-
- while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
- *--dest = *--source;
-
- yy_cp += (int) (dest - source);
- yy_bp += (int) (dest - source);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- YY_FATAL_ERROR( "flex scanner push-back overflow" );
- }
-
- *--yy_cp = (char) c;
-
- if ( c == '\n' ){
- --yylineno;
- }
-
- (yytext_ptr) = yy_bp;
- (yy_hold_char) = *yy_cp;
- (yy_c_buf_p) = yy_cp;
-}
-
-#ifndef YY_NO_INPUT
-#ifdef __cplusplus
- static int yyinput (void)
-#else
- static int input (void)
-#endif
-
-{
- int c;
-
- *(yy_c_buf_p) = (yy_hold_char);
-
- if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
- {
- /* yy_c_buf_p now points to the character we want to return.
- * If this occurs *before* the EOB characters, then it's a
- * valid NUL; if not, then we've hit the end of the buffer.
- */
- if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- /* This was really a NUL. */
- *(yy_c_buf_p) = '\0';
-
- else
- { /* need more input */
- int offset = (yy_c_buf_p) - (yytext_ptr);
- ++(yy_c_buf_p);
-
- switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_LAST_MATCH:
- /* This happens because yy_g_n_b()
- * sees that we've accumulated a
- * token and flags that we need to
- * try matching the token before
- * proceeding. But for input(),
- * there's no matching to consider.
- * So convert the EOB_ACT_LAST_MATCH
- * to EOB_ACT_END_OF_FILE.
- */
-
- /* Reset buffer status. */
- yyrestart(yyin );
-
- /*FALLTHROUGH*/
-
- case EOB_ACT_END_OF_FILE:
- {
- if ( yywrap( ) )
- return EOF;
-
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
-#ifdef __cplusplus
- return yyinput();
-#else
- return input();
-#endif
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) = (yytext_ptr) + offset;
- break;
- }
- }
- }
-
- c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
- *(yy_c_buf_p) = '\0'; /* preserve yytext */
- (yy_hold_char) = *++(yy_c_buf_p);
-
- if ( c == '\n' )
-
- yylineno++;
-;
-
- return c;
-}
-#endif /* ifndef YY_NO_INPUT */
-
-/** Immediately switch to a different input stream.
- * @param input_file A readable stream.
- *
- * @note This function does not reset the start condition to @c INITIAL .
- */
- void yyrestart (FILE * input_file )
-{
-
- if ( ! YY_CURRENT_BUFFER ){
- yyensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- yy_create_buffer(yyin,YY_BUF_SIZE );
- }
-
- yy_init_buffer(YY_CURRENT_BUFFER,input_file );
- yy_load_buffer_state( );
-}
-
-/** Switch to a different input buffer.
- * @param new_buffer The new input buffer.
- *
- */
- void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
-{
-
- /* TODO. We should be able to replace this entire function body
- * with
- * yypop_buffer_state();
- * yypush_buffer_state(new_buffer);
- */
- yyensure_buffer_stack ();
- if ( YY_CURRENT_BUFFER == new_buffer )
- return;
-
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
- yy_load_buffer_state( );
-
- /* We don't actually know whether we did this switch during
- * EOF (yywrap()) processing, but the only time this flag
- * is looked at is after yywrap() is called, so it's safe
- * to go ahead and always set it.
- */
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-static void yy_load_buffer_state (void)
-{
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
- yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
- (yy_hold_char) = *(yy_c_buf_p);
-}
-
-/** Allocate and initialize an input buffer state.
- * @param file A readable stream.
- * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
- *
- * @return the allocated buffer state.
- */
- YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
-{
- YY_BUFFER_STATE b;
-
- b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_buf_size = size;
-
- /* yy_ch_buf has to be 2 characters longer than the size given because
- * we need to put in 2 end-of-buffer characters.
- */
- b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 );
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_is_our_buffer = 1;
-
- yy_init_buffer(b,file );
-
- return b;
-}
-
-/** Destroy the buffer.
- * @param b a buffer created with yy_create_buffer()
- *
- */
- void yy_delete_buffer (YY_BUFFER_STATE b )
-{
-
- if ( ! b )
- return;
-
- if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
- YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
-
- if ( b->yy_is_our_buffer )
- yyfree((void *) b->yy_ch_buf );
-
- yyfree((void *) b );
-}
-
-#ifndef __cplusplus
-extern int isatty (int );
-#endif /* __cplusplus */
-
-/* Initializes or reinitializes a buffer.
- * This function is sometimes called more than once on the same buffer,
- * such as during a yyrestart() or at EOF.
- */
- static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
-
-{
- int oerrno = errno;
-
- yy_flush_buffer(b );
-
- b->yy_input_file = file;
- b->yy_fill_buffer = 1;
-
- /* If b is the current buffer, then yy_init_buffer was _probably_
- * called from yyrestart() or through yy_get_next_buffer.
- * In that case, we don't want to reset the lineno or column.
- */
- if (b != YY_CURRENT_BUFFER){
- b->yy_bs_lineno = 1;
- b->yy_bs_column = 0;
- }
-
- b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
-
- errno = oerrno;
-}
-
-/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
- * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
- *
- */
- void yy_flush_buffer (YY_BUFFER_STATE b )
-{
- if ( ! b )
- return;
-
- b->yy_n_chars = 0;
-
- /* We always need two end-of-buffer characters. The first causes
- * a transition to the end-of-buffer state. The second causes
- * a jam in that state.
- */
- b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
- b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
-
- b->yy_buf_pos = &b->yy_ch_buf[0];
-
- b->yy_at_bol = 1;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- if ( b == YY_CURRENT_BUFFER )
- yy_load_buffer_state( );
-}
-
-/** Pushes the new state onto the stack. The new state becomes
- * the current state. This function will allocate the stack
- * if necessary.
- * @param new_buffer The new state.
- *
- */
-void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
-{
- if (new_buffer == NULL)
- return;
-
- yyensure_buffer_stack();
-
- /* This block is copied from yy_switch_to_buffer. */
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- /* Only push if top exists. Otherwise, replace top. */
- if (YY_CURRENT_BUFFER)
- (yy_buffer_stack_top)++;
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
-
- /* copied from yy_switch_to_buffer. */
- yy_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-/** Removes and deletes the top of the stack, if present.
- * The next element becomes the new top.
- *
- */
-void yypop_buffer_state (void)
-{
- if (!YY_CURRENT_BUFFER)
- return;
-
- yy_delete_buffer(YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- if ((yy_buffer_stack_top) > 0)
- --(yy_buffer_stack_top);
-
- if (YY_CURRENT_BUFFER) {
- yy_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
- }
-}
-
-/* Allocates the stack if it does not exist.
- * Guarantees space for at least one push.
- */
-static void yyensure_buffer_stack (void)
-{
- int num_to_alloc;
-
- if (!(yy_buffer_stack)) {
-
- /* First allocation is just for 2 elements, since we don't know if this
- * scanner will even need a stack. We use 2 instead of 1 to avoid an
- * immediate realloc on the next call.
- */
- num_to_alloc = 1;
- (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
- (num_to_alloc * sizeof(struct yy_buffer_state*)
- );
- if ( ! (yy_buffer_stack) )
- YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
-
- memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
-
- (yy_buffer_stack_max) = num_to_alloc;
- (yy_buffer_stack_top) = 0;
- return;
- }
-
- if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
-
- /* Increase the buffer to prepare for a possible push. */
- int grow_size = 8 /* arbitrary grow size */;
-
- num_to_alloc = (yy_buffer_stack_max) + grow_size;
- (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
- ((yy_buffer_stack),
- num_to_alloc * sizeof(struct yy_buffer_state*)
- );
- if ( ! (yy_buffer_stack) )
- YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
-
- /* zero only the new slots.*/
- memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
- (yy_buffer_stack_max) = num_to_alloc;
- }
-}
-
-/** Setup the input buffer state to scan directly from a user-specified character buffer.
- * @param base the character buffer
- * @param size the size in bytes of the character buffer
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
-{
- YY_BUFFER_STATE b;
-
- if ( size < 2 ||
- base[size-2] != YY_END_OF_BUFFER_CHAR ||
- base[size-1] != YY_END_OF_BUFFER_CHAR )
- /* They forgot to leave room for the EOB's. */
- return 0;
-
- b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
-
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
- b->yy_buf_pos = b->yy_ch_buf = base;
- b->yy_is_our_buffer = 0;
- b->yy_input_file = 0;
- b->yy_n_chars = b->yy_buf_size;
- b->yy_is_interactive = 0;
- b->yy_at_bol = 1;
- b->yy_fill_buffer = 0;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- yy_switch_to_buffer(b );
-
- return b;
-}
-
-/** Setup the input buffer state to scan a string. The next call to yylex() will
- * scan from a @e copy of @a str.
- * @param yystr a NUL-terminated string to scan
- *
- * @return the newly allocated buffer state object.
- * @note If you want to scan bytes that may contain NUL values, then use
- * yy_scan_bytes() instead.
- */
-YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
-{
-
- return yy_scan_bytes(yystr,strlen(yystr) );
-}
-
-/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
- * scan from a @e copy of @a bytes.
- * @param yybytes the byte buffer to scan
- * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
-{
- YY_BUFFER_STATE b;
- char *buf;
- yy_size_t n;
- int i;
-
- /* Get memory for full buffer, including space for trailing EOB's. */
- n = _yybytes_len + 2;
- buf = (char *) yyalloc(n );
- if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
-
- for ( i = 0; i < _yybytes_len; ++i )
- buf[i] = yybytes[i];
-
- buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
-
- b = yy_scan_buffer(buf,n );
- if ( ! b )
- YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
-
- /* It's okay to grow etc. this buffer, and we should throw it
- * away when we're done.
- */
- b->yy_is_our_buffer = 1;
-
- return b;
-}
-
-#ifndef YY_EXIT_FAILURE
-#define YY_EXIT_FAILURE 2
-#endif
-
-static void yy_fatal_error (yyconst char* msg )
-{
- (void) fprintf( stderr, "%s\n", msg );
- exit( YY_EXIT_FAILURE );
-}
-
-/* Redefine yyless() so it works in section 3 code. */
-
-#undef yyless
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- yytext[yyleng] = (yy_hold_char); \
- (yy_c_buf_p) = yytext + yyless_macro_arg; \
- (yy_hold_char) = *(yy_c_buf_p); \
- *(yy_c_buf_p) = '\0'; \
- yyleng = yyless_macro_arg; \
- } \
- while ( 0 )
-
-/* Accessor methods (get/set functions) to struct members. */
-
-/** Get the current line number.
- *
- */
-int yyget_lineno (void)
-{
-
- return yylineno;
-}
-
-/** Get the input stream.
- *
- */
-FILE *yyget_in (void)
-{
- return yyin;
-}
-
-/** Get the output stream.
- *
- */
-FILE *yyget_out (void)
-{
- return yyout;
-}
-
-/** Get the length of the current token.
- *
- */
-int yyget_leng (void)
-{
- return yyleng;
-}
-
-/** Get the current token.
- *
- */
-
-char *yyget_text (void)
-{
- return yytext;
-}
-
-/** Set the current line number.
- * @param line_number
- *
- */
-void yyset_lineno (int line_number )
-{
-
- yylineno = line_number;
-}
-
-/** Set the input stream. This does not discard the current
- * input buffer.
- * @param in_str A readable stream.
- *
- * @see yy_switch_to_buffer
- */
-void yyset_in (FILE * in_str )
-{
- yyin = in_str ;
-}
-
-void yyset_out (FILE * out_str )
-{
- yyout = out_str ;
-}
-
-int yyget_debug (void)
-{
- return yy_flex_debug;
-}
-
-void yyset_debug (int bdebug )
-{
- yy_flex_debug = bdebug ;
-}
-
-static int yy_init_globals (void)
-{
- /* Initialization is the same as for the non-reentrant scanner.
- * This function is called from yylex_destroy(), so don't allocate here.
- */
-
- /* We do not touch yylineno unless the option is enabled. */
- yylineno = 1;
-
- (yy_buffer_stack) = 0;
- (yy_buffer_stack_top) = 0;
- (yy_buffer_stack_max) = 0;
- (yy_c_buf_p) = (char *) 0;
- (yy_init) = 0;
- (yy_start) = 0;
-
-/* Defined in main.c */
-#ifdef YY_STDINIT
- yyin = stdin;
- yyout = stdout;
-#else
- yyin = (FILE *) 0;
- yyout = (FILE *) 0;
-#endif
-
- /* For future reference: Set errno on error, since we are called by
- * yylex_init()
- */
- return 0;
-}
-
-/* yylex_destroy is for both reentrant and non-reentrant scanners. */
-int yylex_destroy (void)
-{
-
- /* Pop the buffer stack, destroying each element. */
- while(YY_CURRENT_BUFFER){
- yy_delete_buffer(YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- yypop_buffer_state();
- }
-
- /* Destroy the stack itself. */
- yyfree((yy_buffer_stack) );
- (yy_buffer_stack) = NULL;
-
- /* Reset the globals. This is important in a non-reentrant scanner so the next time
- * yylex() is called, initialization will occur. */
- yy_init_globals( );
-
- return 0;
-}
-
-/*
- * Internal utility routines.
- */
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
-{
- register int i;
- for ( i = 0; i < n; ++i )
- s1[i] = s2[i];
-}
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * s )
-{
- register int n;
- for ( n = 0; s[n]; ++n )
- ;
-
- return n;
-}
-#endif
-
-void *yyalloc (yy_size_t size )
-{
- return (void *) malloc( size );
-}
-
-void *yyrealloc (void * ptr, yy_size_t size )
-{
- /* The cast to (char *) in the following accommodates both
- * implementations that use char* generic pointers, and those
- * that use void* generic pointers. It works with the latter
- * because both ANSI C and C++ allow castless assignment from
- * any pointer type to void*, and deal with argument conversions
- * as though doing an assignment.
- */
- return (void *) realloc( (char *) ptr, size );
-}
-
-void yyfree (void * ptr )
-{
- free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
-}
-
-#define YYTABLES_NAME "yytables"
-
-#line 102 "winprefslex.l"
-
-
-
-/*
- * Run-of-the mill requirement for yacc
- */
-int
-yywrap (void)
-{
- return 1;
-}
-
-/*
- * Run a file through the yacc parser
- */
-void
-parse_file (FILE *file)
-{
- if (!file)
- return;
-
- yylineno = 1;
- yyin = file;
- yyparse ();
-}
-
-
diff --git a/xorg-server/hw/xwin/winprefslex.l b/xorg-server/hw/xwin/winprefslex.l
index 9a384a2cd..fd3fc1c05 100644
--- a/xorg-server/hw/xwin/winprefslex.l
+++ b/xorg-server/hw/xwin/winprefslex.l
@@ -41,8 +41,6 @@ extern YYSTYPE yylval;
extern char *yytext;
extern int yyparse(void);
-extern void ErrorF (const char* /*f*/, ...);
-
int yylineno;
/* Copy the parsed string, must be free()d in yacc parser */
@@ -88,7 +86,7 @@ ATSTART { return ATSTART; }
ATEND { return ATEND; }
EXEC { return EXEC; }
ALWAYSONTOP { return ALWAYSONTOP; }
-DEBUG { return DEBUG; }
+DEBUG { return DEBUGTOK; }
RELOAD { return RELOAD; }
TRAYICON { return TRAYICON; }
SILENTEXIT { return SILENTEXIT; }
diff --git a/xorg-server/hw/xwin/winprefsyacc.c b/xorg-server/hw/xwin/winprefsyacc.c
deleted file mode 100644
index 1255887c3..000000000
--- a/xorg-server/hw/xwin/winprefsyacc.c
+++ /dev/null
@@ -1,2248 +0,0 @@
-
-/* A Bison parser, made by GNU Bison 2.4.1. */
-
-/* Skeleton implementation for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
- Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* As a special exception, you may create a larger work that contains
- part or all of the Bison parser skeleton and distribute that work
- under terms of your choice, so long as that work isn't itself a
- parser generator using the skeleton or a modified version thereof
- as a parser skeleton. Alternatively, if you modify or redistribute
- the parser skeleton itself, you may (at your option) remove this
- special exception, which will cause the skeleton and the resulting
- Bison output files to be licensed under the GNU General Public
- License without this special exception.
-
- This special exception was added by the Free Software Foundation in
- version 2.2 of Bison. */
-
-/* C LALR(1) parser skeleton written by Richard Stallman, by
- simplifying the original so-called "semantic" parser. */
-
-/* All symbols defined below should begin with yy or YY, to avoid
- infringing on user name space. This should be done even for local
- variables, as they might otherwise be expanded by user macros.
- There are some unavoidable exceptions within include files to
- define necessary library symbols; they are noted "INFRINGES ON
- USER NAME SPACE" below. */
-
-/* Identify Bison output. */
-#define YYBISON 1
-
-/* Bison version. */
-#define YYBISON_VERSION "2.4.1"
-
-/* Skeleton name. */
-#define YYSKELETON_NAME "yacc.c"
-
-/* Pure parsers. */
-#define YYPURE 0
-
-/* Push parsers. */
-#define YYPUSH 0
-
-/* Pull parsers. */
-#define YYPULL 1
-
-/* Using locations. */
-#define YYLSP_NEEDED 0
-
-
-
-/* Copy the first part of user declarations. */
-
-/* Line 189 of yacc.c */
-#line 1 "winprefsyacc.y"
-
-/*
- * Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- * Copyright (C) Colin Harrison 2005-2008
- *
- * 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, 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 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 XFREE86 PROJECT 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 XFree86 Project
- * 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 XFree86 Project.
- *
- * Authors: Earle F. Philhower, III
- * Colin Harrison
- */
-/* $XFree86: $ */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "winprefs.h"
-
-/* The following give better error messages in bison at the cost of a few KB */
-#define YYERROR_VERBOSE 1
-
-/* YYLTYPE_IS_TRIVIAL and YYENABLE_NLS defined to suppress warnings */
-#define YYLTYPE_IS_TRIVIAL 1
-#define YYENABLE_NLS 0
-
-/* The global pref settings */
-WINPREFS pref;
-
-/* The working menu */
-static MENUPARSED menu;
-
-/* Functions for parsing the tokens into out structure */
-/* Defined at the end section of this file */
-
-static void SetIconDirectory (char *path);
-static void SetDefaultIcon (char *fname);
-static void SetRootMenu (char *menu);
-static void SetDefaultSysMenu (char *menu, int pos);
-static void SetTrayIcon (char *fname);
-
-static void OpenMenu(char *menuname);
-static void AddMenuLine(char *name, MENUCOMMANDTYPE cmd, char *param);
-static void CloseMenu(void);
-
-static void OpenIcons(void);
-static void AddIconLine(char *matchstr, char *iconfile);
-static void CloseIcons(void);
-
-static void OpenStyles(void);
-static void AddStyleLine(char *matchstr, unsigned long style);
-static void CloseStyles(void);
-
-static void OpenSysMenu(void);
-static void AddSysMenuLine(char *matchstr, char *menuname, int pos);
-static void CloseSysMenu(void);
-
-static int yyerror (char *s);
-
-extern void ErrorF (const char* /*f*/, ...);
-extern char *yytext;
-extern int yylex(void);
-
-
-
-/* Line 189 of yacc.c */
-#line 162 "winprefsyacc.c"
-
-/* Enabling traces. */
-#ifndef YYDEBUG
-# define YYDEBUG 0
-#endif
-
-/* Enabling verbose error messages. */
-#ifdef YYERROR_VERBOSE
-# undef YYERROR_VERBOSE
-# define YYERROR_VERBOSE 1
-#else
-# define YYERROR_VERBOSE 0
-#endif
-
-/* Enabling the token table. */
-#ifndef YYTOKEN_TABLE
-# define YYTOKEN_TABLE 0
-#endif
-
-
-/* Tokens. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- /* Put the tokens into the symbol table, so that GDB and other debuggers
- know about them. */
- enum yytokentype {
- NEWLINE = 258,
- MENU = 259,
- LB = 260,
- RB = 261,
- ICONDIRECTORY = 262,
- DEFAULTICON = 263,
- ICONS = 264,
- STYLES = 265,
- TOPMOST = 266,
- MAXIMIZE = 267,
- MINIMIZE = 268,
- BOTTOM = 269,
- NOTITLE = 270,
- OUTLINE = 271,
- NOFRAME = 272,
- DEFAULTSYSMENU = 273,
- SYSMENU = 274,
- ROOTMENU = 275,
- SEPARATOR = 276,
- ATSTART = 277,
- ATEND = 278,
- EXEC = 279,
- ALWAYSONTOP = 280,
- DEBUG = 281,
- RELOAD = 282,
- TRAYICON = 283,
- SILENTEXIT = 284,
- STRING = 285
- };
-#endif
-/* Tokens. */
-#define NEWLINE 258
-#define MENU 259
-#define LB 260
-#define RB 261
-#define ICONDIRECTORY 262
-#define DEFAULTICON 263
-#define ICONS 264
-#define STYLES 265
-#define TOPMOST 266
-#define MAXIMIZE 267
-#define MINIMIZE 268
-#define BOTTOM 269
-#define NOTITLE 270
-#define OUTLINE 271
-#define NOFRAME 272
-#define DEFAULTSYSMENU 273
-#define SYSMENU 274
-#define ROOTMENU 275
-#define SEPARATOR 276
-#define ATSTART 277
-#define ATEND 278
-#define EXEC 279
-#define ALWAYSONTOP 280
-#define DEBUG 281
-#define RELOAD 282
-#define TRAYICON 283
-#define SILENTEXIT 284
-#define STRING 285
-
-
-
-
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef union YYSTYPE
-{
-
-/* Line 214 of yacc.c */
-#line 89 "winprefsyacc.y"
-
- char *sVal;
- unsigned long uVal;
- int iVal;
-
-
-
-/* Line 214 of yacc.c */
-#line 266 "winprefsyacc.c"
-} YYSTYPE;
-# define YYSTYPE_IS_TRIVIAL 1
-# define yystype YYSTYPE /* obsolescent; will be withdrawn */
-# define YYSTYPE_IS_DECLARED 1
-#endif
-
-
-/* Copy the second part of user declarations. */
-
-
-/* Line 264 of yacc.c */
-#line 278 "winprefsyacc.c"
-
-#ifdef short
-# undef short
-#endif
-
-#ifdef YYTYPE_UINT8
-typedef YYTYPE_UINT8 yytype_uint8;
-#else
-typedef unsigned char yytype_uint8;
-#endif
-
-#ifdef YYTYPE_INT8
-typedef YYTYPE_INT8 yytype_int8;
-#elif (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-typedef signed char yytype_int8;
-#else
-typedef short int yytype_int8;
-#endif
-
-#ifdef YYTYPE_UINT16
-typedef YYTYPE_UINT16 yytype_uint16;
-#else
-typedef unsigned short int yytype_uint16;
-#endif
-
-#ifdef YYTYPE_INT16
-typedef YYTYPE_INT16 yytype_int16;
-#else
-typedef short int yytype_int16;
-#endif
-
-#ifndef YYSIZE_T
-# ifdef __SIZE_TYPE__
-# define YYSIZE_T __SIZE_TYPE__
-# elif defined size_t
-# define YYSIZE_T size_t
-# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
-# define YYSIZE_T size_t
-# else
-# define YYSIZE_T unsigned int
-# endif
-#endif
-
-#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
-
-#ifndef YY_
-# if YYENABLE_NLS
-# if ENABLE_NLS
-# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
-# define YY_(msgid) dgettext ("bison-runtime", msgid)
-# endif
-# endif
-# ifndef YY_
-# define YY_(msgid) msgid
-# endif
-#endif
-
-/* Suppress unused-variable warnings by "using" E. */
-#if ! defined lint || defined __GNUC__
-# define YYUSE(e) ((void) (e))
-#else
-# define YYUSE(e) /* empty */
-#endif
-
-/* Identity function, used to suppress warnings about constant conditions. */
-#ifndef lint
-# define YYID(n) (n)
-#else
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static int
-YYID (int yyi)
-#else
-static int
-YYID (yyi)
- int yyi;
-#endif
-{
- return yyi;
-}
-#endif
-
-#if ! defined yyoverflow || YYERROR_VERBOSE
-
-/* The parser invokes alloca or malloc; define the necessary symbols. */
-
-# ifdef YYSTACK_USE_ALLOCA
-# if YYSTACK_USE_ALLOCA
-# ifdef __GNUC__
-# define YYSTACK_ALLOC __builtin_alloca
-# elif defined __BUILTIN_VA_ARG_INCR
-# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
-# elif defined _AIX
-# define YYSTACK_ALLOC __alloca
-# elif defined _MSC_VER
-# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
-# define alloca _alloca
-# else
-# define YYSTACK_ALLOC alloca
-# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-# ifndef _STDLIB_H
-# define _STDLIB_H 1
-# endif
-# endif
-# endif
-# endif
-# endif
-
-# ifdef YYSTACK_ALLOC
- /* Pacify GCC's `empty if-body' warning. */
-# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
-# ifndef YYSTACK_ALLOC_MAXIMUM
- /* The OS might guarantee only one guard page at the bottom of the stack,
- and a page size can be as small as 4096 bytes. So we cannot safely
- invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
- to allow for a few compiler-allocated temporary stack slots. */
-# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
-# endif
-# else
-# define YYSTACK_ALLOC YYMALLOC
-# define YYSTACK_FREE YYFREE
-# ifndef YYSTACK_ALLOC_MAXIMUM
-# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
-# endif
-# if (defined __cplusplus && ! defined _STDLIB_H \
- && ! ((defined YYMALLOC || defined malloc) \
- && (defined YYFREE || defined free)))
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-# ifndef _STDLIB_H
-# define _STDLIB_H 1
-# endif
-# endif
-# ifndef YYMALLOC
-# define YYMALLOC malloc
-# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
-# endif
-# endif
-# ifndef YYFREE
-# define YYFREE free
-# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-void free (void *); /* INFRINGES ON USER NAME SPACE */
-# endif
-# endif
-# endif
-#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
-
-
-#if (! defined yyoverflow \
- && (! defined __cplusplus \
- || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
-
-/* A type that is properly aligned for any stack member. */
-union yyalloc
-{
- yytype_int16 yyss_alloc;
- YYSTYPE yyvs_alloc;
-};
-
-/* The size of the maximum gap between one aligned stack and the next. */
-# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
-
-/* The size of an array large to enough to hold all stacks, each with
- N elements. */
-# define YYSTACK_BYTES(N) \
- ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
- + YYSTACK_GAP_MAXIMUM)
-
-/* Copy COUNT objects from FROM to TO. The source and destination do
- not overlap. */
-# ifndef YYCOPY
-# if defined __GNUC__ && 1 < __GNUC__
-# define YYCOPY(To, From, Count) \
- __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
-# else
-# define YYCOPY(To, From, Count) \
- do \
- { \
- YYSIZE_T yyi; \
- for (yyi = 0; yyi < (Count); yyi++) \
- (To)[yyi] = (From)[yyi]; \
- } \
- while (YYID (0))
-# endif
-# endif
-
-/* Relocate STACK from its old location to the new one. The
- local variables YYSIZE and YYSTACKSIZE give the old and new number of
- elements in the stack, and YYPTR gives the new location of the
- stack. Advance YYPTR to a properly aligned location for the next
- stack. */
-# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
- do \
- { \
- YYSIZE_T yynewbytes; \
- YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
- Stack = &yyptr->Stack_alloc; \
- yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
- yyptr += yynewbytes / sizeof (*yyptr); \
- } \
- while (YYID (0))
-
-#endif
-
-/* YYFINAL -- State number of the termination state. */
-#define YYFINAL 2
-/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 92
-
-/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS 31
-/* YYNNTS -- Number of nonterminals. */
-#define YYNNTS 32
-/* YYNRULES -- Number of rules. */
-#define YYNRULES 63
-/* YYNRULES -- Number of states. */
-#define YYNSTATES 118
-
-/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
-#define YYUNDEFTOK 2
-#define YYMAXUTOK 285
-
-#define YYTRANSLATE(YYX) \
- ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
-
-/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
-static const yytype_uint8 yytranslate[] =
-{
- 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
- 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30
-};
-
-#if YYDEBUG
-/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
- YYRHS. */
-static const yytype_uint8 yyprhs[] =
-{
- 0, 0, 3, 4, 7, 9, 11, 12, 15, 17,
- 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
- 41, 45, 50, 54, 58, 62, 67, 73, 79, 84,
- 86, 89, 90, 98, 103, 105, 108, 109, 116, 118,
- 120, 122, 124, 126, 128, 130, 132, 134, 137, 140,
- 145, 147, 150, 151, 158, 159, 161, 163, 169, 171,
- 174, 175, 183, 186
-};
-
-/* YYRHS -- A `-1'-separated list of the rules' RHS. */
-static const yytype_int8 yyrhs[] =
-{
- 32, 0, -1, -1, 32, 33, -1, 3, -1, 35,
- -1, -1, 3, 34, -1, 39, -1, 40, -1, 43,
- -1, 47, -1, 54, -1, 59, -1, 37, -1, 38,
- -1, 62, -1, 36, -1, 61, -1, 28, 30, 3,
- -1, 20, 30, 3, -1, 18, 30, 56, 3, -1,
- 8, 30, 3, -1, 7, 30, 3, -1, 21, 3,
- 34, -1, 30, 25, 3, 34, -1, 30, 24, 30,
- 3, 34, -1, 30, 4, 30, 3, 34, -1, 30,
- 27, 3, 34, -1, 41, -1, 41, 42, -1, -1,
- 4, 30, 5, 44, 34, 42, 6, -1, 30, 30,
- 3, 34, -1, 45, -1, 45, 46, -1, -1, 9,
- 5, 48, 34, 46, 6, -1, 11, -1, 12, -1,
- 13, -1, 14, -1, 15, -1, 16, -1, 17, -1,
- 49, -1, 50, -1, 49, 50, -1, 50, 49, -1,
- 30, 51, 3, 34, -1, 52, -1, 52, 53, -1,
- -1, 10, 5, 55, 34, 53, 6, -1, -1, 22,
- -1, 23, -1, 30, 30, 56, 3, 34, -1, 57,
- -1, 57, 58, -1, -1, 19, 5, 3, 60, 34,
- 58, 6, -1, 29, 3, -1, 26, 30, 3, -1
-};
-
-/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
-static const yytype_uint8 yyrline[] =
-{
- 0, 108, 108, 109, 112, 113, 117, 118, 121, 122,
- 123, 124, 125, 126, 127, 128, 129, 130, 131, 134,
- 137, 140, 143, 146, 149, 150, 151, 152, 153, 156,
- 157, 160, 160, 163, 166, 167, 170, 170, 173, 174,
- 175, 176, 179, 180, 181, 184, 185, 186, 187, 190,
- 193, 194, 197, 197, 200, 201, 202, 205, 208, 209,
- 212, 212, 215, 218
-};
-#endif
-
-#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
-/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
- First, the terminals, then, starting at YYNTOKENS, nonterminals. */
-static const char *const yytname[] =
-{
- "$end", "error", "$undefined", "NEWLINE", "MENU", "LB", "RB",
- "ICONDIRECTORY", "DEFAULTICON", "ICONS", "STYLES", "TOPMOST", "MAXIMIZE",
- "MINIMIZE", "BOTTOM", "NOTITLE", "OUTLINE", "NOFRAME", "DEFAULTSYSMENU",
- "SYSMENU", "ROOTMENU", "SEPARATOR", "ATSTART", "ATEND", "EXEC",
- "ALWAYSONTOP", "DEBUG", "RELOAD", "TRAYICON", "SILENTEXIT", "STRING",
- "$accept", "input", "line", "newline_or_nada", "command", "trayicon",
- "rootmenu", "defaultsysmenu", "defaulticon", "icondirectory", "menuline",
- "menulist", "menu", "$@1", "iconline", "iconlist", "icons", "$@2",
- "group1", "group2", "stylecombo", "styleline", "stylelist", "styles",
- "$@3", "atspot", "sysmenuline", "sysmenulist", "sysmenu", "$@4",
- "silentexit", "debug", 0
-};
-#endif
-
-# ifdef YYPRINT
-/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
- token YYLEX-NUM. */
-static const yytype_uint16 yytoknum[] =
-{
- 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
- 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
- 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
- 285
-};
-# endif
-
-/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
-static const yytype_uint8 yyr1[] =
-{
- 0, 31, 32, 32, 33, 33, 34, 34, 35, 35,
- 35, 35, 35, 35, 35, 35, 35, 35, 35, 36,
- 37, 38, 39, 40, 41, 41, 41, 41, 41, 42,
- 42, 44, 43, 45, 46, 46, 48, 47, 49, 49,
- 49, 49, 50, 50, 50, 51, 51, 51, 51, 52,
- 53, 53, 55, 54, 56, 56, 56, 57, 58, 58,
- 60, 59, 61, 62
-};
-
-/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
-static const yytype_uint8 yyr2[] =
-{
- 0, 2, 0, 2, 1, 1, 0, 2, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
- 3, 4, 3, 3, 3, 4, 5, 5, 4, 1,
- 2, 0, 7, 4, 1, 2, 0, 6, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 2, 2, 4,
- 1, 2, 0, 6, 0, 1, 1, 5, 1, 2,
- 0, 7, 2, 3
-};
-
-/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
- STATE-NUM when YYTABLE doesn't specify something else to do. Zero
- means the default is an error. */
-static const yytype_uint8 yydefact[] =
-{
- 2, 0, 1, 4, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 3, 5, 17, 14, 15,
- 8, 9, 10, 11, 12, 13, 18, 16, 0, 0,
- 0, 36, 52, 54, 0, 0, 0, 0, 62, 31,
- 23, 22, 6, 6, 55, 56, 0, 60, 20, 63,
- 19, 6, 6, 0, 0, 21, 6, 0, 7, 0,
- 34, 0, 0, 50, 0, 0, 0, 0, 29, 0,
- 0, 35, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 0, 51, 53, 0, 58, 0, 6, 0,
- 0, 0, 0, 30, 32, 6, 47, 48, 6, 54,
- 59, 61, 24, 0, 0, 6, 6, 33, 49, 0,
- 6, 6, 25, 28, 6, 27, 26, 57
-};
-
-/* YYDEFGOTO[NTERM-NUM]. */
-static const yytype_int8 yydefgoto[] =
-{
- -1, 1, 15, 53, 16, 17, 18, 19, 20, 21,
- 68, 69, 22, 51, 60, 61, 23, 42, 80, 81,
- 82, 63, 64, 24, 43, 46, 86, 87, 25, 56,
- 26, 27
-};
-
-/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
- STATE-NUM. */
-#define YYPACT_NINF -44
-static const yytype_int8 yypact[] =
-{
- -44, 7, -44, -44, -28, -10, -7, 27, 29, 14,
- 41, 18, 19, 20, 44, -44, -44, -44, -44, -44,
- -44, -44, -44, -44, -44, -44, -44, -44, 46, 50,
- 51, -44, -44, -4, 53, 54, 55, 56, -44, -44,
- -44, -44, 57, 57, -44, -44, 58, -44, -44, -44,
- -44, 57, 57, 34, 35, -44, 57, -18, -44, 36,
- 34, 63, 26, 35, 64, 42, 70, -3, -18, 68,
- 72, -44, -44, -44, -44, -44, -44, -44, -44, -44,
- -11, 17, 73, -44, -44, 47, 42, 74, 57, 48,
- 49, 78, 79, -44, -44, 57, -44, -44, 57, -4,
- -44, -44, -44, 80, 81, 57, 57, -44, -44, 82,
- 57, 57, -44, -44, 57, -44, -44, -44
-};
-
-/* YYPGOTO[NTERM-NUM]. */
-static const yytype_int8 yypgoto[] =
-{
- -44, -44, -44, -43, -44, -44, -44, -44, -44, -44,
- -44, 21, -44, -44, -44, 28, -44, -44, 5, 10,
- -44, -44, 24, -44, -44, -8, -44, 6, -44, -44,
- -44, -44
-};
-
-/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
- positive, shift that token. If negative, reduce the rule which
- number is the opposite. If zero, do what YYDEFACT says.
- If YYTABLE_NINF, syntax error. */
-#define YYTABLE_NINF -1
-static const yytype_uint8 yytable[] =
-{
- 54, 89, 28, 66, 77, 78, 79, 2, 57, 58,
- 3, 4, 67, 65, 5, 6, 7, 8, 44, 45,
- 29, 90, 91, 30, 92, 9, 10, 11, 73, 74,
- 75, 76, 31, 12, 32, 13, 14, 73, 74, 75,
- 76, 77, 78, 79, 33, 102, 34, 38, 35, 36,
- 37, 39, 107, 40, 41, 108, 47, 48, 49, 50,
- 52, 55, 112, 113, 59, 62, 70, 115, 116, 72,
- 84, 117, 85, 88, 94, 95, 98, 99, 103, 104,
- 101, 105, 106, 110, 111, 114, 97, 83, 71, 93,
- 96, 109, 100
-};
-
-static const yytype_uint8 yycheck[] =
-{
- 43, 4, 30, 21, 15, 16, 17, 0, 51, 52,
- 3, 4, 30, 56, 7, 8, 9, 10, 22, 23,
- 30, 24, 25, 30, 27, 18, 19, 20, 11, 12,
- 13, 14, 5, 26, 5, 28, 29, 11, 12, 13,
- 14, 15, 16, 17, 30, 88, 5, 3, 30, 30,
- 30, 5, 95, 3, 3, 98, 3, 3, 3, 3,
- 3, 3, 105, 106, 30, 30, 30, 110, 111, 6,
- 6, 114, 30, 3, 6, 3, 3, 30, 30, 30,
- 6, 3, 3, 3, 3, 3, 81, 63, 60, 68,
- 80, 99, 86
-};
-
-/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
- symbol of state STATE-NUM. */
-static const yytype_uint8 yystos[] =
-{
- 0, 32, 0, 3, 4, 7, 8, 9, 10, 18,
- 19, 20, 26, 28, 29, 33, 35, 36, 37, 38,
- 39, 40, 43, 47, 54, 59, 61, 62, 30, 30,
- 30, 5, 5, 30, 5, 30, 30, 30, 3, 5,
- 3, 3, 48, 55, 22, 23, 56, 3, 3, 3,
- 3, 44, 3, 34, 34, 3, 60, 34, 34, 30,
- 45, 46, 30, 52, 53, 34, 21, 30, 41, 42,
- 30, 46, 6, 11, 12, 13, 14, 15, 16, 17,
- 49, 50, 51, 53, 6, 30, 57, 58, 3, 4,
- 24, 25, 27, 42, 6, 3, 50, 49, 3, 30,
- 58, 6, 34, 30, 30, 3, 3, 34, 34, 56,
- 3, 3, 34, 34, 3, 34, 34, 34
-};
-
-#define yyerrok (yyerrstatus = 0)
-#define yyclearin (yychar = YYEMPTY)
-#define YYEMPTY (-2)
-#define YYEOF 0
-
-#define YYACCEPT goto yyacceptlab
-#define YYABORT goto yyabortlab
-#define YYERROR goto yyerrorlab
-
-
-/* Like YYERROR except do call yyerror. This remains here temporarily
- to ease the transition to the new meaning of YYERROR, for GCC.
- Once GCC version 2 has supplanted version 1, this can go. */
-
-#define YYFAIL goto yyerrlab
-
-#define YYRECOVERING() (!!yyerrstatus)
-
-#define YYBACKUP(Token, Value) \
-do \
- if (yychar == YYEMPTY && yylen == 1) \
- { \
- yychar = (Token); \
- yylval = (Value); \
- yytoken = YYTRANSLATE (yychar); \
- YYPOPSTACK (1); \
- goto yybackup; \
- } \
- else \
- { \
- yyerror (YY_("syntax error: cannot back up")); \
- YYERROR; \
- } \
-while (YYID (0))
-
-
-#define YYTERROR 1
-#define YYERRCODE 256
-
-
-/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
- If N is 0, then set CURRENT to the empty location which ends
- the previous symbol: RHS[0] (always defined). */
-
-#define YYRHSLOC(Rhs, K) ((Rhs)[K])
-#ifndef YYLLOC_DEFAULT
-# define YYLLOC_DEFAULT(Current, Rhs, N) \
- do \
- if (YYID (N)) \
- { \
- (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
- (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
- (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
- (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
- } \
- else \
- { \
- (Current).first_line = (Current).last_line = \
- YYRHSLOC (Rhs, 0).last_line; \
- (Current).first_column = (Current).last_column = \
- YYRHSLOC (Rhs, 0).last_column; \
- } \
- while (YYID (0))
-#endif
-
-
-/* YY_LOCATION_PRINT -- Print the location on the stream.
- This macro was not mandated originally: define only if we know
- we won't break user code: when these are the locations we know. */
-
-#ifndef YY_LOCATION_PRINT
-# if YYLTYPE_IS_TRIVIAL
-# define YY_LOCATION_PRINT(File, Loc) \
- fprintf (File, "%d.%d-%d.%d", \
- (Loc).first_line, (Loc).first_column, \
- (Loc).last_line, (Loc).last_column)
-# else
-# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
-# endif
-#endif
-
-
-/* YYLEX -- calling `yylex' with the right arguments. */
-
-#ifdef YYLEX_PARAM
-# define YYLEX yylex (YYLEX_PARAM)
-#else
-# define YYLEX yylex ()
-#endif
-
-/* Enable debugging if requested. */
-#if YYDEBUG
-
-# ifndef YYFPRINTF
-# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
-# define YYFPRINTF fprintf
-# endif
-
-# define YYDPRINTF(Args) \
-do { \
- if (yydebug) \
- YYFPRINTF Args; \
-} while (YYID (0))
-
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
-do { \
- if (yydebug) \
- { \
- YYFPRINTF (stderr, "%s ", Title); \
- yy_symbol_print (stderr, \
- Type, Value); \
- YYFPRINTF (stderr, "\n"); \
- } \
-} while (YYID (0))
-
-
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
-
-/*ARGSUSED*/
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
-#else
-static void
-yy_symbol_value_print (yyoutput, yytype, yyvaluep)
- FILE *yyoutput;
- int yytype;
- YYSTYPE const * const yyvaluep;
-#endif
-{
- if (!yyvaluep)
- return;
-# ifdef YYPRINT
- if (yytype < YYNTOKENS)
- YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
-# else
- YYUSE (yyoutput);
-# endif
- switch (yytype)
- {
- default:
- break;
- }
-}
-
-
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
-
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
-#else
-static void
-yy_symbol_print (yyoutput, yytype, yyvaluep)
- FILE *yyoutput;
- int yytype;
- YYSTYPE const * const yyvaluep;
-#endif
-{
- if (yytype < YYNTOKENS)
- YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
- else
- YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
-
- yy_symbol_value_print (yyoutput, yytype, yyvaluep);
- YYFPRINTF (yyoutput, ")");
-}
-
-/*------------------------------------------------------------------.
-| yy_stack_print -- Print the state stack from its BOTTOM up to its |
-| TOP (included). |
-`------------------------------------------------------------------*/
-
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
-#else
-static void
-yy_stack_print (yybottom, yytop)
- yytype_int16 *yybottom;
- yytype_int16 *yytop;
-#endif
-{
- YYFPRINTF (stderr, "Stack now");
- for (; yybottom <= yytop; yybottom++)
- {
- int yybot = *yybottom;
- YYFPRINTF (stderr, " %d", yybot);
- }
- YYFPRINTF (stderr, "\n");
-}
-
-# define YY_STACK_PRINT(Bottom, Top) \
-do { \
- if (yydebug) \
- yy_stack_print ((Bottom), (Top)); \
-} while (YYID (0))
-
-
-/*------------------------------------------------.
-| Report that the YYRULE is going to be reduced. |
-`------------------------------------------------*/
-
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
-#else
-static void
-yy_reduce_print (yyvsp, yyrule)
- YYSTYPE *yyvsp;
- int yyrule;
-#endif
-{
- int yynrhs = yyr2[yyrule];
- int yyi;
- unsigned long int yylno = yyrline[yyrule];
- YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
- yyrule - 1, yylno);
- /* The symbols being reduced. */
- for (yyi = 0; yyi < yynrhs; yyi++)
- {
- YYFPRINTF (stderr, " $%d = ", yyi + 1);
- yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
- &(yyvsp[(yyi + 1) - (yynrhs)])
- );
- YYFPRINTF (stderr, "\n");
- }
-}
-
-# define YY_REDUCE_PRINT(Rule) \
-do { \
- if (yydebug) \
- yy_reduce_print (yyvsp, Rule); \
-} while (YYID (0))
-
-/* Nonzero means print parse trace. It is left uninitialized so that
- multiple parsers can coexist. */
-int yydebug;
-#else /* !YYDEBUG */
-# define YYDPRINTF(Args)
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
-# define YY_STACK_PRINT(Bottom, Top)
-# define YY_REDUCE_PRINT(Rule)
-#endif /* !YYDEBUG */
-
-
-/* YYINITDEPTH -- initial size of the parser's stacks. */
-#ifndef YYINITDEPTH
-# define YYINITDEPTH 200
-#endif
-
-/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
- if the built-in stack extension method is used).
-
- Do not make this value too large; the results are undefined if
- YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
- evaluated with infinite-precision integer arithmetic. */
-
-#ifndef YYMAXDEPTH
-# define YYMAXDEPTH 10000
-#endif
-
-
-
-#if YYERROR_VERBOSE
-
-# ifndef yystrlen
-# if defined __GLIBC__ && defined _STRING_H
-# define yystrlen strlen
-# else
-/* Return the length of YYSTR. */
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static YYSIZE_T
-yystrlen (const char *yystr)
-#else
-static YYSIZE_T
-yystrlen (yystr)
- const char *yystr;
-#endif
-{
- YYSIZE_T yylen;
- for (yylen = 0; yystr[yylen]; yylen++)
- continue;
- return yylen;
-}
-# endif
-# endif
-
-# ifndef yystpcpy
-# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
-# define yystpcpy stpcpy
-# else
-/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
- YYDEST. */
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static char *
-yystpcpy (char *yydest, const char *yysrc)
-#else
-static char *
-yystpcpy (yydest, yysrc)
- char *yydest;
- const char *yysrc;
-#endif
-{
- char *yyd = yydest;
- const char *yys = yysrc;
-
- while ((*yyd++ = *yys++) != '\0')
- continue;
-
- return yyd - 1;
-}
-# endif
-# endif
-
-# ifndef yytnamerr
-/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
- quotes and backslashes, so that it's suitable for yyerror. The
- heuristic is that double-quoting is unnecessary unless the string
- contains an apostrophe, a comma, or backslash (other than
- backslash-backslash). YYSTR is taken from yytname. If YYRES is
- null, do not copy; instead, return the length of what the result
- would have been. */
-static YYSIZE_T
-yytnamerr (char *yyres, const char *yystr)
-{
- if (*yystr == '"')
- {
- YYSIZE_T yyn = 0;
- char const *yyp = yystr;
-
- for (;;)
- switch (*++yyp)
- {
- case '\'':
- case ',':
- goto do_not_strip_quotes;
-
- case '\\':
- if (*++yyp != '\\')
- goto do_not_strip_quotes;
- /* Fall through. */
- default:
- if (yyres)
- yyres[yyn] = *yyp;
- yyn++;
- break;
-
- case '"':
- if (yyres)
- yyres[yyn] = '\0';
- return yyn;
- }
- do_not_strip_quotes: ;
- }
-
- if (! yyres)
- return yystrlen (yystr);
-
- return yystpcpy (yyres, yystr) - yyres;
-}
-# endif
-
-/* Copy into YYRESULT an error message about the unexpected token
- YYCHAR while in state YYSTATE. Return the number of bytes copied,
- including the terminating null byte. If YYRESULT is null, do not
- copy anything; just return the number of bytes that would be
- copied. As a special case, return 0 if an ordinary "syntax error"
- message will do. Return YYSIZE_MAXIMUM if overflow occurs during
- size calculation. */
-static YYSIZE_T
-yysyntax_error (char *yyresult, int yystate, int yychar)
-{
- int yyn = yypact[yystate];
-
- if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
- return 0;
- else
- {
- int yytype = YYTRANSLATE (yychar);
- YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
- YYSIZE_T yysize = yysize0;
- YYSIZE_T yysize1;
- int yysize_overflow = 0;
- enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
- char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
- int yyx;
-
-# if 0
- /* This is so xgettext sees the translatable formats that are
- constructed on the fly. */
- YY_("syntax error, unexpected %s");
- YY_("syntax error, unexpected %s, expecting %s");
- YY_("syntax error, unexpected %s, expecting %s or %s");
- YY_("syntax error, unexpected %s, expecting %s or %s or %s");
- YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
-# endif
- char *yyfmt;
- char const *yyf;
- static char const yyunexpected[] = "syntax error, unexpected %s";
- static char const yyexpecting[] = ", expecting %s";
- static char const yyor[] = " or %s";
- char yyformat[sizeof yyunexpected
- + sizeof yyexpecting - 1
- + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
- * (sizeof yyor - 1))];
- char const *yyprefix = yyexpecting;
-
- /* Start YYX at -YYN if negative to avoid negative indexes in
- YYCHECK. */
- int yyxbegin = yyn < 0 ? -yyn : 0;
-
- /* Stay within bounds of both yycheck and yytname. */
- int yychecklim = YYLAST - yyn + 1;
- int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
- int yycount = 1;
-
- yyarg[0] = yytname[yytype];
- yyfmt = yystpcpy (yyformat, yyunexpected);
-
- for (yyx = yyxbegin; yyx < yyxend; ++yyx)
- if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
- {
- if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
- {
- yycount = 1;
- yysize = yysize0;
- yyformat[sizeof yyunexpected - 1] = '\0';
- break;
- }
- yyarg[yycount++] = yytname[yyx];
- yysize1 = yysize + yytnamerr (0, yytname[yyx]);
- yysize_overflow |= (yysize1 < yysize);
- yysize = yysize1;
- yyfmt = yystpcpy (yyfmt, yyprefix);
- yyprefix = yyor;
- }
-
- yyf = YY_(yyformat);
- yysize1 = yysize + yystrlen (yyf);
- yysize_overflow |= (yysize1 < yysize);
- yysize = yysize1;
-
- if (yysize_overflow)
- return YYSIZE_MAXIMUM;
-
- if (yyresult)
- {
- /* Avoid sprintf, as that infringes on the user's name space.
- Don't have undefined behavior even if the translation
- produced a string with the wrong number of "%s"s. */
- char *yyp = yyresult;
- int yyi = 0;
- while ((*yyp = *yyf) != '\0')
- {
- if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
- {
- yyp += yytnamerr (yyp, yyarg[yyi++]);
- yyf += 2;
- }
- else
- {
- yyp++;
- yyf++;
- }
- }
- }
- return yysize;
- }
-}
-#endif /* YYERROR_VERBOSE */
-
-
-/*-----------------------------------------------.
-| Release the memory associated to this symbol. |
-`-----------------------------------------------*/
-
-/*ARGSUSED*/
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
-#else
-static void
-yydestruct (yymsg, yytype, yyvaluep)
- const char *yymsg;
- int yytype;
- YYSTYPE *yyvaluep;
-#endif
-{
- YYUSE (yyvaluep);
-
- if (!yymsg)
- yymsg = "Deleting";
- YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
-
- switch (yytype)
- {
-
- default:
- break;
- }
-}
-
-/* Prevent warnings from -Wmissing-prototypes. */
-#ifdef YYPARSE_PARAM
-#if defined __STDC__ || defined __cplusplus
-int yyparse (void *YYPARSE_PARAM);
-#else
-int yyparse ();
-#endif
-#else /* ! YYPARSE_PARAM */
-#if defined __STDC__ || defined __cplusplus
-int yyparse (void);
-#else
-int yyparse ();
-#endif
-#endif /* ! YYPARSE_PARAM */
-
-
-/* The lookahead symbol. */
-int yychar;
-
-/* The semantic value of the lookahead symbol. */
-YYSTYPE yylval;
-
-/* Number of syntax errors so far. */
-int yynerrs;
-
-
-
-/*-------------------------.
-| yyparse or yypush_parse. |
-`-------------------------*/
-
-#ifdef YYPARSE_PARAM
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-int
-yyparse (void *YYPARSE_PARAM)
-#else
-int
-yyparse (YYPARSE_PARAM)
- void *YYPARSE_PARAM;
-#endif
-#else /* ! YYPARSE_PARAM */
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-int
-yyparse (void)
-#else
-int
-yyparse ()
-
-#endif
-#endif
-{
-
-
- int yystate;
- /* Number of tokens to shift before error messages enabled. */
- int yyerrstatus;
-
- /* The stacks and their tools:
- `yyss': related to states.
- `yyvs': related to semantic values.
-
- Refer to the stacks thru separate pointers, to allow yyoverflow
- to reallocate them elsewhere. */
-
- /* The state stack. */
- yytype_int16 yyssa[YYINITDEPTH];
- yytype_int16 *yyss;
- yytype_int16 *yyssp;
-
- /* The semantic value stack. */
- YYSTYPE yyvsa[YYINITDEPTH];
- YYSTYPE *yyvs;
- YYSTYPE *yyvsp;
-
- YYSIZE_T yystacksize;
-
- int yyn;
- int yyresult;
- /* Lookahead token as an internal (translated) token number. */
- int yytoken;
- /* The variables used to return semantic value and location from the
- action routines. */
- YYSTYPE yyval;
-
-#if YYERROR_VERBOSE
- /* Buffer for error messages, and its allocated size. */
- char yymsgbuf[128];
- char *yymsg = yymsgbuf;
- YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
-#endif
-
-#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
-
- /* The number of symbols on the RHS of the reduced rule.
- Keep to zero when no symbol should be popped. */
- int yylen = 0;
-
- yytoken = 0;
- yyss = yyssa;
- yyvs = yyvsa;
- yystacksize = YYINITDEPTH;
-
- YYDPRINTF ((stderr, "Starting parse\n"));
-
- yystate = 0;
- yyerrstatus = 0;
- yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
-
- /* Initialize stack pointers.
- Waste one element of value and location stack
- so that they stay on the same level as the state stack.
- The wasted elements are never initialized. */
- yyssp = yyss;
- yyvsp = yyvs;
-
- goto yysetstate;
-
-/*------------------------------------------------------------.
-| yynewstate -- Push a new state, which is found in yystate. |
-`------------------------------------------------------------*/
- yynewstate:
- /* In all cases, when you get here, the value and location stacks
- have just been pushed. So pushing a state here evens the stacks. */
- yyssp++;
-
- yysetstate:
- *yyssp = yystate;
-
- if (yyss + yystacksize - 1 <= yyssp)
- {
- /* Get the current used size of the three stacks, in elements. */
- YYSIZE_T yysize = yyssp - yyss + 1;
-
-#ifdef yyoverflow
- {
- /* Give user a chance to reallocate the stack. Use copies of
- these so that the &'s don't force the real ones into
- memory. */
- YYSTYPE *yyvs1 = yyvs;
- yytype_int16 *yyss1 = yyss;
-
- /* Each stack pointer address is followed by the size of the
- data in use in that stack, in bytes. This used to be a
- conditional around just the two extra args, but that might
- be undefined if yyoverflow is a macro. */
- yyoverflow (YY_("memory exhausted"),
- &yyss1, yysize * sizeof (*yyssp),
- &yyvs1, yysize * sizeof (*yyvsp),
- &yystacksize);
-
- yyss = yyss1;
- yyvs = yyvs1;
- }
-#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
- goto yyexhaustedlab;
-# else
- /* Extend the stack our own way. */
- if (YYMAXDEPTH <= yystacksize)
- goto yyexhaustedlab;
- yystacksize *= 2;
- if (YYMAXDEPTH < yystacksize)
- yystacksize = YYMAXDEPTH;
-
- {
- yytype_int16 *yyss1 = yyss;
- union yyalloc *yyptr =
- (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
- if (! yyptr)
- goto yyexhaustedlab;
- YYSTACK_RELOCATE (yyss_alloc, yyss);
- YYSTACK_RELOCATE (yyvs_alloc, yyvs);
-# undef YYSTACK_RELOCATE
- if (yyss1 != yyssa)
- YYSTACK_FREE (yyss1);
- }
-# endif
-#endif /* no yyoverflow */
-
- yyssp = yyss + yysize - 1;
- yyvsp = yyvs + yysize - 1;
-
- YYDPRINTF ((stderr, "Stack size increased to %lu\n",
- (unsigned long int) yystacksize));
-
- if (yyss + yystacksize - 1 <= yyssp)
- YYABORT;
- }
-
- YYDPRINTF ((stderr, "Entering state %d\n", yystate));
-
- if (yystate == YYFINAL)
- YYACCEPT;
-
- goto yybackup;
-
-/*-----------.
-| yybackup. |
-`-----------*/
-yybackup:
-
- /* Do appropriate processing given the current state. Read a
- lookahead token if we need one and don't already have one. */
-
- /* First try to decide what to do without reference to lookahead token. */
- yyn = yypact[yystate];
- if (yyn == YYPACT_NINF)
- goto yydefault;
-
- /* Not known => get a lookahead token if don't already have one. */
-
- /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
- if (yychar == YYEMPTY)
- {
- YYDPRINTF ((stderr, "Reading a token: "));
- yychar = YYLEX;
- }
-
- if (yychar <= YYEOF)
- {
- yychar = yytoken = YYEOF;
- YYDPRINTF ((stderr, "Now at end of input.\n"));
- }
- else
- {
- yytoken = YYTRANSLATE (yychar);
- YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
- }
-
- /* If the proper action on seeing token YYTOKEN is to reduce or to
- detect an error, take that action. */
- yyn += yytoken;
- if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
- goto yydefault;
- yyn = yytable[yyn];
- if (yyn <= 0)
- {
- if (yyn == 0 || yyn == YYTABLE_NINF)
- goto yyerrlab;
- yyn = -yyn;
- goto yyreduce;
- }
-
- /* Count tokens shifted since error; after three, turn off error
- status. */
- if (yyerrstatus)
- yyerrstatus--;
-
- /* Shift the lookahead token. */
- YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
-
- /* Discard the shifted token. */
- yychar = YYEMPTY;
-
- yystate = yyn;
- *++yyvsp = yylval;
-
- goto yynewstate;
-
-
-/*-----------------------------------------------------------.
-| yydefault -- do the default action for the current state. |
-`-----------------------------------------------------------*/
-yydefault:
- yyn = yydefact[yystate];
- if (yyn == 0)
- goto yyerrlab;
- goto yyreduce;
-
-
-/*-----------------------------.
-| yyreduce -- Do a reduction. |
-`-----------------------------*/
-yyreduce:
- /* yyn is the number of a rule to reduce with. */
- yylen = yyr2[yyn];
-
- /* If YYLEN is nonzero, implement the default value of the action:
- `$$ = $1'.
-
- Otherwise, the following line sets YYVAL to garbage.
- This behavior is undocumented and Bison
- users should not rely upon it. Assigning to YYVAL
- unconditionally makes the parser a bit smaller, and it avoids a
- GCC warning that YYVAL may be used uninitialized. */
- yyval = yyvsp[1-yylen];
-
-
- YY_REDUCE_PRINT (yyn);
- switch (yyn)
- {
- case 19:
-
-/* Line 1455 of yacc.c */
-#line 134 "winprefsyacc.y"
- { SetTrayIcon((yyvsp[(2) - (3)].sVal)); free((yyvsp[(2) - (3)].sVal)); }
- break;
-
- case 20:
-
-/* Line 1455 of yacc.c */
-#line 137 "winprefsyacc.y"
- { SetRootMenu((yyvsp[(2) - (3)].sVal)); free((yyvsp[(2) - (3)].sVal)); }
- break;
-
- case 21:
-
-/* Line 1455 of yacc.c */
-#line 140 "winprefsyacc.y"
- { SetDefaultSysMenu((yyvsp[(2) - (4)].sVal), (yyvsp[(3) - (4)].iVal)); free((yyvsp[(2) - (4)].sVal)); }
- break;
-
- case 22:
-
-/* Line 1455 of yacc.c */
-#line 143 "winprefsyacc.y"
- { SetDefaultIcon((yyvsp[(2) - (3)].sVal)); free((yyvsp[(2) - (3)].sVal)); }
- break;
-
- case 23:
-
-/* Line 1455 of yacc.c */
-#line 146 "winprefsyacc.y"
- { SetIconDirectory((yyvsp[(2) - (3)].sVal)); free((yyvsp[(2) - (3)].sVal)); }
- break;
-
- case 24:
-
-/* Line 1455 of yacc.c */
-#line 149 "winprefsyacc.y"
- { AddMenuLine("-", CMD_SEPARATOR, ""); }
- break;
-
- case 25:
-
-/* Line 1455 of yacc.c */
-#line 150 "winprefsyacc.y"
- { AddMenuLine((yyvsp[(1) - (4)].sVal), CMD_ALWAYSONTOP, ""); free((yyvsp[(1) - (4)].sVal)); }
- break;
-
- case 26:
-
-/* Line 1455 of yacc.c */
-#line 151 "winprefsyacc.y"
- { AddMenuLine((yyvsp[(1) - (5)].sVal), CMD_EXEC, (yyvsp[(3) - (5)].sVal)); free((yyvsp[(1) - (5)].sVal)); free((yyvsp[(3) - (5)].sVal)); }
- break;
-
- case 27:
-
-/* Line 1455 of yacc.c */
-#line 152 "winprefsyacc.y"
- { AddMenuLine((yyvsp[(1) - (5)].sVal), CMD_MENU, (yyvsp[(3) - (5)].sVal)); free((yyvsp[(1) - (5)].sVal)); free((yyvsp[(3) - (5)].sVal)); }
- break;
-
- case 28:
-
-/* Line 1455 of yacc.c */
-#line 153 "winprefsyacc.y"
- { AddMenuLine((yyvsp[(1) - (4)].sVal), CMD_RELOAD, ""); free((yyvsp[(1) - (4)].sVal)); }
- break;
-
- case 31:
-
-/* Line 1455 of yacc.c */
-#line 160 "winprefsyacc.y"
- { OpenMenu((yyvsp[(2) - (3)].sVal)); free((yyvsp[(2) - (3)].sVal)); }
- break;
-
- case 32:
-
-/* Line 1455 of yacc.c */
-#line 160 "winprefsyacc.y"
- {CloseMenu();}
- break;
-
- case 33:
-
-/* Line 1455 of yacc.c */
-#line 163 "winprefsyacc.y"
- { AddIconLine((yyvsp[(1) - (4)].sVal), (yyvsp[(2) - (4)].sVal)); free((yyvsp[(1) - (4)].sVal)); free((yyvsp[(2) - (4)].sVal)); }
- break;
-
- case 36:
-
-/* Line 1455 of yacc.c */
-#line 170 "winprefsyacc.y"
- {OpenIcons();}
- break;
-
- case 37:
-
-/* Line 1455 of yacc.c */
-#line 170 "winprefsyacc.y"
- {CloseIcons();}
- break;
-
- case 38:
-
-/* Line 1455 of yacc.c */
-#line 173 "winprefsyacc.y"
- { (yyval.uVal)=STYLE_TOPMOST; }
- break;
-
- case 39:
-
-/* Line 1455 of yacc.c */
-#line 174 "winprefsyacc.y"
- { (yyval.uVal)=STYLE_MAXIMIZE; }
- break;
-
- case 40:
-
-/* Line 1455 of yacc.c */
-#line 175 "winprefsyacc.y"
- { (yyval.uVal)=STYLE_MINIMIZE; }
- break;
-
- case 41:
-
-/* Line 1455 of yacc.c */
-#line 176 "winprefsyacc.y"
- { (yyval.uVal)=STYLE_BOTTOM; }
- break;
-
- case 42:
-
-/* Line 1455 of yacc.c */
-#line 179 "winprefsyacc.y"
- { (yyval.uVal)=STYLE_NOTITLE; }
- break;
-
- case 43:
-
-/* Line 1455 of yacc.c */
-#line 180 "winprefsyacc.y"
- { (yyval.uVal)=STYLE_OUTLINE; }
- break;
-
- case 44:
-
-/* Line 1455 of yacc.c */
-#line 181 "winprefsyacc.y"
- { (yyval.uVal)=STYLE_NOFRAME; }
- break;
-
- case 45:
-
-/* Line 1455 of yacc.c */
-#line 184 "winprefsyacc.y"
- { (yyval.uVal)=(yyvsp[(1) - (1)].uVal); }
- break;
-
- case 46:
-
-/* Line 1455 of yacc.c */
-#line 185 "winprefsyacc.y"
- { (yyval.uVal)=(yyvsp[(1) - (1)].uVal); }
- break;
-
- case 47:
-
-/* Line 1455 of yacc.c */
-#line 186 "winprefsyacc.y"
- { (yyval.uVal)=(yyvsp[(1) - (2)].uVal)|(yyvsp[(2) - (2)].uVal); }
- break;
-
- case 48:
-
-/* Line 1455 of yacc.c */
-#line 187 "winprefsyacc.y"
- { (yyval.uVal)=(yyvsp[(1) - (2)].uVal)|(yyvsp[(2) - (2)].uVal); }
- break;
-
- case 49:
-
-/* Line 1455 of yacc.c */
-#line 190 "winprefsyacc.y"
- { AddStyleLine((yyvsp[(1) - (4)].sVal), (yyvsp[(2) - (4)].uVal)); free((yyvsp[(1) - (4)].sVal)); }
- break;
-
- case 52:
-
-/* Line 1455 of yacc.c */
-#line 197 "winprefsyacc.y"
- {OpenStyles();}
- break;
-
- case 53:
-
-/* Line 1455 of yacc.c */
-#line 197 "winprefsyacc.y"
- {CloseStyles();}
- break;
-
- case 54:
-
-/* Line 1455 of yacc.c */
-#line 200 "winprefsyacc.y"
- { (yyval.iVal)=AT_END; }
- break;
-
- case 55:
-
-/* Line 1455 of yacc.c */
-#line 201 "winprefsyacc.y"
- { (yyval.iVal)=AT_START; }
- break;
-
- case 56:
-
-/* Line 1455 of yacc.c */
-#line 202 "winprefsyacc.y"
- { (yyval.iVal)=AT_END; }
- break;
-
- case 57:
-
-/* Line 1455 of yacc.c */
-#line 205 "winprefsyacc.y"
- { AddSysMenuLine((yyvsp[(1) - (5)].sVal), (yyvsp[(2) - (5)].sVal), (yyvsp[(3) - (5)].iVal)); free((yyvsp[(1) - (5)].sVal)); free((yyvsp[(2) - (5)].sVal)); }
- break;
-
- case 60:
-
-/* Line 1455 of yacc.c */
-#line 212 "winprefsyacc.y"
- {OpenSysMenu();}
- break;
-
- case 61:
-
-/* Line 1455 of yacc.c */
-#line 212 "winprefsyacc.y"
- {CloseSysMenu();}
- break;
-
- case 62:
-
-/* Line 1455 of yacc.c */
-#line 215 "winprefsyacc.y"
- { pref.fSilentExit = TRUE; }
- break;
-
- case 63:
-
-/* Line 1455 of yacc.c */
-#line 218 "winprefsyacc.y"
- { ErrorF("LoadPreferences: %s\n", (yyvsp[(2) - (3)].sVal)); free((yyvsp[(2) - (3)].sVal)); }
- break;
-
-
-
-/* Line 1455 of yacc.c */
-#line 1828 "winprefsyacc.c"
- default: break;
- }
- YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
-
- YYPOPSTACK (yylen);
- yylen = 0;
- YY_STACK_PRINT (yyss, yyssp);
-
- *++yyvsp = yyval;
-
- /* Now `shift' the result of the reduction. Determine what state
- that goes to, based on the state we popped back to and the rule
- number reduced by. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
- if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTOKENS];
-
- goto yynewstate;
-
-
-/*------------------------------------.
-| yyerrlab -- here on detecting error |
-`------------------------------------*/
-yyerrlab:
- /* If not already recovering from an error, report this error. */
- if (!yyerrstatus)
- {
- ++yynerrs;
-#if ! YYERROR_VERBOSE
- yyerror (YY_("syntax error"));
-#else
- {
- YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
- if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
- {
- YYSIZE_T yyalloc = 2 * yysize;
- if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
- yyalloc = YYSTACK_ALLOC_MAXIMUM;
- if (yymsg != yymsgbuf)
- YYSTACK_FREE (yymsg);
- yymsg = (char *) YYSTACK_ALLOC (yyalloc);
- if (yymsg)
- yymsg_alloc = yyalloc;
- else
- {
- yymsg = yymsgbuf;
- yymsg_alloc = sizeof yymsgbuf;
- }
- }
-
- if (0 < yysize && yysize <= yymsg_alloc)
- {
- (void) yysyntax_error (yymsg, yystate, yychar);
- yyerror (yymsg);
- }
- else
- {
- yyerror (YY_("syntax error"));
- if (yysize != 0)
- goto yyexhaustedlab;
- }
- }
-#endif
- }
-
-
-
- if (yyerrstatus == 3)
- {
- /* If just tried and failed to reuse lookahead token after an
- error, discard it. */
-
- if (yychar <= YYEOF)
- {
- /* Return failure if at end of input. */
- if (yychar == YYEOF)
- YYABORT;
- }
- else
- {
- yydestruct ("Error: discarding",
- yytoken, &yylval);
- yychar = YYEMPTY;
- }
- }
-
- /* Else will try to reuse lookahead token after shifting the error
- token. */
- goto yyerrlab1;
-
-
-/*---------------------------------------------------.
-| yyerrorlab -- error raised explicitly by YYERROR. |
-`---------------------------------------------------*/
-yyerrorlab:
-
- /* Pacify compilers like GCC when the user code never invokes
- YYERROR and the label yyerrorlab therefore never appears in user
- code. */
- if (/*CONSTCOND*/ 0)
- goto yyerrorlab;
-
- /* Do not reclaim the symbols of the rule which action triggered
- this YYERROR. */
- YYPOPSTACK (yylen);
- yylen = 0;
- YY_STACK_PRINT (yyss, yyssp);
- yystate = *yyssp;
- goto yyerrlab1;
-
-
-/*-------------------------------------------------------------.
-| yyerrlab1 -- common code for both syntax error and YYERROR. |
-`-------------------------------------------------------------*/
-yyerrlab1:
- yyerrstatus = 3; /* Each real token shifted decrements this. */
-
- for (;;)
- {
- yyn = yypact[yystate];
- if (yyn != YYPACT_NINF)
- {
- yyn += YYTERROR;
- if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
- {
- yyn = yytable[yyn];
- if (0 < yyn)
- break;
- }
- }
-
- /* Pop the current state because it cannot handle the error token. */
- if (yyssp == yyss)
- YYABORT;
-
-
- yydestruct ("Error: popping",
- yystos[yystate], yyvsp);
- YYPOPSTACK (1);
- yystate = *yyssp;
- YY_STACK_PRINT (yyss, yyssp);
- }
-
- *++yyvsp = yylval;
-
-
- /* Shift the error token. */
- YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
-
- yystate = yyn;
- goto yynewstate;
-
-
-/*-------------------------------------.
-| yyacceptlab -- YYACCEPT comes here. |
-`-------------------------------------*/
-yyacceptlab:
- yyresult = 0;
- goto yyreturn;
-
-/*-----------------------------------.
-| yyabortlab -- YYABORT comes here. |
-`-----------------------------------*/
-yyabortlab:
- yyresult = 1;
- goto yyreturn;
-
-#if !defined(yyoverflow) || YYERROR_VERBOSE
-/*-------------------------------------------------.
-| yyexhaustedlab -- memory exhaustion comes here. |
-`-------------------------------------------------*/
-yyexhaustedlab:
- yyerror (YY_("memory exhausted"));
- yyresult = 2;
- /* Fall through. */
-#endif
-
-yyreturn:
- if (yychar != YYEMPTY)
- yydestruct ("Cleanup: discarding lookahead",
- yytoken, &yylval);
- /* Do not reclaim the symbols of the rule which action triggered
- this YYABORT or YYACCEPT. */
- YYPOPSTACK (yylen);
- YY_STACK_PRINT (yyss, yyssp);
- while (yyssp != yyss)
- {
- yydestruct ("Cleanup: popping",
- yystos[*yyssp], yyvsp);
- YYPOPSTACK (1);
- }
-#ifndef yyoverflow
- if (yyss != yyssa)
- YYSTACK_FREE (yyss);
-#endif
-#if YYERROR_VERBOSE
- if (yymsg != yymsgbuf)
- YYSTACK_FREE (yymsg);
-#endif
- /* Make sure YYID is used. */
- return YYID (yyresult);
-}
-
-
-
-/* Line 1675 of yacc.c */
-#line 222 "winprefsyacc.y"
-
-/*
- * Errors in parsing abort and print log messages
- */
-static int
-yyerror (char *s)
-{
- extern int yylineno; /* Handled by flex internally */
-
- ErrorF("LoadPreferences: %s line %d\n", s, yylineno);
- return 1;
-}
-
-/* Miscellaneous functions to store TOKENs into the structure */
-static void
-SetIconDirectory (char *path)
-{
- strncpy (pref.iconDirectory, path, PATH_MAX);
- pref.iconDirectory[PATH_MAX] = 0;
-}
-
-static void
-SetDefaultIcon (char *fname)
-{
- strncpy (pref.defaultIconName, fname, NAME_MAX);
- pref.defaultIconName[NAME_MAX] = 0;
-}
-
-static void
-SetTrayIcon (char *fname)
-{
- strncpy (pref.trayIconName, fname, NAME_MAX);
- pref.trayIconName[NAME_MAX] = 0;
-}
-
-static void
-SetRootMenu (char *menu)
-{
- strncpy (pref.rootMenuName, menu, MENU_MAX);
- pref.rootMenuName[MENU_MAX] = 0;
-}
-
-static void
-SetDefaultSysMenu (char *menu, int pos)
-{
- strncpy (pref.defaultSysMenuName, menu, MENU_MAX);
- pref.defaultSysMenuName[MENU_MAX] = 0;
- pref.defaultSysMenuPos = pos;
-}
-
-static void
-OpenMenu (char *menuname)
-{
- if (menu.menuItem) free(menu.menuItem);
- menu.menuItem = NULL;
- strncpy(menu.menuName, menuname, MENU_MAX);
- menu.menuName[MENU_MAX] = 0;
- menu.menuItems = 0;
-}
-
-static void
-AddMenuLine (char *text, MENUCOMMANDTYPE cmd, char *param)
-{
- if (menu.menuItem==NULL)
- menu.menuItem = (MENUITEM*)malloc(sizeof(MENUITEM));
- else
- menu.menuItem = (MENUITEM*)
- realloc(menu.menuItem, sizeof(MENUITEM)*(menu.menuItems+1));
-
- strncpy (menu.menuItem[menu.menuItems].text, text, MENU_MAX);
- menu.menuItem[menu.menuItems].text[MENU_MAX] = 0;
-
- menu.menuItem[menu.menuItems].cmd = cmd;
-
- strncpy(menu.menuItem[menu.menuItems].param, param, PARAM_MAX);
- menu.menuItem[menu.menuItems].param[PARAM_MAX] = 0;
-
- menu.menuItem[menu.menuItems].commandID = 0;
-
- menu.menuItems++;
-}
-
-static void
-CloseMenu (void)
-{
- if (menu.menuItem==NULL || menu.menuItems==0)
- {
- ErrorF("LoadPreferences: Empty menu detected\n");
- return;
- }
-
- if (pref.menuItems)
- pref.menu = (MENUPARSED*)
- realloc (pref.menu, (pref.menuItems+1)*sizeof(MENUPARSED));
- else
- pref.menu = (MENUPARSED*)malloc (sizeof(MENUPARSED));
-
- memcpy (pref.menu+pref.menuItems, &menu, sizeof(MENUPARSED));
- pref.menuItems++;
-
- memset (&menu, 0, sizeof(MENUPARSED));
-}
-
-static void
-OpenIcons (void)
-{
- if (pref.icon != NULL) {
- ErrorF("LoadPreferences: Redefining icon mappings\n");
- free(pref.icon);
- pref.icon = NULL;
- }
- pref.iconItems = 0;
-}
-
-static void
-AddIconLine (char *matchstr, char *iconfile)
-{
- if (pref.icon==NULL)
- pref.icon = (ICONITEM*)malloc(sizeof(ICONITEM));
- else
- pref.icon = (ICONITEM*)
- realloc(pref.icon, sizeof(ICONITEM)*(pref.iconItems+1));
-
- strncpy(pref.icon[pref.iconItems].match, matchstr, MENU_MAX);
- pref.icon[pref.iconItems].match[MENU_MAX] = 0;
-
- strncpy(pref.icon[pref.iconItems].iconFile, iconfile, PATH_MAX+NAME_MAX+1);
- pref.icon[pref.iconItems].iconFile[PATH_MAX+NAME_MAX+1] = 0;
-
- pref.icon[pref.iconItems].hicon = 0;
-
- pref.iconItems++;
-}
-
-static void
-CloseIcons (void)
-{
-}
-
-static void
-OpenStyles (void)
-{
- if (pref.style != NULL) {
- ErrorF("LoadPreferences: Redefining window style\n");
- free(pref.style);
- pref.style = NULL;
- }
- pref.styleItems = 0;
-}
-
-static void
-AddStyleLine (char *matchstr, unsigned long style)
-{
- if (pref.style==NULL)
- pref.style = (STYLEITEM*)malloc(sizeof(STYLEITEM));
- else
- pref.style = (STYLEITEM*)
- realloc(pref.style, sizeof(STYLEITEM)*(pref.styleItems+1));
-
- strncpy(pref.style[pref.styleItems].match, matchstr, MENU_MAX);
- pref.style[pref.styleItems].match[MENU_MAX] = 0;
-
- pref.style[pref.styleItems].type = style;
-
- pref.styleItems++;
-}
-
-static void
-CloseStyles (void)
-{
-}
-
-static void
-OpenSysMenu (void)
-{
- if (pref.sysMenu != NULL) {
- ErrorF("LoadPreferences: Redefining system menu\n");
- free(pref.sysMenu);
- pref.sysMenu = NULL;
- }
- pref.sysMenuItems = 0;
-}
-
-static void
-AddSysMenuLine (char *matchstr, char *menuname, int pos)
-{
- if (pref.sysMenu==NULL)
- pref.sysMenu = (SYSMENUITEM*)malloc(sizeof(SYSMENUITEM));
- else
- pref.sysMenu = (SYSMENUITEM*)
- realloc(pref.sysMenu, sizeof(SYSMENUITEM)*(pref.sysMenuItems+1));
-
- strncpy (pref.sysMenu[pref.sysMenuItems].match, matchstr, MENU_MAX);
- pref.sysMenu[pref.sysMenuItems].match[MENU_MAX] = 0;
-
- strncpy (pref.sysMenu[pref.sysMenuItems].menuName, menuname, MENU_MAX);
- pref.sysMenu[pref.sysMenuItems].menuName[MENU_MAX] = 0;
-
- pref.sysMenu[pref.sysMenuItems].menuPos = pos;
-
- pref.sysMenuItems++;
-}
-
-static void
-CloseSysMenu (void)
-{
-}
-
-
diff --git a/xorg-server/hw/xwin/winprefsyacc.h b/xorg-server/hw/xwin/winprefsyacc.h
deleted file mode 100644
index a9e5d0c2b..000000000
--- a/xorg-server/hw/xwin/winprefsyacc.h
+++ /dev/null
@@ -1,128 +0,0 @@
-
-/* A Bison parser, made by GNU Bison 2.4.1. */
-
-/* Skeleton interface for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
- Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* As a special exception, you may create a larger work that contains
- part or all of the Bison parser skeleton and distribute that work
- under terms of your choice, so long as that work isn't itself a
- parser generator using the skeleton or a modified version thereof
- as a parser skeleton. Alternatively, if you modify or redistribute
- the parser skeleton itself, you may (at your option) remove this
- special exception, which will cause the skeleton and the resulting
- Bison output files to be licensed under the GNU General Public
- License without this special exception.
-
- This special exception was added by the Free Software Foundation in
- version 2.2 of Bison. */
-
-
-/* Tokens. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- /* Put the tokens into the symbol table, so that GDB and other debuggers
- know about them. */
- enum yytokentype {
- NEWLINE = 258,
- MENU = 259,
- LB = 260,
- RB = 261,
- ICONDIRECTORY = 262,
- DEFAULTICON = 263,
- ICONS = 264,
- STYLES = 265,
- TOPMOST = 266,
- MAXIMIZE = 267,
- MINIMIZE = 268,
- BOTTOM = 269,
- NOTITLE = 270,
- OUTLINE = 271,
- NOFRAME = 272,
- DEFAULTSYSMENU = 273,
- SYSMENU = 274,
- ROOTMENU = 275,
- SEPARATOR = 276,
- ATSTART = 277,
- ATEND = 278,
- EXEC = 279,
- ALWAYSONTOP = 280,
- DEBUG = 281,
- RELOAD = 282,
- TRAYICON = 283,
- SILENTEXIT = 284,
- STRING = 285
- };
-#endif
-/* Tokens. */
-#define NEWLINE 258
-#define MENU 259
-#define LB 260
-#define RB 261
-#define ICONDIRECTORY 262
-#define DEFAULTICON 263
-#define ICONS 264
-#define STYLES 265
-#define TOPMOST 266
-#define MAXIMIZE 267
-#define MINIMIZE 268
-#define BOTTOM 269
-#define NOTITLE 270
-#define OUTLINE 271
-#define NOFRAME 272
-#define DEFAULTSYSMENU 273
-#define SYSMENU 274
-#define ROOTMENU 275
-#define SEPARATOR 276
-#define ATSTART 277
-#define ATEND 278
-#define EXEC 279
-#define ALWAYSONTOP 280
-#define DEBUG 281
-#define RELOAD 282
-#define TRAYICON 283
-#define SILENTEXIT 284
-#define STRING 285
-
-
-
-
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef union YYSTYPE
-{
-
-/* Line 1676 of yacc.c */
-#line 89 "winprefsyacc.y"
-
- char *sVal;
- unsigned long uVal;
- int iVal;
-
-
-
-/* Line 1676 of yacc.c */
-#line 120 "winprefsyacc.h"
-} YYSTYPE;
-# define YYSTYPE_IS_TRIVIAL 1
-# define yystype YYSTYPE /* obsolescent; will be withdrawn */
-# define YYSTYPE_IS_DECLARED 1
-#endif
-
-extern YYSTYPE yylval;
-
-
diff --git a/xorg-server/hw/xwin/winprefsyacc.y b/xorg-server/hw/xwin/winprefsyacc.y
index 73f165915..653a4ab25 100644
--- a/xorg-server/hw/xwin/winprefsyacc.y
+++ b/xorg-server/hw/xwin/winprefsyacc.y
@@ -1,457 +1,460 @@
-%{
-/*
- * Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- * Copyright (C) Colin Harrison 2005-2008
- *
- * 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, 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 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 XFREE86 PROJECT 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 XFree86 Project
- * 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 XFree86 Project.
- *
- * Authors: Earle F. Philhower, III
- * Colin Harrison
- */
-/* $XFree86: $ */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "winprefs.h"
-
-/* The following give better error messages in bison at the cost of a few KB */
-#define YYERROR_VERBOSE 1
-
-/* YYLTYPE_IS_TRIVIAL and YYENABLE_NLS defined to suppress warnings */
-#define YYLTYPE_IS_TRIVIAL 1
-#define YYENABLE_NLS 0
-
-/* The global pref settings */
-WINPREFS pref;
-
-/* The working menu */
-static MENUPARSED menu;
-
-/* Functions for parsing the tokens into out structure */
-/* Defined at the end section of this file */
-
-static void SetIconDirectory (char *path);
-static void SetDefaultIcon (char *fname);
-static void SetRootMenu (char *menu);
-static void SetDefaultSysMenu (char *menu, int pos);
-static void SetTrayIcon (char *fname);
-
-static void OpenMenu(char *menuname);
-static void AddMenuLine(char *name, MENUCOMMANDTYPE cmd, char *param);
-static void CloseMenu(void);
-
-static void OpenIcons(void);
-static void AddIconLine(char *matchstr, char *iconfile);
-static void CloseIcons(void);
-
-static void OpenStyles(void);
-static void AddStyleLine(char *matchstr, unsigned long style);
-static void CloseStyles(void);
-
-static void OpenSysMenu(void);
-static void AddSysMenuLine(char *matchstr, char *menuname, int pos);
-static void CloseSysMenu(void);
-
-static int yyerror (char *s);
-
-extern void ErrorF (const char* /*f*/, ...);
-extern char *yytext;
-extern int yylex(void);
-
-%}
-
-%union {
- char *sVal;
- unsigned long uVal;
- int iVal;
-}
-
-%token NEWLINE
-%token MENU
-%token LB
-%token RB
-%token ICONDIRECTORY
-%token DEFAULTICON
-%token ICONS
-%token STYLES
-%token TOPMOST
-%token MAXIMIZE
-%token MINIMIZE
-%token BOTTOM
-%token NOTITLE
-%token OUTLINE
-%token NOFRAME
-%token DEFAULTSYSMENU
-%token SYSMENU
-%token ROOTMENU
-%token SEPARATOR
-%token ATSTART
-%token ATEND
-%token EXEC
-%token ALWAYSONTOP
-%token DEBUG
-%token RELOAD
-%token TRAYICON
-%token FORCEEXIT
-%token SILENTEXIT
-
-%token <sVal> STRING
-%type <uVal> group1
-%type <uVal> group2
-%type <uVal> stylecombo
-%type <iVal> atspot
-
-%%
-
-input: /* empty */
- | input line
- ;
-
-line: NEWLINE
- | command
- ;
-
-
-newline_or_nada:
- | NEWLINE newline_or_nada
- ;
-
-command: defaulticon
- | icondirectory
- | menu
- | icons
- | styles
- | sysmenu
- | rootmenu
- | defaultsysmenu
- | debug
- | trayicon
- | forceexit
- | silentexit
- ;
-
-trayicon: TRAYICON STRING NEWLINE { SetTrayIcon($2); free($2); }
- ;
-
-rootmenu: ROOTMENU STRING NEWLINE { SetRootMenu($2); free($2); }
- ;
-
-defaultsysmenu: DEFAULTSYSMENU STRING atspot NEWLINE { SetDefaultSysMenu($2, $3); free($2); }
- ;
-
-defaulticon: DEFAULTICON STRING NEWLINE { SetDefaultIcon($2); free($2); }
- ;
-
-icondirectory: ICONDIRECTORY STRING NEWLINE { SetIconDirectory($2); free($2); }
- ;
-
-menuline: SEPARATOR NEWLINE newline_or_nada { AddMenuLine("-", CMD_SEPARATOR, ""); }
- | STRING ALWAYSONTOP NEWLINE newline_or_nada { AddMenuLine($1, CMD_ALWAYSONTOP, ""); free($1); }
- | STRING EXEC STRING NEWLINE newline_or_nada { AddMenuLine($1, CMD_EXEC, $3); free($1); free($3); }
- | STRING MENU STRING NEWLINE newline_or_nada { AddMenuLine($1, CMD_MENU, $3); free($1); free($3); }
- | STRING RELOAD NEWLINE newline_or_nada { AddMenuLine($1, CMD_RELOAD, ""); free($1); }
- ;
-
-menulist: menuline
- | menuline menulist
- ;
-
-menu: MENU STRING LB { OpenMenu($2); free($2); } newline_or_nada menulist RB {CloseMenu();}
- ;
-
-iconline: STRING STRING NEWLINE newline_or_nada { AddIconLine($1, $2); free($1); free($2); }
- ;
-
-iconlist: iconline
- | iconline iconlist
- ;
-
-icons: ICONS LB {OpenIcons();} newline_or_nada iconlist RB {CloseIcons();}
- ;
-
-group1: TOPMOST { $$=STYLE_TOPMOST; }
- | MAXIMIZE { $$=STYLE_MAXIMIZE; }
- | MINIMIZE { $$=STYLE_MINIMIZE; }
- | BOTTOM { $$=STYLE_BOTTOM; }
- ;
-
-group2: NOTITLE { $$=STYLE_NOTITLE; }
- | OUTLINE { $$=STYLE_OUTLINE; }
- | NOFRAME { $$=STYLE_NOFRAME; }
- ;
-
-stylecombo: group1 { $$=$1; }
- | group2 { $$=$1; }
- | group1 group2 { $$=$1|$2; }
- | group2 group1 { $$=$1|$2; }
- ;
-
-styleline: STRING stylecombo NEWLINE newline_or_nada { AddStyleLine($1, $2); free($1); }
- ;
-
-stylelist: styleline
- | styleline stylelist
- ;
-
-styles: STYLES LB {OpenStyles();} newline_or_nada stylelist RB {CloseStyles();}
- ;
-
-atspot: { $$=AT_END; }
- | ATSTART { $$=AT_START; }
- | ATEND { $$=AT_END; }
- ;
-
-sysmenuline: STRING STRING atspot NEWLINE newline_or_nada { AddSysMenuLine($1, $2, $3); free($1); free($2); }
- ;
-
-sysmenulist: sysmenuline
- | sysmenuline sysmenulist
- ;
-
-sysmenu: SYSMENU LB NEWLINE {OpenSysMenu();} newline_or_nada sysmenulist RB {CloseSysMenu();}
- ;
-
-forceexit: FORCEEXIT NEWLINE { pref.fForceExit = TRUE; }
- ;
-
-silentexit: SILENTEXIT NEWLINE { pref.fSilentExit = TRUE; }
- ;
-
-debug: DEBUG STRING NEWLINE { ErrorF("LoadPreferences: %s\n", $2); free($2); }
- ;
-
-
-%%
-/*
- * Errors in parsing abort and print log messages
- */
-static int
-yyerror (char *s)
-{
- extern int yylineno; /* Handled by flex internally */
-
- ErrorF("LoadPreferences: %s line %d\n", s, yylineno);
- return 1;
-}
-
-/* Miscellaneous functions to store TOKENs into the structure */
-static void
-SetIconDirectory (char *path)
-{
- strncpy (pref.iconDirectory, path, PATH_MAX);
- pref.iconDirectory[PATH_MAX] = 0;
-}
-
-static void
-SetDefaultIcon (char *fname)
-{
- strncpy (pref.defaultIconName, fname, NAME_MAX);
- pref.defaultIconName[NAME_MAX] = 0;
-}
-
-static void
-SetTrayIcon (char *fname)
-{
- strncpy (pref.trayIconName, fname, NAME_MAX);
- pref.trayIconName[NAME_MAX] = 0;
-}
-
-static void
-SetRootMenu (char *menu)
-{
- strncpy (pref.rootMenuName, menu, MENU_MAX);
- pref.rootMenuName[MENU_MAX] = 0;
-}
-
-static void
-SetDefaultSysMenu (char *menu, int pos)
-{
- strncpy (pref.defaultSysMenuName, menu, MENU_MAX);
- pref.defaultSysMenuName[MENU_MAX] = 0;
- pref.defaultSysMenuPos = pos;
-}
-
-static void
-OpenMenu (char *menuname)
-{
- if (menu.menuItem) free(menu.menuItem);
- menu.menuItem = NULL;
- strncpy(menu.menuName, menuname, MENU_MAX);
- menu.menuName[MENU_MAX] = 0;
- menu.menuItems = 0;
-}
-
-static void
-AddMenuLine (char *text, MENUCOMMANDTYPE cmd, char *param)
-{
- if (menu.menuItem==NULL)
- menu.menuItem = (MENUITEM*)malloc(sizeof(MENUITEM));
- else
- menu.menuItem = (MENUITEM*)
- realloc(menu.menuItem, sizeof(MENUITEM)*(menu.menuItems+1));
-
- strncpy (menu.menuItem[menu.menuItems].text, text, MENU_MAX);
- menu.menuItem[menu.menuItems].text[MENU_MAX] = 0;
-
- menu.menuItem[menu.menuItems].cmd = cmd;
-
- strncpy(menu.menuItem[menu.menuItems].param, param, PARAM_MAX);
- menu.menuItem[menu.menuItems].param[PARAM_MAX] = 0;
-
- menu.menuItem[menu.menuItems].commandID = 0;
-
- menu.menuItems++;
-}
-
-static void
-CloseMenu (void)
-{
- if (menu.menuItem==NULL || menu.menuItems==0)
- {
- ErrorF("LoadPreferences: Empty menu detected\n");
- return;
- }
-
- if (pref.menuItems)
- pref.menu = (MENUPARSED*)
- realloc (pref.menu, (pref.menuItems+1)*sizeof(MENUPARSED));
- else
- pref.menu = (MENUPARSED*)malloc (sizeof(MENUPARSED));
-
- memcpy (pref.menu+pref.menuItems, &menu, sizeof(MENUPARSED));
- pref.menuItems++;
-
- memset (&menu, 0, sizeof(MENUPARSED));
-}
-
-static void
-OpenIcons (void)
-{
- if (pref.icon != NULL) {
- ErrorF("LoadPreferences: Redefining icon mappings\n");
- free(pref.icon);
- pref.icon = NULL;
- }
- pref.iconItems = 0;
-}
-
-static void
-AddIconLine (char *matchstr, char *iconfile)
-{
- if (pref.icon==NULL)
- pref.icon = (ICONITEM*)malloc(sizeof(ICONITEM));
- else
- pref.icon = (ICONITEM*)
- realloc(pref.icon, sizeof(ICONITEM)*(pref.iconItems+1));
-
- strncpy(pref.icon[pref.iconItems].match, matchstr, MENU_MAX);
- pref.icon[pref.iconItems].match[MENU_MAX] = 0;
-
- strncpy(pref.icon[pref.iconItems].iconFile, iconfile, PATH_MAX+NAME_MAX+1);
- pref.icon[pref.iconItems].iconFile[PATH_MAX+NAME_MAX+1] = 0;
-
- pref.icon[pref.iconItems].hicon = 0;
-
- pref.iconItems++;
-}
-
-static void
-CloseIcons (void)
-{
-}
-
-static void
-OpenStyles (void)
-{
- if (pref.style != NULL) {
- ErrorF("LoadPreferences: Redefining window style\n");
- free(pref.style);
- pref.style = NULL;
- }
- pref.styleItems = 0;
-}
-
-static void
-AddStyleLine (char *matchstr, unsigned long style)
-{
- if (pref.style==NULL)
- pref.style = (STYLEITEM*)malloc(sizeof(STYLEITEM));
- else
- pref.style = (STYLEITEM*)
- realloc(pref.style, sizeof(STYLEITEM)*(pref.styleItems+1));
-
- strncpy(pref.style[pref.styleItems].match, matchstr, MENU_MAX);
- pref.style[pref.styleItems].match[MENU_MAX] = 0;
-
- pref.style[pref.styleItems].type = style;
-
- pref.styleItems++;
-}
-
-static void
-CloseStyles (void)
-{
-}
-
-static void
-OpenSysMenu (void)
-{
- if (pref.sysMenu != NULL) {
- ErrorF("LoadPreferences: Redefining system menu\n");
- free(pref.sysMenu);
- pref.sysMenu = NULL;
- }
- pref.sysMenuItems = 0;
-}
-
-static void
-AddSysMenuLine (char *matchstr, char *menuname, int pos)
-{
- if (pref.sysMenu==NULL)
- pref.sysMenu = (SYSMENUITEM*)malloc(sizeof(SYSMENUITEM));
- else
- pref.sysMenu = (SYSMENUITEM*)
- realloc(pref.sysMenu, sizeof(SYSMENUITEM)*(pref.sysMenuItems+1));
-
- strncpy (pref.sysMenu[pref.sysMenuItems].match, matchstr, MENU_MAX);
- pref.sysMenu[pref.sysMenuItems].match[MENU_MAX] = 0;
-
- strncpy (pref.sysMenu[pref.sysMenuItems].menuName, menuname, MENU_MAX);
- pref.sysMenu[pref.sysMenuItems].menuName[MENU_MAX] = 0;
-
- pref.sysMenu[pref.sysMenuItems].menuPos = pos;
-
- pref.sysMenuItems++;
-}
-
-static void
-CloseSysMenu (void)
-{
-}
-
+%{
+/*
+ * Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ * Copyright (C) Colin Harrison 2005-2008
+ *
+ * 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, 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 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 XFREE86 PROJECT 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 XFree86 Project
+ * 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 XFree86 Project.
+ *
+ * Authors: Earle F. Philhower, III
+ * Colin Harrison
+ */
+/* $XFree86: $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "winprefs.h"
+#include "winmsg.h"
+
+/* The following give better error messages in bison at the cost of a few KB */
+#define YYERROR_VERBOSE 1
+
+/* YYLTYPE_IS_TRIVIAL and YYENABLE_NLS defined to suppress warnings */
+#define YYLTYPE_IS_TRIVIAL 1
+#define YYENABLE_NLS 0
+
+/* The global pref settings */
+WINPREFS pref;
+
+/* The working menu */
+static MENUPARSED menu;
+
+/* Functions for parsing the tokens into out structure */
+/* Defined at the end section of this file */
+
+static void SetIconDirectory (char *path);
+static void SetDefaultIcon (char *fname);
+static void SetRootMenu (char *menu);
+static void SetDefaultSysMenu (char *menu, int pos);
+static void SetTrayIcon (char *fname);
+
+static void OpenMenu(char *menuname);
+static void AddMenuLine(char *name, MENUCOMMANDTYPE cmd, char *param);
+static void CloseMenu(void);
+
+static void OpenIcons(void);
+static void AddIconLine(char *matchstr, char *iconfile);
+static void CloseIcons(void);
+
+static void OpenStyles(void);
+static void AddStyleLine(char *matchstr, unsigned long style);
+static void CloseStyles(void);
+
+static void OpenSysMenu(void);
+static void AddSysMenuLine(char *matchstr, char *menuname, int pos);
+static void CloseSysMenu(void);
+
+static int yyerror (char *s);
+
+extern char *yytext;
+extern int yylex(void);
+
+#define YYMALLOC malloc
+#define YYFREE free
+
+%}
+
+%union {
+ char *sVal;
+ unsigned long uVal;
+ int iVal;
+}
+
+%token NEWLINE
+%token MENU
+%token LB
+%token RB
+%token ICONDIRECTORY
+%token DEFAULTICON
+%token ICONS
+%token STYLES
+%token TOPMOST
+%token MAXIMIZE
+%token MINIMIZE
+%token BOTTOM
+%token NOTITLE
+%token OUTLINE
+%token NOFRAME
+%token DEFAULTSYSMENU
+%token SYSMENU
+%token ROOTMENU
+%token SEPARATOR
+%token ATSTART
+%token ATEND
+%token EXEC
+%token ALWAYSONTOP
+%token DEBUGTOK
+%token RELOAD
+%token TRAYICON
+%token FORCEEXIT
+%token SILENTEXIT
+
+%token <sVal> STRING
+%type <uVal> group1
+%type <uVal> group2
+%type <uVal> stylecombo
+%type <iVal> atspot
+
+%%
+
+input: /* empty */
+ | input line
+ ;
+
+line: NEWLINE
+ | command
+ ;
+
+
+newline_or_nada:
+ | NEWLINE newline_or_nada
+ ;
+
+command: defaulticon
+ | icondirectory
+ | menu
+ | icons
+ | styles
+ | sysmenu
+ | rootmenu
+ | defaultsysmenu
+ | debug
+ | trayicon
+ | forceexit
+ | silentexit
+ ;
+
+trayicon: TRAYICON STRING NEWLINE { SetTrayIcon($2); free($2); }
+ ;
+
+rootmenu: ROOTMENU STRING NEWLINE { SetRootMenu($2); free($2); }
+ ;
+
+defaultsysmenu: DEFAULTSYSMENU STRING atspot NEWLINE { SetDefaultSysMenu($2, $3); free($2); }
+ ;
+
+defaulticon: DEFAULTICON STRING NEWLINE { SetDefaultIcon($2); free($2); }
+ ;
+
+icondirectory: ICONDIRECTORY STRING NEWLINE { SetIconDirectory($2); free($2); }
+ ;
+
+menuline: SEPARATOR NEWLINE newline_or_nada { AddMenuLine("-", CMD_SEPARATOR, ""); }
+ | STRING ALWAYSONTOP NEWLINE newline_or_nada { AddMenuLine($1, CMD_ALWAYSONTOP, ""); free($1); }
+ | STRING EXEC STRING NEWLINE newline_or_nada { AddMenuLine($1, CMD_EXEC, $3); free($1); free($3); }
+ | STRING MENU STRING NEWLINE newline_or_nada { AddMenuLine($1, CMD_MENU, $3); free($1); free($3); }
+ | STRING RELOAD NEWLINE newline_or_nada { AddMenuLine($1, CMD_RELOAD, ""); free($1); }
+ ;
+
+menulist: menuline
+ | menuline menulist
+ ;
+
+menu: MENU STRING LB { OpenMenu($2); free($2); } newline_or_nada menulist RB {CloseMenu();}
+ ;
+
+iconline: STRING STRING NEWLINE newline_or_nada { AddIconLine($1, $2); free($1); free($2); }
+ ;
+
+iconlist: iconline
+ | iconline iconlist
+ ;
+
+icons: ICONS LB {OpenIcons();} newline_or_nada iconlist RB {CloseIcons();}
+ ;
+
+group1: TOPMOST { $$=STYLE_TOPMOST; }
+ | MAXIMIZE { $$=STYLE_MAXIMIZE; }
+ | MINIMIZE { $$=STYLE_MINIMIZE; }
+ | BOTTOM { $$=STYLE_BOTTOM; }
+ ;
+
+group2: NOTITLE { $$=STYLE_NOTITLE; }
+ | OUTLINE { $$=STYLE_OUTLINE; }
+ | NOFRAME { $$=STYLE_NOFRAME; }
+ ;
+
+stylecombo: group1 { $$=$1; }
+ | group2 { $$=$1; }
+ | group1 group2 { $$=$1|$2; }
+ | group2 group1 { $$=$1|$2; }
+ ;
+
+styleline: STRING stylecombo NEWLINE newline_or_nada { AddStyleLine($1, $2); free($1); }
+ ;
+
+stylelist: styleline
+ | styleline stylelist
+ ;
+
+styles: STYLES LB {OpenStyles();} newline_or_nada stylelist RB {CloseStyles();}
+ ;
+
+atspot: { $$=AT_END; }
+ | ATSTART { $$=AT_START; }
+ | ATEND { $$=AT_END; }
+ ;
+
+sysmenuline: STRING STRING atspot NEWLINE newline_or_nada { AddSysMenuLine($1, $2, $3); free($1); free($2); }
+ ;
+
+sysmenulist: sysmenuline
+ | sysmenuline sysmenulist
+ ;
+
+sysmenu: SYSMENU LB NEWLINE {OpenSysMenu();} newline_or_nada sysmenulist RB {CloseSysMenu();}
+ ;
+
+forceexit: FORCEEXIT NEWLINE { pref.fForceExit = TRUE; }
+ ;
+
+silentexit: SILENTEXIT NEWLINE { pref.fSilentExit = TRUE; }
+ ;
+
+debug: DEBUGTOK STRING NEWLINE { winDebug("LoadPreferences: %s\n", $2); free($2); }
+ ;
+
+
+%%
+/*
+ * Errors in parsing abort and print log messages
+ */
+static int
+yyerror (char *s)
+{
+ extern int yylineno; /* Handled by flex internally */
+
+ ErrorF("LoadPreferences: %s line %d\n", s, yylineno);
+ return 1;
+}
+
+/* Miscellaneous functions to store TOKENs into the structure */
+static void
+SetIconDirectory (char *path)
+{
+ strncpy (pref.iconDirectory, path, PATH_MAX);
+ pref.iconDirectory[PATH_MAX] = 0;
+}
+
+static void
+SetDefaultIcon (char *fname)
+{
+ strncpy (pref.defaultIconName, fname, NAME_MAX);
+ pref.defaultIconName[NAME_MAX] = 0;
+}
+
+static void
+SetTrayIcon (char *fname)
+{
+ strncpy (pref.trayIconName, fname, NAME_MAX);
+ pref.trayIconName[NAME_MAX] = 0;
+}
+
+static void
+SetRootMenu (char *menu)
+{
+ strncpy (pref.rootMenuName, menu, MENU_MAX);
+ pref.rootMenuName[MENU_MAX] = 0;
+}
+
+static void
+SetDefaultSysMenu (char *menu, int pos)
+{
+ strncpy (pref.defaultSysMenuName, menu, MENU_MAX);
+ pref.defaultSysMenuName[MENU_MAX] = 0;
+ pref.defaultSysMenuPos = pos;
+}
+
+static void
+OpenMenu (char *menuname)
+{
+ if (menu.menuItem) free(menu.menuItem);
+ menu.menuItem = NULL;
+ strncpy(menu.menuName, menuname, MENU_MAX);
+ menu.menuName[MENU_MAX] = 0;
+ menu.menuItems = 0;
+}
+
+static void
+AddMenuLine (char *text, MENUCOMMANDTYPE cmd, char *param)
+{
+ if (menu.menuItem==NULL)
+ menu.menuItem = (MENUITEM*)malloc(sizeof(MENUITEM));
+ else
+ menu.menuItem = (MENUITEM*)
+ realloc(menu.menuItem, sizeof(MENUITEM)*(menu.menuItems+1));
+
+ strncpy (menu.menuItem[menu.menuItems].text, text, MENU_MAX);
+ menu.menuItem[menu.menuItems].text[MENU_MAX] = 0;
+
+ menu.menuItem[menu.menuItems].cmd = cmd;
+
+ strncpy(menu.menuItem[menu.menuItems].param, param, PARAM_MAX);
+ menu.menuItem[menu.menuItems].param[PARAM_MAX] = 0;
+
+ menu.menuItem[menu.menuItems].commandID = 0;
+
+ menu.menuItems++;
+}
+
+static void
+CloseMenu (void)
+{
+ if (menu.menuItem==NULL || menu.menuItems==0)
+ {
+ ErrorF("LoadPreferences: Empty menu detected\n");
+ return;
+ }
+
+ if (pref.menuItems)
+ pref.menu = (MENUPARSED*)
+ realloc (pref.menu, (pref.menuItems+1)*sizeof(MENUPARSED));
+ else
+ pref.menu = (MENUPARSED*)malloc (sizeof(MENUPARSED));
+
+ memcpy (pref.menu+pref.menuItems, &menu, sizeof(MENUPARSED));
+ pref.menuItems++;
+
+ memset (&menu, 0, sizeof(MENUPARSED));
+}
+
+static void
+OpenIcons (void)
+{
+ if (pref.icon != NULL) {
+ winDebug("LoadPreferences: Redefining icon mappings\n");
+ free(pref.icon);
+ pref.icon = NULL;
+ }
+ pref.iconItems = 0;
+}
+
+static void
+AddIconLine (char *matchstr, char *iconfile)
+{
+ if (pref.icon==NULL)
+ pref.icon = (ICONITEM*)malloc(sizeof(ICONITEM));
+ else
+ pref.icon = (ICONITEM*)
+ realloc(pref.icon, sizeof(ICONITEM)*(pref.iconItems+1));
+
+ strncpy(pref.icon[pref.iconItems].match, matchstr, MENU_MAX);
+ pref.icon[pref.iconItems].match[MENU_MAX] = 0;
+
+ strncpy(pref.icon[pref.iconItems].iconFile, iconfile, PATH_MAX+NAME_MAX+1);
+ pref.icon[pref.iconItems].iconFile[PATH_MAX+NAME_MAX+1] = 0;
+
+ pref.icon[pref.iconItems].hicon = 0;
+
+ pref.iconItems++;
+}
+
+static void
+CloseIcons (void)
+{
+}
+
+static void
+OpenStyles (void)
+{
+ if (pref.style != NULL) {
+ winDebug("LoadPreferences: Redefining window style\n");
+ free(pref.style);
+ pref.style = NULL;
+ }
+ pref.styleItems = 0;
+}
+
+static void
+AddStyleLine (char *matchstr, unsigned long style)
+{
+ if (pref.style==NULL)
+ pref.style = (STYLEITEM*)malloc(sizeof(STYLEITEM));
+ else
+ pref.style = (STYLEITEM*)
+ realloc(pref.style, sizeof(STYLEITEM)*(pref.styleItems+1));
+
+ strncpy(pref.style[pref.styleItems].match, matchstr, MENU_MAX);
+ pref.style[pref.styleItems].match[MENU_MAX] = 0;
+
+ pref.style[pref.styleItems].type = style;
+
+ pref.styleItems++;
+}
+
+static void
+CloseStyles (void)
+{
+}
+
+static void
+OpenSysMenu (void)
+{
+ if (pref.sysMenu != NULL) {
+ winDebug("LoadPreferences: Redefining system menu\n");
+ free(pref.sysMenu);
+ pref.sysMenu = NULL;
+ }
+ pref.sysMenuItems = 0;
+}
+
+static void
+AddSysMenuLine (char *matchstr, char *menuname, int pos)
+{
+ if (pref.sysMenu==NULL)
+ pref.sysMenu = (SYSMENUITEM*)malloc(sizeof(SYSMENUITEM));
+ else
+ pref.sysMenu = (SYSMENUITEM*)
+ realloc(pref.sysMenu, sizeof(SYSMENUITEM)*(pref.sysMenuItems+1));
+
+ strncpy (pref.sysMenu[pref.sysMenuItems].match, matchstr, MENU_MAX);
+ pref.sysMenu[pref.sysMenuItems].match[MENU_MAX] = 0;
+
+ strncpy (pref.sysMenu[pref.sysMenuItems].menuName, menuname, MENU_MAX);
+ pref.sysMenu[pref.sysMenuItems].menuName[MENU_MAX] = 0;
+
+ pref.sysMenu[pref.sysMenuItems].menuPos = pos;
+
+ pref.sysMenuItems++;
+}
+
+static void
+CloseSysMenu (void)
+{
+}
+
diff --git a/xorg-server/hw/xwin/winpriv.c b/xorg-server/hw/xwin/winpriv.c
index 29221cf2b..9dbeade89 100644
--- a/xorg-server/hw/xwin/winpriv.c
+++ b/xorg-server/hw/xwin/winpriv.c
@@ -126,7 +126,7 @@ extern void winGetWindowInfo(WindowPtr pWin, winWindowInfoPtr pWinInfo)
return;
}
- ErrorF("winGetWindowInfo: returning root window\n");
+ winDebug("winGetWindowInfo: returning root window\n");
pWinInfo->hwnd = pWinScreen->hwndScreen;
}
diff --git a/xorg-server/hw/xwin/winprocarg.c b/xorg-server/hw/xwin/winprocarg.c
index 31e505e8d..8b8af966e 100644
--- a/xorg-server/hw/xwin/winprocarg.c
+++ b/xorg-server/hw/xwin/winprocarg.c
@@ -1,1563 +1,1539 @@
-/*
-
-Copyright 1993, 1998 The Open Group
-Copyright (C) Colin Harrison 2005-2008
-
-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.
-
-*/
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#ifdef XVENDORNAME
-#define VENDOR_STRING XVENDORNAME
-#define VENDOR_CONTACT BUILDERADDR
-#endif
-#include <../xfree86/common/xorgVersion.h>
-#include "win.h"
-#include "winconfig.h"
-#include "winprefs.h"
-#include "winmsg.h"
-
-/*
- * References to external symbols
- */
-
-extern int g_iNumScreens;
-extern winScreenInfo g_ScreenInfo[];
-extern int g_iLastScreen;
-extern Bool g_fInitializedDefaultScreens;
-#ifdef XWIN_CLIPBOARD
-extern Bool g_fUnicodeClipboard;
-extern Bool g_fClipboard;
-#endif
-extern int g_iLogVerbose;
-extern char * g_pszLogFile;
-#ifdef RELOCATE_PROJECTROOT
-extern Bool g_fLogFileChanged;
-#endif
-extern Bool g_fXdmcpEnabled;
-extern Bool g_fAuthEnabled;
-extern char * g_pszCommandLine;
-extern Bool g_fKeyboardHookLL;
-extern Bool g_fNoHelpMessageBox;
-extern Bool g_fSoftwareCursor;
-extern Bool g_fSilentDupError;
-
-/* globals required by callback function for monitor information */
-struct GetMonitorInfoData {
- int requestedMonitor;
- int monitorNum;
- Bool bUserSpecifiedMonitor;
- Bool bMonitorSpecifiedExists;
- int monitorOffsetX;
- int monitorOffsetY;
- int monitorHeight;
- int monitorWidth;
-};
-
-typedef wBOOL (*ENUMDISPLAYMONITORSPROC)(HDC,LPCRECT,MONITORENUMPROC,LPARAM);
-ENUMDISPLAYMONITORSPROC _EnumDisplayMonitors;
-
-wBOOL CALLBACK getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _data);
-
-static Bool QueryMonitor(int index, struct GetMonitorInfoData *data)
-{
- /* Load EnumDisplayMonitors from DLL */
- HMODULE user32;
- FARPROC func;
- user32 = LoadLibrary("user32.dll");
- if (user32 == NULL)
- {
- winW32Error(2, "Could not open user32.dll");
- return FALSE;
- }
- func = GetProcAddress(user32, "EnumDisplayMonitors");
- if (func == NULL)
- {
- winW32Error(2, "Could not resolve EnumDisplayMonitors: ");
- return FALSE;
- }
- _EnumDisplayMonitors = (ENUMDISPLAYMONITORSPROC)func;
-
- /* prepare data */
- if (data == NULL)
- return FALSE;
- memset(data, 0, sizeof(*data));
- data->requestedMonitor = index;
-
- /* query information */
- _EnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) data);
-
- /* cleanup */
- FreeLibrary(user32);
- return TRUE;
-}
-
-/*
- * Function prototypes
- */
-
-void
-winLogCommandLine (int argc, char *argv[]);
-
-void
-winLogVersionInfo (void);
-
-#ifdef DDXOSVERRORF
-void OsVendorVErrorF (const char *pszFormat, va_list va_args);
-#endif
-
-void
-winInitializeDefaultScreens (void);
-
-/*
- * Process arguments on the command line
- */
-
-void
-winInitializeDefaultScreens (void)
-{
- int i;
- DWORD dwWidth, dwHeight;
-
- /* Bail out early if default screens have already been initialized */
- if (g_fInitializedDefaultScreens)
- return;
-
- /* Zero the memory used for storing the screen info */
- ZeroMemory (g_ScreenInfo, MAXSCREENS * sizeof (winScreenInfo));
-
- /* Get default width and height */
- /*
- * NOTE: These defaults will cause the window to cover only
- * the primary monitor in the case that we have multiple monitors.
- */
- dwWidth = GetSystemMetrics (SM_CXSCREEN);
- dwHeight = GetSystemMetrics (SM_CYSCREEN);
-
- winErrorFVerb (2, "winInitializeDefaultScreens - w %d h %d\n",
- (int) dwWidth, (int) dwHeight);
-
- /* Set a default DPI, if no parameter was passed */
- if (monitorResolution == 0)
- monitorResolution = WIN_DEFAULT_DPI;
-
- for (i = 0; i < MAXSCREENS; ++i)
- {
- g_ScreenInfo[i].dwScreen = i;
- g_ScreenInfo[i].dwWidth = dwWidth;
- g_ScreenInfo[i].dwHeight = dwHeight;
- g_ScreenInfo[i].dwUserWidth = dwWidth;
- g_ScreenInfo[i].dwUserHeight = dwHeight;
- g_ScreenInfo[i].fUserGaveHeightAndWidth
- = WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH;
- g_ScreenInfo[i].fUserGavePosition = FALSE;
- g_ScreenInfo[i].dwBPP = WIN_DEFAULT_BPP;
- g_ScreenInfo[i].dwClipUpdatesNBoxes = WIN_DEFAULT_CLIP_UPDATES_NBOXES;
-#ifdef XWIN_EMULATEPSEUDO
- g_ScreenInfo[i].fEmulatePseudo = WIN_DEFAULT_EMULATE_PSEUDO;
-#endif
- g_ScreenInfo[i].dwRefreshRate = WIN_DEFAULT_REFRESH;
- g_ScreenInfo[i].pfb = NULL;
- g_ScreenInfo[i].fFullScreen = FALSE;
- g_ScreenInfo[i].fDecoration = TRUE;
-#ifdef XWIN_MULTIWINDOWEXTWM
- g_ScreenInfo[i].fMWExtWM = FALSE;
- g_ScreenInfo[i].fInternalWM = FALSE;
-#endif
- g_ScreenInfo[i].fRootless = FALSE;
-#ifdef XWIN_MULTIWINDOW
- g_ScreenInfo[i].fMultiWindow = FALSE;
-#endif
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- g_ScreenInfo[i].fMultiMonitorOverride = FALSE;
-#endif
- g_ScreenInfo[i].fMultipleMonitors = FALSE;
- g_ScreenInfo[i].fLessPointer = FALSE;
- g_ScreenInfo[i].fScrollbars = FALSE;
- g_ScreenInfo[i].fNoTrayIcon = FALSE;
- g_ScreenInfo[i].iE3BTimeout = WIN_E3B_OFF;
- g_ScreenInfo[i].dwWidth_mm = (dwWidth / WIN_DEFAULT_DPI)
- * 25.4;
- g_ScreenInfo[i].dwHeight_mm = (dwHeight / WIN_DEFAULT_DPI)
- * 25.4;
- g_ScreenInfo[i].fUseWinKillKey = WIN_DEFAULT_WIN_KILL;
- g_ScreenInfo[i].fUseUnixKillKey = WIN_DEFAULT_UNIX_KILL;
- g_ScreenInfo[i].fIgnoreInput = FALSE;
- g_ScreenInfo[i].fExplicitScreen = FALSE;
- }
-
- /* Signal that the default screens have been initialized */
- g_fInitializedDefaultScreens = TRUE;
-
- winErrorFVerb (2, "winInitializeDefaultScreens - Returning\n");
-}
-
-/* See Porting Layer Definition - p. 57 */
-/*
- * INPUT
- * argv: pointer to an array of null-terminated strings, one for
- * each token in the X Server command line; the first token
- * is 'XWin.exe', or similar.
- * argc: a count of the number of tokens stored in argv.
- * i: a zero-based index into argv indicating the current token being
- * processed.
- *
- * OUTPUT
- * return: return the number of tokens processed correctly.
- *
- * NOTE
- * When looking for n tokens, check that i + n is less than argc. Or,
- * you may check if i is greater than or equal to argc, in which case
- * you should display the UseMsg () and return 0.
- */
-
-/* Check if enough arguments are given for the option */
-#define CHECK_ARGS(count) if (i + count >= argc) { UseMsg (); return 0; }
-
-/* Compare the current option with the string. */
-#define IS_OPTION(name) (strcmp (argv[i], name) == 0)
-
-int
-ddxProcessArgument (int argc, char *argv[], int i)
-{
- static Bool s_fBeenHere = FALSE;
-
- /* Initialize once */
- if (!s_fBeenHere)
- {
-#ifdef DDXOSVERRORF
- /*
- * This initialises our hook into VErrorF () for catching log messages
- * that are generated before OsInit () is called.
- */
- OsVendorVErrorFProc = OsVendorVErrorF;
-#endif
-
- s_fBeenHere = TRUE;
-
- /* Initialize only if option is not -help */
- if (!IS_OPTION("-help") && !IS_OPTION("-h") && !IS_OPTION("--help") &&
- !IS_OPTION("-version") && !IS_OPTION("--version"))
- {
-
- /* Log the version information */
- winLogVersionInfo ();
-
- /* Log the command line */
- winLogCommandLine (argc, argv);
-
- /*
- * Initialize default screen settings. We have to do this before
- * OsVendorInit () gets called, otherwise we will overwrite
- * settings changed by parameters such as -fullscreen, etc.
- */
- winErrorFVerb (2, "ddxProcessArgument - Initializing default "
- "screens\n");
- winInitializeDefaultScreens ();
- }
- }
-
-#if CYGDEBUG
- winDebug ("ddxProcessArgument - arg: %s\n", argv[i]);
-#endif
-
- /*
- * Look for the '-help' and similar options
- */
- if (IS_OPTION ("-help") || IS_OPTION("-h") || IS_OPTION("--help"))
- {
- /* Reset logfile. We don't need that helpmessage in the logfile */
- g_pszLogFile = NULL;
- g_fNoHelpMessageBox = TRUE;
- UseMsg();
- exit (0);
- return 1;
- }
-
- if (IS_OPTION ("-version") || IS_OPTION("--version"))
- {
- /* Reset logfile. We don't need that versioninfo in the logfile */
- g_pszLogFile = NULL;
- winLogVersionInfo ();
- exit (0);
- return 1;
- }
-
- /*
- * Look for the '-screen scr_num [width height]' argument
- */
- if (IS_OPTION ("-screen"))
- {
- int iArgsProcessed = 1;
- int nScreenNum;
- int iWidth, iHeight, iX, iY;
- int iMonitor;
-
-#if CYGDEBUG
- winDebug ("ddxProcessArgument - screen - argc: %d i: %d\n",
- argc, i);
-#endif
-
- /* Display the usage message if the argument is malformed */
- if (i + 1 >= argc)
- {
- return 0;
- }
-
- /* Grab screen number */
- nScreenNum = atoi (argv[i + 1]);
-
- /* Validate the specified screen number */
- if (nScreenNum < 0 || nScreenNum >= MAXSCREENS)
- {
- ErrorF ("ddxProcessArgument - screen - Invalid screen number %d\n",
- nScreenNum);
- UseMsg ();
- return 0;
- }
-
- /* look for @m where m is monitor number */
- if (i + 2 < argc
- && 1 == sscanf(argv[i + 2], "@%d", (int *) &iMonitor))
- {
- struct GetMonitorInfoData data;
- if (!QueryMonitor(iMonitor, &data))
- {
- ErrorF ("ddxProcessArgument - screen - "
- "Querying monitors is not supported on NT4 and Win95\n");
- } else if (data.bMonitorSpecifiedExists == TRUE)
- {
- winErrorFVerb(2, "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor);
- iArgsProcessed = 3;
- g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE;
- g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
- g_ScreenInfo[nScreenNum].dwWidth = data.monitorWidth;
- g_ScreenInfo[nScreenNum].dwHeight = data.monitorHeight;
- g_ScreenInfo[nScreenNum].dwUserWidth = data.monitorWidth;
- g_ScreenInfo[nScreenNum].dwUserHeight = data.monitorHeight;
- g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX;
- g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY;
- }
- else
- {
- /* monitor does not exist, error out */
- ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
- iMonitor);
- UseMsg ();
- exit (0);
- return 0;
- }
- }
-
- /* Look for 'WxD' or 'W D' */
- else if (i + 2 < argc
- && 2 == sscanf (argv[i + 2], "%dx%d",
- (int *) &iWidth,
- (int *) &iHeight))
- {
- winErrorFVerb (2, "ddxProcessArgument - screen - Found ``WxD'' arg\n");
- iArgsProcessed = 3;
- g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE;
- g_ScreenInfo[nScreenNum].dwWidth = iWidth;
- g_ScreenInfo[nScreenNum].dwHeight = iHeight;
- g_ScreenInfo[nScreenNum].dwUserWidth = iWidth;
- g_ScreenInfo[nScreenNum].dwUserHeight = iHeight;
- /* Look for WxD+X+Y */
- if (2 == sscanf (argv[i + 2], "%*dx%*d+%d+%d",
- (int *) &iX,
- (int *) &iY))
- {
- winErrorFVerb (2, "ddxProcessArgument - screen - Found ``X+Y'' arg\n");
- g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
- g_ScreenInfo[nScreenNum].dwInitialX = iX;
- g_ScreenInfo[nScreenNum].dwInitialY = iY;
-
- /* look for WxD+X+Y@m where m is monitor number. take X,Y to be offsets from monitor's root position */
- if (1 == sscanf (argv[i + 2], "%*dx%*d+%*d+%*d@%d",
- (int *) &iMonitor))
- {
- struct GetMonitorInfoData data;
- if (!QueryMonitor(iMonitor, &data))
- {
- ErrorF ("ddxProcessArgument - screen - "
- "Querying monitors is not supported on NT4 and Win95\n");
- } else if (data.bMonitorSpecifiedExists == TRUE)
- {
- g_ScreenInfo[nScreenNum].dwInitialX += data.monitorOffsetX;
- g_ScreenInfo[nScreenNum].dwInitialY += data.monitorOffsetY;
- }
- else
- {
- /* monitor does not exist, error out */
- ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
- iMonitor);
- UseMsg ();
- exit (0);
- return 0;
- }
-
- }
- }
-
- /* look for WxD@m where m is monitor number */
- else if (1 == sscanf(argv[i + 2], "%*dx%*d@%d",
- (int *) &iMonitor))
- {
- struct GetMonitorInfoData data;
- if (!QueryMonitor(iMonitor, &data))
- {
- ErrorF ("ddxProcessArgument - screen - "
- "Querying monitors is not supported on NT4 and Win95\n");
- } else if (data.bMonitorSpecifiedExists == TRUE)
- {
- winErrorFVerb (2, "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor);
- g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
- g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX;
- g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY;
- }
- else
- {
- /* monitor does not exist, error out */
- ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
- iMonitor);
- UseMsg ();
- exit (0);
- return 0;
- }
-
- }
- }
- else if (i + 3 < argc
- && 1 == sscanf (argv[i + 2], "%d",
- (int *) &iWidth)
- && 1 == sscanf (argv[i + 3], "%d",
- (int *) &iHeight))
- {
- winErrorFVerb (2, "ddxProcessArgument - screen - Found ``W D'' arg\n");
- iArgsProcessed = 4;
- g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE;
- g_ScreenInfo[nScreenNum].dwWidth = iWidth;
- g_ScreenInfo[nScreenNum].dwHeight = iHeight;
- g_ScreenInfo[nScreenNum].dwUserWidth = iWidth;
- g_ScreenInfo[nScreenNum].dwUserHeight = iHeight;
- if (i + 5 < argc
- && 1 == sscanf (argv[i + 4], "%d",
- (int *) &iX)
- && 1 == sscanf (argv[i + 5], "%d",
- (int *) &iY))
- {
- winErrorFVerb (2, "ddxProcessArgument - screen - Found ``X Y'' arg\n");
- iArgsProcessed = 6;
- g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
- g_ScreenInfo[nScreenNum].dwInitialX = iX;
- g_ScreenInfo[nScreenNum].dwInitialY = iY;
- }
- }
- else
- {
- winErrorFVerb (2, "ddxProcessArgument - screen - Did not find size arg. "
- "dwWidth: %d dwHeight: %d\n",
- (int) g_ScreenInfo[nScreenNum].dwWidth,
- (int) g_ScreenInfo[nScreenNum].dwHeight);
- iArgsProcessed = 2;
- g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE;
- }
-
- /* Calculate the screen width and height in millimeters */
- if (g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth)
- {
- g_ScreenInfo[nScreenNum].dwWidth_mm
- = (g_ScreenInfo[nScreenNum].dwWidth
- / monitorResolution) * 25.4;
- g_ScreenInfo[nScreenNum].dwHeight_mm
- = (g_ScreenInfo[nScreenNum].dwHeight
- / monitorResolution) * 25.4;
- }
-
- /* Flag that this screen was explicity specified by the user */
- g_ScreenInfo[nScreenNum].fExplicitScreen = TRUE;
-
- /*
- * Keep track of the last screen number seen, as parameters seen
- * before a screen number apply to all screens, whereas parameters
- * seen after a screen number apply to that screen number only.
- */
- g_iLastScreen = nScreenNum;
-
- /* Keep a count of the number of screens */
- ++g_iNumScreens;
-
- return iArgsProcessed;
- }
-
- /*
- * Look for the '-engine n' argument
- */
- if (IS_OPTION ("-engine"))
- {
- DWORD dwEngine = 0;
- CARD8 c8OnBits = 0;
-
- /* Display the usage message if the argument is malformed */
- if (++i >= argc)
- {
- UseMsg ();
- return 0;
- }
-
- /* Grab the argument */
- dwEngine = atoi (argv[i]);
-
- /* Count the one bits in the engine argument */
- c8OnBits = winCountBits (dwEngine);
-
- /* Argument should only have a single bit on */
- if (c8OnBits != 1)
- {
- UseMsg ();
- return 0;
- }
-
- /* Is this parameter attached to a screen or global? */
- if (-1 == g_iLastScreen)
- {
- int j;
-
- /* Parameter is for all screens */
- for (j = 0; j < MAXSCREENS; j++)
- {
- g_ScreenInfo[j].dwEnginePreferred = dwEngine;
- }
- }
- else
- {
- /* Parameter is for a single screen */
- g_ScreenInfo[g_iLastScreen].dwEnginePreferred = dwEngine;
- }
-
- /* Indicate that we have processed the argument */
- return 2;
- }
-
- /*
- * Look for the '-fullscreen' argument
- */
- if (IS_OPTION ("-fullscreen"))
- {
- /* Is this parameter attached to a screen or is it global? */
- if (-1 == g_iLastScreen)
- {
- int j;
-
- /* Parameter is for all screens */
- for (j = 0; j < MAXSCREENS; j++)
- {
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- if (!g_ScreenInfo[j].fMultiMonitorOverride)
- g_ScreenInfo[j].fMultipleMonitors = FALSE;
-#endif
- g_ScreenInfo[j].fFullScreen = TRUE;
- }
- }
- else
- {
- /* Parameter is for a single screen */
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
- g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE;
-#endif
- g_ScreenInfo[g_iLastScreen].fFullScreen = TRUE;
- }
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
- /*
- * Look for the '-lesspointer' argument
- */
- if (IS_OPTION ("-lesspointer"))
- {
- /* Is this parameter attached to a screen or is it global? */
- if (-1 == g_iLastScreen)
- {
- int j;
-
- /* Parameter is for all screens */
- for (j = 0; j < MAXSCREENS; j++)
- {
- g_ScreenInfo[j].fLessPointer = TRUE;
- }
- }
- else
- {
- /* Parameter is for a single screen */
- g_ScreenInfo[g_iLastScreen].fLessPointer = TRUE;
- }
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
- /*
- * Look for the '-nodecoration' argument
- */
- if (IS_OPTION ("-nodecoration"))
- {
- /* Is this parameter attached to a screen or is it global? */
- if (-1 == g_iLastScreen)
- {
- int j;
-
- /* Parameter is for all screens */
- for (j = 0; j < MAXSCREENS; j++)
- {
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- if (!g_ScreenInfo[j].fMultiMonitorOverride)
- g_ScreenInfo[j].fMultipleMonitors = FALSE;
-#endif
- g_ScreenInfo[j].fDecoration = FALSE;
- }
- }
- else
- {
- /* Parameter is for a single screen */
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
- g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE;
-#endif
- g_ScreenInfo[g_iLastScreen].fDecoration = FALSE;
- }
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
-#ifdef XWIN_MULTIWINDOWEXTWM
- /*
- * Look for the '-mwextwm' argument
- */
- if (IS_OPTION ("-mwextwm"))
- {
- /* Is this parameter attached to a screen or is it global? */
- if (-1 == g_iLastScreen)
- {
- int j;
-
- /* Parameter is for all screens */
- for (j = 0; j < MAXSCREENS; j++)
- {
- if (!g_ScreenInfo[j].fMultiMonitorOverride)
- g_ScreenInfo[j].fMultipleMonitors = TRUE;
- g_ScreenInfo[j].fMWExtWM = TRUE;
- }
- }
- else
- {
- /* Parameter is for a single screen */
- if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
- g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE;
- g_ScreenInfo[g_iLastScreen].fMWExtWM = TRUE;
- }
-
- /* Indicate that we have processed this argument */
- return 1;
- }
- /*
- * Look for the '-internalwm' argument
- */
- if (IS_OPTION ("-internalwm"))
- {
- /* Is this parameter attached to a screen or is it global? */
- if (-1 == g_iLastScreen)
- {
- int j;
-
- /* Parameter is for all screens */
- for (j = 0; j < MAXSCREENS; j++)
- {
- if (!g_ScreenInfo[j].fMultiMonitorOverride)
- g_ScreenInfo[j].fMultipleMonitors = TRUE;
- g_ScreenInfo[j].fMWExtWM = TRUE;
- g_ScreenInfo[j].fInternalWM = TRUE;
- }
- }
- else
- {
- /* Parameter is for a single screen */
- if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
- g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE;
- g_ScreenInfo[g_iLastScreen].fMWExtWM = TRUE;
- g_ScreenInfo[g_iLastScreen].fInternalWM = TRUE;
- }
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-#endif
-
- /*
- * Look for the '-rootless' argument
- */
- if (IS_OPTION ("-rootless"))
- {
- /* Is this parameter attached to a screen or is it global? */
- if (-1 == g_iLastScreen)
- {
- int j;
-
- /* Parameter is for all screens */
- for (j = 0; j < MAXSCREENS; j++)
- {
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- if (!g_ScreenInfo[j].fMultiMonitorOverride)
- g_ScreenInfo[j].fMultipleMonitors = FALSE;
-#endif
- g_ScreenInfo[j].fRootless = TRUE;
- }
- }
- else
- {
- /* Parameter is for a single screen */
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
- g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE;
-#endif
- g_ScreenInfo[g_iLastScreen].fRootless = TRUE;
- }
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
-#ifdef XWIN_MULTIWINDOW
- /*
- * Look for the '-multiwindow' argument
- */
- if (IS_OPTION ("-multiwindow"))
- {
- /* Is this parameter attached to a screen or is it global? */
- if (-1 == g_iLastScreen)
- {
- int j;
-
- /* Parameter is for all screens */
- for (j = 0; j < MAXSCREENS; j++)
- {
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- if (!g_ScreenInfo[j].fMultiMonitorOverride)
- g_ScreenInfo[j].fMultipleMonitors = TRUE;
-#endif
- g_ScreenInfo[j].fMultiWindow = TRUE;
- }
- }
- else
- {
- /* Parameter is for a single screen */
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
- g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE;
-#endif
- g_ScreenInfo[g_iLastScreen].fMultiWindow = TRUE;
- }
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-#endif
-
- /*
- * Look for the '-multiplemonitors' argument
- */
- if (IS_OPTION ("-multiplemonitors")
- || IS_OPTION ("-multimonitors"))
- {
- /* Is this parameter attached to a screen or is it global? */
- if (-1 == g_iLastScreen)
- {
- int j;
-
- /* Parameter is for all screens */
- for (j = 0; j < MAXSCREENS; j++)
- {
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- g_ScreenInfo[j].fMultiMonitorOverride = TRUE;
-#endif
- g_ScreenInfo[j].fMultipleMonitors = TRUE;
- }
- }
- else
- {
- /* Parameter is for a single screen */
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride = TRUE;
-#endif
- g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE;
- }
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
- /*
- * Look for the '-nomultiplemonitors' argument
- */
- if (IS_OPTION ("-nomultiplemonitors")
- || IS_OPTION ("-nomultimonitors"))
- {
- /* Is this parameter attached to a screen or is it global? */
- if (-1 == g_iLastScreen)
- {
- int j;
-
- /* Parameter is for all screens */
- for (j = 0; j < MAXSCREENS; j++)
- {
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- g_ScreenInfo[j].fMultiMonitorOverride = TRUE;
-#endif
- g_ScreenInfo[j].fMultipleMonitors = FALSE;
- }
- }
- else
- {
- /* Parameter is for a single screen */
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride = TRUE;
-#endif
- g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE;
- }
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
-
- /*
- * Look for the '-scrollbars' argument
- */
- if (IS_OPTION ("-scrollbars"))
- {
- /* Is this parameter attached to a screen or is it global? */
- if (-1 == g_iLastScreen)
- {
- int j;
-
- /* Parameter is for all screens */
- for (j = 0; j < MAXSCREENS; j++)
- {
- g_ScreenInfo[j].fScrollbars = TRUE;
- }
- }
- else
- {
- /* Parameter is for a single screen */
- g_ScreenInfo[g_iLastScreen].fScrollbars = TRUE;
- }
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
-
-#ifdef XWIN_CLIPBOARD
- /*
- * Look for the '-clipboard' argument
- */
- if (IS_OPTION ("-clipboard"))
- {
- /* Now the default, we still accept the arg for backwards compatibility */
- g_fClipboard = TRUE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
- /*
- * Look for the '-noclipboard' argument
- */
- if (IS_OPTION ("-noclipboard"))
- {
- g_fClipboard = FALSE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-#endif
-
-
- /*
- * Look for the '-ignoreinput' argument
- */
- if (IS_OPTION ("-ignoreinput"))
- {
- /* Is this parameter attached to a screen or is it global? */
- if (-1 == g_iLastScreen)
- {
- int j;
-
- /* Parameter is for all screens */
- for (j = 0; j < MAXSCREENS; j++)
- {
- g_ScreenInfo[j].fIgnoreInput = TRUE;
- }
- }
- else
- {
- /* Parameter is for a single screen */
- g_ScreenInfo[g_iLastScreen].fIgnoreInput = TRUE;
- }
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
- /*
- * Look for the '-emulate3buttons' argument
- */
- if (IS_OPTION ("-emulate3buttons"))
- {
- int iArgsProcessed = 1;
- int iE3BTimeout = WIN_DEFAULT_E3B_TIME;
-
- /* Grab the optional timeout value */
- if (i + 1 < argc
- && 1 == sscanf (argv[i + 1], "%d",
- &iE3BTimeout))
- {
- /* Indicate that we have processed the next argument */
- iArgsProcessed++;
- }
- else
- {
- /*
- * sscanf () won't modify iE3BTimeout if it doesn't find
- * the specified format; however, I want to be explicit
- * about setting the default timeout in such cases to
- * prevent some programs (me) from getting confused.
- */
- iE3BTimeout = WIN_DEFAULT_E3B_TIME;
- }
-
- /* Is this parameter attached to a screen or is it global? */
- if (-1 == g_iLastScreen)
- {
- int j;
-
- /* Parameter is for all screens */
- for (j = 0; j < MAXSCREENS; j++)
- {
- g_ScreenInfo[j].iE3BTimeout = iE3BTimeout;
- }
- }
- else
- {
- /* Parameter is for a single screen */
- g_ScreenInfo[g_iLastScreen].iE3BTimeout = iE3BTimeout;
- }
-
- /* Indicate that we have processed this argument */
- return iArgsProcessed;
- }
-
- /*
- * Look for the '-depth n' argument
- */
- if (IS_OPTION ("-depth"))
- {
- DWORD dwBPP = 0;
-
- /* Display the usage message if the argument is malformed */
- if (++i >= argc)
- {
- UseMsg ();
- return 0;
- }
-
- /* Grab the argument */
- dwBPP = atoi (argv[i]);
-
- /* Is this parameter attached to a screen or global? */
- if (-1 == g_iLastScreen)
- {
- int j;
-
- /* Parameter is for all screens */
- for (j = 0; j < MAXSCREENS; j++)
- {
- g_ScreenInfo[j].dwBPP = dwBPP;
- }
- }
- else
- {
- /* Parameter is for a single screen */
- g_ScreenInfo[g_iLastScreen].dwBPP = dwBPP;
- }
-
- /* Indicate that we have processed the argument */
- return 2;
- }
-
- /*
- * Look for the '-refresh n' argument
- */
- if (IS_OPTION ("-refresh"))
- {
- DWORD dwRefreshRate = 0;
-
- /* Display the usage message if the argument is malformed */
- if (++i >= argc)
- {
- UseMsg ();
- return 0;
- }
-
- /* Grab the argument */
- dwRefreshRate = atoi (argv[i]);
-
- /* Is this parameter attached to a screen or global? */
- if (-1 == g_iLastScreen)
- {
- int j;
-
- /* Parameter is for all screens */
- for (j = 0; j < MAXSCREENS; j++)
- {
- g_ScreenInfo[j].dwRefreshRate = dwRefreshRate;
- }
- }
- else
- {
- /* Parameter is for a single screen */
- g_ScreenInfo[g_iLastScreen].dwRefreshRate = dwRefreshRate;
- }
-
- /* Indicate that we have processed the argument */
- return 2;
- }
-
- /*
- * Look for the '-clipupdates num_boxes' argument
- */
- if (IS_OPTION ("-clipupdates"))
- {
- DWORD dwNumBoxes = 0;
-
- /* Display the usage message if the argument is malformed */
- if (++i >= argc)
- {
- UseMsg ();
- return 0;
- }
-
- /* Grab the argument */
- dwNumBoxes = atoi (argv[i]);
-
- /* Is this parameter attached to a screen or global? */
- if (-1 == g_iLastScreen)
- {
- int j;
-
- /* Parameter is for all screens */
- for (j = 0; j < MAXSCREENS; j++)
- {
- g_ScreenInfo[j].dwClipUpdatesNBoxes = dwNumBoxes;
- }
- }
- else
- {
- /* Parameter is for a single screen */
- g_ScreenInfo[g_iLastScreen].dwClipUpdatesNBoxes = dwNumBoxes;
- }
-
- /* Indicate that we have processed the argument */
- return 2;
- }
-
-#ifdef XWIN_EMULATEPSEUDO
- /*
- * Look for the '-emulatepseudo' argument
- */
- if (IS_OPTION ("-emulatepseudo"))
- {
- /* Is this parameter attached to a screen or is it global? */
- if (-1 == g_iLastScreen)
- {
- int j;
-
- /* Parameter is for all screens */
- for (j = 0; j < MAXSCREENS; j++)
- {
- g_ScreenInfo[j].fEmulatePseudo = TRUE;
- }
- }
- else
- {
- /* Parameter is for a single screen */
- g_ScreenInfo[g_iLastScreen].fEmulatePseudo = TRUE;
- }
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-#endif
-
- /*
- * Look for the '-nowinkill' argument
- */
- if (IS_OPTION ("-nowinkill"))
- {
- /* Is this parameter attached to a screen or is it global? */
- if (-1 == g_iLastScreen)
- {
- int j;
-
- /* Parameter is for all screens */
- for (j = 0; j < MAXSCREENS; j++)
- {
- g_ScreenInfo[j].fUseWinKillKey = FALSE;
- }
- }
- else
- {
- /* Parameter is for a single screen */
- g_ScreenInfo[g_iLastScreen].fUseWinKillKey = FALSE;
- }
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
- /*
- * Look for the '-winkill' argument
- */
- if (IS_OPTION ("-winkill"))
- {
- /* Is this parameter attached to a screen or is it global? */
- if (-1 == g_iLastScreen)
- {
- int j;
-
- /* Parameter is for all screens */
- for (j = 0; j < MAXSCREENS; j++)
- {
- g_ScreenInfo[j].fUseWinKillKey = TRUE;
- }
- }
- else
- {
- /* Parameter is for a single screen */
- g_ScreenInfo[g_iLastScreen].fUseWinKillKey = TRUE;
- }
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
- /*
- * Look for the '-nounixkill' argument
- */
- if (IS_OPTION ("-nounixkill"))
- {
- /* Is this parameter attached to a screen or is it global? */
- if (-1 == g_iLastScreen)
- {
- int j;
-
- /* Parameter is for all screens */
- for (j = 0; j < MAXSCREENS; j++)
- {
- g_ScreenInfo[j].fUseUnixKillKey = FALSE;
- }
- }
- else
- {
- /* Parameter is for a single screen */
- g_ScreenInfo[g_iLastScreen].fUseUnixKillKey = FALSE;
- }
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
- /*
- * Look for the '-unixkill' argument
- */
- if (IS_OPTION ("-unixkill"))
- {
- /* Is this parameter attached to a screen or is it global? */
- if (-1 == g_iLastScreen)
- {
- int j;
-
- /* Parameter is for all screens */
- for (j = 0; j < MAXSCREENS; j++)
- {
- g_ScreenInfo[j].fUseUnixKillKey = TRUE;
- }
- }
- else
- {
- /* Parameter is for a single screen */
- g_ScreenInfo[g_iLastScreen].fUseUnixKillKey = TRUE;
- }
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
- /*
- * Look for the '-notrayicon' argument
- */
- if (IS_OPTION ("-notrayicon"))
- {
- /* Is this parameter attached to a screen or is it global? */
- if (-1 == g_iLastScreen)
- {
- int j;
-
- /* Parameter is for all screens */
- for (j = 0; j < MAXSCREENS; j++)
- {
- g_ScreenInfo[j].fNoTrayIcon = TRUE;
- }
- }
- else
- {
- /* Parameter is for a single screen */
- g_ScreenInfo[g_iLastScreen].fNoTrayIcon = TRUE;
- }
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
- /*
- * Look for the '-trayicon' argument
- */
- if (IS_OPTION ("-trayicon"))
- {
- /* Is this parameter attached to a screen or is it global? */
- if (-1 == g_iLastScreen)
- {
- int j;
-
- /* Parameter is for all screens */
- for (j = 0; j < MAXSCREENS; j++)
- {
- g_ScreenInfo[j].fNoTrayIcon = FALSE;
- }
- }
- else
- {
- /* Parameter is for a single screen */
- g_ScreenInfo[g_iLastScreen].fNoTrayIcon = FALSE;
- }
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
- /*
- * Look for the '-fp' argument
- */
- if (IS_OPTION ("-fp"))
- {
- CHECK_ARGS (1);
- g_cmdline.fontPath = argv[++i];
- return 0; /* Let DIX parse this again */
- }
-
- /*
- * Look for the '-query' argument
- */
- if (IS_OPTION ("-query"))
- {
- CHECK_ARGS (1);
- g_fXdmcpEnabled = TRUE;
- g_pszQueryHost = argv[++i];
- return 0; /* Let DIX parse this again */
- }
-
- /*
- * Look for the '-auth' argument
- */
- if (IS_OPTION ("-auth"))
- {
- g_fAuthEnabled = TRUE;
- return 0; /* Let DIX parse this again */
- }
-
- /*
- * Look for the '-indirect' or '-broadcast' arguments
- */
- if (IS_OPTION ("-indirect")
- || IS_OPTION ("-broadcast"))
- {
- g_fXdmcpEnabled = TRUE;
- return 0; /* Let DIX parse this again */
- }
-
- /*
- * Look for the '-config' argument
- */
- if (IS_OPTION ("-config")
- || IS_OPTION ("-xf86config"))
- {
- CHECK_ARGS (1);
-#ifdef XWIN_XF86CONFIG
- g_cmdline.configFile = argv[++i];
-#else
- winMessageBoxF ("The %s option is not supported in this "
- "release.\n"
- "Ignoring this option and continuing.\n",
- MB_ICONINFORMATION,
- argv[i]);
-#endif
- return 2;
- }
-
- /*
- * Look for the '-keyboard' argument
- */
- if (IS_OPTION ("-keyboard"))
- {
-#ifdef XWIN_XF86CONFIG
- CHECK_ARGS (1);
- g_cmdline.keyboard = argv[++i];
-#else
- winMessageBoxF ("The -keyboard option is not supported in this "
- "release.\n"
- "Ignoring this option and continuing.\n",
- MB_ICONINFORMATION);
-#endif
- return 2;
- }
-
- /*
- * Look for the '-logfile' argument
- */
- if (IS_OPTION ("-logfile"))
- {
- CHECK_ARGS (1);
- g_pszLogFile = argv[++i];
-#ifdef RELOCATE_PROJECTROOT
- g_fLogFileChanged = TRUE;
-#endif
- return 2;
- }
-
- /*
- * Look for the '-logverbose' argument
- */
- if (IS_OPTION ("-logverbose"))
- {
- CHECK_ARGS (1);
- g_iLogVerbose = atoi(argv[++i]);
- return 2;
- }
-
-#ifdef XWIN_CLIPBOARD
- /*
- * Look for the '-nounicodeclipboard' argument
- */
- if (IS_OPTION ("-nounicodeclipboard"))
- {
- g_fUnicodeClipboard = FALSE;
- /* Indicate that we have processed the argument */
- return 1;
- }
-#endif
-
- if (IS_OPTION ("-xkbrules"))
- {
- CHECK_ARGS (1);
- g_cmdline.xkbRules = argv[++i];
- return 2;
- }
- if (IS_OPTION ("-xkbmodel"))
- {
- CHECK_ARGS (1);
- g_cmdline.xkbModel = argv[++i];
- return 2;
- }
- if (IS_OPTION ("-xkblayout"))
- {
- CHECK_ARGS (1);
- g_cmdline.xkbLayout = argv[++i];
- return 2;
- }
- if (IS_OPTION ("-xkbvariant"))
- {
- CHECK_ARGS (1);
- g_cmdline.xkbVariant = argv[++i];
- return 2;
- }
- if (IS_OPTION ("-xkboptions"))
- {
- CHECK_ARGS (1);
- g_cmdline.xkbOptions = argv[++i];
- return 2;
- }
-
- if (IS_OPTION ("-keyhook"))
- {
- g_fKeyboardHookLL = TRUE;
- return 1;
- }
-
- if (IS_OPTION ("-nokeyhook"))
- {
- g_fKeyboardHookLL = FALSE;
- return 1;
- }
-
- if (IS_OPTION ("-swcursor"))
- {
- g_fSoftwareCursor = TRUE;
- return 1;
- }
-
- if (IS_OPTION ("-silent-dup-error"))
- {
- g_fSilentDupError = TRUE;
- return 1;
- }
- return 0;
-}
-
-
-/*
- * winLogCommandLine - Write entire command line to the log file
- */
-
-void
-winLogCommandLine (int argc, char *argv[])
-{
- int i;
- int iSize = 0;
- int iCurrLen = 0;
-
-#define CHARS_PER_LINE 60
-
- /* Bail if command line has already been logged */
- if (g_pszCommandLine)
- return;
-
- /* Count how much memory is needed for concatenated command line */
- for (i = 0, iCurrLen = 0; i < argc; ++i)
- if (argv[i])
- {
- /* Adds two characters for lines that overflow */
- if ((strlen (argv[i]) < CHARS_PER_LINE
- && iCurrLen + strlen (argv[i]) > CHARS_PER_LINE)
- || strlen (argv[i]) > CHARS_PER_LINE)
- {
- iCurrLen = 0;
- iSize += 2;
- }
-
- /* Add space for item and trailing space */
- iSize += strlen (argv[i]) + 1;
-
- /* Update current line length */
- iCurrLen += strlen (argv[i]);
- }
-
- /* Allocate memory for concatenated command line */
- g_pszCommandLine = malloc (iSize + 1);
- if (!g_pszCommandLine)
- FatalError ("winLogCommandLine - Could not allocate memory for "
- "command line string. Exiting.\n");
-
- /* Set first character to concatenated command line to null */
- g_pszCommandLine[0] = '\0';
-
- /* Loop through all args */
- for (i = 0, iCurrLen = 0; i < argc; ++i)
- {
- /* Add a character for lines that overflow */
- if ((strlen (argv[i]) < CHARS_PER_LINE
- && iCurrLen + strlen (argv[i]) > CHARS_PER_LINE)
- || strlen (argv[i]) > CHARS_PER_LINE)
- {
- iCurrLen = 0;
-
- /* Add line break if it fits */
- strncat (g_pszCommandLine, "\n ", iSize - strlen (g_pszCommandLine));
- }
-
- strncat (g_pszCommandLine, argv[i], iSize - strlen (g_pszCommandLine));
- strncat (g_pszCommandLine, " ", iSize - strlen (g_pszCommandLine));
-
- /* Save new line length */
- iCurrLen += strlen (argv[i]);
- }
-
- ErrorF ("XWin was started with the following command line:\n\n"
- "%s\n\n", g_pszCommandLine);
-}
-
-
-/*
- * winLogVersionInfo - Log Cygwin/X version information
- */
-
-void
-winLogVersionInfo (void)
-{
- static Bool s_fBeenHere = FALSE;
-
- if (s_fBeenHere)
- return;
- s_fBeenHere = TRUE;
-
- ErrorF ("Welcome to the XWin X Server\n");
- ErrorF ("Vendor: %s\n", VENDOR_STRING);
- ErrorF ("Release: %d.%d.%d.%d (%d)\n", XORG_VERSION_MAJOR, XORG_VERSION_MINOR, XORG_VERSION_PATCH, XORG_VERSION_SNAP, XORG_VERSION_CURRENT);
- ErrorF ("Contact: %s\n", VENDOR_CONTACT);
-}
-
-/*
- * getMonitorInfo - callback function used to return information from the enumeration of monitors attached
- */
-
-wBOOL CALLBACK getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _data)
-{
- struct GetMonitorInfoData* data = (struct GetMonitorInfoData*)_data;
- // only get data for monitor number specified in <data>
- data->monitorNum++;
- if (data->monitorNum == data->requestedMonitor)
- {
- data->bMonitorSpecifiedExists = TRUE;
- data->monitorOffsetX = rect->left;
- data->monitorOffsetY = rect->top;
- data->monitorHeight = rect->bottom - rect->top;
- data->monitorWidth = rect->right - rect->left;
- return FALSE;
- }
- return TRUE;
-}
+/*
+
+Copyright 1993, 1998 The Open Group
+Copyright (C) Colin Harrison 2005-2008
+
+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.
+
+*/
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#ifdef XVENDORNAME
+#define VENDOR_STRING XVENDORNAME
+#define VENDOR_CONTACT BUILDERADDR
+#endif
+#include <../xfree86/common/xorgVersion.h>
+#include "win.h"
+#include "winconfig.h"
+#include "winprefs.h"
+#include "winmsg.h"
+#define COMPILE_MULTIMON_STUBS
+#include <multimon.h>
+/*
+ * References to external symbols
+ */
+
+extern int g_iNumScreens;
+extern winScreenInfo g_ScreenInfo[];
+extern int g_iLastScreen;
+extern Bool g_fInitializedDefaultScreens;
+#ifdef XWIN_CLIPBOARD
+extern Bool g_fUnicodeClipboard;
+extern Bool g_fClipboard;
+#endif
+extern int g_iLogVerbose;
+extern char * g_pszLogFile;
+#ifdef RELOCATE_PROJECTROOT
+extern Bool g_fLogFileChanged;
+#endif
+extern Bool g_fXdmcpEnabled;
+extern Bool g_fAuthEnabled;
+extern char * g_pszCommandLine;
+extern Bool g_fKeyboardHookLL;
+extern Bool g_fNoHelpMessageBox;
+extern Bool g_fSoftwareCursor;
+extern Bool g_fSilentDupError;
+
+/* globals required by callback function for monitor information */
+struct GetMonitorInfoData {
+ int requestedMonitor;
+ int monitorNum;
+ Bool bUserSpecifiedMonitor;
+ Bool bMonitorSpecifiedExists;
+ int monitorOffsetX;
+ int monitorOffsetY;
+ int monitorHeight;
+ int monitorWidth;
+};
+
+wBOOL CALLBACK getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _data);
+
+static Bool QueryMonitor(int index, struct GetMonitorInfoData *data)
+{
+ /* prepare data */
+ if (data == NULL)
+ return FALSE;
+ memset(data, 0, sizeof(*data));
+ data->requestedMonitor = index;
+
+ /* query information */
+ xEnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) data);
+
+ return TRUE;
+}
+
+/*
+ * Function prototypes
+ */
+
+void
+winLogCommandLine (int argc, char *argv[]);
+
+void
+winLogVersionInfo (void);
+
+#ifdef DDXOSVERRORF
+void OsVendorVErrorF (const char *pszFormat, va_list va_args);
+#endif
+
+void
+winInitializeDefaultScreens (void);
+
+/*
+ * Process arguments on the command line
+ */
+
+void
+winInitializeDefaultScreens (void)
+{
+ int i;
+ DWORD dwWidth, dwHeight;
+
+ /* Bail out early if default screens have already been initialized */
+ if (g_fInitializedDefaultScreens)
+ return;
+
+ /* Zero the memory used for storing the screen info */
+ ZeroMemory (g_ScreenInfo, MAXSCREENS * sizeof (winScreenInfo));
+
+ /* Get default width and height */
+ /*
+ * NOTE: These defaults will cause the window to cover only
+ * the primary monitor in the case that we have multiple monitors.
+ */
+ dwWidth = GetSystemMetrics (SM_CXSCREEN);
+ dwHeight = GetSystemMetrics (SM_CYSCREEN);
+
+ winDebug ("winInitializeDefaultScreens - w %d h %d\n",
+ (int) dwWidth, (int) dwHeight);
+
+ /* Set a default DPI, if no parameter was passed */
+ if (monitorResolution == 0)
+ monitorResolution = WIN_DEFAULT_DPI;
+
+ for (i = 0; i < MAXSCREENS; ++i)
+ {
+ g_ScreenInfo[i].dwScreen = i;
+ g_ScreenInfo[i].dwWidth = dwWidth;
+ g_ScreenInfo[i].dwHeight = dwHeight;
+ g_ScreenInfo[i].dwUserWidth = dwWidth;
+ g_ScreenInfo[i].dwUserHeight = dwHeight;
+ g_ScreenInfo[i].fUserGaveHeightAndWidth
+ = WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH;
+ g_ScreenInfo[i].fUserGavePosition = FALSE;
+ g_ScreenInfo[i].dwBPP = WIN_DEFAULT_BPP;
+ g_ScreenInfo[i].dwClipUpdatesNBoxes = WIN_DEFAULT_CLIP_UPDATES_NBOXES;
+#ifdef XWIN_EMULATEPSEUDO
+ g_ScreenInfo[i].fEmulatePseudo = WIN_DEFAULT_EMULATE_PSEUDO;
+#endif
+ g_ScreenInfo[i].dwRefreshRate = WIN_DEFAULT_REFRESH;
+ g_ScreenInfo[i].pfb = NULL;
+ g_ScreenInfo[i].fFullScreen = FALSE;
+ g_ScreenInfo[i].fDecoration = TRUE;
+#ifdef XWIN_MULTIWINDOWEXTWM
+ g_ScreenInfo[i].fMWExtWM = FALSE;
+ g_ScreenInfo[i].fInternalWM = FALSE;
+#endif
+ g_ScreenInfo[i].fRootless = FALSE;
+#ifdef XWIN_MULTIWINDOW
+ g_ScreenInfo[i].fMultiWindow = FALSE;
+#endif
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ g_ScreenInfo[i].fMultiMonitorOverride = FALSE;
+#endif
+ g_ScreenInfo[i].fMultipleMonitors = FALSE;
+ g_ScreenInfo[i].fLessPointer = FALSE;
+ g_ScreenInfo[i].fScrollbars = FALSE;
+ g_ScreenInfo[i].fNoTrayIcon = FALSE;
+ g_ScreenInfo[i].iE3BTimeout = WIN_E3B_OFF;
+ g_ScreenInfo[i].dwWidth_mm = (dwWidth / WIN_DEFAULT_DPI)
+ * 25.4;
+ g_ScreenInfo[i].dwHeight_mm = (dwHeight / WIN_DEFAULT_DPI)
+ * 25.4;
+ g_ScreenInfo[i].fUseWinKillKey = WIN_DEFAULT_WIN_KILL;
+ g_ScreenInfo[i].fUseUnixKillKey = WIN_DEFAULT_UNIX_KILL;
+ g_ScreenInfo[i].fIgnoreInput = FALSE;
+ g_ScreenInfo[i].fExplicitScreen = FALSE;
+ }
+
+ /* Signal that the default screens have been initialized */
+ g_fInitializedDefaultScreens = TRUE;
+
+ winDebug ("winInitializeDefaultScreens - Returning\n");
+}
+
+/* See Porting Layer Definition - p. 57 */
+/*
+ * INPUT
+ * argv: pointer to an array of null-terminated strings, one for
+ * each token in the X Server command line; the first token
+ * is 'XWin.exe', or similar.
+ * argc: a count of the number of tokens stored in argv.
+ * i: a zero-based index into argv indicating the current token being
+ * processed.
+ *
+ * OUTPUT
+ * return: return the number of tokens processed correctly.
+ *
+ * NOTE
+ * When looking for n tokens, check that i + n is less than argc. Or,
+ * you may check if i is greater than or equal to argc, in which case
+ * you should display the UseMsg () and return 0.
+ */
+
+/* Check if enough arguments are given for the option */
+#define CHECK_ARGS(count) if (i + count >= argc) { UseMsg (); return 0; }
+
+/* Compare the current option with the string. */
+#define IS_OPTION(name) (strcmp (argv[i], name) == 0)
+
+int
+ddxProcessArgument (int argc, char *argv[], int i)
+{
+ static Bool s_fBeenHere = FALSE;
+
+ /* Initialize once */
+ if (!s_fBeenHere)
+ {
+#ifdef DDXOSVERRORF
+ /*
+ * This initialises our hook into VErrorF () for catching log messages
+ * that are generated before OsInit () is called.
+ */
+ OsVendorVErrorFProc = OsVendorVErrorF;
+#endif
+
+ s_fBeenHere = TRUE;
+
+ /* Initialize only if option is not -help */
+ if (!IS_OPTION("-help") && !IS_OPTION("-h") && !IS_OPTION("--help") &&
+ !IS_OPTION("-version") && !IS_OPTION("--version"))
+ {
+
+ /* Log the version information */
+ winLogVersionInfo ();
+
+ /* Log the command line */
+ winLogCommandLine (argc, argv);
+
+ /*
+ * Initialize default screen settings. We have to do this before
+ * OsVendorInit () gets called, otherwise we will overwrite
+ * settings changed by parameters such as -fullscreen, etc.
+ */
+ winDebug ("ddxProcessArgument - Initializing default "
+ "screens\n");
+ winInitializeDefaultScreens ();
+ }
+ }
+
+ winDebug ("ddxProcessArgument - arg: %s\n", argv[i]);
+
+ /*
+ * Look for the '-help' and similar options
+ */
+ if (IS_OPTION ("-help") || IS_OPTION("-h") || IS_OPTION("--help"))
+ {
+ /* Reset logfile. We don't need that helpmessage in the logfile */
+ g_pszLogFile = NULL;
+ g_fNoHelpMessageBox = TRUE;
+ UseMsg();
+ exit (0);
+ return 1;
+ }
+
+ if (IS_OPTION ("-version") || IS_OPTION("--version"))
+ {
+ /* Reset logfile. We don't need that versioninfo in the logfile */
+ g_pszLogFile = NULL;
+ winLogVersionInfo ();
+ exit (0);
+ return 1;
+ }
+
+ /*
+ * Look for the '-screen scr_num [width height]' argument
+ */
+ if (IS_OPTION ("-screen"))
+ {
+ int iArgsProcessed = 1;
+ int nScreenNum;
+ int iWidth, iHeight, iX, iY;
+ int iMonitor;
+
+ winDebug ("ddxProcessArgument - screen - argc: %d i: %d\n",
+ argc, i);
+
+ /* Display the usage message if the argument is malformed */
+ if (i + 1 >= argc)
+ {
+ return 0;
+ }
+
+ /* Grab screen number */
+ nScreenNum = atoi (argv[i + 1]);
+
+ /* Validate the specified screen number */
+ if (nScreenNum < 0 || nScreenNum >= MAXSCREENS)
+ {
+ ErrorF ("ddxProcessArgument - screen - Invalid screen number %d\n",
+ nScreenNum);
+ UseMsg ();
+ return 0;
+ }
+
+ /* look for @m where m is monitor number */
+ if (i + 2 < argc
+ && 1 == sscanf(argv[i + 2], "@%d", (int *) &iMonitor))
+ {
+ struct GetMonitorInfoData data;
+ if (!QueryMonitor(iMonitor, &data))
+ {
+ ErrorF ("ddxProcessArgument - screen - "
+ "Querying monitors is not supported on NT4 and Win95\n");
+ } else if (data.bMonitorSpecifiedExists == TRUE)
+ {
+ winDebug("ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor);
+ iArgsProcessed = 3;
+ g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE;
+ g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
+ g_ScreenInfo[nScreenNum].dwWidth = data.monitorWidth;
+ g_ScreenInfo[nScreenNum].dwHeight = data.monitorHeight;
+ g_ScreenInfo[nScreenNum].dwUserWidth = data.monitorWidth;
+ g_ScreenInfo[nScreenNum].dwUserHeight = data.monitorHeight;
+ g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX;
+ g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY;
+ }
+ else
+ {
+ /* monitor does not exist, error out */
+ ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
+ iMonitor);
+ UseMsg ();
+ exit (0);
+ return 0;
+ }
+ }
+
+ /* Look for 'WxD' or 'W D' */
+ else if (i + 2 < argc
+ && 2 == sscanf (argv[i + 2], "%dx%d",
+ (int *) &iWidth,
+ (int *) &iHeight))
+ {
+ winDebug ("ddxProcessArgument - screen - Found ``WxD'' arg\n");
+ iArgsProcessed = 3;
+ g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE;
+ g_ScreenInfo[nScreenNum].dwWidth = iWidth;
+ g_ScreenInfo[nScreenNum].dwHeight = iHeight;
+ g_ScreenInfo[nScreenNum].dwUserWidth = iWidth;
+ g_ScreenInfo[nScreenNum].dwUserHeight = iHeight;
+ /* Look for WxD+X+Y */
+ if (2 == sscanf (argv[i + 2], "%*dx%*d+%d+%d",
+ (int *) &iX,
+ (int *) &iY))
+ {
+ winDebug("ddxProcessArgument - screen - Found ``X+Y'' arg\n");
+ g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
+ g_ScreenInfo[nScreenNum].dwInitialX = iX;
+ g_ScreenInfo[nScreenNum].dwInitialY = iY;
+
+ /* look for WxD+X+Y@m where m is monitor number. take X,Y to be offsets from monitor's root position */
+ if (1 == sscanf (argv[i + 2], "%*dx%*d+%*d+%*d@%d",
+ (int *) &iMonitor))
+ {
+ struct GetMonitorInfoData data;
+ if (!QueryMonitor(iMonitor, &data))
+ {
+ ErrorF ("ddxProcessArgument - screen - "
+ "Querying monitors is not supported on NT4 and Win95\n");
+ } else if (data.bMonitorSpecifiedExists == TRUE)
+ {
+ g_ScreenInfo[nScreenNum].dwInitialX += data.monitorOffsetX;
+ g_ScreenInfo[nScreenNum].dwInitialY += data.monitorOffsetY;
+ }
+ else
+ {
+ /* monitor does not exist, error out */
+ ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
+ iMonitor);
+ UseMsg ();
+ exit (0);
+ return 0;
+ }
+
+ }
+ }
+
+ /* look for WxD@m where m is monitor number */
+ else if (1 == sscanf(argv[i + 2], "%*dx%*d@%d",
+ (int *) &iMonitor))
+ {
+ struct GetMonitorInfoData data;
+ if (!QueryMonitor(iMonitor, &data))
+ {
+ ErrorF ("ddxProcessArgument - screen - "
+ "Querying monitors is not supported on NT4 and Win95\n");
+ } else if (data.bMonitorSpecifiedExists == TRUE)
+ {
+ winDebug ("ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor);
+ g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
+ g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX;
+ g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY;
+ }
+ else
+ {
+ /* monitor does not exist, error out */
+ ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
+ iMonitor);
+ UseMsg ();
+ exit (0);
+ return 0;
+ }
+
+ }
+ }
+ else if (i + 3 < argc
+ && 1 == sscanf (argv[i + 2], "%d",
+ (int *) &iWidth)
+ && 1 == sscanf (argv[i + 3], "%d",
+ (int *) &iHeight))
+ {
+ winDebug ("ddxProcessArgument - screen - Found ``W D'' arg\n");
+ iArgsProcessed = 4;
+ g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE;
+ g_ScreenInfo[nScreenNum].dwWidth = iWidth;
+ g_ScreenInfo[nScreenNum].dwHeight = iHeight;
+ g_ScreenInfo[nScreenNum].dwUserWidth = iWidth;
+ g_ScreenInfo[nScreenNum].dwUserHeight = iHeight;
+ if (i + 5 < argc
+ && 1 == sscanf (argv[i + 4], "%d",
+ (int *) &iX)
+ && 1 == sscanf (argv[i + 5], "%d",
+ (int *) &iY))
+ {
+ winDebug ("ddxProcessArgument - screen - Found ``X Y'' arg\n");
+ iArgsProcessed = 6;
+ g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
+ g_ScreenInfo[nScreenNum].dwInitialX = iX;
+ g_ScreenInfo[nScreenNum].dwInitialY = iY;
+ }
+ }
+ else
+ {
+ ErrorF ("ddxProcessArgument - screen - Did not find size arg. "
+ "dwWidth: %d dwHeight: %d\n",
+ (int) g_ScreenInfo[nScreenNum].dwWidth,
+ (int) g_ScreenInfo[nScreenNum].dwHeight);
+ iArgsProcessed = 2;
+ g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE;
+ }
+
+ /* Calculate the screen width and height in millimeters */
+ if (g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth)
+ {
+ g_ScreenInfo[nScreenNum].dwWidth_mm
+ = (g_ScreenInfo[nScreenNum].dwWidth
+ / monitorResolution) * 25.4;
+ g_ScreenInfo[nScreenNum].dwHeight_mm
+ = (g_ScreenInfo[nScreenNum].dwHeight
+ / monitorResolution) * 25.4;
+ }
+
+ /* Flag that this screen was explicity specified by the user */
+ g_ScreenInfo[nScreenNum].fExplicitScreen = TRUE;
+
+ /*
+ * Keep track of the last screen number seen, as parameters seen
+ * before a screen number apply to all screens, whereas parameters
+ * seen after a screen number apply to that screen number only.
+ */
+ g_iLastScreen = nScreenNum;
+
+ /* Keep a count of the number of screens */
+ ++g_iNumScreens;
+
+ return iArgsProcessed;
+ }
+
+ /*
+ * Look for the '-engine n' argument
+ */
+ if (IS_OPTION ("-engine"))
+ {
+ DWORD dwEngine = 0;
+ CARD8 c8OnBits = 0;
+
+ /* Display the usage message if the argument is malformed */
+ if (++i >= argc)
+ {
+ UseMsg ();
+ return 0;
+ }
+
+ /* Grab the argument */
+ dwEngine = atoi (argv[i]);
+
+ /* Count the one bits in the engine argument */
+ c8OnBits = winCountBits (dwEngine);
+
+ /* Argument should only have a single bit on */
+ if (c8OnBits != 1)
+ {
+ UseMsg ();
+ return 0;
+ }
+
+ /* Is this parameter attached to a screen or global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].dwEnginePreferred = dwEngine;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].dwEnginePreferred = dwEngine;
+ }
+
+ /* Indicate that we have processed the argument */
+ return 2;
+ }
+
+ /*
+ * Look for the '-fullscreen' argument
+ */
+ if (IS_OPTION ("-fullscreen"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ if (!g_ScreenInfo[j].fMultiMonitorOverride)
+ g_ScreenInfo[j].fMultipleMonitors = FALSE;
+#endif
+ g_ScreenInfo[j].fFullScreen = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
+ g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE;
+#endif
+ g_ScreenInfo[g_iLastScreen].fFullScreen = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-lesspointer' argument
+ */
+ if (IS_OPTION ("-lesspointer"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fLessPointer = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fLessPointer = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-nodecoration' argument
+ */
+ if (IS_OPTION ("-nodecoration"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ if (!g_ScreenInfo[j].fMultiMonitorOverride)
+ g_ScreenInfo[j].fMultipleMonitors = FALSE;
+#endif
+ g_ScreenInfo[j].fDecoration = FALSE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
+ g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE;
+#endif
+ g_ScreenInfo[g_iLastScreen].fDecoration = FALSE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+ /*
+ * Look for the '-mwextwm' argument
+ */
+ if (IS_OPTION ("-mwextwm"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ if (!g_ScreenInfo[j].fMultiMonitorOverride)
+ g_ScreenInfo[j].fMultipleMonitors = TRUE;
+ g_ScreenInfo[j].fMWExtWM = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
+ g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE;
+ g_ScreenInfo[g_iLastScreen].fMWExtWM = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+ /*
+ * Look for the '-internalwm' argument
+ */
+ if (IS_OPTION ("-internalwm"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ if (!g_ScreenInfo[j].fMultiMonitorOverride)
+ g_ScreenInfo[j].fMultipleMonitors = TRUE;
+ g_ScreenInfo[j].fMWExtWM = TRUE;
+ g_ScreenInfo[j].fInternalWM = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
+ g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE;
+ g_ScreenInfo[g_iLastScreen].fMWExtWM = TRUE;
+ g_ScreenInfo[g_iLastScreen].fInternalWM = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+#endif
+
+ /*
+ * Look for the '-rootless' argument
+ */
+ if (IS_OPTION ("-rootless"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ if (!g_ScreenInfo[j].fMultiMonitorOverride)
+ g_ScreenInfo[j].fMultipleMonitors = FALSE;
+#endif
+ g_ScreenInfo[j].fRootless = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
+ g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE;
+#endif
+ g_ScreenInfo[g_iLastScreen].fRootless = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+#ifdef XWIN_MULTIWINDOW
+ /*
+ * Look for the '-multiwindow' argument
+ */
+ if (IS_OPTION ("-multiwindow"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ if (!g_ScreenInfo[j].fMultiMonitorOverride)
+ g_ScreenInfo[j].fMultipleMonitors = TRUE;
+#endif
+ g_ScreenInfo[j].fMultiWindow = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
+ g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE;
+#endif
+ g_ScreenInfo[g_iLastScreen].fMultiWindow = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+#endif
+
+ /*
+ * Look for the '-multiplemonitors' argument
+ */
+ if (IS_OPTION ("-multiplemonitors")
+ || IS_OPTION ("-multimonitors"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ g_ScreenInfo[j].fMultiMonitorOverride = TRUE;
+#endif
+ g_ScreenInfo[j].fMultipleMonitors = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride = TRUE;
+#endif
+ g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-nomultiplemonitors' argument
+ */
+ if (IS_OPTION ("-nomultiplemonitors")
+ || IS_OPTION ("-nomultimonitors"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ g_ScreenInfo[j].fMultiMonitorOverride = TRUE;
+#endif
+ g_ScreenInfo[j].fMultipleMonitors = FALSE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride = TRUE;
+#endif
+ g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+
+ /*
+ * Look for the '-scrollbars' argument
+ */
+ if (IS_OPTION ("-scrollbars"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fScrollbars = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fScrollbars = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+
+#ifdef XWIN_CLIPBOARD
+ /*
+ * Look for the '-clipboard' argument
+ */
+ if (IS_OPTION ("-clipboard"))
+ {
+ /* Now the default, we still accept the arg for backwards compatibility */
+ g_fClipboard = TRUE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-noclipboard' argument
+ */
+ if (IS_OPTION ("-noclipboard"))
+ {
+ g_fClipboard = FALSE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+#endif
+
+
+ /*
+ * Look for the '-ignoreinput' argument
+ */
+ if (IS_OPTION ("-ignoreinput"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fIgnoreInput = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fIgnoreInput = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-emulate3buttons' argument
+ */
+ if (IS_OPTION ("-emulate3buttons"))
+ {
+ int iArgsProcessed = 1;
+ int iE3BTimeout = WIN_DEFAULT_E3B_TIME;
+
+ /* Grab the optional timeout value */
+ if (i + 1 < argc
+ && 1 == sscanf (argv[i + 1], "%d",
+ &iE3BTimeout))
+ {
+ /* Indicate that we have processed the next argument */
+ iArgsProcessed++;
+ }
+ else
+ {
+ /*
+ * sscanf () won't modify iE3BTimeout if it doesn't find
+ * the specified format; however, I want to be explicit
+ * about setting the default timeout in such cases to
+ * prevent some programs (me) from getting confused.
+ */
+ iE3BTimeout = WIN_DEFAULT_E3B_TIME;
+ }
+
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].iE3BTimeout = iE3BTimeout;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].iE3BTimeout = iE3BTimeout;
+ }
+
+ /* Indicate that we have processed this argument */
+ return iArgsProcessed;
+ }
+
+ /*
+ * Look for the '-depth n' argument
+ */
+ if (IS_OPTION ("-depth"))
+ {
+ DWORD dwBPP = 0;
+
+ /* Display the usage message if the argument is malformed */
+ if (++i >= argc)
+ {
+ UseMsg ();
+ return 0;
+ }
+
+ /* Grab the argument */
+ dwBPP = atoi (argv[i]);
+
+ /* Is this parameter attached to a screen or global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].dwBPP = dwBPP;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].dwBPP = dwBPP;
+ }
+
+ /* Indicate that we have processed the argument */
+ return 2;
+ }
+
+ /*
+ * Look for the '-refresh n' argument
+ */
+ if (IS_OPTION ("-refresh"))
+ {
+ DWORD dwRefreshRate = 0;
+
+ /* Display the usage message if the argument is malformed */
+ if (++i >= argc)
+ {
+ UseMsg ();
+ return 0;
+ }
+
+ /* Grab the argument */
+ dwRefreshRate = atoi (argv[i]);
+
+ /* Is this parameter attached to a screen or global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].dwRefreshRate = dwRefreshRate;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].dwRefreshRate = dwRefreshRate;
+ }
+
+ /* Indicate that we have processed the argument */
+ return 2;
+ }
+
+ /*
+ * Look for the '-clipupdates num_boxes' argument
+ */
+ if (IS_OPTION ("-clipupdates"))
+ {
+ DWORD dwNumBoxes = 0;
+
+ /* Display the usage message if the argument is malformed */
+ if (++i >= argc)
+ {
+ UseMsg ();
+ return 0;
+ }
+
+ /* Grab the argument */
+ dwNumBoxes = atoi (argv[i]);
+
+ /* Is this parameter attached to a screen or global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].dwClipUpdatesNBoxes = dwNumBoxes;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].dwClipUpdatesNBoxes = dwNumBoxes;
+ }
+
+ /* Indicate that we have processed the argument */
+ return 2;
+ }
+
+#ifdef XWIN_EMULATEPSEUDO
+ /*
+ * Look for the '-emulatepseudo' argument
+ */
+ if (IS_OPTION ("-emulatepseudo"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fEmulatePseudo = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fEmulatePseudo = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+#endif
+
+ /*
+ * Look for the '-nowinkill' argument
+ */
+ if (IS_OPTION ("-nowinkill"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fUseWinKillKey = FALSE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fUseWinKillKey = FALSE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-winkill' argument
+ */
+ if (IS_OPTION ("-winkill"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fUseWinKillKey = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fUseWinKillKey = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-nounixkill' argument
+ */
+ if (IS_OPTION ("-nounixkill"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fUseUnixKillKey = FALSE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fUseUnixKillKey = FALSE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-unixkill' argument
+ */
+ if (IS_OPTION ("-unixkill"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fUseUnixKillKey = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fUseUnixKillKey = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-notrayicon' argument
+ */
+ if (IS_OPTION ("-notrayicon"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fNoTrayIcon = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fNoTrayIcon = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-trayicon' argument
+ */
+ if (IS_OPTION ("-trayicon"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fNoTrayIcon = FALSE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fNoTrayIcon = FALSE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-fp' argument
+ */
+ if (IS_OPTION ("-fp"))
+ {
+ CHECK_ARGS (1);
+ g_cmdline.fontPath = argv[++i];
+ return 0; /* Let DIX parse this again */
+ }
+
+ /*
+ * Look for the '-query' argument
+ */
+ if (IS_OPTION ("-query"))
+ {
+ CHECK_ARGS (1);
+ g_fXdmcpEnabled = TRUE;
+ g_pszQueryHost = argv[++i];
+ return 0; /* Let DIX parse this again */
+ }
+
+ /*
+ * Look for the '-auth' argument
+ */
+ if (IS_OPTION ("-auth"))
+ {
+ g_fAuthEnabled = TRUE;
+ return 0; /* Let DIX parse this again */
+ }
+
+ /*
+ * Look for the '-indirect' or '-broadcast' arguments
+ */
+ if (IS_OPTION ("-indirect")
+ || IS_OPTION ("-broadcast"))
+ {
+ g_fXdmcpEnabled = TRUE;
+ return 0; /* Let DIX parse this again */
+ }
+
+ /*
+ * Look for the '-config' argument
+ */
+ if (IS_OPTION ("-config")
+ || IS_OPTION ("-xf86config"))
+ {
+ CHECK_ARGS (1);
+#ifdef XWIN_XF86CONFIG
+ g_cmdline.configFile = argv[++i];
+#else
+ winMessageBoxF ("The %s option is not supported in this "
+ "release.\n"
+ "Ignoring this option and continuing.\n",
+ MB_ICONINFORMATION,
+ argv[i]);
+#endif
+ return 2;
+ }
+
+ /*
+ * Look for the '-keyboard' argument
+ */
+ if (IS_OPTION ("-keyboard"))
+ {
+#ifdef XWIN_XF86CONFIG
+ CHECK_ARGS (1);
+ g_cmdline.keyboard = argv[++i];
+#else
+ winMessageBoxF ("The -keyboard option is not supported in this "
+ "release.\n"
+ "Ignoring this option and continuing.\n",
+ MB_ICONINFORMATION);
+#endif
+ return 2;
+ }
+
+ /*
+ * Look for the '-logfile' argument
+ */
+ if (IS_OPTION ("-logfile"))
+ {
+ CHECK_ARGS (1);
+ g_pszLogFile = argv[++i];
+#ifdef RELOCATE_PROJECTROOT
+ g_fLogFileChanged = TRUE;
+#endif
+ return 2;
+ }
+
+ /*
+ * Look for the '-logverbose' argument
+ */
+ if (IS_OPTION ("-logverbose"))
+ {
+ CHECK_ARGS (1);
+ g_iLogVerbose = atoi(argv[++i]);
+ return 2;
+ }
+
+#ifdef XWIN_CLIPBOARD
+ /*
+ * Look for the '-nounicodeclipboard' argument
+ */
+ if (IS_OPTION ("-nounicodeclipboard"))
+ {
+ g_fUnicodeClipboard = FALSE;
+ /* Indicate that we have processed the argument */
+ return 1;
+ }
+#endif
+
+ if (IS_OPTION ("-xkbrules"))
+ {
+ CHECK_ARGS (1);
+ g_cmdline.xkbRules = argv[++i];
+ return 2;
+ }
+ if (IS_OPTION ("-xkbmodel"))
+ {
+ CHECK_ARGS (1);
+ g_cmdline.xkbModel = argv[++i];
+ return 2;
+ }
+ if (IS_OPTION ("-xkblayout"))
+ {
+ CHECK_ARGS (1);
+ g_cmdline.xkbLayout = argv[++i];
+ return 2;
+ }
+ if (IS_OPTION ("-xkbvariant"))
+ {
+ CHECK_ARGS (1);
+ g_cmdline.xkbVariant = argv[++i];
+ return 2;
+ }
+ if (IS_OPTION ("-xkboptions"))
+ {
+ CHECK_ARGS (1);
+ g_cmdline.xkbOptions = argv[++i];
+ return 2;
+ }
+
+ if (IS_OPTION ("-keyhook"))
+ {
+ g_fKeyboardHookLL = TRUE;
+ return 1;
+ }
+
+ if (IS_OPTION ("-nokeyhook"))
+ {
+ g_fKeyboardHookLL = FALSE;
+ return 1;
+ }
+
+ if (IS_OPTION ("-swcursor"))
+ {
+ g_fSoftwareCursor = TRUE;
+ return 1;
+ }
+
+ if (IS_OPTION ("-silent-dup-error"))
+ {
+ g_fSilentDupError = TRUE;
+ return 1;
+ }
+ return 0;
+}
+
+
+/*
+ * winLogCommandLine - Write entire command line to the log file
+ */
+
+void
+winLogCommandLine (int argc, char *argv[])
+{
+ int i;
+ int iSize = 0;
+ int iCurrLen = 0;
+
+#define CHARS_PER_LINE 60
+
+ /* Bail if command line has already been logged */
+ if (g_pszCommandLine)
+ return;
+
+ /* Count how much memory is needed for concatenated command line */
+ for (i = 0, iCurrLen = 0; i < argc; ++i)
+ if (argv[i])
+ {
+ /* Adds two characters for lines that overflow */
+ if ((strlen (argv[i]) < CHARS_PER_LINE
+ && iCurrLen + strlen (argv[i]) > CHARS_PER_LINE)
+ || strlen (argv[i]) > CHARS_PER_LINE)
+ {
+ iCurrLen = 0;
+ iSize += 2;
+ }
+
+ /* Add space for item and trailing space */
+ iSize += strlen (argv[i]) + 1;
+
+ /* Update current line length */
+ iCurrLen += strlen (argv[i]);
+ }
+
+ /* Allocate memory for concatenated command line */
+ g_pszCommandLine = malloc (iSize + 1);
+ if (!g_pszCommandLine)
+ FatalError ("winLogCommandLine - Could not allocate memory for "
+ "command line string. Exiting.\n");
+
+ /* Set first character to concatenated command line to null */
+ g_pszCommandLine[0] = '\0';
+
+ /* Loop through all args */
+ for (i = 0, iCurrLen = 0; i < argc; ++i)
+ {
+ /* Add a character for lines that overflow */
+ if ((strlen (argv[i]) < CHARS_PER_LINE
+ && iCurrLen + strlen (argv[i]) > CHARS_PER_LINE)
+ || strlen (argv[i]) > CHARS_PER_LINE)
+ {
+ iCurrLen = 0;
+
+ /* Add line break if it fits */
+ strncat (g_pszCommandLine, "\n ", iSize - strlen (g_pszCommandLine));
+ }
+
+ strncat (g_pszCommandLine, argv[i], iSize - strlen (g_pszCommandLine));
+ strncat (g_pszCommandLine, " ", iSize - strlen (g_pszCommandLine));
+
+ /* Save new line length */
+ iCurrLen += strlen (argv[i]);
+ }
+
+ winDebug ("XWin was started with the following command line:\n\n"
+ "%s\n\n", g_pszCommandLine);
+}
+
+
+/*
+ * winLogVersionInfo - Log Cygwin/X version information
+ */
+
+void
+winLogVersionInfo (void)
+{
+#ifdef WINDBG
+ static Bool s_fBeenHere = FALSE;
+
+ if (s_fBeenHere)
+ return;
+ s_fBeenHere = TRUE;
+
+ winDebug ("Welcome to the VcXsrv X Server\n");
+ winDebug ("Vendor: %s\n", VENDOR_STRING);
+ winDebug ("Release: %d.%d.%d.%d (%d)\n\n", XORG_VERSION_MAJOR, XORG_VERSION_MINOR, XORG_VERSION_PATCH, XORG_VERSION_SNAP, XORG_VERSION_CURRENT);
+ winDebug ("Contact: %s\n\n", VENDOR_CONTACT);
+#endif
+}
+/*
+ * getMonitorInfo - callback function used to return information from the enumeration of monitors attached
+ */
+
+wBOOL CALLBACK getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _data)
+{
+ struct GetMonitorInfoData* data = (struct GetMonitorInfoData*)_data;
+ // only get data for monitor number specified in <data>
+ data->monitorNum++;
+ if (data->monitorNum == data->requestedMonitor)
+ {
+ data->bMonitorSpecifiedExists = TRUE;
+ data->monitorOffsetX = rect->left;
+ data->monitorOffsetY = rect->top;
+ data->monitorHeight = rect->bottom - rect->top;
+ data->monitorWidth = rect->right - rect->left;
+ return FALSE;
+ }
+ return TRUE;
+}
diff --git a/xorg-server/hw/xwin/winregistry.c b/xorg-server/hw/xwin/winregistry.c
index 3571b14d7..898ed978b 100644
--- a/xorg-server/hw/xwin/winregistry.c
+++ b/xorg-server/hw/xwin/winregistry.c
@@ -55,11 +55,11 @@ winGetRegistryDWORD (HKEY hkey, char *pszRegistryKey)
if (dwDisposition == REG_CREATED_NEW_KEY)
{
- ErrorF ("winGetRegistryDWORD - Created new key: %s\n", pszRegistryKey);
+ winDebug ("winGetRegistryDWORD - Created new key: %s\n", pszRegistryKey);
}
else if (dwDisposition == REG_OPENED_EXISTING_KEY)
{
- ErrorF ("winGetRegistryDWORD - Opened existing key: %s\n",
+ winDebug ("winGetRegistryDWORD - Opened existing key: %s\n",
pszRegistryKey);
}
diff --git a/xorg-server/hw/xwin/winscrinit.c b/xorg-server/hw/xwin/winscrinit.c
index 37ec27e08..db65a5eed 100644
--- a/xorg-server/hw/xwin/winscrinit.c
+++ b/xorg-server/hw/xwin/winscrinit.c
@@ -1,790 +1,777 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, 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 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 XFREE86 PROJECT 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 XFree86 Project
- *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 XFree86 Project.
- *
- * Authors: Dakshinamurthy Karra
- * Suhaib M Siddiqi
- * Peter Busch
- * Harold L Hunt II
- * Kensuke Matsuzaki
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-#include "winmsg.h"
-
-
-#ifdef XWIN_MULTIWINDOWEXTWM
-static RootlessFrameProcsRec
-winMWExtWMProcs = {
- winMWExtWMCreateFrame,
- winMWExtWMDestroyFrame,
-
- winMWExtWMMoveFrame,
- winMWExtWMResizeFrame,
- winMWExtWMRestackFrame,
- winMWExtWMReshapeFrame,
- winMWExtWMUnmapFrame,
-
- winMWExtWMStartDrawing,
- winMWExtWMStopDrawing,
- winMWExtWMUpdateRegion,
-#ifndef ROOTLESS_TRACK_DAMAGE
- winMWExtWMDamageRects,
-#endif
- winMWExtWMRootlessSwitchWindow,
- NULL,//winMWExtWMDoReorderWindow,
- NULL,//winMWExtWMHideWindow,
- NULL,//winMWExtWMUpdateColorMap,
-
- NULL,//winMWExtWMCopyBytes,
- NULL,//winMWExtWMFillBytes,
- NULL,//winMWExtWMCompositePixels,
- winMWExtWMCopyWindow
-};
-#endif
-
-
-/*
- * References to external symbols
- */
-
-extern Bool g_fSoftwareCursor;
-
-
-/*
- * Prototypes
- */
-
-Bool
-winRandRInit (ScreenPtr pScreen);
-
-
-/*
- * Local functions
- */
-
-static Bool
-winSaveScreen (ScreenPtr pScreen, int on);
-
-
-/*
- * Determine what type of screen we are initializing
- * and call the appropriate procedure to intiailize
- * that type of screen.
- */
-
-Bool
-winScreenInit (int index,
- ScreenPtr pScreen,
- int argc, char **argv)
-{
- winScreenInfoPtr pScreenInfo = &g_ScreenInfo[index];
- winPrivScreenPtr pScreenPriv;
- HDC hdc;
-
-#if CYGDEBUG || YES
- winDebug ("winScreenInit - dwWidth: %ld dwHeight: %ld\n",
- pScreenInfo->dwWidth, pScreenInfo->dwHeight);
-#endif
-
- /* Allocate privates for this screen */
- if (!winAllocatePrivates (pScreen))
- {
- ErrorF ("winScreenInit - Couldn't allocate screen privates\n");
- return FALSE;
- }
-
- /* Get a pointer to the privates structure that was allocated */
- pScreenPriv = winGetScreenPriv (pScreen);
-
- /* Save a pointer to this screen in the screen info structure */
- pScreenInfo->pScreen = pScreen;
-
- /* Save a pointer to the screen info in the screen privates structure */
- /* This allows us to get back to the screen info from a screen pointer */
- pScreenPriv->pScreenInfo = pScreenInfo;
-
- /*
- * Determine which engine to use.
- *
- * NOTE: This is done once per screen because each screen possibly has
- * a preferred engine specified on the command line.
- */
- if (!winSetEngine (pScreen))
- {
- ErrorF ("winScreenInit - winSetEngine () failed\n");
- return FALSE;
- }
-
- /* Adjust the video mode for our engine type */
- if (!(*pScreenPriv->pwinAdjustVideoMode) (pScreen))
- {
- ErrorF ("winScreenInit - winAdjustVideoMode () failed\n");
- return FALSE;
- }
-
- /* Check for supported display depth */
- if (!(WIN_SUPPORTED_BPPS & (1 << (pScreenInfo->dwBPP - 1))))
- {
- ErrorF ("winScreenInit - Unsupported display depth: %d\n" \
- "Change your Windows display depth to 15, 16, 24, or 32 bits "
- "per pixel.\n",
- (int) pScreenInfo->dwBPP);
- ErrorF ("winScreenInit - Supported depths: %08x\n",
- WIN_SUPPORTED_BPPS);
-#if WIN_CHECK_DEPTH
- return FALSE;
-#endif
- }
-
- /*
- * Check that all monitors have the same display depth if we are using
- * multiple monitors
- */
- if (pScreenInfo->fMultipleMonitors
- && !GetSystemMetrics (SM_SAMEDISPLAYFORMAT))
- {
- ErrorF ("winScreenInit - Monitors do not all have same pixel format / "
- "display depth.\n"
- "Using primary display only.\n");
- pScreenInfo->fMultipleMonitors = FALSE;
- }
-
- /* Create display window */
- if (!(*pScreenPriv->pwinCreateBoundingWindow) (pScreen))
- {
- ErrorF ("winScreenInit - pwinCreateBoundingWindow () "
- "failed\n");
- return FALSE;
- }
-
- /* Get a device context */
- hdc = GetDC (pScreenPriv->hwndScreen);
-
- /* Store the initial height, width, and depth of the display */
- /* Are we using multiple monitors? */
- if (pScreenInfo->fMultipleMonitors)
- {
- pScreenPriv->dwLastWindowsWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN);
- pScreenPriv->dwLastWindowsHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN);
-
- /*
- * In this case, some of the defaults set in
- * winInitializeDefaultScreens () are not correct ...
- */
- if (!pScreenInfo->fUserGaveHeightAndWidth)
- {
- pScreenInfo->dwWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN);
- pScreenInfo->dwHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN);
- pScreenInfo->dwWidth_mm = (pScreenInfo->dwWidth /
- WIN_DEFAULT_DPI) * 25.4;
- pScreenInfo->dwHeight_mm = (pScreenInfo->dwHeight /
- WIN_DEFAULT_DPI) * 25.4;
- }
- }
- else
- {
- pScreenPriv->dwLastWindowsWidth = GetSystemMetrics (SM_CXSCREEN);
- pScreenPriv->dwLastWindowsHeight = GetSystemMetrics (SM_CYSCREEN);
- }
-
- /* Save the original bits per pixel */
- pScreenPriv->dwLastWindowsBitsPixel = GetDeviceCaps (hdc, BITSPIXEL);
-
- /* Release the device context */
- ReleaseDC (pScreenPriv->hwndScreen, hdc);
-
- /* Clear the visuals list */
- miClearVisualTypes ();
-
- /* Set the padded screen width */
- pScreenInfo->dwPaddedWidth = PixmapBytePad (pScreenInfo->dwWidth,
- pScreenInfo->dwBPP);
-
- /* Call the engine dependent screen initialization procedure */
- if (!((*pScreenPriv->pwinFinishScreenInit) (index, pScreen, argc, argv)))
- {
- ErrorF ("winScreenInit - winFinishScreenInit () failed\n");
- return FALSE;
- }
-
- if (!g_fSoftwareCursor)
- winInitCursor(pScreen);
- else
- winErrorFVerb(2, "winScreenInit - Using software cursor\n");
-
- /*
- Note the screen origin in a normalized coordinate space where (0,0) is at the top left
- of the native virtual desktop area
- */
- dixScreenOrigins[index].x = pScreenInfo->dwInitialX - GetSystemMetrics(SM_XVIRTUALSCREEN);
- dixScreenOrigins[index].y = pScreenInfo->dwInitialY - GetSystemMetrics(SM_YVIRTUALSCREEN);
-
- ErrorF("Screen %d added at XINERAMA coordinate (%d,%d).\n",
- index, dixScreenOrigins[index].x, dixScreenOrigins[index].y);
-
-#if CYGDEBUG || YES
- winDebug ("winScreenInit - returning\n");
-#endif
-
- return TRUE;
-}
-
-static Bool
-winCreateScreenResources(ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- Bool result;
-
- result = pScreenPriv->pwinCreateScreenResources(pScreen);
-
- /* Now the screen bitmap has been wrapped in a pixmap,
- add that to the Shadow framebuffer */
- if (!shadowAdd(pScreen, pScreen->devPrivate,
- pScreenPriv->pwinShadowUpdate, NULL, 0, 0))
- {
- ErrorF ("winCreateScreenResources - shadowAdd () failed\n");
- return FALSE;
- }
-
- return result;
-}
-
-/* See Porting Layer Definition - p. 20 */
-Bool
-winFinishScreenInitFB (int index,
- ScreenPtr pScreen,
- int argc, char **argv)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- VisualPtr pVisual = NULL;
- char *pbits = NULL;
-#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
- int iReturn;
-#endif
-
- /* Create framebuffer */
- if (!(*pScreenPriv->pwinAllocateFB) (pScreen))
- {
- ErrorF ("winFinishScreenInitFB - Could not allocate framebuffer\n");
- return FALSE;
- }
-
- /*
- * Grab the number of bits that are used to represent color in each pixel.
- */
- if (pScreenInfo->dwBPP == 8)
- pScreenInfo->dwDepth = 8;
- else
- pScreenInfo->dwDepth = winCountBits (pScreenPriv->dwRedMask)
- + winCountBits (pScreenPriv->dwGreenMask)
- + winCountBits (pScreenPriv->dwBlueMask);
-
- winErrorFVerb (2, "winFinishScreenInitFB - Masks: %08x %08x %08x\n",
- (unsigned int) pScreenPriv->dwRedMask,
- (unsigned int) pScreenPriv->dwGreenMask,
- (unsigned int) pScreenPriv->dwBlueMask);
-
- /* Init visuals */
- if (!(*pScreenPriv->pwinInitVisuals) (pScreen))
- {
- ErrorF ("winFinishScreenInitFB - winInitVisuals failed\n");
- return FALSE;
- }
-
- /* Setup a local variable to point to the framebuffer */
- pbits = pScreenInfo->pfb;
-
- /* Apparently we need this for the render extension */
- miSetPixmapDepths ();
-
- /* Start fb initialization */
- if (!fbSetupScreen (pScreen,
- pScreenInfo->pfb,
- pScreenInfo->dwWidth, pScreenInfo->dwHeight,
- monitorResolution, monitorResolution,
- pScreenInfo->dwStride,
- pScreenInfo->dwBPP))
- {
- ErrorF ("winFinishScreenInitFB - fbSetupScreen failed\n");
- return FALSE;
- }
-
- /* Override default colormap routines if visual class is dynamic */
- if (pScreenInfo->dwDepth == 8
- && (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI
- || (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL
- && pScreenInfo->fFullScreen)
- || (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
- && pScreenInfo->fFullScreen)))
- {
- winSetColormapFunctions (pScreen);
-
- /*
- * NOTE: Setting whitePixel to 255 causes Magic 7.1 to allocate its
- * own colormap, as it cannot allocate 7 planes in the default
- * colormap. Setting whitePixel to 1 allows Magic to get 7
- * planes in the default colormap, so it doesn't create its
- * own colormap. This latter situation is highly desireable,
- * as it keeps the Magic window viewable when switching to
- * other X clients that use the default colormap.
- */
- pScreen->blackPixel = 0;
- pScreen->whitePixel = 1;
- }
-
- /* Place our save screen function */
- pScreen->SaveScreen = winSaveScreen;
-
- /* Finish fb initialization */
- if (!fbFinishScreenInit (pScreen,
- pScreenInfo->pfb,
- pScreenInfo->dwWidth, pScreenInfo->dwHeight,
- monitorResolution, monitorResolution,
- pScreenInfo->dwStride,
- pScreenInfo->dwBPP))
- {
- ErrorF ("winFinishScreenInitFB - fbFinishScreenInit failed\n");
- return FALSE;
- }
-
- /* Save a pointer to the root visual */
- for (pVisual = pScreen->visuals;
- pVisual->vid != pScreen->rootVisual;
- pVisual++);
- pScreenPriv->pRootVisual = pVisual;
-
- /*
- * Setup points to the block and wakeup handlers. Pass a pointer
- * to the current screen as pWakeupdata.
- */
- pScreen->BlockHandler = winBlockHandler;
- pScreen->WakeupHandler = winWakeupHandler;
- pScreen->blockData = pScreen;
- pScreen->wakeupData = pScreen;
-
-#ifdef RENDER
- /* Render extension initialization, calls miPictureInit */
- if (!fbPictureInit (pScreen, NULL, 0))
- {
- ErrorF ("winFinishScreenInitFB - fbPictureInit () failed\n");
- return FALSE;
- }
-#endif
-
-#ifdef RANDR
- /* Initialize resize and rotate support */
- if (!winRandRInit (pScreen))
- {
- ErrorF ("winFinishScreenInitFB - winRandRInit () failed\n");
- return FALSE;
- }
-#endif
-
- /*
- * Backing store support should reduce network traffic and increase
- * performance.
- */
- miInitializeBackingStore (pScreen);
-
- /* KDrive does miDCInitialize right after miInitializeBackingStore */
- /* Setup the cursor routines */
-#if CYGDEBUG
- winDebug ("winFinishScreenInitFB - Calling miDCInitialize ()\n");
-#endif
- miDCInitialize (pScreen, &g_winPointerCursorFuncs);
-
- /* KDrive does winCreateDefColormap right after miDCInitialize */
- /* Create a default colormap */
-#if CYGDEBUG
- winDebug ("winFinishScreenInitFB - Calling winCreateDefColormap ()\n");
-#endif
- if (!winCreateDefColormap (pScreen))
- {
- ErrorF ("winFinishScreenInitFB - Could not create colormap\n");
- return FALSE;
- }
-
- /* Initialize the shadow framebuffer layer */
- if ((pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI
- || pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
- || pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL)
-#ifdef XWIN_MULTIWINDOWEXTWM
- && !pScreenInfo->fMWExtWM
-#endif
- )
- {
-#if CYGDEBUG
- winDebug ("winFinishScreenInitFB - Calling shadowSetup ()\n");
-#endif
- if (!shadowSetup(pScreen))
- {
- ErrorF ("winFinishScreenInitFB - shadowSetup () failed\n");
- return FALSE;
- }
-
- /* Wrap CreateScreenResources so we can add the screen pixmap
- to the Shadow framebuffer after it's been created */
- pScreenPriv->pwinCreateScreenResources = pScreen->CreateScreenResources;
- pScreen->CreateScreenResources = winCreateScreenResources;
- }
-
-#ifdef XWIN_MULTIWINDOWEXTWM
- /* Handle multi-window external window manager mode */
- if (pScreenInfo->fMWExtWM)
- {
- winDebug ("winScreenInit - MultiWindowExtWM - Calling RootlessInit\n");
-
- RootlessInit(pScreen, &winMWExtWMProcs);
-
- winDebug ("winScreenInit - MultiWindowExtWM - RootlessInit returned\n");
-
- rootless_CopyBytes_threshold = 0;
- rootless_FillBytes_threshold = 0;
- rootless_CompositePixels_threshold = 0;
- /* FIXME: How many? Profiling needed? */
- rootless_CopyWindow_threshold = 1;
-
- winWindowsWMExtensionInit ();
- }
-#endif
-
- /* Handle rootless mode */
- if (pScreenInfo->fRootless)
- {
- /* Define the WRAP macro temporarily for local use */
-#define WRAP(a) \
- if (pScreen->a) { \
- pScreenPriv->a = pScreen->a; \
- } else { \
- ErrorF("null screen fn " #a "\n"); \
- pScreenPriv->a = NULL; \
- }
-
- /* Save a pointer to each lower-level window procedure */
- WRAP(CreateWindow);
- WRAP(DestroyWindow);
- WRAP(RealizeWindow);
- WRAP(UnrealizeWindow);
- WRAP(PositionWindow);
- WRAP(ChangeWindowAttributes);
- WRAP(SetShape);
-
- /* Assign rootless window procedures to be top level procedures */
- pScreen->CreateWindow = winCreateWindowRootless;
- pScreen->DestroyWindow = winDestroyWindowRootless;
- pScreen->PositionWindow = winPositionWindowRootless;
- /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesRootless;*/
- pScreen->RealizeWindow = winMapWindowRootless;
- pScreen->UnrealizeWindow = winUnmapWindowRootless;
- pScreen->SetShape = winSetShapeRootless;
-
- /* Undefine the WRAP macro, as it is not needed elsewhere */
-#undef WRAP
- }
-
-
-#ifdef XWIN_MULTIWINDOW
- /* Handle multi window mode */
- else if (pScreenInfo->fMultiWindow)
- {
- /* Define the WRAP macro temporarily for local use */
-#define WRAP(a) \
- if (pScreen->a) { \
- pScreenPriv->a = pScreen->a; \
- } else { \
- ErrorF("null screen fn " #a "\n"); \
- pScreenPriv->a = NULL; \
- }
-
- /* Save a pointer to each lower-level window procedure */
- WRAP(CreateWindow);
- WRAP(DestroyWindow);
- WRAP(RealizeWindow);
- WRAP(UnrealizeWindow);
- WRAP(PositionWindow);
- WRAP(ChangeWindowAttributes);
- WRAP(ReparentWindow);
- WRAP(RestackWindow);
- WRAP(ResizeWindow);
- WRAP(MoveWindow);
- WRAP(CopyWindow);
- WRAP(SetShape);
-
- /* Assign multi-window window procedures to be top level procedures */
- pScreen->CreateWindow = winCreateWindowMultiWindow;
- pScreen->DestroyWindow = winDestroyWindowMultiWindow;
- pScreen->PositionWindow = winPositionWindowMultiWindow;
- /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesMultiWindow;*/
- pScreen->RealizeWindow = winMapWindowMultiWindow;
- pScreen->UnrealizeWindow = winUnmapWindowMultiWindow;
- pScreen->ReparentWindow = winReparentWindowMultiWindow;
- pScreen->RestackWindow = winRestackWindowMultiWindow;
- pScreen->ResizeWindow = winResizeWindowMultiWindow;
- pScreen->MoveWindow = winMoveWindowMultiWindow;
- pScreen->CopyWindow = winCopyWindowMultiWindow;
- pScreen->SetShape = winSetShapeMultiWindow;
-
- /* Undefine the WRAP macro, as it is not needed elsewhere */
-#undef WRAP
- }
-#endif
-
- /* Wrap either fb's or shadow's CloseScreen with our CloseScreen */
- pScreenPriv->CloseScreen = pScreen->CloseScreen;
- pScreen->CloseScreen = pScreenPriv->pwinCloseScreen;
-
-#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
- /* Create a mutex for modules in separate threads to wait for */
- iReturn = pthread_mutex_init (&pScreenPriv->pmServerStarted, NULL);
- if (iReturn != 0)
- {
- ErrorF ("winFinishScreenInitFB - pthread_mutex_init () failed: %d\n",
- iReturn);
- return FALSE;
- }
-
- /* Own the mutex for modules in separate threads */
- iReturn = pthread_mutex_lock (&pScreenPriv->pmServerStarted);
- if (iReturn != 0)
- {
- ErrorF ("winFinishScreenInitFB - pthread_mutex_lock () failed: %d\n",
- iReturn);
- return FALSE;
- }
-
- /* Set the ServerStarted flag to false */
- pScreenPriv->fServerStarted = FALSE;
-#endif
-
-#ifdef XWIN_MULTIWINDOWEXTWM
- pScreenPriv->fRestacking = FALSE;
-#endif
-
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- if (FALSE
-#ifdef XWIN_MULTIWINDOW
- || pScreenInfo->fMultiWindow
-#endif
-#ifdef XWIN_MULTIWINDOWEXTWM
- || pScreenInfo->fInternalWM
-#endif
- )
- {
-#if CYGDEBUG || YES
- winDebug ("winFinishScreenInitFB - Calling winInitWM.\n");
-#endif
-
- /* Initialize multi window mode */
- if (!winInitWM (&pScreenPriv->pWMInfo,
- &pScreenPriv->ptWMProc,
- &pScreenPriv->ptXMsgProc,
- &pScreenPriv->pmServerStarted,
- pScreenInfo->dwScreen,
- (HWND)&pScreenPriv->hwndScreen,
-#ifdef XWIN_MULTIWINDOWEXTWM
- pScreenInfo->fInternalWM ||
-#endif
- FALSE))
- {
- ErrorF ("winFinishScreenInitFB - winInitWM () failed.\n");
- return FALSE;
- }
- }
-#endif
-
- /* Tell the server that we are enabled */
- pScreenPriv->fEnabled = TRUE;
-
- /* Tell the server that we have a valid depth */
- pScreenPriv->fBadDepth = FALSE;
-
-#if CYGDEBUG || YES
- winDebug ("winFinishScreenInitFB - returning\n");
-#endif
-
- return TRUE;
-}
-
-#ifdef XWIN_NATIVEGDI
-/* See Porting Layer Definition - p. 20 */
-
-Bool
-winFinishScreenInitNativeGDI (int index,
- ScreenPtr pScreen,
- int argc, char **argv)
-{
- winScreenPriv(pScreen);
- winScreenInfoPtr pScreenInfo = &g_ScreenInfo[index];
- VisualPtr pVisuals = NULL;
- DepthPtr pDepths = NULL;
- VisualID rootVisual = 0;
- int nVisuals = 0, nDepths = 0, nRootDepth = 0;
-
- /* Ignore user input (mouse, keyboard) */
- pScreenInfo->fIgnoreInput = FALSE;
-
- /* Get device contexts for the screen and shadow bitmap */
- pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen);
- if (pScreenPriv->hdcScreen == NULL)
- FatalError ("winFinishScreenInitNativeGDI - Couldn't get a DC\n");
-
- /* Init visuals */
- if (!(*pScreenPriv->pwinInitVisuals) (pScreen))
- {
- ErrorF ("winFinishScreenInitNativeGDI - pwinInitVisuals failed\n");
- return FALSE;
- }
-
- /* Initialize the mi visuals */
- if (!miInitVisuals (&pVisuals, &pDepths, &nVisuals, &nDepths, &nRootDepth,
- &rootVisual,
- ((unsigned long)1 << (pScreenInfo->dwDepth - 1)), 8,
- TrueColor))
- {
- ErrorF ("winFinishScreenInitNativeGDI - miInitVisuals () failed\n");
- return FALSE;
- }
-
- /* Initialize the CloseScreen procedure pointer */
- pScreen->CloseScreen = NULL;
-
- /* Initialize the mi code */
- if (!miScreenInit (pScreen,
- NULL, /* No framebuffer */
- pScreenInfo->dwWidth, pScreenInfo->dwHeight,
- monitorResolution, monitorResolution,
- pScreenInfo->dwStride,
- nRootDepth, nDepths, pDepths, rootVisual,
- nVisuals, pVisuals))
- {
- ErrorF ("winFinishScreenInitNativeGDI - miScreenInit failed\n");
- return FALSE;
- }
-
- pScreen->defColormap = FakeClientID(0);
-
- /*
- * Register our block and wakeup handlers; these procedures
- * process messages in our Windows message queue; specifically,
- * they process mouse and keyboard input.
- */
- pScreen->BlockHandler = winBlockHandler;
- pScreen->WakeupHandler = winWakeupHandler;
- pScreen->blockData = pScreen;
- pScreen->wakeupData = pScreen;
-
- /* Place our save screen function */
- pScreen->SaveScreen = winSaveScreen;
-
- /* Pixmaps */
- pScreen->CreatePixmap = winCreatePixmapNativeGDI;
- pScreen->DestroyPixmap = winDestroyPixmapNativeGDI;
-
- /* Other Screen Routines */
- pScreen->QueryBestSize = winQueryBestSizeNativeGDI;
- pScreen->SaveScreen = winSaveScreen;
- pScreen->GetImage = miGetImage;
- pScreen->GetSpans = winGetSpansNativeGDI;
-
- /* Window Procedures */
- pScreen->CreateWindow = winCreateWindowNativeGDI;
- pScreen->DestroyWindow = winDestroyWindowNativeGDI;
- pScreen->PositionWindow = winPositionWindowNativeGDI;
- /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesNativeGDI;*/
- pScreen->RealizeWindow = winMapWindowNativeGDI;
- pScreen->UnrealizeWindow = winUnmapWindowNativeGDI;
-
- /* Paint window */
- pScreen->CopyWindow = winCopyWindowNativeGDI;
-
- /* Fonts */
- pScreen->RealizeFont = winRealizeFontNativeGDI;
- pScreen->UnrealizeFont = winUnrealizeFontNativeGDI;
-
- /* GC */
- pScreen->CreateGC = winCreateGCNativeGDI;
-
- /* Colormap Routines */
- pScreen->CreateColormap = miInitializeColormap;
- pScreen->DestroyColormap = (DestroyColormapProcPtr) (void (*)(void)) NoopDDA;
- pScreen->InstallColormap = miInstallColormap;
- pScreen->UninstallColormap = miUninstallColormap;
- pScreen->ListInstalledColormaps = miListInstalledColormaps;
- pScreen->StoreColors = (StoreColorsProcPtr) (void (*)(void)) NoopDDA;
- pScreen->ResolveColor = miResolveColor;
-
- /* Bitmap */
- pScreen->BitmapToRegion = winPixmapToRegionNativeGDI;
-
- ErrorF ("winFinishScreenInitNativeGDI - calling miDCInitialize\n");
-
- /* Set the default white and black pixel positions */
- pScreen->whitePixel = pScreen->blackPixel = (Pixel) 0;
-
- /* Initialize the cursor */
- if (!miDCInitialize (pScreen, &g_winPointerCursorFuncs))
- {
- ErrorF ("winFinishScreenInitNativeGDI - miDCInitialize failed\n");
- return FALSE;
- }
-
- /* Create a default colormap */
- if (!miCreateDefColormap (pScreen))
- {
- ErrorF ("winFinishScreenInitNativeGDI - miCreateDefColormap () "
- "failed\n");
- return FALSE;
- }
-
- ErrorF ("winFinishScreenInitNativeGDI - miCreateDefColormap () "
- "returned\n");
-
- /* mi doesn't use a CloseScreen procedure, so no need to wrap */
- pScreen->CloseScreen = pScreenPriv->pwinCloseScreen;
-
- /* Tell the server that we are enabled */
- pScreenPriv->fEnabled = TRUE;
-
- ErrorF ("winFinishScreenInitNativeGDI - Successful addition of "
- "screen %08x\n",
- (unsigned int) pScreen);
-
- return TRUE;
-}
-#endif
-
-
-/* See Porting Layer Definition - p. 33 */
-static Bool
-winSaveScreen (ScreenPtr pScreen, int on)
-{
- return TRUE;
-}
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, 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 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 XFREE86 PROJECT 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 XFree86 Project
+ *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 XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ * Kensuke Matsuzaki
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "winmsg.h"
+
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+static RootlessFrameProcsRec
+winMWExtWMProcs = {
+ winMWExtWMCreateFrame,
+ winMWExtWMDestroyFrame,
+
+ winMWExtWMMoveFrame,
+ winMWExtWMResizeFrame,
+ winMWExtWMRestackFrame,
+ winMWExtWMReshapeFrame,
+ winMWExtWMUnmapFrame,
+
+ winMWExtWMStartDrawing,
+ winMWExtWMStopDrawing,
+ winMWExtWMUpdateRegion,
+#ifndef ROOTLESS_TRACK_DAMAGE
+ winMWExtWMDamageRects,
+#endif
+ winMWExtWMRootlessSwitchWindow,
+ NULL,//winMWExtWMDoReorderWindow,
+ NULL,//winMWExtWMHideWindow,
+ NULL,//winMWExtWMUpdateColorMap,
+
+ NULL,//winMWExtWMCopyBytes,
+ NULL,//winMWExtWMFillBytes,
+ NULL,//winMWExtWMCompositePixels,
+ winMWExtWMCopyWindow
+};
+#endif
+
+
+/*
+ * References to external symbols
+ */
+
+extern Bool g_fSoftwareCursor;
+
+
+/*
+ * Prototypes
+ */
+
+Bool
+winRandRInit (ScreenPtr pScreen);
+
+
+/*
+ * Local functions
+ */
+
+static Bool
+winSaveScreen (ScreenPtr pScreen, int on);
+
+
+/*
+ * Determine what type of screen we are initializing
+ * and call the appropriate procedure to intiailize
+ * that type of screen.
+ */
+
+Bool
+winScreenInit (int index,
+ ScreenPtr pScreen,
+ int argc, char **argv)
+{
+ winScreenInfoPtr pScreenInfo = &g_ScreenInfo[index];
+ winPrivScreenPtr pScreenPriv;
+ HDC hdc;
+
+ winDebug ("winScreenInit - dwWidth: %ld dwHeight: %ld\n",
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight);
+
+ /* Allocate privates for this screen */
+ if (!winAllocatePrivates (pScreen))
+ {
+ ErrorF ("winScreenInit - Couldn't allocate screen privates\n");
+ return FALSE;
+ }
+
+ /* Get a pointer to the privates structure that was allocated */
+ pScreenPriv = winGetScreenPriv (pScreen);
+
+ /* Save a pointer to this screen in the screen info structure */
+ pScreenInfo->pScreen = pScreen;
+
+ /* Save a pointer to the screen info in the screen privates structure */
+ /* This allows us to get back to the screen info from a screen pointer */
+ pScreenPriv->pScreenInfo = pScreenInfo;
+
+ /*
+ * Determine which engine to use.
+ *
+ * NOTE: This is done once per screen because each screen possibly has
+ * a preferred engine specified on the command line.
+ */
+ if (!winSetEngine (pScreen))
+ {
+ ErrorF ("winScreenInit - winSetEngine () failed\n");
+ return FALSE;
+ }
+
+ /* Adjust the video mode for our engine type */
+ if (pScreenPriv->pwinAdjustVideoMode && !(*pScreenPriv->pwinAdjustVideoMode) (pScreen))
+ {
+ ErrorF ("winScreenInit - winAdjustVideoMode () failed\n");
+ return FALSE;
+ }
+
+ /* Check for supported display depth */
+ if (!(WIN_SUPPORTED_BPPS & (1 << (pScreenInfo->dwBPP - 1))))
+ {
+ ErrorF ("winScreenInit - Unsupported display depth: %d\n" \
+ "Change your Windows display depth to 15, 16, 24, or 32 bits "
+ "per pixel.\n",
+ (int) pScreenInfo->dwBPP);
+ ErrorF ("winScreenInit - Supported depths: %08x\n",
+ WIN_SUPPORTED_BPPS);
+#if WIN_CHECK_DEPTH
+ return FALSE;
+#endif
+ }
+
+ /*
+ * Check that all monitors have the same display depth if we are using
+ * multiple monitors
+ */
+ if (pScreenInfo->fMultipleMonitors
+ && !GetSystemMetrics (SM_SAMEDISPLAYFORMAT))
+ {
+ ErrorF ("winScreenInit - Monitors do not all have same pixel format / "
+ "display depth.\n"
+ "Using primary display only.\n");
+ pScreenInfo->fMultipleMonitors = FALSE;
+ }
+
+ /* Create display window */
+ if (pScreenPriv->pwinCreateBoundingWindow && !(*pScreenPriv->pwinCreateBoundingWindow) (pScreen))
+ {
+ ErrorF ("winScreenInit - pwinCreateBoundingWindow () "
+ "failed\n");
+ return FALSE;
+ }
+
+ /* Get a device context */
+ hdc = GetDC (pScreenPriv->hwndScreen);
+
+ /* Store the initial height, width, and depth of the display */
+ /* Are we using multiple monitors? */
+ if (pScreenInfo->fMultipleMonitors)
+ {
+ pScreenPriv->dwLastWindowsWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN);
+ pScreenPriv->dwLastWindowsHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN);
+
+ /*
+ * In this case, some of the defaults set in
+ * winInitializeDefaultScreens () are not correct ...
+ */
+ if (!pScreenInfo->fUserGaveHeightAndWidth)
+ {
+ pScreenInfo->dwWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN);
+ pScreenInfo->dwHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN);
+ pScreenInfo->dwWidth_mm = (pScreenInfo->dwWidth /
+ WIN_DEFAULT_DPI) * 25.4;
+ pScreenInfo->dwHeight_mm = (pScreenInfo->dwHeight /
+ WIN_DEFAULT_DPI) * 25.4;
+ }
+ }
+ else
+ {
+ pScreenPriv->dwLastWindowsWidth = GetSystemMetrics (SM_CXSCREEN);
+ pScreenPriv->dwLastWindowsHeight = GetSystemMetrics (SM_CYSCREEN);
+ }
+
+ /* Save the original bits per pixel */
+ pScreenPriv->dwLastWindowsBitsPixel = GetDeviceCaps (hdc, BITSPIXEL);
+
+ /* Release the device context */
+ ReleaseDC (pScreenPriv->hwndScreen, hdc);
+
+ /* Clear the visuals list */
+ miClearVisualTypes ();
+
+ /* Set the padded screen width */
+ pScreenInfo->dwPaddedWidth = PixmapBytePad (pScreenInfo->dwWidth,
+ pScreenInfo->dwBPP);
+
+ /* Call the engine dependent screen initialization procedure */
+ if (pScreenPriv->pwinFinishScreenInit && !((*pScreenPriv->pwinFinishScreenInit) (index, pScreen, argc, argv)))
+ {
+ ErrorF ("winScreenInit - winFinishScreenInit () failed\n");
+ return FALSE;
+ }
+
+ if (!g_fSoftwareCursor)
+ winInitCursor(pScreen);
+#ifdef WINDBG
+ else
+ winDebug("winScreenInit - Using software cursor\n");
+#endif
+
+ /*
+ Note the screen origin in a normalized coordinate space where (0,0) is at the top left
+ of the native virtual desktop area
+ */
+ dixScreenOrigins[index].x = pScreenInfo->dwInitialX - GetSystemMetrics(SM_XVIRTUALSCREEN);
+ dixScreenOrigins[index].y = pScreenInfo->dwInitialY - GetSystemMetrics(SM_YVIRTUALSCREEN);
+
+ winDebug("Screen %d added at XINERAMA coordinate (%d,%d).\n",
+ index, dixScreenOrigins[index].x, dixScreenOrigins[index].y);
+ winDebug ("winScreenInit - returning\n");
+
+ return TRUE;
+}
+
+static Bool
+winCreateScreenResources(ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ Bool result;
+
+ result = pScreenPriv->pwinCreateScreenResources(pScreen);
+
+ /* Now the screen bitmap has been wrapped in a pixmap,
+ add that to the Shadow framebuffer */
+ if (!shadowAdd(pScreen, pScreen->devPrivate,
+ pScreenPriv->pwinShadowUpdate, NULL, 0, 0))
+ {
+ ErrorF ("winCreateScreenResources - shadowAdd () failed\n");
+ return FALSE;
+ }
+
+ return result;
+}
+
+/* See Porting Layer Definition - p. 20 */
+Bool
+winFinishScreenInitFB (int index,
+ ScreenPtr pScreen,
+ int argc, char **argv)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ VisualPtr pVisual = NULL;
+ char *pbits = NULL;
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+ int iReturn;
+#endif
+
+ /* Create framebuffer */
+ if (!(*pScreenPriv->pwinAllocateFB) (pScreen))
+ {
+ ErrorF ("winFinishScreenInitFB - Could not allocate framebuffer\n");
+ return FALSE;
+ }
+
+ /*
+ * Grab the number of bits that are used to represent color in each pixel.
+ */
+ if (pScreenInfo->dwBPP == 8)
+ pScreenInfo->dwDepth = 8;
+ else
+ pScreenInfo->dwDepth = winCountBits (pScreenPriv->dwRedMask)
+ + winCountBits (pScreenPriv->dwGreenMask)
+ + winCountBits (pScreenPriv->dwBlueMask);
+
+ winDebug ("winFinishScreenInitFB - Masks: %08x %08x %08x\n",
+ (unsigned int) pScreenPriv->dwRedMask,
+ (unsigned int) pScreenPriv->dwGreenMask,
+ (unsigned int) pScreenPriv->dwBlueMask);
+
+ /* Init visuals */
+ if (!(*pScreenPriv->pwinInitVisuals) (pScreen))
+ {
+ ErrorF ("winFinishScreenInitFB - winInitVisuals failed\n");
+ return FALSE;
+ }
+
+ /* Setup a local variable to point to the framebuffer */
+ pbits = pScreenInfo->pfb;
+
+ /* Apparently we need this for the render extension */
+ miSetPixmapDepths ();
+
+ /* Start fb initialization */
+ if (!fbSetupScreen (pScreen,
+ pScreenInfo->pfb,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ monitorResolution, monitorResolution,
+ pScreenInfo->dwStride,
+ pScreenInfo->dwBPP))
+ {
+ ErrorF ("winFinishScreenInitFB - fbSetupScreen failed\n");
+ return FALSE;
+ }
+
+ /* Override default colormap routines if visual class is dynamic */
+ if (pScreenInfo->dwDepth == 8
+ && (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI
+ || (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL
+ && pScreenInfo->fFullScreen)
+ || (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
+ && pScreenInfo->fFullScreen)))
+ {
+ winSetColormapFunctions (pScreen);
+
+ /*
+ * NOTE: Setting whitePixel to 255 causes Magic 7.1 to allocate its
+ * own colormap, as it cannot allocate 7 planes in the default
+ * colormap. Setting whitePixel to 1 allows Magic to get 7
+ * planes in the default colormap, so it doesn't create its
+ * own colormap. This latter situation is highly desireable,
+ * as it keeps the Magic window viewable when switching to
+ * other X clients that use the default colormap.
+ */
+ pScreen->blackPixel = 0;
+ pScreen->whitePixel = 1;
+ }
+
+ /* Place our save screen function */
+ pScreen->SaveScreen = winSaveScreen;
+
+ /* Finish fb initialization */
+ if (!fbFinishScreenInit (pScreen,
+ pScreenInfo->pfb,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ monitorResolution, monitorResolution,
+ pScreenInfo->dwStride,
+ pScreenInfo->dwBPP))
+ {
+ ErrorF ("winFinishScreenInitFB - fbFinishScreenInit failed\n");
+ return FALSE;
+ }
+
+ /* Save a pointer to the root visual */
+ for (pVisual = pScreen->visuals;
+ pVisual->vid != pScreen->rootVisual;
+ pVisual++);
+ pScreenPriv->pRootVisual = pVisual;
+
+ /*
+ * Setup points to the block and wakeup handlers. Pass a pointer
+ * to the current screen as pWakeupdata.
+ */
+ pScreen->BlockHandler = winBlockHandler;
+ pScreen->WakeupHandler = winWakeupHandler;
+ pScreen->blockData = pScreen;
+ pScreen->wakeupData = pScreen;
+
+#ifdef RENDER
+ /* Render extension initialization, calls miPictureInit */
+ if (!fbPictureInit (pScreen, NULL, 0))
+ {
+ ErrorF ("winFinishScreenInitFB - fbPictureInit () failed\n");
+ return FALSE;
+ }
+#endif
+
+#ifdef RANDR
+ /* Initialize resize and rotate support */
+ if (!winRandRInit (pScreen))
+ {
+ ErrorF ("winFinishScreenInitFB - winRandRInit () failed\n");
+ return FALSE;
+ }
+#endif
+
+ /*
+ * Backing store support should reduce network traffic and increase
+ * performance.
+ */
+ miInitializeBackingStore (pScreen);
+
+ /* KDrive does miDCInitialize right after miInitializeBackingStore */
+ /* Setup the cursor routines */
+ winDebug ("winFinishScreenInitFB - Calling miDCInitialize ()\n");
+ miDCInitialize (pScreen, &g_winPointerCursorFuncs);
+
+ /* KDrive does winCreateDefColormap right after miDCInitialize */
+ /* Create a default colormap */
+ winDebug ("winFinishScreenInitFB - Calling winCreateDefColormap ()\n");
+ if (!winCreateDefColormap (pScreen))
+ {
+ ErrorF ("winFinishScreenInitFB - Could not create colormap\n");
+ return FALSE;
+ }
+
+ /* Initialize the shadow framebuffer layer */
+ if ((pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI
+ || pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
+ || pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL)
+#ifdef XWIN_MULTIWINDOWEXTWM
+ && !pScreenInfo->fMWExtWM
+#endif
+ )
+ {
+ winDebug ("winFinishScreenInitFB - Calling shadowSetup ()\n");
+ if (!shadowSetup(pScreen))
+ {
+ ErrorF ("winFinishScreenInitFB - shadowSetup () failed\n");
+ return FALSE;
+ }
+
+ /* Wrap CreateScreenResources so we can add the screen pixmap
+ to the Shadow framebuffer after it's been created */
+ pScreenPriv->pwinCreateScreenResources = pScreen->CreateScreenResources;
+ pScreen->CreateScreenResources = winCreateScreenResources;
+ }
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+ /* Handle multi-window external window manager mode */
+ if (pScreenInfo->fMWExtWM)
+ {
+ winDebug ("winScreenInit - MultiWindowExtWM - Calling RootlessInit\n");
+
+ RootlessInit(pScreen, &winMWExtWMProcs);
+
+ winDebug ("winScreenInit - MultiWindowExtWM - RootlessInit returned\n");
+
+ rootless_CopyBytes_threshold = 0;
+ rootless_FillBytes_threshold = 0;
+ rootless_CompositePixels_threshold = 0;
+ /* FIXME: How many? Profiling needed? */
+ rootless_CopyWindow_threshold = 1;
+
+ winWindowsWMExtensionInit ();
+ }
+#endif
+
+ /* Handle rootless mode */
+ if (pScreenInfo->fRootless)
+ {
+ /* Define the WRAP macro temporarily for local use */
+#define WRAP(a) \
+ if (pScreen->a) { \
+ pScreenPriv->a = pScreen->a; \
+ } else { \
+ ErrorF("null screen fn " #a "\n"); \
+ pScreenPriv->a = NULL; \
+ }
+
+ /* Save a pointer to each lower-level window procedure */
+ WRAP(CreateWindow);
+ WRAP(DestroyWindow);
+ WRAP(RealizeWindow);
+ WRAP(UnrealizeWindow);
+ WRAP(PositionWindow);
+ WRAP(ChangeWindowAttributes);
+ WRAP(SetShape);
+
+ /* Assign rootless window procedures to be top level procedures */
+ pScreen->CreateWindow = winCreateWindowRootless;
+ pScreen->DestroyWindow = winDestroyWindowRootless;
+ pScreen->PositionWindow = winPositionWindowRootless;
+ /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesRootless;*/
+ pScreen->RealizeWindow = winMapWindowRootless;
+ pScreen->UnrealizeWindow = winUnmapWindowRootless;
+ pScreen->SetShape = winSetShapeRootless;
+
+ /* Undefine the WRAP macro, as it is not needed elsewhere */
+#undef WRAP
+ }
+
+
+#ifdef XWIN_MULTIWINDOW
+ /* Handle multi window mode */
+ else if (pScreenInfo->fMultiWindow)
+ {
+ /* Define the WRAP macro temporarily for local use */
+#define WRAP(a) \
+ if (pScreen->a) { \
+ pScreenPriv->a = pScreen->a; \
+ } else { \
+ ErrorF("null screen fn " #a "\n"); \
+ pScreenPriv->a = NULL; \
+ }
+
+ /* Save a pointer to each lower-level window procedure */
+ WRAP(CreateWindow);
+ WRAP(DestroyWindow);
+ WRAP(RealizeWindow);
+ WRAP(UnrealizeWindow);
+ WRAP(PositionWindow);
+ WRAP(ChangeWindowAttributes);
+ WRAP(ReparentWindow);
+ WRAP(RestackWindow);
+ WRAP(ResizeWindow);
+ WRAP(MoveWindow);
+ WRAP(CopyWindow);
+ WRAP(SetShape);
+
+ /* Assign multi-window window procedures to be top level procedures */
+ pScreen->CreateWindow = winCreateWindowMultiWindow;
+ pScreen->DestroyWindow = winDestroyWindowMultiWindow;
+ pScreen->PositionWindow = winPositionWindowMultiWindow;
+ /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesMultiWindow;*/
+ pScreen->RealizeWindow = winMapWindowMultiWindow;
+ pScreen->UnrealizeWindow = winUnmapWindowMultiWindow;
+ pScreen->ReparentWindow = winReparentWindowMultiWindow;
+ pScreen->RestackWindow = winRestackWindowMultiWindow;
+ pScreen->ResizeWindow = winResizeWindowMultiWindow;
+ pScreen->MoveWindow = winMoveWindowMultiWindow;
+ pScreen->CopyWindow = winCopyWindowMultiWindow;
+ pScreen->SetShape = winSetShapeMultiWindow;
+
+ /* Undefine the WRAP macro, as it is not needed elsewhere */
+#undef WRAP
+ }
+#endif
+
+ /* Wrap either fb's or shadow's CloseScreen with our CloseScreen */
+ pScreenPriv->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = pScreenPriv->pwinCloseScreen;
+
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+ /* Create a mutex for modules in separate threads to wait for */
+ iReturn = pthread_mutex_init (&pScreenPriv->pmServerStarted, NULL);
+ if (iReturn != 0)
+ {
+ ErrorF ("winFinishScreenInitFB - pthread_mutex_init () failed: %d\n",
+ iReturn);
+ return FALSE;
+ }
+
+ /* Own the mutex for modules in separate threads */
+ iReturn = pthread_mutex_lock (&pScreenPriv->pmServerStarted);
+ if (iReturn != 0)
+ {
+ ErrorF ("winFinishScreenInitFB - pthread_mutex_lock () failed: %d\n",
+ iReturn);
+ return FALSE;
+ }
+
+ /* Set the ServerStarted flag to false */
+ pScreenPriv->fServerStarted = FALSE;
+#endif
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+ pScreenPriv->fRestacking = FALSE;
+#endif
+
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ if (FALSE
+#ifdef XWIN_MULTIWINDOW
+ || pScreenInfo->fMultiWindow
+#endif
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || pScreenInfo->fInternalWM
+#endif
+ )
+ {
+ winDebug ("winFinishScreenInitFB - Calling winInitWM.\n");
+
+ /* Initialize multi window mode */
+ if (!winInitWM (&pScreenPriv->pWMInfo,
+ &pScreenPriv->ptWMProc,
+ &pScreenPriv->ptXMsgProc,
+ &pScreenPriv->pmServerStarted,
+ pScreenInfo->dwScreen,
+ (HWND)&pScreenPriv->hwndScreen,
+#ifdef XWIN_MULTIWINDOWEXTWM
+ pScreenInfo->fInternalWM ||
+#endif
+ FALSE))
+ {
+ ErrorF ("winFinishScreenInitFB - winInitWM () failed.\n");
+ return FALSE;
+ }
+ }
+#endif
+
+ /* Tell the server that we are enabled */
+ pScreenPriv->fEnabled = TRUE;
+
+ /* Tell the server that we have a valid depth */
+ pScreenPriv->fBadDepth = FALSE;
+
+ winDebug ("winFinishScreenInitFB - returning\n");
+
+ return TRUE;
+}
+
+#ifdef XWIN_NATIVEGDI
+/* See Porting Layer Definition - p. 20 */
+
+Bool
+winFinishScreenInitNativeGDI (int index,
+ ScreenPtr pScreen,
+ int argc, char **argv)
+{
+ winScreenPriv(pScreen);
+ winScreenInfoPtr pScreenInfo = &g_ScreenInfo[index];
+ VisualPtr pVisuals = NULL;
+ DepthPtr pDepths = NULL;
+ VisualID rootVisual = 0;
+ int nVisuals = 0, nDepths = 0, nRootDepth = 0;
+
+ /* Ignore user input (mouse, keyboard) */
+ pScreenInfo->fIgnoreInput = FALSE;
+
+ /* Get device contexts for the screen and shadow bitmap */
+ pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen);
+ if (pScreenPriv->hdcScreen == NULL)
+ FatalError ("winFinishScreenInitNativeGDI - Couldn't get a DC\n");
+
+ /* Init visuals */
+ if (!(*pScreenPriv->pwinInitVisuals) (pScreen))
+ {
+ ErrorF ("winFinishScreenInitNativeGDI - pwinInitVisuals failed\n");
+ return FALSE;
+ }
+
+ /* Initialize the mi visuals */
+ if (!miInitVisuals (&pVisuals, &pDepths, &nVisuals, &nDepths, &nRootDepth,
+ &rootVisual,
+ ((unsigned long)1 << (pScreenInfo->dwDepth - 1)), 8,
+ TrueColor))
+ {
+ ErrorF ("winFinishScreenInitNativeGDI - miInitVisuals () failed\n");
+ return FALSE;
+ }
+
+ /* Initialize the CloseScreen procedure pointer */
+ pScreen->CloseScreen = NULL;
+
+ /* Initialize the mi code */
+ if (!miScreenInit (pScreen,
+ NULL, /* No framebuffer */
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ monitorResolution, monitorResolution,
+ pScreenInfo->dwStride,
+ nRootDepth, nDepths, pDepths, rootVisual,
+ nVisuals, pVisuals))
+ {
+ ErrorF ("winFinishScreenInitNativeGDI - miScreenInit failed\n");
+ return FALSE;
+ }
+
+ pScreen->defColormap = FakeClientID(0);
+
+ /*
+ * Register our block and wakeup handlers; these procedures
+ * process messages in our Windows message queue; specifically,
+ * they process mouse and keyboard input.
+ */
+ pScreen->BlockHandler = winBlockHandler;
+ pScreen->WakeupHandler = winWakeupHandler;
+ pScreen->blockData = pScreen;
+ pScreen->wakeupData = pScreen;
+
+ /* Place our save screen function */
+ pScreen->SaveScreen = winSaveScreen;
+
+ /* Pixmaps */
+ pScreen->CreatePixmap = winCreatePixmapNativeGDI;
+ pScreen->DestroyPixmap = winDestroyPixmapNativeGDI;
+
+ /* Other Screen Routines */
+ pScreen->QueryBestSize = winQueryBestSizeNativeGDI;
+ pScreen->SaveScreen = winSaveScreen;
+ pScreen->GetImage = miGetImage;
+ pScreen->GetSpans = winGetSpansNativeGDI;
+
+ /* Window Procedures */
+ pScreen->CreateWindow = winCreateWindowNativeGDI;
+ pScreen->DestroyWindow = winDestroyWindowNativeGDI;
+ pScreen->PositionWindow = winPositionWindowNativeGDI;
+ /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesNativeGDI;*/
+ pScreen->RealizeWindow = winMapWindowNativeGDI;
+ pScreen->UnrealizeWindow = winUnmapWindowNativeGDI;
+
+ /* Paint window */
+ pScreen->CopyWindow = winCopyWindowNativeGDI;
+
+ /* Fonts */
+ pScreen->RealizeFont = winRealizeFontNativeGDI;
+ pScreen->UnrealizeFont = winUnrealizeFontNativeGDI;
+
+ /* GC */
+ pScreen->CreateGC = winCreateGCNativeGDI;
+
+ /* Colormap Routines */
+ pScreen->CreateColormap = miInitializeColormap;
+ pScreen->DestroyColormap = (DestroyColormapProcPtr) (void (*)(void)) NoopDDA;
+ pScreen->InstallColormap = miInstallColormap;
+ pScreen->UninstallColormap = miUninstallColormap;
+ pScreen->ListInstalledColormaps = miListInstalledColormaps;
+ pScreen->StoreColors = (StoreColorsProcPtr) (void (*)(void)) NoopDDA;
+ pScreen->ResolveColor = miResolveColor;
+
+ /* Bitmap */
+ pScreen->BitmapToRegion = winPixmapToRegionNativeGDI;
+
+ winDebug ("winFinishScreenInitNativeGDI - calling miDCInitialize\n");
+
+ /* Set the default white and black pixel positions */
+ pScreen->whitePixel = pScreen->blackPixel = (Pixel) 0;
+
+ /* Initialize the cursor */
+ if (!miDCInitialize (pScreen, &g_winPointerCursorFuncs))
+ {
+ ErrorF ("winFinishScreenInitNativeGDI - miDCInitialize failed\n");
+ return FALSE;
+ }
+
+ /* Create a default colormap */
+ if (!miCreateDefColormap (pScreen))
+ {
+ ErrorF ("winFinishScreenInitNativeGDI - miCreateDefColormap () "
+ "failed\n");
+ return FALSE;
+ }
+
+ winDebug ("winFinishScreenInitNativeGDI - miCreateDefColormap () "
+ "returned\n");
+
+ /* mi doesn't use a CloseScreen procedure, so no need to wrap */
+ pScreen->CloseScreen = pScreenPriv->pwinCloseScreen;
+
+ /* Tell the server that we are enabled */
+ pScreenPriv->fEnabled = TRUE;
+
+ winDebug ("winFinishScreenInitNativeGDI - Successful addition of "
+ "screen %08x\n",
+ (unsigned int) pScreen);
+
+ return TRUE;
+}
+#endif
+
+
+/* See Porting Layer Definition - p. 33 */
+static Bool
+winSaveScreen (ScreenPtr pScreen, int on)
+{
+ return TRUE;
+}
diff --git a/xorg-server/hw/xwin/winshaddd.c b/xorg-server/hw/xwin/winshaddd.c
index 833444177..e1501c6c2 100644
--- a/xorg-server/hw/xwin/winshaddd.c
+++ b/xorg-server/hw/xwin/winshaddd.c
@@ -48,10 +48,12 @@ extern char *g_pszLogFile;
* FIXME: Headers are broken, DEFINE_GUID doesn't work correctly,
* so we have to redefine it here.
*/
+#ifndef _MSC_VER
#ifdef DEFINE_GUID
#undef DEFINE_GUID
#define DEFINE_GUID(n,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) const GUID n GUID_SECT = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
#endif /* DEFINE_GUID */
+#endif
/*
@@ -147,9 +149,7 @@ winCreatePrimarySurfaceShadowDD (ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG
winDebug ("winCreatePrimarySurfaceShadowDD - Created primary surface\n");
-#endif
/*
* Attach a clipper to the primary surface that will clip our blits to our
@@ -165,10 +165,8 @@ winCreatePrimarySurfaceShadowDD (ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG
winDebug ("winCreatePrimarySurfaceShadowDD - Attached clipper to "
"primary surface\n");
-#endif
/* Everything was correct */
return TRUE;
@@ -185,7 +183,7 @@ winReleasePrimarySurfaceShadowDD (ScreenPtr pScreen)
{
winScreenPriv(pScreen);
- ErrorF ("winReleasePrimarySurfaceShadowDD - Hello\n");
+ winDebug ("winReleasePrimarySurfaceShadowDD - Hello\n");
/* Release the primary surface and clipper, if they exist */
if (pScreenPriv->pddsPrimary)
@@ -197,14 +195,14 @@ winReleasePrimarySurfaceShadowDD (ScreenPtr pScreen)
IDirectDrawSurface2_SetClipper (pScreenPriv->pddsPrimary,
NULL);
- ErrorF ("winReleasePrimarySurfaceShadowDD - Detached clipper\n");
+ winDebug ("winReleasePrimarySurfaceShadowDD - Detached clipper\n");
/* Release the primary surface */
IDirectDrawSurface2_Release (pScreenPriv->pddsPrimary);
pScreenPriv->pddsPrimary = NULL;
}
- ErrorF ("winReleasePrimarySurfaceShadowDD - Released primary surface\n");
+ winDebug ("winReleasePrimarySurfaceShadowDD - Released primary surface\n");
return TRUE;
}
@@ -227,9 +225,7 @@ winAllocateFBShadowDD (ScreenPtr pScreen)
DDSURFACEDESC ddsd;
DDSURFACEDESC *pddsdShadow = NULL;
-#if CYGDEBUG
winDebug ("winAllocateFBShadowDD\n");
-#endif
/* Create a clipper */
ddrval = (*g_fpDirectDrawCreateClipper) (0,
@@ -242,9 +238,7 @@ winAllocateFBShadowDD (ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG
winDebug ("winAllocateFBShadowDD - Created a clipper\n");
-#endif
/* Get a device context for the screen */
pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen);
@@ -261,9 +255,7 @@ winAllocateFBShadowDD (ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG
winDebug ("winAllocateFBShadowDD - Attached clipper to window\n");
-#endif
/* Create a DirectDraw object, store the address at lpdd */
ddrval = (*g_fpDirectDrawCreate) (NULL, &pScreenPriv->pdd, NULL);
@@ -274,9 +266,7 @@ winAllocateFBShadowDD (ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG
winDebug ("winAllocateFBShadowDD () - Created and initialized DD\n");
-#endif
/* Get a DirectDraw2 interface pointer */
ddrval = IDirectDraw_QueryInterface (pScreenPriv->pdd,
@@ -359,7 +349,7 @@ winAllocateFBShadowDD (ScreenPtr pScreen)
|| pScreenInfo->dwBPP != GetDeviceCaps (hdc, BITSPIXEL)
|| pScreenInfo->dwRefreshRate != 0))
{
- ErrorF ("winAllocateFBShadowDD - Changing video mode\n");
+ winDebug ("winAllocateFBShadowDD - Changing video mode\n");
/* Change the video mode to the mode requested, and use the driver default refresh rate on failure */
ddrval = IDirectDraw2_SetDisplayMode (pScreenPriv->pdd2,
@@ -391,7 +381,7 @@ winAllocateFBShadowDD (ScreenPtr pScreen)
}
else
{
- ErrorF ("winAllocateFBShadowDD - Not changing video mode\n");
+ winDebug ("winAllocateFBShadowDD - Not changing video mode\n");
}
/* Release our DC */
@@ -448,9 +438,7 @@ winAllocateFBShadowDD (ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG
winDebug ("winAllocateFBShadowDD - Created shadow\n");
-#endif
/* Allocate a DD surface description for our screen privates */
pddsdShadow = pScreenPriv->pddsdShadow = malloc (sizeof (DDSURFACEDESC));
@@ -463,9 +451,7 @@ winAllocateFBShadowDD (ScreenPtr pScreen)
ZeroMemory (pddsdShadow, sizeof (*pddsdShadow));
pddsdShadow->dwSize = sizeof (*pddsdShadow);
-#if CYGDEBUG
winDebug ("winAllocateFBShadowDD - Locking shadow\n");
-#endif
/* Lock the shadow surface */
ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow,
@@ -480,9 +466,7 @@ winAllocateFBShadowDD (ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG
winDebug ("winAllocateFBShadowDD - Locked shadow\n");
-#endif
/* We don't know how to deal with anything other than RGB */
if (!(pddsdShadow->ddpfPixelFormat.dwFlags & DDPF_RGB))
@@ -503,9 +487,7 @@ winAllocateFBShadowDD (ScreenPtr pScreen)
pScreenPriv->dwGreenMask = pddsdShadow->ddpfPixelFormat.u3.dwGBitMask;
pScreenPriv->dwBlueMask = pddsdShadow->ddpfPixelFormat.u4.dwBBitMask;
-#if CYGDEBUG
winDebug ("winAllocateFBShadowDD - Returning\n");
-#endif
return TRUE;
}
@@ -646,6 +628,7 @@ winShadowUpdateDD (ScreenPtr pScreen,
/* Has our memory pointer changed? */
if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface)
{
+ extern char *g_pszLogFile;
ErrorF ("winShadowUpdateDD - Memory location of the shadow "
"surface has changed, trying to update the root window "
"pixmap header to point to the new address. If you get "
@@ -687,9 +670,7 @@ winCloseScreenShadowDD (int nIndex, ScreenPtr pScreen)
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
Bool fReturn;
-#if CYGDEBUG
winDebug ("winCloseScreenShadowDD - Freeing screen resources\n");
-#endif
/* Flag that the screen is closed */
pScreenPriv->fClosed = TRUE;
@@ -813,7 +794,7 @@ winInitVisualsShadowDD (ScreenPtr pScreen)
else
pScreenPriv->dwBitsPerRGB = dwBlueBits;
- ErrorF ("winInitVisualsShadowDD - Masks %08x %08x %08x BPRGB %d d %d "
+ winDebug ("winInitVisualsShadowDD - Masks %08x %08x %08x BPRGB %d d %d "
"bpp %d\n",
(unsigned int) pScreenPriv->dwRedMask,
(unsigned int) pScreenPriv->dwGreenMask,
@@ -932,9 +913,7 @@ winInitVisualsShadowDD (ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG
winDebug ("winInitVisualsShadowDD - Returning\n");
-#endif
return TRUE;
}
@@ -967,7 +946,7 @@ winAdjustVideoModeShadowDD (ScreenPtr pScreen)
if (pScreenInfo->dwBPP == WIN_DEFAULT_BPP)
{
/* No -depth parameter passed, let the user know the depth being used */
- ErrorF ("winAdjustVideoModeShadowDD - Using Windows display "
+ winDebug ("winAdjustVideoModeShadowDD - Using Windows display "
"depth of %d bits per pixel\n", (int) dwBPP);
/* Use GDI's depth */
@@ -977,13 +956,13 @@ winAdjustVideoModeShadowDD (ScreenPtr pScreen)
&& pScreenInfo->dwBPP != dwBPP)
{
/* FullScreen, and GDI depth differs from -depth parameter */
- ErrorF ("winAdjustVideoModeShadowDD - FullScreen, using command line "
+ winDebug ("winAdjustVideoModeShadowDD - FullScreen, using command line "
"bpp: %d\n", (int) pScreenInfo->dwBPP);
}
else if (dwBPP != pScreenInfo->dwBPP)
{
/* Windowed, and GDI depth differs from -depth parameter */
- ErrorF ("winAdjustVideoModeShadowDD - Windowed, command line bpp: "
+ winDebug ("winAdjustVideoModeShadowDD - Windowed, command line bpp: "
"%d, using bpp: %d\n", (int) pScreenInfo->dwBPP, (int) dwBPP);
/* We'll use GDI's depth */
@@ -1379,10 +1358,8 @@ winDestroyColormapShadowDD (ColormapPtr pColormap)
*/
if (pColormap->flags & IsDefault)
{
-#if CYGDEBUG
winDebug ("winDestroyColormapShadowDD - Destroying default "
"colormap\n");
-#endif
/*
* FIXME: Walk the list of all screens, popping the default
diff --git a/xorg-server/hw/xwin/winshadddnl.c b/xorg-server/hw/xwin/winshadddnl.c
index ef5c21469..b8d6222ac 100644
--- a/xorg-server/hw/xwin/winshadddnl.c
+++ b/xorg-server/hw/xwin/winshadddnl.c
@@ -48,10 +48,12 @@ extern HWND g_hDlgExit;
* FIXME: Headers are broken, DEFINE_GUID doesn't work correctly,
* so we have to redefine it here.
*/
+#ifndef _MSC_VER
#ifdef DEFINE_GUID
#undef DEFINE_GUID
#define DEFINE_GUID(n,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) const GUID n GUID_SECT = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
#endif /* DEFINE_GUID */
+#endif
/*
* FIXME: Headers are broken, IID_IDirectDraw4 has to be defined
@@ -161,9 +163,7 @@ winCreatePrimarySurfaceShadowDDNL (ScreenPtr pScreen)
return FALSE;
}
-#if 1
winDebug ("winCreatePrimarySurfaceShadowDDNL - Created primary surface\n");
-#endif
/* Attach our clipper to our primary surface handle */
ddrval = IDirectDrawSurface4_SetClipper (pScreenPriv->pddsPrimary4,
@@ -176,10 +176,8 @@ winCreatePrimarySurfaceShadowDDNL (ScreenPtr pScreen)
return FALSE;
}
-#if 1
winDebug ("winCreatePrimarySurfaceShadowDDNL - Attached clipper to primary "
"surface\n");
-#endif
/* Everything was correct */
return TRUE;
@@ -239,10 +237,8 @@ winAllocateFBShadowDDNL (ScreenPtr pScreen)
char *lpSurface = NULL;
DDPIXELFORMAT ddpfPrimary;
-#if CYGDEBUG
winDebug ("winAllocateFBShadowDDNL - w %d h %d d %d\n",
pScreenInfo->dwWidth, pScreenInfo->dwHeight, pScreenInfo->dwDepth);
-#endif
/* Allocate memory for our shadow surface */
lpSurface = malloc (pScreenInfo->dwPaddedWidth * pScreenInfo->dwHeight);
@@ -269,9 +265,7 @@ winAllocateFBShadowDDNL (ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG
winDebug ("winAllocateFBShadowDDNL - Created a clipper\n");
-#endif
/* Get a device context for the screen */
pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen);
@@ -288,9 +282,7 @@ winAllocateFBShadowDDNL (ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG
winDebug ("winAllocateFBShadowDDNL - Attached clipper to window\n");
-#endif
/* Create a DirectDraw object, store the address at lpdd */
ddrval = (*g_fpDirectDrawCreate) (NULL,
@@ -304,9 +296,7 @@ winAllocateFBShadowDDNL (ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG
winDebug ("winAllocateFBShadowDDNL - Created and initialized DD\n");
-#endif
/* Get a DirectDraw4 interface pointer */
ddrval = IDirectDraw_QueryInterface (pScreenPriv->pdd,
@@ -464,14 +454,12 @@ winAllocateFBShadowDDNL (ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG
winDebug ("winAllocateFBShadowDDNL - Primary masks: %08x %08x %08x "
"dwRGBBitCount: %d\n",
ddpfPrimary.u2.dwRBitMask,
ddpfPrimary.u3.dwGBitMask,
ddpfPrimary.u4.dwBBitMask,
ddpfPrimary.u1.dwRGBBitCount);
-#endif
/* Describe the shadow surface to be created */
/*
@@ -508,19 +496,15 @@ winAllocateFBShadowDDNL (ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG || YES
winDebug ("winAllocateFBShadowDDNL - Created shadow pitch: %d\n",
(int) ddsdShadow.u1.lPitch);
-#endif
/* Grab the pitch from the surface desc */
pScreenInfo->dwStride = (ddsdShadow.u1.lPitch * 8)
/ pScreenInfo->dwBPP;
-#if CYGDEBUG || YES
winDebug ("winAllocateFBShadowDDNL - Created shadow stride: %d\n",
(int) pScreenInfo->dwStride);
-#endif
/* Save the pointer to our surface memory */
pScreenInfo->pfb = lpSurface;
@@ -530,9 +514,7 @@ winAllocateFBShadowDDNL (ScreenPtr pScreen)
pScreenPriv->dwGreenMask = ddsdShadow.u4.ddpfPixelFormat.u3.dwGBitMask;
pScreenPriv->dwBlueMask = ddsdShadow.u4.ddpfPixelFormat.u4.dwBBitMask;
-#if CYGDEBUG
winDebug ("winAllocateFBShadowDDNL - Returning\n");
-#endif
return TRUE;
}
@@ -696,11 +678,9 @@ winShadowUpdateDDNL (ScreenPtr pScreen,
DeleteObject (hrgnCombined);
hrgnCombined = NULL;
-#if CYGDEBUG
winDebug ("winShadowUpdateDDNL - be x1 %d y1 %d x2 %d y2 %d\n",
pBoxExtents->x1, pBoxExtents->y1,
pBoxExtents->x2, pBoxExtents->y2);
-#endif
/* Calculating a bounding box for the source is easy */
rcSrc.left = pBoxExtents->x1;
@@ -741,9 +721,7 @@ winCloseScreenShadowDDNL (int nIndex, ScreenPtr pScreen)
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
Bool fReturn;
-#if CYGDEBUG
winDebug ("winCloseScreenShadowDDNL - Freeing screen resources\n");
-#endif
/* Flag that the screen is closed */
pScreenPriv->fClosed = TRUE;
@@ -987,9 +965,7 @@ winInitVisualsShadowDDNL (ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG
winDebug ("winInitVisualsShadowDDNL - Returning\n");
-#endif
return TRUE;
}
@@ -1022,7 +998,7 @@ winAdjustVideoModeShadowDDNL (ScreenPtr pScreen)
if (pScreenInfo->dwBPP == WIN_DEFAULT_BPP)
{
/* No -depth parameter passed, let the user know the depth being used */
- winErrorFVerb (2, "winAdjustVideoModeShadowDDNL - Using Windows display "
+ winDebug ("winAdjustVideoModeShadowDDNL - Using Windows display "
"depth of %d bits per pixel\n", (int) dwBPP);
/* Use GDI's depth */
@@ -1032,13 +1008,13 @@ winAdjustVideoModeShadowDDNL (ScreenPtr pScreen)
&& pScreenInfo->dwBPP != dwBPP)
{
/* FullScreen, and GDI depth differs from -depth parameter */
- winErrorFVerb (2, "winAdjustVideoModeShadowDDNL - FullScreen, using command "
+ winDebug ("winAdjustVideoModeShadowDDNL - FullScreen, using command "
"line bpp: %d\n", (int) pScreenInfo->dwBPP);
}
else if (dwBPP != pScreenInfo->dwBPP)
{
/* Windowed, and GDI depth differs from -depth parameter */
- winErrorFVerb (2, "winAdjustVideoModeShadowDDNL - Windowed, command line "
+ winDebug ("winAdjustVideoModeShadowDDNL - Windowed, command line "
"bpp: %d, using bpp: %d\n",
(int) pScreenInfo->dwBPP, (int) dwBPP);
@@ -1050,7 +1026,7 @@ winAdjustVideoModeShadowDDNL (ScreenPtr pScreen)
if (pScreenInfo->dwWidth * pScreenInfo->dwHeight * pScreenInfo->dwBPP
>= WIN_DIB_MAXIMUM_SIZE)
{
- winErrorFVerb (1, "winAdjustVideoModeShadowDDNL - Requested DirectDraw surface "
+ ErrorF ("winAdjustVideoModeShadowDDNL - Requested DirectDraw surface "
"will be larger than %d MB. The surface may fail to be "
"allocated on Windows 95, 98, or Me, due to a %d MB limit in "
"DIB size. This limit does not apply to Windows NT/2000, and "
@@ -1134,7 +1110,7 @@ winBltExposedRegionsShadowDDNL (ScreenPtr pScreen)
if (ddrval == DDERR_SURFACELOST)
{
/* Surface was lost */
- winErrorFVerb (1, "winBltExposedRegionsShadowDDNL - "
+ ErrorF ("winBltExposedRegionsShadowDDNL - "
"IDirectDrawSurface4_Blt reported that the primary "
"surface was lost, trying to restore, retry: %d\n", i + 1);
@@ -1164,7 +1140,7 @@ winBltExposedRegionsShadowDDNL (ScreenPtr pScreen)
else if (FAILED (ddrval))
{
fReturn = FALSE;
- winErrorFVerb (1, "winBltExposedRegionsShadowDDNL - "
+ ErrorF ("winBltExposedRegionsShadowDDNL - "
"IDirectDrawSurface4_Blt failed, but surface not "
"lost: %08x %d\n",
(unsigned int) ddrval, (int) ddrval);
@@ -1392,9 +1368,7 @@ winDestroyColormapShadowDDNL (ColormapPtr pColormap)
*/
if (pColormap->flags & IsDefault)
{
-#if CYGDEBUG
winDebug ("winDestroyColormapShadowDDNL - Destroying default colormap\n");
-#endif
/*
* FIXME: Walk the list of all screens, popping the default
diff --git a/xorg-server/hw/xwin/winshadgdi.c b/xorg-server/hw/xwin/winshadgdi.c
index d38e4f76b..fbc15abb3 100644
--- a/xorg-server/hw/xwin/winshadgdi.c
+++ b/xorg-server/hw/xwin/winshadgdi.c
@@ -109,7 +109,7 @@ winQueryScreenDIBFormat (ScreenPtr pScreen, BITMAPINFOHEADER *pbmih)
{
winScreenPriv(pScreen);
HBITMAP hbmp;
-#if CYGDEBUG
+#ifdef WINDBG
LPDWORD pdw = NULL;
#endif
@@ -138,7 +138,7 @@ winQueryScreenDIBFormat (ScreenPtr pScreen, BITMAPINFOHEADER *pbmih)
return FALSE;
}
-#if CYGDEBUG
+#ifdef WINDBG
/* Get a pointer to bitfields */
pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
@@ -199,7 +199,7 @@ winQueryRGBBitsAndMasks (ScreenPtr pScreen)
if (GetDeviceCaps (pScreenPriv->hdcScreen, PLANES)
* GetDeviceCaps (pScreenPriv->hdcScreen, BITSPIXEL) == 24)
{
- ErrorF ("winQueryRGBBitsAndMasks - GetDeviceCaps (BITSPIXEL) "
+ winDebug ("winQueryRGBBitsAndMasks - GetDeviceCaps (BITSPIXEL) "
"returned 24 for the screen. Using default 24bpp masks.\n");
/* 8 bits per primary color */
@@ -228,7 +228,7 @@ winQueryRGBBitsAndMasks (ScreenPtr pScreen)
/* Get a pointer to bitfields */
pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
-#if CYGDEBUG
+#ifdef WINDBG
winDebug ("%s - Masks: %08x %08x %08x\n", __FUNCTION__,
pdw[0], pdw[1], pdw[2]);
winDebug ("%s - Bitmap: %dx%d %d bpp %d planes\n", __FUNCTION__,
@@ -372,7 +372,7 @@ winAllocateFBShadowGDI (ScreenPtr pScreen)
pbmih->biWidth = pScreenInfo->dwWidth;
pbmih->biHeight = -pScreenInfo->dwHeight;
- ErrorF ("winAllocateFBShadowGDI - Creating DIB with width: %d height: %d "
+ winDebug ("winAllocateFBShadowGDI - Creating DIB with width: %d height: %d "
"depth: %d\n",
(int) pbmih->biWidth, (int) -pbmih->biHeight, pbmih->biBitCount);
@@ -385,14 +385,12 @@ winAllocateFBShadowGDI (ScreenPtr pScreen)
0);
if (pScreenPriv->hbmpShadow == NULL || pScreenInfo->pfb == NULL)
{
- winW32Error (2, "winAllocateFBShadowGDI - CreateDIBSection failed:");
+ winW32Error ("winAllocateFBShadowGDI - CreateDIBSection failed:");
return FALSE;
}
else
{
-#if CYGDEBUG
winDebug ("winAllocateFBShadowGDI - Shadow buffer allocated\n");
-#endif
}
/* Get information about the bitmap that was allocated */
@@ -400,22 +398,18 @@ winAllocateFBShadowGDI (ScreenPtr pScreen)
sizeof (dibsection),
&dibsection);
-#if CYGDEBUG || YES
/* Print information about bitmap allocated */
winDebug ("winAllocateFBShadowGDI - Dibsection width: %d height: %d "
"depth: %d size image: %d\n",
(int) dibsection.dsBmih.biWidth, (int) dibsection.dsBmih.biHeight,
dibsection.dsBmih.biBitCount,
(int) dibsection.dsBmih.biSizeImage);
-#endif
/* Select the shadow bitmap into the shadow DC */
SelectObject (pScreenPriv->hdcShadow,
pScreenPriv->hbmpShadow);
-#if CYGDEBUG
winDebug ("winAllocateFBShadowGDI - Attempting a shadow blit\n");
-#endif
/* Do a test blit from the shadow to the screen, I think */
fReturn = BitBlt (pScreenPriv->hdcScreen,
@@ -426,21 +420,15 @@ winAllocateFBShadowGDI (ScreenPtr pScreen)
SRCCOPY);
if (fReturn)
{
-#if CYGDEBUG
winDebug ("winAllocateFBShadowGDI - Shadow blit success\n");
-#endif
}
else
{
- winW32Error (2, "winAllocateFBShadowGDI - Shadow blit failure\n");
-#if 0
- return FALSE;
-#else
+ winW32Error ("winAllocateFBShadowGDI - Shadow blit failure\n");
/* ago: ignore this error. The blit fails with wine, but does not
* cause any problems later. */
fReturn = TRUE;
-#endif
}
/* Look for height weirdness */
@@ -454,10 +442,8 @@ winAllocateFBShadowGDI (ScreenPtr pScreen)
/ dibsection.dsBmih.biHeight)
* 8) / pScreenInfo->dwBPP;
-#if CYGDEBUG || YES
winDebug ("winAllocateFBShadowGDI - Created shadow stride: %d\n",
(int) pScreenInfo->dwStride);
-#endif
/* See if the shadow bitmap will be larger than the DIB size limit */
if (pScreenInfo->dwWidth * pScreenInfo->dwHeight * pScreenInfo->dwBPP
@@ -524,15 +510,17 @@ winShadowUpdateGDI (ScreenPtr pScreen,
if (dwBox != 1)
{
++s_dwNonUnitRegions;
- ErrorF ("winShadowUpdatGDI - dwBox: %d\n", dwBox);
+ winDebug ("winShadowUpdatGDI - dwBox: %d\n", dwBox);
}
if ((s_dwTotalUpdates % 100) == 0)
- ErrorF ("winShadowUpdateGDI - %d%% non-unity regions, avg boxes: %d "
+ {
+ winDebug ("winShadowUpdateGDI - %d%% non-unity regions, avg boxes: %d "
"nu: %d tu: %d\n",
(s_dwNonUnitRegions * 100) / s_dwTotalUpdates,
s_dwTotalBoxes / s_dwTotalUpdates,
s_dwNonUnitRegions, s_dwTotalUpdates);
+ }
#endif /* XWIN_UPDATESTATS */
/*
@@ -625,9 +613,7 @@ winCloseScreenShadowGDI (int nIndex, ScreenPtr pScreen)
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
Bool fReturn;
-#if CYGDEBUG
winDebug ("winCloseScreenShadowGDI - Freeing screen resources\n");
-#endif
/* Flag that the screen is closed */
pScreenPriv->fClosed = TRUE;
@@ -700,7 +686,7 @@ winInitVisualsShadowGDI (ScreenPtr pScreen)
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
/* Display debugging information */
- ErrorF ("winInitVisualsShadowGDI - Masks %08x %08x %08x BPRGB %d d %d "
+ winDebug ("winInitVisualsShadowGDI - Masks %08x %08x %08x BPRGB %d d %d "
"bpp %d\n",
(unsigned int) pScreenPriv->dwRedMask,
(unsigned int) pScreenPriv->dwGreenMask,
@@ -816,9 +802,7 @@ winInitVisualsShadowGDI (ScreenPtr pScreen)
return FALSE;
}
-#if CYGDEBUG
winDebug ("winInitVisualsShadowGDI - Returning\n");
-#endif
return TRUE;
}
@@ -852,7 +836,7 @@ winAdjustVideoModeShadowGDI (ScreenPtr pScreen)
if (pScreenInfo->dwBPP == WIN_DEFAULT_BPP)
{
/* No -depth parameter passed, let the user know the depth being used */
- ErrorF ("winAdjustVideoModeShadowGDI - Using Windows display "
+ winDebug ("winAdjustVideoModeShadowGDI - Using Windows display "
"depth of %d bits per pixel\n", (int) dwBPP);
/* Use GDI's depth */
@@ -861,7 +845,7 @@ winAdjustVideoModeShadowGDI (ScreenPtr pScreen)
else if (dwBPP != pScreenInfo->dwBPP)
{
/* Warn user if GDI depth is different than -depth parameter */
- ErrorF ("winAdjustVideoModeShadowGDI - Command line bpp: %d, "\
+ winDebug ("winAdjustVideoModeShadowGDI - Command line bpp: %d, "\
"using bpp: %d\n", (int) pScreenInfo->dwBPP, (int) dwBPP);
/* We'll use GDI's depth */
@@ -1010,17 +994,13 @@ winRealizeInstalledPaletteShadowGDI (ScreenPtr pScreen)
winScreenPriv(pScreen);
winPrivCmapPtr pCmapPriv = NULL;
-#if CYGDEBUG
winDebug ("winRealizeInstalledPaletteShadowGDI\n");
-#endif
/* Don't do anything if there is not a colormap */
if (pScreenPriv->pcmapInstalled == NULL)
{
-#if CYGDEBUG
winDebug ("winRealizeInstalledPaletteShadowGDI - No colormap "
"installed\n");
-#endif
return TRUE;
}
@@ -1247,10 +1227,8 @@ winDestroyColormapShadowGDI (ColormapPtr pColormap)
*/
if (pColormap->flags & IsDefault)
{
-#if CYGDEBUG
winDebug ("winDestroyColormapShadowGDI - Destroying default "
"colormap\n");
-#endif
/*
* FIXME: Walk the list of all screens, popping the default
diff --git a/xorg-server/hw/xwin/wintrayicon.c b/xorg-server/hw/xwin/wintrayicon.c
index 895b47caf..7750932b4 100644
--- a/xorg-server/hw/xwin/wintrayicon.c
+++ b/xorg-server/hw/xwin/wintrayicon.c
@@ -36,35 +36,43 @@
#include <shellapi.h>
#include "winprefs.h"
+static NOTIFYICONDATA nid;
/*
* Initialize the tray icon
*/
void
-winInitNotifyIcon (winPrivScreenPtr pScreenPriv)
+winInitNotifyIcon (winPrivScreenPtr pScreenPriv, Bool Modify)
{
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- NOTIFYICONDATA nid = {0};
+ char HostName[256];
- nid.cbSize = sizeof (NOTIFYICONDATA);
- nid.hWnd = pScreenPriv->hwndScreen;
- nid.uID = pScreenInfo->dwScreen;
- nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
- nid.uCallbackMessage = WM_TRAYICON;
- nid.hIcon = winTaskbarIcon ();
+ if (!Modify)
+ {
+ nid.cbSize = sizeof (NOTIFYICONDATA);
+ nid.hWnd = pScreenPriv->hwndScreen;
+ nid.uID = pScreenInfo->dwScreen;
+ nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
+ nid.uCallbackMessage = WM_TRAYICON;
+ nid.hIcon = winTaskbarIcon ();
+
+ /* Save handle to the icon so it can be freed later */
+ pScreenPriv->hiconNotifyIcon = nid.hIcon;
+ }
- /* Save handle to the icon so it can be freed later */
- pScreenPriv->hiconNotifyIcon = nid.hIcon;
+ gethostname(HostName,256);
/* Set display and screen-specific tooltip text */
snprintf (nid.szTip,
sizeof (nid.szTip),
- PROJECT_NAME " Server:%s.%d",
+ PROJECT_NAME " Server - %s:%s.%d - %d clients",
+ HostName,
display,
- (int) pScreenInfo->dwScreen);
+ (int) pScreenInfo->dwScreen,
+ pScreenPriv->iConnectedClients);
/* Add the tray icon */
- if (!Shell_NotifyIcon (NIM_ADD, &nid))
+ if (!Shell_NotifyIcon ((Modify) ? NIM_MODIFY : NIM_ADD, &nid))
ErrorF ("winInitNotifyIcon - Shell_NotifyIcon Failed\n");
}
@@ -79,10 +87,6 @@ winDeleteNotifyIcon (winPrivScreenPtr pScreenPriv)
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
NOTIFYICONDATA nid = {0};
-#if 0
- ErrorF ("winDeleteNotifyIcon\n");
-#endif
-
nid.cbSize = sizeof (NOTIFYICONDATA);
nid.hWnd = pScreenPriv->hwndScreen;
nid.uID = pScreenInfo->dwScreen;
@@ -119,6 +123,17 @@ winHandleIconMessage (HWND hwnd, UINT message,
switch (lParam)
{
+ case WM_MOUSEMOVE:
+ {
+ static int PrevNrClients;
+ int NrClients=GetLiveClients(pScreenPriv);
+ if (NrClients!=PrevNrClients)
+ {
+ PrevNrClients=NrClients;
+ winInitNotifyIcon (pScreenPriv, TRUE);
+ }
+ }
+ break;
case WM_LBUTTONUP:
/* Restack and bring all windows to top */
SetForegroundWindow (hwnd);
diff --git a/xorg-server/hw/xwin/winvalargs.c b/xorg-server/hw/xwin/winvalargs.c
index 038e097a5..1c9b17fde 100644
--- a/xorg-server/hw/xwin/winvalargs.c
+++ b/xorg-server/hw/xwin/winvalargs.c
@@ -75,7 +75,7 @@ winValidateArgs (void)
if (g_ScreenInfo[i].fExplicitScreen)
iMaxConsecutiveScreen = i + 1;
}
- winErrorFVerb (2, "winValidateArgs - g_iNumScreens: %d "
+ winDebug ("winValidateArgs - g_iNumScreens: %d "
"iMaxConsecutiveScreen: %d\n",
g_iNumScreens, iMaxConsecutiveScreen);
if (g_iNumScreens < iMaxConsecutiveScreen)
diff --git a/xorg-server/hw/xwin/winwin32rootless.c b/xorg-server/hw/xwin/winwin32rootless.c
index c225a4495..f76363e43 100644
--- a/xorg-server/hw/xwin/winwin32rootless.c
+++ b/xorg-server/hw/xwin/winwin32rootless.c
@@ -323,9 +323,7 @@ winMWExtWMCreateFrame (RootlessWindowPtr pFrame, ScreenPtr pScreen,
fResult = FALSE;
}
-#if CYGMULTIWINDOW_DEBUG
winDebug ("winMWExtWMCreateFrame - ShowWindow\n");
-#endif
//ShowWindow (pRLWinPriv->hWnd, SW_SHOWNOACTIVATE);
g_fNoConfigureWindow = FALSE;
@@ -799,9 +797,7 @@ winMWExtWMStartDrawing (RootlessFrameID wid, char **pixelData, int *bytesPerRow)
SRCCOPY);
if (fReturn)
{
-#if CYGMULTIWINDOW_DEBUG
winDebug ("winMWExtWMStartDrawing - Shadow blit success\n");
-#endif
}
else
{
@@ -822,10 +818,8 @@ winMWExtWMStartDrawing (RootlessFrameID wid, char **pixelData, int *bytesPerRow)
pRLWinPriv->dwWidthBytes = dibsection.dsBm.bmWidthBytes;
-#if CYGMULTIWINDOW_DEBUG
winDebug ("winMWExtWMStartDrawing - bytesPerRow: %d\n",
(unsigned int)dibsection.dsBm.bmWidthBytes);
-#endif
/* Free the old shadow bitmap */
DeleteObject (pRLWinPriv->hdcShadow);
@@ -835,22 +829,18 @@ winMWExtWMStartDrawing (RootlessFrameID wid, char **pixelData, int *bytesPerRow)
pRLWinPriv->hbmpShadow = hbmpNew;
pRLWinPriv->fResized = FALSE;
-#if CYGMULTIWINDOW_DEBUG && FALSE
winDebug ("winMWExtWMStartDrawing - 0x%08x %d\n",
(unsigned int)pRLWinPriv->pfb,
(unsigned int)dibsection.dsBm.bmWidthBytes);
-#endif
}
}
else
{
ErrorF ("winMWExtWMStartDrawing - Already window was destroyed \n");
}
-#if CYGMULTIWINDOW_DEBUG
winDebug ("winMWExtWMStartDrawing - done (0x%08x) 0x%08x %d\n",
(int) pRLWinPriv,
(unsigned int)pRLWinPriv->pfb, (unsigned int)pRLWinPriv->dwWidthBytes);
-#endif
*pixelData = pRLWinPriv->pfb;
*bytesPerRow = pRLWinPriv->dwWidthBytes;
}
@@ -858,77 +848,12 @@ winMWExtWMStartDrawing (RootlessFrameID wid, char **pixelData, int *bytesPerRow)
void
winMWExtWMStopDrawing (RootlessFrameID wid, Bool fFlush)
{
-#if 0
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
- BLENDFUNCTION bfBlend;
- SIZE szWin;
- POINT ptSrc;
-#if CYGMULTIWINDOW_DEBUG || TRUE
- winDebug ("winMWExtWMStopDrawing (%08x)\n", pRLWinPriv);
-#endif
- szWin.cx = pRLWinPriv->dwWidth;
- szWin.cy = pRLWinPriv->dwHeight;
- ptSrc.x = 0;
- ptSrc.y = 0;
- bfBlend.BlendOp = AC_SRC_OVER;
- bfBlend.BlendFlags = 0;
- bfBlend.SourceConstantAlpha = 255;
- bfBlend.AlphaFormat = AC_SRC_ALPHA;
-
- if (!UpdateLayeredWindow (pRLWinPriv->hWnd,
- NULL, NULL, &szWin,
- pRLWinPriv->hdcShadow, &ptSrc,
- 0, &bfBlend, ULW_ALPHA))
- {
- ErrorF ("winMWExtWMStopDrawing - UpdateLayeredWindow failed\n");
- }
-#endif
}
void
winMWExtWMUpdateRegion (RootlessFrameID wid, RegionPtr pDamage)
{
win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
-#if 0
- BLENDFUNCTION bfBlend;
- SIZE szWin;
- POINT ptSrc;
-#endif
-#if CYGMULTIWINDOW_DEBUG && 0
- winDebug ("winMWExtWMUpdateRegion (%08x)\n", pRLWinPriv);
-#endif
-#if 0
- szWin.cx = pRLWinPriv->dwWidth;
- szWin.cy = pRLWinPriv->dwHeight;
- ptSrc.x = 0;
- ptSrc.y = 0;
- bfBlend.BlendOp = AC_SRC_OVER;
- bfBlend.BlendFlags = 0;
- bfBlend.SourceConstantAlpha = 255;
- bfBlend.AlphaFormat = AC_SRC_ALPHA;
-
- if (!UpdateLayeredWindow (pRLWinPriv->hWnd,
- NULL, NULL, &szWin,
- pRLWinPriv->hdcShadow, &ptSrc,
- 0, &bfBlend, ULW_ALPHA))
- {
- LPVOID lpMsgBuf;
-
- /* Display a fancy error message */
- FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- GetLastError (),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &lpMsgBuf,
- 0, NULL);
-
- ErrorF ("winMWExtWMUpdateRegion - UpdateLayeredWindow failed: %s\n",
- (LPSTR)lpMsgBuf);
- LocalFree (lpMsgBuf);
- }
-#endif
if (!g_fNoConfigureWindow) UpdateWindow (pRLWinPriv->hWnd);
}
@@ -938,10 +863,8 @@ winMWExtWMDamageRects (RootlessFrameID wid, int nCount, const BoxRec *pRects,
{
win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
const BoxRec *pEnd;
-#if CYGMULTIWINDOW_DEBUG && 0
winDebug ("winMWExtWMDamageRects (%08x, %d, %08x, %d, %d)\n",
pRLWinPriv, nCount, pRects, shift_x, shift_y);
-#endif
for (pEnd = pRects + nCount; pRects < pEnd; pRects++) {
RECT rcDmg;
@@ -958,10 +881,8 @@ void
winMWExtWMRootlessSwitchWindow (RootlessWindowPtr pFrame, WindowPtr oldWin)
{
win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) pFrame->wid;
-#if CYGMULTIWINDOW_DEBUG
winDebug ("winMWExtWMRootlessSwitchWindow (%08x) %08x\n",
(int) pRLWinPriv, (int) pRLWinPriv->hWnd);
-#endif
pRLWinPriv->pFrame = pFrame;
pRLWinPriv->fResized = TRUE;
@@ -974,26 +895,6 @@ winMWExtWMRootlessSwitchWindow (RootlessWindowPtr pFrame, WindowPtr oldWin)
DeleteProperty (serverClient, oldWin, AtmWindowsWmNativeHwnd ());
winMWExtWMSetNativeProperty (pFrame);
-#if CYGMULTIWINDOW_DEBUG
-#if 0
- {
- WindowPtr pWin2 = NULL;
- win32RootlessWindowPtr pRLWinPriv2 = NULL;
-
- /* Check if the Windows window property for our X window pointer is valid */
- if ((pWin2 = (WindowPtr)GetProp (pRLWinPriv->hWnd, WIN_WINDOW_PROP)) != NULL)
- {
- pRLWinPriv2 = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin2, FALSE);
- }
- winDebug ("winMWExtWMSwitchFrame2 (%08x) %08x\n",
- pRLWinPriv2, pRLWinPriv2->hWnd);
- if (pRLWinPriv != pRLWinPriv2 || pRLWinPriv->hWnd != pRLWinPriv2->hWnd)
- {
- winDebug ("Error param missmatch\n");
- }
- }
-#endif
-#endif
}
void
@@ -1001,18 +902,14 @@ winMWExtWMCopyBytes (unsigned int width, unsigned int height,
const void *src, unsigned int srcRowBytes,
void *dst, unsigned int dstRowBytes)
{
-#if CYGMULTIWINDOW_DEBUG
winDebug ("winMWExtWMCopyBytes - Not implemented\n");
-#endif
}
void
winMWExtWMFillBytes (unsigned int width, unsigned int height, unsigned int value,
void *dst, unsigned int dstRowBytes)
{
-#if CYGMULTIWINDOW_DEBUG
winDebug ("winMWExtWMFillBytes - Not implemented\n");
-#endif
}
int
@@ -1021,9 +918,7 @@ winMWExtWMCompositePixels (unsigned int width, unsigned int height, unsigned int
void *mask, unsigned int maskRowBytes,
void *dst[2], unsigned int dstRowBytes[2])
{
-#if CYGMULTIWINDOW_DEBUG
winDebug ("winMWExtWMCompositePixels - Not implemented\n");
-#endif
return 0;
}
@@ -1035,21 +930,17 @@ winMWExtWMCopyWindow (RootlessFrameID wid, int nDstRects, const BoxRec *pDstRect
win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
const BoxRec *pEnd;
RECT rcDmg;
-#if CYGMULTIWINDOW_DEBUG
winDebug ("winMWExtWMCopyWindow (%08x, %d, %08x, %d, %d)\n",
(int) pRLWinPriv, nDstRects, (int) pDstRects, nDx, nDy);
-#endif
for (pEnd = pDstRects + nDstRects; pDstRects < pEnd; pDstRects++)
{
-#if CYGMULTIWINDOW_DEBUG
winDebug ("BitBlt (%d, %d, %d, %d) (%d, %d)\n",
pDstRects->x1, pDstRects->y1,
pDstRects->x2 - pDstRects->x1,
pDstRects->y2 - pDstRects->y1,
pDstRects->x1 + nDx,
pDstRects->y1 + nDy);
-#endif
if (!BitBlt (pRLWinPriv->hdcShadow,
pDstRects->x1, pDstRects->y1,
@@ -1069,9 +960,7 @@ winMWExtWMCopyWindow (RootlessFrameID wid, int nDstRects, const BoxRec *pDstRect
InvalidateRect (pRLWinPriv->hWnd, &rcDmg, FALSE);
}
-#if CYGMULTIWINDOW_DEBUG
winDebug ("winMWExtWMCopyWindow - done\n");
-#endif
}
diff --git a/xorg-server/hw/xwin/winwin32rootlesswndproc.c b/xorg-server/hw/xwin/winwin32rootlesswndproc.c
index 4d7afee42..71979456d 100644
--- a/xorg-server/hw/xwin/winwin32rootlesswndproc.c
+++ b/xorg-server/hw/xwin/winwin32rootlesswndproc.c
@@ -441,7 +441,6 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
wmMsg.iHeight = pRLWinPriv->pFrame->height;
fWMMsgInitialized = TRUE;
-#if CYGDEBUG
winDebugWin32Message("winMWExtWMWindowProc", hwnd, message, wParam, lParam);
winDebug ("\thWnd %08X\n", hwnd);
@@ -450,7 +449,6 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
winDebug ("\thwndScreen %08X\n", hwndScreen);
winDebug ("winMWExtWMWindowProc (%08x) %08x %08x %08x\n",
pRLWinPriv, message, wParam, lParam);
-#endif
}
/* Branch on message type */
switch (message)
@@ -784,9 +782,7 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
return 0;
case WM_ERASEBKGND:
-#if CYGDEBUG
winDebug ("winMWExtWMWindowProc - WM_ERASEBKGND\n");
-#endif
/*
* Pretend that we did erase the background but we don't care,
* since we repaint the entire region anyhow
@@ -1324,11 +1320,11 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
break;
case WM_MANAGE:
- ErrorF ("winMWExtWMWindowProc - WM_MANAGE\n");
+ winDebug ("winMWExtWMWindowProc - WM_MANAGE\n");
break;
case WM_UNMANAGE:
- ErrorF ("winMWExtWMWindowProc - WM_UNMANAGE\n");
+ winDebug ("winMWExtWMWindowProc - WM_UNMANAGE\n");
break;
default:
diff --git a/xorg-server/hw/xwin/winwindow.c b/xorg-server/hw/xwin/winwindow.c
index 0e75a2c6a..6f22a5a6e 100644
--- a/xorg-server/hw/xwin/winwindow.c
+++ b/xorg-server/hw/xwin/winwindow.c
@@ -58,13 +58,12 @@ winReshapeRootless (WindowPtr pWin);
Bool
winCreateWindowNativeGDI (WindowPtr pWin)
{
+ Bool fResult;
ScreenPtr pScreen = pWin->drawable.pScreen;
winWindowPriv(pWin);
winScreenPriv(pScreen);
-#if CYGDEBUG
- winTrace ("winCreateWindowNativeGDI (%p)\n", pWin);
-#endif
+ winDebug ("winCreateWindowNativeGDI (%p)\n", pWin);
WIN_UNWRAP(CreateWindow);
fResult = (*pScreen->CreateWindow) (pWin);
@@ -85,9 +84,7 @@ winDestroyWindowNativeGDI (WindowPtr pWin)
winWindowPriv(pWin);
winScreenPriv(pScreen);
-#if CYGDEBUG
- winTrace ("winDestroyWindowNativeGDI (%p)\n", pWin);
-#endif
+ winDebug ("winDestroyWindowNativeGDI (%p)\n", pWin);
WIN_UNWRAP(DestroyWindow);
fResult = (*pScreen->DestroyWindow)(pWin);
@@ -108,9 +105,7 @@ winPositionWindowNativeGDI (WindowPtr pWin, int x, int y)
winWindowPriv(pWin);
winScreenPriv(pScreen);
-#if CYGDEBUG
- winTrace ("winPositionWindowNativeGDI (%p)\n", pWin);
-#endif
+ winDebug ("winPositionWindowNativeGDI (%p)\n", pWin);
WIN_UNWRAP(PositionWindow);
fResult = (*pScreen->PositionWindow)(pWin, x, y);
@@ -139,10 +134,6 @@ winCopyWindowNativeGDI (WindowPtr pWin,
ScreenPtr pScreen = pWin->drawable.pScreen;
winScreenPriv(pScreen);
-#if 0
- ErrorF ("winCopyWindow\n");
-#endif
-
/* Get a pointer to the root window */
pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
@@ -182,19 +173,9 @@ winCopyWindowNativeGDI (WindowPtr pWin,
pBoxDst = REGION_RECTS(prgnDst);
ppt = pptSrc;
-#if 0
- ErrorF ("winCopyWindow - x1\tx2\ty1\ty2\tx\ty\n");
-#endif
-
/* BitBlt each source to the destination point */
for (i = nbox; --i >= 0; pBoxDst++, ppt++)
{
-#if 0
- ErrorF ("winCopyWindow - %d\t%d\t%d\t%d\t%d\t%d\n",
- pBoxDst->x1, pBoxDst->x2, pBoxDst->y1, pBoxDst->y2,
- ppt->x, ppt->y);
-#endif
-
BitBlt (pScreenPriv->hdcScreen,
pBoxDst->x1, pBoxDst->y1,
pBoxDst->x2 - pBoxDst->x1, pBoxDst->y2 - pBoxDst->y1,
@@ -220,9 +201,7 @@ winChangeWindowAttributesNativeGDI (WindowPtr pWin, unsigned long mask)
winWindowPriv(pWin);
winScreenPriv(pScreen);
-#if CYGDEBUG
- winTrace ("winChangeWindowAttributesNativeGDI (%p)\n", pWin);
-#endif
+ winDebug ("winChangeWindowAttributesNativeGDI (%p)\n", pWin);
WIN_UNWRAP(ChangeWindowAttributes);
fResult = (*pScreen->ChangeWindowAttributes)(pWin, mask);
@@ -248,9 +227,7 @@ winUnmapWindowNativeGDI (WindowPtr pWin)
winWindowPriv(pWin);
winScreenPriv(pScreen);
-#if CYGDEBUG
- winTrace ("winUnmapWindowNativeGDI (%p)\n", pWin);
-#endif
+ winDebug ("winUnmapWindowNativeGDI (%p)\n", pWin);
WIN_UNWRAP(UnrealizeWindow);
fResult = (*pScreen->UnrealizeWindow)(pWin);
@@ -272,9 +249,7 @@ winMapWindowNativeGDI (WindowPtr pWin)
winWindowPriv(pWin);
winScreenPriv(pScreen);
-#if CYGDEBUG
- winTrace ("winMapWindowNativeGDI (%p)\n", pWin);
-#endif
+ winDebug ("winMapWindowNativeGDI (%p)\n", pWin);
WIN_UNWRAP(RealizeWindow);
fResult = (*pScreen->RealizeWindow)(pWin);
@@ -297,9 +272,7 @@ winCreateWindowRootless (WindowPtr pWin)
winWindowPriv(pWin);
winScreenPriv(pScreen);
-#if CYGDEBUG
- winTrace ("winCreateWindowRootless (%p)\n", pWin);
-#endif
+ winDebug ("winCreateWindowRootless (%p)\n", pWin);
WIN_UNWRAP(CreateWindow);
fResult = (*pScreen->CreateWindow) (pWin);
@@ -322,9 +295,7 @@ winDestroyWindowRootless (WindowPtr pWin)
winWindowPriv(pWin);
winScreenPriv(pScreen);
-#if CYGDEBUG
- winTrace ("winDestroyWindowRootless (%p)\n", pWin);
-#endif
+ winDebug ("winDestroyWindowRootless (%p)\n", pWin);
WIN_UNWRAP(DestroyWindow);
fResult = (*pScreen->DestroyWindow)(pWin);
@@ -352,10 +323,7 @@ winPositionWindowRootless (WindowPtr pWin, int x, int y)
ScreenPtr pScreen = pWin->drawable.pScreen;
winScreenPriv(pScreen);
-
-#if CYGDEBUG
- winTrace ("winPositionWindowRootless (%p)\n", pWin);
-#endif
+ winDebug ("winPositionWindowRootless (%p)\n", pWin);
WIN_UNWRAP(PositionWindow);
fResult = (*pScreen->PositionWindow)(pWin, x, y);
@@ -377,9 +345,7 @@ winChangeWindowAttributesRootless (WindowPtr pWin, unsigned long mask)
ScreenPtr pScreen = pWin->drawable.pScreen;
winScreenPriv(pScreen);
-#if CYGDEBUG
- winTrace ("winChangeWindowAttributesRootless (%p)\n", pWin);
-#endif
+ winDebug ("winChangeWindowAttributesRootless (%p)\n", pWin);
WIN_UNWRAP(ChangeWindowAttributes);
fResult = (*pScreen->ChangeWindowAttributes)(pWin, mask);
@@ -403,9 +369,7 @@ winUnmapWindowRootless (WindowPtr pWin)
winWindowPriv(pWin);
winScreenPriv(pScreen);
-#if CYGDEBUG
- winTrace ("winUnmapWindowRootless (%p)\n", pWin);
-#endif
+ winDebug ("winUnmapWindowRootless (%p)\n", pWin);
WIN_UNWRAP(UnrealizeWindow);
fResult = (*pScreen->UnrealizeWindow)(pWin);
@@ -434,9 +398,7 @@ winMapWindowRootless (WindowPtr pWin)
ScreenPtr pScreen = pWin->drawable.pScreen;
winScreenPriv(pScreen);
-#if CYGDEBUG
- winTrace ("winMapWindowRootless (%p)\n", pWin);
-#endif
+ winDebug ("winMapWindowRootless (%p)\n", pWin);
WIN_UNWRAP(RealizeWindow);
fResult = (*pScreen->RealizeWindow)(pWin);
@@ -456,9 +418,7 @@ winSetShapeRootless (WindowPtr pWin)
ScreenPtr pScreen = pWin->drawable.pScreen;
winScreenPriv(pScreen);
-#if CYGDEBUG
- winTrace ("winSetShapeRootless (%p)\n", pWin);
-#endif
+ winDebug ("winSetShapeRootless (%p)\n", pWin);
WIN_UNWRAP(SetShape);
(*pScreen->SetShape)(pWin);
@@ -487,9 +447,7 @@ winAddRgn (WindowPtr pWin, pointer data)
/* If pWin is not Root */
if (pWin->parent != NULL)
{
-#if CYGDEBUG
winDebug ("winAddRgn ()\n");
-#endif
if (pWin->mapped)
{
iBorder = wBorderWidth (pWin);
@@ -504,8 +462,8 @@ winAddRgn (WindowPtr pWin, pointer data)
if (hRgnWin == NULL)
{
- ErrorF ("winAddRgn - CreateRectRgn () failed\n");
- ErrorF (" Rect %d %d %d %d\n",
+ winDebug ("winAddRgn - CreateRectRgn () failed\n");
+ winDebug (" Rect %d %d %d %d\n",
iX, iY, iX + iWidth, iY + iHeight);
}
@@ -570,9 +528,7 @@ winReshapeRootless (WindowPtr pWin)
HRGN hRgn, hRgnRect;
winWindowPriv(pWin);
-#if CYGDEBUG
winDebug ("winReshapeRootless ()\n");
-#endif
/* Bail if the window is the root window */
if (pWin->parent == NULL)
diff --git a/xorg-server/hw/xwin/winwindow.h b/xorg-server/hw/xwin/winwindow.h
index 86c094334..3bd619ad3 100644
--- a/xorg-server/hw/xwin/winwindow.h
+++ b/xorg-server/hw/xwin/winwindow.h
@@ -41,28 +41,22 @@
/* Constant strings */
#ifndef PROJECT_NAME
-# define PROJECT_NAME "Cygwin/X"
+# define PROJECT_NAME "VcXsrv"
#endif
-#define WINDOW_CLASS "cygwin/x"
-#define WINDOW_TITLE PROJECT_NAME ":%s.%d"
-#define WINDOW_TITLE_XDMCP "%s:%s.%d"
-#define WIN_SCR_PROP "cyg_screen_prop rl"
-#define WINDOW_CLASS_X "cygwin/x X rl"
+#define WINDOW_CLASS "VcXsrv/x"
+#define WINDOW_TITLE PROJECT_NAME " Server - %s:%s.%d"
+#define WINDOW_TITLE_XDMCP PROJECT_NAME " Server - %s:%s.%d"
+#define WIN_SCR_PROP "vcxsrv_screen_prop rl"
+#define WINDOW_CLASS_X "vcxsrv/x X rl"
#define WINDOW_TITLE_X PROJECT_NAME " X"
-#define WIN_WINDOW_PROP "cyg_window_prop_rl"
+#define WIN_WINDOW_PROP "vcxsrv_window_prop_rl"
#ifdef HAS_DEVWINDOWS
# define WIN_MSG_QUEUE_FNAME "/dev/windows"
#endif
-#define WIN_WID_PROP "cyg_wid_prop_rl"
-#define WIN_NEEDMANAGE_PROP "cyg_override_redirect_prop_rl"
-#ifndef CYGMULTIWINDOW_DEBUG
-#define CYGMULTIWINDOW_DEBUG NO
-#endif
-#ifndef CYGWINDOWING_DEBUG
-#define CYGWINDOWING_DEBUG NO
-#endif
+#define WIN_WID_PROP "vcxsrv_wid_prop_rl"
+#define WIN_NEEDMANAGE_PROP "vcxsrv_override_redirect_prop_rl"
-#define XMING_SIGNATURE 0x12345678L
+#define VCXSRV_SIGNATURE 0xdeaddeadL
typedef struct _winPrivScreenRec *winPrivScreenPtr;
diff --git a/xorg-server/hw/xwin/winwindowswm.c b/xorg-server/hw/xwin/winwindowswm.c
index 3d4d8c208..d1b405683 100644
--- a/xorg-server/hw/xwin/winwindowswm.c
+++ b/xorg-server/hw/xwin/winwindowswm.c
@@ -1,655 +1,630 @@
-/* WindowsWM extension is based on AppleWM extension */
-/**************************************************************************
-
-Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
-Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, 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 NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
-
-**************************************************************************/
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-#include "misc.h"
-#include "dixstruct.h"
-#include "extnsionst.h"
-#include "colormapst.h"
-#include "cursorstr.h"
-#include "scrnintstr.h"
-#include "servermd.h"
-#include "swaprep.h"
-#define _WINDOWSWM_SERVER_
-#include <X11/extensions/windowswmstr.h>
-#include "protocol-versions.h"
-
-static int WMErrorBase;
-
-static DISPATCH_PROC(ProcWindowsWMDispatch);
-static DISPATCH_PROC(SProcWindowsWMDispatch);
-
-static unsigned char WMReqCode = 0;
-static int WMEventBase = 0;
-
-static RESTYPE ClientType, eventResourceType; /* resource types for event masks */
-static XID eventResource;
-
-/* Currently selected events */
-static unsigned int eventMask = 0;
-
-static int WMFreeClient (pointer data, XID id);
-static int WMFreeEvents (pointer data, XID id);
-static void SNotifyEvent(xWindowsWMNotifyEvent *from, xWindowsWMNotifyEvent *to);
-
-typedef struct _WMEvent *WMEventPtr;
-typedef struct _WMEvent {
- WMEventPtr next;
- ClientPtr client;
- XID clientResource;
- unsigned int mask;
-} WMEventRec;
-
-static inline BoxRec
-make_box (int x, int y, int w, int h)
-{
- BoxRec r;
- r.x1 = x;
- r.y1 = y;
- r.x2 = x + w;
- r.y2 = y + h;
- return r;
-}
-
-void
-winWindowsWMExtensionInit ()
-{
- ExtensionEntry* extEntry;
-
- ClientType = CreateNewResourceType(WMFreeClient);
- eventResourceType = CreateNewResourceType(WMFreeEvents);
- eventResource = FakeClientID(0);
-
- if (ClientType && eventResourceType &&
- (extEntry = AddExtension(WINDOWSWMNAME,
- WindowsWMNumberEvents,
- WindowsWMNumberErrors,
- ProcWindowsWMDispatch,
- SProcWindowsWMDispatch,
- NULL,
- StandardMinorOpcode)))
- {
- WMReqCode = (unsigned char)extEntry->base;
- WMErrorBase = extEntry->errorBase;
- WMEventBase = extEntry->eventBase;
- EventSwapVector[WMEventBase] = (EventSwapPtr) SNotifyEvent;
- }
-}
-
-static int
-ProcWindowsWMQueryVersion(register ClientPtr client)
-{
- xWindowsWMQueryVersionReply rep;
- register int n;
-
- REQUEST_SIZE_MATCH(xWindowsWMQueryVersionReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.majorVersion = SERVER_WINDOWSWM_MAJOR_VERSION;
- rep.minorVersion = SERVER_WINDOWSWM_MINOR_VERSION;
- rep.patchVersion = SERVER_WINDOWSWM_PATCH_VERSION;
- if (client->swapped)
- {
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- }
- WriteToClient(client, sizeof(xWindowsWMQueryVersionReply), (char *)&rep);
- return (client->noClientException);
-}
-
-
-/* events */
-
-static inline void
-updateEventMask (WMEventPtr *pHead)
-{
- WMEventPtr pCur;
-
- eventMask = 0;
- for (pCur = *pHead; pCur != NULL; pCur = pCur->next)
- eventMask |= pCur->mask;
-}
-
-/*ARGSUSED*/
-static int
-WMFreeClient (pointer data, XID id)
-{
- WMEventPtr pEvent;
- WMEventPtr *pHead, pCur, pPrev;
-
- pEvent = (WMEventPtr) data;
- dixLookupResourceByType((pointer) &pHead, eventResource, eventResourceType,
- NullClient, DixUnknownAccess);
- if (pHead)
- {
- pPrev = 0;
- for (pCur = *pHead; pCur && pCur != pEvent; pCur=pCur->next)
- pPrev = pCur;
- if (pCur)
- {
- if (pPrev)
- pPrev->next = pEvent->next;
- else
- *pHead = pEvent->next;
- }
- updateEventMask (pHead);
- }
- xfree ((pointer) pEvent);
- return 1;
-}
-
-/*ARGSUSED*/
-static int
-WMFreeEvents (pointer data, XID id)
-{
- WMEventPtr *pHead, pCur, pNext;
-
- pHead = (WMEventPtr *) data;
- for (pCur = *pHead; pCur; pCur = pNext)
- {
- pNext = pCur->next;
- FreeResource (pCur->clientResource, ClientType);
- xfree ((pointer) pCur);
- }
- xfree ((pointer) pHead);
- eventMask = 0;
- return 1;
-}
-
-static int
-ProcWindowsWMSelectInput (register ClientPtr client)
-{
- REQUEST(xWindowsWMSelectInputReq);
- WMEventPtr pEvent, pNewEvent, *pHead;
- XID clientResource;
-
- REQUEST_SIZE_MATCH (xWindowsWMSelectInputReq);
- dixLookupResourceByType((pointer) &pHead, eventResource, eventResourceType, client, DixWriteAccess);
- if (stuff->mask != 0)
- {
- if (pHead)
- {
- /* check for existing entry. */
- for (pEvent = *pHead; pEvent; pEvent = pEvent->next)
- {
- if (pEvent->client == client)
- {
- pEvent->mask = stuff->mask;
- updateEventMask (pHead);
- return Success;
- }
- }
- }
-
- /* build the entry */
- pNewEvent = (WMEventPtr) xalloc (sizeof (WMEventRec));
- if (!pNewEvent)
- return BadAlloc;
- pNewEvent->next = 0;
- pNewEvent->client = client;
- pNewEvent->mask = stuff->mask;
- /*
- * add a resource that will be deleted when
- * the client goes away
- */
- clientResource = FakeClientID (client->index);
- pNewEvent->clientResource = clientResource;
- if (!AddResource (clientResource, ClientType, (pointer)pNewEvent))
- return BadAlloc;
- /*
- * create a resource to contain a pointer to the list
- * of clients selecting input. This must be indirect as
- * the list may be arbitrarily rearranged which cannot be
- * done through the resource database.
- */
- if (!pHead)
- {
- pHead = (WMEventPtr *) xalloc (sizeof (WMEventPtr));
- if (!pHead ||
- !AddResource (eventResource, eventResourceType, (pointer)pHead))
- {
- FreeResource (clientResource, RT_NONE);
- return BadAlloc;
- }
- *pHead = 0;
- }
- pNewEvent->next = *pHead;
- *pHead = pNewEvent;
- updateEventMask (pHead);
- }
- else if (stuff->mask == 0)
- {
- /* delete the interest */
- if (pHead)
- {
- pNewEvent = 0;
- for (pEvent = *pHead; pEvent; pEvent = pEvent->next)
- {
- if (pEvent->client == client)
- break;
- pNewEvent = pEvent;
- }
- if (pEvent)
- {
- FreeResource (pEvent->clientResource, ClientType);
- if (pNewEvent)
- pNewEvent->next = pEvent->next;
- else
- *pHead = pEvent->next;
- xfree (pEvent);
- updateEventMask (pHead);
- }
- }
- }
- else
- {
- client->errorValue = stuff->mask;
- return BadValue;
- }
- return Success;
-}
-
-/*
- * deliver the event
- */
-
-void
-winWindowsWMSendEvent (int type, unsigned int mask, int which, int arg,
- Window window, int x, int y, int w, int h)
-{
- WMEventPtr *pHead, pEvent;
- ClientPtr client;
- xWindowsWMNotifyEvent se;
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winWindowsWMSendEvent %d %d %d %d, %d %d - %d %d\n",
- type, mask, which, arg, x, y, w, h);
-#endif
- dixLookupResourceByType((pointer) &pHead, eventResource, eventResourceType,
- NullClient, DixUnknownAccess);
- if (!pHead)
- return;
- for (pEvent = *pHead; pEvent; pEvent = pEvent->next)
- {
- client = pEvent->client;
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winWindowsWMSendEvent - x%08x\n", (int) client);
-#endif
- if ((pEvent->mask & mask) == 0
- || client == serverClient || client->clientGone)
- {
- continue;
- }
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winWindowsWMSendEvent - send\n");
-#endif
- se.type = type + WMEventBase;
- se.kind = which;
- se.window = window;
- se.arg = arg;
- se.x = x;
- se.y = y;
- se.w = w;
- se.h = h;
- se.sequenceNumber = client->sequence;
- se.time = currentTime.milliseconds;
- WriteEventsToClient (client, 1, (xEvent *) &se);
- }
-}
-
-/* Safe to call from any thread. */
-unsigned int
-WindowsWMSelectedEvents (void)
-{
- return eventMask;
-}
-
-
-/* general utility functions */
-
-static int
-ProcWindowsWMDisableUpdate (register ClientPtr client)
-{
- REQUEST_SIZE_MATCH(xWindowsWMDisableUpdateReq);
-
- //winDisableUpdate();
-
- return (client->noClientException);
-}
-
-static int
-ProcWindowsWMReenableUpdate (register ClientPtr client)
-{
- REQUEST_SIZE_MATCH(xWindowsWMReenableUpdateReq);
-
- //winEnableUpdate();
-
- return (client->noClientException);
-}
-
-
-/* window functions */
-
-static int
-ProcWindowsWMSetFrontProcess (register ClientPtr client)
-{
- REQUEST_SIZE_MATCH(xWindowsWMSetFrontProcessReq);
-
- //QuartzMessageMainThread(kWindowsSetFrontProcess, NULL, 0);
-
- return (client->noClientException);
-}
-
-
-/* frame functions */
-
-static int
-ProcWindowsWMFrameGetRect (register ClientPtr client)
-{
- xWindowsWMFrameGetRectReply rep;
- BoxRec ir;
- RECT rcNew;
- REQUEST(xWindowsWMFrameGetRectReq);
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("ProcWindowsWMFrameGetRect %d %d\n",
- (sizeof(xWindowsWMFrameGetRectReq) >> 2), (int) client->req_len);
-#endif
-
- REQUEST_SIZE_MATCH(xWindowsWMFrameGetRectReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
-
- if (stuff->frame_rect != 0)
- {
- ErrorF ("ProcWindowsWMFrameGetRect - stuff->frame_rect != 0\n");
- return BadValue;
- }
-
- /* Store the origin, height, and width in a rectangle structure */
- SetRect (&rcNew, stuff->ix, stuff->iy,
- stuff->ix + stuff->iw, stuff->iy + stuff->ih);
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("ProcWindowsWMFrameGetRect - %d %d %d %d\n",
- stuff->ix, stuff->iy, stuff->ix + stuff->iw, stuff->iy + stuff->ih);
-#endif
-
- /*
- * Calculate the required size of the Windows window rectangle,
- * given the size of the Windows window client area.
- */
- AdjustWindowRectEx (&rcNew, stuff->frame_style, FALSE, stuff->frame_style_ex);
- rep.x = rcNew.left;
- rep.y = rcNew.top;
- rep.w = rcNew.right - rcNew.left;
- rep.h = rcNew.bottom - rcNew.top;
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("ProcWindowsWMFrameGetRect - %d %d %d %d\n",
- rep.x, rep.y, rep.w, rep.h);
-#endif
-
- WriteToClient(client, sizeof(xWindowsWMFrameGetRectReply), (char *)&rep);
- return (client->noClientException);
-}
-
-
-static int
-ProcWindowsWMFrameDraw (register ClientPtr client)
-{
- REQUEST(xWindowsWMFrameDrawReq);
- WindowPtr pWin;
- win32RootlessWindowPtr pRLWinPriv;
- RECT rcNew;
- int nCmdShow, rc;
- RegionRec newShape;
- ScreenPtr pScreen;
-
- REQUEST_SIZE_MATCH (xWindowsWMFrameDrawReq);
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("ProcWindowsWMFrameDraw\n");
-#endif
- rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
- if (rc != Success)
- return rc;
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("ProcWindowsWMFrameDraw - Window found\n");
-#endif
-
- pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, TRUE);
- if (pRLWinPriv == 0) return BadWindow;
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("ProcWindowsWMFrameDraw - HWND 0x%08x 0x%08x 0x%08x\n",
- (int) pRLWinPriv->hWnd, (int) stuff->frame_style,
- (int) stuff->frame_style_ex);
- ErrorF ("ProcWindowsWMFrameDraw - %d %d %d %d\n",
- stuff->ix, stuff->iy, stuff->iw, stuff->ih);
-#endif
-
- /* Store the origin, height, and width in a rectangle structure */
- SetRect (&rcNew, stuff->ix, stuff->iy,
- stuff->ix + stuff->iw, stuff->iy + stuff->ih);
-
- /*
- * Calculate the required size of the Windows window rectangle,
- * given the size of the Windows window client area.
- */
- AdjustWindowRectEx (&rcNew, stuff->frame_style, FALSE, stuff->frame_style_ex);
-
- /* Set the window extended style flags */
- if (!SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, stuff->frame_style_ex))
- {
- return BadValue;
- }
-
- /* Set the window standard style flags */
- if (!SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE, stuff->frame_style))
- {
- return BadValue;
- }
-
- /* Flush the window style */
- if (!SetWindowPos (pRLWinPriv->hWnd, NULL,
- rcNew.left, rcNew.top,
- rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
- SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE))
- {
- return BadValue;
- }
- if (!IsWindowVisible(pRLWinPriv->hWnd))
- nCmdShow = SW_HIDE;
- else
- nCmdShow = SW_SHOWNA;
-
- ShowWindow (pRLWinPriv->hWnd, nCmdShow);
-
- winMWExtWMUpdateIcon (pWin->drawable.id);
-
- if (wBoundingShape(pWin) != NULL)
- {
- pScreen = pWin->drawable.pScreen;
- /* wBoundingShape is relative to *inner* origin of window.
- Translate by borderWidth to get the outside-relative position. */
-
- REGION_NULL(pScreen, &newShape);
- REGION_COPY(pScreen, &newShape, wBoundingShape(pWin));
- REGION_TRANSLATE(pScreen, &newShape, pWin->borderWidth, pWin->borderWidth);
- winMWExtWMReshapeFrame (pRLWinPriv, &newShape);
- REGION_UNINIT(pScreen, &newShape);
- }
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("ProcWindowsWMFrameDraw - done\n");
-#endif
-
- return (client->noClientException);
-}
-
-static int
-ProcWindowsWMFrameSetTitle(
- register ClientPtr client
- )
-{
- unsigned int title_length, title_max;
- unsigned char *title_bytes;
- REQUEST(xWindowsWMFrameSetTitleReq);
- WindowPtr pWin;
- win32RootlessWindowPtr pRLWinPriv;
- int rc;
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("ProcWindowsWMFrameSetTitle\n");
-#endif
-
- REQUEST_AT_LEAST_SIZE(xWindowsWMFrameSetTitleReq);
-
- rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
- if (rc != Success)
- return rc;
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("ProcWindowsWMFrameSetTitle - Window found\n");
-#endif
-
- title_length = stuff->title_length;
- title_max = (stuff->length << 2) - sizeof(xWindowsWMFrameSetTitleReq);
-
- if (title_max < title_length)
- return BadValue;
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("ProcWindowsWMFrameSetTitle - length is valid\n");
-#endif
-
- title_bytes = malloc (title_length+1);
- strncpy (title_bytes, (unsigned char *) &stuff[1], title_length);
- title_bytes[title_length] = '\0';
-
- pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE);
-
- if (pRLWinPriv == 0)
- {
- free (title_bytes);
- return BadWindow;
- }
-
- /* Flush the window style */
- SetWindowText (pRLWinPriv->hWnd, title_bytes);
-
- free (title_bytes);
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("ProcWindowsWMFrameSetTitle - done\n");
-#endif
-
- return (client->noClientException);
-}
-
-
-/* dispatch */
-
-static int
-ProcWindowsWMDispatch (register ClientPtr client)
-{
- REQUEST(xReq);
-
- switch (stuff->data)
- {
- case X_WindowsWMQueryVersion:
- return ProcWindowsWMQueryVersion(client);
- }
-
- if (!LocalClient(client))
- return WMErrorBase + WindowsWMClientNotLocal;
-
- switch (stuff->data)
- {
- case X_WindowsWMSelectInput:
- return ProcWindowsWMSelectInput(client);
- case X_WindowsWMDisableUpdate:
- return ProcWindowsWMDisableUpdate(client);
- case X_WindowsWMReenableUpdate:
- return ProcWindowsWMReenableUpdate(client);
- case X_WindowsWMSetFrontProcess:
- return ProcWindowsWMSetFrontProcess(client);
- case X_WindowsWMFrameGetRect:
- return ProcWindowsWMFrameGetRect(client);
- case X_WindowsWMFrameDraw:
- return ProcWindowsWMFrameDraw(client);
- case X_WindowsWMFrameSetTitle:
- return ProcWindowsWMFrameSetTitle(client);
- default:
- return BadRequest;
- }
-}
-
-static void
-SNotifyEvent (xWindowsWMNotifyEvent *from, xWindowsWMNotifyEvent *to)
-{
- to->type = from->type;
- to->kind = from->kind;
- cpswaps (from->sequenceNumber, to->sequenceNumber);
- cpswapl (from->window, to->window);
- cpswapl (from->time, to->time);
- cpswapl (from->arg, to->arg);
-}
-
-static int
-SProcWindowsWMQueryVersion (register ClientPtr client)
-{
- register int n;
- REQUEST(xWindowsWMQueryVersionReq);
- swaps(&stuff->length, n);
- return ProcWindowsWMQueryVersion(client);
-}
-
-static int
-SProcWindowsWMDispatch (register ClientPtr client)
-{
- REQUEST(xReq);
-
- /* It is bound to be non-local when there is byte swapping */
- if (!LocalClient(client))
- return WMErrorBase + WindowsWMClientNotLocal;
-
- /* only local clients are allowed WM access */
- switch (stuff->data)
- {
- case X_WindowsWMQueryVersion:
- return SProcWindowsWMQueryVersion(client);
- default:
- return BadRequest;
- }
-}
+/* WindowsWM extension is based on AppleWM extension */
+/**************************************************************************
+
+Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
+Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, 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 NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+#include "misc.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "scrnintstr.h"
+#include "servermd.h"
+#include "swaprep.h"
+#define _WINDOWSWM_SERVER_
+#include <X11/extensions/windowswmstr.h>
+#include "protocol-versions.h"
+
+static int WMErrorBase;
+
+static DISPATCH_PROC(ProcWindowsWMDispatch);
+static DISPATCH_PROC(SProcWindowsWMDispatch);
+
+static unsigned char WMReqCode = 0;
+static int WMEventBase = 0;
+
+static RESTYPE ClientType, eventResourceType; /* resource types for event masks */
+static XID eventResource;
+
+/* Currently selected events */
+static unsigned int eventMask = 0;
+
+static int WMFreeClient (pointer data, XID id);
+static int WMFreeEvents (pointer data, XID id);
+static void SNotifyEvent(xWindowsWMNotifyEvent *from, xWindowsWMNotifyEvent *to);
+
+typedef struct _WMEvent *WMEventPtr;
+typedef struct _WMEvent {
+ WMEventPtr next;
+ ClientPtr client;
+ XID clientResource;
+ unsigned int mask;
+} WMEventRec;
+
+static inline BoxRec
+make_box (int x, int y, int w, int h)
+{
+ BoxRec r;
+ r.x1 = x;
+ r.y1 = y;
+ r.x2 = x + w;
+ r.y2 = y + h;
+ return r;
+}
+
+void
+winWindowsWMExtensionInit ()
+{
+ ExtensionEntry* extEntry;
+
+ ClientType = CreateNewResourceType(WMFreeClient);
+ eventResourceType = CreateNewResourceType(WMFreeEvents);
+ eventResource = FakeClientID(0);
+
+ if (ClientType && eventResourceType &&
+ (extEntry = AddExtension(WINDOWSWMNAME,
+ WindowsWMNumberEvents,
+ WindowsWMNumberErrors,
+ ProcWindowsWMDispatch,
+ SProcWindowsWMDispatch,
+ NULL,
+ StandardMinorOpcode)))
+ {
+ WMReqCode = (unsigned char)extEntry->base;
+ WMErrorBase = extEntry->errorBase;
+ WMEventBase = extEntry->eventBase;
+ EventSwapVector[WMEventBase] = (EventSwapPtr) SNotifyEvent;
+ }
+}
+
+static int
+ProcWindowsWMQueryVersion(register ClientPtr client)
+{
+ xWindowsWMQueryVersionReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xWindowsWMQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = SERVER_WINDOWSWM_MAJOR_VERSION;
+ rep.minorVersion = SERVER_WINDOWSWM_MINOR_VERSION;
+ rep.patchVersion = SERVER_WINDOWSWM_PATCH_VERSION;
+ if (client->swapped)
+ {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ }
+ WriteToClient(client, sizeof(xWindowsWMQueryVersionReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+
+/* events */
+
+static inline void
+updateEventMask (WMEventPtr *pHead)
+{
+ WMEventPtr pCur;
+
+ eventMask = 0;
+ for (pCur = *pHead; pCur != NULL; pCur = pCur->next)
+ eventMask |= pCur->mask;
+}
+
+/*ARGSUSED*/
+static int
+WMFreeClient (pointer data, XID id)
+{
+ WMEventPtr pEvent;
+ WMEventPtr *pHead, pCur, pPrev;
+
+ pEvent = (WMEventPtr) data;
+ dixLookupResourceByType((pointer) &pHead, eventResource, eventResourceType,
+ NullClient, DixUnknownAccess);
+ if (pHead)
+ {
+ pPrev = 0;
+ for (pCur = *pHead; pCur && pCur != pEvent; pCur=pCur->next)
+ pPrev = pCur;
+ if (pCur)
+ {
+ if (pPrev)
+ pPrev->next = pEvent->next;
+ else
+ *pHead = pEvent->next;
+ }
+ updateEventMask (pHead);
+ }
+ xfree ((pointer) pEvent);
+ return 1;
+}
+
+/*ARGSUSED*/
+static int
+WMFreeEvents (pointer data, XID id)
+{
+ WMEventPtr *pHead, pCur, pNext;
+
+ pHead = (WMEventPtr *) data;
+ for (pCur = *pHead; pCur; pCur = pNext)
+ {
+ pNext = pCur->next;
+ FreeResource (pCur->clientResource, ClientType);
+ xfree ((pointer) pCur);
+ }
+ xfree ((pointer) pHead);
+ eventMask = 0;
+ return 1;
+}
+
+static int
+ProcWindowsWMSelectInput (register ClientPtr client)
+{
+ REQUEST(xWindowsWMSelectInputReq);
+ WMEventPtr pEvent, pNewEvent, *pHead;
+ XID clientResource;
+
+ REQUEST_SIZE_MATCH (xWindowsWMSelectInputReq);
+ dixLookupResourceByType((pointer) &pHead, eventResource, eventResourceType, client, DixWriteAccess);
+ if (stuff->mask != 0)
+ {
+ if (pHead)
+ {
+ /* check for existing entry. */
+ for (pEvent = *pHead; pEvent; pEvent = pEvent->next)
+ {
+ if (pEvent->client == client)
+ {
+ pEvent->mask = stuff->mask;
+ updateEventMask (pHead);
+ return Success;
+ }
+ }
+ }
+
+ /* build the entry */
+ pNewEvent = (WMEventPtr) xalloc (sizeof (WMEventRec));
+ if (!pNewEvent)
+ return BadAlloc;
+ pNewEvent->next = 0;
+ pNewEvent->client = client;
+ pNewEvent->mask = stuff->mask;
+ /*
+ * add a resource that will be deleted when
+ * the client goes away
+ */
+ clientResource = FakeClientID (client->index);
+ pNewEvent->clientResource = clientResource;
+ if (!AddResource (clientResource, ClientType, (pointer)pNewEvent))
+ return BadAlloc;
+ /*
+ * create a resource to contain a pointer to the list
+ * of clients selecting input. This must be indirect as
+ * the list may be arbitrarily rearranged which cannot be
+ * done through the resource database.
+ */
+ if (!pHead)
+ {
+ pHead = (WMEventPtr *) xalloc (sizeof (WMEventPtr));
+ if (!pHead ||
+ !AddResource (eventResource, eventResourceType, (pointer)pHead))
+ {
+ FreeResource (clientResource, RT_NONE);
+ return BadAlloc;
+ }
+ *pHead = 0;
+ }
+ pNewEvent->next = *pHead;
+ *pHead = pNewEvent;
+ updateEventMask (pHead);
+ }
+ else if (stuff->mask == 0)
+ {
+ /* delete the interest */
+ if (pHead)
+ {
+ pNewEvent = 0;
+ for (pEvent = *pHead; pEvent; pEvent = pEvent->next)
+ {
+ if (pEvent->client == client)
+ break;
+ pNewEvent = pEvent;
+ }
+ if (pEvent)
+ {
+ FreeResource (pEvent->clientResource, ClientType);
+ if (pNewEvent)
+ pNewEvent->next = pEvent->next;
+ else
+ *pHead = pEvent->next;
+ xfree (pEvent);
+ updateEventMask (pHead);
+ }
+ }
+ }
+ else
+ {
+ client->errorValue = stuff->mask;
+ return BadValue;
+ }
+ return Success;
+}
+
+/*
+ * deliver the event
+ */
+
+void
+winWindowsWMSendEvent (int type, unsigned int mask, int which, int arg,
+ Window window, int x, int y, int w, int h)
+{
+ WMEventPtr *pHead, pEvent;
+ ClientPtr client;
+ xWindowsWMNotifyEvent se;
+ winDebug ("winWindowsWMSendEvent %d %d %d %d, %d %d - %d %d\n",
+ type, mask, which, arg, x, y, w, h);
+ dixLookupResourceByType((pointer) &pHead, eventResource, eventResourceType,
+ NullClient, DixUnknownAccess);
+ if (!pHead)
+ return;
+ for (pEvent = *pHead; pEvent; pEvent = pEvent->next)
+ {
+ client = pEvent->client;
+ winDebug ("winWindowsWMSendEvent - x%08x\n", (int) client);
+ if ((pEvent->mask & mask) == 0
+ || client == serverClient || client->clientGone)
+ {
+ continue;
+ }
+ winDebug ("winWindowsWMSendEvent - send\n");
+
+ se.type = type + WMEventBase;
+ se.kind = which;
+ se.window = window;
+ se.arg = arg;
+ se.x = x;
+ se.y = y;
+ se.w = w;
+ se.h = h;
+ se.sequenceNumber = client->sequence;
+ se.time = currentTime.milliseconds;
+ WriteEventsToClient (client, 1, (xEvent *) &se);
+ }
+}
+
+/* Safe to call from any thread. */
+unsigned int
+WindowsWMSelectedEvents (void)
+{
+ return eventMask;
+}
+
+
+/* general utility functions */
+
+static int
+ProcWindowsWMDisableUpdate (register ClientPtr client)
+{
+ REQUEST_SIZE_MATCH(xWindowsWMDisableUpdateReq);
+
+ //winDisableUpdate();
+
+ return (client->noClientException);
+}
+
+static int
+ProcWindowsWMReenableUpdate (register ClientPtr client)
+{
+ REQUEST_SIZE_MATCH(xWindowsWMReenableUpdateReq);
+
+ //winEnableUpdate();
+
+ return (client->noClientException);
+}
+
+
+/* window functions */
+
+static int
+ProcWindowsWMSetFrontProcess (register ClientPtr client)
+{
+ REQUEST_SIZE_MATCH(xWindowsWMSetFrontProcessReq);
+
+ //QuartzMessageMainThread(kWindowsSetFrontProcess, NULL, 0);
+
+ return (client->noClientException);
+}
+
+
+/* frame functions */
+
+static int
+ProcWindowsWMFrameGetRect (register ClientPtr client)
+{
+ xWindowsWMFrameGetRectReply rep;
+ BoxRec ir;
+ RECT rcNew;
+ REQUEST(xWindowsWMFrameGetRectReq);
+
+ winDebug ("ProcWindowsWMFrameGetRect %d %d\n",
+ (sizeof(xWindowsWMFrameGetRectReq) >> 2), (int) client->req_len);
+
+ REQUEST_SIZE_MATCH(xWindowsWMFrameGetRectReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
+
+ if (stuff->frame_rect != 0)
+ {
+ ErrorF ("ProcWindowsWMFrameGetRect - stuff->frame_rect != 0\n");
+ return BadValue;
+ }
+
+ /* Store the origin, height, and width in a rectangle structure */
+ SetRect (&rcNew, stuff->ix, stuff->iy,
+ stuff->ix + stuff->iw, stuff->iy + stuff->ih);
+
+ winDebug ("ProcWindowsWMFrameGetRect - %d %d %d %d\n",
+ stuff->ix, stuff->iy, stuff->ix + stuff->iw, stuff->iy + stuff->ih);
+
+ /*
+ * Calculate the required size of the Windows window rectangle,
+ * given the size of the Windows window client area.
+ */
+ AdjustWindowRectEx (&rcNew, stuff->frame_style, FALSE, stuff->frame_style_ex);
+ rep.x = rcNew.left;
+ rep.y = rcNew.top;
+ rep.w = rcNew.right - rcNew.left;
+ rep.h = rcNew.bottom - rcNew.top;
+ winDebug ("ProcWindowsWMFrameGetRect - %d %d %d %d\n",
+ rep.x, rep.y, rep.w, rep.h);
+
+ WriteToClient(client, sizeof(xWindowsWMFrameGetRectReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+
+static int
+ProcWindowsWMFrameDraw (register ClientPtr client)
+{
+ REQUEST(xWindowsWMFrameDrawReq);
+ WindowPtr pWin;
+ win32RootlessWindowPtr pRLWinPriv;
+ RECT rcNew;
+ int nCmdShow, rc;
+ RegionRec newShape;
+ ScreenPtr pScreen;
+
+ REQUEST_SIZE_MATCH (xWindowsWMFrameDrawReq);
+
+ winDebug ("ProcWindowsWMFrameDraw\n");
+
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+ if (rc != Success)
+ return rc;
+
+ winDebug ("ProcWindowsWMFrameDraw - Window found\n");
+
+ pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, TRUE);
+ if (pRLWinPriv == 0) return BadWindow;
+
+ winDebug ("ProcWindowsWMFrameDraw - HWND 0x%08x 0x%08x 0x%08x\n",
+ (int) pRLWinPriv->hWnd, (int) stuff->frame_style,
+ (int) stuff->frame_style_ex);
+ winDebug ("ProcWindowsWMFrameDraw - %d %d %d %d\n",
+ stuff->ix, stuff->iy, stuff->iw, stuff->ih);
+
+ /* Store the origin, height, and width in a rectangle structure */
+ SetRect (&rcNew, stuff->ix, stuff->iy,
+ stuff->ix + stuff->iw, stuff->iy + stuff->ih);
+
+ /*
+ * Calculate the required size of the Windows window rectangle,
+ * given the size of the Windows window client area.
+ */
+ AdjustWindowRectEx (&rcNew, stuff->frame_style, FALSE, stuff->frame_style_ex);
+
+ /* Set the window extended style flags */
+ if (!SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, stuff->frame_style_ex))
+ {
+ return BadValue;
+ }
+
+ /* Set the window standard style flags */
+ if (!SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE, stuff->frame_style))
+ {
+ return BadValue;
+ }
+
+ /* Flush the window style */
+ if (!SetWindowPos (pRLWinPriv->hWnd, NULL,
+ rcNew.left, rcNew.top,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
+ SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE))
+ {
+ return BadValue;
+ }
+ if (!IsWindowVisible(pRLWinPriv->hWnd))
+ nCmdShow = SW_HIDE;
+ else
+ nCmdShow = SW_SHOWNA;
+
+ ShowWindow (pRLWinPriv->hWnd, nCmdShow);
+
+ winMWExtWMUpdateIcon (pWin->drawable.id);
+
+ if (wBoundingShape(pWin) != NULL)
+ {
+ pScreen = pWin->drawable.pScreen;
+ /* wBoundingShape is relative to *inner* origin of window.
+ Translate by borderWidth to get the outside-relative position. */
+
+ REGION_NULL(pScreen, &newShape);
+ REGION_COPY(pScreen, &newShape, wBoundingShape(pWin));
+ REGION_TRANSLATE(pScreen, &newShape, pWin->borderWidth, pWin->borderWidth);
+ winMWExtWMReshapeFrame (pRLWinPriv, &newShape);
+ REGION_UNINIT(pScreen, &newShape);
+ }
+ winDebug ("ProcWindowsWMFrameDraw - done\n");
+
+ return (client->noClientException);
+}
+
+static int
+ProcWindowsWMFrameSetTitle(
+ register ClientPtr client
+ )
+{
+ unsigned int title_length, title_max;
+ unsigned char *title_bytes;
+ REQUEST(xWindowsWMFrameSetTitleReq);
+ WindowPtr pWin;
+ win32RootlessWindowPtr pRLWinPriv;
+ int rc;
+
+ winDebug ("ProcWindowsWMFrameSetTitle\n");
+
+ REQUEST_AT_LEAST_SIZE(xWindowsWMFrameSetTitleReq);
+
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+ if (rc != Success)
+ return rc;
+ winDebug ("ProcWindowsWMFrameSetTitle - Window found\n");
+
+ title_length = stuff->title_length;
+ title_max = (stuff->length << 2) - sizeof(xWindowsWMFrameSetTitleReq);
+
+ if (title_max < title_length)
+ return BadValue;
+
+ winDebug ("ProcWindowsWMFrameSetTitle - length is valid\n");
+
+ title_bytes = malloc (title_length+1);
+ strncpy (title_bytes, (unsigned char *) &stuff[1], title_length);
+ title_bytes[title_length] = '\0';
+
+ pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE);
+
+ if (pRLWinPriv == 0)
+ {
+ free (title_bytes);
+ return BadWindow;
+ }
+
+ /* Flush the window style */
+ SetWindowText (pRLWinPriv->hWnd, title_bytes);
+
+ free (title_bytes);
+
+ winDebug ("ProcWindowsWMFrameSetTitle - done\n");
+
+ return (client->noClientException);
+}
+
+
+/* dispatch */
+
+static int
+ProcWindowsWMDispatch (register ClientPtr client)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data)
+ {
+ case X_WindowsWMQueryVersion:
+ return ProcWindowsWMQueryVersion(client);
+ }
+
+ if (!LocalClient(client))
+ return WMErrorBase + WindowsWMClientNotLocal;
+
+ switch (stuff->data)
+ {
+ case X_WindowsWMSelectInput:
+ return ProcWindowsWMSelectInput(client);
+ case X_WindowsWMDisableUpdate:
+ return ProcWindowsWMDisableUpdate(client);
+ case X_WindowsWMReenableUpdate:
+ return ProcWindowsWMReenableUpdate(client);
+ case X_WindowsWMSetFrontProcess:
+ return ProcWindowsWMSetFrontProcess(client);
+ case X_WindowsWMFrameGetRect:
+ return ProcWindowsWMFrameGetRect(client);
+ case X_WindowsWMFrameDraw:
+ return ProcWindowsWMFrameDraw(client);
+ case X_WindowsWMFrameSetTitle:
+ return ProcWindowsWMFrameSetTitle(client);
+ default:
+ return BadRequest;
+ }
+}
+
+static void
+SNotifyEvent (xWindowsWMNotifyEvent *from, xWindowsWMNotifyEvent *to)
+{
+ to->type = from->type;
+ to->kind = from->kind;
+ cpswaps (from->sequenceNumber, to->sequenceNumber);
+ cpswapl (from->window, to->window);
+ cpswapl (from->time, to->time);
+ cpswapl (from->arg, to->arg);
+}
+
+static int
+SProcWindowsWMQueryVersion (register ClientPtr client)
+{
+ register int n;
+ REQUEST(xWindowsWMQueryVersionReq);
+ swaps(&stuff->length, n);
+ return ProcWindowsWMQueryVersion(client);
+}
+
+static int
+SProcWindowsWMDispatch (register ClientPtr client)
+{
+ REQUEST(xReq);
+
+ /* It is bound to be non-local when there is byte swapping */
+ if (!LocalClient(client))
+ return WMErrorBase + WindowsWMClientNotLocal;
+
+ /* only local clients are allowed WM access */
+ switch (stuff->data)
+ {
+ case X_WindowsWMQueryVersion:
+ return SProcWindowsWMQueryVersion(client);
+ default:
+ return BadRequest;
+ }
+}
diff --git a/xorg-server/hw/xwin/winwndproc.c b/xorg-server/hw/xwin/winwndproc.c
index 5e8451082..73ca16bc5 100644
--- a/xorg-server/hw/xwin/winwndproc.c
+++ b/xorg-server/hw/xwin/winwndproc.c
@@ -42,6 +42,10 @@
#include "winmsg.h"
#include "inputstr.h"
+#ifndef XKB_IN_SERVER
+#define XKB_IN_SERVER
+#endif
+#include <xkbsrv.h>
/*
* Global variables
*/
@@ -82,9 +86,7 @@ winWindowProc (HWND hwnd, UINT message,
int iScanCode;
int i;
-#if CYGDEBUG
winDebugWin32Message("winWindowProc", hwnd, message, wParam, lParam);
-#endif
/* Watch for server regeneration */
if (g_ulServerGeneration != s_ulServerGeneration)
@@ -97,9 +99,7 @@ winWindowProc (HWND hwnd, UINT message,
if ((s_pScreenPriv == NULL || hwnd != s_hwndLastPrivates)
&& (s_pScreenPriv = GetProp (hwnd, WIN_SCR_PROP)) != NULL)
{
-#if CYGDEBUG
winDebug ("winWindowProc - Setting privates handle\n");
-#endif
s_pScreenInfo = s_pScreenPriv->pScreenInfo;
s_pScreen = s_pScreenInfo->pScreen;
s_hwndLastPrivates = hwnd;
@@ -120,9 +120,7 @@ winWindowProc (HWND hwnd, UINT message,
s_pScreenPriv);
case WM_CREATE:
-#if CYGDEBUG
winDebug ("winWindowProc - WM_CREATE\n");
-#endif
/*
* Add a property to our display window that references
@@ -155,7 +153,7 @@ winWindowProc (HWND hwnd, UINT message,
s_pScreenPriv->hwndScreen = hwnd;
- winInitNotifyIcon (s_pScreenPriv);
+ winInitNotifyIcon (s_pScreenPriv,FALSE);
}
return 0;
@@ -191,13 +189,13 @@ winWindowProc (HWND hwnd, UINT message,
break;
}
- ErrorF ("winWindowProc - WM_DISPLAYCHANGE - orig bpp: %d, last bpp: %d, "
+ winDebug ("winWindowProc - WM_DISPLAYCHANGE - orig bpp: %d, last bpp: %d, "
"new bpp: %d\n",
(int) s_pScreenInfo->dwBPP,
(int) s_pScreenPriv->dwLastWindowsBitsPixel,
wParam);
- ErrorF ("winWindowProc - WM_DISPLAYCHANGE - new width: %d "
+ winDebug ("winWindowProc - WM_DISPLAYCHANGE - new width: %d "
"new height: %d\n",
LOWORD (lParam), HIWORD (lParam));
@@ -237,7 +235,7 @@ winWindowProc (HWND hwnd, UINT message,
))
{
/* Cannot display the visual until the depth is restored */
- ErrorF ("winWindowProc - Disruptive change in depth\n");
+ winDebug ("winWindowProc - Disruptive change in depth\n");
/* Display Exit dialog */
winDisplayDepthChangeDialog (s_pScreenPriv);
@@ -270,25 +268,19 @@ winWindowProc (HWND hwnd, UINT message,
* relevant to the current engine (e.g., Shadow GDI).
*/
-#if CYGDEBUG
winDebug ("winWindowProc - WM_DISPLAYCHANGE - Dimensions changed\n");
-#endif
/* Release the old primary surface */
(*s_pScreenPriv->pwinReleasePrimarySurface) (s_pScreen);
-#if CYGDEBUG
winDebug ("winWindowProc - WM_DISPLAYCHANGE - Released "
"primary surface\n");
-#endif
/* Create the new primary surface */
(*s_pScreenPriv->pwinCreatePrimarySurface) (s_pScreen);
-#if CYGDEBUG
winDebug ("winWindowProc - WM_DISPLAYCHANGE - Recreated "
"primary surface\n");
-#endif
#if 0
/* Multi-Window mode uses RandR for resizes */
@@ -300,10 +292,8 @@ winWindowProc (HWND hwnd, UINT message,
}
else
{
-#if CYGDEBUG
winDebug ("winWindowProc - WM_DISPLAYCHANGE - Dimensions did not "
"change\n");
-#endif
}
/* Store the new display dimensions and depth */
@@ -331,9 +321,7 @@ winWindowProc (HWND hwnd, UINT message,
RECT rcWindow;
int iWidth, iHeight;
-#if CYGDEBUG
winDebug ("winWindowProc - WM_SIZE\n");
-#endif
/* Break if we do not use scrollbars */
if (!s_pScreenInfo->fScrollbars
@@ -369,7 +357,7 @@ winWindowProc (HWND hwnd, UINT message,
iWidth = rcWindow.right - rcWindow.left;
iHeight = rcWindow.bottom - rcWindow.top;
- ErrorF ("winWindowProc - WM_SIZE - window w: %d h: %d, "
+ winDebug ("winWindowProc - WM_SIZE - window w: %d h: %d, "
"new client area w: %d h: %d\n",
iWidth, iHeight, LOWORD (lParam), HIWORD (lParam));
@@ -433,9 +421,7 @@ winWindowProc (HWND hwnd, UINT message,
SCROLLINFO si;
int iVertPos;
-#if CYGDEBUG
winDebug ("winWindowProc - WM_VSCROLL\n");
-#endif
/* Get vertical scroll bar info */
si.cbSize = sizeof (si);
@@ -518,9 +504,7 @@ winWindowProc (HWND hwnd, UINT message,
SCROLLINFO si;
int iHorzPos;
-#if CYGDEBUG
winDebug ("winWindowProc - WM_HSCROLL\n");
-#endif
/* Get horizontal scroll bar info */
si.cbSize = sizeof (si);
@@ -604,10 +588,8 @@ winWindowProc (HWND hwnd, UINT message,
int iCaptionHeight;
int iBorderHeight, iBorderWidth;
-#if CYGDEBUG
winDebug ("winWindowProc - WM_GETMINMAXINFO - pScreenInfo: %08x\n",
s_pScreenInfo);
-#endif
/* Can't do anything without screen info */
if (s_pScreenInfo == NULL
@@ -650,9 +632,7 @@ winWindowProc (HWND hwnd, UINT message,
return 0;
case WM_ERASEBKGND:
-#if CYGDEBUG
winDebug ("winWindowProc - WM_ERASEBKGND\n");
-#endif
/*
* Pretend that we did erase the background but we don't care,
* the application uses the full window estate. This avoids some
@@ -661,9 +641,7 @@ winWindowProc (HWND hwnd, UINT message,
return TRUE;
case WM_PAINT:
-#if CYGDEBUG
winDebug ("winWindowProc - WM_PAINT\n");
-#endif
/* Only paint if we have privates and the server is enabled */
if (s_pScreenPriv == NULL
|| !s_pScreenPriv->fEnabled
@@ -684,9 +662,7 @@ winWindowProc (HWND hwnd, UINT message,
case WM_PALETTECHANGED:
{
-#if CYGDEBUG
winDebug ("winWindowProc - WM_PALETTECHANGED\n");
-#endif
/*
* Don't process if we don't have privates or a colormap,
* or if we have an invalid depth.
@@ -954,9 +930,7 @@ winWindowProc (HWND hwnd, UINT message,
case WM_MOUSEWHEEL:
if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
break;
-#if CYGDEBUG
winDebug ("winWindowProc - WM_MOUSEWHEEL\n");
-#endif
winMouseWheel (s_pScreen, GET_WHEEL_DELTA_WPARAM(wParam));
break;
@@ -1014,7 +988,7 @@ winWindowProc (HWND hwnd, UINT message,
* user enters Alt + F4 and is surprised when the application
* quits.
*/
- ErrorF ("winWindowProc - WM_*KEYDOWN - Closekey hit, quitting\n");
+ winDebug ("winWindowProc - WM_*KEYDOWN - Closekey hit, quitting\n");
/* Display Exit dialog */
winDisplayExitDialog (s_pScreenPriv);
@@ -1107,7 +1081,7 @@ winWindowProc (HWND hwnd, UINT message,
/* TODO: Override display of window when we have a bad depth */
if (LOWORD(wParam) != WA_INACTIVE && s_pScreenPriv->fBadDepth)
{
- ErrorF ("winWindowProc - WM_ACTIVATE - Bad depth, trying "
+ winDebug ("winWindowProc - WM_ACTIVATE - Bad depth, trying "
"to override window activation\n");
/* Minimize the window */
@@ -1129,9 +1103,7 @@ winWindowProc (HWND hwnd, UINT message,
return 0;
}
-#if CYGDEBUG
winDebug ("winWindowProc - WM_ACTIVATE\n");
-#endif
/*
* Focus is being changed to another window.
@@ -1157,9 +1129,7 @@ winWindowProc (HWND hwnd, UINT message,
|| s_pScreenInfo->fIgnoreInput)
break;
-#if CYGDEBUG || TRUE
winDebug ("winWindowProc - WM_ACTIVATEAPP\n");
-#endif
/* Activate or deactivate */
s_pScreenPriv->fActive = wParam;
@@ -1247,7 +1217,7 @@ winWindowProc (HWND hwnd, UINT message,
#ifdef XWIN_MULTIWINDOWEXTWM
case WM_MANAGE:
- ErrorF ("winWindowProc - WM_MANAGE\n");
+ winDebug ("winWindowProc - WM_MANAGE\n");
s_pScreenInfo->fAnotherWMRunning = FALSE;
if (s_pScreenInfo->fInternalWM)
@@ -1258,7 +1228,7 @@ winWindowProc (HWND hwnd, UINT message,
break;
case WM_UNMANAGE:
- ErrorF ("winWindowProc - WM_UNMANAGE\n");
+ winDebug ("winWindowProc - WM_UNMANAGE\n");
s_pScreenInfo->fAnotherWMRunning = TRUE;
if (s_pScreenInfo->fInternalWM)
@@ -1272,7 +1242,7 @@ winWindowProc (HWND hwnd, UINT message,
default:
if(message == s_uTaskbarRestart)
{
- winInitNotifyIcon (s_pScreenPriv);
+ winInitNotifyIcon (s_pScreenPriv,FALSE);
}
break;
}
diff --git a/xorg-server/hw/xwin/xlaunch/config.h b/xorg-server/hw/xwin/xlaunch/config.h
index f0aed3cf1..8448c54a4 100644
--- a/xorg-server/hw/xwin/xlaunch/config.h
+++ b/xorg-server/hw/xwin/xlaunch/config.h
@@ -22,39 +22,55 @@
* Except as contained in this notice, the name(s) of the above copyright
* holders shall not be used in advertising or otherwise to promote the sale,
* use or other dealings in this Software without prior written authorization.
+ *
+ * Authors: Alexander Gottwald, Colin Harrison
*/
#ifndef __CONFIG_H__
#define __CONFIG_H__
+#define UNICODE
+#define _UNICODE
+
+#define PROG_NUMBER 10
+#define HOST_NUMBER 10
+#define MAX_MESSAGE 256
+#define MAX_CAPTION 128
+#include <windows.h>
#include <string>
+#include <vector>
struct CConfig
{
enum {MultiWindow, Fullscreen, Windowed, Nodecoration} window;
enum {NoClient, StartProgram, XDMCP} client;
+ enum {NoXClient, Local, PuTTY, OpenSSH} clientstart;
bool local;
std::string display;
std::string protocol;
+ std::string protocol_path;
std::string program;
+ std::vector<std::string> progs;
+ bool compress;
std::string host;
std::string user;
+ std::string password;
+ bool password_save;
+ bool password_start;
bool broadcast;
bool indirect;
std::string xdmcp_host;
+ std::vector<std::string> xhosts;
bool clipboard;
+ bool no_access_control;
+ std::string font_server;
std::string extra_params;
-#ifdef _DEBUG
- CConfig() : window(MultiWindow), client(StartProgram), local(false), display("1"),
- protocol("Putty"), program("xterm"), host("lupus"), user("ago"),
- broadcast(false), indirect(false), xdmcp_host("lupus"),
- clipboard(true), extra_params() {};
-#else
- CConfig() : window(MultiWindow), client(StartProgram), local(false), display("0"),
- protocol("Putty"), program("xterm"), host(""), user(""),
- broadcast(true), indirect(false), xdmcp_host(""),
- clipboard(true), extra_params() {};
-#endif
- void Load(const char* filename);
- void Save(const char* filename);
+ std::string extra_ssh;
+ CConfig() : window(MultiWindow), client(NoClient), clientstart(NoXClient), display("0"),
+ protocol_path(""), program("xeyes"), progs(PROG_NUMBER), compress(false), host(""), user(""),
+ password(""), password_save(false), password_start(false), broadcast(false),
+ indirect(false), xdmcp_host(""), xhosts(HOST_NUMBER), clipboard(true), no_access_control(false),
+ font_server(), extra_params(), extra_ssh() {};
+ void Load(const char * filename);
+ void Save(const char * filename);
};
#endif
diff --git a/xorg-server/hw/xwin/xlaunch/main.cc b/xorg-server/hw/xwin/xlaunch/main.cc
index 2247d3aaf..d20b788d7 100644
--- a/xorg-server/hw/xwin/xlaunch/main.cc
+++ b/xorg-server/hw/xwin/xlaunch/main.cc
@@ -23,6 +23,10 @@
* holders shall not be used in advertising or otherwise to promote the sale,
* use or other dealings in this Software without prior written authorization.
*/
+
+#define printf _not_used_ /* Make sure that we do not use the standard printf definition because
+ we are going to reimplement it in this file */
+
#include "window/util.h"
#include "window/wizard.h"
#include "resources/resources.h"
@@ -34,6 +38,68 @@
#include <X11/Xlib.h>
+#ifdef _MSC_VER
+#define snprintf _snprintf
+#endif
+#include <fcntl.h>
+#include <io.h>
+#undef printf
+
+#if defined(_MSC_VER) && defined(_DLL)
+#define _CRTEXP __declspec(dllexport)
+#else
+#define _CRTEXP
+#endif
+
+_Check_return_opt_ _CRTEXP int __cdecl printf(_In_z_ _Printf_format_string_ const char * pFmt, ...)
+{
+ static int ConsoleCreated=0;
+ va_list arglist;
+ if (!ConsoleCreated)
+ {
+ int hConHandle;
+ long lStdHandle;
+ CONSOLE_SCREEN_BUFFER_INFO coninfo;
+
+ FILE *fp;
+ const unsigned int MAX_CONSOLE_LINES = 500;
+ ConsoleCreated=1;
+ if (!AttachConsole(ATTACH_PARENT_PROCESS))
+ AllocConsole();
+
+ // set the screen buffer to be big enough to let us scroll text
+ GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
+ coninfo.dwSize.Y = MAX_CONSOLE_LINES;
+ SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize);
+
+ // redirect unbuffered STDOUT to the console
+ lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
+ hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
+ fp = _fdopen( hConHandle, "w" );
+ *stdout = *fp;
+ setvbuf( stdout, NULL, _IONBF, 0 );
+
+ // redirect unbuffered STDIN to the console
+ lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE);
+ hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
+ fp = _fdopen( hConHandle, "r" );
+ *stdin = *fp;
+ setvbuf( stdin, NULL, _IONBF, 0 );
+
+ // redirect unbuffered STDERR to the console
+ lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
+ hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
+ fp = _fdopen( hConHandle, "w" );
+ *stderr = *fp;
+ setvbuf( stderr, NULL, _IONBF, 0 );
+
+ }
+
+ va_start(arglist, pFmt );
+ return vfprintf(stderr, pFmt, arglist);
+}
+
+
/// @brief Send WM_ENDSESSION to all program windows.
/// This will shutdown the started xserver
BOOL CALLBACK KillWindowsProc(HWND hwnd, LPARAM lParam)
@@ -108,7 +174,10 @@ class CMyWizard : public CWizard
}
// Check for valid input
if (config.display.empty())
+ {
+ MessageBox(hwndDlg,"Please fill in a display number.","Error",MB_OK);
SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
+ }
else
SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_CLIENTS);
return TRUE;
@@ -489,7 +558,7 @@ class CMyWizard : public CWizard
return NULL;
}
- /// @brief Do the actual start of Xming and clients
+ /// @brief Do the actual start of VCXsrv and clients
void StartUp()
{
std::string buffer;
@@ -500,12 +569,12 @@ class CMyWizard : public CWizard
std::string display = "localhost" + display_id + ":0";
#ifdef _DEBUG
- // Debug only: Switch to Xming installation directory
- SetCurrentDirectory("C:\\Programme\\Xming");
+ // Debug only: Switch to VCXsrv installation directory
+ SetCurrentDirectory("C:\\Programme\\vcxsrv");
#endif
- // Build Xming commandline
- buffer = "Xming " + display_id + " ";
+ // Build Xsrv commandline
+ buffer = "vcxsrv " + display_id + " ";
switch (config.window)
{
case CConfig::MultiWindow:
@@ -577,7 +646,7 @@ class CMyWizard : public CWizard
sic.cb = sizeof(sic);
ZeroMemory( &pic, sizeof(pic) );
- // Start Xming process.
+ // Start VCXsrv process.
#ifdef _DEBUG
printf("%s\n", buffer.c_str());
#endif
@@ -627,7 +696,7 @@ class CMyWizard : public CWizard
#ifdef _DEBUG
printf("killing process!\n");
#endif
- // Check if Xming is still running
+ // Check if Xsrv is still running
DWORD exitcode;
GetExitCodeProcess(pi.hProcess, &exitcode);
unsigned counter = 0;
@@ -636,7 +705,7 @@ class CMyWizard : public CWizard
if (++counter > 10)
TerminateProcess(pi.hProcess, (DWORD)-1);
else
- // Shutdown Xming (the soft way!)
+ // Shutdown Xsrv (the soft way!)
EnumThreadWindows(pi.dwThreadId, KillWindowsProc, 0);
Sleep(500);
GetExitCodeProcess(pi.hProcess, &exitcode);
@@ -694,7 +763,3 @@ int main(int argc, char **argv)
return -1;
}
}
-
-
-
-
diff --git a/xorg-server/hw/xwin/xlaunch/makefile b/xorg-server/hw/xwin/xlaunch/makefile
index f7cf923df..63b37dd1b 100644
--- a/xorg-server/hw/xwin/xlaunch/makefile
+++ b/xorg-server/hw/xwin/xlaunch/makefile
@@ -1,79 +1,32 @@
-#
-# Copyright (c) 2005 Alexander Gottwald
-#
-# 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, 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 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 ABOVE LISTED COPYRIGHT HOLDER(S) 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(s) of the above copyright
-# holders shall not be used in advertising or otherwise to promote the sale,
-# use or other dealings in this Software without prior written authorization.
-#
-WINDRES=windres
-
-TARGET=mingw
-#DEBUG_FLAGS=-D_DEBUG
-
-OS_FLAGS_mingw=-mno-cygwin
-OS_FLAGS=$(OS_FLAGS_$(TARGET)) $(DEBUG_FLAGS)
-
-X11_DIR_$(TARGET)=/usr/X11R6
-X11_DIR_mingw=../../../../../exports
-X11_DIR=$(X11_DIR_$(TARGET))
-X11_INCLUDE=-I$(X11_DIR)/include
-X11_LIBDIR=-L$(X11_DIR)/lib
-X11_LIBS_$(TARGET)=-lX11
-X11_LIBS_mingw=-lX11 -lwsock32
-X11_LIBS=$(X11_LIBS_$(TARGET))
-
-PROGRAMFILES:=$(shell cygpath -u $(PROGRAMFILES))
-#MSXML_DIR=$(PROGRAMFILES)/MSXML 4.0
-MSXML_DIR=$(PROGRAMFILES)/Microsoft XML Parser SDK
-MSXML_INCLUDE="-I$(MSXML_DIR)/inc"
-MSXML_LIBDIR="-L$(MSXML_DIR)/lib"
-MSXML_LIBS=
-
-
-CXXFLAGS=-g $(OS_FLAGS) $(X11_INCLUDE) $(MSXML_INCLUDE)
-LDFLAGS=-mwindows $(X11_LIBDIR) $(MSXML_LIBDIR)
-LIBS=-lcomctl32 -lole32 -loleaut32 $(X11_LIBS) $(MSXML_LIBS)
-all:xlaunch.exe
-%.res: %.rc
- $(WINDRES) -O coff -o $@ $<
-
-WINDOW_PARTS=window util dialog wizard
-WINDOW_OBJECTS=$(foreach file,$(WINDOW_PARTS),window/$(file).o)
-
-RESOURCES_IMAGES=resources/multiwindow.bmp resources/fullscreen.bmp \
- resources/windowed.bmp resources/nodecoration.bmp
-
-resources/resources.res: resources/resources.rc resources/resources.h \
- resources/images.rc resources/dialog.rc resources/strings.rc \
- $(RESOURCES_IMAGES)
-xlaunch.exe: $(WINDOW_OBJECTS) main.o config.o resources/resources.res
- $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
-
-
-window/dialog.o: window/dialog.cc window/dialog.h window/window.h window/util.h
-window/frame.o: window/frame.cc window/frame.h window/window.h
-window/util.o: window/util.cc window/util.h
-window/window.o: window/window.cc window/window.h window/util.h
-window/wizard.o: window/wizard.cc window/wizard.h window/dialog.h \
- window/window.h window/util.h
-main.o: main.cc window/util.h window/wizard.h window/dialog.h \
- window/window.h resources/resources.h config.h
-config.o: config.cc config.h
+INCLUDELIBFILES = window\$(OBJDIR)\window.lib \
+ $(MHMAKECONF)\libx11\src\$(OBJDIR)\libx11.lib \
+ $(MHMAKECONF)\libxcb\src\$(OBJDIR)\libxcb.lib \
+ $(MHMAKECONF)\libxau\$(OBJDIR)\libxau.lib \
+ $(MHMAKECONF)\libx11\src\xlibi18n\$(OBJDIR)\libi18n.lib \
+ $(MHMAKECONF)\libx11\modules\lc\xlocale\$(OBJDIR)\libxlocale.lib \
+ $(MHMAKECONF)\libx11\modules\lc\utf8\$(OBJDIR)\libxlcUTF8Load.lib \
+ $(MHMAKECONF)\libx11\modules\lc\gen\$(OBJDIR)\liblcGenConvLoad.lib \
+ $(MHMAKECONF)\libx11\modules\lc\def\$(OBJDIR)\libxlcDef.lib \
+ $(MHMAKECONF)\libx11\src\xkb\$(OBJDIR)\libxkb.lib \
+ $(MHMAKECONF)\libx11\modules\im\ximcp\$(OBJDIR)\libximcp.lib \
+ $(MHMAKECONF)\libx11\modules\om\generic\$(OBJDIR)\libxomGeneric.lib
+
+CSRCS=config.cc main.cc
+
+WINAPP = xlaunch
+
+RESOURCES = resources.rc
+
+$(OBJDIR)\%.res : resources\%.rc
+ $(RC) $(RCFLAGS) $(RCDEFINES:%=-d "%") $(RCINCLUDES:%=-i %) -Fo$(relpath $@) $<
+
+LIBDIRS=$(dir $(INCLUDELIBFILES))
+
+load_makefile $(LIBDIRS:%$(OBJDIR)\=%makefile MAKESERVER=$(MAKESERVER) DEBUG=$(DEBUG);)
+
+ifeq ($(DEBUG),1)
+LINKLIBS += $(MHMAKECONF)\pthreads\pthreadVC2d.lib
+else
+LINKLIBS += $(MHMAKECONF)\pthreads\pthreadVC2.lib
+endif
+
diff --git a/xorg-server/hw/xwin/xlaunch/resources/resources.h b/xorg-server/hw/xwin/xlaunch/resources/resources.h
index 470005192..15e733844 100644
--- a/xorg-server/hw/xwin/xlaunch/resources/resources.h
+++ b/xorg-server/hw/xwin/xlaunch/resources/resources.h
@@ -35,6 +35,8 @@
#define IDD_FONTPATH 106
#define IDD_CLIPBOARD 107
+#define IDI_XLAUNCH 108
+
#define IDS_DISPLAY_TITLE 300
#define IDS_DISPLAY_SUBTITLE 301
#define IDS_CLIENTS_TITLE 302
diff --git a/xorg-server/hw/xwin/xlaunch/resources/resources.rc b/xorg-server/hw/xwin/xlaunch/resources/resources.rc
index 07fd52f32..e3df4610a 100644
--- a/xorg-server/hw/xwin/xlaunch/resources/resources.rc
+++ b/xorg-server/hw/xwin/xlaunch/resources/resources.rc
@@ -28,3 +28,5 @@
#include "resources.h"
#include "images.rc"
#include "dialog.rc"
+
+IDI_XLAUNCH ICON "..\\..\\X.ico"
diff --git a/xorg-server/hw/xwin/xlaunch/resources/strings.rc b/xorg-server/hw/xwin/xlaunch/resources/strings.rc
index 5a9cd281b..94db96659 100644
--- a/xorg-server/hw/xwin/xlaunch/resources/strings.rc
+++ b/xorg-server/hw/xwin/xlaunch/resources/strings.rc
@@ -60,15 +60,15 @@
#define STR_CAPTION_CLIPBOARD "Clipboard settings"
#define STR_CLIPBOARD "Clipboard"
#define STR_CLIPBOARD_DESC "Start the integrated clipboard manager"
-#define STR_EXTRA_PARAMS_DESC "Additional parameters for Xming"
+#define STR_EXTRA_PARAMS_DESC "Additional parameters for VcXsrv"
#define STR_CAPTION_FINISH "Finish configuration"
-#define STR_FINISH_DESC "Configuration is complete. Clish Finish to start Xming."
+#define STR_FINISH_DESC "Configuration is complete. Clish Finish to start VcXsrv."
#define STR_FINISH_SAVE_DESC "You may also save the configuration for later use."
#define STR_FINISH_SAVE "Save configuration"
#define STR_DISPLAY_TITLE "Select display settings"
-#define STR_DISPLAY_SUBTITLE "Choose how Xming display programs"
+#define STR_DISPLAY_SUBTITLE "Choose how VcXsrv display programs"
#define STR_CLIENTS_TITLE "Select how to start clients"
#define STR_CLIENTS_SUBTITLE ""
#define STR_PROGRAM_TITLE "Specify the program to start"
diff --git a/xorg-server/hw/xwin/xlaunch/window/makefile b/xorg-server/hw/xwin/xlaunch/window/makefile
new file mode 100644
index 000000000..18a33e728
--- /dev/null
+++ b/xorg-server/hw/xwin/xlaunch/window/makefile
@@ -0,0 +1,4 @@
+CSRCS=dialog.cc util.cc window.cc wizard.cc
+
+LIBRARY = window
+
diff --git a/xorg-server/hw/xwin/xlaunch/window/util.cc b/xorg-server/hw/xwin/xlaunch/window/util.cc
index fb7e87297..6f768348e 100644
--- a/xorg-server/hw/xwin/xlaunch/window/util.cc
+++ b/xorg-server/hw/xwin/xlaunch/window/util.cc
@@ -25,6 +25,8 @@
*/
#include "util.h"
+const char * MessageDebug::notify_names[NOTIFY_NAMES_LEN];
+
std::string win32_error::message(DWORD errorcode)
{
LPVOID lpMsgBuf;
diff --git a/xorg-server/hw/xwin/xlaunch/window/util.h b/xorg-server/hw/xwin/xlaunch/window/util.h
index cd21da657..a1196b115 100644
--- a/xorg-server/hw/xwin/xlaunch/window/util.h
+++ b/xorg-server/hw/xwin/xlaunch/window/util.h
@@ -28,7 +28,7 @@
#include <windows.h>
#include <stdexcept>
-
+#include <string>
class win32_error : public std::runtime_error
{
@@ -39,7 +39,7 @@ class win32_error : public std::runtime_error
};
#define MESSAGE_NAMES_LEN 1024
-#define NOTIFY_NAMES_LEN 0
+#define NOTIFY_NAMES_LEN 1
class MessageDebug
{
protected:
diff --git a/xorg-server/hw/xwin/xlaunch/window/wizard.h b/xorg-server/hw/xwin/xlaunch/window/wizard.h
index a2361c51c..c576cc093 100644
--- a/xorg-server/hw/xwin/xlaunch/window/wizard.h
+++ b/xorg-server/hw/xwin/xlaunch/window/wizard.h
@@ -29,7 +29,6 @@
#include "dialog.h"
#include <vector>
-#define _WIN32_IE 0x0500
#include <prsht.h>
class CWizard : public CBaseDialog